10b57cec5SDimitry Andric// -*- C++ -*- 2349cc55cSDimitry Andric//===----------------------------------------------------------------------===// 30b57cec5SDimitry Andric// 40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 70b57cec5SDimitry Andric// 80b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 90b57cec5SDimitry Andric 100b57cec5SDimitry Andric#ifndef _LIBCPP_SCOPED_ALLOCATOR 110b57cec5SDimitry Andric#define _LIBCPP_SCOPED_ALLOCATOR 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric/* 140b57cec5SDimitry Andric scoped_allocator synopsis 150b57cec5SDimitry Andric 160b57cec5SDimitry Andricnamespace std 170b57cec5SDimitry Andric{ 180b57cec5SDimitry Andric 190b57cec5SDimitry Andrictemplate <class OuterAlloc, class... InnerAllocs> 200b57cec5SDimitry Andricclass scoped_allocator_adaptor : public OuterAlloc 210b57cec5SDimitry Andric{ 220b57cec5SDimitry Andric typedef allocator_traits<OuterAlloc> OuterTraits; // exposition only 230b57cec5SDimitry Andric scoped_allocator_adaptor<InnerAllocs...> inner; // exposition only 240b57cec5SDimitry Andricpublic: 250b57cec5SDimitry Andric 260b57cec5SDimitry Andric typedef OuterAlloc outer_allocator_type; 270b57cec5SDimitry Andric typedef see below inner_allocator_type; 280b57cec5SDimitry Andric 290b57cec5SDimitry Andric typedef typename OuterTraits::value_type value_type; 300b57cec5SDimitry Andric typedef typename OuterTraits::size_type size_type; 310b57cec5SDimitry Andric typedef typename OuterTraits::difference_type difference_type; 320b57cec5SDimitry Andric typedef typename OuterTraits::pointer pointer; 330b57cec5SDimitry Andric typedef typename OuterTraits::const_pointer const_pointer; 340b57cec5SDimitry Andric typedef typename OuterTraits::void_pointer void_pointer; 350b57cec5SDimitry Andric typedef typename OuterTraits::const_void_pointer const_void_pointer; 360b57cec5SDimitry Andric 370b57cec5SDimitry Andric typedef see below propagate_on_container_copy_assignment; 380b57cec5SDimitry Andric typedef see below propagate_on_container_move_assignment; 390b57cec5SDimitry Andric typedef see below propagate_on_container_swap; 400b57cec5SDimitry Andric typedef see below is_always_equal; 410b57cec5SDimitry Andric 420b57cec5SDimitry Andric template <class Tp> 430b57cec5SDimitry Andric struct rebind 440b57cec5SDimitry Andric { 450b57cec5SDimitry Andric typedef scoped_allocator_adaptor< 460b57cec5SDimitry Andric OuterTraits::template rebind_alloc<Tp>, InnerAllocs...> other; 470b57cec5SDimitry Andric }; 480b57cec5SDimitry Andric 490b57cec5SDimitry Andric scoped_allocator_adaptor(); 500b57cec5SDimitry Andric template <class OuterA2> 510b57cec5SDimitry Andric scoped_allocator_adaptor(OuterA2&& outerAlloc, 520b57cec5SDimitry Andric const InnerAllocs&... innerAllocs) noexcept; 530b57cec5SDimitry Andric scoped_allocator_adaptor(const scoped_allocator_adaptor& other) noexcept; 540b57cec5SDimitry Andric scoped_allocator_adaptor(scoped_allocator_adaptor&& other) noexcept; 550b57cec5SDimitry Andric template <class OuterA2> 560b57cec5SDimitry Andric scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& other) noexcept; 570b57cec5SDimitry Andric template <class OuterA2> 580b57cec5SDimitry Andric scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2, InnerAllocs...>&& other) noexcept; 590b57cec5SDimitry Andric 600b57cec5SDimitry Andric scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default; 610b57cec5SDimitry Andric scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default; 620b57cec5SDimitry Andric ~scoped_allocator_adaptor(); 630b57cec5SDimitry Andric 640b57cec5SDimitry Andric inner_allocator_type& inner_allocator() noexcept; 650b57cec5SDimitry Andric const inner_allocator_type& inner_allocator() const noexcept; 660b57cec5SDimitry Andric 670b57cec5SDimitry Andric outer_allocator_type& outer_allocator() noexcept; 680b57cec5SDimitry Andric const outer_allocator_type& outer_allocator() const noexcept; 690b57cec5SDimitry Andric 700b57cec5SDimitry Andric pointer allocate(size_type n); // [[nodiscard]] in C++20 710b57cec5SDimitry Andric pointer allocate(size_type n, const_void_pointer hint); // [[nodiscard]] in C++20 720b57cec5SDimitry Andric void deallocate(pointer p, size_type n) noexcept; 730b57cec5SDimitry Andric 740b57cec5SDimitry Andric size_type max_size() const; 750b57cec5SDimitry Andric template <class T, class... Args> void construct(T* p, Args&& args); 760b57cec5SDimitry Andric template <class T1, class T2, class... Args1, class... Args2> 770b57cec5SDimitry Andric void construct(pair<T1, T2>* p, piecewise_construct t, tuple<Args1...> x, 780b57cec5SDimitry Andric tuple<Args2...> y); 790b57cec5SDimitry Andric template <class T1, class T2> 800b57cec5SDimitry Andric void construct(pair<T1, T2>* p); 810b57cec5SDimitry Andric template <class T1, class T2, class U, class V> 820b57cec5SDimitry Andric void construct(pair<T1, T2>* p, U&& x, V&& y); 830b57cec5SDimitry Andric template <class T1, class T2, class U, class V> 840b57cec5SDimitry Andric void construct(pair<T1, T2>* p, const pair<U, V>& x); 850b57cec5SDimitry Andric template <class T1, class T2, class U, class V> 860b57cec5SDimitry Andric void construct(pair<T1, T2>* p, pair<U, V>&& x); 870b57cec5SDimitry Andric template <class T> void destroy(T* p); 880b57cec5SDimitry Andric 890b57cec5SDimitry Andric template <class T> void destroy(T* p) noexcept; 900b57cec5SDimitry Andric 910b57cec5SDimitry Andric scoped_allocator_adaptor select_on_container_copy_construction() const noexcept; 920b57cec5SDimitry Andric}; 930b57cec5SDimitry Andric 94349cc55cSDimitry Andrictemplate<class OuterAlloc, class... InnerAllocs> 95349cc55cSDimitry Andric scoped_allocator_adaptor(OuterAlloc, InnerAllocs...) 96349cc55cSDimitry Andric -> scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>; 97349cc55cSDimitry Andric 980b57cec5SDimitry Andrictemplate <class OuterA1, class OuterA2, class... InnerAllocs> 990b57cec5SDimitry Andric bool 1000b57cec5SDimitry Andric operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a, 1010b57cec5SDimitry Andric const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept; 1020b57cec5SDimitry Andric 1030b57cec5SDimitry Andrictemplate <class OuterA1, class OuterA2, class... InnerAllocs> 1040b57cec5SDimitry Andric bool 1050b57cec5SDimitry Andric operator!=(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a, 106*06c3fb27SDimitry Andric const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept; // removed in C++20 1070b57cec5SDimitry Andric 1080b57cec5SDimitry Andric} // std 1090b57cec5SDimitry Andric 1100b57cec5SDimitry Andric*/ 1110b57cec5SDimitry Andric 11281ad6265SDimitry Andric#include <__assert> // all public C++ headers provide the assertion handler 1130b57cec5SDimitry Andric#include <__config> 114bdd1243dSDimitry Andric#include <__memory/allocator_traits.h> 115bdd1243dSDimitry Andric#include <__memory/uses_allocator_construction.h> 116bdd1243dSDimitry Andric#include <__type_traits/common_type.h> 117bdd1243dSDimitry Andric#include <__type_traits/enable_if.h> 118bdd1243dSDimitry Andric#include <__type_traits/integral_constant.h> 119bdd1243dSDimitry Andric#include <__type_traits/is_constructible.h> 120bdd1243dSDimitry Andric#include <__type_traits/remove_reference.h> 121bdd1243dSDimitry Andric#include <__utility/declval.h> 122fe6060f1SDimitry Andric#include <__utility/forward.h> 123bdd1243dSDimitry Andric#include <__utility/move.h> 124bdd1243dSDimitry Andric#include <__utility/pair.h> 125bdd1243dSDimitry Andric#include <__utility/piecewise_construct.h> 126bdd1243dSDimitry Andric#include <tuple> 1270b57cec5SDimitry Andric#include <version> 1280b57cec5SDimitry Andric 1290b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 1300b57cec5SDimitry Andric# pragma GCC system_header 1310b57cec5SDimitry Andric#endif 1320b57cec5SDimitry Andric 133*06c3fb27SDimitry Andric_LIBCPP_PUSH_MACROS 134*06c3fb27SDimitry Andric#include <__undef_macros> 135*06c3fb27SDimitry Andric 1360b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 1370b57cec5SDimitry Andric 1380b57cec5SDimitry Andric#if !defined(_LIBCPP_CXX03_LANG) 1390b57cec5SDimitry Andric 1400b57cec5SDimitry Andric// scoped_allocator_adaptor 1410b57cec5SDimitry Andric 1420b57cec5SDimitry Andrictemplate <class ..._Allocs> 1430b57cec5SDimitry Andricclass scoped_allocator_adaptor; 1440b57cec5SDimitry Andric 1450b57cec5SDimitry Andrictemplate <class ..._Allocs> struct __get_poc_copy_assignment; 1460b57cec5SDimitry Andric 1470b57cec5SDimitry Andrictemplate <class _A0> 1480b57cec5SDimitry Andricstruct __get_poc_copy_assignment<_A0> 1490b57cec5SDimitry Andric{ 1500b57cec5SDimitry Andric static const bool value = allocator_traits<_A0>:: 1510b57cec5SDimitry Andric propagate_on_container_copy_assignment::value; 1520b57cec5SDimitry Andric}; 1530b57cec5SDimitry Andric 1540b57cec5SDimitry Andrictemplate <class _A0, class ..._Allocs> 1550b57cec5SDimitry Andricstruct __get_poc_copy_assignment<_A0, _Allocs...> 1560b57cec5SDimitry Andric{ 1570b57cec5SDimitry Andric static const bool value = 1580b57cec5SDimitry Andric allocator_traits<_A0>::propagate_on_container_copy_assignment::value || 1590b57cec5SDimitry Andric __get_poc_copy_assignment<_Allocs...>::value; 1600b57cec5SDimitry Andric}; 1610b57cec5SDimitry Andric 1620b57cec5SDimitry Andrictemplate <class ..._Allocs> struct __get_poc_move_assignment; 1630b57cec5SDimitry Andric 1640b57cec5SDimitry Andrictemplate <class _A0> 1650b57cec5SDimitry Andricstruct __get_poc_move_assignment<_A0> 1660b57cec5SDimitry Andric{ 1670b57cec5SDimitry Andric static const bool value = allocator_traits<_A0>:: 1680b57cec5SDimitry Andric propagate_on_container_move_assignment::value; 1690b57cec5SDimitry Andric}; 1700b57cec5SDimitry Andric 1710b57cec5SDimitry Andrictemplate <class _A0, class ..._Allocs> 1720b57cec5SDimitry Andricstruct __get_poc_move_assignment<_A0, _Allocs...> 1730b57cec5SDimitry Andric{ 1740b57cec5SDimitry Andric static const bool value = 1750b57cec5SDimitry Andric allocator_traits<_A0>::propagate_on_container_move_assignment::value || 1760b57cec5SDimitry Andric __get_poc_move_assignment<_Allocs...>::value; 1770b57cec5SDimitry Andric}; 1780b57cec5SDimitry Andric 1790b57cec5SDimitry Andrictemplate <class ..._Allocs> struct __get_poc_swap; 1800b57cec5SDimitry Andric 1810b57cec5SDimitry Andrictemplate <class _A0> 1820b57cec5SDimitry Andricstruct __get_poc_swap<_A0> 1830b57cec5SDimitry Andric{ 1840b57cec5SDimitry Andric static const bool value = allocator_traits<_A0>:: 1850b57cec5SDimitry Andric propagate_on_container_swap::value; 1860b57cec5SDimitry Andric}; 1870b57cec5SDimitry Andric 1880b57cec5SDimitry Andrictemplate <class _A0, class ..._Allocs> 1890b57cec5SDimitry Andricstruct __get_poc_swap<_A0, _Allocs...> 1900b57cec5SDimitry Andric{ 1910b57cec5SDimitry Andric static const bool value = 1920b57cec5SDimitry Andric allocator_traits<_A0>::propagate_on_container_swap::value || 1930b57cec5SDimitry Andric __get_poc_swap<_Allocs...>::value; 1940b57cec5SDimitry Andric}; 1950b57cec5SDimitry Andric 1960b57cec5SDimitry Andrictemplate <class ..._Allocs> struct __get_is_always_equal; 1970b57cec5SDimitry Andric 1980b57cec5SDimitry Andrictemplate <class _A0> 1990b57cec5SDimitry Andricstruct __get_is_always_equal<_A0> 2000b57cec5SDimitry Andric{ 2010b57cec5SDimitry Andric static const bool value = allocator_traits<_A0>::is_always_equal::value; 2020b57cec5SDimitry Andric}; 2030b57cec5SDimitry Andric 2040b57cec5SDimitry Andrictemplate <class _A0, class ..._Allocs> 2050b57cec5SDimitry Andricstruct __get_is_always_equal<_A0, _Allocs...> 2060b57cec5SDimitry Andric{ 2070b57cec5SDimitry Andric static const bool value = 2080b57cec5SDimitry Andric allocator_traits<_A0>::is_always_equal::value && 2090b57cec5SDimitry Andric __get_is_always_equal<_Allocs...>::value; 2100b57cec5SDimitry Andric}; 2110b57cec5SDimitry Andric 2120b57cec5SDimitry Andrictemplate <class ..._Allocs> 2130b57cec5SDimitry Andricclass __scoped_allocator_storage; 2140b57cec5SDimitry Andric 2150b57cec5SDimitry Andrictemplate <class _OuterAlloc, class... _InnerAllocs> 2160b57cec5SDimitry Andricclass __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> 2170b57cec5SDimitry Andric : public _OuterAlloc 2180b57cec5SDimitry Andric{ 2190b57cec5SDimitry Andric typedef _OuterAlloc outer_allocator_type; 2200b57cec5SDimitry Andricprotected: 2210b57cec5SDimitry Andric typedef scoped_allocator_adaptor<_InnerAllocs...> inner_allocator_type; 2220b57cec5SDimitry Andric 2230b57cec5SDimitry Andricprivate: 2240b57cec5SDimitry Andric inner_allocator_type __inner_; 2250b57cec5SDimitry Andric 2260b57cec5SDimitry Andricprotected: 2270b57cec5SDimitry Andric 2280b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2290b57cec5SDimitry Andric __scoped_allocator_storage() _NOEXCEPT {} 2300b57cec5SDimitry Andric 2310b57cec5SDimitry Andric template <class _OuterA2, 2320b57cec5SDimitry Andric class = typename enable_if< 2330b57cec5SDimitry Andric is_constructible<outer_allocator_type, _OuterA2>::value 2340b57cec5SDimitry Andric >::type> 2350b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 236753f127fSDimitry Andric __scoped_allocator_storage(_OuterA2&& __outer_alloc, 237753f127fSDimitry Andric const _InnerAllocs& ...__inner_allocs) _NOEXCEPT 238753f127fSDimitry Andric : outer_allocator_type(_VSTD::forward<_OuterA2>(__outer_alloc)), 239753f127fSDimitry Andric __inner_(__inner_allocs...) {} 2400b57cec5SDimitry Andric 2410b57cec5SDimitry Andric template <class _OuterA2, 2420b57cec5SDimitry Andric class = typename enable_if< 2430b57cec5SDimitry Andric is_constructible<outer_allocator_type, const _OuterA2&>::value 2440b57cec5SDimitry Andric >::type> 2450b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2460b57cec5SDimitry Andric __scoped_allocator_storage( 2470b57cec5SDimitry Andric const __scoped_allocator_storage<_OuterA2, _InnerAllocs...>& __other) _NOEXCEPT 2480b57cec5SDimitry Andric : outer_allocator_type(__other.outer_allocator()), 2490b57cec5SDimitry Andric __inner_(__other.inner_allocator()) {} 2500b57cec5SDimitry Andric 2510b57cec5SDimitry Andric template <class _OuterA2, 2520b57cec5SDimitry Andric class = typename enable_if< 2530b57cec5SDimitry Andric is_constructible<outer_allocator_type, _OuterA2>::value 2540b57cec5SDimitry Andric >::type> 2550b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2560b57cec5SDimitry Andric __scoped_allocator_storage( 2570b57cec5SDimitry Andric __scoped_allocator_storage<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT 2580b57cec5SDimitry Andric : outer_allocator_type(_VSTD::move(__other.outer_allocator())), 2590b57cec5SDimitry Andric __inner_(_VSTD::move(__other.inner_allocator())) {} 2600b57cec5SDimitry Andric 2610b57cec5SDimitry Andric template <class _OuterA2, 2620b57cec5SDimitry Andric class = typename enable_if< 2630b57cec5SDimitry Andric is_constructible<outer_allocator_type, _OuterA2>::value 2640b57cec5SDimitry Andric >::type> 2650b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2660b57cec5SDimitry Andric __scoped_allocator_storage(_OuterA2&& __o, 2670b57cec5SDimitry Andric const inner_allocator_type& __i) _NOEXCEPT 2680b57cec5SDimitry Andric : outer_allocator_type(_VSTD::forward<_OuterA2>(__o)), 2690b57cec5SDimitry Andric __inner_(__i) 2700b57cec5SDimitry Andric { 2710b57cec5SDimitry Andric } 2720b57cec5SDimitry Andric 2730b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2740b57cec5SDimitry Andric inner_allocator_type& inner_allocator() _NOEXCEPT {return __inner_;} 2750b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2760b57cec5SDimitry Andric const inner_allocator_type& inner_allocator() const _NOEXCEPT {return __inner_;} 2770b57cec5SDimitry Andric 2780b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2790b57cec5SDimitry Andric outer_allocator_type& outer_allocator() _NOEXCEPT 2800b57cec5SDimitry Andric {return static_cast<outer_allocator_type&>(*this);} 2810b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2820b57cec5SDimitry Andric const outer_allocator_type& outer_allocator() const _NOEXCEPT 2830b57cec5SDimitry Andric {return static_cast<const outer_allocator_type&>(*this);} 2840b57cec5SDimitry Andric 2850b57cec5SDimitry Andric scoped_allocator_adaptor<outer_allocator_type, _InnerAllocs...> 2860b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2870b57cec5SDimitry Andric select_on_container_copy_construction() const _NOEXCEPT 2880b57cec5SDimitry Andric { 2890b57cec5SDimitry Andric return scoped_allocator_adaptor<outer_allocator_type, _InnerAllocs...> 2900b57cec5SDimitry Andric ( 2910b57cec5SDimitry Andric allocator_traits<outer_allocator_type>:: 2920b57cec5SDimitry Andric select_on_container_copy_construction(outer_allocator()), 2930b57cec5SDimitry Andric allocator_traits<inner_allocator_type>:: 2940b57cec5SDimitry Andric select_on_container_copy_construction(inner_allocator()) 2950b57cec5SDimitry Andric ); 2960b57cec5SDimitry Andric } 2970b57cec5SDimitry Andric 2980b57cec5SDimitry Andric template <class...> friend class __scoped_allocator_storage; 2990b57cec5SDimitry Andric}; 3000b57cec5SDimitry Andric 3010b57cec5SDimitry Andrictemplate <class _OuterAlloc> 3020b57cec5SDimitry Andricclass __scoped_allocator_storage<_OuterAlloc> 3030b57cec5SDimitry Andric : public _OuterAlloc 3040b57cec5SDimitry Andric{ 3050b57cec5SDimitry Andric typedef _OuterAlloc outer_allocator_type; 3060b57cec5SDimitry Andricprotected: 3070b57cec5SDimitry Andric typedef scoped_allocator_adaptor<_OuterAlloc> inner_allocator_type; 3080b57cec5SDimitry Andric 3090b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3100b57cec5SDimitry Andric __scoped_allocator_storage() _NOEXCEPT {} 3110b57cec5SDimitry Andric 3120b57cec5SDimitry Andric template <class _OuterA2, 3130b57cec5SDimitry Andric class = typename enable_if< 3140b57cec5SDimitry Andric is_constructible<outer_allocator_type, _OuterA2>::value 3150b57cec5SDimitry Andric >::type> 3160b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 317753f127fSDimitry Andric __scoped_allocator_storage(_OuterA2&& __outer_alloc) _NOEXCEPT 318753f127fSDimitry Andric : outer_allocator_type(_VSTD::forward<_OuterA2>(__outer_alloc)) {} 3190b57cec5SDimitry Andric 3200b57cec5SDimitry Andric template <class _OuterA2, 3210b57cec5SDimitry Andric class = typename enable_if< 3220b57cec5SDimitry Andric is_constructible<outer_allocator_type, const _OuterA2&>::value 3230b57cec5SDimitry Andric >::type> 3240b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3250b57cec5SDimitry Andric __scoped_allocator_storage( 3260b57cec5SDimitry Andric const __scoped_allocator_storage<_OuterA2>& __other) _NOEXCEPT 3270b57cec5SDimitry Andric : outer_allocator_type(__other.outer_allocator()) {} 3280b57cec5SDimitry Andric 3290b57cec5SDimitry Andric template <class _OuterA2, 3300b57cec5SDimitry Andric class = typename enable_if< 3310b57cec5SDimitry Andric is_constructible<outer_allocator_type, _OuterA2>::value 3320b57cec5SDimitry Andric >::type> 3330b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3340b57cec5SDimitry Andric __scoped_allocator_storage( 3350b57cec5SDimitry Andric __scoped_allocator_storage<_OuterA2>&& __other) _NOEXCEPT 3360b57cec5SDimitry Andric : outer_allocator_type(_VSTD::move(__other.outer_allocator())) {} 3370b57cec5SDimitry Andric 3380b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3390b57cec5SDimitry Andric inner_allocator_type& inner_allocator() _NOEXCEPT 3400b57cec5SDimitry Andric {return static_cast<inner_allocator_type&>(*this);} 3410b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3420b57cec5SDimitry Andric const inner_allocator_type& inner_allocator() const _NOEXCEPT 3430b57cec5SDimitry Andric {return static_cast<const inner_allocator_type&>(*this);} 3440b57cec5SDimitry Andric 3450b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3460b57cec5SDimitry Andric outer_allocator_type& outer_allocator() _NOEXCEPT 3470b57cec5SDimitry Andric {return static_cast<outer_allocator_type&>(*this);} 3480b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3490b57cec5SDimitry Andric const outer_allocator_type& outer_allocator() const _NOEXCEPT 3500b57cec5SDimitry Andric {return static_cast<const outer_allocator_type&>(*this);} 3510b57cec5SDimitry Andric 3520b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3530b57cec5SDimitry Andric scoped_allocator_adaptor<outer_allocator_type> 3540b57cec5SDimitry Andric select_on_container_copy_construction() const _NOEXCEPT 3550b57cec5SDimitry Andric {return scoped_allocator_adaptor<outer_allocator_type>( 3560b57cec5SDimitry Andric allocator_traits<outer_allocator_type>:: 3570b57cec5SDimitry Andric select_on_container_copy_construction(outer_allocator()) 3580b57cec5SDimitry Andric );} 3590b57cec5SDimitry Andric 3600b57cec5SDimitry Andric __scoped_allocator_storage(const outer_allocator_type& __o, 3610b57cec5SDimitry Andric const inner_allocator_type& __i) _NOEXCEPT; 3620b57cec5SDimitry Andric 3630b57cec5SDimitry Andric template <class...> friend class __scoped_allocator_storage; 3640b57cec5SDimitry Andric}; 3650b57cec5SDimitry Andric 3660b57cec5SDimitry Andric// __outermost 3670b57cec5SDimitry Andric 3680b57cec5SDimitry Andrictemplate <class _Alloc> 369bdd1243dSDimitry Andricdecltype(std::declval<_Alloc>().outer_allocator(), true_type()) 3700b57cec5SDimitry Andric__has_outer_allocator_test(_Alloc&& __a); 3710b57cec5SDimitry Andric 3720b57cec5SDimitry Andrictemplate <class _Alloc> 3730b57cec5SDimitry Andricfalse_type 3740b57cec5SDimitry Andric__has_outer_allocator_test(const volatile _Alloc& __a); 3750b57cec5SDimitry Andric 3760b57cec5SDimitry Andrictemplate <class _Alloc> 3770b57cec5SDimitry Andricstruct __has_outer_allocator 3780b57cec5SDimitry Andric : public common_type 3790b57cec5SDimitry Andric < 380bdd1243dSDimitry Andric decltype(std::__has_outer_allocator_test(std::declval<_Alloc&>())) 3810b57cec5SDimitry Andric >::type 3820b57cec5SDimitry Andric{ 3830b57cec5SDimitry Andric}; 3840b57cec5SDimitry Andric 3850b57cec5SDimitry Andrictemplate <class _Alloc, bool = __has_outer_allocator<_Alloc>::value> 3860b57cec5SDimitry Andricstruct __outermost 3870b57cec5SDimitry Andric{ 3880b57cec5SDimitry Andric typedef _Alloc type; 3890b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3900b57cec5SDimitry Andric type& operator()(type& __a) const _NOEXCEPT {return __a;} 3910b57cec5SDimitry Andric}; 3920b57cec5SDimitry Andric 3930b57cec5SDimitry Andrictemplate <class _Alloc> 3940b57cec5SDimitry Andricstruct __outermost<_Alloc, true> 3950b57cec5SDimitry Andric{ 396bdd1243dSDimitry Andric typedef __libcpp_remove_reference_t 3970b57cec5SDimitry Andric < 398bdd1243dSDimitry Andric decltype(std::declval<_Alloc>().outer_allocator()) 399bdd1243dSDimitry Andric > _OuterAlloc; 4000b57cec5SDimitry Andric typedef typename __outermost<_OuterAlloc>::type type; 4010b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4020b57cec5SDimitry Andric type& operator()(_Alloc& __a) const _NOEXCEPT 4030b57cec5SDimitry Andric {return __outermost<_OuterAlloc>()(__a.outer_allocator());} 4040b57cec5SDimitry Andric}; 4050b57cec5SDimitry Andric 4060b57cec5SDimitry Andrictemplate <class _OuterAlloc, class... _InnerAllocs> 4070b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...> 4080b57cec5SDimitry Andric : public __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> 4090b57cec5SDimitry Andric{ 4100b57cec5SDimitry Andric typedef __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> base; 4110b57cec5SDimitry Andric typedef allocator_traits<_OuterAlloc> _OuterTraits; 4120b57cec5SDimitry Andricpublic: 4130b57cec5SDimitry Andric typedef _OuterAlloc outer_allocator_type; 4140b57cec5SDimitry Andric typedef typename base::inner_allocator_type inner_allocator_type; 4150b57cec5SDimitry Andric typedef typename _OuterTraits::size_type size_type; 4160b57cec5SDimitry Andric typedef typename _OuterTraits::difference_type difference_type; 4170b57cec5SDimitry Andric typedef typename _OuterTraits::pointer pointer; 4180b57cec5SDimitry Andric typedef typename _OuterTraits::const_pointer const_pointer; 4190b57cec5SDimitry Andric typedef typename _OuterTraits::void_pointer void_pointer; 4200b57cec5SDimitry Andric typedef typename _OuterTraits::const_void_pointer const_void_pointer; 4210b57cec5SDimitry Andric 4220b57cec5SDimitry Andric typedef integral_constant 4230b57cec5SDimitry Andric < 4240b57cec5SDimitry Andric bool, 4250b57cec5SDimitry Andric __get_poc_copy_assignment<outer_allocator_type, 4260b57cec5SDimitry Andric _InnerAllocs...>::value 4270b57cec5SDimitry Andric > propagate_on_container_copy_assignment; 4280b57cec5SDimitry Andric typedef integral_constant 4290b57cec5SDimitry Andric < 4300b57cec5SDimitry Andric bool, 4310b57cec5SDimitry Andric __get_poc_move_assignment<outer_allocator_type, 4320b57cec5SDimitry Andric _InnerAllocs...>::value 4330b57cec5SDimitry Andric > propagate_on_container_move_assignment; 4340b57cec5SDimitry Andric typedef integral_constant 4350b57cec5SDimitry Andric < 4360b57cec5SDimitry Andric bool, 4370b57cec5SDimitry Andric __get_poc_swap<outer_allocator_type, _InnerAllocs...>::value 4380b57cec5SDimitry Andric > propagate_on_container_swap; 4390b57cec5SDimitry Andric typedef integral_constant 4400b57cec5SDimitry Andric < 4410b57cec5SDimitry Andric bool, 4420b57cec5SDimitry Andric __get_is_always_equal<outer_allocator_type, _InnerAllocs...>::value 4430b57cec5SDimitry Andric > is_always_equal; 4440b57cec5SDimitry Andric 4450b57cec5SDimitry Andric template <class _Tp> 4460b57cec5SDimitry Andric struct rebind 4470b57cec5SDimitry Andric { 4480b57cec5SDimitry Andric typedef scoped_allocator_adaptor 4490b57cec5SDimitry Andric < 4500b57cec5SDimitry Andric typename _OuterTraits::template rebind_alloc<_Tp>, _InnerAllocs... 4510b57cec5SDimitry Andric > other; 4520b57cec5SDimitry Andric }; 4530b57cec5SDimitry Andric 4540b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4550b57cec5SDimitry Andric scoped_allocator_adaptor() _NOEXCEPT {} 4560b57cec5SDimitry Andric template <class _OuterA2, 4570b57cec5SDimitry Andric class = typename enable_if< 4580b57cec5SDimitry Andric is_constructible<outer_allocator_type, _OuterA2>::value 4590b57cec5SDimitry Andric >::type> 4600b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 461753f127fSDimitry Andric scoped_allocator_adaptor(_OuterA2&& __outer_alloc, 462753f127fSDimitry Andric const _InnerAllocs& ...__inner_allocs) _NOEXCEPT 463753f127fSDimitry Andric : base(_VSTD::forward<_OuterA2>(__outer_alloc), __inner_allocs...) {} 4640b57cec5SDimitry Andric // scoped_allocator_adaptor(const scoped_allocator_adaptor& __other) = default; 4650b57cec5SDimitry Andric template <class _OuterA2, 4660b57cec5SDimitry Andric class = typename enable_if< 4670b57cec5SDimitry Andric is_constructible<outer_allocator_type, const _OuterA2&>::value 4680b57cec5SDimitry Andric >::type> 4690b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4700b57cec5SDimitry Andric scoped_allocator_adaptor( 4710b57cec5SDimitry Andric const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __other) _NOEXCEPT 4720b57cec5SDimitry Andric : base(__other) {} 4730b57cec5SDimitry Andric template <class _OuterA2, 4740b57cec5SDimitry Andric class = typename enable_if< 4750b57cec5SDimitry Andric is_constructible<outer_allocator_type, _OuterA2>::value 4760b57cec5SDimitry Andric >::type> 4770b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4780b57cec5SDimitry Andric scoped_allocator_adaptor( 4790b57cec5SDimitry Andric scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT 4800b57cec5SDimitry Andric : base(_VSTD::move(__other)) {} 4810b57cec5SDimitry Andric 4820b57cec5SDimitry Andric // scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default; 4830b57cec5SDimitry Andric // scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default; 4840b57cec5SDimitry Andric // ~scoped_allocator_adaptor() = default; 4850b57cec5SDimitry Andric 4860b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4870b57cec5SDimitry Andric inner_allocator_type& inner_allocator() _NOEXCEPT 4880b57cec5SDimitry Andric {return base::inner_allocator();} 4890b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4900b57cec5SDimitry Andric const inner_allocator_type& inner_allocator() const _NOEXCEPT 4910b57cec5SDimitry Andric {return base::inner_allocator();} 4920b57cec5SDimitry Andric 4930b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4940b57cec5SDimitry Andric outer_allocator_type& outer_allocator() _NOEXCEPT 4950b57cec5SDimitry Andric {return base::outer_allocator();} 4960b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4970b57cec5SDimitry Andric const outer_allocator_type& outer_allocator() const _NOEXCEPT 4980b57cec5SDimitry Andric {return base::outer_allocator();} 4990b57cec5SDimitry Andric 5000b57cec5SDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 5010b57cec5SDimitry Andric pointer allocate(size_type __n) 5020b57cec5SDimitry Andric {return allocator_traits<outer_allocator_type>:: 5030b57cec5SDimitry Andric allocate(outer_allocator(), __n);} 5040b57cec5SDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 5050b57cec5SDimitry Andric pointer allocate(size_type __n, const_void_pointer __hint) 5060b57cec5SDimitry Andric {return allocator_traits<outer_allocator_type>:: 5070b57cec5SDimitry Andric allocate(outer_allocator(), __n, __hint);} 5080b57cec5SDimitry Andric 5090b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5100b57cec5SDimitry Andric void deallocate(pointer __p, size_type __n) _NOEXCEPT 5110b57cec5SDimitry Andric {allocator_traits<outer_allocator_type>:: 5120b57cec5SDimitry Andric deallocate(outer_allocator(), __p, __n);} 5130b57cec5SDimitry Andric 5140b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5150b57cec5SDimitry Andric size_type max_size() const 5160b57cec5SDimitry Andric {return allocator_traits<outer_allocator_type>::max_size(outer_allocator());} 5170b57cec5SDimitry Andric 518bdd1243dSDimitry Andric#if _LIBCPP_STD_VER >= 20 519bdd1243dSDimitry Andric template <class _Type, class... _Args> 520bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI void construct(_Type* __ptr, _Args&&... __args) { 521bdd1243dSDimitry Andric using _OM = __outermost<outer_allocator_type>; 522bdd1243dSDimitry Andric std::apply( 523bdd1243dSDimitry Andric [__ptr, this](auto&&... __newargs) { 524bdd1243dSDimitry Andric allocator_traits<typename _OM::type>::construct( 525bdd1243dSDimitry Andric _OM()(outer_allocator()), __ptr, std::forward<decltype(__newargs)>(__newargs)...); 526bdd1243dSDimitry Andric }, 527bdd1243dSDimitry Andric std::uses_allocator_construction_args<_Type>(inner_allocator(), std::forward<_Args>(__args)...)); 528bdd1243dSDimitry Andric } 529bdd1243dSDimitry Andric#else 5300b57cec5SDimitry Andric template <class _Tp, class... _Args> 5310b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5320b57cec5SDimitry Andric void construct(_Tp* __p, _Args&& ...__args) 5330b57cec5SDimitry Andric {__construct(__uses_alloc_ctor<_Tp, inner_allocator_type&, _Args...>(), 5340b57cec5SDimitry Andric __p, _VSTD::forward<_Args>(__args)...);} 5350b57cec5SDimitry Andric 5360b57cec5SDimitry Andric template <class _T1, class _T2, class... _Args1, class... _Args2> 537*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, piecewise_construct_t, 5380b57cec5SDimitry Andric tuple<_Args1...> __x, tuple<_Args2...> __y) 5390b57cec5SDimitry Andric { 5400b57cec5SDimitry Andric typedef __outermost<outer_allocator_type> _OM; 5410b57cec5SDimitry Andric allocator_traits<typename _OM::type>::construct( 5420b57cec5SDimitry Andric _OM()(outer_allocator()), __p, piecewise_construct 5430b57cec5SDimitry Andric , __transform_tuple( 5440b57cec5SDimitry Andric typename __uses_alloc_ctor< 5450b57cec5SDimitry Andric _T1, inner_allocator_type&, _Args1... 5460b57cec5SDimitry Andric >::type() 5470b57cec5SDimitry Andric , _VSTD::move(__x) 5480b57cec5SDimitry Andric , typename __make_tuple_indices<sizeof...(_Args1)>::type{} 5490b57cec5SDimitry Andric ) 5500b57cec5SDimitry Andric , __transform_tuple( 5510b57cec5SDimitry Andric typename __uses_alloc_ctor< 5520b57cec5SDimitry Andric _T2, inner_allocator_type&, _Args2... 5530b57cec5SDimitry Andric >::type() 5540b57cec5SDimitry Andric , _VSTD::move(__y) 5550b57cec5SDimitry Andric , typename __make_tuple_indices<sizeof...(_Args2)>::type{} 5560b57cec5SDimitry Andric ) 5570b57cec5SDimitry Andric ); 5580b57cec5SDimitry Andric } 5590b57cec5SDimitry Andric 5600b57cec5SDimitry Andric template <class _T1, class _T2> 561*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p) 5620b57cec5SDimitry Andric { construct(__p, piecewise_construct, tuple<>{}, tuple<>{}); } 5630b57cec5SDimitry Andric 5640b57cec5SDimitry Andric template <class _T1, class _T2, class _Up, class _Vp> 565*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, _Up&& __x, _Vp&& __y) { 5660b57cec5SDimitry Andric construct(__p, piecewise_construct, 5670b57cec5SDimitry Andric _VSTD::forward_as_tuple(_VSTD::forward<_Up>(__x)), 5680b57cec5SDimitry Andric _VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__y))); 5690b57cec5SDimitry Andric } 5700b57cec5SDimitry Andric 5710b57cec5SDimitry Andric template <class _T1, class _T2, class _Up, class _Vp> 572*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, const pair<_Up, _Vp>& __x) { 5730b57cec5SDimitry Andric construct(__p, piecewise_construct, 5740b57cec5SDimitry Andric _VSTD::forward_as_tuple(__x.first), 5750b57cec5SDimitry Andric _VSTD::forward_as_tuple(__x.second)); 5760b57cec5SDimitry Andric } 5770b57cec5SDimitry Andric 5780b57cec5SDimitry Andric template <class _T1, class _T2, class _Up, class _Vp> 579*06c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, pair<_Up, _Vp>&& __x) { 5800b57cec5SDimitry Andric construct(__p, piecewise_construct, 5810b57cec5SDimitry Andric _VSTD::forward_as_tuple(_VSTD::forward<_Up>(__x.first)), 5820b57cec5SDimitry Andric _VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__x.second))); 5830b57cec5SDimitry Andric } 584bdd1243dSDimitry Andric#endif 5850b57cec5SDimitry Andric 5860b57cec5SDimitry Andric template <class _Tp> 5870b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5880b57cec5SDimitry Andric void destroy(_Tp* __p) 5890b57cec5SDimitry Andric { 5900b57cec5SDimitry Andric typedef __outermost<outer_allocator_type> _OM; 5910b57cec5SDimitry Andric allocator_traits<typename _OM::type>:: 5920b57cec5SDimitry Andric destroy(_OM()(outer_allocator()), __p); 5930b57cec5SDimitry Andric } 5940b57cec5SDimitry Andric 5950b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5960b57cec5SDimitry Andric scoped_allocator_adaptor select_on_container_copy_construction() const _NOEXCEPT 5970b57cec5SDimitry Andric {return base::select_on_container_copy_construction();} 5980b57cec5SDimitry Andric 5990b57cec5SDimitry Andricprivate: 6000b57cec5SDimitry Andric 6010b57cec5SDimitry Andric 6020b57cec5SDimitry Andric template <class _OuterA2, 6030b57cec5SDimitry Andric class = typename enable_if< 6040b57cec5SDimitry Andric is_constructible<outer_allocator_type, _OuterA2>::value 6050b57cec5SDimitry Andric >::type> 6060b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6070b57cec5SDimitry Andric scoped_allocator_adaptor(_OuterA2&& __o, 6080b57cec5SDimitry Andric const inner_allocator_type& __i) _NOEXCEPT 6090b57cec5SDimitry Andric : base(_VSTD::forward<_OuterA2>(__o), __i) {} 6100b57cec5SDimitry Andric 6110b57cec5SDimitry Andric template <class _Tp, class... _Args> 6120b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6130b57cec5SDimitry Andric void __construct(integral_constant<int, 0>, _Tp* __p, _Args&& ...__args) 6140b57cec5SDimitry Andric { 6150b57cec5SDimitry Andric typedef __outermost<outer_allocator_type> _OM; 6160b57cec5SDimitry Andric allocator_traits<typename _OM::type>::construct 6170b57cec5SDimitry Andric ( 6180b57cec5SDimitry Andric _OM()(outer_allocator()), 6190b57cec5SDimitry Andric __p, 6200b57cec5SDimitry Andric _VSTD::forward<_Args>(__args)... 6210b57cec5SDimitry Andric ); 6220b57cec5SDimitry Andric } 6230b57cec5SDimitry Andric 6240b57cec5SDimitry Andric template <class _Tp, class... _Args> 6250b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6260b57cec5SDimitry Andric void __construct(integral_constant<int, 1>, _Tp* __p, _Args&& ...__args) 6270b57cec5SDimitry Andric { 6280b57cec5SDimitry Andric typedef __outermost<outer_allocator_type> _OM; 6290b57cec5SDimitry Andric allocator_traits<typename _OM::type>::construct 6300b57cec5SDimitry Andric ( 6310b57cec5SDimitry Andric _OM()(outer_allocator()), 6320b57cec5SDimitry Andric __p, allocator_arg, inner_allocator(), 6330b57cec5SDimitry Andric _VSTD::forward<_Args>(__args)... 6340b57cec5SDimitry Andric ); 6350b57cec5SDimitry Andric } 6360b57cec5SDimitry Andric 6370b57cec5SDimitry Andric template <class _Tp, class... _Args> 6380b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6390b57cec5SDimitry Andric void __construct(integral_constant<int, 2>, _Tp* __p, _Args&& ...__args) 6400b57cec5SDimitry Andric { 6410b57cec5SDimitry Andric typedef __outermost<outer_allocator_type> _OM; 6420b57cec5SDimitry Andric allocator_traits<typename _OM::type>::construct 6430b57cec5SDimitry Andric ( 6440b57cec5SDimitry Andric _OM()(outer_allocator()), 6450b57cec5SDimitry Andric __p, 6460b57cec5SDimitry Andric _VSTD::forward<_Args>(__args)..., 6470b57cec5SDimitry Andric inner_allocator() 6480b57cec5SDimitry Andric ); 6490b57cec5SDimitry Andric } 6500b57cec5SDimitry Andric 6510b57cec5SDimitry Andric template <class ..._Args, size_t ..._Idx> 6520b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6530b57cec5SDimitry Andric tuple<_Args&&...> 6540b57cec5SDimitry Andric __transform_tuple(integral_constant<int, 0>, tuple<_Args...>&& __t, 6550b57cec5SDimitry Andric __tuple_indices<_Idx...>) 6560b57cec5SDimitry Andric { 6570b57cec5SDimitry Andric return _VSTD::forward_as_tuple(_VSTD::get<_Idx>(_VSTD::move(__t))...); 6580b57cec5SDimitry Andric } 6590b57cec5SDimitry Andric 6600b57cec5SDimitry Andric template <class ..._Args, size_t ..._Idx> 6610b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6620b57cec5SDimitry Andric tuple<allocator_arg_t, inner_allocator_type&, _Args&&...> 6630b57cec5SDimitry Andric __transform_tuple(integral_constant<int, 1>, tuple<_Args...> && __t, 6640b57cec5SDimitry Andric __tuple_indices<_Idx...>) 6650b57cec5SDimitry Andric { 6660b57cec5SDimitry Andric using _Tup = tuple<allocator_arg_t, inner_allocator_type&, _Args&&...>; 6670b57cec5SDimitry Andric return _Tup(allocator_arg, inner_allocator(), 6680b57cec5SDimitry Andric _VSTD::get<_Idx>(_VSTD::move(__t))...); 6690b57cec5SDimitry Andric } 6700b57cec5SDimitry Andric 6710b57cec5SDimitry Andric template <class ..._Args, size_t ..._Idx> 6720b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6730b57cec5SDimitry Andric tuple<_Args&&..., inner_allocator_type&> 6740b57cec5SDimitry Andric __transform_tuple(integral_constant<int, 2>, tuple<_Args...> && __t, 6750b57cec5SDimitry Andric __tuple_indices<_Idx...>) 6760b57cec5SDimitry Andric { 6770b57cec5SDimitry Andric using _Tup = tuple<_Args&&..., inner_allocator_type&>; 6780b57cec5SDimitry Andric return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., inner_allocator()); 6790b57cec5SDimitry Andric } 6800b57cec5SDimitry Andric 6810b57cec5SDimitry Andric template <class...> friend class __scoped_allocator_storage; 6820b57cec5SDimitry Andric}; 6830b57cec5SDimitry Andric 684*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17 685349cc55cSDimitry Andrictemplate<class _OuterAlloc, class... _InnerAllocs> 686349cc55cSDimitry Andric scoped_allocator_adaptor(_OuterAlloc, _InnerAllocs...) 687349cc55cSDimitry Andric -> scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>; 688349cc55cSDimitry Andric#endif 689349cc55cSDimitry Andric 6900b57cec5SDimitry Andrictemplate <class _OuterA1, class _OuterA2> 6910b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 6920b57cec5SDimitry Andricbool 6930b57cec5SDimitry Andricoperator==(const scoped_allocator_adaptor<_OuterA1>& __a, 6940b57cec5SDimitry Andric const scoped_allocator_adaptor<_OuterA2>& __b) _NOEXCEPT 6950b57cec5SDimitry Andric{ 6960b57cec5SDimitry Andric return __a.outer_allocator() == __b.outer_allocator(); 6970b57cec5SDimitry Andric} 6980b57cec5SDimitry Andric 6990b57cec5SDimitry Andrictemplate <class _OuterA1, class _OuterA2, class _InnerA0, class... _InnerAllocs> 7000b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 7010b57cec5SDimitry Andricbool 7020b57cec5SDimitry Andricoperator==(const scoped_allocator_adaptor<_OuterA1, _InnerA0, _InnerAllocs...>& __a, 7030b57cec5SDimitry Andric const scoped_allocator_adaptor<_OuterA2, _InnerA0, _InnerAllocs...>& __b) _NOEXCEPT 7040b57cec5SDimitry Andric{ 7050b57cec5SDimitry Andric return __a.outer_allocator() == __b.outer_allocator() && 7060b57cec5SDimitry Andric __a.inner_allocator() == __b.inner_allocator(); 7070b57cec5SDimitry Andric} 7080b57cec5SDimitry Andric 709*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER <= 17 710*06c3fb27SDimitry Andric 7110b57cec5SDimitry Andrictemplate <class _OuterA1, class _OuterA2, class... _InnerAllocs> 7120b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 7130b57cec5SDimitry Andricbool 7140b57cec5SDimitry Andricoperator!=(const scoped_allocator_adaptor<_OuterA1, _InnerAllocs...>& __a, 7150b57cec5SDimitry Andric const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __b) _NOEXCEPT 7160b57cec5SDimitry Andric{ 7170b57cec5SDimitry Andric return !(__a == __b); 7180b57cec5SDimitry Andric} 7190b57cec5SDimitry Andric 720*06c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER <= 17 721*06c3fb27SDimitry Andric 7220b57cec5SDimitry Andric#endif // !defined(_LIBCPP_CXX03_LANG) 7230b57cec5SDimitry Andric 7240b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD 7250b57cec5SDimitry Andric 726*06c3fb27SDimitry Andric_LIBCPP_POP_MACROS 727*06c3fb27SDimitry Andric 728bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 729bdd1243dSDimitry Andric# include <atomic> 730bdd1243dSDimitry Andric# include <climits> 731bdd1243dSDimitry Andric# include <concepts> 732bdd1243dSDimitry Andric# include <cstring> 733bdd1243dSDimitry Andric# include <ctime> 734bdd1243dSDimitry Andric# include <iterator> 735bdd1243dSDimitry Andric# include <memory> 736bdd1243dSDimitry Andric# include <ratio> 737bdd1243dSDimitry Andric# include <stdexcept> 738bdd1243dSDimitry Andric# include <type_traits> 739bdd1243dSDimitry Andric# include <variant> 740bdd1243dSDimitry Andric#endif 741bdd1243dSDimitry Andric 7420b57cec5SDimitry Andric#endif // _LIBCPP_SCOPED_ALLOCATOR 743