Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/c++/v1/scoped_allocator is written in an unsupported language. File is not indexed.

0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 #ifndef _LIBCPP_SCOPED_ALLOCATOR
0011 #define _LIBCPP_SCOPED_ALLOCATOR
0012 
0013 /*
0014     scoped_allocator synopsis
0015 
0016 namespace std
0017 {
0018 
0019 template <class OuterAlloc, class... InnerAllocs>
0020 class scoped_allocator_adaptor : public OuterAlloc
0021 {
0022     typedef allocator_traits<OuterAlloc> OuterTraits; // exposition only
0023     scoped_allocator_adaptor<InnerAllocs...> inner;   // exposition only
0024 public:
0025 
0026     typedef OuterAlloc outer_allocator_type;
0027     typedef see below inner_allocator_type;
0028 
0029     typedef typename OuterTraits::value_type value_type;
0030     typedef typename OuterTraits::size_type size_type;
0031     typedef typename OuterTraits::difference_type difference_type;
0032     typedef typename OuterTraits::pointer pointer;
0033     typedef typename OuterTraits::const_pointer const_pointer;
0034     typedef typename OuterTraits::void_pointer void_pointer;
0035     typedef typename OuterTraits::const_void_pointer const_void_pointer;
0036 
0037     typedef see below propagate_on_container_copy_assignment;
0038     typedef see below propagate_on_container_move_assignment;
0039     typedef see below propagate_on_container_swap;
0040     typedef see below is_always_equal;
0041 
0042     template <class Tp>
0043         struct rebind
0044         {
0045             typedef scoped_allocator_adaptor<
0046                 OuterTraits::template rebind_alloc<Tp>, InnerAllocs...> other;
0047         };
0048 
0049     scoped_allocator_adaptor();
0050     template <class OuterA2>
0051         scoped_allocator_adaptor(OuterA2&& outerAlloc,
0052                                  const InnerAllocs&... innerAllocs) noexcept;
0053     scoped_allocator_adaptor(const scoped_allocator_adaptor& other) noexcept;
0054     scoped_allocator_adaptor(scoped_allocator_adaptor&& other) noexcept;
0055     template <class OuterA2>
0056         scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& other) noexcept;
0057     template <class OuterA2>
0058         scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2, InnerAllocs...>&& other) noexcept;
0059 
0060     scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default;
0061     scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default;
0062     ~scoped_allocator_adaptor();
0063 
0064     inner_allocator_type& inner_allocator() noexcept;
0065     const inner_allocator_type& inner_allocator() const noexcept;
0066 
0067     outer_allocator_type& outer_allocator() noexcept;
0068     const outer_allocator_type& outer_allocator() const noexcept;
0069 
0070     pointer allocate(size_type n);                           // [[nodiscard]] in C++20
0071     pointer allocate(size_type n, const_void_pointer hint);  // [[nodiscard]] in C++20
0072     void deallocate(pointer p, size_type n) noexcept;
0073 
0074     size_type max_size() const;
0075     template <class T, class... Args> void construct(T* p, Args&& args);
0076     template <class T1, class T2, class... Args1, class... Args2>
0077         void construct(pair<T1, T2>* p, piecewise_construct t, tuple<Args1...> x,
0078                        tuple<Args2...> y);
0079     template <class T1, class T2>
0080         void construct(pair<T1, T2>* p);
0081     template <class T1, class T2, class U, class V>
0082         void construct(pair<T1, T2>* p, U&& x, V&& y);
0083     template <class T1, class T2, class U, class V>
0084         void construct(pair<T1, T2>* p, const pair<U, V>& x);
0085     template <class T1, class T2, class U, class V>
0086         void construct(pair<T1, T2>* p, pair<U, V>&& x);
0087     template <class T> void destroy(T* p);
0088 
0089     template <class T> void destroy(T* p) noexcept;
0090 
0091     scoped_allocator_adaptor select_on_container_copy_construction() const noexcept;
0092 };
0093 
0094 template<class OuterAlloc, class... InnerAllocs>
0095     scoped_allocator_adaptor(OuterAlloc, InnerAllocs...)
0096         -> scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>;
0097 
0098 template <class OuterA1, class OuterA2, class... InnerAllocs>
0099     bool
0100     operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
0101                const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;
0102 
0103 template <class OuterA1, class OuterA2, class... InnerAllocs>
0104     bool
0105     operator!=(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
0106                const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept; // removed in C++20
0107 
0108 }  // std
0109 
0110 */
0111 
0112 #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
0113 #  include <__cxx03/scoped_allocator>
0114 #else
0115 #  include <__config>
0116 #  include <__memory/allocator_traits.h>
0117 #  include <__memory/uses_allocator_construction.h>
0118 #  include <__type_traits/common_type.h>
0119 #  include <__type_traits/enable_if.h>
0120 #  include <__type_traits/integral_constant.h>
0121 #  include <__type_traits/is_constructible.h>
0122 #  include <__type_traits/remove_reference.h>
0123 #  include <__utility/declval.h>
0124 #  include <__utility/forward.h>
0125 #  include <__utility/move.h>
0126 #  include <__utility/pair.h>
0127 #  include <__utility/piecewise_construct.h>
0128 #  include <tuple>
0129 #  include <version>
0130 
0131 #  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0132 #    pragma GCC system_header
0133 #  endif
0134 
0135 _LIBCPP_PUSH_MACROS
0136 #  include <__undef_macros>
0137 
0138 _LIBCPP_BEGIN_NAMESPACE_STD
0139 
0140 #  if !defined(_LIBCPP_CXX03_LANG)
0141 
0142 // scoped_allocator_adaptor
0143 
0144 template <class... _Allocs>
0145 class scoped_allocator_adaptor;
0146 
0147 template <class... _Allocs>
0148 struct __get_poc_copy_assignment;
0149 
0150 template <class _A0>
0151 struct __get_poc_copy_assignment<_A0> {
0152   static const bool value = allocator_traits<_A0>::propagate_on_container_copy_assignment::value;
0153 };
0154 
0155 template <class _A0, class... _Allocs>
0156 struct __get_poc_copy_assignment<_A0, _Allocs...> {
0157   static const bool value = allocator_traits<_A0>::propagate_on_container_copy_assignment::value ||
0158                             __get_poc_copy_assignment<_Allocs...>::value;
0159 };
0160 
0161 template <class... _Allocs>
0162 struct __get_poc_move_assignment;
0163 
0164 template <class _A0>
0165 struct __get_poc_move_assignment<_A0> {
0166   static const bool value = allocator_traits<_A0>::propagate_on_container_move_assignment::value;
0167 };
0168 
0169 template <class _A0, class... _Allocs>
0170 struct __get_poc_move_assignment<_A0, _Allocs...> {
0171   static const bool value = allocator_traits<_A0>::propagate_on_container_move_assignment::value ||
0172                             __get_poc_move_assignment<_Allocs...>::value;
0173 };
0174 
0175 template <class... _Allocs>
0176 struct __get_poc_swap;
0177 
0178 template <class _A0>
0179 struct __get_poc_swap<_A0> {
0180   static const bool value = allocator_traits<_A0>::propagate_on_container_swap::value;
0181 };
0182 
0183 template <class _A0, class... _Allocs>
0184 struct __get_poc_swap<_A0, _Allocs...> {
0185   static const bool value =
0186       allocator_traits<_A0>::propagate_on_container_swap::value || __get_poc_swap<_Allocs...>::value;
0187 };
0188 
0189 template <class... _Allocs>
0190 struct __get_is_always_equal;
0191 
0192 template <class _A0>
0193 struct __get_is_always_equal<_A0> {
0194   static const bool value = allocator_traits<_A0>::is_always_equal::value;
0195 };
0196 
0197 template <class _A0, class... _Allocs>
0198 struct __get_is_always_equal<_A0, _Allocs...> {
0199   static const bool value = allocator_traits<_A0>::is_always_equal::value && __get_is_always_equal<_Allocs...>::value;
0200 };
0201 
0202 template <class... _Allocs>
0203 class __scoped_allocator_storage;
0204 
0205 template <class _OuterAlloc, class... _InnerAllocs>
0206 class __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> : public _OuterAlloc {
0207   typedef _OuterAlloc outer_allocator_type;
0208 
0209 protected:
0210   typedef scoped_allocator_adaptor<_InnerAllocs...> inner_allocator_type;
0211 
0212 private:
0213   inner_allocator_type __inner_;
0214 
0215 protected:
0216   _LIBCPP_HIDE_FROM_ABI __scoped_allocator_storage() _NOEXCEPT {}
0217 
0218   template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0>
0219   _LIBCPP_HIDE_FROM_ABI
0220   __scoped_allocator_storage(_OuterA2&& __outer_alloc, const _InnerAllocs&... __inner_allocs) _NOEXCEPT
0221       : outer_allocator_type(std::forward<_OuterA2>(__outer_alloc)),
0222         __inner_(__inner_allocs...) {}
0223 
0224   template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, const _OuterA2&>::value, int> = 0>
0225   _LIBCPP_HIDE_FROM_ABI
0226   __scoped_allocator_storage(const __scoped_allocator_storage<_OuterA2, _InnerAllocs...>& __other) _NOEXCEPT
0227       : outer_allocator_type(__other.outer_allocator()),
0228         __inner_(__other.inner_allocator()) {}
0229 
0230   template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0>
0231   _LIBCPP_HIDE_FROM_ABI
0232   __scoped_allocator_storage(__scoped_allocator_storage<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT
0233       : outer_allocator_type(std::move(__other.outer_allocator())),
0234         __inner_(std::move(__other.inner_allocator())) {}
0235 
0236   template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0>
0237   _LIBCPP_HIDE_FROM_ABI __scoped_allocator_storage(_OuterA2&& __o, const inner_allocator_type& __i) _NOEXCEPT
0238       : outer_allocator_type(std::forward<_OuterA2>(__o)),
0239         __inner_(__i) {}
0240 
0241   _LIBCPP_HIDE_FROM_ABI inner_allocator_type& inner_allocator() _NOEXCEPT { return __inner_; }
0242   _LIBCPP_HIDE_FROM_ABI const inner_allocator_type& inner_allocator() const _NOEXCEPT { return __inner_; }
0243 
0244   _LIBCPP_HIDE_FROM_ABI outer_allocator_type& outer_allocator() _NOEXCEPT {
0245     return static_cast<outer_allocator_type&>(*this);
0246   }
0247   _LIBCPP_HIDE_FROM_ABI const outer_allocator_type& outer_allocator() const _NOEXCEPT {
0248     return static_cast<const outer_allocator_type&>(*this);
0249   }
0250 
0251   scoped_allocator_adaptor<outer_allocator_type, _InnerAllocs...> _LIBCPP_HIDE_FROM_ABI
0252   select_on_container_copy_construction() const _NOEXCEPT {
0253     return scoped_allocator_adaptor<outer_allocator_type, _InnerAllocs...>(
0254         allocator_traits<outer_allocator_type>::select_on_container_copy_construction(outer_allocator()),
0255         allocator_traits<inner_allocator_type>::select_on_container_copy_construction(inner_allocator()));
0256   }
0257 
0258   template <class...>
0259   friend class __scoped_allocator_storage;
0260 };
0261 
0262 template <class _OuterAlloc>
0263 class __scoped_allocator_storage<_OuterAlloc> : public _OuterAlloc {
0264   typedef _OuterAlloc outer_allocator_type;
0265 
0266 protected:
0267   typedef scoped_allocator_adaptor<_OuterAlloc> inner_allocator_type;
0268 
0269   _LIBCPP_HIDE_FROM_ABI __scoped_allocator_storage() _NOEXCEPT {}
0270 
0271   template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0>
0272   _LIBCPP_HIDE_FROM_ABI __scoped_allocator_storage(_OuterA2&& __outer_alloc) _NOEXCEPT
0273       : outer_allocator_type(std::forward<_OuterA2>(__outer_alloc)) {}
0274 
0275   template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, const _OuterA2&>::value, int> = 0>
0276   _LIBCPP_HIDE_FROM_ABI __scoped_allocator_storage(const __scoped_allocator_storage<_OuterA2>& __other) _NOEXCEPT
0277       : outer_allocator_type(__other.outer_allocator()) {}
0278 
0279   template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0>
0280   _LIBCPP_HIDE_FROM_ABI __scoped_allocator_storage(__scoped_allocator_storage<_OuterA2>&& __other) _NOEXCEPT
0281       : outer_allocator_type(std::move(__other.outer_allocator())) {}
0282 
0283   _LIBCPP_HIDE_FROM_ABI inner_allocator_type& inner_allocator() _NOEXCEPT {
0284     return static_cast<inner_allocator_type&>(*this);
0285   }
0286   _LIBCPP_HIDE_FROM_ABI const inner_allocator_type& inner_allocator() const _NOEXCEPT {
0287     return static_cast<const inner_allocator_type&>(*this);
0288   }
0289 
0290   _LIBCPP_HIDE_FROM_ABI outer_allocator_type& outer_allocator() _NOEXCEPT {
0291     return static_cast<outer_allocator_type&>(*this);
0292   }
0293   _LIBCPP_HIDE_FROM_ABI const outer_allocator_type& outer_allocator() const _NOEXCEPT {
0294     return static_cast<const outer_allocator_type&>(*this);
0295   }
0296 
0297   _LIBCPP_HIDE_FROM_ABI scoped_allocator_adaptor<outer_allocator_type>
0298   select_on_container_copy_construction() const _NOEXCEPT {
0299     return scoped_allocator_adaptor<outer_allocator_type>(
0300         allocator_traits<outer_allocator_type>::select_on_container_copy_construction(outer_allocator()));
0301   }
0302 
0303   __scoped_allocator_storage(const outer_allocator_type& __o, const inner_allocator_type& __i) _NOEXCEPT;
0304 
0305   template <class...>
0306   friend class __scoped_allocator_storage;
0307 };
0308 
0309 // __outermost
0310 
0311 template <class _Alloc>
0312 decltype(std::declval<_Alloc>().outer_allocator(), true_type()) __has_outer_allocator_test(_Alloc&& __a);
0313 
0314 template <class _Alloc>
0315 false_type __has_outer_allocator_test(const volatile _Alloc& __a);
0316 
0317 template <class _Alloc>
0318 struct __has_outer_allocator
0319     : public common_type< decltype(std::__has_outer_allocator_test(std::declval<_Alloc&>()))>::type {};
0320 
0321 template <class _Alloc, bool = __has_outer_allocator<_Alloc>::value>
0322 struct __outermost {
0323   typedef _Alloc type;
0324   _LIBCPP_HIDE_FROM_ABI type& operator()(type& __a) const _NOEXCEPT { return __a; }
0325 };
0326 
0327 template <class _Alloc>
0328 struct __outermost<_Alloc, true> {
0329   typedef __libcpp_remove_reference_t< decltype(std::declval<_Alloc>().outer_allocator()) > _OuterAlloc;
0330   typedef typename __outermost<_OuterAlloc>::type type;
0331   _LIBCPP_HIDE_FROM_ABI type& operator()(_Alloc& __a) const _NOEXCEPT {
0332     return __outermost<_OuterAlloc>()(__a.outer_allocator());
0333   }
0334 };
0335 
0336 template <class _OuterAlloc, class... _InnerAllocs>
0337 class _LIBCPP_TEMPLATE_VIS scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>
0338     : public __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> {
0339   typedef __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> _Base;
0340   typedef allocator_traits<_OuterAlloc> _OuterTraits;
0341 
0342 public:
0343   typedef _OuterAlloc outer_allocator_type;
0344   typedef typename _Base::inner_allocator_type inner_allocator_type;
0345   typedef typename _OuterTraits::size_type size_type;
0346   typedef typename _OuterTraits::difference_type difference_type;
0347   typedef typename _OuterTraits::pointer pointer;
0348   typedef typename _OuterTraits::const_pointer const_pointer;
0349   typedef typename _OuterTraits::void_pointer void_pointer;
0350   typedef typename _OuterTraits::const_void_pointer const_void_pointer;
0351 
0352   typedef integral_constant< bool, __get_poc_copy_assignment<outer_allocator_type, _InnerAllocs...>::value >
0353       propagate_on_container_copy_assignment;
0354   typedef integral_constant< bool, __get_poc_move_assignment<outer_allocator_type, _InnerAllocs...>::value >
0355       propagate_on_container_move_assignment;
0356   typedef integral_constant< bool, __get_poc_swap<outer_allocator_type, _InnerAllocs...>::value >
0357       propagate_on_container_swap;
0358   typedef integral_constant< bool, __get_is_always_equal<outer_allocator_type, _InnerAllocs...>::value >
0359       is_always_equal;
0360 
0361   template <class _Tp>
0362   struct rebind {
0363     typedef scoped_allocator_adaptor< typename _OuterTraits::template rebind_alloc<_Tp>, _InnerAllocs... > other;
0364   };
0365 
0366   _LIBCPP_HIDE_FROM_ABI scoped_allocator_adaptor() _NOEXCEPT {}
0367   template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0>
0368   _LIBCPP_HIDE_FROM_ABI
0369   scoped_allocator_adaptor(_OuterA2&& __outer_alloc, const _InnerAllocs&... __inner_allocs) _NOEXCEPT
0370       : _Base(std::forward<_OuterA2>(__outer_alloc), __inner_allocs...) {}
0371   // scoped_allocator_adaptor(const scoped_allocator_adaptor& __other) = default;
0372   template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, const _OuterA2&>::value, int> = 0>
0373   _LIBCPP_HIDE_FROM_ABI
0374   scoped_allocator_adaptor(const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __other) _NOEXCEPT
0375       : _Base(__other) {}
0376   template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0>
0377   _LIBCPP_HIDE_FROM_ABI
0378   scoped_allocator_adaptor(scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT
0379       : _Base(std::move(__other)) {}
0380 
0381   // scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default;
0382   // scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default;
0383   // ~scoped_allocator_adaptor() = default;
0384 
0385   _LIBCPP_HIDE_FROM_ABI inner_allocator_type& inner_allocator() _NOEXCEPT { return _Base::inner_allocator(); }
0386   _LIBCPP_HIDE_FROM_ABI const inner_allocator_type& inner_allocator() const _NOEXCEPT {
0387     return _Base::inner_allocator();
0388   }
0389 
0390   _LIBCPP_HIDE_FROM_ABI outer_allocator_type& outer_allocator() _NOEXCEPT { return _Base::outer_allocator(); }
0391   _LIBCPP_HIDE_FROM_ABI const outer_allocator_type& outer_allocator() const _NOEXCEPT {
0392     return _Base::outer_allocator();
0393   }
0394 
0395   [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n) {
0396     return allocator_traits<outer_allocator_type>::allocate(outer_allocator(), __n);
0397   }
0398   [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n, const_void_pointer __hint) {
0399     return allocator_traits<outer_allocator_type>::allocate(outer_allocator(), __n, __hint);
0400   }
0401 
0402   _LIBCPP_HIDE_FROM_ABI void deallocate(pointer __p, size_type __n) _NOEXCEPT {
0403     allocator_traits<outer_allocator_type>::deallocate(outer_allocator(), __p, __n);
0404   }
0405 
0406   _LIBCPP_HIDE_FROM_ABI size_type max_size() const {
0407     return allocator_traits<outer_allocator_type>::max_size(outer_allocator());
0408   }
0409 
0410 #    if _LIBCPP_STD_VER >= 20
0411   template <class _Type, class... _Args>
0412   _LIBCPP_HIDE_FROM_ABI void construct(_Type* __ptr, _Args&&... __args) {
0413     using _OM = __outermost<outer_allocator_type>;
0414     std::apply(
0415         [__ptr, this](auto&&... __newargs) {
0416           allocator_traits<typename _OM::type>::construct(
0417               _OM()(outer_allocator()), __ptr, std::forward<decltype(__newargs)>(__newargs)...);
0418         },
0419         std::uses_allocator_construction_args<_Type>(inner_allocator(), std::forward<_Args>(__args)...));
0420   }
0421 #    else
0422   template <class _Tp, class... _Args>
0423   _LIBCPP_HIDE_FROM_ABI void construct(_Tp* __p, _Args&&... __args) {
0424     __construct(__uses_alloc_ctor<_Tp, inner_allocator_type&, _Args...>(), __p, std::forward<_Args>(__args)...);
0425   }
0426 
0427   template <class _T1, class _T2, class... _Args1, class... _Args2>
0428   _LIBCPP_HIDE_FROM_ABI void
0429   construct(pair<_T1, _T2>* __p, piecewise_construct_t, tuple<_Args1...> __x, tuple<_Args2...> __y) {
0430     typedef __outermost<outer_allocator_type> _OM;
0431     allocator_traits<typename _OM::type>::construct(
0432         _OM()(outer_allocator()),
0433         __p,
0434         piecewise_construct,
0435         __transform_tuple(typename __uses_alloc_ctor< _T1, inner_allocator_type&, _Args1... >::type(),
0436                           std::move(__x),
0437                           typename __make_tuple_indices<sizeof...(_Args1)>::type{}),
0438         __transform_tuple(typename __uses_alloc_ctor< _T2, inner_allocator_type&, _Args2... >::type(),
0439                           std::move(__y),
0440                           typename __make_tuple_indices<sizeof...(_Args2)>::type{}));
0441   }
0442 
0443   template <class _T1, class _T2>
0444   _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p) {
0445     construct(__p, piecewise_construct, tuple<>{}, tuple<>{});
0446   }
0447 
0448   template <class _T1, class _T2, class _Up, class _Vp>
0449   _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, _Up&& __x, _Vp&& __y) {
0450     construct(__p,
0451               piecewise_construct,
0452               std::forward_as_tuple(std::forward<_Up>(__x)),
0453               std::forward_as_tuple(std::forward<_Vp>(__y)));
0454   }
0455 
0456   template <class _T1, class _T2, class _Up, class _Vp>
0457   _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, const pair<_Up, _Vp>& __x) {
0458     construct(__p, piecewise_construct, std::forward_as_tuple(__x.first), std::forward_as_tuple(__x.second));
0459   }
0460 
0461   template <class _T1, class _T2, class _Up, class _Vp>
0462   _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, pair<_Up, _Vp>&& __x) {
0463     construct(__p,
0464               piecewise_construct,
0465               std::forward_as_tuple(std::forward<_Up>(__x.first)),
0466               std::forward_as_tuple(std::forward<_Vp>(__x.second)));
0467   }
0468 #    endif
0469 
0470   template <class _Tp>
0471   _LIBCPP_HIDE_FROM_ABI void destroy(_Tp* __p) {
0472     typedef __outermost<outer_allocator_type> _OM;
0473     allocator_traits<typename _OM::type>::destroy(_OM()(outer_allocator()), __p);
0474   }
0475 
0476   _LIBCPP_HIDE_FROM_ABI scoped_allocator_adaptor select_on_container_copy_construction() const _NOEXCEPT {
0477     return _Base::select_on_container_copy_construction();
0478   }
0479 
0480 private:
0481   _LIBCPP_HIDE_FROM_ABI explicit scoped_allocator_adaptor(
0482       outer_allocator_type&& __o, inner_allocator_type&& __i) _NOEXCEPT : _Base(std::move(__o), std::move(__i)) {}
0483 
0484   template <class _Tp, class... _Args>
0485   _LIBCPP_HIDE_FROM_ABI void __construct(integral_constant<int, 0>, _Tp* __p, _Args&&... __args) {
0486     typedef __outermost<outer_allocator_type> _OM;
0487     allocator_traits<typename _OM::type>::construct(_OM()(outer_allocator()), __p, std::forward<_Args>(__args)...);
0488   }
0489 
0490   template <class _Tp, class... _Args>
0491   _LIBCPP_HIDE_FROM_ABI void __construct(integral_constant<int, 1>, _Tp* __p, _Args&&... __args) {
0492     typedef __outermost<outer_allocator_type> _OM;
0493     allocator_traits<typename _OM::type>::construct(
0494         _OM()(outer_allocator()), __p, allocator_arg, inner_allocator(), std::forward<_Args>(__args)...);
0495   }
0496 
0497   template <class _Tp, class... _Args>
0498   _LIBCPP_HIDE_FROM_ABI void __construct(integral_constant<int, 2>, _Tp* __p, _Args&&... __args) {
0499     typedef __outermost<outer_allocator_type> _OM;
0500     allocator_traits<typename _OM::type>::construct(
0501         _OM()(outer_allocator()), __p, std::forward<_Args>(__args)..., inner_allocator());
0502   }
0503 
0504   template <class... _Args, size_t... _Idx>
0505   _LIBCPP_HIDE_FROM_ABI tuple<_Args&&...>
0506   __transform_tuple(integral_constant<int, 0>, tuple<_Args...>&& __t, __tuple_indices<_Idx...>) {
0507     return std::forward_as_tuple(std::get<_Idx>(std::move(__t))...);
0508   }
0509 
0510   template <class... _Args, size_t... _Idx>
0511   _LIBCPP_HIDE_FROM_ABI tuple<allocator_arg_t, inner_allocator_type&, _Args&&...>
0512   __transform_tuple(integral_constant<int, 1>, tuple<_Args...>&& __t, __tuple_indices<_Idx...>) {
0513     using _Tup = tuple<allocator_arg_t, inner_allocator_type&, _Args&&...>;
0514     return _Tup(allocator_arg, inner_allocator(), std::get<_Idx>(std::move(__t))...);
0515   }
0516 
0517   template <class... _Args, size_t... _Idx>
0518   _LIBCPP_HIDE_FROM_ABI tuple<_Args&&..., inner_allocator_type&>
0519   __transform_tuple(integral_constant<int, 2>, tuple<_Args...>&& __t, __tuple_indices<_Idx...>) {
0520     using _Tup = tuple<_Args&&..., inner_allocator_type&>;
0521     return _Tup(std::get<_Idx>(std::move(__t))..., inner_allocator());
0522   }
0523 
0524   template <class...>
0525   friend class __scoped_allocator_storage;
0526 };
0527 
0528 #    if _LIBCPP_STD_VER >= 17
0529 template <class _OuterAlloc, class... _InnerAllocs>
0530 scoped_allocator_adaptor(_OuterAlloc, _InnerAllocs...) -> scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>;
0531 #    endif
0532 
0533 template <class _OuterA1, class _OuterA2>
0534 inline _LIBCPP_HIDE_FROM_ABI bool
0535 operator==(const scoped_allocator_adaptor<_OuterA1>& __a, const scoped_allocator_adaptor<_OuterA2>& __b) _NOEXCEPT {
0536   return __a.outer_allocator() == __b.outer_allocator();
0537 }
0538 
0539 template <class _OuterA1, class _OuterA2, class _InnerA0, class... _InnerAllocs>
0540 inline _LIBCPP_HIDE_FROM_ABI bool
0541 operator==(const scoped_allocator_adaptor<_OuterA1, _InnerA0, _InnerAllocs...>& __a,
0542            const scoped_allocator_adaptor<_OuterA2, _InnerA0, _InnerAllocs...>& __b) _NOEXCEPT {
0543   return __a.outer_allocator() == __b.outer_allocator() && __a.inner_allocator() == __b.inner_allocator();
0544 }
0545 
0546 #    if _LIBCPP_STD_VER <= 17
0547 
0548 template <class _OuterA1, class _OuterA2, class... _InnerAllocs>
0549 inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const scoped_allocator_adaptor<_OuterA1, _InnerAllocs...>& __a,
0550                                              const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __b) _NOEXCEPT {
0551   return !(__a == __b);
0552 }
0553 
0554 #    endif // _LIBCPP_STD_VER <= 17
0555 
0556 #  endif // !defined(_LIBCPP_CXX03_LANG)
0557 
0558 _LIBCPP_END_NAMESPACE_STD
0559 
0560 _LIBCPP_POP_MACROS
0561 
0562 #  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
0563 #    include <atomic>
0564 #    include <climits>
0565 #    include <concepts>
0566 #    include <cstring>
0567 #    include <ctime>
0568 #    include <iterator>
0569 #    include <memory>
0570 #    include <ratio>
0571 #    include <stdexcept>
0572 #    include <type_traits>
0573 #    include <variant>
0574 #  endif
0575 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
0576 
0577 #endif // _LIBCPP_SCOPED_ALLOCATOR