diff libcxx/include/scoped_allocator @ 236:c4bab56944e8 llvm-original

LLVM 16
author kono
date Wed, 09 Nov 2022 17:45:10 +0900
parents 5f17cb93ff66
children 1f2b6ac9f198
line wrap: on
line diff
--- a/libcxx/include/scoped_allocator	Wed Jul 21 10:27:27 2021 +0900
+++ b/libcxx/include/scoped_allocator	Wed Nov 09 17:45:10 2022 +0900
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-//===-------------------------- scoped_allocator --------------------------===//
+//===----------------------------------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -91,6 +91,10 @@
     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,
@@ -105,13 +109,24 @@
 
 */
 
+#include <__assert> // all public C++ headers provide the assertion handler
 #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/forward.h>
-#include <memory>
+#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
+#  pragma GCC system_header
 #endif
 
 _LIBCPP_BEGIN_NAMESPACE_STD
@@ -214,10 +229,10 @@
                         is_constructible<outer_allocator_type, _OuterA2>::value
                       >::type>
         _LIBCPP_INLINE_VISIBILITY
-        __scoped_allocator_storage(_OuterA2&& __outerAlloc,
-                                   const _InnerAllocs& ...__innerAllocs) _NOEXCEPT
-            : outer_allocator_type(_VSTD::forward<_OuterA2>(__outerAlloc)),
-              __inner_(__innerAllocs...) {}
+        __scoped_allocator_storage(_OuterA2&& __outer_alloc,
+                                   const _InnerAllocs& ...__inner_allocs) _NOEXCEPT
+            : outer_allocator_type(_VSTD::forward<_OuterA2>(__outer_alloc)),
+              __inner_(__inner_allocs...) {}
 
     template <class _OuterA2,
               class = typename enable_if<
@@ -295,8 +310,8 @@
                         is_constructible<outer_allocator_type, _OuterA2>::value
                       >::type>
         _LIBCPP_INLINE_VISIBILITY
-        __scoped_allocator_storage(_OuterA2&& __outerAlloc) _NOEXCEPT
-            : outer_allocator_type(_VSTD::forward<_OuterA2>(__outerAlloc)) {}
+        __scoped_allocator_storage(_OuterA2&& __outer_alloc) _NOEXCEPT
+            : outer_allocator_type(_VSTD::forward<_OuterA2>(__outer_alloc)) {}
 
     template <class _OuterA2,
               class = typename enable_if<
@@ -374,10 +389,10 @@
 template <class _Alloc>
 struct __outermost<_Alloc, true>
 {
-    typedef typename remove_reference
+    typedef __libcpp_remove_reference_t
                      <
                         decltype(declval<_Alloc>().outer_allocator())
-                     >::type                                    _OuterAlloc;
+                     >                                    _OuterAlloc;
     typedef typename __outermost<_OuterAlloc>::type             type;
     _LIBCPP_INLINE_VISIBILITY
     type& operator()(_Alloc& __a) const _NOEXCEPT
@@ -439,9 +454,9 @@
                         is_constructible<outer_allocator_type, _OuterA2>::value
                       >::type>
         _LIBCPP_INLINE_VISIBILITY
-        scoped_allocator_adaptor(_OuterA2&& __outerAlloc,
-                                 const _InnerAllocs& ...__innerAllocs) _NOEXCEPT
-            : base(_VSTD::forward<_OuterA2>(__outerAlloc), __innerAllocs...) {}
+        scoped_allocator_adaptor(_OuterA2&& __outer_alloc,
+                                 const _InnerAllocs& ...__inner_allocs) _NOEXCEPT
+            : base(_VSTD::forward<_OuterA2>(__outer_alloc), __inner_allocs...) {}
     // scoped_allocator_adaptor(const scoped_allocator_adaptor& __other) = default;
     template <class _OuterA2,
               class = typename enable_if<
@@ -496,6 +511,18 @@
     size_type max_size() const
         {return allocator_traits<outer_allocator_type>::max_size(outer_allocator());}
 
+#if _LIBCPP_STD_VER >= 20
+    template <class _Type, class... _Args>
+    _LIBCPP_HIDE_FROM_ABI void construct(_Type* __ptr, _Args&&... __args) {
+      using _OM = __outermost<outer_allocator_type>;
+      std::apply(
+          [__ptr, this](auto&&... __newargs) {
+            allocator_traits<typename _OM::type>::construct(
+                _OM()(outer_allocator()), __ptr, std::forward<decltype(__newargs)>(__newargs)...);
+          },
+          std::uses_allocator_construction_args<_Type>(inner_allocator(), std::forward<_Args>(__args)...));
+    }
+#else
     template <class _Tp, class... _Args>
         _LIBCPP_INLINE_VISIBILITY
         void construct(_Tp* __p, _Args&& ...__args)
@@ -550,6 +577,7 @@
                   _VSTD::forward_as_tuple(_VSTD::forward<_Up>(__x.first)),
                   _VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__x.second)));
     }
+#endif
 
     template <class _Tp>
         _LIBCPP_INLINE_VISIBILITY
@@ -649,6 +677,12 @@
     template <class...> friend class __scoped_allocator_storage;
 };
 
+#if _LIBCPP_STD_VER > 14
+template<class _OuterAlloc, class... _InnerAllocs>
+    scoped_allocator_adaptor(_OuterAlloc, _InnerAllocs...)
+        -> scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>;
+#endif
+
 template <class _OuterA1, class _OuterA2>
 inline _LIBCPP_INLINE_VISIBILITY
 bool
@@ -681,4 +715,17 @@
 
 _LIBCPP_END_NAMESPACE_STD
 
+#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 <variant>
+#endif
+
 #endif // _LIBCPP_SCOPED_ALLOCATOR