180 class scoped_allocator_adaptor
185 typedef __inner_type_impl<_OuterAlloc, _InnerAllocs...> __inner_type;
186 __inner_type _M_inner;
188 template<
typename _Outer,
typename... _Inner>
189 friend class scoped_allocator_adaptor;
191 template<
typename...>
192 friend struct __inner_type_impl;
194 tuple<
const _OuterAlloc&,
const _InnerAllocs&...>
195 _M_tie()
const noexcept
198 template<
typename _Alloc>
199 using __outermost_alloc_traits
202#if ! __glibcxx_make_obj_using_allocator
203 template<
typename _Tp,
typename... _Args>
205 _M_construct(__uses_alloc0, _Tp* __p, _Args&&... __args)
207 typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
208 _O_traits::construct(__outermost(*
this), __p,
212 typedef __uses_alloc1<typename __inner_type::__type> __uses_alloc1_;
213 typedef __uses_alloc2<typename __inner_type::__type> __uses_alloc2_;
215 template<
typename _Tp,
typename... _Args>
217 _M_construct(__uses_alloc1_, _Tp* __p, _Args&&... __args)
219 typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
220 _O_traits::construct(__outermost(*
this), __p,
221 allocator_arg, inner_allocator(),
225 template<
typename _Tp,
typename... _Args>
227 _M_construct(__uses_alloc2_, _Tp* __p, _Args&&... __args)
229 typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
230 _O_traits::construct(__outermost(*
this), __p,
236 template<
typename _Alloc>
238 _S_select_on_copy(
const _Alloc& __a)
241 return __a_traits::select_on_container_copy_construction(__a);
244 template<std::size_t... _Indices>
245 scoped_allocator_adaptor(
tuple<
const _OuterAlloc&,
246 const _InnerAllocs&...> __refs,
247 _Index_tuple<_Indices...>)
248 : _OuterAlloc(_S_select_on_copy(std::get<0>(__refs))),
249 _M_inner(_S_select_on_copy(std::get<_Indices+1>(__refs))...)
253 template<
typename _Alloc>
254 using _Constructible =
typename enable_if<
260 template<
typename _Tp>
261 struct __not_pair {
using type = void; };
263 template<
typename _Tp,
typename _Up>
264 struct __not_pair<
pair<_Tp, _Up>> { };
267 typedef _OuterAlloc outer_allocator_type;
268 typedef typename __inner_type::__type inner_allocator_type;
278 typedef typename __or_<
281 propagate_on_container_copy_assignment...>
::type
282 propagate_on_container_copy_assignment;
284 typedef typename __or_<
287 propagate_on_container_move_assignment...>
::type
288 propagate_on_container_move_assignment;
290 typedef typename __or_<
293 propagate_on_container_swap...>
::type
294 propagate_on_container_swap;
296 typedef typename __and_<
304 typedef scoped_allocator_adaptor<
305 typename __traits::template rebind_alloc<_Tp>,
306 _InnerAllocs...> other;
309 scoped_allocator_adaptor() : _OuterAlloc(), _M_inner() { }
311 template<
typename _Outer2,
typename = _Constructible<_Outer2>>
312 scoped_allocator_adaptor(_Outer2&& __outer,
313 const _InnerAllocs&... __inner) noexcept
318 scoped_allocator_adaptor(
const scoped_allocator_adaptor& __other) noexcept
319 : _OuterAlloc(__other.outer_allocator()),
320 _M_inner(__other._M_inner)
323 scoped_allocator_adaptor(scoped_allocator_adaptor&& __other) noexcept
324 : _OuterAlloc(
std::move(__other.outer_allocator())),
328 template<
typename _Outer2,
typename = _Constructible<const _Outer2&>>
329 scoped_allocator_adaptor(
330 const scoped_allocator_adaptor<_Outer2, _InnerAllocs...>& __other
332 : _OuterAlloc(__other.outer_allocator()),
333 _M_inner(__other._M_inner)
336 template<
typename _Outer2,
typename = _Constructible<_Outer2>>
337 scoped_allocator_adaptor(
338 scoped_allocator_adaptor<_Outer2, _InnerAllocs...>&& __other) noexcept
339 : _OuterAlloc(
std::move(__other.outer_allocator())),
343 scoped_allocator_adaptor&
344 operator=(
const scoped_allocator_adaptor&) =
default;
346 scoped_allocator_adaptor&
347 operator=(scoped_allocator_adaptor&&) =
default;
349 inner_allocator_type&
350 inner_allocator()
noexcept
351 {
return _M_inner._M_get(
this); }
353 const inner_allocator_type&
354 inner_allocator()
const noexcept
355 {
return _M_inner._M_get(
this); }
357 outer_allocator_type&
358 outer_allocator()
noexcept
359 {
return static_cast<_OuterAlloc&
>(*this); }
361 const outer_allocator_type&
362 outer_allocator()
const noexcept
363 {
return static_cast<const _OuterAlloc&
>(*this); }
365 _GLIBCXX_NODISCARD pointer
366 allocate(size_type __n)
369 _GLIBCXX_NODISCARD pointer
370 allocate(size_type __n, const_void_pointer __hint)
373 void deallocate(pointer __p, size_type __n)
noexcept
376 size_type max_size()
const
379#if ! __glibcxx_make_obj_using_allocator
380 template<
typename _Tp,
typename... _Args>
381 typename __not_pair<_Tp>::type
382 construct(_Tp* __p, _Args&&... __args)
384 auto& __inner = inner_allocator();
386 = std::__use_alloc<_Tp, inner_allocator_type, _Args...>(__inner);
390 template<
typename _T1,
typename _T2,
typename... _Args1,
398 auto& __inner = inner_allocator();
400 = std::__use_alloc<_T1, inner_allocator_type, _Args1...>(__inner);
402 = std::__use_alloc<_T2, inner_allocator_type, _Args2...>(__inner);
403 typename _Build_index_tuple<
sizeof...(_Args1)>::__type __x_indices;
404 typename _Build_index_tuple<
sizeof...(_Args2)>::__type __y_indices;
405 typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
407 _M_construct_p(__x_use_tag, __x_indices, __x),
408 _M_construct_p(__y_use_tag, __y_indices, __y));
411 template<
typename _T1,
typename _T2>
416 template<
typename _T1,
typename _T2,
typename _Up,
typename _Vp>
425 template<
typename _T1,
typename _T2,
typename _Up,
typename _Vp>
434 template<
typename _T1,
typename _T2,
typename _Up,
typename _Vp>
443 template<
typename _Tp,
typename... _Args>
444 __attribute__((__nonnull__))
446 construct(_Tp* __p, _Args&&... __args)
448 typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
449 std::apply([__p,
this](
auto&&... __newargs) {
450 _O_traits::construct(__outermost(*
this), __p,
453 uses_allocator_construction_args<_Tp>(inner_allocator(),
458 template<
typename _Tp>
459 void destroy(_Tp* __p)
461 typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
462 _O_traits::destroy(__outermost(*
this), __p);
465 scoped_allocator_adaptor
466 select_on_container_copy_construction()
const
468 typedef typename _Build_index_tuple<
sizeof...(_InnerAllocs)>::__type
470 return scoped_allocator_adaptor(_M_tie(), _Indices());
473 template <
typename _OutA1,
typename _OutA2,
typename... _InA>
475 operator==(
const scoped_allocator_adaptor<_OutA1, _InA...>& __a,
476 const scoped_allocator_adaptor<_OutA2, _InA...>& __b)
noexcept;
479#if ! __glibcxx_make_obj_using_allocator
480 template<
typename _Ind,
typename... _Args>
485 template<
size_t... _Ind,
typename... _Args>
486 tuple<allocator_arg_t, inner_allocator_type&, _Args&&...>
487 _M_construct_p(__uses_alloc1_, _Index_tuple<_Ind...>,
490 return { allocator_arg, inner_allocator(),
495 template<
size_t... _Ind,
typename... _Args>
496 tuple<_Args&&..., inner_allocator_type&>
497 _M_construct_p(__uses_alloc2_, _Index_tuple<_Ind...>,
500 return { std::get<_Ind>(
std::move(__t))..., inner_allocator() };