xref: /freebsd/contrib/llvm-project/libcxx/include/scoped_allocator (revision fe6060f10f634930ff71b7c50291ddc610da2475)
10b57cec5SDimitry Andric// -*- C++ -*-
20b57cec5SDimitry Andric//===-------------------------- scoped_allocator --------------------------===//
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
940b57cec5SDimitry Andrictemplate <class OuterA1, class OuterA2, class... InnerAllocs>
950b57cec5SDimitry Andric    bool
960b57cec5SDimitry Andric    operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
970b57cec5SDimitry Andric               const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;
980b57cec5SDimitry Andric
990b57cec5SDimitry Andrictemplate <class OuterA1, class OuterA2, class... InnerAllocs>
1000b57cec5SDimitry Andric    bool
1010b57cec5SDimitry Andric    operator!=(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
1020b57cec5SDimitry Andric               const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;
1030b57cec5SDimitry Andric
1040b57cec5SDimitry Andric}  // std
1050b57cec5SDimitry Andric
1060b57cec5SDimitry Andric*/
1070b57cec5SDimitry Andric
1080b57cec5SDimitry Andric#include <__config>
109*fe6060f1SDimitry Andric#include <__utility/forward.h>
1100b57cec5SDimitry Andric#include <memory>
1110b57cec5SDimitry Andric#include <version>
1120b57cec5SDimitry Andric
1130b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1140b57cec5SDimitry Andric#pragma GCC system_header
1150b57cec5SDimitry Andric#endif
1160b57cec5SDimitry Andric
1170b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
1180b57cec5SDimitry Andric
1190b57cec5SDimitry Andric#if !defined(_LIBCPP_CXX03_LANG)
1200b57cec5SDimitry Andric
1210b57cec5SDimitry Andric// scoped_allocator_adaptor
1220b57cec5SDimitry Andric
1230b57cec5SDimitry Andrictemplate <class ..._Allocs>
1240b57cec5SDimitry Andricclass scoped_allocator_adaptor;
1250b57cec5SDimitry Andric
1260b57cec5SDimitry Andrictemplate <class ..._Allocs> struct __get_poc_copy_assignment;
1270b57cec5SDimitry Andric
1280b57cec5SDimitry Andrictemplate <class _A0>
1290b57cec5SDimitry Andricstruct __get_poc_copy_assignment<_A0>
1300b57cec5SDimitry Andric{
1310b57cec5SDimitry Andric    static const bool value = allocator_traits<_A0>::
1320b57cec5SDimitry Andric                              propagate_on_container_copy_assignment::value;
1330b57cec5SDimitry Andric};
1340b57cec5SDimitry Andric
1350b57cec5SDimitry Andrictemplate <class _A0, class ..._Allocs>
1360b57cec5SDimitry Andricstruct __get_poc_copy_assignment<_A0, _Allocs...>
1370b57cec5SDimitry Andric{
1380b57cec5SDimitry Andric    static const bool value =
1390b57cec5SDimitry Andric        allocator_traits<_A0>::propagate_on_container_copy_assignment::value ||
1400b57cec5SDimitry Andric        __get_poc_copy_assignment<_Allocs...>::value;
1410b57cec5SDimitry Andric};
1420b57cec5SDimitry Andric
1430b57cec5SDimitry Andrictemplate <class ..._Allocs> struct __get_poc_move_assignment;
1440b57cec5SDimitry Andric
1450b57cec5SDimitry Andrictemplate <class _A0>
1460b57cec5SDimitry Andricstruct __get_poc_move_assignment<_A0>
1470b57cec5SDimitry Andric{
1480b57cec5SDimitry Andric    static const bool value = allocator_traits<_A0>::
1490b57cec5SDimitry Andric                              propagate_on_container_move_assignment::value;
1500b57cec5SDimitry Andric};
1510b57cec5SDimitry Andric
1520b57cec5SDimitry Andrictemplate <class _A0, class ..._Allocs>
1530b57cec5SDimitry Andricstruct __get_poc_move_assignment<_A0, _Allocs...>
1540b57cec5SDimitry Andric{
1550b57cec5SDimitry Andric    static const bool value =
1560b57cec5SDimitry Andric        allocator_traits<_A0>::propagate_on_container_move_assignment::value ||
1570b57cec5SDimitry Andric        __get_poc_move_assignment<_Allocs...>::value;
1580b57cec5SDimitry Andric};
1590b57cec5SDimitry Andric
1600b57cec5SDimitry Andrictemplate <class ..._Allocs> struct __get_poc_swap;
1610b57cec5SDimitry Andric
1620b57cec5SDimitry Andrictemplate <class _A0>
1630b57cec5SDimitry Andricstruct __get_poc_swap<_A0>
1640b57cec5SDimitry Andric{
1650b57cec5SDimitry Andric    static const bool value = allocator_traits<_A0>::
1660b57cec5SDimitry Andric                              propagate_on_container_swap::value;
1670b57cec5SDimitry Andric};
1680b57cec5SDimitry Andric
1690b57cec5SDimitry Andrictemplate <class _A0, class ..._Allocs>
1700b57cec5SDimitry Andricstruct __get_poc_swap<_A0, _Allocs...>
1710b57cec5SDimitry Andric{
1720b57cec5SDimitry Andric    static const bool value =
1730b57cec5SDimitry Andric        allocator_traits<_A0>::propagate_on_container_swap::value ||
1740b57cec5SDimitry Andric        __get_poc_swap<_Allocs...>::value;
1750b57cec5SDimitry Andric};
1760b57cec5SDimitry Andric
1770b57cec5SDimitry Andrictemplate <class ..._Allocs> struct __get_is_always_equal;
1780b57cec5SDimitry Andric
1790b57cec5SDimitry Andrictemplate <class _A0>
1800b57cec5SDimitry Andricstruct __get_is_always_equal<_A0>
1810b57cec5SDimitry Andric{
1820b57cec5SDimitry Andric    static const bool value = allocator_traits<_A0>::is_always_equal::value;
1830b57cec5SDimitry Andric};
1840b57cec5SDimitry Andric
1850b57cec5SDimitry Andrictemplate <class _A0, class ..._Allocs>
1860b57cec5SDimitry Andricstruct __get_is_always_equal<_A0, _Allocs...>
1870b57cec5SDimitry Andric{
1880b57cec5SDimitry Andric    static const bool value =
1890b57cec5SDimitry Andric        allocator_traits<_A0>::is_always_equal::value &&
1900b57cec5SDimitry Andric        __get_is_always_equal<_Allocs...>::value;
1910b57cec5SDimitry Andric};
1920b57cec5SDimitry Andric
1930b57cec5SDimitry Andrictemplate <class ..._Allocs>
1940b57cec5SDimitry Andricclass __scoped_allocator_storage;
1950b57cec5SDimitry Andric
1960b57cec5SDimitry Andrictemplate <class _OuterAlloc, class... _InnerAllocs>
1970b57cec5SDimitry Andricclass __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...>
1980b57cec5SDimitry Andric    : public _OuterAlloc
1990b57cec5SDimitry Andric{
2000b57cec5SDimitry Andric    typedef _OuterAlloc outer_allocator_type;
2010b57cec5SDimitry Andricprotected:
2020b57cec5SDimitry Andric    typedef scoped_allocator_adaptor<_InnerAllocs...> inner_allocator_type;
2030b57cec5SDimitry Andric
2040b57cec5SDimitry Andricprivate:
2050b57cec5SDimitry Andric    inner_allocator_type __inner_;
2060b57cec5SDimitry Andric
2070b57cec5SDimitry Andricprotected:
2080b57cec5SDimitry Andric
2090b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2100b57cec5SDimitry Andric    __scoped_allocator_storage() _NOEXCEPT {}
2110b57cec5SDimitry Andric
2120b57cec5SDimitry Andric    template <class _OuterA2,
2130b57cec5SDimitry Andric              class = typename enable_if<
2140b57cec5SDimitry Andric                        is_constructible<outer_allocator_type, _OuterA2>::value
2150b57cec5SDimitry Andric                      >::type>
2160b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
2170b57cec5SDimitry Andric        __scoped_allocator_storage(_OuterA2&& __outerAlloc,
2180b57cec5SDimitry Andric                                   const _InnerAllocs& ...__innerAllocs) _NOEXCEPT
2190b57cec5SDimitry Andric            : outer_allocator_type(_VSTD::forward<_OuterA2>(__outerAlloc)),
2200b57cec5SDimitry Andric              __inner_(__innerAllocs...) {}
2210b57cec5SDimitry Andric
2220b57cec5SDimitry Andric    template <class _OuterA2,
2230b57cec5SDimitry Andric              class = typename enable_if<
2240b57cec5SDimitry Andric                        is_constructible<outer_allocator_type, const _OuterA2&>::value
2250b57cec5SDimitry Andric                      >::type>
2260b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
2270b57cec5SDimitry Andric        __scoped_allocator_storage(
2280b57cec5SDimitry Andric            const __scoped_allocator_storage<_OuterA2, _InnerAllocs...>& __other) _NOEXCEPT
2290b57cec5SDimitry Andric            : outer_allocator_type(__other.outer_allocator()),
2300b57cec5SDimitry Andric              __inner_(__other.inner_allocator()) {}
2310b57cec5SDimitry Andric
2320b57cec5SDimitry Andric    template <class _OuterA2,
2330b57cec5SDimitry Andric              class = typename enable_if<
2340b57cec5SDimitry Andric                        is_constructible<outer_allocator_type, _OuterA2>::value
2350b57cec5SDimitry Andric                      >::type>
2360b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
2370b57cec5SDimitry Andric        __scoped_allocator_storage(
2380b57cec5SDimitry Andric            __scoped_allocator_storage<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT
2390b57cec5SDimitry Andric            : outer_allocator_type(_VSTD::move(__other.outer_allocator())),
2400b57cec5SDimitry Andric              __inner_(_VSTD::move(__other.inner_allocator())) {}
2410b57cec5SDimitry Andric
2420b57cec5SDimitry Andric    template <class _OuterA2,
2430b57cec5SDimitry Andric              class = typename enable_if<
2440b57cec5SDimitry Andric                        is_constructible<outer_allocator_type, _OuterA2>::value
2450b57cec5SDimitry Andric                      >::type>
2460b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
2470b57cec5SDimitry Andric        __scoped_allocator_storage(_OuterA2&& __o,
2480b57cec5SDimitry Andric                                   const inner_allocator_type& __i) _NOEXCEPT
2490b57cec5SDimitry Andric            : outer_allocator_type(_VSTD::forward<_OuterA2>(__o)),
2500b57cec5SDimitry Andric              __inner_(__i)
2510b57cec5SDimitry Andric        {
2520b57cec5SDimitry Andric        }
2530b57cec5SDimitry Andric
2540b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2550b57cec5SDimitry Andric    inner_allocator_type& inner_allocator() _NOEXCEPT             {return __inner_;}
2560b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2570b57cec5SDimitry Andric    const inner_allocator_type& inner_allocator() const _NOEXCEPT {return __inner_;}
2580b57cec5SDimitry Andric
2590b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2600b57cec5SDimitry Andric    outer_allocator_type& outer_allocator() _NOEXCEPT
2610b57cec5SDimitry Andric        {return static_cast<outer_allocator_type&>(*this);}
2620b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2630b57cec5SDimitry Andric    const outer_allocator_type& outer_allocator() const _NOEXCEPT
2640b57cec5SDimitry Andric        {return static_cast<const outer_allocator_type&>(*this);}
2650b57cec5SDimitry Andric
2660b57cec5SDimitry Andric    scoped_allocator_adaptor<outer_allocator_type, _InnerAllocs...>
2670b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2680b57cec5SDimitry Andric    select_on_container_copy_construction() const _NOEXCEPT
2690b57cec5SDimitry Andric        {
2700b57cec5SDimitry Andric            return scoped_allocator_adaptor<outer_allocator_type, _InnerAllocs...>
2710b57cec5SDimitry Andric            (
2720b57cec5SDimitry Andric                allocator_traits<outer_allocator_type>::
2730b57cec5SDimitry Andric                    select_on_container_copy_construction(outer_allocator()),
2740b57cec5SDimitry Andric                allocator_traits<inner_allocator_type>::
2750b57cec5SDimitry Andric                    select_on_container_copy_construction(inner_allocator())
2760b57cec5SDimitry Andric            );
2770b57cec5SDimitry Andric        }
2780b57cec5SDimitry Andric
2790b57cec5SDimitry Andric    template <class...> friend class __scoped_allocator_storage;
2800b57cec5SDimitry Andric};
2810b57cec5SDimitry Andric
2820b57cec5SDimitry Andrictemplate <class _OuterAlloc>
2830b57cec5SDimitry Andricclass __scoped_allocator_storage<_OuterAlloc>
2840b57cec5SDimitry Andric    : public _OuterAlloc
2850b57cec5SDimitry Andric{
2860b57cec5SDimitry Andric    typedef _OuterAlloc outer_allocator_type;
2870b57cec5SDimitry Andricprotected:
2880b57cec5SDimitry Andric    typedef scoped_allocator_adaptor<_OuterAlloc> inner_allocator_type;
2890b57cec5SDimitry Andric
2900b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2910b57cec5SDimitry Andric    __scoped_allocator_storage() _NOEXCEPT {}
2920b57cec5SDimitry Andric
2930b57cec5SDimitry Andric    template <class _OuterA2,
2940b57cec5SDimitry Andric              class = typename enable_if<
2950b57cec5SDimitry Andric                        is_constructible<outer_allocator_type, _OuterA2>::value
2960b57cec5SDimitry Andric                      >::type>
2970b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
2980b57cec5SDimitry Andric        __scoped_allocator_storage(_OuterA2&& __outerAlloc) _NOEXCEPT
2990b57cec5SDimitry Andric            : outer_allocator_type(_VSTD::forward<_OuterA2>(__outerAlloc)) {}
3000b57cec5SDimitry Andric
3010b57cec5SDimitry Andric    template <class _OuterA2,
3020b57cec5SDimitry Andric              class = typename enable_if<
3030b57cec5SDimitry Andric                        is_constructible<outer_allocator_type, const _OuterA2&>::value
3040b57cec5SDimitry Andric                      >::type>
3050b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
3060b57cec5SDimitry Andric        __scoped_allocator_storage(
3070b57cec5SDimitry Andric            const __scoped_allocator_storage<_OuterA2>& __other) _NOEXCEPT
3080b57cec5SDimitry Andric            : outer_allocator_type(__other.outer_allocator()) {}
3090b57cec5SDimitry Andric
3100b57cec5SDimitry Andric    template <class _OuterA2,
3110b57cec5SDimitry Andric              class = typename enable_if<
3120b57cec5SDimitry Andric                        is_constructible<outer_allocator_type, _OuterA2>::value
3130b57cec5SDimitry Andric                      >::type>
3140b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
3150b57cec5SDimitry Andric        __scoped_allocator_storage(
3160b57cec5SDimitry Andric            __scoped_allocator_storage<_OuterA2>&& __other) _NOEXCEPT
3170b57cec5SDimitry Andric            : outer_allocator_type(_VSTD::move(__other.outer_allocator())) {}
3180b57cec5SDimitry Andric
3190b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3200b57cec5SDimitry Andric    inner_allocator_type& inner_allocator() _NOEXCEPT
3210b57cec5SDimitry Andric        {return static_cast<inner_allocator_type&>(*this);}
3220b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3230b57cec5SDimitry Andric    const inner_allocator_type& inner_allocator() const _NOEXCEPT
3240b57cec5SDimitry Andric        {return static_cast<const inner_allocator_type&>(*this);}
3250b57cec5SDimitry Andric
3260b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3270b57cec5SDimitry Andric    outer_allocator_type& outer_allocator() _NOEXCEPT
3280b57cec5SDimitry Andric        {return static_cast<outer_allocator_type&>(*this);}
3290b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3300b57cec5SDimitry Andric    const outer_allocator_type& outer_allocator() const _NOEXCEPT
3310b57cec5SDimitry Andric        {return static_cast<const outer_allocator_type&>(*this);}
3320b57cec5SDimitry Andric
3330b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3340b57cec5SDimitry Andric    scoped_allocator_adaptor<outer_allocator_type>
3350b57cec5SDimitry Andric    select_on_container_copy_construction() const _NOEXCEPT
3360b57cec5SDimitry Andric        {return scoped_allocator_adaptor<outer_allocator_type>(
3370b57cec5SDimitry Andric            allocator_traits<outer_allocator_type>::
3380b57cec5SDimitry Andric                select_on_container_copy_construction(outer_allocator())
3390b57cec5SDimitry Andric        );}
3400b57cec5SDimitry Andric
3410b57cec5SDimitry Andric    __scoped_allocator_storage(const outer_allocator_type& __o,
3420b57cec5SDimitry Andric                               const inner_allocator_type& __i) _NOEXCEPT;
3430b57cec5SDimitry Andric
3440b57cec5SDimitry Andric    template <class...> friend class __scoped_allocator_storage;
3450b57cec5SDimitry Andric};
3460b57cec5SDimitry Andric
3470b57cec5SDimitry Andric// __outermost
3480b57cec5SDimitry Andric
3490b57cec5SDimitry Andrictemplate <class _Alloc>
3500b57cec5SDimitry Andricdecltype(declval<_Alloc>().outer_allocator(), true_type())
3510b57cec5SDimitry Andric__has_outer_allocator_test(_Alloc&& __a);
3520b57cec5SDimitry Andric
3530b57cec5SDimitry Andrictemplate <class _Alloc>
3540b57cec5SDimitry Andricfalse_type
3550b57cec5SDimitry Andric__has_outer_allocator_test(const volatile _Alloc& __a);
3560b57cec5SDimitry Andric
3570b57cec5SDimitry Andrictemplate <class _Alloc>
3580b57cec5SDimitry Andricstruct __has_outer_allocator
3590b57cec5SDimitry Andric    : public common_type
3600b57cec5SDimitry Andric             <
3610b57cec5SDimitry Andric                 decltype(__has_outer_allocator_test(declval<_Alloc&>()))
3620b57cec5SDimitry Andric             >::type
3630b57cec5SDimitry Andric{
3640b57cec5SDimitry Andric};
3650b57cec5SDimitry Andric
3660b57cec5SDimitry Andrictemplate <class _Alloc, bool = __has_outer_allocator<_Alloc>::value>
3670b57cec5SDimitry Andricstruct __outermost
3680b57cec5SDimitry Andric{
3690b57cec5SDimitry Andric    typedef _Alloc type;
3700b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3710b57cec5SDimitry Andric    type& operator()(type& __a) const _NOEXCEPT {return __a;}
3720b57cec5SDimitry Andric};
3730b57cec5SDimitry Andric
3740b57cec5SDimitry Andrictemplate <class _Alloc>
3750b57cec5SDimitry Andricstruct __outermost<_Alloc, true>
3760b57cec5SDimitry Andric{
3770b57cec5SDimitry Andric    typedef typename remove_reference
3780b57cec5SDimitry Andric                     <
379*fe6060f1SDimitry Andric                        decltype(declval<_Alloc>().outer_allocator())
3800b57cec5SDimitry Andric                     >::type                                    _OuterAlloc;
3810b57cec5SDimitry Andric    typedef typename __outermost<_OuterAlloc>::type             type;
3820b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3830b57cec5SDimitry Andric    type& operator()(_Alloc& __a) const _NOEXCEPT
3840b57cec5SDimitry Andric        {return __outermost<_OuterAlloc>()(__a.outer_allocator());}
3850b57cec5SDimitry Andric};
3860b57cec5SDimitry Andric
3870b57cec5SDimitry Andrictemplate <class _OuterAlloc, class... _InnerAllocs>
3880b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>
3890b57cec5SDimitry Andric    : public __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...>
3900b57cec5SDimitry Andric{
3910b57cec5SDimitry Andric    typedef __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> base;
3920b57cec5SDimitry Andric    typedef allocator_traits<_OuterAlloc>             _OuterTraits;
3930b57cec5SDimitry Andricpublic:
3940b57cec5SDimitry Andric    typedef _OuterAlloc                               outer_allocator_type;
3950b57cec5SDimitry Andric    typedef typename base::inner_allocator_type       inner_allocator_type;
3960b57cec5SDimitry Andric    typedef typename _OuterTraits::size_type          size_type;
3970b57cec5SDimitry Andric    typedef typename _OuterTraits::difference_type    difference_type;
3980b57cec5SDimitry Andric    typedef typename _OuterTraits::pointer            pointer;
3990b57cec5SDimitry Andric    typedef typename _OuterTraits::const_pointer      const_pointer;
4000b57cec5SDimitry Andric    typedef typename _OuterTraits::void_pointer       void_pointer;
4010b57cec5SDimitry Andric    typedef typename _OuterTraits::const_void_pointer const_void_pointer;
4020b57cec5SDimitry Andric
4030b57cec5SDimitry Andric    typedef integral_constant
4040b57cec5SDimitry Andric            <
4050b57cec5SDimitry Andric                bool,
4060b57cec5SDimitry Andric                __get_poc_copy_assignment<outer_allocator_type,
4070b57cec5SDimitry Andric                                          _InnerAllocs...>::value
4080b57cec5SDimitry Andric            > propagate_on_container_copy_assignment;
4090b57cec5SDimitry Andric    typedef integral_constant
4100b57cec5SDimitry Andric            <
4110b57cec5SDimitry Andric                bool,
4120b57cec5SDimitry Andric                __get_poc_move_assignment<outer_allocator_type,
4130b57cec5SDimitry Andric                                          _InnerAllocs...>::value
4140b57cec5SDimitry Andric            > propagate_on_container_move_assignment;
4150b57cec5SDimitry Andric    typedef integral_constant
4160b57cec5SDimitry Andric            <
4170b57cec5SDimitry Andric                bool,
4180b57cec5SDimitry Andric                __get_poc_swap<outer_allocator_type, _InnerAllocs...>::value
4190b57cec5SDimitry Andric            > propagate_on_container_swap;
4200b57cec5SDimitry Andric    typedef integral_constant
4210b57cec5SDimitry Andric            <
4220b57cec5SDimitry Andric                bool,
4230b57cec5SDimitry Andric                __get_is_always_equal<outer_allocator_type, _InnerAllocs...>::value
4240b57cec5SDimitry Andric            > is_always_equal;
4250b57cec5SDimitry Andric
4260b57cec5SDimitry Andric    template <class _Tp>
4270b57cec5SDimitry Andric    struct rebind
4280b57cec5SDimitry Andric    {
4290b57cec5SDimitry Andric        typedef scoped_allocator_adaptor
4300b57cec5SDimitry Andric        <
4310b57cec5SDimitry Andric            typename _OuterTraits::template rebind_alloc<_Tp>, _InnerAllocs...
4320b57cec5SDimitry Andric        > other;
4330b57cec5SDimitry Andric    };
4340b57cec5SDimitry Andric
4350b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4360b57cec5SDimitry Andric    scoped_allocator_adaptor() _NOEXCEPT {}
4370b57cec5SDimitry Andric    template <class _OuterA2,
4380b57cec5SDimitry Andric              class = typename enable_if<
4390b57cec5SDimitry Andric                        is_constructible<outer_allocator_type, _OuterA2>::value
4400b57cec5SDimitry Andric                      >::type>
4410b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
4420b57cec5SDimitry Andric        scoped_allocator_adaptor(_OuterA2&& __outerAlloc,
4430b57cec5SDimitry Andric                                 const _InnerAllocs& ...__innerAllocs) _NOEXCEPT
4440b57cec5SDimitry Andric            : base(_VSTD::forward<_OuterA2>(__outerAlloc), __innerAllocs...) {}
4450b57cec5SDimitry Andric    // scoped_allocator_adaptor(const scoped_allocator_adaptor& __other) = default;
4460b57cec5SDimitry Andric    template <class _OuterA2,
4470b57cec5SDimitry Andric              class = typename enable_if<
4480b57cec5SDimitry Andric                        is_constructible<outer_allocator_type, const _OuterA2&>::value
4490b57cec5SDimitry Andric                      >::type>
4500b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
4510b57cec5SDimitry Andric        scoped_allocator_adaptor(
4520b57cec5SDimitry Andric            const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __other) _NOEXCEPT
4530b57cec5SDimitry Andric                : base(__other) {}
4540b57cec5SDimitry Andric    template <class _OuterA2,
4550b57cec5SDimitry Andric              class = typename enable_if<
4560b57cec5SDimitry Andric                        is_constructible<outer_allocator_type, _OuterA2>::value
4570b57cec5SDimitry Andric                      >::type>
4580b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
4590b57cec5SDimitry Andric        scoped_allocator_adaptor(
4600b57cec5SDimitry Andric            scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT
4610b57cec5SDimitry Andric                : base(_VSTD::move(__other)) {}
4620b57cec5SDimitry Andric
4630b57cec5SDimitry Andric    // scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default;
4640b57cec5SDimitry Andric    // scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default;
4650b57cec5SDimitry Andric    // ~scoped_allocator_adaptor() = default;
4660b57cec5SDimitry Andric
4670b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4680b57cec5SDimitry Andric    inner_allocator_type& inner_allocator() _NOEXCEPT
4690b57cec5SDimitry Andric        {return base::inner_allocator();}
4700b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4710b57cec5SDimitry Andric    const inner_allocator_type& inner_allocator() const _NOEXCEPT
4720b57cec5SDimitry Andric        {return base::inner_allocator();}
4730b57cec5SDimitry Andric
4740b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4750b57cec5SDimitry Andric    outer_allocator_type& outer_allocator() _NOEXCEPT
4760b57cec5SDimitry Andric        {return base::outer_allocator();}
4770b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4780b57cec5SDimitry Andric    const outer_allocator_type& outer_allocator() const _NOEXCEPT
4790b57cec5SDimitry Andric        {return base::outer_allocator();}
4800b57cec5SDimitry Andric
4810b57cec5SDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
4820b57cec5SDimitry Andric    pointer allocate(size_type __n)
4830b57cec5SDimitry Andric        {return allocator_traits<outer_allocator_type>::
4840b57cec5SDimitry Andric            allocate(outer_allocator(), __n);}
4850b57cec5SDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
4860b57cec5SDimitry Andric    pointer allocate(size_type __n, const_void_pointer __hint)
4870b57cec5SDimitry Andric        {return allocator_traits<outer_allocator_type>::
4880b57cec5SDimitry Andric            allocate(outer_allocator(), __n, __hint);}
4890b57cec5SDimitry Andric
4900b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4910b57cec5SDimitry Andric    void deallocate(pointer __p, size_type __n) _NOEXCEPT
4920b57cec5SDimitry Andric        {allocator_traits<outer_allocator_type>::
4930b57cec5SDimitry Andric            deallocate(outer_allocator(), __p, __n);}
4940b57cec5SDimitry Andric
4950b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4960b57cec5SDimitry Andric    size_type max_size() const
4970b57cec5SDimitry Andric        {return allocator_traits<outer_allocator_type>::max_size(outer_allocator());}
4980b57cec5SDimitry Andric
4990b57cec5SDimitry Andric    template <class _Tp, class... _Args>
5000b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5010b57cec5SDimitry Andric        void construct(_Tp* __p, _Args&& ...__args)
5020b57cec5SDimitry Andric            {__construct(__uses_alloc_ctor<_Tp, inner_allocator_type&, _Args...>(),
5030b57cec5SDimitry Andric                         __p, _VSTD::forward<_Args>(__args)...);}
5040b57cec5SDimitry Andric
5050b57cec5SDimitry Andric    template <class _T1, class _T2, class... _Args1, class... _Args2>
5060b57cec5SDimitry Andric    void construct(pair<_T1, _T2>* __p, piecewise_construct_t,
5070b57cec5SDimitry Andric                       tuple<_Args1...> __x, tuple<_Args2...> __y)
5080b57cec5SDimitry Andric    {
5090b57cec5SDimitry Andric        typedef __outermost<outer_allocator_type> _OM;
5100b57cec5SDimitry Andric        allocator_traits<typename _OM::type>::construct(
5110b57cec5SDimitry Andric            _OM()(outer_allocator()), __p, piecewise_construct
5120b57cec5SDimitry Andric          , __transform_tuple(
5130b57cec5SDimitry Andric              typename __uses_alloc_ctor<
5140b57cec5SDimitry Andric                  _T1, inner_allocator_type&, _Args1...
5150b57cec5SDimitry Andric              >::type()
5160b57cec5SDimitry Andric            , _VSTD::move(__x)
5170b57cec5SDimitry Andric            , typename __make_tuple_indices<sizeof...(_Args1)>::type{}
5180b57cec5SDimitry Andric          )
5190b57cec5SDimitry Andric          , __transform_tuple(
5200b57cec5SDimitry Andric              typename __uses_alloc_ctor<
5210b57cec5SDimitry Andric                  _T2, inner_allocator_type&, _Args2...
5220b57cec5SDimitry Andric              >::type()
5230b57cec5SDimitry Andric            , _VSTD::move(__y)
5240b57cec5SDimitry Andric            , typename __make_tuple_indices<sizeof...(_Args2)>::type{}
5250b57cec5SDimitry Andric          )
5260b57cec5SDimitry Andric        );
5270b57cec5SDimitry Andric    }
5280b57cec5SDimitry Andric
5290b57cec5SDimitry Andric    template <class _T1, class _T2>
5300b57cec5SDimitry Andric    void construct(pair<_T1, _T2>* __p)
5310b57cec5SDimitry Andric    { construct(__p, piecewise_construct, tuple<>{}, tuple<>{}); }
5320b57cec5SDimitry Andric
5330b57cec5SDimitry Andric    template <class _T1, class _T2, class _Up, class _Vp>
5340b57cec5SDimitry Andric    void construct(pair<_T1, _T2>* __p, _Up&& __x, _Vp&& __y) {
5350b57cec5SDimitry Andric        construct(__p, piecewise_construct,
5360b57cec5SDimitry Andric                  _VSTD::forward_as_tuple(_VSTD::forward<_Up>(__x)),
5370b57cec5SDimitry Andric                  _VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__y)));
5380b57cec5SDimitry Andric    }
5390b57cec5SDimitry Andric
5400b57cec5SDimitry Andric    template <class _T1, class _T2, class _Up, class _Vp>
5410b57cec5SDimitry Andric    void construct(pair<_T1, _T2>* __p, const pair<_Up, _Vp>& __x) {
5420b57cec5SDimitry Andric        construct(__p, piecewise_construct,
5430b57cec5SDimitry Andric                  _VSTD::forward_as_tuple(__x.first),
5440b57cec5SDimitry Andric                  _VSTD::forward_as_tuple(__x.second));
5450b57cec5SDimitry Andric    }
5460b57cec5SDimitry Andric
5470b57cec5SDimitry Andric    template <class _T1, class _T2, class _Up, class _Vp>
5480b57cec5SDimitry Andric    void construct(pair<_T1, _T2>* __p, pair<_Up, _Vp>&& __x) {
5490b57cec5SDimitry Andric        construct(__p, piecewise_construct,
5500b57cec5SDimitry Andric                  _VSTD::forward_as_tuple(_VSTD::forward<_Up>(__x.first)),
5510b57cec5SDimitry Andric                  _VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__x.second)));
5520b57cec5SDimitry Andric    }
5530b57cec5SDimitry Andric
5540b57cec5SDimitry Andric    template <class _Tp>
5550b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5560b57cec5SDimitry Andric        void destroy(_Tp* __p)
5570b57cec5SDimitry Andric            {
5580b57cec5SDimitry Andric                typedef __outermost<outer_allocator_type> _OM;
5590b57cec5SDimitry Andric                allocator_traits<typename _OM::type>::
5600b57cec5SDimitry Andric                                         destroy(_OM()(outer_allocator()), __p);
5610b57cec5SDimitry Andric            }
5620b57cec5SDimitry Andric
5630b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5640b57cec5SDimitry Andric    scoped_allocator_adaptor select_on_container_copy_construction() const _NOEXCEPT
5650b57cec5SDimitry Andric        {return base::select_on_container_copy_construction();}
5660b57cec5SDimitry Andric
5670b57cec5SDimitry Andricprivate:
5680b57cec5SDimitry Andric
5690b57cec5SDimitry Andric
5700b57cec5SDimitry Andric    template <class _OuterA2,
5710b57cec5SDimitry Andric              class = typename enable_if<
5720b57cec5SDimitry Andric                        is_constructible<outer_allocator_type, _OuterA2>::value
5730b57cec5SDimitry Andric                      >::type>
5740b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5750b57cec5SDimitry Andric    scoped_allocator_adaptor(_OuterA2&& __o,
5760b57cec5SDimitry Andric                             const inner_allocator_type& __i) _NOEXCEPT
5770b57cec5SDimitry Andric        : base(_VSTD::forward<_OuterA2>(__o), __i) {}
5780b57cec5SDimitry Andric
5790b57cec5SDimitry Andric    template <class _Tp, class... _Args>
5800b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5810b57cec5SDimitry Andric        void __construct(integral_constant<int, 0>, _Tp* __p, _Args&& ...__args)
5820b57cec5SDimitry Andric            {
5830b57cec5SDimitry Andric                typedef __outermost<outer_allocator_type> _OM;
5840b57cec5SDimitry Andric                allocator_traits<typename _OM::type>::construct
5850b57cec5SDimitry Andric                (
5860b57cec5SDimitry Andric                    _OM()(outer_allocator()),
5870b57cec5SDimitry Andric                    __p,
5880b57cec5SDimitry Andric                    _VSTD::forward<_Args>(__args)...
5890b57cec5SDimitry Andric                );
5900b57cec5SDimitry Andric            }
5910b57cec5SDimitry Andric
5920b57cec5SDimitry Andric    template <class _Tp, class... _Args>
5930b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5940b57cec5SDimitry Andric        void __construct(integral_constant<int, 1>, _Tp* __p, _Args&& ...__args)
5950b57cec5SDimitry Andric            {
5960b57cec5SDimitry Andric                typedef __outermost<outer_allocator_type> _OM;
5970b57cec5SDimitry Andric                allocator_traits<typename _OM::type>::construct
5980b57cec5SDimitry Andric                (
5990b57cec5SDimitry Andric                    _OM()(outer_allocator()),
6000b57cec5SDimitry Andric                    __p, allocator_arg, inner_allocator(),
6010b57cec5SDimitry Andric                    _VSTD::forward<_Args>(__args)...
6020b57cec5SDimitry Andric                );
6030b57cec5SDimitry Andric            }
6040b57cec5SDimitry Andric
6050b57cec5SDimitry Andric    template <class _Tp, class... _Args>
6060b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
6070b57cec5SDimitry Andric        void __construct(integral_constant<int, 2>, _Tp* __p, _Args&& ...__args)
6080b57cec5SDimitry Andric            {
6090b57cec5SDimitry Andric                typedef __outermost<outer_allocator_type> _OM;
6100b57cec5SDimitry Andric                allocator_traits<typename _OM::type>::construct
6110b57cec5SDimitry Andric                (
6120b57cec5SDimitry Andric                    _OM()(outer_allocator()),
6130b57cec5SDimitry Andric                    __p,
6140b57cec5SDimitry Andric                    _VSTD::forward<_Args>(__args)...,
6150b57cec5SDimitry Andric                    inner_allocator()
6160b57cec5SDimitry Andric                );
6170b57cec5SDimitry Andric            }
6180b57cec5SDimitry Andric
6190b57cec5SDimitry Andric    template <class ..._Args, size_t ..._Idx>
6200b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6210b57cec5SDimitry Andric    tuple<_Args&&...>
6220b57cec5SDimitry Andric    __transform_tuple(integral_constant<int, 0>, tuple<_Args...>&& __t,
6230b57cec5SDimitry Andric                      __tuple_indices<_Idx...>)
6240b57cec5SDimitry Andric    {
6250b57cec5SDimitry Andric        return _VSTD::forward_as_tuple(_VSTD::get<_Idx>(_VSTD::move(__t))...);
6260b57cec5SDimitry Andric    }
6270b57cec5SDimitry Andric
6280b57cec5SDimitry Andric    template <class ..._Args, size_t ..._Idx>
6290b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6300b57cec5SDimitry Andric    tuple<allocator_arg_t, inner_allocator_type&, _Args&&...>
6310b57cec5SDimitry Andric    __transform_tuple(integral_constant<int, 1>, tuple<_Args...> && __t,
6320b57cec5SDimitry Andric                      __tuple_indices<_Idx...>)
6330b57cec5SDimitry Andric    {
6340b57cec5SDimitry Andric        using _Tup = tuple<allocator_arg_t, inner_allocator_type&, _Args&&...>;
6350b57cec5SDimitry Andric        return _Tup(allocator_arg, inner_allocator(),
6360b57cec5SDimitry Andric                    _VSTD::get<_Idx>(_VSTD::move(__t))...);
6370b57cec5SDimitry Andric    }
6380b57cec5SDimitry Andric
6390b57cec5SDimitry Andric    template <class ..._Args, size_t ..._Idx>
6400b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6410b57cec5SDimitry Andric    tuple<_Args&&..., inner_allocator_type&>
6420b57cec5SDimitry Andric    __transform_tuple(integral_constant<int, 2>, tuple<_Args...> && __t,
6430b57cec5SDimitry Andric                      __tuple_indices<_Idx...>)
6440b57cec5SDimitry Andric    {
6450b57cec5SDimitry Andric        using _Tup = tuple<_Args&&..., inner_allocator_type&>;
6460b57cec5SDimitry Andric        return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., inner_allocator());
6470b57cec5SDimitry Andric    }
6480b57cec5SDimitry Andric
6490b57cec5SDimitry Andric    template <class...> friend class __scoped_allocator_storage;
6500b57cec5SDimitry Andric};
6510b57cec5SDimitry Andric
6520b57cec5SDimitry Andrictemplate <class _OuterA1, class _OuterA2>
6530b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
6540b57cec5SDimitry Andricbool
6550b57cec5SDimitry Andricoperator==(const scoped_allocator_adaptor<_OuterA1>& __a,
6560b57cec5SDimitry Andric           const scoped_allocator_adaptor<_OuterA2>& __b) _NOEXCEPT
6570b57cec5SDimitry Andric{
6580b57cec5SDimitry Andric    return __a.outer_allocator() == __b.outer_allocator();
6590b57cec5SDimitry Andric}
6600b57cec5SDimitry Andric
6610b57cec5SDimitry Andrictemplate <class _OuterA1, class _OuterA2, class _InnerA0, class... _InnerAllocs>
6620b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
6630b57cec5SDimitry Andricbool
6640b57cec5SDimitry Andricoperator==(const scoped_allocator_adaptor<_OuterA1, _InnerA0, _InnerAllocs...>& __a,
6650b57cec5SDimitry Andric           const scoped_allocator_adaptor<_OuterA2, _InnerA0, _InnerAllocs...>& __b) _NOEXCEPT
6660b57cec5SDimitry Andric{
6670b57cec5SDimitry Andric    return __a.outer_allocator() == __b.outer_allocator() &&
6680b57cec5SDimitry Andric           __a.inner_allocator() == __b.inner_allocator();
6690b57cec5SDimitry Andric}
6700b57cec5SDimitry Andric
6710b57cec5SDimitry Andrictemplate <class _OuterA1, class _OuterA2, class... _InnerAllocs>
6720b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
6730b57cec5SDimitry Andricbool
6740b57cec5SDimitry Andricoperator!=(const scoped_allocator_adaptor<_OuterA1, _InnerAllocs...>& __a,
6750b57cec5SDimitry Andric           const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __b) _NOEXCEPT
6760b57cec5SDimitry Andric{
6770b57cec5SDimitry Andric    return !(__a == __b);
6780b57cec5SDimitry Andric}
6790b57cec5SDimitry Andric
6800b57cec5SDimitry Andric#endif // !defined(_LIBCPP_CXX03_LANG)
6810b57cec5SDimitry Andric
6820b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
6830b57cec5SDimitry Andric
6840b57cec5SDimitry Andric#endif // _LIBCPP_SCOPED_ALLOCATOR
685