Warning, /include/c++/v1/__cxx03/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___CXX03_SCOPED_ALLOCATOR
0011 #define _LIBCPP___CXX03_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 #include <__cxx03/__config>
0113 #include <__cxx03/__memory/allocator_traits.h>
0114 #include <__cxx03/__memory/uses_allocator_construction.h>
0115 #include <__cxx03/__type_traits/common_type.h>
0116 #include <__cxx03/__type_traits/enable_if.h>
0117 #include <__cxx03/__type_traits/integral_constant.h>
0118 #include <__cxx03/__type_traits/is_constructible.h>
0119 #include <__cxx03/__type_traits/remove_reference.h>
0120 #include <__cxx03/__utility/declval.h>
0121 #include <__cxx03/__utility/forward.h>
0122 #include <__cxx03/__utility/move.h>
0123 #include <__cxx03/__utility/pair.h>
0124 #include <__cxx03/__utility/piecewise_construct.h>
0125 #include <__cxx03/tuple>
0126 #include <__cxx03/version>
0127
0128 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0129 # pragma GCC system_header
0130 #endif
0131
0132 _LIBCPP_PUSH_MACROS
0133 #include <__cxx03/__undef_macros>
0134
0135 _LIBCPP_BEGIN_NAMESPACE_STD
0136
0137 #if !defined(_LIBCPP_CXX03_LANG)
0138
0139 // scoped_allocator_adaptor
0140
0141 template <class... _Allocs>
0142 class scoped_allocator_adaptor;
0143
0144 template <class... _Allocs>
0145 struct __get_poc_copy_assignment;
0146
0147 template <class _A0>
0148 struct __get_poc_copy_assignment<_A0> {
0149 static const bool value = allocator_traits<_A0>::propagate_on_container_copy_assignment::value;
0150 };
0151
0152 template <class _A0, class... _Allocs>
0153 struct __get_poc_copy_assignment<_A0, _Allocs...> {
0154 static const bool value = allocator_traits<_A0>::propagate_on_container_copy_assignment::value ||
0155 __get_poc_copy_assignment<_Allocs...>::value;
0156 };
0157
0158 template <class... _Allocs>
0159 struct __get_poc_move_assignment;
0160
0161 template <class _A0>
0162 struct __get_poc_move_assignment<_A0> {
0163 static const bool value = allocator_traits<_A0>::propagate_on_container_move_assignment::value;
0164 };
0165
0166 template <class _A0, class... _Allocs>
0167 struct __get_poc_move_assignment<_A0, _Allocs...> {
0168 static const bool value = allocator_traits<_A0>::propagate_on_container_move_assignment::value ||
0169 __get_poc_move_assignment<_Allocs...>::value;
0170 };
0171
0172 template <class... _Allocs>
0173 struct __get_poc_swap;
0174
0175 template <class _A0>
0176 struct __get_poc_swap<_A0> {
0177 static const bool value = allocator_traits<_A0>::propagate_on_container_swap::value;
0178 };
0179
0180 template <class _A0, class... _Allocs>
0181 struct __get_poc_swap<_A0, _Allocs...> {
0182 static const bool value =
0183 allocator_traits<_A0>::propagate_on_container_swap::value || __get_poc_swap<_Allocs...>::value;
0184 };
0185
0186 template <class... _Allocs>
0187 struct __get_is_always_equal;
0188
0189 template <class _A0>
0190 struct __get_is_always_equal<_A0> {
0191 static const bool value = allocator_traits<_A0>::is_always_equal::value;
0192 };
0193
0194 template <class _A0, class... _Allocs>
0195 struct __get_is_always_equal<_A0, _Allocs...> {
0196 static const bool value = allocator_traits<_A0>::is_always_equal::value && __get_is_always_equal<_Allocs...>::value;
0197 };
0198
0199 template <class... _Allocs>
0200 class __scoped_allocator_storage;
0201
0202 template <class _OuterAlloc, class... _InnerAllocs>
0203 class __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> : public _OuterAlloc {
0204 typedef _OuterAlloc outer_allocator_type;
0205
0206 protected:
0207 typedef scoped_allocator_adaptor<_InnerAllocs...> inner_allocator_type;
0208
0209 private:
0210 inner_allocator_type __inner_;
0211
0212 protected:
0213 _LIBCPP_HIDE_FROM_ABI __scoped_allocator_storage() _NOEXCEPT {}
0214
0215 template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0>
0216 _LIBCPP_HIDE_FROM_ABI
0217 __scoped_allocator_storage(_OuterA2&& __outer_alloc, const _InnerAllocs&... __inner_allocs) _NOEXCEPT
0218 : outer_allocator_type(std::forward<_OuterA2>(__outer_alloc)),
0219 __inner_(__inner_allocs...) {}
0220
0221 template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, const _OuterA2&>::value, int> = 0>
0222 _LIBCPP_HIDE_FROM_ABI
0223 __scoped_allocator_storage(const __scoped_allocator_storage<_OuterA2, _InnerAllocs...>& __other) _NOEXCEPT
0224 : outer_allocator_type(__other.outer_allocator()),
0225 __inner_(__other.inner_allocator()) {}
0226
0227 template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0>
0228 _LIBCPP_HIDE_FROM_ABI
0229 __scoped_allocator_storage(__scoped_allocator_storage<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT
0230 : outer_allocator_type(std::move(__other.outer_allocator())),
0231 __inner_(std::move(__other.inner_allocator())) {}
0232
0233 template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0>
0234 _LIBCPP_HIDE_FROM_ABI __scoped_allocator_storage(_OuterA2&& __o, const inner_allocator_type& __i) _NOEXCEPT
0235 : outer_allocator_type(std::forward<_OuterA2>(__o)),
0236 __inner_(__i) {}
0237
0238 _LIBCPP_HIDE_FROM_ABI inner_allocator_type& inner_allocator() _NOEXCEPT { return __inner_; }
0239 _LIBCPP_HIDE_FROM_ABI const inner_allocator_type& inner_allocator() const _NOEXCEPT { return __inner_; }
0240
0241 _LIBCPP_HIDE_FROM_ABI outer_allocator_type& outer_allocator() _NOEXCEPT {
0242 return static_cast<outer_allocator_type&>(*this);
0243 }
0244 _LIBCPP_HIDE_FROM_ABI const outer_allocator_type& outer_allocator() const _NOEXCEPT {
0245 return static_cast<const outer_allocator_type&>(*this);
0246 }
0247
0248 scoped_allocator_adaptor<outer_allocator_type, _InnerAllocs...> _LIBCPP_HIDE_FROM_ABI
0249 select_on_container_copy_construction() const _NOEXCEPT {
0250 return scoped_allocator_adaptor<outer_allocator_type, _InnerAllocs...>(
0251 allocator_traits<outer_allocator_type>::select_on_container_copy_construction(outer_allocator()),
0252 allocator_traits<inner_allocator_type>::select_on_container_copy_construction(inner_allocator()));
0253 }
0254
0255 template <class...>
0256 friend class __scoped_allocator_storage;
0257 };
0258
0259 template <class _OuterAlloc>
0260 class __scoped_allocator_storage<_OuterAlloc> : public _OuterAlloc {
0261 typedef _OuterAlloc outer_allocator_type;
0262
0263 protected:
0264 typedef scoped_allocator_adaptor<_OuterAlloc> inner_allocator_type;
0265
0266 _LIBCPP_HIDE_FROM_ABI __scoped_allocator_storage() _NOEXCEPT {}
0267
0268 template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0>
0269 _LIBCPP_HIDE_FROM_ABI __scoped_allocator_storage(_OuterA2&& __outer_alloc) _NOEXCEPT
0270 : outer_allocator_type(std::forward<_OuterA2>(__outer_alloc)) {}
0271
0272 template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, const _OuterA2&>::value, int> = 0>
0273 _LIBCPP_HIDE_FROM_ABI __scoped_allocator_storage(const __scoped_allocator_storage<_OuterA2>& __other) _NOEXCEPT
0274 : outer_allocator_type(__other.outer_allocator()) {}
0275
0276 template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0>
0277 _LIBCPP_HIDE_FROM_ABI __scoped_allocator_storage(__scoped_allocator_storage<_OuterA2>&& __other) _NOEXCEPT
0278 : outer_allocator_type(std::move(__other.outer_allocator())) {}
0279
0280 _LIBCPP_HIDE_FROM_ABI inner_allocator_type& inner_allocator() _NOEXCEPT {
0281 return static_cast<inner_allocator_type&>(*this);
0282 }
0283 _LIBCPP_HIDE_FROM_ABI const inner_allocator_type& inner_allocator() const _NOEXCEPT {
0284 return static_cast<const inner_allocator_type&>(*this);
0285 }
0286
0287 _LIBCPP_HIDE_FROM_ABI outer_allocator_type& outer_allocator() _NOEXCEPT {
0288 return static_cast<outer_allocator_type&>(*this);
0289 }
0290 _LIBCPP_HIDE_FROM_ABI const outer_allocator_type& outer_allocator() const _NOEXCEPT {
0291 return static_cast<const outer_allocator_type&>(*this);
0292 }
0293
0294 _LIBCPP_HIDE_FROM_ABI scoped_allocator_adaptor<outer_allocator_type>
0295 select_on_container_copy_construction() const _NOEXCEPT {
0296 return scoped_allocator_adaptor<outer_allocator_type>(
0297 allocator_traits<outer_allocator_type>::select_on_container_copy_construction(outer_allocator()));
0298 }
0299
0300 __scoped_allocator_storage(const outer_allocator_type& __o, const inner_allocator_type& __i) _NOEXCEPT;
0301
0302 template <class...>
0303 friend class __scoped_allocator_storage;
0304 };
0305
0306 // __outermost
0307
0308 template <class _Alloc>
0309 decltype(std::declval<_Alloc>().outer_allocator(), true_type()) __has_outer_allocator_test(_Alloc&& __a);
0310
0311 template <class _Alloc>
0312 false_type __has_outer_allocator_test(const volatile _Alloc& __a);
0313
0314 template <class _Alloc>
0315 struct __has_outer_allocator
0316 : public common_type< decltype(std::__has_outer_allocator_test(std::declval<_Alloc&>()))>::type {};
0317
0318 template <class _Alloc, bool = __has_outer_allocator<_Alloc>::value>
0319 struct __outermost {
0320 typedef _Alloc type;
0321 _LIBCPP_HIDE_FROM_ABI type& operator()(type& __a) const _NOEXCEPT { return __a; }
0322 };
0323
0324 template <class _Alloc>
0325 struct __outermost<_Alloc, true> {
0326 typedef __libcpp_remove_reference_t< decltype(std::declval<_Alloc>().outer_allocator()) > _OuterAlloc;
0327 typedef typename __outermost<_OuterAlloc>::type type;
0328 _LIBCPP_HIDE_FROM_ABI type& operator()(_Alloc& __a) const _NOEXCEPT {
0329 return __outermost<_OuterAlloc>()(__a.outer_allocator());
0330 }
0331 };
0332
0333 template <class _OuterAlloc, class... _InnerAllocs>
0334 class _LIBCPP_TEMPLATE_VIS scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>
0335 : public __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> {
0336 typedef __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> _Base;
0337 typedef allocator_traits<_OuterAlloc> _OuterTraits;
0338
0339 public:
0340 typedef _OuterAlloc outer_allocator_type;
0341 typedef typename _Base::inner_allocator_type inner_allocator_type;
0342 typedef typename _OuterTraits::size_type size_type;
0343 typedef typename _OuterTraits::difference_type difference_type;
0344 typedef typename _OuterTraits::pointer pointer;
0345 typedef typename _OuterTraits::const_pointer const_pointer;
0346 typedef typename _OuterTraits::void_pointer void_pointer;
0347 typedef typename _OuterTraits::const_void_pointer const_void_pointer;
0348
0349 typedef integral_constant< bool, __get_poc_copy_assignment<outer_allocator_type, _InnerAllocs...>::value >
0350 propagate_on_container_copy_assignment;
0351 typedef integral_constant< bool, __get_poc_move_assignment<outer_allocator_type, _InnerAllocs...>::value >
0352 propagate_on_container_move_assignment;
0353 typedef integral_constant< bool, __get_poc_swap<outer_allocator_type, _InnerAllocs...>::value >
0354 propagate_on_container_swap;
0355 typedef integral_constant< bool, __get_is_always_equal<outer_allocator_type, _InnerAllocs...>::value >
0356 is_always_equal;
0357
0358 template <class _Tp>
0359 struct rebind {
0360 typedef scoped_allocator_adaptor< typename _OuterTraits::template rebind_alloc<_Tp>, _InnerAllocs... > other;
0361 };
0362
0363 _LIBCPP_HIDE_FROM_ABI scoped_allocator_adaptor() _NOEXCEPT {}
0364 template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0>
0365 _LIBCPP_HIDE_FROM_ABI
0366 scoped_allocator_adaptor(_OuterA2&& __outer_alloc, const _InnerAllocs&... __inner_allocs) _NOEXCEPT
0367 : _Base(std::forward<_OuterA2>(__outer_alloc), __inner_allocs...) {}
0368 // scoped_allocator_adaptor(const scoped_allocator_adaptor& __other) = default;
0369 template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, const _OuterA2&>::value, int> = 0>
0370 _LIBCPP_HIDE_FROM_ABI
0371 scoped_allocator_adaptor(const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __other) _NOEXCEPT
0372 : _Base(__other) {}
0373 template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0>
0374 _LIBCPP_HIDE_FROM_ABI
0375 scoped_allocator_adaptor(scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT
0376 : _Base(std::move(__other)) {}
0377
0378 // scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default;
0379 // scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default;
0380 // ~scoped_allocator_adaptor() = default;
0381
0382 _LIBCPP_HIDE_FROM_ABI inner_allocator_type& inner_allocator() _NOEXCEPT { return _Base::inner_allocator(); }
0383 _LIBCPP_HIDE_FROM_ABI const inner_allocator_type& inner_allocator() const _NOEXCEPT {
0384 return _Base::inner_allocator();
0385 }
0386
0387 _LIBCPP_HIDE_FROM_ABI outer_allocator_type& outer_allocator() _NOEXCEPT { return _Base::outer_allocator(); }
0388 _LIBCPP_HIDE_FROM_ABI const outer_allocator_type& outer_allocator() const _NOEXCEPT {
0389 return _Base::outer_allocator();
0390 }
0391
0392 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n) {
0393 return allocator_traits<outer_allocator_type>::allocate(outer_allocator(), __n);
0394 }
0395 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n, const_void_pointer __hint) {
0396 return allocator_traits<outer_allocator_type>::allocate(outer_allocator(), __n, __hint);
0397 }
0398
0399 _LIBCPP_HIDE_FROM_ABI void deallocate(pointer __p, size_type __n) _NOEXCEPT {
0400 allocator_traits<outer_allocator_type>::deallocate(outer_allocator(), __p, __n);
0401 }
0402
0403 _LIBCPP_HIDE_FROM_ABI size_type max_size() const {
0404 return allocator_traits<outer_allocator_type>::max_size(outer_allocator());
0405 }
0406
0407 # if _LIBCPP_STD_VER >= 20
0408 template <class _Type, class... _Args>
0409 _LIBCPP_HIDE_FROM_ABI void construct(_Type* __ptr, _Args&&... __args) {
0410 using _OM = __outermost<outer_allocator_type>;
0411 std::apply(
0412 [__ptr, this](auto&&... __newargs) {
0413 allocator_traits<typename _OM::type>::construct(
0414 _OM()(outer_allocator()), __ptr, std::forward<decltype(__newargs)>(__newargs)...);
0415 },
0416 std::uses_allocator_construction_args<_Type>(inner_allocator(), std::forward<_Args>(__args)...));
0417 }
0418 # else
0419 template <class _Tp, class... _Args>
0420 _LIBCPP_HIDE_FROM_ABI void construct(_Tp* __p, _Args&&... __args) {
0421 __construct(__uses_alloc_ctor<_Tp, inner_allocator_type&, _Args...>(), __p, std::forward<_Args>(__args)...);
0422 }
0423
0424 template <class _T1, class _T2, class... _Args1, class... _Args2>
0425 _LIBCPP_HIDE_FROM_ABI void
0426 construct(pair<_T1, _T2>* __p, piecewise_construct_t, tuple<_Args1...> __x, tuple<_Args2...> __y) {
0427 typedef __outermost<outer_allocator_type> _OM;
0428 allocator_traits<typename _OM::type>::construct(
0429 _OM()(outer_allocator()),
0430 __p,
0431 piecewise_construct,
0432 __transform_tuple(typename __uses_alloc_ctor< _T1, inner_allocator_type&, _Args1... >::type(),
0433 std::move(__x),
0434 typename __make_tuple_indices<sizeof...(_Args1)>::type{}),
0435 __transform_tuple(typename __uses_alloc_ctor< _T2, inner_allocator_type&, _Args2... >::type(),
0436 std::move(__y),
0437 typename __make_tuple_indices<sizeof...(_Args2)>::type{}));
0438 }
0439
0440 template <class _T1, class _T2>
0441 _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p) {
0442 construct(__p, piecewise_construct, tuple<>{}, tuple<>{});
0443 }
0444
0445 template <class _T1, class _T2, class _Up, class _Vp>
0446 _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, _Up&& __x, _Vp&& __y) {
0447 construct(__p,
0448 piecewise_construct,
0449 std::forward_as_tuple(std::forward<_Up>(__x)),
0450 std::forward_as_tuple(std::forward<_Vp>(__y)));
0451 }
0452
0453 template <class _T1, class _T2, class _Up, class _Vp>
0454 _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, const pair<_Up, _Vp>& __x) {
0455 construct(__p, piecewise_construct, std::forward_as_tuple(__x.first), std::forward_as_tuple(__x.second));
0456 }
0457
0458 template <class _T1, class _T2, class _Up, class _Vp>
0459 _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, pair<_Up, _Vp>&& __x) {
0460 construct(__p,
0461 piecewise_construct,
0462 std::forward_as_tuple(std::forward<_Up>(__x.first)),
0463 std::forward_as_tuple(std::forward<_Vp>(__x.second)));
0464 }
0465 # endif
0466
0467 template <class _Tp>
0468 _LIBCPP_HIDE_FROM_ABI void destroy(_Tp* __p) {
0469 typedef __outermost<outer_allocator_type> _OM;
0470 allocator_traits<typename _OM::type>::destroy(_OM()(outer_allocator()), __p);
0471 }
0472
0473 _LIBCPP_HIDE_FROM_ABI scoped_allocator_adaptor select_on_container_copy_construction() const _NOEXCEPT {
0474 return _Base::select_on_container_copy_construction();
0475 }
0476
0477 private:
0478 _LIBCPP_HIDE_FROM_ABI explicit scoped_allocator_adaptor(
0479 outer_allocator_type&& __o, inner_allocator_type&& __i) _NOEXCEPT : _Base(std::move(__o), std::move(__i)) {}
0480
0481 template <class _Tp, class... _Args>
0482 _LIBCPP_HIDE_FROM_ABI void __construct(integral_constant<int, 0>, _Tp* __p, _Args&&... __args) {
0483 typedef __outermost<outer_allocator_type> _OM;
0484 allocator_traits<typename _OM::type>::construct(_OM()(outer_allocator()), __p, std::forward<_Args>(__args)...);
0485 }
0486
0487 template <class _Tp, class... _Args>
0488 _LIBCPP_HIDE_FROM_ABI void __construct(integral_constant<int, 1>, _Tp* __p, _Args&&... __args) {
0489 typedef __outermost<outer_allocator_type> _OM;
0490 allocator_traits<typename _OM::type>::construct(
0491 _OM()(outer_allocator()), __p, allocator_arg, inner_allocator(), std::forward<_Args>(__args)...);
0492 }
0493
0494 template <class _Tp, class... _Args>
0495 _LIBCPP_HIDE_FROM_ABI void __construct(integral_constant<int, 2>, _Tp* __p, _Args&&... __args) {
0496 typedef __outermost<outer_allocator_type> _OM;
0497 allocator_traits<typename _OM::type>::construct(
0498 _OM()(outer_allocator()), __p, std::forward<_Args>(__args)..., inner_allocator());
0499 }
0500
0501 template <class... _Args, size_t... _Idx>
0502 _LIBCPP_HIDE_FROM_ABI tuple<_Args&&...>
0503 __transform_tuple(integral_constant<int, 0>, tuple<_Args...>&& __t, __tuple_indices<_Idx...>) {
0504 return std::forward_as_tuple(std::get<_Idx>(std::move(__t))...);
0505 }
0506
0507 template <class... _Args, size_t... _Idx>
0508 _LIBCPP_HIDE_FROM_ABI tuple<allocator_arg_t, inner_allocator_type&, _Args&&...>
0509 __transform_tuple(integral_constant<int, 1>, tuple<_Args...>&& __t, __tuple_indices<_Idx...>) {
0510 using _Tup = tuple<allocator_arg_t, inner_allocator_type&, _Args&&...>;
0511 return _Tup(allocator_arg, inner_allocator(), std::get<_Idx>(std::move(__t))...);
0512 }
0513
0514 template <class... _Args, size_t... _Idx>
0515 _LIBCPP_HIDE_FROM_ABI tuple<_Args&&..., inner_allocator_type&>
0516 __transform_tuple(integral_constant<int, 2>, tuple<_Args...>&& __t, __tuple_indices<_Idx...>) {
0517 using _Tup = tuple<_Args&&..., inner_allocator_type&>;
0518 return _Tup(std::get<_Idx>(std::move(__t))..., inner_allocator());
0519 }
0520
0521 template <class...>
0522 friend class __scoped_allocator_storage;
0523 };
0524
0525 # if _LIBCPP_STD_VER >= 17
0526 template <class _OuterAlloc, class... _InnerAllocs>
0527 scoped_allocator_adaptor(_OuterAlloc, _InnerAllocs...) -> scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>;
0528 # endif
0529
0530 template <class _OuterA1, class _OuterA2>
0531 inline _LIBCPP_HIDE_FROM_ABI bool
0532 operator==(const scoped_allocator_adaptor<_OuterA1>& __a, const scoped_allocator_adaptor<_OuterA2>& __b) _NOEXCEPT {
0533 return __a.outer_allocator() == __b.outer_allocator();
0534 }
0535
0536 template <class _OuterA1, class _OuterA2, class _InnerA0, class... _InnerAllocs>
0537 inline _LIBCPP_HIDE_FROM_ABI bool
0538 operator==(const scoped_allocator_adaptor<_OuterA1, _InnerA0, _InnerAllocs...>& __a,
0539 const scoped_allocator_adaptor<_OuterA2, _InnerA0, _InnerAllocs...>& __b) _NOEXCEPT {
0540 return __a.outer_allocator() == __b.outer_allocator() && __a.inner_allocator() == __b.inner_allocator();
0541 }
0542
0543 # if _LIBCPP_STD_VER <= 17
0544
0545 template <class _OuterA1, class _OuterA2, class... _InnerAllocs>
0546 inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const scoped_allocator_adaptor<_OuterA1, _InnerAllocs...>& __a,
0547 const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __b) _NOEXCEPT {
0548 return !(__a == __b);
0549 }
0550
0551 # endif // _LIBCPP_STD_VER <= 17
0552
0553 #endif // !defined(_LIBCPP_CXX03_LANG)
0554
0555 _LIBCPP_END_NAMESPACE_STD
0556
0557 _LIBCPP_POP_MACROS
0558
0559 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
0560 # include <__cxx03/atomic>
0561 # include <__cxx03/climits>
0562 # include <__cxx03/concepts>
0563 # include <__cxx03/cstring>
0564 # include <__cxx03/ctime>
0565 # include <__cxx03/iterator>
0566 # include <__cxx03/memory>
0567 # include <__cxx03/ratio>
0568 # include <__cxx03/stdexcept>
0569 # include <__cxx03/type_traits>
0570 # include <__cxx03/variant>
0571 #endif
0572
0573 #endif // _LIBCPP___CXX03_SCOPED_ALLOCATOR