Skip to content

Commit 4bbe2dd

Browse files
committed
fix get_allocator private alloc_
1 parent 1cdf892 commit 4bbe2dd

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

include/boost/multi/array.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ struct
159159
using decay_type = array<T, D, allocator_type>;
160160

161161
/// returns the allocator that is used to acquire/release memory and to construct/destroy the elements in that memory
162-
BOOST_MULTI_HD constexpr auto get_allocator() const -> allocator_type { return this->alloc_; }
162+
BOOST_MULTI_HD constexpr auto get_allocator() const -> allocator_type { return detail::array_allocator<
163+
typename allocator_traits<DummyAlloc>::template rebind_alloc<T>>::get_allocator(); }
163164

164165
/*[[deprecated]]*/ auto operator new(std::size_t count) -> void* { return ::operator new(count); } // overrides the deleted new operator in reference (base) class subarray
165166
/*[[deprecated]]*/ auto operator new(std::size_t count, void* ptr) -> void* { return ::operator new(count, ptr); } // overrides the deleted new operator in reference (base) class subarray

test/allocator.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ auto main() -> int { // NOLINT(readability-function-cognitive-complexity,bugpro
282282

283283
multi::array<char, 2, std::pmr::polymorphic_allocator<char>> Barr({3, 2}, 'o', &pool);
284284

285+
BOOST_TEST( Aarr.get_allocator() == Barr.get_allocator() );
286+
285287
BOOST_TEST(( buffer != std::array<char, 13>{{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C'}} ));
286288

287289
#ifdef __GLIBCXX__

0 commit comments

Comments
 (0)