mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-01 10:12:27 +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
117
third_party/libcxx/stack
vendored
117
third_party/libcxx/stack
vendored
|
@ -1,5 +1,5 @@
|
|||
// -*- C++ -*-
|
||||
//===---------------------------- stack -----------------------------------===//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
|
@ -10,15 +10,6 @@
|
|||
#ifndef _LIBCPP_STACK
|
||||
#define _LIBCPP_STACK
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "third_party/libcxx/deque"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
/*
|
||||
stack synopsis
|
||||
|
||||
|
@ -50,11 +41,14 @@ public:
|
|||
|
||||
explicit stack(const container_type& c);
|
||||
explicit stack(container_type&& c);
|
||||
template <class InputIterator> stack(InputIterator first, InputIterator last); // since C++23
|
||||
template <class Alloc> explicit stack(const Alloc& a);
|
||||
template <class Alloc> stack(const container_type& c, const Alloc& a);
|
||||
template <class Alloc> stack(container_type&& c, const Alloc& a);
|
||||
template <class Alloc> stack(const stack& c, const Alloc& a);
|
||||
template <class Alloc> stack(stack&& c, const Alloc& a);
|
||||
template<class InputIterator, class Alloc>
|
||||
stack(InputIterator first, InputIterator last, const Alloc&); // since C++23
|
||||
|
||||
bool empty() const;
|
||||
size_type size() const;
|
||||
|
@ -72,9 +66,17 @@ public:
|
|||
template<class Container>
|
||||
stack(Container) -> stack<typename Container::value_type, Container>; // C++17
|
||||
|
||||
template<class InputIterator>
|
||||
stack(InputIterator, InputIterator) -> stack<iter-value-type<InputIterator>>; // since C++23
|
||||
|
||||
template<class Container, class Allocator>
|
||||
stack(Container, Allocator) -> stack<typename Container::value_type, Container>; // C++17
|
||||
|
||||
template<class InputIterator, class Allocator>
|
||||
stack(InputIterator, InputIterator, Allocator)
|
||||
-> stack<iter-value-type<InputIterator>,
|
||||
deque<iter-value-type<InputIterator>, Allocator>>; // since C++23
|
||||
|
||||
template <class T, class Container>
|
||||
bool operator==(const stack<T, Container>& x, const stack<T, Container>& y);
|
||||
template <class T, class Container>
|
||||
|
@ -96,6 +98,27 @@ template <class T, class Container>
|
|||
|
||||
*/
|
||||
|
||||
#include <__assert> // all public C++ headers provide the assertion handler
|
||||
#include <__config>
|
||||
#include <__iterator/iterator_traits.h>
|
||||
#include <__memory/uses_allocator.h>
|
||||
#include <__type_traits/is_same.h>
|
||||
#include <__utility/forward.h>
|
||||
#include <deque>
|
||||
#include <version>
|
||||
|
||||
// standard-mandated includes
|
||||
|
||||
// [stack.syn]
|
||||
#include <compare>
|
||||
#include <initializer_list>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS stack;
|
||||
|
||||
template <class _Tp, class _Container>
|
||||
|
@ -148,7 +171,7 @@ public:
|
|||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit stack(container_type&& __c) : c(_VSTD::move(__c)) {}
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit stack(const container_type& __c) : c(__c) {}
|
||||
|
@ -156,35 +179,44 @@ public:
|
|||
template <class _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit stack(const _Alloc& __a,
|
||||
typename enable_if<uses_allocator<container_type,
|
||||
_Alloc>::value>::type* = 0)
|
||||
__enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
|
||||
: c(__a) {}
|
||||
template <class _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
stack(const container_type& __c, const _Alloc& __a,
|
||||
typename enable_if<uses_allocator<container_type,
|
||||
_Alloc>::value>::type* = 0)
|
||||
__enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
|
||||
: c(__c, __a) {}
|
||||
template <class _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
stack(const stack& __s, const _Alloc& __a,
|
||||
typename enable_if<uses_allocator<container_type,
|
||||
_Alloc>::value>::type* = 0)
|
||||
__enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
|
||||
: c(__s.c, __a) {}
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
stack(container_type&& __c, const _Alloc& __a,
|
||||
typename enable_if<uses_allocator<container_type,
|
||||
_Alloc>::value>::type* = 0)
|
||||
__enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
|
||||
: c(_VSTD::move(__c), __a) {}
|
||||
template <class _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
stack(stack&& __s, const _Alloc& __a,
|
||||
typename enable_if<uses_allocator<container_type,
|
||||
_Alloc>::value>::type* = 0)
|
||||
__enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
|
||||
: c(_VSTD::move(__s.c), __a) {}
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
#if _LIBCPP_STD_VER >= 23
|
||||
template <class _InputIterator,
|
||||
class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>>
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
stack(_InputIterator __first, _InputIterator __last) : c(__first, __last) {}
|
||||
|
||||
template <class _InputIterator,
|
||||
class _Alloc,
|
||||
class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
|
||||
class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>>
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
stack(_InputIterator __first, _InputIterator __last, const _Alloc& __alloc) : c(__first, __last, __alloc) {}
|
||||
#endif
|
||||
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const {return c.empty();}
|
||||
|
@ -203,14 +235,14 @@ public:
|
|||
|
||||
template <class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
#if _LIBCPP_STD_VER >= 17
|
||||
decltype(auto) emplace(_Args&&... __args)
|
||||
{ return c.emplace_back(_VSTD::forward<_Args>(__args)...);}
|
||||
#else
|
||||
void emplace(_Args&&... __args)
|
||||
{ c.emplace_back(_VSTD::forward<_Args>(__args)...);}
|
||||
#endif
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void pop() {c.pop_back();}
|
||||
|
@ -223,6 +255,8 @@ public:
|
|||
swap(c, __s.c);
|
||||
}
|
||||
|
||||
_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
|
||||
|
||||
template <class T1, class _C1>
|
||||
friend
|
||||
bool
|
||||
|
@ -234,22 +268,36 @@ public:
|
|||
operator< (const stack<T1, _C1>& __x, const stack<T1, _C1>& __y);
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
|
||||
#if _LIBCPP_STD_VER >= 17
|
||||
template<class _Container,
|
||||
class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
|
||||
class = enable_if_t<!__is_allocator<_Container>::value>
|
||||
>
|
||||
stack(_Container)
|
||||
-> stack<typename _Container::value_type, _Container>;
|
||||
|
||||
template<class _Container,
|
||||
class _Alloc,
|
||||
class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type,
|
||||
class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type
|
||||
class = enable_if_t<!__is_allocator<_Container>::value>,
|
||||
class = enable_if_t<uses_allocator<_Container, _Alloc>::value>
|
||||
>
|
||||
stack(_Container, _Alloc)
|
||||
-> stack<typename _Container::value_type, _Container>;
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_STD_VER >= 23
|
||||
template<class _InputIterator,
|
||||
class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>>
|
||||
stack(_InputIterator, _InputIterator)
|
||||
-> stack<__iter_value_type<_InputIterator>>;
|
||||
|
||||
template<class _InputIterator,
|
||||
class _Alloc,
|
||||
class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
|
||||
class = __enable_if_t<__is_allocator<_Alloc>::value>>
|
||||
stack(_InputIterator, _InputIterator, _Alloc)
|
||||
-> stack<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>;
|
||||
#endif
|
||||
|
||||
template <class _Tp, class _Container>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
|
@ -300,10 +348,7 @@ operator<=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
|
|||
|
||||
template <class _Tp, class _Container>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<
|
||||
__is_swappable<_Container>::value,
|
||||
void
|
||||
>::type
|
||||
__enable_if_t<__is_swappable<_Container>::value, void>
|
||||
swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y)
|
||||
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
|
||||
{
|
||||
|
@ -318,4 +363,10 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator<stack<_Tp, _Container>, _Alloc>
|
|||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_STACK
|
||||
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
|
||||
# include <concepts>
|
||||
# include <functional>
|
||||
# include <type_traits>
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_STACK
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue