Skip to content

Commit 1cdf892

Browse files
committed
get_allocator-doc
1 parent ca8444a commit 1cdf892

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

include/boost/multi/array.hpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,19 +149,22 @@ struct
149149
using array_alloc = detail::array_allocator<typename multi::allocator_traits<DummyAlloc>::template rebind_alloc<T>>;
150150

151151
public:
152-
using detail::array_allocator<typename multi::allocator_traits<DummyAlloc>::template rebind_alloc<T>>::get_allocator;
153-
154-
/// Alloc
152+
/// Allocator type (returned by `get_allocator()`)
155153
using allocator_type = typename detail::array_allocator<typename multi::allocator_traits<DummyAlloc>::template rebind_alloc<T>>::allocator_type; // NOLINT(readability-redundant-typename) needed for C++17
154+
156155
/// Layout type (generally a strided layout `multi::layout_t<D>`)
157156
using layout_type = typename array_ref<T, D, typename multi::allocator_traits<allocator_type>::pointer>::layout_type; // NOLINT(readability-redundant-typename) needed for C++17
157+
158158
/// Associalted array value type (generally itself, `multi::array<element, dimensionality, allocator_type>`)
159159
using decay_type = array<T, D, allocator_type>;
160160

161-
[[deprecated]] auto operator new(std::size_t count) -> void* { return ::operator new(count); }
162-
[[deprecated]] auto operator new(std::size_t count, void* ptr) -> void* { return ::operator new(count, ptr); }
161+
/// 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_; }
163+
164+
/*[[deprecated]]*/ auto operator new(std::size_t count) -> void* { return ::operator new(count); } // overrides the deleted new operator in reference (base) class subarray
165+
/*[[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
163166

164-
[[deprecated]] void operator delete(void* ptr) noexcept { ::operator delete(ptr); } // this overrides the deleted delete operator in reference (base) class subarray
167+
/*[[deprecated]]*/ void operator delete(void* ptr) noexcept { ::operator delete(ptr); } // overrides the deleted delete operator in reference (base) class subarray
165168

166169
protected: // TODO(correaa) make private
167170
/// Associated array reference type, also its base class (generally `multi::array_ref<element, dimensionality, allocator_type>`)
@@ -866,7 +869,7 @@ struct
866869
/// Random-access iterator in the leading dimension, in general they dereference to an immutable subarrays of lower dimension (`multi::const_subarray<...>`) or, for `D == 1`, to an element immutable reference (`T const&`)
867870
using const_iterator = multi::detail::array_iterator<T, D, typename dynamic_array::element_ptr, true>;
868871

869-
friend auto get_allocator(dynamic_array const& self) -> allocator_type { return self.get_allocator(); }
872+
// friend auto get_allocator(dynamic_array const& self) -> allocator_type { return self.get_allocator(); }
870873

871874
/// gets a const-pointer to a contigous range of size `.num_elements()` containing the data of the array
872875
BOOST_MULTI_HD constexpr auto data_elements() const& -> element_const_ptr { return this->base_; } // cppcheck-suppress duplInheritedMember ; to override

include/boost/multi/array_ref.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1407,12 +1407,13 @@ class const_subarray : public array_types<T, D, ElementPtr, Layout> {
14071407
using default_allocator_type = typename multi::pointer_traits<const_subarray::element_ptr>::default_allocator_type;
14081408

14091409
public:
1410+
/// returns the associated allocator
14101411
BOOST_MULTI_HD constexpr auto get_allocator() const -> default_allocator_type {
14111412
using multi::get_allocator;
14121413
return get_allocator(this->base());
14131414
}
14141415

1415-
BOOST_MULTI_FRIEND_CONSTEXPR auto get_allocator(const_subarray const& self) -> default_allocator_type { return self.get_allocator(); }
1416+
// BOOST_MULTI_FRIEND_CONSTEXPR auto get_allocator(const_subarray const& self) -> default_allocator_type { return self.get_allocator(); }
14161417

14171418
/// Associated type that this reference decays to (when true copies are needed)
14181419
using decay_type = array<std::decay_t<typename types::element>, D, typename multi::pointer_traits<typename const_subarray::element_ptr>::default_allocator_type>;

0 commit comments

Comments
 (0)