Skip to content

Commit c015e21

Browse files
committed
Deprecate the names "find_first", "find_first_off", "find_next", "find_next_off"
Reason: Some people expressed a dislike for the name "find_first_off", saying it causes confusion with "find_first_of" (although a find_first_of() wouldn't make much sense for a bitset), so we choose a new set of consistent names: find_first() → find_first_one() find_first_off() → find_first_zero() find_next() → find_next_one() find_next_off() → find_next_zero() .
1 parent 9b64641 commit c015e21

File tree

4 files changed

+62
-14
lines changed

4 files changed

+62
-14
lines changed

include/boost/dynamic_bitset/dynamic_bitset.hpp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,11 @@ class dynamic_bitset
12491249
// -----------------------------------------------------------------------
12501250
BOOST_DYNAMIC_BITSET_CONSTEXPR20 bool intersects( const dynamic_bitset & b ) const;
12511251

1252+
//! A deprecated synonym for `find_first_one()`.
1253+
// -----------------------------------------------------------------------
1254+
[[ deprecated ]]
1255+
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_first( size_type pos = 0 ) const;
1256+
12521257
//! Finds the first set bit in `*this` with an index >= `pos`,
12531258
//! if any.
12541259
//!
@@ -1260,8 +1265,13 @@ class dynamic_bitset
12601265
//! \par Throws
12611266
//! Nothing.
12621267
// -----------------------------------------------------------------------
1263-
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_first( size_type pos = 0 ) const;
1268+
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_first_one( size_type pos = 0 ) const;
12641269

1270+
//! A deprecated synonym for `find_first_zero()`.
1271+
// -----------------------------------------------------------------------
1272+
[[ deprecated ]]
1273+
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_first_off( size_type pos = 0 ) const;
1274+
12651275
//! Finds the first unset bit in `*this` with an index >= `pos`,
12661276
//! if any.
12671277
//!
@@ -1276,7 +1286,12 @@ class dynamic_bitset
12761286
//! \par Throws
12771287
//! Nothing.
12781288
// -----------------------------------------------------------------------
1279-
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_first_off( size_type pos = 0 ) const;
1289+
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_first_zero( size_type pos = 0 ) const;
1290+
1291+
//! A deprecated synonym for `find_next_one()`.
1292+
// -----------------------------------------------------------------------
1293+
[[deprecated]]
1294+
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_next( size_type pos ) const;
12801295

12811296
//! Finds the first bit set in `*this` with an index > `pos`, if
12821297
//! any.
@@ -1291,7 +1306,12 @@ class dynamic_bitset
12911306
//! \par Throws
12921307
//! Nothing.
12931308
// -----------------------------------------------------------------------
1294-
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_next( size_type pos ) const;
1309+
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_next_one( size_type pos ) const;
1310+
1311+
//! A deprecated synonym for `find_next_zero()`.
1312+
// -----------------------------------------------------------------------
1313+
[[ deprecated ]]
1314+
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_next_off( size_type pos ) const;
12951315

12961316
//! Finds the first unset bit in `*this` with an index > `pos`,
12971317
//! if any.
@@ -1303,7 +1323,7 @@ class dynamic_bitset
13031323
//! The lowest index `i` greater than `pos` such that bit `i` is
13041324
//! unset, or `npos` if no such index exists.
13051325
// -----------------------------------------------------------------------
1306-
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_next_off( size_type pos ) const;
1326+
BOOST_DYNAMIC_BITSET_CONSTEXPR20 size_type find_next_zero( size_type pos ) const;
13071327

13081328
template< typename B, typename A >
13091329
friend BOOST_DYNAMIC_BITSET_CONSTEXPR20 bool operator==( const dynamic_bitset< B, A > & a, const dynamic_bitset< B, A > & b );

include/boost/dynamic_bitset/impl/dynamic_bitset.ipp

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,7 @@ dynamic_bitset< Block, AllocatorOrContainer >::
12071207

12081208
// Check for overflows. This may be a performance burden on very large
12091209
// bitsets but is required by the specification, sorry.
1210-
if ( find_first( ulong_width ) != npos ) {
1210+
if ( find_first_one( ulong_width ) != npos ) {
12111211
BOOST_THROW_EXCEPTION( std::overflow_error( "boost::dynamic_bitset::to_ulong overflow" ) );
12121212
}
12131213

@@ -1392,6 +1392,13 @@ dynamic_bitset< Block, AllocatorOrContainer >::m_do_find_from( size_type first_b
13921392
template< typename Block, typename AllocatorOrContainer >
13931393
BOOST_DYNAMIC_BITSET_CONSTEXPR20 typename dynamic_bitset< Block, AllocatorOrContainer >::size_type
13941394
dynamic_bitset< Block, AllocatorOrContainer >::find_first( size_type pos ) const
1395+
{
1396+
return find_first_one( pos );
1397+
}
1398+
1399+
template< typename Block, typename AllocatorOrContainer >
1400+
BOOST_DYNAMIC_BITSET_CONSTEXPR20 typename dynamic_bitset< Block, AllocatorOrContainer >::size_type
1401+
dynamic_bitset< Block, AllocatorOrContainer >::find_first_one( size_type pos ) const
13951402
{
13961403
const size_type sz = size();
13971404
if ( pos >= sz ) {
@@ -1412,6 +1419,13 @@ dynamic_bitset< Block, AllocatorOrContainer >::find_first( size_type pos ) const
14121419
template< typename Block, typename AllocatorOrContainer >
14131420
BOOST_DYNAMIC_BITSET_CONSTEXPR20 typename dynamic_bitset< Block, AllocatorOrContainer >::size_type
14141421
dynamic_bitset< Block, AllocatorOrContainer >::find_first_off( size_type pos ) const
1422+
{
1423+
return find_first_zero( pos );
1424+
}
1425+
1426+
template< typename Block, typename AllocatorOrContainer >
1427+
BOOST_DYNAMIC_BITSET_CONSTEXPR20 typename dynamic_bitset< Block, AllocatorOrContainer >::size_type
1428+
dynamic_bitset< Block, AllocatorOrContainer >::find_first_zero( size_type pos ) const
14151429
{
14161430
if ( pos >= size() ) {
14171431
return npos;
@@ -1439,19 +1453,33 @@ dynamic_bitset< Block, AllocatorOrContainer >::find_first_off( size_type pos ) c
14391453
template< typename Block, typename AllocatorOrContainer >
14401454
BOOST_DYNAMIC_BITSET_CONSTEXPR20 typename dynamic_bitset< Block, AllocatorOrContainer >::size_type
14411455
dynamic_bitset< Block, AllocatorOrContainer >::find_next( size_type pos ) const
1456+
{
1457+
return find_next_one( pos );
1458+
}
1459+
1460+
template< typename Block, typename AllocatorOrContainer >
1461+
BOOST_DYNAMIC_BITSET_CONSTEXPR20 typename dynamic_bitset< Block, AllocatorOrContainer >::size_type
1462+
dynamic_bitset< Block, AllocatorOrContainer >::find_next_one( size_type pos ) const
14421463
{
14431464
return pos == npos
14441465
? npos
1445-
: find_first( pos + 1 );
1466+
: find_first_one( pos + 1 );
14461467
}
14471468

14481469
template< typename Block, typename AllocatorOrContainer >
14491470
BOOST_DYNAMIC_BITSET_CONSTEXPR20 typename dynamic_bitset< Block, AllocatorOrContainer >::size_type
14501471
dynamic_bitset< Block, AllocatorOrContainer >::find_next_off( size_type pos ) const
1472+
{
1473+
return find_next_zero( pos );
1474+
}
1475+
1476+
template< typename Block, typename AllocatorOrContainer >
1477+
BOOST_DYNAMIC_BITSET_CONSTEXPR20 typename dynamic_bitset< Block, AllocatorOrContainer >::size_type
1478+
dynamic_bitset< Block, AllocatorOrContainer >::find_next_zero( size_type pos ) const
14511479
{
14521480
return pos == npos
14531481
? npos
1454-
: find_first_off( pos + 1 );
1482+
: find_first_zero( pos + 1 );
14551483
}
14561484

14571485
//-----------------------------------------------------------------------------

test/bitset_test.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,8 +1091,8 @@ struct bitset_test
10911091
find_first( const Bitset & b, typename Bitset::size_type offset = 0, bool value = true )
10921092
{
10931093
const typename Bitset::size_type result = value
1094-
? b.find_first( offset )
1095-
: b.find_first_off( offset );
1094+
? b.find_first_one( offset )
1095+
: b.find_first_zero( offset );
10961096

10971097
// find first bit with value `value` from offset onwards, if any
10981098
typename Bitset::size_type i = offset;
@@ -1112,9 +1112,9 @@ struct bitset_test
11121112
{
11131113
find_first( b, pos, value);
11141114
if ( value ) {
1115-
BOOST_TEST( next_bit_on( b, pos ) == b.find_next( pos ) );
1115+
BOOST_TEST( next_bit_on( b, pos ) == b.find_next_one( pos ) );
11161116
} else {
1117-
BOOST_TEST( next_bit_off( b, pos ) == b.find_next_off( pos ) );
1117+
BOOST_TEST( next_bit_off( b, pos ) == b.find_next_zero( pos ) );
11181118
}
11191119
}
11201120

test/dyn_bitset_unit_tests3.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ run_test_cases()
299299
Tests::intersects( a, b );
300300
}
301301
//=====================================================================
302-
// Test find_first
302+
// Test find_first_one/find_first_zero
303303
{
304304
// empty bitset
305305
bitset_type b;
@@ -334,7 +334,7 @@ run_test_cases()
334334
Tests::find_first( b, 0, false );
335335
}
336336
//=====================================================================
337-
// Test find_next, find_next_off, offset find_first and offset find_first_off
337+
// Test find_next_one, find_next_zero
338338
{
339339
// empty bitset
340340
bitset_type b;
@@ -350,7 +350,7 @@ run_test_cases()
350350
Tests::find_pos( b, b.npos, false );
351351
}
352352
{
353-
// bitset of size 1 (find_next can never find)
353+
// bitset of size 1 (find_next_one or find_next_zero can never find)
354354
bitset_type b( 1, 1ul );
355355

356356
// check

0 commit comments

Comments
 (0)