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, 10606c3fb27SDimitry 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 13306c3fb27SDimitry Andric_LIBCPP_PUSH_MACROS 13406c3fb27SDimitry Andric#include <__undef_macros> 13506c3fb27SDimitry 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 228*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 2290b57cec5SDimitry Andric __scoped_allocator_storage() _NOEXCEPT {} 2300b57cec5SDimitry Andric 2310b57cec5SDimitry Andric template <class _OuterA2, 232*5f757f3fSDimitry Andric __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0> 233*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 234753f127fSDimitry Andric __scoped_allocator_storage(_OuterA2&& __outer_alloc, 235753f127fSDimitry Andric const _InnerAllocs& ...__inner_allocs) _NOEXCEPT 236*5f757f3fSDimitry Andric : outer_allocator_type(std::forward<_OuterA2>(__outer_alloc)), 237753f127fSDimitry Andric __inner_(__inner_allocs...) {} 2380b57cec5SDimitry Andric 2390b57cec5SDimitry Andric template <class _OuterA2, 240*5f757f3fSDimitry Andric __enable_if_t<is_constructible<outer_allocator_type, const _OuterA2&>::value, int> = 0> 241*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 2420b57cec5SDimitry Andric __scoped_allocator_storage( 2430b57cec5SDimitry Andric const __scoped_allocator_storage<_OuterA2, _InnerAllocs...>& __other) _NOEXCEPT 2440b57cec5SDimitry Andric : outer_allocator_type(__other.outer_allocator()), 2450b57cec5SDimitry Andric __inner_(__other.inner_allocator()) {} 2460b57cec5SDimitry Andric 2470b57cec5SDimitry Andric template <class _OuterA2, 248*5f757f3fSDimitry Andric __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0> 249*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 2500b57cec5SDimitry Andric __scoped_allocator_storage( 2510b57cec5SDimitry Andric __scoped_allocator_storage<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT 252*5f757f3fSDimitry Andric : outer_allocator_type(std::move(__other.outer_allocator())), 253*5f757f3fSDimitry Andric __inner_(std::move(__other.inner_allocator())) {} 2540b57cec5SDimitry Andric 2550b57cec5SDimitry Andric template <class _OuterA2, 256*5f757f3fSDimitry Andric __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0> 257*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 2580b57cec5SDimitry Andric __scoped_allocator_storage(_OuterA2&& __o, 2590b57cec5SDimitry Andric const inner_allocator_type& __i) _NOEXCEPT 260*5f757f3fSDimitry Andric : outer_allocator_type(std::forward<_OuterA2>(__o)), 2610b57cec5SDimitry Andric __inner_(__i) 2620b57cec5SDimitry Andric { 2630b57cec5SDimitry Andric } 2640b57cec5SDimitry Andric 265*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 2660b57cec5SDimitry Andric inner_allocator_type& inner_allocator() _NOEXCEPT {return __inner_;} 267*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 2680b57cec5SDimitry Andric const inner_allocator_type& inner_allocator() const _NOEXCEPT {return __inner_;} 2690b57cec5SDimitry Andric 270*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 2710b57cec5SDimitry Andric outer_allocator_type& outer_allocator() _NOEXCEPT 2720b57cec5SDimitry Andric {return static_cast<outer_allocator_type&>(*this);} 273*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 2740b57cec5SDimitry Andric const outer_allocator_type& outer_allocator() const _NOEXCEPT 2750b57cec5SDimitry Andric {return static_cast<const outer_allocator_type&>(*this);} 2760b57cec5SDimitry Andric 2770b57cec5SDimitry Andric scoped_allocator_adaptor<outer_allocator_type, _InnerAllocs...> 278*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 2790b57cec5SDimitry Andric select_on_container_copy_construction() const _NOEXCEPT 2800b57cec5SDimitry Andric { 2810b57cec5SDimitry Andric return scoped_allocator_adaptor<outer_allocator_type, _InnerAllocs...> 2820b57cec5SDimitry Andric ( 2830b57cec5SDimitry Andric allocator_traits<outer_allocator_type>:: 2840b57cec5SDimitry Andric select_on_container_copy_construction(outer_allocator()), 2850b57cec5SDimitry Andric allocator_traits<inner_allocator_type>:: 2860b57cec5SDimitry Andric select_on_container_copy_construction(inner_allocator()) 2870b57cec5SDimitry Andric ); 2880b57cec5SDimitry Andric } 2890b57cec5SDimitry Andric 2900b57cec5SDimitry Andric template <class...> friend class __scoped_allocator_storage; 2910b57cec5SDimitry Andric}; 2920b57cec5SDimitry Andric 2930b57cec5SDimitry Andrictemplate <class _OuterAlloc> 2940b57cec5SDimitry Andricclass __scoped_allocator_storage<_OuterAlloc> 2950b57cec5SDimitry Andric : public _OuterAlloc 2960b57cec5SDimitry Andric{ 2970b57cec5SDimitry Andric typedef _OuterAlloc outer_allocator_type; 2980b57cec5SDimitry Andricprotected: 2990b57cec5SDimitry Andric typedef scoped_allocator_adaptor<_OuterAlloc> inner_allocator_type; 3000b57cec5SDimitry Andric 301*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 3020b57cec5SDimitry Andric __scoped_allocator_storage() _NOEXCEPT {} 3030b57cec5SDimitry Andric 3040b57cec5SDimitry Andric template <class _OuterA2, 305*5f757f3fSDimitry Andric __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0> 306*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 307753f127fSDimitry Andric __scoped_allocator_storage(_OuterA2&& __outer_alloc) _NOEXCEPT 308*5f757f3fSDimitry Andric : outer_allocator_type(std::forward<_OuterA2>(__outer_alloc)) {} 3090b57cec5SDimitry Andric 3100b57cec5SDimitry Andric template <class _OuterA2, 311*5f757f3fSDimitry Andric __enable_if_t<is_constructible<outer_allocator_type, const _OuterA2&>::value, int> = 0> 312*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 3130b57cec5SDimitry Andric __scoped_allocator_storage( 3140b57cec5SDimitry Andric const __scoped_allocator_storage<_OuterA2>& __other) _NOEXCEPT 3150b57cec5SDimitry Andric : outer_allocator_type(__other.outer_allocator()) {} 3160b57cec5SDimitry Andric 3170b57cec5SDimitry Andric template <class _OuterA2, 318*5f757f3fSDimitry Andric __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0> 319*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 3200b57cec5SDimitry Andric __scoped_allocator_storage( 3210b57cec5SDimitry Andric __scoped_allocator_storage<_OuterA2>&& __other) _NOEXCEPT 322*5f757f3fSDimitry Andric : outer_allocator_type(std::move(__other.outer_allocator())) {} 3230b57cec5SDimitry Andric 324*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 3250b57cec5SDimitry Andric inner_allocator_type& inner_allocator() _NOEXCEPT 3260b57cec5SDimitry Andric {return static_cast<inner_allocator_type&>(*this);} 327*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 3280b57cec5SDimitry Andric const inner_allocator_type& inner_allocator() const _NOEXCEPT 3290b57cec5SDimitry Andric {return static_cast<const inner_allocator_type&>(*this);} 3300b57cec5SDimitry Andric 331*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 3320b57cec5SDimitry Andric outer_allocator_type& outer_allocator() _NOEXCEPT 3330b57cec5SDimitry Andric {return static_cast<outer_allocator_type&>(*this);} 334*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 3350b57cec5SDimitry Andric const outer_allocator_type& outer_allocator() const _NOEXCEPT 3360b57cec5SDimitry Andric {return static_cast<const outer_allocator_type&>(*this);} 3370b57cec5SDimitry Andric 338*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 3390b57cec5SDimitry Andric scoped_allocator_adaptor<outer_allocator_type> 3400b57cec5SDimitry Andric select_on_container_copy_construction() const _NOEXCEPT 3410b57cec5SDimitry Andric {return scoped_allocator_adaptor<outer_allocator_type>( 3420b57cec5SDimitry Andric allocator_traits<outer_allocator_type>:: 3430b57cec5SDimitry Andric select_on_container_copy_construction(outer_allocator()) 3440b57cec5SDimitry Andric );} 3450b57cec5SDimitry Andric 3460b57cec5SDimitry Andric __scoped_allocator_storage(const outer_allocator_type& __o, 3470b57cec5SDimitry Andric const inner_allocator_type& __i) _NOEXCEPT; 3480b57cec5SDimitry Andric 3490b57cec5SDimitry Andric template <class...> friend class __scoped_allocator_storage; 3500b57cec5SDimitry Andric}; 3510b57cec5SDimitry Andric 3520b57cec5SDimitry Andric// __outermost 3530b57cec5SDimitry Andric 3540b57cec5SDimitry Andrictemplate <class _Alloc> 355bdd1243dSDimitry Andricdecltype(std::declval<_Alloc>().outer_allocator(), true_type()) 3560b57cec5SDimitry Andric__has_outer_allocator_test(_Alloc&& __a); 3570b57cec5SDimitry Andric 3580b57cec5SDimitry Andrictemplate <class _Alloc> 3590b57cec5SDimitry Andricfalse_type 3600b57cec5SDimitry Andric__has_outer_allocator_test(const volatile _Alloc& __a); 3610b57cec5SDimitry Andric 3620b57cec5SDimitry Andrictemplate <class _Alloc> 3630b57cec5SDimitry Andricstruct __has_outer_allocator 3640b57cec5SDimitry Andric : public common_type 3650b57cec5SDimitry Andric < 366bdd1243dSDimitry Andric decltype(std::__has_outer_allocator_test(std::declval<_Alloc&>())) 3670b57cec5SDimitry Andric >::type 3680b57cec5SDimitry Andric{ 3690b57cec5SDimitry Andric}; 3700b57cec5SDimitry Andric 3710b57cec5SDimitry Andrictemplate <class _Alloc, bool = __has_outer_allocator<_Alloc>::value> 3720b57cec5SDimitry Andricstruct __outermost 3730b57cec5SDimitry Andric{ 3740b57cec5SDimitry Andric typedef _Alloc type; 375*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 3760b57cec5SDimitry Andric type& operator()(type& __a) const _NOEXCEPT {return __a;} 3770b57cec5SDimitry Andric}; 3780b57cec5SDimitry Andric 3790b57cec5SDimitry Andrictemplate <class _Alloc> 3800b57cec5SDimitry Andricstruct __outermost<_Alloc, true> 3810b57cec5SDimitry Andric{ 382bdd1243dSDimitry Andric typedef __libcpp_remove_reference_t 3830b57cec5SDimitry Andric < 384bdd1243dSDimitry Andric decltype(std::declval<_Alloc>().outer_allocator()) 385bdd1243dSDimitry Andric > _OuterAlloc; 3860b57cec5SDimitry Andric typedef typename __outermost<_OuterAlloc>::type type; 387*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 3880b57cec5SDimitry Andric type& operator()(_Alloc& __a) const _NOEXCEPT 3890b57cec5SDimitry Andric {return __outermost<_OuterAlloc>()(__a.outer_allocator());} 3900b57cec5SDimitry Andric}; 3910b57cec5SDimitry Andric 3920b57cec5SDimitry Andrictemplate <class _OuterAlloc, class... _InnerAllocs> 3930b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...> 3940b57cec5SDimitry Andric : public __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> 3950b57cec5SDimitry Andric{ 3960b57cec5SDimitry Andric typedef __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> base; 3970b57cec5SDimitry Andric typedef allocator_traits<_OuterAlloc> _OuterTraits; 3980b57cec5SDimitry Andricpublic: 3990b57cec5SDimitry Andric typedef _OuterAlloc outer_allocator_type; 4000b57cec5SDimitry Andric typedef typename base::inner_allocator_type inner_allocator_type; 4010b57cec5SDimitry Andric typedef typename _OuterTraits::size_type size_type; 4020b57cec5SDimitry Andric typedef typename _OuterTraits::difference_type difference_type; 4030b57cec5SDimitry Andric typedef typename _OuterTraits::pointer pointer; 4040b57cec5SDimitry Andric typedef typename _OuterTraits::const_pointer const_pointer; 4050b57cec5SDimitry Andric typedef typename _OuterTraits::void_pointer void_pointer; 4060b57cec5SDimitry Andric typedef typename _OuterTraits::const_void_pointer const_void_pointer; 4070b57cec5SDimitry Andric 4080b57cec5SDimitry Andric typedef integral_constant 4090b57cec5SDimitry Andric < 4100b57cec5SDimitry Andric bool, 4110b57cec5SDimitry Andric __get_poc_copy_assignment<outer_allocator_type, 4120b57cec5SDimitry Andric _InnerAllocs...>::value 4130b57cec5SDimitry Andric > propagate_on_container_copy_assignment; 4140b57cec5SDimitry Andric typedef integral_constant 4150b57cec5SDimitry Andric < 4160b57cec5SDimitry Andric bool, 4170b57cec5SDimitry Andric __get_poc_move_assignment<outer_allocator_type, 4180b57cec5SDimitry Andric _InnerAllocs...>::value 4190b57cec5SDimitry Andric > propagate_on_container_move_assignment; 4200b57cec5SDimitry Andric typedef integral_constant 4210b57cec5SDimitry Andric < 4220b57cec5SDimitry Andric bool, 4230b57cec5SDimitry Andric __get_poc_swap<outer_allocator_type, _InnerAllocs...>::value 4240b57cec5SDimitry Andric > propagate_on_container_swap; 4250b57cec5SDimitry Andric typedef integral_constant 4260b57cec5SDimitry Andric < 4270b57cec5SDimitry Andric bool, 4280b57cec5SDimitry Andric __get_is_always_equal<outer_allocator_type, _InnerAllocs...>::value 4290b57cec5SDimitry Andric > is_always_equal; 4300b57cec5SDimitry Andric 4310b57cec5SDimitry Andric template <class _Tp> 4320b57cec5SDimitry Andric struct rebind 4330b57cec5SDimitry Andric { 4340b57cec5SDimitry Andric typedef scoped_allocator_adaptor 4350b57cec5SDimitry Andric < 4360b57cec5SDimitry Andric typename _OuterTraits::template rebind_alloc<_Tp>, _InnerAllocs... 4370b57cec5SDimitry Andric > other; 4380b57cec5SDimitry Andric }; 4390b57cec5SDimitry Andric 440*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 4410b57cec5SDimitry Andric scoped_allocator_adaptor() _NOEXCEPT {} 4420b57cec5SDimitry Andric template <class _OuterA2, 443*5f757f3fSDimitry Andric __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0> 444*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 445753f127fSDimitry Andric scoped_allocator_adaptor(_OuterA2&& __outer_alloc, 446753f127fSDimitry Andric const _InnerAllocs& ...__inner_allocs) _NOEXCEPT 447*5f757f3fSDimitry Andric : base(std::forward<_OuterA2>(__outer_alloc), __inner_allocs...) {} 4480b57cec5SDimitry Andric // scoped_allocator_adaptor(const scoped_allocator_adaptor& __other) = default; 4490b57cec5SDimitry Andric template <class _OuterA2, 450*5f757f3fSDimitry Andric __enable_if_t<is_constructible<outer_allocator_type, const _OuterA2&>::value, int> = 0> 451*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 4520b57cec5SDimitry Andric scoped_allocator_adaptor( 4530b57cec5SDimitry Andric const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __other) _NOEXCEPT 4540b57cec5SDimitry Andric : base(__other) {} 4550b57cec5SDimitry Andric template <class _OuterA2, 456*5f757f3fSDimitry Andric __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0> 457*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 4580b57cec5SDimitry Andric scoped_allocator_adaptor( 4590b57cec5SDimitry Andric scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT 460*5f757f3fSDimitry Andric : base(std::move(__other)) {} 4610b57cec5SDimitry Andric 4620b57cec5SDimitry Andric // scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default; 4630b57cec5SDimitry Andric // scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default; 4640b57cec5SDimitry Andric // ~scoped_allocator_adaptor() = default; 4650b57cec5SDimitry Andric 466*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 4670b57cec5SDimitry Andric inner_allocator_type& inner_allocator() _NOEXCEPT 4680b57cec5SDimitry Andric {return base::inner_allocator();} 469*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 4700b57cec5SDimitry Andric const inner_allocator_type& inner_allocator() const _NOEXCEPT 4710b57cec5SDimitry Andric {return base::inner_allocator();} 4720b57cec5SDimitry Andric 473*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 4740b57cec5SDimitry Andric outer_allocator_type& outer_allocator() _NOEXCEPT 4750b57cec5SDimitry Andric {return base::outer_allocator();} 476*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 4770b57cec5SDimitry Andric const outer_allocator_type& outer_allocator() const _NOEXCEPT 4780b57cec5SDimitry Andric {return base::outer_allocator();} 4790b57cec5SDimitry Andric 480*5f757f3fSDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI 4810b57cec5SDimitry Andric pointer allocate(size_type __n) 4820b57cec5SDimitry Andric {return allocator_traits<outer_allocator_type>:: 4830b57cec5SDimitry Andric allocate(outer_allocator(), __n);} 484*5f757f3fSDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI 4850b57cec5SDimitry Andric pointer allocate(size_type __n, const_void_pointer __hint) 4860b57cec5SDimitry Andric {return allocator_traits<outer_allocator_type>:: 4870b57cec5SDimitry Andric allocate(outer_allocator(), __n, __hint);} 4880b57cec5SDimitry Andric 489*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 4900b57cec5SDimitry Andric void deallocate(pointer __p, size_type __n) _NOEXCEPT 4910b57cec5SDimitry Andric {allocator_traits<outer_allocator_type>:: 4920b57cec5SDimitry Andric deallocate(outer_allocator(), __p, __n);} 4930b57cec5SDimitry Andric 494*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 4950b57cec5SDimitry Andric size_type max_size() const 4960b57cec5SDimitry Andric {return allocator_traits<outer_allocator_type>::max_size(outer_allocator());} 4970b57cec5SDimitry Andric 498bdd1243dSDimitry Andric#if _LIBCPP_STD_VER >= 20 499bdd1243dSDimitry Andric template <class _Type, class... _Args> 500bdd1243dSDimitry Andric _LIBCPP_HIDE_FROM_ABI void construct(_Type* __ptr, _Args&&... __args) { 501bdd1243dSDimitry Andric using _OM = __outermost<outer_allocator_type>; 502bdd1243dSDimitry Andric std::apply( 503bdd1243dSDimitry Andric [__ptr, this](auto&&... __newargs) { 504bdd1243dSDimitry Andric allocator_traits<typename _OM::type>::construct( 505bdd1243dSDimitry Andric _OM()(outer_allocator()), __ptr, std::forward<decltype(__newargs)>(__newargs)...); 506bdd1243dSDimitry Andric }, 507bdd1243dSDimitry Andric std::uses_allocator_construction_args<_Type>(inner_allocator(), std::forward<_Args>(__args)...)); 508bdd1243dSDimitry Andric } 509bdd1243dSDimitry Andric#else 5100b57cec5SDimitry Andric template <class _Tp, class... _Args> 511*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 5120b57cec5SDimitry Andric void construct(_Tp* __p, _Args&& ...__args) 5130b57cec5SDimitry Andric {__construct(__uses_alloc_ctor<_Tp, inner_allocator_type&, _Args...>(), 514*5f757f3fSDimitry Andric __p, std::forward<_Args>(__args)...);} 5150b57cec5SDimitry Andric 5160b57cec5SDimitry Andric template <class _T1, class _T2, class... _Args1, class... _Args2> 51706c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, piecewise_construct_t, 5180b57cec5SDimitry Andric tuple<_Args1...> __x, tuple<_Args2...> __y) 5190b57cec5SDimitry Andric { 5200b57cec5SDimitry Andric typedef __outermost<outer_allocator_type> _OM; 5210b57cec5SDimitry Andric allocator_traits<typename _OM::type>::construct( 5220b57cec5SDimitry Andric _OM()(outer_allocator()), __p, piecewise_construct 5230b57cec5SDimitry Andric , __transform_tuple( 5240b57cec5SDimitry Andric typename __uses_alloc_ctor< 5250b57cec5SDimitry Andric _T1, inner_allocator_type&, _Args1... 5260b57cec5SDimitry Andric >::type() 527*5f757f3fSDimitry Andric , std::move(__x) 5280b57cec5SDimitry Andric , typename __make_tuple_indices<sizeof...(_Args1)>::type{} 5290b57cec5SDimitry Andric ) 5300b57cec5SDimitry Andric , __transform_tuple( 5310b57cec5SDimitry Andric typename __uses_alloc_ctor< 5320b57cec5SDimitry Andric _T2, inner_allocator_type&, _Args2... 5330b57cec5SDimitry Andric >::type() 534*5f757f3fSDimitry Andric , std::move(__y) 5350b57cec5SDimitry Andric , typename __make_tuple_indices<sizeof...(_Args2)>::type{} 5360b57cec5SDimitry Andric ) 5370b57cec5SDimitry Andric ); 5380b57cec5SDimitry Andric } 5390b57cec5SDimitry Andric 5400b57cec5SDimitry Andric template <class _T1, class _T2> 54106c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p) 5420b57cec5SDimitry Andric { construct(__p, piecewise_construct, tuple<>{}, tuple<>{}); } 5430b57cec5SDimitry Andric 5440b57cec5SDimitry Andric template <class _T1, class _T2, class _Up, class _Vp> 54506c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, _Up&& __x, _Vp&& __y) { 5460b57cec5SDimitry Andric construct(__p, piecewise_construct, 547*5f757f3fSDimitry Andric std::forward_as_tuple(std::forward<_Up>(__x)), 548*5f757f3fSDimitry Andric std::forward_as_tuple(std::forward<_Vp>(__y))); 5490b57cec5SDimitry Andric } 5500b57cec5SDimitry Andric 5510b57cec5SDimitry Andric template <class _T1, class _T2, class _Up, class _Vp> 55206c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, const pair<_Up, _Vp>& __x) { 5530b57cec5SDimitry Andric construct(__p, piecewise_construct, 554*5f757f3fSDimitry Andric std::forward_as_tuple(__x.first), 555*5f757f3fSDimitry Andric std::forward_as_tuple(__x.second)); 5560b57cec5SDimitry Andric } 5570b57cec5SDimitry Andric 5580b57cec5SDimitry Andric template <class _T1, class _T2, class _Up, class _Vp> 55906c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, pair<_Up, _Vp>&& __x) { 5600b57cec5SDimitry Andric construct(__p, piecewise_construct, 561*5f757f3fSDimitry Andric std::forward_as_tuple(std::forward<_Up>(__x.first)), 562*5f757f3fSDimitry Andric std::forward_as_tuple(std::forward<_Vp>(__x.second))); 5630b57cec5SDimitry Andric } 564bdd1243dSDimitry Andric#endif 5650b57cec5SDimitry Andric 5660b57cec5SDimitry Andric template <class _Tp> 567*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 5680b57cec5SDimitry Andric void destroy(_Tp* __p) 5690b57cec5SDimitry Andric { 5700b57cec5SDimitry Andric typedef __outermost<outer_allocator_type> _OM; 5710b57cec5SDimitry Andric allocator_traits<typename _OM::type>:: 5720b57cec5SDimitry Andric destroy(_OM()(outer_allocator()), __p); 5730b57cec5SDimitry Andric } 5740b57cec5SDimitry Andric 575*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 5760b57cec5SDimitry Andric scoped_allocator_adaptor select_on_container_copy_construction() const _NOEXCEPT 5770b57cec5SDimitry Andric {return base::select_on_container_copy_construction();} 5780b57cec5SDimitry Andric 5790b57cec5SDimitry Andricprivate: 5800b57cec5SDimitry Andric 5810b57cec5SDimitry Andric 5820b57cec5SDimitry Andric template <class _OuterA2, 583*5f757f3fSDimitry Andric __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0> 584*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 5850b57cec5SDimitry Andric scoped_allocator_adaptor(_OuterA2&& __o, 5860b57cec5SDimitry Andric const inner_allocator_type& __i) _NOEXCEPT 587*5f757f3fSDimitry Andric : base(std::forward<_OuterA2>(__o), __i) {} 5880b57cec5SDimitry Andric 5890b57cec5SDimitry Andric template <class _Tp, class... _Args> 590*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 5910b57cec5SDimitry Andric void __construct(integral_constant<int, 0>, _Tp* __p, _Args&& ...__args) 5920b57cec5SDimitry Andric { 5930b57cec5SDimitry Andric typedef __outermost<outer_allocator_type> _OM; 5940b57cec5SDimitry Andric allocator_traits<typename _OM::type>::construct 5950b57cec5SDimitry Andric ( 5960b57cec5SDimitry Andric _OM()(outer_allocator()), 5970b57cec5SDimitry Andric __p, 598*5f757f3fSDimitry Andric std::forward<_Args>(__args)... 5990b57cec5SDimitry Andric ); 6000b57cec5SDimitry Andric } 6010b57cec5SDimitry Andric 6020b57cec5SDimitry Andric template <class _Tp, class... _Args> 603*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6040b57cec5SDimitry Andric void __construct(integral_constant<int, 1>, _Tp* __p, _Args&& ...__args) 6050b57cec5SDimitry Andric { 6060b57cec5SDimitry Andric typedef __outermost<outer_allocator_type> _OM; 6070b57cec5SDimitry Andric allocator_traits<typename _OM::type>::construct 6080b57cec5SDimitry Andric ( 6090b57cec5SDimitry Andric _OM()(outer_allocator()), 6100b57cec5SDimitry Andric __p, allocator_arg, inner_allocator(), 611*5f757f3fSDimitry Andric std::forward<_Args>(__args)... 6120b57cec5SDimitry Andric ); 6130b57cec5SDimitry Andric } 6140b57cec5SDimitry Andric 6150b57cec5SDimitry Andric template <class _Tp, class... _Args> 616*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6170b57cec5SDimitry Andric void __construct(integral_constant<int, 2>, _Tp* __p, _Args&& ...__args) 6180b57cec5SDimitry Andric { 6190b57cec5SDimitry Andric typedef __outermost<outer_allocator_type> _OM; 6200b57cec5SDimitry Andric allocator_traits<typename _OM::type>::construct 6210b57cec5SDimitry Andric ( 6220b57cec5SDimitry Andric _OM()(outer_allocator()), 6230b57cec5SDimitry Andric __p, 624*5f757f3fSDimitry Andric std::forward<_Args>(__args)..., 6250b57cec5SDimitry Andric inner_allocator() 6260b57cec5SDimitry Andric ); 6270b57cec5SDimitry Andric } 6280b57cec5SDimitry Andric 6290b57cec5SDimitry Andric template <class ..._Args, size_t ..._Idx> 630*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6310b57cec5SDimitry Andric tuple<_Args&&...> 6320b57cec5SDimitry Andric __transform_tuple(integral_constant<int, 0>, tuple<_Args...>&& __t, 6330b57cec5SDimitry Andric __tuple_indices<_Idx...>) 6340b57cec5SDimitry Andric { 635*5f757f3fSDimitry Andric return std::forward_as_tuple(std::get<_Idx>(std::move(__t))...); 6360b57cec5SDimitry Andric } 6370b57cec5SDimitry Andric 6380b57cec5SDimitry Andric template <class ..._Args, size_t ..._Idx> 639*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6400b57cec5SDimitry Andric tuple<allocator_arg_t, inner_allocator_type&, _Args&&...> 6410b57cec5SDimitry Andric __transform_tuple(integral_constant<int, 1>, tuple<_Args...> && __t, 6420b57cec5SDimitry Andric __tuple_indices<_Idx...>) 6430b57cec5SDimitry Andric { 6440b57cec5SDimitry Andric using _Tup = tuple<allocator_arg_t, inner_allocator_type&, _Args&&...>; 6450b57cec5SDimitry Andric return _Tup(allocator_arg, inner_allocator(), 646*5f757f3fSDimitry Andric std::get<_Idx>(std::move(__t))...); 6470b57cec5SDimitry Andric } 6480b57cec5SDimitry Andric 6490b57cec5SDimitry Andric template <class ..._Args, size_t ..._Idx> 650*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6510b57cec5SDimitry Andric tuple<_Args&&..., inner_allocator_type&> 6520b57cec5SDimitry Andric __transform_tuple(integral_constant<int, 2>, tuple<_Args...> && __t, 6530b57cec5SDimitry Andric __tuple_indices<_Idx...>) 6540b57cec5SDimitry Andric { 6550b57cec5SDimitry Andric using _Tup = tuple<_Args&&..., inner_allocator_type&>; 656*5f757f3fSDimitry Andric return _Tup(std::get<_Idx>(std::move(__t))..., inner_allocator()); 6570b57cec5SDimitry Andric } 6580b57cec5SDimitry Andric 6590b57cec5SDimitry Andric template <class...> friend class __scoped_allocator_storage; 6600b57cec5SDimitry Andric}; 6610b57cec5SDimitry Andric 66206c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17 663349cc55cSDimitry Andrictemplate<class _OuterAlloc, class... _InnerAllocs> 664349cc55cSDimitry Andric scoped_allocator_adaptor(_OuterAlloc, _InnerAllocs...) 665349cc55cSDimitry Andric -> scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>; 666349cc55cSDimitry Andric#endif 667349cc55cSDimitry Andric 6680b57cec5SDimitry Andrictemplate <class _OuterA1, class _OuterA2> 669*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 6700b57cec5SDimitry Andricbool 6710b57cec5SDimitry Andricoperator==(const scoped_allocator_adaptor<_OuterA1>& __a, 6720b57cec5SDimitry Andric const scoped_allocator_adaptor<_OuterA2>& __b) _NOEXCEPT 6730b57cec5SDimitry Andric{ 6740b57cec5SDimitry Andric return __a.outer_allocator() == __b.outer_allocator(); 6750b57cec5SDimitry Andric} 6760b57cec5SDimitry Andric 6770b57cec5SDimitry Andrictemplate <class _OuterA1, class _OuterA2, class _InnerA0, class... _InnerAllocs> 678*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 6790b57cec5SDimitry Andricbool 6800b57cec5SDimitry Andricoperator==(const scoped_allocator_adaptor<_OuterA1, _InnerA0, _InnerAllocs...>& __a, 6810b57cec5SDimitry Andric const scoped_allocator_adaptor<_OuterA2, _InnerA0, _InnerAllocs...>& __b) _NOEXCEPT 6820b57cec5SDimitry Andric{ 6830b57cec5SDimitry Andric return __a.outer_allocator() == __b.outer_allocator() && 6840b57cec5SDimitry Andric __a.inner_allocator() == __b.inner_allocator(); 6850b57cec5SDimitry Andric} 6860b57cec5SDimitry Andric 68706c3fb27SDimitry Andric#if _LIBCPP_STD_VER <= 17 68806c3fb27SDimitry Andric 6890b57cec5SDimitry Andrictemplate <class _OuterA1, class _OuterA2, class... _InnerAllocs> 690*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 6910b57cec5SDimitry Andricbool 6920b57cec5SDimitry Andricoperator!=(const scoped_allocator_adaptor<_OuterA1, _InnerAllocs...>& __a, 6930b57cec5SDimitry Andric const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __b) _NOEXCEPT 6940b57cec5SDimitry Andric{ 6950b57cec5SDimitry Andric return !(__a == __b); 6960b57cec5SDimitry Andric} 6970b57cec5SDimitry Andric 69806c3fb27SDimitry Andric#endif // _LIBCPP_STD_VER <= 17 69906c3fb27SDimitry Andric 7000b57cec5SDimitry Andric#endif // !defined(_LIBCPP_CXX03_LANG) 7010b57cec5SDimitry Andric 7020b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD 7030b57cec5SDimitry Andric 70406c3fb27SDimitry Andric_LIBCPP_POP_MACROS 70506c3fb27SDimitry Andric 706bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 707bdd1243dSDimitry Andric# include <atomic> 708bdd1243dSDimitry Andric# include <climits> 709bdd1243dSDimitry Andric# include <concepts> 710bdd1243dSDimitry Andric# include <cstring> 711bdd1243dSDimitry Andric# include <ctime> 712bdd1243dSDimitry Andric# include <iterator> 713bdd1243dSDimitry Andric# include <memory> 714bdd1243dSDimitry Andric# include <ratio> 715bdd1243dSDimitry Andric# include <stdexcept> 716bdd1243dSDimitry Andric# include <type_traits> 717bdd1243dSDimitry Andric# include <variant> 718bdd1243dSDimitry Andric#endif 719bdd1243dSDimitry Andric 7200b57cec5SDimitry Andric#endif // _LIBCPP_SCOPED_ALLOCATOR 721