1*58b9f456SAndroid Build Coastguard Worker// -*- C++ -*- 2*58b9f456SAndroid Build Coastguard Worker//===-------------------------- scoped_allocator --------------------------===// 3*58b9f456SAndroid Build Coastguard Worker// 4*58b9f456SAndroid Build Coastguard Worker// The LLVM Compiler Infrastructure 5*58b9f456SAndroid Build Coastguard Worker// 6*58b9f456SAndroid Build Coastguard Worker// This file is dual licensed under the MIT and the University of Illinois Open 7*58b9f456SAndroid Build Coastguard Worker// Source Licenses. See LICENSE.TXT for details. 8*58b9f456SAndroid Build Coastguard Worker// 9*58b9f456SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 10*58b9f456SAndroid Build Coastguard Worker 11*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_SCOPED_ALLOCATOR 12*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_SCOPED_ALLOCATOR 13*58b9f456SAndroid Build Coastguard Worker 14*58b9f456SAndroid Build Coastguard Worker/* 15*58b9f456SAndroid Build Coastguard Worker scoped_allocator synopsis 16*58b9f456SAndroid Build Coastguard Worker 17*58b9f456SAndroid Build Coastguard Workernamespace std 18*58b9f456SAndroid Build Coastguard Worker{ 19*58b9f456SAndroid Build Coastguard Worker 20*58b9f456SAndroid Build Coastguard Workertemplate <class OuterAlloc, class... InnerAllocs> 21*58b9f456SAndroid Build Coastguard Workerclass scoped_allocator_adaptor : public OuterAlloc 22*58b9f456SAndroid Build Coastguard Worker{ 23*58b9f456SAndroid Build Coastguard Worker typedef allocator_traits<OuterAlloc> OuterTraits; // exposition only 24*58b9f456SAndroid Build Coastguard Worker scoped_allocator_adaptor<InnerAllocs...> inner; // exposition only 25*58b9f456SAndroid Build Coastguard Workerpublic: 26*58b9f456SAndroid Build Coastguard Worker 27*58b9f456SAndroid Build Coastguard Worker typedef OuterAlloc outer_allocator_type; 28*58b9f456SAndroid Build Coastguard Worker typedef see below inner_allocator_type; 29*58b9f456SAndroid Build Coastguard Worker 30*58b9f456SAndroid Build Coastguard Worker typedef typename OuterTraits::value_type value_type; 31*58b9f456SAndroid Build Coastguard Worker typedef typename OuterTraits::size_type size_type; 32*58b9f456SAndroid Build Coastguard Worker typedef typename OuterTraits::difference_type difference_type; 33*58b9f456SAndroid Build Coastguard Worker typedef typename OuterTraits::pointer pointer; 34*58b9f456SAndroid Build Coastguard Worker typedef typename OuterTraits::const_pointer const_pointer; 35*58b9f456SAndroid Build Coastguard Worker typedef typename OuterTraits::void_pointer void_pointer; 36*58b9f456SAndroid Build Coastguard Worker typedef typename OuterTraits::const_void_pointer const_void_pointer; 37*58b9f456SAndroid Build Coastguard Worker 38*58b9f456SAndroid Build Coastguard Worker typedef see below propagate_on_container_copy_assignment; 39*58b9f456SAndroid Build Coastguard Worker typedef see below propagate_on_container_move_assignment; 40*58b9f456SAndroid Build Coastguard Worker typedef see below propagate_on_container_swap; 41*58b9f456SAndroid Build Coastguard Worker typedef see below is_always_equal; 42*58b9f456SAndroid Build Coastguard Worker 43*58b9f456SAndroid Build Coastguard Worker template <class Tp> 44*58b9f456SAndroid Build Coastguard Worker struct rebind 45*58b9f456SAndroid Build Coastguard Worker { 46*58b9f456SAndroid Build Coastguard Worker typedef scoped_allocator_adaptor< 47*58b9f456SAndroid Build Coastguard Worker OuterTraits::template rebind_alloc<Tp>, InnerAllocs...> other; 48*58b9f456SAndroid Build Coastguard Worker }; 49*58b9f456SAndroid Build Coastguard Worker 50*58b9f456SAndroid Build Coastguard Worker scoped_allocator_adaptor(); 51*58b9f456SAndroid Build Coastguard Worker template <class OuterA2> 52*58b9f456SAndroid Build Coastguard Worker scoped_allocator_adaptor(OuterA2&& outerAlloc, 53*58b9f456SAndroid Build Coastguard Worker const InnerAllocs&... innerAllocs) noexcept; 54*58b9f456SAndroid Build Coastguard Worker scoped_allocator_adaptor(const scoped_allocator_adaptor& other) noexcept; 55*58b9f456SAndroid Build Coastguard Worker scoped_allocator_adaptor(scoped_allocator_adaptor&& other) noexcept; 56*58b9f456SAndroid Build Coastguard Worker template <class OuterA2> 57*58b9f456SAndroid Build Coastguard Worker scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& other) noexcept; 58*58b9f456SAndroid Build Coastguard Worker template <class OuterA2> 59*58b9f456SAndroid Build Coastguard Worker scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2, InnerAllocs...>&& other) noexcept; 60*58b9f456SAndroid Build Coastguard Worker 61*58b9f456SAndroid Build Coastguard Worker scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default; 62*58b9f456SAndroid Build Coastguard Worker scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default; 63*58b9f456SAndroid Build Coastguard Worker ~scoped_allocator_adaptor(); 64*58b9f456SAndroid Build Coastguard Worker 65*58b9f456SAndroid Build Coastguard Worker inner_allocator_type& inner_allocator() noexcept; 66*58b9f456SAndroid Build Coastguard Worker const inner_allocator_type& inner_allocator() const noexcept; 67*58b9f456SAndroid Build Coastguard Worker 68*58b9f456SAndroid Build Coastguard Worker outer_allocator_type& outer_allocator() noexcept; 69*58b9f456SAndroid Build Coastguard Worker const outer_allocator_type& outer_allocator() const noexcept; 70*58b9f456SAndroid Build Coastguard Worker 71*58b9f456SAndroid Build Coastguard Worker pointer allocate(size_type n); // [[nodiscard]] in C++20 72*58b9f456SAndroid Build Coastguard Worker pointer allocate(size_type n, const_void_pointer hint); // [[nodiscard]] in C++20 73*58b9f456SAndroid Build Coastguard Worker void deallocate(pointer p, size_type n) noexcept; 74*58b9f456SAndroid Build Coastguard Worker 75*58b9f456SAndroid Build Coastguard Worker size_type max_size() const; 76*58b9f456SAndroid Build Coastguard Worker template <class T, class... Args> void construct(T* p, Args&& args); 77*58b9f456SAndroid Build Coastguard Worker template <class T1, class T2, class... Args1, class... Args2> 78*58b9f456SAndroid Build Coastguard Worker void construct(pair<T1, T2>* p, piecewise_construct t, tuple<Args1...> x, 79*58b9f456SAndroid Build Coastguard Worker tuple<Args2...> y); 80*58b9f456SAndroid Build Coastguard Worker template <class T1, class T2> 81*58b9f456SAndroid Build Coastguard Worker void construct(pair<T1, T2>* p); 82*58b9f456SAndroid Build Coastguard Worker template <class T1, class T2, class U, class V> 83*58b9f456SAndroid Build Coastguard Worker void construct(pair<T1, T2>* p, U&& x, V&& y); 84*58b9f456SAndroid Build Coastguard Worker template <class T1, class T2, class U, class V> 85*58b9f456SAndroid Build Coastguard Worker void construct(pair<T1, T2>* p, const pair<U, V>& x); 86*58b9f456SAndroid Build Coastguard Worker template <class T1, class T2, class U, class V> 87*58b9f456SAndroid Build Coastguard Worker void construct(pair<T1, T2>* p, pair<U, V>&& x); 88*58b9f456SAndroid Build Coastguard Worker template <class T> void destroy(T* p); 89*58b9f456SAndroid Build Coastguard Worker 90*58b9f456SAndroid Build Coastguard Worker template <class T> void destroy(T* p) noexcept; 91*58b9f456SAndroid Build Coastguard Worker 92*58b9f456SAndroid Build Coastguard Worker scoped_allocator_adaptor select_on_container_copy_construction() const noexcept; 93*58b9f456SAndroid Build Coastguard Worker}; 94*58b9f456SAndroid Build Coastguard Worker 95*58b9f456SAndroid Build Coastguard Workertemplate <class OuterA1, class OuterA2, class... InnerAllocs> 96*58b9f456SAndroid Build Coastguard Worker bool 97*58b9f456SAndroid Build Coastguard Worker operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a, 98*58b9f456SAndroid Build Coastguard Worker const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept; 99*58b9f456SAndroid Build Coastguard Worker 100*58b9f456SAndroid Build Coastguard Workertemplate <class OuterA1, class OuterA2, class... InnerAllocs> 101*58b9f456SAndroid Build Coastguard Worker bool 102*58b9f456SAndroid Build Coastguard Worker operator!=(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a, 103*58b9f456SAndroid Build Coastguard Worker const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept; 104*58b9f456SAndroid Build Coastguard Worker 105*58b9f456SAndroid Build Coastguard Worker} // std 106*58b9f456SAndroid Build Coastguard Worker 107*58b9f456SAndroid Build Coastguard Worker*/ 108*58b9f456SAndroid Build Coastguard Worker 109*58b9f456SAndroid Build Coastguard Worker#include <__config> 110*58b9f456SAndroid Build Coastguard Worker#include <memory> 111*58b9f456SAndroid Build Coastguard Worker#include <version> 112*58b9f456SAndroid Build Coastguard Worker 113*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 114*58b9f456SAndroid Build Coastguard Worker#pragma GCC system_header 115*58b9f456SAndroid Build Coastguard Worker#endif 116*58b9f456SAndroid Build Coastguard Worker 117*58b9f456SAndroid Build Coastguard Worker_LIBCPP_BEGIN_NAMESPACE_STD 118*58b9f456SAndroid Build Coastguard Worker 119*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_CXX03_LANG) 120*58b9f456SAndroid Build Coastguard Worker 121*58b9f456SAndroid Build Coastguard Worker// scoped_allocator_adaptor 122*58b9f456SAndroid Build Coastguard Worker 123*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Allocs> 124*58b9f456SAndroid Build Coastguard Workerclass scoped_allocator_adaptor; 125*58b9f456SAndroid Build Coastguard Worker 126*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Allocs> struct __get_poc_copy_assignment; 127*58b9f456SAndroid Build Coastguard Worker 128*58b9f456SAndroid Build Coastguard Workertemplate <class _A0> 129*58b9f456SAndroid Build Coastguard Workerstruct __get_poc_copy_assignment<_A0> 130*58b9f456SAndroid Build Coastguard Worker{ 131*58b9f456SAndroid Build Coastguard Worker static const bool value = allocator_traits<_A0>:: 132*58b9f456SAndroid Build Coastguard Worker propagate_on_container_copy_assignment::value; 133*58b9f456SAndroid Build Coastguard Worker}; 134*58b9f456SAndroid Build Coastguard Worker 135*58b9f456SAndroid Build Coastguard Workertemplate <class _A0, class ..._Allocs> 136*58b9f456SAndroid Build Coastguard Workerstruct __get_poc_copy_assignment<_A0, _Allocs...> 137*58b9f456SAndroid Build Coastguard Worker{ 138*58b9f456SAndroid Build Coastguard Worker static const bool value = 139*58b9f456SAndroid Build Coastguard Worker allocator_traits<_A0>::propagate_on_container_copy_assignment::value || 140*58b9f456SAndroid Build Coastguard Worker __get_poc_copy_assignment<_Allocs...>::value; 141*58b9f456SAndroid Build Coastguard Worker}; 142*58b9f456SAndroid Build Coastguard Worker 143*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Allocs> struct __get_poc_move_assignment; 144*58b9f456SAndroid Build Coastguard Worker 145*58b9f456SAndroid Build Coastguard Workertemplate <class _A0> 146*58b9f456SAndroid Build Coastguard Workerstruct __get_poc_move_assignment<_A0> 147*58b9f456SAndroid Build Coastguard Worker{ 148*58b9f456SAndroid Build Coastguard Worker static const bool value = allocator_traits<_A0>:: 149*58b9f456SAndroid Build Coastguard Worker propagate_on_container_move_assignment::value; 150*58b9f456SAndroid Build Coastguard Worker}; 151*58b9f456SAndroid Build Coastguard Worker 152*58b9f456SAndroid Build Coastguard Workertemplate <class _A0, class ..._Allocs> 153*58b9f456SAndroid Build Coastguard Workerstruct __get_poc_move_assignment<_A0, _Allocs...> 154*58b9f456SAndroid Build Coastguard Worker{ 155*58b9f456SAndroid Build Coastguard Worker static const bool value = 156*58b9f456SAndroid Build Coastguard Worker allocator_traits<_A0>::propagate_on_container_move_assignment::value || 157*58b9f456SAndroid Build Coastguard Worker __get_poc_move_assignment<_Allocs...>::value; 158*58b9f456SAndroid Build Coastguard Worker}; 159*58b9f456SAndroid Build Coastguard Worker 160*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Allocs> struct __get_poc_swap; 161*58b9f456SAndroid Build Coastguard Worker 162*58b9f456SAndroid Build Coastguard Workertemplate <class _A0> 163*58b9f456SAndroid Build Coastguard Workerstruct __get_poc_swap<_A0> 164*58b9f456SAndroid Build Coastguard Worker{ 165*58b9f456SAndroid Build Coastguard Worker static const bool value = allocator_traits<_A0>:: 166*58b9f456SAndroid Build Coastguard Worker propagate_on_container_swap::value; 167*58b9f456SAndroid Build Coastguard Worker}; 168*58b9f456SAndroid Build Coastguard Worker 169*58b9f456SAndroid Build Coastguard Workertemplate <class _A0, class ..._Allocs> 170*58b9f456SAndroid Build Coastguard Workerstruct __get_poc_swap<_A0, _Allocs...> 171*58b9f456SAndroid Build Coastguard Worker{ 172*58b9f456SAndroid Build Coastguard Worker static const bool value = 173*58b9f456SAndroid Build Coastguard Worker allocator_traits<_A0>::propagate_on_container_swap::value || 174*58b9f456SAndroid Build Coastguard Worker __get_poc_swap<_Allocs...>::value; 175*58b9f456SAndroid Build Coastguard Worker}; 176*58b9f456SAndroid Build Coastguard Worker 177*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Allocs> struct __get_is_always_equal; 178*58b9f456SAndroid Build Coastguard Worker 179*58b9f456SAndroid Build Coastguard Workertemplate <class _A0> 180*58b9f456SAndroid Build Coastguard Workerstruct __get_is_always_equal<_A0> 181*58b9f456SAndroid Build Coastguard Worker{ 182*58b9f456SAndroid Build Coastguard Worker static const bool value = allocator_traits<_A0>::is_always_equal::value; 183*58b9f456SAndroid Build Coastguard Worker}; 184*58b9f456SAndroid Build Coastguard Worker 185*58b9f456SAndroid Build Coastguard Workertemplate <class _A0, class ..._Allocs> 186*58b9f456SAndroid Build Coastguard Workerstruct __get_is_always_equal<_A0, _Allocs...> 187*58b9f456SAndroid Build Coastguard Worker{ 188*58b9f456SAndroid Build Coastguard Worker static const bool value = 189*58b9f456SAndroid Build Coastguard Worker allocator_traits<_A0>::is_always_equal::value && 190*58b9f456SAndroid Build Coastguard Worker __get_is_always_equal<_Allocs...>::value; 191*58b9f456SAndroid Build Coastguard Worker}; 192*58b9f456SAndroid Build Coastguard Worker 193*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Allocs> 194*58b9f456SAndroid Build Coastguard Workerclass __scoped_allocator_storage; 195*58b9f456SAndroid Build Coastguard Worker 196*58b9f456SAndroid Build Coastguard Workertemplate <class _OuterAlloc, class... _InnerAllocs> 197*58b9f456SAndroid Build Coastguard Workerclass __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> 198*58b9f456SAndroid Build Coastguard Worker : public _OuterAlloc 199*58b9f456SAndroid Build Coastguard Worker{ 200*58b9f456SAndroid Build Coastguard Worker typedef _OuterAlloc outer_allocator_type; 201*58b9f456SAndroid Build Coastguard Workerprotected: 202*58b9f456SAndroid Build Coastguard Worker typedef scoped_allocator_adaptor<_InnerAllocs...> inner_allocator_type; 203*58b9f456SAndroid Build Coastguard Worker 204*58b9f456SAndroid Build Coastguard Workerprivate: 205*58b9f456SAndroid Build Coastguard Worker inner_allocator_type __inner_; 206*58b9f456SAndroid Build Coastguard Worker 207*58b9f456SAndroid Build Coastguard Workerprotected: 208*58b9f456SAndroid Build Coastguard Worker 209*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 210*58b9f456SAndroid Build Coastguard Worker __scoped_allocator_storage() _NOEXCEPT {} 211*58b9f456SAndroid Build Coastguard Worker 212*58b9f456SAndroid Build Coastguard Worker template <class _OuterA2, 213*58b9f456SAndroid Build Coastguard Worker class = typename enable_if< 214*58b9f456SAndroid Build Coastguard Worker is_constructible<outer_allocator_type, _OuterA2>::value 215*58b9f456SAndroid Build Coastguard Worker >::type> 216*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 217*58b9f456SAndroid Build Coastguard Worker __scoped_allocator_storage(_OuterA2&& __outerAlloc, 218*58b9f456SAndroid Build Coastguard Worker const _InnerAllocs& ...__innerAllocs) _NOEXCEPT 219*58b9f456SAndroid Build Coastguard Worker : outer_allocator_type(_VSTD::forward<_OuterA2>(__outerAlloc)), 220*58b9f456SAndroid Build Coastguard Worker __inner_(__innerAllocs...) {} 221*58b9f456SAndroid Build Coastguard Worker 222*58b9f456SAndroid Build Coastguard Worker template <class _OuterA2, 223*58b9f456SAndroid Build Coastguard Worker class = typename enable_if< 224*58b9f456SAndroid Build Coastguard Worker is_constructible<outer_allocator_type, const _OuterA2&>::value 225*58b9f456SAndroid Build Coastguard Worker >::type> 226*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 227*58b9f456SAndroid Build Coastguard Worker __scoped_allocator_storage( 228*58b9f456SAndroid Build Coastguard Worker const __scoped_allocator_storage<_OuterA2, _InnerAllocs...>& __other) _NOEXCEPT 229*58b9f456SAndroid Build Coastguard Worker : outer_allocator_type(__other.outer_allocator()), 230*58b9f456SAndroid Build Coastguard Worker __inner_(__other.inner_allocator()) {} 231*58b9f456SAndroid Build Coastguard Worker 232*58b9f456SAndroid Build Coastguard Worker template <class _OuterA2, 233*58b9f456SAndroid Build Coastguard Worker class = typename enable_if< 234*58b9f456SAndroid Build Coastguard Worker is_constructible<outer_allocator_type, _OuterA2>::value 235*58b9f456SAndroid Build Coastguard Worker >::type> 236*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 237*58b9f456SAndroid Build Coastguard Worker __scoped_allocator_storage( 238*58b9f456SAndroid Build Coastguard Worker __scoped_allocator_storage<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT 239*58b9f456SAndroid Build Coastguard Worker : outer_allocator_type(_VSTD::move(__other.outer_allocator())), 240*58b9f456SAndroid Build Coastguard Worker __inner_(_VSTD::move(__other.inner_allocator())) {} 241*58b9f456SAndroid Build Coastguard Worker 242*58b9f456SAndroid Build Coastguard Worker template <class _OuterA2, 243*58b9f456SAndroid Build Coastguard Worker class = typename enable_if< 244*58b9f456SAndroid Build Coastguard Worker is_constructible<outer_allocator_type, _OuterA2>::value 245*58b9f456SAndroid Build Coastguard Worker >::type> 246*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 247*58b9f456SAndroid Build Coastguard Worker __scoped_allocator_storage(_OuterA2&& __o, 248*58b9f456SAndroid Build Coastguard Worker const inner_allocator_type& __i) _NOEXCEPT 249*58b9f456SAndroid Build Coastguard Worker : outer_allocator_type(_VSTD::forward<_OuterA2>(__o)), 250*58b9f456SAndroid Build Coastguard Worker __inner_(__i) 251*58b9f456SAndroid Build Coastguard Worker { 252*58b9f456SAndroid Build Coastguard Worker } 253*58b9f456SAndroid Build Coastguard Worker 254*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 255*58b9f456SAndroid Build Coastguard Worker inner_allocator_type& inner_allocator() _NOEXCEPT {return __inner_;} 256*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 257*58b9f456SAndroid Build Coastguard Worker const inner_allocator_type& inner_allocator() const _NOEXCEPT {return __inner_;} 258*58b9f456SAndroid Build Coastguard Worker 259*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 260*58b9f456SAndroid Build Coastguard Worker outer_allocator_type& outer_allocator() _NOEXCEPT 261*58b9f456SAndroid Build Coastguard Worker {return static_cast<outer_allocator_type&>(*this);} 262*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 263*58b9f456SAndroid Build Coastguard Worker const outer_allocator_type& outer_allocator() const _NOEXCEPT 264*58b9f456SAndroid Build Coastguard Worker {return static_cast<const outer_allocator_type&>(*this);} 265*58b9f456SAndroid Build Coastguard Worker 266*58b9f456SAndroid Build Coastguard Worker scoped_allocator_adaptor<outer_allocator_type, _InnerAllocs...> 267*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 268*58b9f456SAndroid Build Coastguard Worker select_on_container_copy_construction() const _NOEXCEPT 269*58b9f456SAndroid Build Coastguard Worker { 270*58b9f456SAndroid Build Coastguard Worker return scoped_allocator_adaptor<outer_allocator_type, _InnerAllocs...> 271*58b9f456SAndroid Build Coastguard Worker ( 272*58b9f456SAndroid Build Coastguard Worker allocator_traits<outer_allocator_type>:: 273*58b9f456SAndroid Build Coastguard Worker select_on_container_copy_construction(outer_allocator()), 274*58b9f456SAndroid Build Coastguard Worker allocator_traits<inner_allocator_type>:: 275*58b9f456SAndroid Build Coastguard Worker select_on_container_copy_construction(inner_allocator()) 276*58b9f456SAndroid Build Coastguard Worker ); 277*58b9f456SAndroid Build Coastguard Worker } 278*58b9f456SAndroid Build Coastguard Worker 279*58b9f456SAndroid Build Coastguard Worker template <class...> friend class __scoped_allocator_storage; 280*58b9f456SAndroid Build Coastguard Worker}; 281*58b9f456SAndroid Build Coastguard Worker 282*58b9f456SAndroid Build Coastguard Workertemplate <class _OuterAlloc> 283*58b9f456SAndroid Build Coastguard Workerclass __scoped_allocator_storage<_OuterAlloc> 284*58b9f456SAndroid Build Coastguard Worker : public _OuterAlloc 285*58b9f456SAndroid Build Coastguard Worker{ 286*58b9f456SAndroid Build Coastguard Worker typedef _OuterAlloc outer_allocator_type; 287*58b9f456SAndroid Build Coastguard Workerprotected: 288*58b9f456SAndroid Build Coastguard Worker typedef scoped_allocator_adaptor<_OuterAlloc> inner_allocator_type; 289*58b9f456SAndroid Build Coastguard Worker 290*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 291*58b9f456SAndroid Build Coastguard Worker __scoped_allocator_storage() _NOEXCEPT {} 292*58b9f456SAndroid Build Coastguard Worker 293*58b9f456SAndroid Build Coastguard Worker template <class _OuterA2, 294*58b9f456SAndroid Build Coastguard Worker class = typename enable_if< 295*58b9f456SAndroid Build Coastguard Worker is_constructible<outer_allocator_type, _OuterA2>::value 296*58b9f456SAndroid Build Coastguard Worker >::type> 297*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 298*58b9f456SAndroid Build Coastguard Worker __scoped_allocator_storage(_OuterA2&& __outerAlloc) _NOEXCEPT 299*58b9f456SAndroid Build Coastguard Worker : outer_allocator_type(_VSTD::forward<_OuterA2>(__outerAlloc)) {} 300*58b9f456SAndroid Build Coastguard Worker 301*58b9f456SAndroid Build Coastguard Worker template <class _OuterA2, 302*58b9f456SAndroid Build Coastguard Worker class = typename enable_if< 303*58b9f456SAndroid Build Coastguard Worker is_constructible<outer_allocator_type, const _OuterA2&>::value 304*58b9f456SAndroid Build Coastguard Worker >::type> 305*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 306*58b9f456SAndroid Build Coastguard Worker __scoped_allocator_storage( 307*58b9f456SAndroid Build Coastguard Worker const __scoped_allocator_storage<_OuterA2>& __other) _NOEXCEPT 308*58b9f456SAndroid Build Coastguard Worker : outer_allocator_type(__other.outer_allocator()) {} 309*58b9f456SAndroid Build Coastguard Worker 310*58b9f456SAndroid Build Coastguard Worker template <class _OuterA2, 311*58b9f456SAndroid Build Coastguard Worker class = typename enable_if< 312*58b9f456SAndroid Build Coastguard Worker is_constructible<outer_allocator_type, _OuterA2>::value 313*58b9f456SAndroid Build Coastguard Worker >::type> 314*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 315*58b9f456SAndroid Build Coastguard Worker __scoped_allocator_storage( 316*58b9f456SAndroid Build Coastguard Worker __scoped_allocator_storage<_OuterA2>&& __other) _NOEXCEPT 317*58b9f456SAndroid Build Coastguard Worker : outer_allocator_type(_VSTD::move(__other.outer_allocator())) {} 318*58b9f456SAndroid Build Coastguard Worker 319*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 320*58b9f456SAndroid Build Coastguard Worker inner_allocator_type& inner_allocator() _NOEXCEPT 321*58b9f456SAndroid Build Coastguard Worker {return static_cast<inner_allocator_type&>(*this);} 322*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 323*58b9f456SAndroid Build Coastguard Worker const inner_allocator_type& inner_allocator() const _NOEXCEPT 324*58b9f456SAndroid Build Coastguard Worker {return static_cast<const inner_allocator_type&>(*this);} 325*58b9f456SAndroid Build Coastguard Worker 326*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 327*58b9f456SAndroid Build Coastguard Worker outer_allocator_type& outer_allocator() _NOEXCEPT 328*58b9f456SAndroid Build Coastguard Worker {return static_cast<outer_allocator_type&>(*this);} 329*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 330*58b9f456SAndroid Build Coastguard Worker const outer_allocator_type& outer_allocator() const _NOEXCEPT 331*58b9f456SAndroid Build Coastguard Worker {return static_cast<const outer_allocator_type&>(*this);} 332*58b9f456SAndroid Build Coastguard Worker 333*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 334*58b9f456SAndroid Build Coastguard Worker scoped_allocator_adaptor<outer_allocator_type> 335*58b9f456SAndroid Build Coastguard Worker select_on_container_copy_construction() const _NOEXCEPT 336*58b9f456SAndroid Build Coastguard Worker {return scoped_allocator_adaptor<outer_allocator_type>( 337*58b9f456SAndroid Build Coastguard Worker allocator_traits<outer_allocator_type>:: 338*58b9f456SAndroid Build Coastguard Worker select_on_container_copy_construction(outer_allocator()) 339*58b9f456SAndroid Build Coastguard Worker );} 340*58b9f456SAndroid Build Coastguard Worker 341*58b9f456SAndroid Build Coastguard Worker __scoped_allocator_storage(const outer_allocator_type& __o, 342*58b9f456SAndroid Build Coastguard Worker const inner_allocator_type& __i) _NOEXCEPT; 343*58b9f456SAndroid Build Coastguard Worker 344*58b9f456SAndroid Build Coastguard Worker template <class...> friend class __scoped_allocator_storage; 345*58b9f456SAndroid Build Coastguard Worker}; 346*58b9f456SAndroid Build Coastguard Worker 347*58b9f456SAndroid Build Coastguard Worker// __outermost 348*58b9f456SAndroid Build Coastguard Worker 349*58b9f456SAndroid Build Coastguard Workertemplate <class _Alloc> 350*58b9f456SAndroid Build Coastguard Workerdecltype(declval<_Alloc>().outer_allocator(), true_type()) 351*58b9f456SAndroid Build Coastguard Worker__has_outer_allocator_test(_Alloc&& __a); 352*58b9f456SAndroid Build Coastguard Worker 353*58b9f456SAndroid Build Coastguard Workertemplate <class _Alloc> 354*58b9f456SAndroid Build Coastguard Workerfalse_type 355*58b9f456SAndroid Build Coastguard Worker__has_outer_allocator_test(const volatile _Alloc& __a); 356*58b9f456SAndroid Build Coastguard Worker 357*58b9f456SAndroid Build Coastguard Workertemplate <class _Alloc> 358*58b9f456SAndroid Build Coastguard Workerstruct __has_outer_allocator 359*58b9f456SAndroid Build Coastguard Worker : public common_type 360*58b9f456SAndroid Build Coastguard Worker < 361*58b9f456SAndroid Build Coastguard Worker decltype(__has_outer_allocator_test(declval<_Alloc&>())) 362*58b9f456SAndroid Build Coastguard Worker >::type 363*58b9f456SAndroid Build Coastguard Worker{ 364*58b9f456SAndroid Build Coastguard Worker}; 365*58b9f456SAndroid Build Coastguard Worker 366*58b9f456SAndroid Build Coastguard Workertemplate <class _Alloc, bool = __has_outer_allocator<_Alloc>::value> 367*58b9f456SAndroid Build Coastguard Workerstruct __outermost 368*58b9f456SAndroid Build Coastguard Worker{ 369*58b9f456SAndroid Build Coastguard Worker typedef _Alloc type; 370*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 371*58b9f456SAndroid Build Coastguard Worker type& operator()(type& __a) const _NOEXCEPT {return __a;} 372*58b9f456SAndroid Build Coastguard Worker}; 373*58b9f456SAndroid Build Coastguard Worker 374*58b9f456SAndroid Build Coastguard Workertemplate <class _Alloc> 375*58b9f456SAndroid Build Coastguard Workerstruct __outermost<_Alloc, true> 376*58b9f456SAndroid Build Coastguard Worker{ 377*58b9f456SAndroid Build Coastguard Worker typedef typename remove_reference 378*58b9f456SAndroid Build Coastguard Worker < 379*58b9f456SAndroid Build Coastguard Worker decltype(_VSTD::declval<_Alloc>().outer_allocator()) 380*58b9f456SAndroid Build Coastguard Worker >::type _OuterAlloc; 381*58b9f456SAndroid Build Coastguard Worker typedef typename __outermost<_OuterAlloc>::type type; 382*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 383*58b9f456SAndroid Build Coastguard Worker type& operator()(_Alloc& __a) const _NOEXCEPT 384*58b9f456SAndroid Build Coastguard Worker {return __outermost<_OuterAlloc>()(__a.outer_allocator());} 385*58b9f456SAndroid Build Coastguard Worker}; 386*58b9f456SAndroid Build Coastguard Worker 387*58b9f456SAndroid Build Coastguard Workertemplate <class _OuterAlloc, class... _InnerAllocs> 388*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...> 389*58b9f456SAndroid Build Coastguard Worker : public __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> 390*58b9f456SAndroid Build Coastguard Worker{ 391*58b9f456SAndroid Build Coastguard Worker typedef __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> base; 392*58b9f456SAndroid Build Coastguard Worker typedef allocator_traits<_OuterAlloc> _OuterTraits; 393*58b9f456SAndroid Build Coastguard Workerpublic: 394*58b9f456SAndroid Build Coastguard Worker typedef _OuterAlloc outer_allocator_type; 395*58b9f456SAndroid Build Coastguard Worker typedef typename base::inner_allocator_type inner_allocator_type; 396*58b9f456SAndroid Build Coastguard Worker typedef typename _OuterTraits::size_type size_type; 397*58b9f456SAndroid Build Coastguard Worker typedef typename _OuterTraits::difference_type difference_type; 398*58b9f456SAndroid Build Coastguard Worker typedef typename _OuterTraits::pointer pointer; 399*58b9f456SAndroid Build Coastguard Worker typedef typename _OuterTraits::const_pointer const_pointer; 400*58b9f456SAndroid Build Coastguard Worker typedef typename _OuterTraits::void_pointer void_pointer; 401*58b9f456SAndroid Build Coastguard Worker typedef typename _OuterTraits::const_void_pointer const_void_pointer; 402*58b9f456SAndroid Build Coastguard Worker 403*58b9f456SAndroid Build Coastguard Worker typedef integral_constant 404*58b9f456SAndroid Build Coastguard Worker < 405*58b9f456SAndroid Build Coastguard Worker bool, 406*58b9f456SAndroid Build Coastguard Worker __get_poc_copy_assignment<outer_allocator_type, 407*58b9f456SAndroid Build Coastguard Worker _InnerAllocs...>::value 408*58b9f456SAndroid Build Coastguard Worker > propagate_on_container_copy_assignment; 409*58b9f456SAndroid Build Coastguard Worker typedef integral_constant 410*58b9f456SAndroid Build Coastguard Worker < 411*58b9f456SAndroid Build Coastguard Worker bool, 412*58b9f456SAndroid Build Coastguard Worker __get_poc_move_assignment<outer_allocator_type, 413*58b9f456SAndroid Build Coastguard Worker _InnerAllocs...>::value 414*58b9f456SAndroid Build Coastguard Worker > propagate_on_container_move_assignment; 415*58b9f456SAndroid Build Coastguard Worker typedef integral_constant 416*58b9f456SAndroid Build Coastguard Worker < 417*58b9f456SAndroid Build Coastguard Worker bool, 418*58b9f456SAndroid Build Coastguard Worker __get_poc_swap<outer_allocator_type, _InnerAllocs...>::value 419*58b9f456SAndroid Build Coastguard Worker > propagate_on_container_swap; 420*58b9f456SAndroid Build Coastguard Worker typedef integral_constant 421*58b9f456SAndroid Build Coastguard Worker < 422*58b9f456SAndroid Build Coastguard Worker bool, 423*58b9f456SAndroid Build Coastguard Worker __get_is_always_equal<outer_allocator_type, _InnerAllocs...>::value 424*58b9f456SAndroid Build Coastguard Worker > is_always_equal; 425*58b9f456SAndroid Build Coastguard Worker 426*58b9f456SAndroid Build Coastguard Worker template <class _Tp> 427*58b9f456SAndroid Build Coastguard Worker struct rebind 428*58b9f456SAndroid Build Coastguard Worker { 429*58b9f456SAndroid Build Coastguard Worker typedef scoped_allocator_adaptor 430*58b9f456SAndroid Build Coastguard Worker < 431*58b9f456SAndroid Build Coastguard Worker typename _OuterTraits::template rebind_alloc<_Tp>, _InnerAllocs... 432*58b9f456SAndroid Build Coastguard Worker > other; 433*58b9f456SAndroid Build Coastguard Worker }; 434*58b9f456SAndroid Build Coastguard Worker 435*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 436*58b9f456SAndroid Build Coastguard Worker scoped_allocator_adaptor() _NOEXCEPT {} 437*58b9f456SAndroid Build Coastguard Worker template <class _OuterA2, 438*58b9f456SAndroid Build Coastguard Worker class = typename enable_if< 439*58b9f456SAndroid Build Coastguard Worker is_constructible<outer_allocator_type, _OuterA2>::value 440*58b9f456SAndroid Build Coastguard Worker >::type> 441*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 442*58b9f456SAndroid Build Coastguard Worker scoped_allocator_adaptor(_OuterA2&& __outerAlloc, 443*58b9f456SAndroid Build Coastguard Worker const _InnerAllocs& ...__innerAllocs) _NOEXCEPT 444*58b9f456SAndroid Build Coastguard Worker : base(_VSTD::forward<_OuterA2>(__outerAlloc), __innerAllocs...) {} 445*58b9f456SAndroid Build Coastguard Worker // scoped_allocator_adaptor(const scoped_allocator_adaptor& __other) = default; 446*58b9f456SAndroid Build Coastguard Worker template <class _OuterA2, 447*58b9f456SAndroid Build Coastguard Worker class = typename enable_if< 448*58b9f456SAndroid Build Coastguard Worker is_constructible<outer_allocator_type, const _OuterA2&>::value 449*58b9f456SAndroid Build Coastguard Worker >::type> 450*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 451*58b9f456SAndroid Build Coastguard Worker scoped_allocator_adaptor( 452*58b9f456SAndroid Build Coastguard Worker const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __other) _NOEXCEPT 453*58b9f456SAndroid Build Coastguard Worker : base(__other) {} 454*58b9f456SAndroid Build Coastguard Worker template <class _OuterA2, 455*58b9f456SAndroid Build Coastguard Worker class = typename enable_if< 456*58b9f456SAndroid Build Coastguard Worker is_constructible<outer_allocator_type, _OuterA2>::value 457*58b9f456SAndroid Build Coastguard Worker >::type> 458*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 459*58b9f456SAndroid Build Coastguard Worker scoped_allocator_adaptor( 460*58b9f456SAndroid Build Coastguard Worker scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT 461*58b9f456SAndroid Build Coastguard Worker : base(_VSTD::move(__other)) {} 462*58b9f456SAndroid Build Coastguard Worker 463*58b9f456SAndroid Build Coastguard Worker // scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default; 464*58b9f456SAndroid Build Coastguard Worker // scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default; 465*58b9f456SAndroid Build Coastguard Worker // ~scoped_allocator_adaptor() = default; 466*58b9f456SAndroid Build Coastguard Worker 467*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 468*58b9f456SAndroid Build Coastguard Worker inner_allocator_type& inner_allocator() _NOEXCEPT 469*58b9f456SAndroid Build Coastguard Worker {return base::inner_allocator();} 470*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 471*58b9f456SAndroid Build Coastguard Worker const inner_allocator_type& inner_allocator() const _NOEXCEPT 472*58b9f456SAndroid Build Coastguard Worker {return base::inner_allocator();} 473*58b9f456SAndroid Build Coastguard Worker 474*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 475*58b9f456SAndroid Build Coastguard Worker outer_allocator_type& outer_allocator() _NOEXCEPT 476*58b9f456SAndroid Build Coastguard Worker {return base::outer_allocator();} 477*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 478*58b9f456SAndroid Build Coastguard Worker const outer_allocator_type& outer_allocator() const _NOEXCEPT 479*58b9f456SAndroid Build Coastguard Worker {return base::outer_allocator();} 480*58b9f456SAndroid Build Coastguard Worker 481*58b9f456SAndroid Build Coastguard Worker _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 482*58b9f456SAndroid Build Coastguard Worker pointer allocate(size_type __n) 483*58b9f456SAndroid Build Coastguard Worker {return allocator_traits<outer_allocator_type>:: 484*58b9f456SAndroid Build Coastguard Worker allocate(outer_allocator(), __n);} 485*58b9f456SAndroid Build Coastguard Worker _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 486*58b9f456SAndroid Build Coastguard Worker pointer allocate(size_type __n, const_void_pointer __hint) 487*58b9f456SAndroid Build Coastguard Worker {return allocator_traits<outer_allocator_type>:: 488*58b9f456SAndroid Build Coastguard Worker allocate(outer_allocator(), __n, __hint);} 489*58b9f456SAndroid Build Coastguard Worker 490*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 491*58b9f456SAndroid Build Coastguard Worker void deallocate(pointer __p, size_type __n) _NOEXCEPT 492*58b9f456SAndroid Build Coastguard Worker {allocator_traits<outer_allocator_type>:: 493*58b9f456SAndroid Build Coastguard Worker deallocate(outer_allocator(), __p, __n);} 494*58b9f456SAndroid Build Coastguard Worker 495*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 496*58b9f456SAndroid Build Coastguard Worker size_type max_size() const 497*58b9f456SAndroid Build Coastguard Worker {return allocator_traits<outer_allocator_type>::max_size(outer_allocator());} 498*58b9f456SAndroid Build Coastguard Worker 499*58b9f456SAndroid Build Coastguard Worker template <class _Tp, class... _Args> 500*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 501*58b9f456SAndroid Build Coastguard Worker void construct(_Tp* __p, _Args&& ...__args) 502*58b9f456SAndroid Build Coastguard Worker {__construct(__uses_alloc_ctor<_Tp, inner_allocator_type&, _Args...>(), 503*58b9f456SAndroid Build Coastguard Worker __p, _VSTD::forward<_Args>(__args)...);} 504*58b9f456SAndroid Build Coastguard Worker 505*58b9f456SAndroid Build Coastguard Worker template <class _T1, class _T2, class... _Args1, class... _Args2> 506*58b9f456SAndroid Build Coastguard Worker void construct(pair<_T1, _T2>* __p, piecewise_construct_t, 507*58b9f456SAndroid Build Coastguard Worker tuple<_Args1...> __x, tuple<_Args2...> __y) 508*58b9f456SAndroid Build Coastguard Worker { 509*58b9f456SAndroid Build Coastguard Worker typedef __outermost<outer_allocator_type> _OM; 510*58b9f456SAndroid Build Coastguard Worker allocator_traits<typename _OM::type>::construct( 511*58b9f456SAndroid Build Coastguard Worker _OM()(outer_allocator()), __p, piecewise_construct 512*58b9f456SAndroid Build Coastguard Worker , __transform_tuple( 513*58b9f456SAndroid Build Coastguard Worker typename __uses_alloc_ctor< 514*58b9f456SAndroid Build Coastguard Worker _T1, inner_allocator_type&, _Args1... 515*58b9f456SAndroid Build Coastguard Worker >::type() 516*58b9f456SAndroid Build Coastguard Worker , _VSTD::move(__x) 517*58b9f456SAndroid Build Coastguard Worker , typename __make_tuple_indices<sizeof...(_Args1)>::type{} 518*58b9f456SAndroid Build Coastguard Worker ) 519*58b9f456SAndroid Build Coastguard Worker , __transform_tuple( 520*58b9f456SAndroid Build Coastguard Worker typename __uses_alloc_ctor< 521*58b9f456SAndroid Build Coastguard Worker _T2, inner_allocator_type&, _Args2... 522*58b9f456SAndroid Build Coastguard Worker >::type() 523*58b9f456SAndroid Build Coastguard Worker , _VSTD::move(__y) 524*58b9f456SAndroid Build Coastguard Worker , typename __make_tuple_indices<sizeof...(_Args2)>::type{} 525*58b9f456SAndroid Build Coastguard Worker ) 526*58b9f456SAndroid Build Coastguard Worker ); 527*58b9f456SAndroid Build Coastguard Worker } 528*58b9f456SAndroid Build Coastguard Worker 529*58b9f456SAndroid Build Coastguard Worker template <class _T1, class _T2> 530*58b9f456SAndroid Build Coastguard Worker void construct(pair<_T1, _T2>* __p) 531*58b9f456SAndroid Build Coastguard Worker { construct(__p, piecewise_construct, tuple<>{}, tuple<>{}); } 532*58b9f456SAndroid Build Coastguard Worker 533*58b9f456SAndroid Build Coastguard Worker template <class _T1, class _T2, class _Up, class _Vp> 534*58b9f456SAndroid Build Coastguard Worker void construct(pair<_T1, _T2>* __p, _Up&& __x, _Vp&& __y) { 535*58b9f456SAndroid Build Coastguard Worker construct(__p, piecewise_construct, 536*58b9f456SAndroid Build Coastguard Worker _VSTD::forward_as_tuple(_VSTD::forward<_Up>(__x)), 537*58b9f456SAndroid Build Coastguard Worker _VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__y))); 538*58b9f456SAndroid Build Coastguard Worker } 539*58b9f456SAndroid Build Coastguard Worker 540*58b9f456SAndroid Build Coastguard Worker template <class _T1, class _T2, class _Up, class _Vp> 541*58b9f456SAndroid Build Coastguard Worker void construct(pair<_T1, _T2>* __p, const pair<_Up, _Vp>& __x) { 542*58b9f456SAndroid Build Coastguard Worker construct(__p, piecewise_construct, 543*58b9f456SAndroid Build Coastguard Worker _VSTD::forward_as_tuple(__x.first), 544*58b9f456SAndroid Build Coastguard Worker _VSTD::forward_as_tuple(__x.second)); 545*58b9f456SAndroid Build Coastguard Worker } 546*58b9f456SAndroid Build Coastguard Worker 547*58b9f456SAndroid Build Coastguard Worker template <class _T1, class _T2, class _Up, class _Vp> 548*58b9f456SAndroid Build Coastguard Worker void construct(pair<_T1, _T2>* __p, pair<_Up, _Vp>&& __x) { 549*58b9f456SAndroid Build Coastguard Worker construct(__p, piecewise_construct, 550*58b9f456SAndroid Build Coastguard Worker _VSTD::forward_as_tuple(_VSTD::forward<_Up>(__x.first)), 551*58b9f456SAndroid Build Coastguard Worker _VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__x.second))); 552*58b9f456SAndroid Build Coastguard Worker } 553*58b9f456SAndroid Build Coastguard Worker 554*58b9f456SAndroid Build Coastguard Worker template <class _Tp> 555*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 556*58b9f456SAndroid Build Coastguard Worker void destroy(_Tp* __p) 557*58b9f456SAndroid Build Coastguard Worker { 558*58b9f456SAndroid Build Coastguard Worker typedef __outermost<outer_allocator_type> _OM; 559*58b9f456SAndroid Build Coastguard Worker allocator_traits<typename _OM::type>:: 560*58b9f456SAndroid Build Coastguard Worker destroy(_OM()(outer_allocator()), __p); 561*58b9f456SAndroid Build Coastguard Worker } 562*58b9f456SAndroid Build Coastguard Worker 563*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 564*58b9f456SAndroid Build Coastguard Worker scoped_allocator_adaptor select_on_container_copy_construction() const _NOEXCEPT 565*58b9f456SAndroid Build Coastguard Worker {return base::select_on_container_copy_construction();} 566*58b9f456SAndroid Build Coastguard Worker 567*58b9f456SAndroid Build Coastguard Workerprivate: 568*58b9f456SAndroid Build Coastguard Worker 569*58b9f456SAndroid Build Coastguard Worker 570*58b9f456SAndroid Build Coastguard Worker template <class _OuterA2, 571*58b9f456SAndroid Build Coastguard Worker class = typename enable_if< 572*58b9f456SAndroid Build Coastguard Worker is_constructible<outer_allocator_type, _OuterA2>::value 573*58b9f456SAndroid Build Coastguard Worker >::type> 574*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 575*58b9f456SAndroid Build Coastguard Worker scoped_allocator_adaptor(_OuterA2&& __o, 576*58b9f456SAndroid Build Coastguard Worker const inner_allocator_type& __i) _NOEXCEPT 577*58b9f456SAndroid Build Coastguard Worker : base(_VSTD::forward<_OuterA2>(__o), __i) {} 578*58b9f456SAndroid Build Coastguard Worker 579*58b9f456SAndroid Build Coastguard Worker template <class _Tp, class... _Args> 580*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 581*58b9f456SAndroid Build Coastguard Worker void __construct(integral_constant<int, 0>, _Tp* __p, _Args&& ...__args) 582*58b9f456SAndroid Build Coastguard Worker { 583*58b9f456SAndroid Build Coastguard Worker typedef __outermost<outer_allocator_type> _OM; 584*58b9f456SAndroid Build Coastguard Worker allocator_traits<typename _OM::type>::construct 585*58b9f456SAndroid Build Coastguard Worker ( 586*58b9f456SAndroid Build Coastguard Worker _OM()(outer_allocator()), 587*58b9f456SAndroid Build Coastguard Worker __p, 588*58b9f456SAndroid Build Coastguard Worker _VSTD::forward<_Args>(__args)... 589*58b9f456SAndroid Build Coastguard Worker ); 590*58b9f456SAndroid Build Coastguard Worker } 591*58b9f456SAndroid Build Coastguard Worker 592*58b9f456SAndroid Build Coastguard Worker template <class _Tp, class... _Args> 593*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 594*58b9f456SAndroid Build Coastguard Worker void __construct(integral_constant<int, 1>, _Tp* __p, _Args&& ...__args) 595*58b9f456SAndroid Build Coastguard Worker { 596*58b9f456SAndroid Build Coastguard Worker typedef __outermost<outer_allocator_type> _OM; 597*58b9f456SAndroid Build Coastguard Worker allocator_traits<typename _OM::type>::construct 598*58b9f456SAndroid Build Coastguard Worker ( 599*58b9f456SAndroid Build Coastguard Worker _OM()(outer_allocator()), 600*58b9f456SAndroid Build Coastguard Worker __p, allocator_arg, inner_allocator(), 601*58b9f456SAndroid Build Coastguard Worker _VSTD::forward<_Args>(__args)... 602*58b9f456SAndroid Build Coastguard Worker ); 603*58b9f456SAndroid Build Coastguard Worker } 604*58b9f456SAndroid Build Coastguard Worker 605*58b9f456SAndroid Build Coastguard Worker template <class _Tp, class... _Args> 606*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 607*58b9f456SAndroid Build Coastguard Worker void __construct(integral_constant<int, 2>, _Tp* __p, _Args&& ...__args) 608*58b9f456SAndroid Build Coastguard Worker { 609*58b9f456SAndroid Build Coastguard Worker typedef __outermost<outer_allocator_type> _OM; 610*58b9f456SAndroid Build Coastguard Worker allocator_traits<typename _OM::type>::construct 611*58b9f456SAndroid Build Coastguard Worker ( 612*58b9f456SAndroid Build Coastguard Worker _OM()(outer_allocator()), 613*58b9f456SAndroid Build Coastguard Worker __p, 614*58b9f456SAndroid Build Coastguard Worker _VSTD::forward<_Args>(__args)..., 615*58b9f456SAndroid Build Coastguard Worker inner_allocator() 616*58b9f456SAndroid Build Coastguard Worker ); 617*58b9f456SAndroid Build Coastguard Worker } 618*58b9f456SAndroid Build Coastguard Worker 619*58b9f456SAndroid Build Coastguard Worker template <class ..._Args, size_t ..._Idx> 620*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 621*58b9f456SAndroid Build Coastguard Worker tuple<_Args&&...> 622*58b9f456SAndroid Build Coastguard Worker __transform_tuple(integral_constant<int, 0>, tuple<_Args...>&& __t, 623*58b9f456SAndroid Build Coastguard Worker __tuple_indices<_Idx...>) 624*58b9f456SAndroid Build Coastguard Worker { 625*58b9f456SAndroid Build Coastguard Worker return _VSTD::forward_as_tuple(_VSTD::get<_Idx>(_VSTD::move(__t))...); 626*58b9f456SAndroid Build Coastguard Worker } 627*58b9f456SAndroid Build Coastguard Worker 628*58b9f456SAndroid Build Coastguard Worker template <class ..._Args, size_t ..._Idx> 629*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 630*58b9f456SAndroid Build Coastguard Worker tuple<allocator_arg_t, inner_allocator_type&, _Args&&...> 631*58b9f456SAndroid Build Coastguard Worker __transform_tuple(integral_constant<int, 1>, tuple<_Args...> && __t, 632*58b9f456SAndroid Build Coastguard Worker __tuple_indices<_Idx...>) 633*58b9f456SAndroid Build Coastguard Worker { 634*58b9f456SAndroid Build Coastguard Worker using _Tup = tuple<allocator_arg_t, inner_allocator_type&, _Args&&...>; 635*58b9f456SAndroid Build Coastguard Worker return _Tup(allocator_arg, inner_allocator(), 636*58b9f456SAndroid Build Coastguard Worker _VSTD::get<_Idx>(_VSTD::move(__t))...); 637*58b9f456SAndroid Build Coastguard Worker } 638*58b9f456SAndroid Build Coastguard Worker 639*58b9f456SAndroid Build Coastguard Worker template <class ..._Args, size_t ..._Idx> 640*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 641*58b9f456SAndroid Build Coastguard Worker tuple<_Args&&..., inner_allocator_type&> 642*58b9f456SAndroid Build Coastguard Worker __transform_tuple(integral_constant<int, 2>, tuple<_Args...> && __t, 643*58b9f456SAndroid Build Coastguard Worker __tuple_indices<_Idx...>) 644*58b9f456SAndroid Build Coastguard Worker { 645*58b9f456SAndroid Build Coastguard Worker using _Tup = tuple<_Args&&..., inner_allocator_type&>; 646*58b9f456SAndroid Build Coastguard Worker return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., inner_allocator()); 647*58b9f456SAndroid Build Coastguard Worker } 648*58b9f456SAndroid Build Coastguard Worker 649*58b9f456SAndroid Build Coastguard Worker template <class...> friend class __scoped_allocator_storage; 650*58b9f456SAndroid Build Coastguard Worker}; 651*58b9f456SAndroid Build Coastguard Worker 652*58b9f456SAndroid Build Coastguard Workertemplate <class _OuterA1, class _OuterA2> 653*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 654*58b9f456SAndroid Build Coastguard Workerbool 655*58b9f456SAndroid Build Coastguard Workeroperator==(const scoped_allocator_adaptor<_OuterA1>& __a, 656*58b9f456SAndroid Build Coastguard Worker const scoped_allocator_adaptor<_OuterA2>& __b) _NOEXCEPT 657*58b9f456SAndroid Build Coastguard Worker{ 658*58b9f456SAndroid Build Coastguard Worker return __a.outer_allocator() == __b.outer_allocator(); 659*58b9f456SAndroid Build Coastguard Worker} 660*58b9f456SAndroid Build Coastguard Worker 661*58b9f456SAndroid Build Coastguard Workertemplate <class _OuterA1, class _OuterA2, class _InnerA0, class... _InnerAllocs> 662*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 663*58b9f456SAndroid Build Coastguard Workerbool 664*58b9f456SAndroid Build Coastguard Workeroperator==(const scoped_allocator_adaptor<_OuterA1, _InnerA0, _InnerAllocs...>& __a, 665*58b9f456SAndroid Build Coastguard Worker const scoped_allocator_adaptor<_OuterA2, _InnerA0, _InnerAllocs...>& __b) _NOEXCEPT 666*58b9f456SAndroid Build Coastguard Worker{ 667*58b9f456SAndroid Build Coastguard Worker return __a.outer_allocator() == __b.outer_allocator() && 668*58b9f456SAndroid Build Coastguard Worker __a.inner_allocator() == __b.inner_allocator(); 669*58b9f456SAndroid Build Coastguard Worker} 670*58b9f456SAndroid Build Coastguard Worker 671*58b9f456SAndroid Build Coastguard Workertemplate <class _OuterA1, class _OuterA2, class... _InnerAllocs> 672*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY 673*58b9f456SAndroid Build Coastguard Workerbool 674*58b9f456SAndroid Build Coastguard Workeroperator!=(const scoped_allocator_adaptor<_OuterA1, _InnerAllocs...>& __a, 675*58b9f456SAndroid Build Coastguard Worker const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __b) _NOEXCEPT 676*58b9f456SAndroid Build Coastguard Worker{ 677*58b9f456SAndroid Build Coastguard Worker return !(__a == __b); 678*58b9f456SAndroid Build Coastguard Worker} 679*58b9f456SAndroid Build Coastguard Worker 680*58b9f456SAndroid Build Coastguard Worker#endif // !defined(_LIBCPP_CXX03_LANG) 681*58b9f456SAndroid Build Coastguard Worker 682*58b9f456SAndroid Build Coastguard Worker_LIBCPP_END_NAMESPACE_STD 683*58b9f456SAndroid Build Coastguard Worker 684*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_SCOPED_ALLOCATOR 685