33
44// SPDX-License-Identifier: MIT
55
6+ #include < iris/bits/specialization_of.hpp>
67#include < iris/compare.hpp>
78#include < iris/hash.hpp>
8- #include < iris/type_traits.hpp>
99
1010#include < compare>
1111#include < memory>
@@ -25,13 +25,12 @@ class scoped_allocation
2525 using pointer = std::allocator_traits<Alloc>::pointer;
2626 using const_pointer = std::allocator_traits<Alloc>::const_pointer;
2727
28-
2928 template <class ... Args>
30- constexpr explicit scoped_allocation (Alloc const & a, std:: in_place_t , Args&&... args)
29+ constexpr explicit scoped_allocation (Alloc const & a, Args&&... args)
3130 : alloc_(a)
3231 , ptr_(std::allocator_traits<Alloc>::allocate(alloc_, 1 ))
3332 {
34- std::allocator_traits<Alloc>::construct (alloc_, get (), std::forward<Args>(args)...);
33+ std::allocator_traits<Alloc>::construct (alloc_, this -> get (), std::forward<Args>(args)...);
3534 }
3635
3736 constexpr ~scoped_allocation ()
@@ -70,7 +69,7 @@ class indirect_base
7069 using const_pointer = std::allocator_traits<Allocator>::const_pointer;
7170
7271 constexpr explicit indirect_base () requires std::is_default_constructible_v<Allocator>
73- : ptr_(make_obj())
72+ : ptr_(this -> make_obj ())
7473 {}
7574
7675 constexpr indirect_base (indirect_base const & other)
@@ -83,12 +82,12 @@ class indirect_base
8382
8483 constexpr explicit indirect_base (std::allocator_arg_t , Allocator const & a)
8584 : alloc_(a)
86- , ptr_(make_obj())
85+ , ptr_(this -> make_obj ())
8786 {}
8887
8988 constexpr indirect_base (std::allocator_arg_t , Allocator const & a, indirect_base const & other)
9089 : alloc_(a)
91- , ptr_(other.ptr_ ? make_obj(std::as_const(*other.ptr_)) : nullptr)
90+ , ptr_(other.ptr_ ? this -> make_obj (std::as_const(*other.ptr_)) : nullptr)
9291 {
9392 static_assert (std::is_copy_constructible_v<T>);
9493 }
@@ -103,7 +102,7 @@ class indirect_base
103102 : alloc_(a)
104103 , ptr_(alloc_ == other.alloc_
105104 ? std::exchange(other.ptr_, nullptr )
106- : make_obj(*std::move (other))
105+ : this-> make_obj(*std::move (other))
107106 )
108107 {}
109108
@@ -114,7 +113,7 @@ class indirect_base
114113 std::is_constructible_v<T, U> &&
115114 std::is_default_constructible_v<Allocator>
116115 constexpr explicit indirect_base(U&& u)
117- : ptr_(make_obj(std::forward<U>(u)))
116+ : ptr_(this -> make_obj (std::forward<U>(u)))
118117 {}
119118
120119 template <class U = T>
@@ -124,45 +123,45 @@ class indirect_base
124123 std::is_constructible_v<T, U>
125124 constexpr explicit indirect_base(std::allocator_arg_t , Allocator const & a, U&& u)
126125 : alloc_(a)
127- , ptr_(make_obj(std::forward<U>(u)))
126+ , ptr_(this -> make_obj (std::forward<U>(u)))
128127 {}
129128
130129 template <class ... Us>
131130 requires
132131 std::is_constructible_v<T, Us...> &&
133132 std::is_default_constructible_v<Allocator>
134133 constexpr explicit indirect_base (std::in_place_t , Us&&... us)
135- : ptr_(make_obj(std::forward<Us>(us)...))
134+ : ptr_(this -> make_obj (std::forward<Us>(us)...))
136135 {}
137136
138137 template <class ... Us>
139138 requires
140139 std::is_constructible_v<T, Us...>
141140 constexpr explicit indirect_base (std::allocator_arg_t , Allocator const & a, std::in_place_t , Us&&... us)
142141 : alloc_(a)
143- , ptr_(make_obj(std::forward<Us>(us)...))
142+ , ptr_(this -> make_obj (std::forward<Us>(us)...))
144143 {}
145144
146145 template <class I , class ... Us>
147146 requires
148147 std::is_constructible_v<T, std::initializer_list<I>&, Us...> &&
149148 std::is_default_constructible_v<Allocator>
150149 constexpr explicit indirect_base (std::in_place_t , std::initializer_list<I> il, Us&&... us)
151- : ptr_(make_obj(il, std::forward<Us>(us)...))
150+ : ptr_(this -> make_obj (il, std::forward<Us>(us)...))
152151 {}
153152
154153 template <class I , class ... Us>
155154 requires
156155 std::is_constructible_v<T, std::initializer_list<I>&, Us...>
157156 constexpr explicit indirect_base (std::allocator_arg_t , Allocator const & a, std::in_place_t , std::initializer_list<I> il, Us&&... us)
158157 : alloc_(a)
159- , ptr_(make_obj(il, std::forward<Us>(us)...))
158+ , ptr_(this -> make_obj (il, std::forward<Us>(us)...))
160159 {}
161160
162161 constexpr ~indirect_base () noexcept
163162 {
164163 if (ptr_) [[likely]] {
165- destroy_deallocate ();
164+ this -> destroy_deallocate ();
166165 }
167166 }
168167
@@ -220,7 +219,7 @@ class indirect_base
220219 // other.ptr_ && (ptr_ || !ptr_)
221220 // either allocator is not equal or `this` does not contain value; create copy from `other`
222221 if (ptr_) [[likely]] {
223- destroy_deallocate ();
222+ this -> destroy_deallocate ();
224223 ptr_ = nullptr ; // make it safer
225224 }
226225 if constexpr (pocca) {
@@ -234,7 +233,7 @@ class indirect_base
234233
235234 } else [[unlikely]] { // !other.ptr_
236235 if (ptr_) [[likely]] {
237- destroy_deallocate ();
236+ this -> destroy_deallocate ();
238237 ptr_ = nullptr ; // make it safer
239238 }
240239 if constexpr (pocca) {
@@ -261,7 +260,7 @@ class indirect_base
261260 if (other.ptr_ ) [[likely]] {
262261 if constexpr (std::allocator_traits<Allocator>::is_always_equal::value) {
263262 if (ptr_) [[likely]] {
264- destroy_deallocate ();
263+ this -> destroy_deallocate ();
265264 }
266265 ptr_ = std::exchange (other.ptr_ , nullptr );
267266 if constexpr (pocma) {
@@ -271,7 +270,7 @@ class indirect_base
271270
272271 } else if (alloc_ == other.alloc_ ) {
273272 if (ptr_) [[likely]] {
274- destroy_deallocate ();
273+ this -> destroy_deallocate ();
275274 }
276275 ptr_ = std::exchange (other.ptr_ , nullptr );
277276 if constexpr (pocma) {
@@ -281,7 +280,7 @@ class indirect_base
281280
282281 } else {
283282 if (ptr_) [[likely]] {
284- destroy_deallocate ();
283+ this -> destroy_deallocate ();
285284 }
286285 if constexpr (pocma) {
287286 ptr_ = other.make_obj (std::move (*other));
@@ -293,7 +292,7 @@ class indirect_base
293292 }
294293 } else [[unlikely]] { // !other.ptr_
295294 if (ptr_) [[likely]] {
296- destroy_deallocate ();
295+ this -> destroy_deallocate ();
297296 ptr_ = nullptr ;
298297 }
299298 if constexpr (pocma) {
@@ -314,7 +313,7 @@ class indirect_base
314313 **this = std::forward<U>(u);
315314
316315 } else [[unlikely]] {
317- ptr_ = make_obj (std::forward<U>(u));
316+ ptr_ = this -> make_obj (std::forward<U>(u));
318317 }
319318 return *this ;
320319 }
@@ -361,7 +360,7 @@ class indirect_base
361360 template <class ... Args>
362361 [[nodiscard]] constexpr T* make_obj (Args&&... args) const
363362 {
364- detail::scoped_allocation sa (alloc_, std::in_place, std:: forward<Args>(args)...);
363+ detail::scoped_allocation sa (alloc_, std::forward<Args>(args)...);
365364 return sa.release ();
366365 }
367366
0 commit comments