Fixes #304 ("Usage of boost::container::small_vector with custom allocator")

This commit is contained in:
Ion Gaztañaga
2025-10-27 23:55:05 +01:00
parent 2170155cb9
commit 247ffd0336
3 changed files with 12 additions and 5 deletions

View File

@@ -1434,7 +1434,7 @@ use [*Boost.Container]? There are several reasons for that:
[section:release_notes Release Notes]
[section:release_notes_boost_1_90_00 Boost Release]
[section:release_notes_boost_1_90_00 Boost 1.90 Release]
* Reimplemented [classref boost::container::deque]. The original implementation was based on
the SGI's original data structure (similar to libstdc++). Main changes:
@@ -1450,6 +1450,7 @@ use [*Boost.Container]? There are several reasons for that:
* [@https://github.com/boostorg/container/pull/317/ GitHub #293: ['"UBSAN reports unaligned access error"]].
* [@https://github.com/boostorg/container/pull/294 GitHub #294: ['"CMake: Add option to use header-only Boost::container"]].
* [@https://github.com/boostorg/container/issues/300 GitHub #300: ['"Warnings when building with clang-20"]].
* [@https://github.com/boostorg/container/issues/300 GitHub #304: ['"Usage of boost::container::small_vector with custom allocator"]].
* [@https://github.com/boostorg/container/pull/305 GitHub #305: ['"Warnings with -Wstrict-prototypes"]].
* [@https://github.com/boostorg/container/pull/307 GitHub #307: ['"Fix all instances of MSVC warning C4146 (unsigned negation)"]].
* [@https://github.com/boostorg/container/issues/309 GitHub #309: ['"Performance regression of boost::container::static_vector introduced in boost v1.86"]].

View File

@@ -127,10 +127,11 @@ class small_vector_allocator
{
typedef unsigned int allocation_type;
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
private:
public:
typedef typename allocator_traits<VoidAlloc>::template portable_rebind_alloc<T>::type allocator_type;
private:
BOOST_COPYABLE_AND_MOVABLE(small_vector_allocator)
inline const allocator_type &as_base() const BOOST_NOEXCEPT
@@ -353,7 +354,8 @@ class small_vector_base
typedef typename real_allocator<T, SecAlloc>::type underlying_allocator_t;
typedef typename allocator_traits<underlying_allocator_t>::
template portable_rebind_alloc<void>::type void_underlying_allocator_t;
typedef small_vector_allocator<T, void_underlying_allocator_t, Options>allocator_type;
typedef typename small_vector_allocator
<T, void_underlying_allocator_t, Options>::allocator_type allocator_type;
typedef typename dtl::get_small_vector_opt<Options>::type options_t;
typedef typename dtl::vector_for_small_vector
<T, SecAlloc, Options>::type base_type;
@@ -548,6 +550,7 @@ class small_vector
BOOST_COPYABLE_AND_MOVABLE(small_vector)
public:
typedef dtl::true_type is_partially_propagable;
typedef small_vector_base<T, Allocator, Options> base_type;
typedef typename base_type::allocator_type allocator_type;
typedef typename base_type::size_type size_type;

View File

@@ -626,8 +626,11 @@ int vector_test()
if(!test::CheckEqualContainers(*boostvectorp2, *stdvectorp)) return 1;
}
if (0 != vector_test_fully_propagable<MyBoostVector>
( dtl::bool_< !allocator_traits<typename MyBoostVector::allocator_type>::is_partially_propagable::value >() )) return 1;
typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::dtl::, MyBoostVector,
is_partially_propagable, dtl::false_type)
is_partially_propagable_t;
if (0 != vector_test_fully_propagable<MyBoostVector>( dtl::bool_< !is_partially_propagable_t::value >() )) return 1;
if (0 != vector_move_assignable_only< MyBoostVector>(dtl::bool_<boost::container::test::is_move_assignable<IntType>::value>()))
return 1;