Skip to content

Commit 9d78d55

Browse files
committed
Remove max_size_workaround()
Reason: I checked the three major standard library implementations and they all take the allocator into account in max_size(), so the workaround should be no longer necessary.
1 parent 7d8a9d4 commit 9d78d55

File tree

2 files changed

+3
-36
lines changed

2 files changed

+3
-36
lines changed

include/boost/dynamic_bitset/detail/dynamic_bitset.hpp

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <memory>
2121
#include <type_traits>
2222
#include <utility>
23-
#include <vector>
2423

2524
namespace boost {
2625

@@ -83,36 +82,6 @@ struct value_to_type
8382
{
8483
};
8584

86-
// Some library implementations simply return a dummy
87-
// value such as
88-
//
89-
// size_type(-1) / sizeof(T)
90-
//
91-
// from vector<>::max_size. This tries to get more
92-
// meaningful info.
93-
//
94-
template< typename T, typename Allocator >
95-
BOOST_DYNAMIC_BITSET_CONSTEXPR20 typename std::vector< T, Allocator >::size_type
96-
max_size_workaround( const std::vector< T, Allocator > & v ) noexcept
97-
{
98-
typedef typename std::vector< T, Allocator >::allocator_type allocator_type;
99-
100-
const allocator_type & alloc = v.get_allocator();
101-
102-
const typename std::allocator_traits< allocator_type >::size_type alloc_max =
103-
std::allocator_traits< allocator_type >::max_size( alloc );
104-
105-
const typename std::vector< T, Allocator >::size_type container_max = v.max_size();
106-
return alloc_max < container_max ? alloc_max : container_max;
107-
}
108-
109-
template< typename Container >
110-
BOOST_DYNAMIC_BITSET_CONSTEXPR20 typename Container::size_type
111-
max_size_workaround( const Container & c ) noexcept
112-
{
113-
return c.max_size();
114-
}
115-
11685
// for static_asserts
11786
template< typename T >
11887
struct allowed_block_type

include/boost/dynamic_bitset/impl/dynamic_bitset.ipp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,15 +1275,13 @@ BOOST_DYNAMIC_BITSET_CONSTEXPR20 typename dynamic_bitset< Block, AllocatorOrCont
12751275
dynamic_bitset< Block, AllocatorOrContainer >::max_size() const noexcept
12761276
{
12771277
// The semantics of vector<>::max_size() aren't very clear (see lib
1278-
// issue 197) and many library implementations simply return dummy
1279-
// values, _unrelated_ to the underlying allocator.
1278+
// issue 197).
12801279
//
1281-
// Given these problems, I was tempted to not provide this function
1280+
// Because of that, I was tempted to not provide this function
12821281
// at all, but the user could need it if they provide their own
12831282
// allocator.
12841283

1285-
const size_type m = detail::dynamic_bitset_impl::
1286-
max_size_workaround( m_bits );
1284+
const size_type m = m_bits.max_size();
12871285

12881286
return m <= ( size_type( -1 ) / bits_per_block ) ? m * bits_per_block : size_type( -1 );
12891287
}

0 commit comments

Comments
 (0)