Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
scoped_allocator684 linesDownload Raw Back to include
1// -*- C++ -*-2//===-------------------------- scoped_allocator --------------------------===//3//4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCUDACXX_SCOPED_ALLOCATOR11#define _LIBCUDACXX_SCOPED_ALLOCATOR12 13/*14    scoped_allocator synopsis15 16namespace std17{18 19template <class OuterAlloc, class... InnerAllocs>20class scoped_allocator_adaptor : public OuterAlloc21{22    typedef allocator_traits<OuterAlloc> OuterTraits; // exposition only23    scoped_allocator_adaptor<InnerAllocs...> inner;   // exposition only24public:25 26    typedef OuterAlloc outer_allocator_type;27    typedef see below inner_allocator_type;28 29    typedef typename OuterTraits::value_type value_type;30    typedef typename OuterTraits::size_type size_type;31    typedef typename OuterTraits::difference_type difference_type;32    typedef typename OuterTraits::pointer pointer;33    typedef typename OuterTraits::const_pointer const_pointer;34    typedef typename OuterTraits::void_pointer void_pointer;35    typedef typename OuterTraits::const_void_pointer const_void_pointer;36 37    typedef see below propagate_on_container_copy_assignment;38    typedef see below propagate_on_container_move_assignment;39    typedef see below propagate_on_container_swap;40    typedef see below is_always_equal;41 42    template <class Tp>43        struct rebind44        {45            typedef scoped_allocator_adaptor<46                OuterTraits::template rebind_alloc<Tp>, InnerAllocs...> other;47        };48 49    scoped_allocator_adaptor();50    template <class OuterA2>51        scoped_allocator_adaptor(OuterA2&& outerAlloc,52                                 const InnerAllocs&... innerAllocs) noexcept;53    scoped_allocator_adaptor(const scoped_allocator_adaptor& other) noexcept;54    scoped_allocator_adaptor(scoped_allocator_adaptor&& other) noexcept;55    template <class OuterA2>56        scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& other) noexcept;57    template <class OuterA2>58        scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2, InnerAllocs...>&& other) noexcept;59 60    scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default;61    scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default;62    ~scoped_allocator_adaptor();63 64    inner_allocator_type& inner_allocator() noexcept;65    const inner_allocator_type& inner_allocator() const noexcept;66 67    outer_allocator_type& outer_allocator() noexcept;68    const outer_allocator_type& outer_allocator() const noexcept;69 70    pointer allocate(size_type n);                           // [[nodiscard]] in C++2071    pointer allocate(size_type n, const_void_pointer hint);  // [[nodiscard]] in C++2072    void deallocate(pointer p, size_type n) noexcept;73 74    size_type max_size() const;75    template <class T, class... Args> void construct(T* p, Args&& args);76    template <class T1, class T2, class... Args1, class... Args2>77        void construct(pair<T1, T2>* p, piecewise_construct t, tuple<Args1...> x,78                       tuple<Args2...> y);79    template <class T1, class T2>80        void construct(pair<T1, T2>* p);81    template <class T1, class T2, class U, class V>82        void construct(pair<T1, T2>* p, U&& x, V&& y);83    template <class T1, class T2, class U, class V>84        void construct(pair<T1, T2>* p, const pair<U, V>& x);85    template <class T1, class T2, class U, class V>86        void construct(pair<T1, T2>* p, pair<U, V>&& x);87    template <class T> void destroy(T* p);88 89    template <class T> void destroy(T* p) noexcept;90 91    scoped_allocator_adaptor select_on_container_copy_construction() const noexcept;92};93 94template <class OuterA1, class OuterA2, class... InnerAllocs>95    bool96    operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,97               const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;98 99template <class OuterA1, class OuterA2, class... InnerAllocs>100    bool101    operator!=(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,102               const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;103 104}  // std105 106*/107 108#include <__config>109#include <memory>110#include <version>111 112#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)113#  pragma GCC system_header114#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)115#  pragma clang system_header116#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)117#  pragma system_header118#endif // no system header119 120_LIBCUDACXX_BEGIN_NAMESPACE_STD121 122// scoped_allocator_adaptor123 124template <class ..._Allocs>125class scoped_allocator_adaptor;126 127template <class ..._Allocs> struct __get_poc_copy_assignment;128 129template <class _A0>130struct __get_poc_copy_assignment<_A0>131{132    static const bool value = allocator_traits<_A0>::133                              propagate_on_container_copy_assignment::value;134};135 136template <class _A0, class ..._Allocs>137struct __get_poc_copy_assignment<_A0, _Allocs...>138{139    static const bool value =140        allocator_traits<_A0>::propagate_on_container_copy_assignment::value ||141        __get_poc_copy_assignment<_Allocs...>::value;142};143 144template <class ..._Allocs> struct __get_poc_move_assignment;145 146template <class _A0>147struct __get_poc_move_assignment<_A0>148{149    static const bool value = allocator_traits<_A0>::150                              propagate_on_container_move_assignment::value;151};152 153template <class _A0, class ..._Allocs>154struct __get_poc_move_assignment<_A0, _Allocs...>155{156    static const bool value =157        allocator_traits<_A0>::propagate_on_container_move_assignment::value ||158        __get_poc_move_assignment<_Allocs...>::value;159};160 161template <class ..._Allocs> struct __get_poc_swap;162 163template <class _A0>164struct __get_poc_swap<_A0>165{166    static const bool value = allocator_traits<_A0>::167                              propagate_on_container_swap::value;168};169 170template <class _A0, class ..._Allocs>171struct __get_poc_swap<_A0, _Allocs...>172{173    static const bool value =174        allocator_traits<_A0>::propagate_on_container_swap::value ||175        __get_poc_swap<_Allocs...>::value;176};177 178template <class ..._Allocs> struct __get_is_always_equal;179 180template <class _A0>181struct __get_is_always_equal<_A0>182{183    static const bool value = allocator_traits<_A0>::is_always_equal::value;184};185 186template <class _A0, class ..._Allocs>187struct __get_is_always_equal<_A0, _Allocs...>188{189    static const bool value =190        allocator_traits<_A0>::is_always_equal::value &&191        __get_is_always_equal<_Allocs...>::value;192};193 194template <class ..._Allocs>195class __scoped_allocator_storage;196 197template <class _OuterAlloc, class... _InnerAllocs>198class __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...>199    : public _OuterAlloc200{201    typedef _OuterAlloc outer_allocator_type;202protected:203    typedef scoped_allocator_adaptor<_InnerAllocs...> inner_allocator_type;204 205private:206    inner_allocator_type __inner_;207 208protected:209 210    _LIBCUDACXX_INLINE_VISIBILITY211    __scoped_allocator_storage() noexcept {}212 213    template <class _OuterA2,214              class = typename enable_if<215                        is_constructible<outer_allocator_type, _OuterA2>::value216                      >::type>217        _LIBCUDACXX_INLINE_VISIBILITY218        __scoped_allocator_storage(_OuterA2&& __outerAlloc,219                                   const _InnerAllocs& ...__innerAllocs) noexcept220            : outer_allocator_type(_CUDA_VSTD::forward<_OuterA2>(__outerAlloc)),221              __inner_(__innerAllocs...) {}222 223    template <class _OuterA2,224              class = typename enable_if<225                        is_constructible<outer_allocator_type, const _OuterA2&>::value226                      >::type>227        _LIBCUDACXX_INLINE_VISIBILITY228        __scoped_allocator_storage(229            const __scoped_allocator_storage<_OuterA2, _InnerAllocs...>& __other) noexcept230            : outer_allocator_type(__other.outer_allocator()),231              __inner_(__other.inner_allocator()) {}232 233    template <class _OuterA2,234              class = typename enable_if<235                        is_constructible<outer_allocator_type, _OuterA2>::value236                      >::type>237        _LIBCUDACXX_INLINE_VISIBILITY238        __scoped_allocator_storage(239            __scoped_allocator_storage<_OuterA2, _InnerAllocs...>&& __other) noexcept240            : outer_allocator_type(_CUDA_VSTD::move(__other.outer_allocator())),241              __inner_(_CUDA_VSTD::move(__other.inner_allocator())) {}242 243    template <class _OuterA2,244              class = typename enable_if<245                        is_constructible<outer_allocator_type, _OuterA2>::value246                      >::type>247        _LIBCUDACXX_INLINE_VISIBILITY248        __scoped_allocator_storage(_OuterA2&& __o,249                                   const inner_allocator_type& __i) noexcept250            : outer_allocator_type(_CUDA_VSTD::forward<_OuterA2>(__o)),251              __inner_(__i)252        {253        }254 255    _LIBCUDACXX_INLINE_VISIBILITY256    inner_allocator_type& inner_allocator() noexcept             {return __inner_;}257    _LIBCUDACXX_INLINE_VISIBILITY258    const inner_allocator_type& inner_allocator() const noexcept {return __inner_;}259 260    _LIBCUDACXX_INLINE_VISIBILITY261    outer_allocator_type& outer_allocator() noexcept262        {return static_cast<outer_allocator_type&>(*this);}263    _LIBCUDACXX_INLINE_VISIBILITY264    const outer_allocator_type& outer_allocator() const noexcept265        {return static_cast<const outer_allocator_type&>(*this);}266 267    scoped_allocator_adaptor<outer_allocator_type, _InnerAllocs...>268    _LIBCUDACXX_INLINE_VISIBILITY269    select_on_container_copy_construction() const noexcept270        {271            return scoped_allocator_adaptor<outer_allocator_type, _InnerAllocs...>272            (273                allocator_traits<outer_allocator_type>::274                    select_on_container_copy_construction(outer_allocator()),275                allocator_traits<inner_allocator_type>::276                    select_on_container_copy_construction(inner_allocator())277            );278        }279 280    template <class...> friend class __scoped_allocator_storage;281};282 283template <class _OuterAlloc>284class __scoped_allocator_storage<_OuterAlloc>285    : public _OuterAlloc286{287    typedef _OuterAlloc outer_allocator_type;288protected:289    typedef scoped_allocator_adaptor<_OuterAlloc> inner_allocator_type;290 291    _LIBCUDACXX_INLINE_VISIBILITY292    __scoped_allocator_storage() noexcept {}293 294    template <class _OuterA2,295              class = typename enable_if<296                        is_constructible<outer_allocator_type, _OuterA2>::value297                      >::type>298        _LIBCUDACXX_INLINE_VISIBILITY299        __scoped_allocator_storage(_OuterA2&& __outerAlloc) noexcept300            : outer_allocator_type(_CUDA_VSTD::forward<_OuterA2>(__outerAlloc)) {}301 302    template <class _OuterA2,303              class = typename enable_if<304                        is_constructible<outer_allocator_type, const _OuterA2&>::value305                      >::type>306        _LIBCUDACXX_INLINE_VISIBILITY307        __scoped_allocator_storage(308            const __scoped_allocator_storage<_OuterA2>& __other) noexcept309            : outer_allocator_type(__other.outer_allocator()) {}310 311    template <class _OuterA2,312              class = typename enable_if<313                        is_constructible<outer_allocator_type, _OuterA2>::value314                      >::type>315        _LIBCUDACXX_INLINE_VISIBILITY316        __scoped_allocator_storage(317            __scoped_allocator_storage<_OuterA2>&& __other) noexcept318            : outer_allocator_type(_CUDA_VSTD::move(__other.outer_allocator())) {}319 320    _LIBCUDACXX_INLINE_VISIBILITY321    inner_allocator_type& inner_allocator() noexcept322        {return static_cast<inner_allocator_type&>(*this);}323    _LIBCUDACXX_INLINE_VISIBILITY324    const inner_allocator_type& inner_allocator() const noexcept325        {return static_cast<const inner_allocator_type&>(*this);}326 327    _LIBCUDACXX_INLINE_VISIBILITY328    outer_allocator_type& outer_allocator() noexcept329        {return static_cast<outer_allocator_type&>(*this);}330    _LIBCUDACXX_INLINE_VISIBILITY331    const outer_allocator_type& outer_allocator() const noexcept332        {return static_cast<const outer_allocator_type&>(*this);}333 334    _LIBCUDACXX_INLINE_VISIBILITY335    scoped_allocator_adaptor<outer_allocator_type>336    select_on_container_copy_construction() const noexcept337        {return scoped_allocator_adaptor<outer_allocator_type>(338            allocator_traits<outer_allocator_type>::339                select_on_container_copy_construction(outer_allocator())340        );}341 342    __scoped_allocator_storage(const outer_allocator_type& __o,343                               const inner_allocator_type& __i) noexcept;344 345    template <class...> friend class __scoped_allocator_storage;346};347 348// __outermost349 350template <class _Alloc>351decltype(declval<_Alloc>().outer_allocator(), true_type())352__has_outer_allocator_test(_Alloc&& __a);353 354template <class _Alloc>355false_type356__has_outer_allocator_test(const volatile _Alloc& __a);357 358template <class _Alloc>359struct __has_outer_allocator360    : public common_type361             <362                 decltype(__has_outer_allocator_test(declval<_Alloc&>()))363             >::type364{365};366 367template <class _Alloc, bool = __has_outer_allocator<_Alloc>::value>368struct __outermost369{370    typedef _Alloc type;371    _LIBCUDACXX_INLINE_VISIBILITY372    type& operator()(type& __a) const noexcept {return __a;}373};374 375template <class _Alloc>376struct __outermost<_Alloc, true>377{378    typedef typename remove_reference379                     <380                        decltype(_CUDA_VSTD::declval<_Alloc>().outer_allocator())381                     >::type                                    _OuterAlloc;382    typedef typename __outermost<_OuterAlloc>::type             type;383    _LIBCUDACXX_INLINE_VISIBILITY384    type& operator()(_Alloc& __a) const noexcept385        {return __outermost<_OuterAlloc>()(__a.outer_allocator());}386};387 388template <class _OuterAlloc, class... _InnerAllocs>389class _LIBCUDACXX_TEMPLATE_VIS scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>390    : public __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...>391{392    typedef __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> base;393    typedef allocator_traits<_OuterAlloc>             _OuterTraits;394public:395    typedef _OuterAlloc                               outer_allocator_type;396    typedef typename base::inner_allocator_type       inner_allocator_type;397    typedef typename _OuterTraits::size_type          size_type;398    typedef typename _OuterTraits::difference_type    difference_type;399    typedef typename _OuterTraits::pointer            pointer;400    typedef typename _OuterTraits::const_pointer      const_pointer;401    typedef typename _OuterTraits::void_pointer       void_pointer;402    typedef typename _OuterTraits::const_void_pointer const_void_pointer;403 404    typedef integral_constant405            <406                bool,407                __get_poc_copy_assignment<outer_allocator_type,408                                          _InnerAllocs...>::value409            > propagate_on_container_copy_assignment;410    typedef integral_constant411            <412                bool,413                __get_poc_move_assignment<outer_allocator_type,414                                          _InnerAllocs...>::value415            > propagate_on_container_move_assignment;416    typedef integral_constant417            <418                bool,419                __get_poc_swap<outer_allocator_type, _InnerAllocs...>::value420            > propagate_on_container_swap;421    typedef integral_constant422            <423                bool,424                __get_is_always_equal<outer_allocator_type, _InnerAllocs...>::value425            > is_always_equal;426 427    template <class _Tp>428    struct rebind429    {430        typedef scoped_allocator_adaptor431        <432            typename _OuterTraits::template rebind_alloc<_Tp>, _InnerAllocs...433        > other;434    };435 436    _LIBCUDACXX_INLINE_VISIBILITY437    scoped_allocator_adaptor() noexcept {}438    template <class _OuterA2,439              class = typename enable_if<440                        is_constructible<outer_allocator_type, _OuterA2>::value441                      >::type>442        _LIBCUDACXX_INLINE_VISIBILITY443        scoped_allocator_adaptor(_OuterA2&& __outerAlloc,444                                 const _InnerAllocs& ...__innerAllocs) noexcept445            : base(_CUDA_VSTD::forward<_OuterA2>(__outerAlloc), __innerAllocs...) {}446    // scoped_allocator_adaptor(const scoped_allocator_adaptor& __other) = default;447    template <class _OuterA2,448              class = typename enable_if<449                        is_constructible<outer_allocator_type, const _OuterA2&>::value450                      >::type>451        _LIBCUDACXX_INLINE_VISIBILITY452        scoped_allocator_adaptor(453            const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __other) noexcept454                : base(__other) {}455    template <class _OuterA2,456              class = typename enable_if<457                        is_constructible<outer_allocator_type, _OuterA2>::value458                      >::type>459        _LIBCUDACXX_INLINE_VISIBILITY460        scoped_allocator_adaptor(461            scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>&& __other) noexcept462                : base(_CUDA_VSTD::move(__other)) {}463 464    // scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default;465    // scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default;466    // ~scoped_allocator_adaptor() = default;467 468    _LIBCUDACXX_INLINE_VISIBILITY469    inner_allocator_type& inner_allocator() noexcept470        {return base::inner_allocator();}471    _LIBCUDACXX_INLINE_VISIBILITY472    const inner_allocator_type& inner_allocator() const noexcept473        {return base::inner_allocator();}474 475    _LIBCUDACXX_INLINE_VISIBILITY476    outer_allocator_type& outer_allocator() noexcept477        {return base::outer_allocator();}478    _LIBCUDACXX_INLINE_VISIBILITY479    const outer_allocator_type& outer_allocator() const noexcept480        {return base::outer_allocator();}481 482    _LIBCUDACXX_NODISCARD_AFTER_CXX17 _LIBCUDACXX_INLINE_VISIBILITY483    pointer allocate(size_type __n)484        {return allocator_traits<outer_allocator_type>::485            allocate(outer_allocator(), __n);}486    _LIBCUDACXX_NODISCARD_AFTER_CXX17 _LIBCUDACXX_INLINE_VISIBILITY487    pointer allocate(size_type __n, const_void_pointer __hint)488        {return allocator_traits<outer_allocator_type>::489            allocate(outer_allocator(), __n, __hint);}490 491    _LIBCUDACXX_INLINE_VISIBILITY492    void deallocate(pointer __p, size_type __n) noexcept493        {allocator_traits<outer_allocator_type>::494            deallocate(outer_allocator(), __p, __n);}495 496    _LIBCUDACXX_INLINE_VISIBILITY497    size_type max_size() const498        {return allocator_traits<outer_allocator_type>::max_size(outer_allocator());}499 500    template <class _Tp, class... _Args>501        _LIBCUDACXX_INLINE_VISIBILITY502        void construct(_Tp* __p, _Args&& ...__args)503            {__construct(__uses_alloc_ctor<_Tp, inner_allocator_type&, _Args...>(),504                         __p, _CUDA_VSTD::forward<_Args>(__args)...);}505 506    template <class _T1, class _T2, class... _Args1, class... _Args2>507    void construct(pair<_T1, _T2>* __p, piecewise_construct_t,508                       tuple<_Args1...> __x, tuple<_Args2...> __y)509    {510        typedef __outermost<outer_allocator_type> _OM;511        allocator_traits<typename _OM::type>::construct(512            _OM()(outer_allocator()), __p, piecewise_construct513          , __transform_tuple(514              typename __uses_alloc_ctor<515                  _T1, inner_allocator_type&, _Args1...516              >::type()517            , _CUDA_VSTD::move(__x)518            , typename __make_tuple_indices<sizeof...(_Args1)>::type{}519          )520          , __transform_tuple(521              typename __uses_alloc_ctor<522                  _T2, inner_allocator_type&, _Args2...523              >::type()524            , _CUDA_VSTD::move(__y)525            , typename __make_tuple_indices<sizeof...(_Args2)>::type{}526          )527        );528    }529 530    template <class _T1, class _T2>531    void construct(pair<_T1, _T2>* __p)532    { construct(__p, piecewise_construct, tuple<>{}, tuple<>{}); }533 534    template <class _T1, class _T2, class _Up, class _Vp>535    void construct(pair<_T1, _T2>* __p, _Up&& __x, _Vp&& __y) {536        construct(__p, piecewise_construct,537                  _CUDA_VSTD::forward_as_tuple(_CUDA_VSTD::forward<_Up>(__x)),538                  _CUDA_VSTD::forward_as_tuple(_CUDA_VSTD::forward<_Vp>(__y)));539    }540 541    template <class _T1, class _T2, class _Up, class _Vp>542    void construct(pair<_T1, _T2>* __p, const pair<_Up, _Vp>& __x) {543        construct(__p, piecewise_construct,544                  _CUDA_VSTD::forward_as_tuple(__x.first),545                  _CUDA_VSTD::forward_as_tuple(__x.second));546    }547 548    template <class _T1, class _T2, class _Up, class _Vp>549    void construct(pair<_T1, _T2>* __p, pair<_Up, _Vp>&& __x) {550        construct(__p, piecewise_construct,551                  _CUDA_VSTD::forward_as_tuple(_CUDA_VSTD::forward<_Up>(__x.first)),552                  _CUDA_VSTD::forward_as_tuple(_CUDA_VSTD::forward<_Vp>(__x.second)));553    }554 555    template <class _Tp>556        _LIBCUDACXX_INLINE_VISIBILITY557        void destroy(_Tp* __p)558            {559                typedef __outermost<outer_allocator_type> _OM;560                allocator_traits<typename _OM::type>::561                                         destroy(_OM()(outer_allocator()), __p);562            }563 564    _LIBCUDACXX_INLINE_VISIBILITY565    scoped_allocator_adaptor select_on_container_copy_construction() const noexcept566        {return base::select_on_container_copy_construction();}567 568private:569 570 571    template <class _OuterA2,572              class = typename enable_if<573                        is_constructible<outer_allocator_type, _OuterA2>::value574                      >::type>575    _LIBCUDACXX_INLINE_VISIBILITY576    scoped_allocator_adaptor(_OuterA2&& __o,577                             const inner_allocator_type& __i) noexcept578        : base(_CUDA_VSTD::forward<_OuterA2>(__o), __i) {}579 580    template <class _Tp, class... _Args>581        _LIBCUDACXX_INLINE_VISIBILITY582        void __construct(integral_constant<int, 0>, _Tp* __p, _Args&& ...__args)583            {584                typedef __outermost<outer_allocator_type> _OM;585                allocator_traits<typename _OM::type>::construct586                (587                    _OM()(outer_allocator()),588                    __p,589                    _CUDA_VSTD::forward<_Args>(__args)...590                );591            }592 593    template <class _Tp, class... _Args>594        _LIBCUDACXX_INLINE_VISIBILITY595        void __construct(integral_constant<int, 1>, _Tp* __p, _Args&& ...__args)596            {597                typedef __outermost<outer_allocator_type> _OM;598                allocator_traits<typename _OM::type>::construct599                (600                    _OM()(outer_allocator()),601                    __p, allocator_arg, inner_allocator(),602                    _CUDA_VSTD::forward<_Args>(__args)...603                );604            }605 606    template <class _Tp, class... _Args>607        _LIBCUDACXX_INLINE_VISIBILITY608        void __construct(integral_constant<int, 2>, _Tp* __p, _Args&& ...__args)609            {610                typedef __outermost<outer_allocator_type> _OM;611                allocator_traits<typename _OM::type>::construct612                (613                    _OM()(outer_allocator()),614                    __p,615                    _CUDA_VSTD::forward<_Args>(__args)...,616                    inner_allocator()617                );618            }619 620    template <class ..._Args, size_t ..._Idx>621    _LIBCUDACXX_INLINE_VISIBILITY622    tuple<_Args&&...>623    __transform_tuple(integral_constant<int, 0>, tuple<_Args...>&& __t,624                      __tuple_indices<_Idx...>)625    {626        return _CUDA_VSTD::forward_as_tuple(_CUDA_VSTD::get<_Idx>(_CUDA_VSTD::move(__t))...);627    }628 629    template <class ..._Args, size_t ..._Idx>630    _LIBCUDACXX_INLINE_VISIBILITY631    tuple<allocator_arg_t, inner_allocator_type&, _Args&&...>632    __transform_tuple(integral_constant<int, 1>, tuple<_Args...> && __t,633                      __tuple_indices<_Idx...>)634    {635        using _Tup = tuple<allocator_arg_t, inner_allocator_type&, _Args&&...>;636        return _Tup(allocator_arg, inner_allocator(),637                    _CUDA_VSTD::get<_Idx>(_CUDA_VSTD::move(__t))...);638    }639 640    template <class ..._Args, size_t ..._Idx>641    _LIBCUDACXX_INLINE_VISIBILITY642    tuple<_Args&&..., inner_allocator_type&>643    __transform_tuple(integral_constant<int, 2>, tuple<_Args...> && __t,644                      __tuple_indices<_Idx...>)645    {646        using _Tup = tuple<_Args&&..., inner_allocator_type&>;647        return _Tup(_CUDA_VSTD::get<_Idx>(_CUDA_VSTD::move(__t))..., inner_allocator());648    }649 650    template <class...> friend class __scoped_allocator_storage;651};652 653template <class _OuterA1, class _OuterA2>654inline _LIBCUDACXX_INLINE_VISIBILITY655bool656operator==(const scoped_allocator_adaptor<_OuterA1>& __a,657           const scoped_allocator_adaptor<_OuterA2>& __b) noexcept658{659    return __a.outer_allocator() == __b.outer_allocator();660}661 662template <class _OuterA1, class _OuterA2, class _InnerA0, class... _InnerAllocs>663inline _LIBCUDACXX_INLINE_VISIBILITY664bool665operator==(const scoped_allocator_adaptor<_OuterA1, _InnerA0, _InnerAllocs...>& __a,666           const scoped_allocator_adaptor<_OuterA2, _InnerA0, _InnerAllocs...>& __b) noexcept667{668    return __a.outer_allocator() == __b.outer_allocator() &&669           __a.inner_allocator() == __b.inner_allocator();670}671 672template <class _OuterA1, class _OuterA2, class... _InnerAllocs>673inline _LIBCUDACXX_INLINE_VISIBILITY674bool675operator!=(const scoped_allocator_adaptor<_OuterA1, _InnerAllocs...>& __a,676           const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __b) noexcept677{678    return !(__a == __b);679}680 681_LIBCUDACXX_END_NAMESPACE_STD682 683#endif  // _LIBCUDACXX_SCOPED_ALLOCATOR684 
codekingpro/portable-devtools · Team Ai