178 class scoped_allocator_adaptor
183 typedef __inner_type_impl<_OuterAlloc, _InnerAllocs...> __inner_type;
184 __inner_type _M_inner;
186 template<
typename _Outer,
typename... _Inner>
187 friend class scoped_allocator_adaptor;
189 template<
typename...>
190 friend class __inner_type_impl;
192 tuple<
const _OuterAlloc&,
const _InnerAllocs&...>
193 _M_tie()
const noexcept
196 template<
typename _Alloc>
197 using __outermost_alloc_traits
200#if ! __cpp_lib_make_obj_using_allocator
201 template<
typename _Tp,
typename... _Args>
203 _M_construct(__uses_alloc0, _Tp* __p, _Args&&... __args)
205 typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
206 _O_traits::construct(__outermost(*
this), __p,
210 typedef __uses_alloc1<typename __inner_type::__type> __uses_alloc1_;
211 typedef __uses_alloc2<typename __inner_type::__type> __uses_alloc2_;
213 template<
typename _Tp,
typename... _Args>
215 _M_construct(__uses_alloc1_, _Tp* __p, _Args&&... __args)
217 typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
218 _O_traits::construct(__outermost(*
this), __p,
219 allocator_arg, inner_allocator(),
223 template<
typename _Tp,
typename... _Args>
225 _M_construct(__uses_alloc2_, _Tp* __p, _Args&&... __args)
227 typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
228 _O_traits::construct(__outermost(*
this), __p,
234 template<
typename _Alloc>
236 _S_select_on_copy(
const _Alloc& __a)
239 return __a_traits::select_on_container_copy_construction(__a);
242 template<std::size_t... _Indices>
243 scoped_allocator_adaptor(
tuple<
const _OuterAlloc&,
244 const _InnerAllocs&...> __refs,
245 _Index_tuple<_Indices...>)
246 : _OuterAlloc(_S_select_on_copy(std::get<0>(__refs))),
247 _M_inner(_S_select_on_copy(std::get<_Indices+1>(__refs))...)
251 template<
typename _Alloc>
252 using _Constructible =
typename enable_if<
258 template<
typename _Tp>
259 struct __not_pair {
using type = void; };
261 template<
typename _Tp,
typename _Up>
262 struct __not_pair<
pair<_Tp, _Up>> { };
265 typedef _OuterAlloc outer_allocator_type;
266 typedef typename __inner_type::__type inner_allocator_type;
276 typedef typename __or_<
279 propagate_on_container_copy_assignment...>
::type
280 propagate_on_container_copy_assignment;
282 typedef typename __or_<
285 propagate_on_container_move_assignment...>
::type
286 propagate_on_container_move_assignment;
288 typedef typename __or_<
291 propagate_on_container_swap...>
::type
292 propagate_on_container_swap;
294 typedef typename __and_<
302 typedef scoped_allocator_adaptor<
303 typename __traits::template rebind_alloc<_Tp>,
304 _InnerAllocs...> other;
307 scoped_allocator_adaptor() : _OuterAlloc(), _M_inner() { }
309 template<
typename _Outer2,
typename = _Constructible<_Outer2>>
310 scoped_allocator_adaptor(_Outer2&& __outer,
311 const _InnerAllocs&... __inner)
316 scoped_allocator_adaptor(
const scoped_allocator_adaptor& __other)
317 : _OuterAlloc(__other.outer_allocator()),
318 _M_inner(__other._M_inner)
321 scoped_allocator_adaptor(scoped_allocator_adaptor&& __other)
322 : _OuterAlloc(
std::move(__other.outer_allocator())),
326 template<
typename _Outer2,
typename = _Constructible<const _Outer2&>>
327 scoped_allocator_adaptor(
328 const scoped_allocator_adaptor<_Outer2, _InnerAllocs...>& __other)
329 : _OuterAlloc(__other.outer_allocator()),
330 _M_inner(__other._M_inner)
333 template<
typename _Outer2,
typename = _Constructible<_Outer2>>
334 scoped_allocator_adaptor(
335 scoped_allocator_adaptor<_Outer2, _InnerAllocs...>&& __other)
336 : _OuterAlloc(
std::move(__other.outer_allocator())),
340 scoped_allocator_adaptor&
341 operator=(
const scoped_allocator_adaptor&) =
default;
343 scoped_allocator_adaptor&
344 operator=(scoped_allocator_adaptor&&) =
default;
346 inner_allocator_type& inner_allocator()
noexcept
347 {
return _M_inner._M_get(
this); }
349 const inner_allocator_type& inner_allocator()
const noexcept
350 {
return _M_inner._M_get(
this); }
352 outer_allocator_type& outer_allocator()
noexcept
353 {
return static_cast<_OuterAlloc&
>(*this); }
355 const outer_allocator_type& outer_allocator()
const noexcept
356 {
return static_cast<const _OuterAlloc&
>(*this); }
358 _GLIBCXX_NODISCARD pointer allocate(size_type __n)
361 _GLIBCXX_NODISCARD pointer allocate(size_type __n, const_void_pointer __hint)
364 void deallocate(pointer __p, size_type __n)
367 size_type max_size()
const
370#if ! __cpp_lib_make_obj_using_allocator
371 template<
typename _Tp,
typename... _Args>
372 typename __not_pair<_Tp>::type
373 construct(_Tp* __p, _Args&&... __args)
375 auto& __inner = inner_allocator();
377 = std::__use_alloc<_Tp, inner_allocator_type, _Args...>(__inner);
381 template<
typename _T1,
typename _T2,
typename... _Args1,
389 auto& __inner = inner_allocator();
391 = std::__use_alloc<_T1, inner_allocator_type, _Args1...>(__inner);
393 = std::__use_alloc<_T2, inner_allocator_type, _Args2...>(__inner);
394 typename _Build_index_tuple<
sizeof...(_Args1)>::__type __x_indices;
395 typename _Build_index_tuple<
sizeof...(_Args2)>::__type __y_indices;
396 typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
398 _M_construct_p(__x_use_tag, __x_indices, __x),
399 _M_construct_p(__y_use_tag, __y_indices, __y));
402 template<
typename _T1,
typename _T2>
407 template<
typename _T1,
typename _T2,
typename _Up,
typename _Vp>
416 template<
typename _T1,
typename _T2,
typename _Up,
typename _Vp>
425 template<
typename _T1,
typename _T2,
typename _Up,
typename _Vp>
434 template<
typename _Tp,
typename... _Args>
435 __attribute__((__nonnull__))
437 construct(_Tp* __p, _Args&&... __args)
439 typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
440 std::apply([__p,
this](
auto&&... __newargs) {
441 _O_traits::construct(__outermost(*
this), __p,
444 uses_allocator_construction_args<_Tp>(inner_allocator(),
449 template<
typename _Tp>
450 void destroy(_Tp* __p)
452 typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
453 _O_traits::destroy(__outermost(*
this), __p);
456 scoped_allocator_adaptor
457 select_on_container_copy_construction()
const
459 typedef typename _Build_index_tuple<
sizeof...(_InnerAllocs)>::__type
461 return scoped_allocator_adaptor(_M_tie(), _Indices());
464 template <
typename _OutA1,
typename _OutA2,
typename... _InA>
466 operator==(
const scoped_allocator_adaptor<_OutA1, _InA...>& __a,
467 const scoped_allocator_adaptor<_OutA2, _InA...>& __b)
noexcept;
470#if ! __cpp_lib_make_obj_using_allocator
471 template<
typename _Ind,
typename... _Args>
476 template<
size_t... _Ind,
typename... _Args>
477 tuple<allocator_arg_t, inner_allocator_type&, _Args&&...>
478 _M_construct_p(__uses_alloc1_, _Index_tuple<_Ind...>,
481 return { allocator_arg, inner_allocator(),
486 template<
size_t... _Ind,
typename... _Args>
487 tuple<_Args&&..., inner_allocator_type&>
488 _M_construct_p(__uses_alloc2_, _Index_tuple<_Ind...>,
491 return { std::get<_Ind>(
std::move(__t))..., inner_allocator() };