182 class scoped_allocator_adaptor
187 typedef __inner_type_impl<_OuterAlloc, _InnerAllocs...> __inner_type;
188 __inner_type _M_inner;
190 template<
typename _Outer,
typename... _Inner>
191 friend class scoped_allocator_adaptor;
193 template<
typename...>
194 friend struct __inner_type_impl;
196 tuple<
const _OuterAlloc&,
const _InnerAllocs&...>
197 _M_tie()
const noexcept
200 template<
typename _Alloc>
201 using __outermost_alloc_traits
204#if ! __glibcxx_make_obj_using_allocator
205 template<
typename _Tp,
typename... _Args>
207 _M_construct(__uses_alloc0, _Tp* __p, _Args&&... __args)
209 typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
210 _O_traits::construct(__outermost(*
this), __p,
214 typedef __uses_alloc1<typename __inner_type::__type> __uses_alloc1_;
215 typedef __uses_alloc2<typename __inner_type::__type> __uses_alloc2_;
217 template<
typename _Tp,
typename... _Args>
219 _M_construct(__uses_alloc1_, _Tp* __p, _Args&&... __args)
221 typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
222 _O_traits::construct(__outermost(*
this), __p,
223 allocator_arg, inner_allocator(),
227 template<
typename _Tp,
typename... _Args>
229 _M_construct(__uses_alloc2_, _Tp* __p, _Args&&... __args)
231 typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
232 _O_traits::construct(__outermost(*
this), __p,
238 template<
typename _Alloc>
240 _S_select_on_copy(
const _Alloc& __a)
243 return __a_traits::select_on_container_copy_construction(__a);
246 template<std::size_t... _Indices>
247 scoped_allocator_adaptor(
tuple<
const _OuterAlloc&,
248 const _InnerAllocs&...> __refs,
249 _Index_tuple<_Indices...>)
250 : _OuterAlloc(_S_select_on_copy(std::get<0>(__refs))),
251 _M_inner(_S_select_on_copy(std::get<_Indices+1>(__refs))...)
255 template<
typename _Alloc>
256 using _Constructible =
typename enable_if<
262 template<
typename _Tp>
263 struct __not_pair {
using type = void; };
265 template<
typename _Tp,
typename _Up>
266 struct __not_pair<
pair<_Tp, _Up>> { };
269 typedef _OuterAlloc outer_allocator_type;
270 typedef typename __inner_type::__type inner_allocator_type;
280 typedef typename __or_<
283 propagate_on_container_copy_assignment...>
::type
284 propagate_on_container_copy_assignment;
286 typedef typename __or_<
289 propagate_on_container_move_assignment...>
::type
290 propagate_on_container_move_assignment;
292 typedef typename __or_<
295 propagate_on_container_swap...>
::type
296 propagate_on_container_swap;
298 typedef typename __and_<
306 typedef scoped_allocator_adaptor<
307 typename __traits::template rebind_alloc<_Tp>,
308 _InnerAllocs...> other;
311 scoped_allocator_adaptor() : _OuterAlloc(), _M_inner() { }
313 template<
typename _Outer2,
typename = _Constructible<_Outer2>>
314 scoped_allocator_adaptor(_Outer2&& __outer,
315 const _InnerAllocs&... __inner) noexcept
320 scoped_allocator_adaptor(
const scoped_allocator_adaptor& __other) noexcept
321 : _OuterAlloc(__other.outer_allocator()),
322 _M_inner(__other._M_inner)
325 scoped_allocator_adaptor(scoped_allocator_adaptor&& __other) noexcept
326 : _OuterAlloc(
std::move(__other.outer_allocator())),
330 template<
typename _Outer2,
typename = _Constructible<const _Outer2&>>
331 scoped_allocator_adaptor(
332 const scoped_allocator_adaptor<_Outer2, _InnerAllocs...>& __other
334 : _OuterAlloc(__other.outer_allocator()),
335 _M_inner(__other._M_inner)
338 template<
typename _Outer2,
typename = _Constructible<_Outer2>>
339 scoped_allocator_adaptor(
340 scoped_allocator_adaptor<_Outer2, _InnerAllocs...>&& __other) noexcept
341 : _OuterAlloc(
std::move(__other.outer_allocator())),
345 scoped_allocator_adaptor&
346 operator=(
const scoped_allocator_adaptor&) =
default;
348 scoped_allocator_adaptor&
349 operator=(scoped_allocator_adaptor&&) =
default;
351 inner_allocator_type&
352 inner_allocator()
noexcept
353 {
return _M_inner._M_get(
this); }
355 const inner_allocator_type&
356 inner_allocator()
const noexcept
357 {
return _M_inner._M_get(
this); }
359 outer_allocator_type&
360 outer_allocator()
noexcept
361 {
return static_cast<_OuterAlloc&
>(*this); }
363 const outer_allocator_type&
364 outer_allocator()
const noexcept
365 {
return static_cast<const _OuterAlloc&
>(*this); }
367 _GLIBCXX_NODISCARD pointer
368 allocate(size_type __n)
371 _GLIBCXX_NODISCARD pointer
372 allocate(size_type __n, const_void_pointer __hint)
375 void deallocate(pointer __p, size_type __n)
noexcept
378 size_type max_size()
const
381#if ! __glibcxx_make_obj_using_allocator
382 template<
typename _Tp,
typename... _Args>
383 typename __not_pair<_Tp>::type
384 construct(_Tp* __p, _Args&&... __args)
386 auto& __inner = inner_allocator();
388 = std::__use_alloc<_Tp, inner_allocator_type, _Args...>(__inner);
392 template<
typename _T1,
typename _T2,
typename... _Args1,
400 auto& __inner = inner_allocator();
402 = std::__use_alloc<_T1, inner_allocator_type, _Args1...>(__inner);
404 = std::__use_alloc<_T2, inner_allocator_type, _Args2...>(__inner);
405 typename _Build_index_tuple<
sizeof...(_Args1)>::__type __x_indices;
406 typename _Build_index_tuple<
sizeof...(_Args2)>::__type __y_indices;
407 typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
409 _M_construct_p(__x_use_tag, __x_indices, __x),
410 _M_construct_p(__y_use_tag, __y_indices, __y));
413 template<
typename _T1,
typename _T2>
418 template<
typename _T1,
typename _T2,
typename _Up,
typename _Vp>
427 template<
typename _T1,
typename _T2,
typename _Up,
typename _Vp>
436 template<
typename _T1,
typename _T2,
typename _Up,
typename _Vp>
445 template<
typename _Tp,
typename... _Args>
446 __attribute__((__nonnull__))
448 construct(_Tp* __p, _Args&&... __args)
450 typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
451 std::apply([__p,
this](
auto&&... __newargs) {
452 _O_traits::construct(__outermost(*
this), __p,
455 uses_allocator_construction_args<_Tp>(inner_allocator(),
460 template<
typename _Tp>
461 void destroy(_Tp* __p)
463 typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
464 _O_traits::destroy(__outermost(*
this), __p);
467 scoped_allocator_adaptor
468 select_on_container_copy_construction()
const
470 typedef typename _Build_index_tuple<
sizeof...(_InnerAllocs)>::__type
472 return scoped_allocator_adaptor(_M_tie(), _Indices());
475 template <
typename _OutA1,
typename _OutA2,
typename... _InA>
477 operator==(
const scoped_allocator_adaptor<_OutA1, _InA...>& __a,
478 const scoped_allocator_adaptor<_OutA2, _InA...>& __b)
noexcept;
481#if ! __glibcxx_make_obj_using_allocator
482 template<
typename _Ind,
typename... _Args>
487 template<
size_t... _Ind,
typename... _Args>
488 tuple<allocator_arg_t, inner_allocator_type&, _Args&&...>
489 _M_construct_p(__uses_alloc1_, _Index_tuple<_Ind...>,
492 return { allocator_arg, inner_allocator(),
497 template<
size_t... _Ind,
typename... _Args>
498 tuple<_Args&&..., inner_allocator_type&>
499 _M_construct_p(__uses_alloc2_, _Index_tuple<_Ind...>,
502 return { std::get<_Ind>(
std::move(__t))..., inner_allocator() };