// -*- C++ -*- //===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef _LIBCPP_SCOPED_ALLOCATOR #define _LIBCPP_SCOPED_ALLOCATOR /* scoped_allocator synopsis namespace std { template <class OuterAlloc, class... InnerAllocs> class scoped_allocator_adaptor : public OuterAlloc { typedef allocator_traits<OuterAlloc> OuterTraits; // exposition only scoped_allocator_adaptor<InnerAllocs...> inner; // exposition only public: typedef OuterAlloc outer_allocator_type; typedef see below inner_allocator_type; typedef typename OuterTraits::value_type value_type; typedef typename OuterTraits::size_type size_type; typedef typename OuterTraits::difference_type difference_type; typedef typename OuterTraits::pointer pointer; typedef typename OuterTraits::const_pointer const_pointer; typedef typename OuterTraits::void_pointer void_pointer; typedef typename OuterTraits::const_void_pointer const_void_pointer; typedef see below propagate_on_container_copy_assignment; typedef see below propagate_on_container_move_assignment; typedef see below propagate_on_container_swap; typedef see below is_always_equal; template <class Tp> struct rebind { typedef scoped_allocator_adaptor< OuterTraits::template rebind_alloc<Tp>, InnerAllocs...> other; }; scoped_allocator_adaptor(); template <class OuterA2> scoped_allocator_adaptor(OuterA2&& outerAlloc, const InnerAllocs&... innerAllocs) noexcept; scoped_allocator_adaptor(const scoped_allocator_adaptor& other) noexcept; scoped_allocator_adaptor(scoped_allocator_adaptor&& other) noexcept; template <class OuterA2> scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& other) noexcept; template <class OuterA2> scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2, InnerAllocs...>&& other) noexcept; scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default; scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default; ~scoped_allocator_adaptor(); inner_allocator_type& inner_allocator() noexcept; const inner_allocator_type& inner_allocator() const noexcept; outer_allocator_type& outer_allocator() noexcept; const outer_allocator_type& outer_allocator() const noexcept; pointer allocate(size_type n); // [[nodiscard]] in C++20 pointer allocate(size_type n, const_void_pointer hint); // [[nodiscard]] in C++20 void deallocate(pointer p, size_type n) noexcept; size_type max_size() const; template <class T, class... Args> void construct(T* p, Args&& args); template <class T1, class T2, class... Args1, class... Args2> void construct(pair<T1, T2>* p, piecewise_construct t, tuple<Args1...> x, tuple<Args2...> y); template <class T1, class T2> void construct(pair<T1, T2>* p); template <class T1, class T2, class U, class V> void construct(pair<T1, T2>* p, U&& x, V&& y); template <class T1, class T2, class U, class V> void construct(pair<T1, T2>* p, const pair<U, V>& x); template <class T1, class T2, class U, class V> void construct(pair<T1, T2>* p, pair<U, V>&& x); template <class T> void destroy(T* p); template <class T> void destroy(T* p) noexcept; scoped_allocator_adaptor select_on_container_copy_construction() const noexcept; }; template<class OuterAlloc, class... InnerAllocs> scoped_allocator_adaptor(OuterAlloc, InnerAllocs...) -> scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>; template <class OuterA1, class OuterA2, class... InnerAllocs> bool operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a, const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept; template <class OuterA1, class OuterA2, class... InnerAllocs> bool operator!=(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a, const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept; // removed in C++20 } // std */ #include <__config> #include <__memory/allocator_traits.h> #include <__memory/uses_allocator_construction.h> #include <__type_traits/common_type.h> #include <__type_traits/enable_if.h> #include <__type_traits/integral_constant.h> #include <__type_traits/is_constructible.h> #include <__type_traits/remove_reference.h> #include <__utility/declval.h> #include <__utility/forward.h> #include <__utility/move.h> #include <__utility/pair.h> #include <__utility/piecewise_construct.h> #include <tuple> #include <version> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif _LIBCPP_PUSH_MACROS #include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD #if !defined(_LIBCPP_CXX03_LANG) // scoped_allocator_adaptor template <class... _Allocs> class scoped_allocator_adaptor; template <class... _Allocs> struct __get_poc_copy_assignment; __get_poc_copy_assignment<_A0>; __get_poc_copy_assignment<_A0, _Allocs...>; template <class... _Allocs> struct __get_poc_move_assignment; __get_poc_move_assignment<_A0>; __get_poc_move_assignment<_A0, _Allocs...>; template <class... _Allocs> struct __get_poc_swap; __get_poc_swap<_A0>; __get_poc_swap<_A0, _Allocs...>; template <class... _Allocs> struct __get_is_always_equal; __get_is_always_equal<_A0>; __get_is_always_equal<_A0, _Allocs...>; template <class... _Allocs> class __scoped_allocator_storage; __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...>; __scoped_allocator_storage<_OuterAlloc>; // __outermost template <class _Alloc> decltype(std::declval<_Alloc>().outer_allocator(), true_type()) __has_outer_allocator_test(_Alloc&& __a); template <class _Alloc> false_type __has_outer_allocator_test(const volatile _Alloc& __a); template <class _Alloc> struct __has_outer_allocator : public common_type< decltype(std::__has_outer_allocator_test(std::declval<_Alloc&>()))>::type { … }; template <class _Alloc, bool = __has_outer_allocator<_Alloc>::value> struct __outermost { … }; __outermost<_Alloc, true>; scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>; # if _LIBCPP_STD_VER >= 17 template <class _OuterAlloc, class... _InnerAllocs> scoped_allocator_adaptor(_OuterAlloc, _InnerAllocs...) -> scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>; # endif template <class _OuterA1, class _OuterA2> inline _LIBCPP_HIDE_FROM_ABI bool operator==(const scoped_allocator_adaptor<_OuterA1>& __a, const scoped_allocator_adaptor<_OuterA2>& __b) _NOEXCEPT { … } template <class _OuterA1, class _OuterA2, class _InnerA0, class... _InnerAllocs> inline _LIBCPP_HIDE_FROM_ABI bool operator==(const scoped_allocator_adaptor<_OuterA1, _InnerA0, _InnerAllocs...>& __a, const scoped_allocator_adaptor<_OuterA2, _InnerA0, _InnerAllocs...>& __b) _NOEXCEPT { … } # if _LIBCPP_STD_VER <= 17 template <class _OuterA1, class _OuterA2, class... _InnerAllocs> inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const scoped_allocator_adaptor<_OuterA1, _InnerAllocs...>& __a, const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __b) _NOEXCEPT { return !(__a == __b); } # endif // _LIBCPP_STD_VER <= 17 #endif // !defined(_LIBCPP_CXX03_LANG) _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include <atomic> # include <climits> # include <concepts> # include <cstring> # include <ctime> # include <iterator> # include <memory> # include <ratio> # include <stdexcept> # include <type_traits> # include <variant> #endif #endif // _LIBCPP_SCOPED_ALLOCATOR