mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-25 14:52:28 +00:00
Upgrade to 2022-era LLVM LIBCXX
This commit is contained in:
parent
2f4ca71f26
commit
8e68384e15
2078 changed files with 165657 additions and 65010 deletions
102
third_party/libcxx/scoped_allocator
vendored
102
third_party/libcxx/scoped_allocator
vendored
|
@ -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 @@ public:
|
|||
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,12 +109,25 @@ template <class OuterA1, class OuterA2, class... InnerAllocs>
|
|||
|
||||
*/
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "third_party/libcxx/memory"
|
||||
#include "third_party/libcxx/version"
|
||||
#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/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
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
@ -213,10 +230,10 @@ protected:
|
|||
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<
|
||||
|
@ -294,8 +311,8 @@ protected:
|
|||
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<
|
||||
|
@ -346,7 +363,7 @@ protected:
|
|||
// __outermost
|
||||
|
||||
template <class _Alloc>
|
||||
decltype(declval<_Alloc>().outer_allocator(), true_type())
|
||||
decltype(std::declval<_Alloc>().outer_allocator(), true_type())
|
||||
__has_outer_allocator_test(_Alloc&& __a);
|
||||
|
||||
template <class _Alloc>
|
||||
|
@ -357,7 +374,7 @@ template <class _Alloc>
|
|||
struct __has_outer_allocator
|
||||
: public common_type
|
||||
<
|
||||
decltype(__has_outer_allocator_test(declval<_Alloc&>()))
|
||||
decltype(std::__has_outer_allocator_test(std::declval<_Alloc&>()))
|
||||
>::type
|
||||
{
|
||||
};
|
||||
|
@ -373,10 +390,10 @@ struct __outermost
|
|||
template <class _Alloc>
|
||||
struct __outermost<_Alloc, true>
|
||||
{
|
||||
typedef typename remove_reference
|
||||
typedef __libcpp_remove_reference_t
|
||||
<
|
||||
decltype(_VSTD::declval<_Alloc>().outer_allocator())
|
||||
>::type _OuterAlloc;
|
||||
decltype(std::declval<_Alloc>().outer_allocator())
|
||||
> _OuterAlloc;
|
||||
typedef typename __outermost<_OuterAlloc>::type type;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
type& operator()(_Alloc& __a) const _NOEXCEPT
|
||||
|
@ -438,9 +455,9 @@ public:
|
|||
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<
|
||||
|
@ -495,6 +512,18 @@ public:
|
|||
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)
|
||||
|
@ -502,7 +531,7 @@ public:
|
|||
__p, _VSTD::forward<_Args>(__args)...);}
|
||||
|
||||
template <class _T1, class _T2, class... _Args1, class... _Args2>
|
||||
void construct(pair<_T1, _T2>* __p, piecewise_construct_t,
|
||||
_LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, piecewise_construct_t,
|
||||
tuple<_Args1...> __x, tuple<_Args2...> __y)
|
||||
{
|
||||
typedef __outermost<outer_allocator_type> _OM;
|
||||
|
@ -526,29 +555,30 @@ public:
|
|||
}
|
||||
|
||||
template <class _T1, class _T2>
|
||||
void construct(pair<_T1, _T2>* __p)
|
||||
_LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p)
|
||||
{ construct(__p, piecewise_construct, tuple<>{}, tuple<>{}); }
|
||||
|
||||
template <class _T1, class _T2, class _Up, class _Vp>
|
||||
void construct(pair<_T1, _T2>* __p, _Up&& __x, _Vp&& __y) {
|
||||
_LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, _Up&& __x, _Vp&& __y) {
|
||||
construct(__p, piecewise_construct,
|
||||
_VSTD::forward_as_tuple(_VSTD::forward<_Up>(__x)),
|
||||
_VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__y)));
|
||||
}
|
||||
|
||||
template <class _T1, class _T2, class _Up, class _Vp>
|
||||
void construct(pair<_T1, _T2>* __p, const pair<_Up, _Vp>& __x) {
|
||||
_LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, const pair<_Up, _Vp>& __x) {
|
||||
construct(__p, piecewise_construct,
|
||||
_VSTD::forward_as_tuple(__x.first),
|
||||
_VSTD::forward_as_tuple(__x.second));
|
||||
}
|
||||
|
||||
template <class _T1, class _T2, class _Up, class _Vp>
|
||||
void construct(pair<_T1, _T2>* __p, pair<_Up, _Vp>&& __x) {
|
||||
_LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, pair<_Up, _Vp>&& __x) {
|
||||
construct(__p, piecewise_construct,
|
||||
_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
|
||||
|
@ -648,6 +678,12 @@ private:
|
|||
template <class...> friend class __scoped_allocator_storage;
|
||||
};
|
||||
|
||||
#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_INLINE_VISIBILITY
|
||||
bool
|
||||
|
@ -676,8 +712,22 @@ operator!=(const scoped_allocator_adaptor<_OuterA1, _InnerAllocs...>& __a,
|
|||
return !(__a == __b);
|
||||
}
|
||||
|
||||
#endif // !defined(_LIBCPP_CXX03_LANG)
|
||||
#endif // !defined(_LIBCPP_CXX03_LANG)
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_SCOPED_ALLOCATOR
|
||||
#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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue