Skip to content

Commit 247ffd0

Browse files
committed
Fixes #304 ("Usage of boost::container::small_vector with custom allocator")
1 parent 2170155 commit 247ffd0

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

doc/container.qbk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,7 @@ use [*Boost.Container]? There are several reasons for that:
14341434

14351435
[section:release_notes Release Notes]
14361436

1437-
[section:release_notes_boost_1_90_00 Boost Release]
1437+
[section:release_notes_boost_1_90_00 Boost 1.90 Release]
14381438

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

include/boost/container/small_vector.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,11 @@ class small_vector_allocator
127127
{
128128
typedef unsigned int allocation_type;
129129
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
130-
private:
131130

131+
public:
132132
typedef typename allocator_traits<VoidAlloc>::template portable_rebind_alloc<T>::type allocator_type;
133133

134+
private:
134135
BOOST_COPYABLE_AND_MOVABLE(small_vector_allocator)
135136

136137
inline const allocator_type &as_base() const BOOST_NOEXCEPT
@@ -353,7 +354,8 @@ class small_vector_base
353354
typedef typename real_allocator<T, SecAlloc>::type underlying_allocator_t;
354355
typedef typename allocator_traits<underlying_allocator_t>::
355356
template portable_rebind_alloc<void>::type void_underlying_allocator_t;
356-
typedef small_vector_allocator<T, void_underlying_allocator_t, Options>allocator_type;
357+
typedef typename small_vector_allocator
358+
<T, void_underlying_allocator_t, Options>::allocator_type allocator_type;
357359
typedef typename dtl::get_small_vector_opt<Options>::type options_t;
358360
typedef typename dtl::vector_for_small_vector
359361
<T, SecAlloc, Options>::type base_type;
@@ -548,6 +550,7 @@ class small_vector
548550
BOOST_COPYABLE_AND_MOVABLE(small_vector)
549551

550552
public:
553+
typedef dtl::true_type is_partially_propagable;
551554
typedef small_vector_base<T, Allocator, Options> base_type;
552555
typedef typename base_type::allocator_type allocator_type;
553556
typedef typename base_type::size_type size_type;

test/vector_test.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,11 @@ int vector_test()
626626
if(!test::CheckEqualContainers(*boostvectorp2, *stdvectorp)) return 1;
627627
}
628628

629-
if (0 != vector_test_fully_propagable<MyBoostVector>
630-
( dtl::bool_< !allocator_traits<typename MyBoostVector::allocator_type>::is_partially_propagable::value >() )) return 1;
629+
typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::dtl::, MyBoostVector,
630+
is_partially_propagable, dtl::false_type)
631+
is_partially_propagable_t;
632+
633+
if (0 != vector_test_fully_propagable<MyBoostVector>( dtl::bool_< !is_partially_propagable_t::value >() )) return 1;
631634

632635
if (0 != vector_move_assignable_only< MyBoostVector>(dtl::bool_<boost::container::test::is_move_assignable<IntType>::value>()))
633636
return 1;

0 commit comments

Comments
 (0)