Upgrade to 2022-era LLVM LIBCXX

This commit is contained in:
Justine Tunney 2024-05-27 02:12:27 -07:00
parent 2f4ca71f26
commit 8e68384e15
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
2078 changed files with 165657 additions and 65010 deletions

View file

@ -1,5 +1,5 @@
// -*- C++ -*-
//===----------------------- forward_list ---------------------------------===//
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@ -146,51 +146,95 @@ template <class T, class Allocator>
template <class T, class Allocator>
bool operator< (const forward_list<T, Allocator>& x,
const forward_list<T, Allocator>& y);
const forward_list<T, Allocator>& y); // removed in C++20
template <class T, class Allocator>
bool operator!=(const forward_list<T, Allocator>& x,
const forward_list<T, Allocator>& y);
const forward_list<T, Allocator>& y); // removed in C++20
template <class T, class Allocator>
bool operator> (const forward_list<T, Allocator>& x,
const forward_list<T, Allocator>& y);
const forward_list<T, Allocator>& y); // removed in C++20
template <class T, class Allocator>
bool operator>=(const forward_list<T, Allocator>& x,
const forward_list<T, Allocator>& y);
const forward_list<T, Allocator>& y); // removed in C++20
template <class T, class Allocator>
bool operator<=(const forward_list<T, Allocator>& x,
const forward_list<T, Allocator>& y);
const forward_list<T, Allocator>& y); // removed in C++20
template<class T, class Allocator>
synth-three-way-result<T> operator<=>(const forward_list<T, Allocator>& x,
const forward_list<T, Allocator>& y); // since C++20
template <class T, class Allocator>
void swap(forward_list<T, Allocator>& x, forward_list<T, Allocator>& y)
noexcept(noexcept(x.swap(y)));
template <class T, class Allocator, class U>
void erase(forward_list<T, Allocator>& c, const U& value); // C++20
typename forward_list<T, Allocator>::size_type
erase(forward_list<T, Allocator>& c, const U& value); // C++20
template <class T, class Allocator, class Predicate>
void erase_if(forward_list<T, Allocator>& c, Predicate pred); // C++20
typename forward_list<T, Allocator>::size_type
erase_if(forward_list<T, Allocator>& c, Predicate pred); // C++20
} // std
*/
#include "third_party/libcxx/__config"
#include "third_party/libcxx/initializer_list"
#include "third_party/libcxx/memory"
#include "third_party/libcxx/limits"
#include "third_party/libcxx/iterator"
#include "third_party/libcxx/algorithm"
#include "third_party/libcxx/version"
#include <__algorithm/comp.h>
#include <__algorithm/lexicographical_compare.h>
#include <__algorithm/lexicographical_compare_three_way.h>
#include <__algorithm/min.h>
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/move_iterator.h>
#include <__iterator/next.h>
#include <__memory/addressof.h>
#include <__memory/allocator.h>
#include <__memory/allocator_destructor.h>
#include <__memory/allocator_traits.h>
#include <__memory/compressed_pair.h>
#include <__memory/pointer_traits.h>
#include <__memory/swap_allocator.h>
#include <__memory/unique_ptr.h>
#include <__memory_resource/polymorphic_allocator.h>
#include <__type_traits/conditional.h>
#include <__type_traits/is_allocator.h>
#include <__type_traits/is_const.h>
#include <__type_traits/is_nothrow_default_constructible.h>
#include <__type_traits/is_nothrow_move_assignable.h>
#include <__type_traits/is_nothrow_move_constructible.h>
#include <__type_traits/is_pointer.h>
#include <__type_traits/is_same.h>
#include <__type_traits/type_identity.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <limits>
#include <version>
// standard-mandated includes
// [iterator.range]
#include <__iterator/access.h>
#include <__iterator/data.h>
#include <__iterator/empty.h>
#include <__iterator/reverse_access.h>
#include <__iterator/size.h>
// [forward.list.syn]
#include <compare>
#include <initializer_list>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
# pragma GCC system_header
#endif
_LIBCPP_PUSH_MACROS
#include "third_party/libcxx/__undef_macros"
#include <__undef_macros>
_LIBCPP_BEGIN_NAMESPACE_STD
@ -210,30 +254,23 @@ struct __forward_list_node_value_type<__forward_list_node<_Tp, _VoidPtr> > {
template <class _NodePtr>
struct __forward_node_traits {
typedef typename remove_cv<
typename pointer_traits<_NodePtr>::element_type>::type __node;
typedef __remove_cv_t<
typename pointer_traits<_NodePtr>::element_type> __node;
typedef typename __forward_list_node_value_type<__node>::type __node_value_type;
typedef _NodePtr __node_pointer;
typedef __forward_begin_node<_NodePtr> __begin_node;
typedef typename __rebind_pointer<_NodePtr, __begin_node>::type
__begin_node_pointer;
typedef typename __rebind_pointer<_NodePtr, void>::type __void_pointer;
typedef __rebind_pointer_t<_NodePtr, __begin_node> __begin_node_pointer;
typedef __rebind_pointer_t<_NodePtr, void> __void_pointer;
#if defined(_LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB)
typedef __begin_node_pointer __iter_node_pointer;
#else
typedef typename conditional<
is_pointer<__void_pointer>::value,
__begin_node_pointer,
__node_pointer
>::type __iter_node_pointer;
typedef __conditional_t<is_pointer<__void_pointer>::value, __begin_node_pointer, __node_pointer>
__iter_node_pointer;
#endif
typedef typename conditional<
is_same<__iter_node_pointer, __node_pointer>::value,
__begin_node_pointer,
__node_pointer
>::type __non_iter_node_pointer;
typedef __conditional_t<is_same<__iter_node_pointer, __node_pointer>::value, __begin_node_pointer, __node_pointer>
__non_iter_node_pointer;
_LIBCPP_INLINE_VISIBILITY
static __iter_node_pointer __as_iter_node(__iter_node_pointer __p) {
@ -249,7 +286,7 @@ template <class _NodePtr>
struct __forward_begin_node
{
typedef _NodePtr pointer;
typedef typename __rebind_pointer<_NodePtr, __forward_begin_node>::type __begin_node_pointer;
typedef __rebind_pointer_t<_NodePtr, __forward_begin_node> __begin_node_pointer;
pointer __next_;
@ -262,16 +299,11 @@ struct __forward_begin_node
};
template <class _Tp, class _VoidPtr>
struct _LIBCPP_HIDDEN __begin_node_of
{
typedef __forward_begin_node<
typename __rebind_pointer<_VoidPtr, __forward_list_node<_Tp, _VoidPtr> >::type
> type;
};
using __begin_node_of = __forward_begin_node<__rebind_pointer_t<_VoidPtr, __forward_list_node<_Tp, _VoidPtr> > >;
template <class _Tp, class _VoidPtr>
struct __forward_list_node
: public __begin_node_of<_Tp, _VoidPtr>::type
struct _LIBCPP_STANDALONE_DEBUG __forward_list_node
: public __begin_node_of<_Tp, _VoidPtr>
{
typedef _Tp value_type;
@ -324,7 +356,7 @@ public:
typedef value_type& reference;
typedef typename pointer_traits<__node_pointer>::difference_type
difference_type;
typedef typename __rebind_pointer<__node_pointer, value_type>::type pointer;
typedef __rebind_pointer_t<__node_pointer, value_type> pointer;
_LIBCPP_INLINE_VISIBILITY
__forward_list_iterator() _NOEXCEPT : __ptr_(nullptr) {}
@ -375,11 +407,11 @@ class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator
__iter_node_pointer __ptr_;
__begin_node_pointer __get_begin() const {
_LIBCPP_HIDE_FROM_ABI __begin_node_pointer __get_begin() const {
return static_cast<__begin_node_pointer>(
static_cast<__void_pointer>(__ptr_));
}
__node_pointer __get_unsafe_node_pointer() const {
_LIBCPP_HIDE_FROM_ABI __node_pointer __get_unsafe_node_pointer() const {
return static_cast<__node_pointer>(
static_cast<__void_pointer>(__ptr_));
}
@ -405,7 +437,7 @@ public:
typedef const value_type& reference;
typedef typename pointer_traits<__node_pointer>::difference_type
difference_type;
typedef typename __rebind_pointer<__node_pointer, const value_type>::type
typedef __rebind_pointer_t<__node_pointer, const value_type>
pointer;
_LIBCPP_INLINE_VISIBILITY
@ -453,21 +485,15 @@ protected:
typedef typename allocator_traits<allocator_type>::void_pointer void_pointer;
typedef __forward_list_node<value_type, void_pointer> __node;
typedef typename __begin_node_of<value_type, void_pointer>::type __begin_node;
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __node>::type __node_allocator;
typedef __begin_node_of<value_type, void_pointer> __begin_node;
typedef __rebind_alloc<allocator_traits<allocator_type>, __node> __node_allocator;
typedef allocator_traits<__node_allocator> __node_traits;
typedef typename __node_traits::pointer __node_pointer;
typedef typename __rebind_alloc_helper<
allocator_traits<allocator_type>, __begin_node
>::type __begin_node_allocator;
typedef __rebind_alloc<allocator_traits<allocator_type>, __begin_node> __begin_node_allocator;
typedef typename allocator_traits<__begin_node_allocator>::pointer
__begin_node_pointer;
static_assert((!is_same<allocator_type, __node_allocator>::value),
"internal allocator type must differ from user-specified "
"type; otherwise overload resolution breaks");
__compressed_pair<__begin_node, __node_allocator> __before_begin_;
_LIBCPP_INLINE_VISIBILITY
@ -490,7 +516,7 @@ protected:
_LIBCPP_INLINE_VISIBILITY
__forward_list_base()
_NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
: __before_begin_(__begin_node()) {}
: __before_begin_(__begin_node(), __default_init_tag()) {}
_LIBCPP_INLINE_VISIBILITY
explicit __forward_list_base(const allocator_type& __a)
: __before_begin_(__begin_node(), __node_allocator(__a)) {}
@ -504,14 +530,14 @@ public:
_NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value);
_LIBCPP_INLINE_VISIBILITY
__forward_list_base(__forward_list_base&& __x, const allocator_type& __a);
#endif // _LIBCPP_CXX03_LANG
#endif // _LIBCPP_CXX03_LANG
private:
__forward_list_base(const __forward_list_base&);
__forward_list_base& operator=(const __forward_list_base&);
public:
~__forward_list_base();
_LIBCPP_HIDE_FROM_ABI ~__forward_list_base();
protected:
_LIBCPP_INLINE_VISIBILITY
@ -532,11 +558,11 @@ public:
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT;
#else
_NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value ||
_NOEXCEPT_(!__node_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value);
#endif
protected:
void clear() _NOEXCEPT;
_LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT;
private:
_LIBCPP_INLINE_VISIBILITY
@ -582,7 +608,7 @@ __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x,
}
}
#endif // _LIBCPP_CXX03_LANG
#endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Alloc>
__forward_list_base<_Tp, _Alloc>::~__forward_list_base()
@ -597,11 +623,11 @@ __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
#else
_NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value ||
_NOEXCEPT_(!__node_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value)
#endif
{
__swap_allocator(__alloc(), __x.__alloc(),
_VSTD::__swap_allocator(__alloc(), __x.__alloc(),
integral_constant<bool, __node_traits::propagate_on_container_swap::value>());
using _VSTD::swap;
swap(__before_begin()->__next_, __x.__before_begin()->__next_);
@ -637,19 +663,27 @@ public:
typedef _Tp value_type;
typedef _Alloc allocator_type;
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
static_assert(is_same<value_type, typename allocator_type::value_type>::value,
"Allocator::value_type must be same type as value_type");
typedef value_type& reference;
typedef const value_type& const_reference;
typedef typename allocator_traits<allocator_type>::pointer pointer;
typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
typedef typename allocator_traits<allocator_type>::size_type size_type;
typedef typename allocator_traits<allocator_type>::difference_type difference_type;
static_assert(is_same<allocator_type, __rebind_alloc<allocator_traits<allocator_type>, value_type> >::value,
"[allocator.requirements] states that rebinding an allocator to the same type should result in the "
"original allocator");
static_assert((!is_same<allocator_type, __node_allocator>::value),
"internal allocator type must differ from user-specified "
"type; otherwise overload resolution breaks");
typedef value_type& reference;
typedef const value_type& const_reference;
typedef typename allocator_traits<allocator_type>::pointer pointer;
typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
typedef typename allocator_traits<allocator_type>::size_type size_type;
typedef typename allocator_traits<allocator_type>::difference_type difference_type;
typedef typename base::iterator iterator;
typedef typename base::const_iterator const_iterator;
#if _LIBCPP_STD_VER > 17
#if _LIBCPP_STD_VER >= 20
typedef size_type __remove_return_type;
#else
typedef void __remove_return_type;
@ -661,37 +695,39 @@ public:
{} // = default;
_LIBCPP_INLINE_VISIBILITY
explicit forward_list(const allocator_type& __a);
explicit forward_list(size_type __n);
#if _LIBCPP_STD_VER > 11
explicit forward_list(size_type __n, const allocator_type& __a);
_LIBCPP_HIDE_FROM_ABI explicit forward_list(size_type __n);
#if _LIBCPP_STD_VER >= 14
_LIBCPP_HIDE_FROM_ABI explicit forward_list(size_type __n, const allocator_type& __a);
#endif
forward_list(size_type __n, const value_type& __v);
forward_list(size_type __n, const value_type& __v, const allocator_type& __a);
template <class _InputIterator>
forward_list(_InputIterator __f, _InputIterator __l,
typename enable_if<
__is_input_iterator<_InputIterator>::value
>::type* = nullptr);
template <class _InputIterator>
forward_list(_InputIterator __f, _InputIterator __l,
const allocator_type& __a,
typename enable_if<
__is_input_iterator<_InputIterator>::value
>::type* = nullptr);
forward_list(const forward_list& __x);
forward_list(const forward_list& __x, const allocator_type& __a);
_LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v);
forward_list& operator=(const forward_list& __x);
template <class = __enable_if_t<__is_allocator<_Alloc>::value> >
_LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v, const allocator_type& __a) : base(__a)
{
insert_after(cbefore_begin(), __n, __v);
}
template <class _InputIterator>
_LIBCPP_HIDE_FROM_ABI forward_list(_InputIterator __f, _InputIterator __l,
__enable_if_t<__has_input_iterator_category<_InputIterator>::value>* = nullptr);
template <class _InputIterator>
_LIBCPP_HIDE_FROM_ABI forward_list(_InputIterator __f, _InputIterator __l,
const allocator_type& __a,
__enable_if_t<__has_input_iterator_category<_InputIterator>::value>* = nullptr);
_LIBCPP_HIDE_FROM_ABI forward_list(const forward_list& __x);
_LIBCPP_HIDE_FROM_ABI forward_list(const forward_list& __x, const __type_identity_t<allocator_type>& __a);
_LIBCPP_HIDE_FROM_ABI forward_list& operator=(const forward_list& __x);
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
forward_list(forward_list&& __x)
_NOEXCEPT_(is_nothrow_move_constructible<base>::value)
: base(_VSTD::move(__x)) {}
forward_list(forward_list&& __x, const allocator_type& __a);
_LIBCPP_HIDE_FROM_ABI forward_list(forward_list&& __x, const __type_identity_t<allocator_type>& __a);
forward_list(initializer_list<value_type> __il);
forward_list(initializer_list<value_type> __il, const allocator_type& __a);
_LIBCPP_HIDE_FROM_ABI forward_list(initializer_list<value_type> __il);
_LIBCPP_HIDE_FROM_ABI forward_list(initializer_list<value_type> __il, const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY
forward_list& operator=(forward_list&& __x)
@ -704,18 +740,14 @@ public:
_LIBCPP_INLINE_VISIBILITY
void assign(initializer_list<value_type> __il);
#endif // _LIBCPP_CXX03_LANG
#endif // _LIBCPP_CXX03_LANG
// ~forward_list() = default;
template <class _InputIterator>
typename enable_if
<
__is_input_iterator<_InputIterator>::value,
void
>::type
assign(_InputIterator __f, _InputIterator __l);
void assign(size_type __n, const value_type& __v);
__enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>
_LIBCPP_HIDE_FROM_ABI assign(_InputIterator __f, _InputIterator __l);
_LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __v);
_LIBCPP_INLINE_VISIBILITY
allocator_type get_allocator() const _NOEXCEPT
@ -756,7 +788,7 @@ public:
{return base::__before_begin()->__next_ == nullptr;}
_LIBCPP_INLINE_VISIBILITY
size_type max_size() const _NOEXCEPT {
return std::min<size_type>(
return _VSTD::min<size_type>(
__node_traits::max_size(base::__alloc()),
numeric_limits<difference_type>::max());
}
@ -767,38 +799,36 @@ public:
const_reference front() const {return base::__before_begin()->__next_->__value_;}
#ifndef _LIBCPP_CXX03_LANG
#if _LIBCPP_STD_VER > 14
template <class... _Args> reference emplace_front(_Args&&... __args);
#if _LIBCPP_STD_VER >= 17
template <class... _Args>
_LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args);
#else
template <class... _Args> void emplace_front(_Args&&... __args);
template <class... _Args>
_LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args);
#endif
void push_front(value_type&& __v);
#endif // _LIBCPP_CXX03_LANG
void push_front(const value_type& __v);
_LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __v);
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __v);
void pop_front();
_LIBCPP_HIDE_FROM_ABI void pop_front();
#ifndef _LIBCPP_CXX03_LANG
template <class... _Args>
iterator emplace_after(const_iterator __p, _Args&&... __args);
_LIBCPP_HIDE_FROM_ABI iterator emplace_after(const_iterator __p, _Args&&... __args);
iterator insert_after(const_iterator __p, value_type&& __v);
iterator insert_after(const_iterator __p, initializer_list<value_type> __il)
_LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, value_type&& __v);
_LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, initializer_list<value_type> __il)
{return insert_after(__p, __il.begin(), __il.end());}
#endif // _LIBCPP_CXX03_LANG
iterator insert_after(const_iterator __p, const value_type& __v);
iterator insert_after(const_iterator __p, size_type __n, const value_type& __v);
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, const value_type& __v);
_LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, size_type __n, const value_type& __v);
template <class _InputIterator>
_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
__is_input_iterator<_InputIterator>::value,
iterator
>::type
_LIBCPP_INLINE_VISIBILITY
__enable_if_t<__has_input_iterator_category<_InputIterator>::value, iterator>
insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l);
iterator erase_after(const_iterator __p);
iterator erase_after(const_iterator __f, const_iterator __l);
_LIBCPP_HIDE_FROM_ABI iterator erase_after(const_iterator __p);
_LIBCPP_HIDE_FROM_ABI iterator erase_after(const_iterator __f, const_iterator __l);
_LIBCPP_INLINE_VISIBILITY
void swap(forward_list& __x)
@ -810,8 +840,8 @@ public:
#endif
{base::swap(__x);}
void resize(size_type __n);
void resize(size_type __n, const value_type& __v);
_LIBCPP_HIDE_FROM_ABI void resize(size_type __n);
_LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __v);
_LIBCPP_INLINE_VISIBILITY
void clear() _NOEXCEPT {base::clear();}
@ -822,15 +852,17 @@ public:
_LIBCPP_INLINE_VISIBILITY
void splice_after(const_iterator __p, forward_list&& __x,
const_iterator __f, const_iterator __l);
void splice_after(const_iterator __p, forward_list& __x);
void splice_after(const_iterator __p, forward_list& __x, const_iterator __i);
void splice_after(const_iterator __p, forward_list& __x,
_LIBCPP_HIDE_FROM_ABI void splice_after(const_iterator __p, forward_list& __x);
_LIBCPP_HIDE_FROM_ABI void splice_after(const_iterator __p, forward_list& __x, const_iterator __i);
_LIBCPP_HIDE_FROM_ABI void splice_after(const_iterator __p, forward_list& __x,
const_iterator __f, const_iterator __l);
__remove_return_type remove(const value_type& __v);
template <class _Predicate> __remove_return_type remove_if(_Predicate __pred);
_LIBCPP_HIDE_FROM_ABI __remove_return_type remove(const value_type& __v);
template <class _Predicate>
_LIBCPP_HIDE_FROM_ABI __remove_return_type remove_if(_Predicate __pred);
_LIBCPP_INLINE_VISIBILITY
__remove_return_type unique() {return unique(__equal_to<value_type>());}
template <class _BinaryPredicate> __remove_return_type unique(_BinaryPredicate __binary_pred);
__remove_return_type unique() { return unique(__equal_to()); }
template <class _BinaryPredicate>
_LIBCPP_HIDE_FROM_ABI __remove_return_type unique(_BinaryPredicate __binary_pred);
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
void merge(forward_list&& __x) {merge(__x, __less<value_type>());}
@ -838,49 +870,53 @@ public:
_LIBCPP_INLINE_VISIBILITY
void merge(forward_list&& __x, _Compare __comp)
{merge(__x, _VSTD::move(__comp));}
#endif // _LIBCPP_CXX03_LANG
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
void merge(forward_list& __x) {merge(__x, __less<value_type>());}
template <class _Compare> void merge(forward_list& __x, _Compare __comp);
template <class _Compare>
_LIBCPP_HIDE_FROM_ABI void merge(forward_list& __x, _Compare __comp);
_LIBCPP_INLINE_VISIBILITY
void sort() {sort(__less<value_type>());}
template <class _Compare> _LIBCPP_INLINE_VISIBILITY void sort(_Compare __comp);
void reverse() _NOEXCEPT;
_LIBCPP_HIDE_FROM_ABI void reverse() _NOEXCEPT;
private:
#ifndef _LIBCPP_CXX03_LANG
void __move_assign(forward_list& __x, true_type)
_LIBCPP_HIDE_FROM_ABI void __move_assign(forward_list& __x, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
void __move_assign(forward_list& __x, false_type);
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI void __move_assign(forward_list& __x, false_type);
#endif // _LIBCPP_CXX03_LANG
template <class _Compare>
static
static _LIBCPP_HIDE_FROM_ABI
__node_pointer
__merge(__node_pointer __f1, __node_pointer __f2, _Compare& __comp);
// TODO: Make this _LIBCPP_HIDE_FROM_ABI
template <class _Compare>
static
static _LIBCPP_HIDDEN
__node_pointer
__sort(__node_pointer __f, difference_type __sz, _Compare& __comp);
};
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
#if _LIBCPP_STD_VER >= 17
template<class _InputIterator,
class _Alloc = typename std::allocator<typename iterator_traits<_InputIterator>::value_type>,
class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
class _Alloc = allocator<__iter_value_type<_InputIterator>>,
class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
class = enable_if_t<__is_allocator<_Alloc>::value>
>
forward_list(_InputIterator, _InputIterator)
-> forward_list<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
-> forward_list<__iter_value_type<_InputIterator>, _Alloc>;
template<class _InputIterator,
class _Alloc,
class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
class = enable_if_t<__is_allocator<_Alloc>::value>
>
forward_list(_InputIterator, _InputIterator, _Alloc)
-> forward_list<typename iterator_traits<_InputIterator>::value_type, _Alloc>;
-> forward_list<__iter_value_type<_InputIterator>, _Alloc>;
#endif
template <class _Tp, class _Alloc>
@ -909,7 +945,7 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n)
}
}
#if _LIBCPP_STD_VER > 11
#if _LIBCPP_STD_VER >= 14
template <class _Tp, class _Alloc>
forward_list<_Tp, _Alloc>::forward_list(size_type __n,
const allocator_type& __base_alloc)
@ -938,20 +974,10 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v)
insert_after(cbefore_begin(), __n, __v);
}
template <class _Tp, class _Alloc>
forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v,
const allocator_type& __a)
: base(__a)
{
insert_after(cbefore_begin(), __n, __v);
}
template <class _Tp, class _Alloc>
template <class _InputIterator>
forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l,
typename enable_if<
__is_input_iterator<_InputIterator>::value
>::type*)
__enable_if_t<__has_input_iterator_category<_InputIterator>::value>*)
{
insert_after(cbefore_begin(), __f, __l);
}
@ -960,9 +986,7 @@ template <class _Tp, class _Alloc>
template <class _InputIterator>
forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l,
const allocator_type& __a,
typename enable_if<
__is_input_iterator<_InputIterator>::value
>::type*)
__enable_if_t<__has_input_iterator_category<_InputIterator>::value>*)
: base(__a)
{
insert_after(cbefore_begin(), __f, __l);
@ -977,7 +1001,7 @@ forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x)
template <class _Tp, class _Alloc>
forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x,
const allocator_type& __a)
const __type_identity_t<allocator_type>& __a)
: base(__a)
{
insert_after(cbefore_begin(), __x.begin(), __x.end());
@ -987,7 +1011,7 @@ template <class _Tp, class _Alloc>
forward_list<_Tp, _Alloc>&
forward_list<_Tp, _Alloc>::operator=(const forward_list& __x)
{
if (this != &__x)
if (this != _VSTD::addressof(__x))
{
base::__copy_assign_alloc(__x);
assign(__x.begin(), __x.end());
@ -998,7 +1022,7 @@ forward_list<_Tp, _Alloc>::operator=(const forward_list& __x)
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Alloc>
forward_list<_Tp, _Alloc>::forward_list(forward_list&& __x,
const allocator_type& __a)
const __type_identity_t<allocator_type>& __a)
: base(_VSTD::move(__x), __a)
{
if (base::__alloc() != __x.__alloc())
@ -1068,15 +1092,11 @@ forward_list<_Tp, _Alloc>::operator=(initializer_list<value_type> __il)
return *this;
}
#endif // _LIBCPP_CXX03_LANG
#endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Alloc>
template <class _InputIterator>
typename enable_if
<
__is_input_iterator<_InputIterator>::value,
void
>::type
__enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>
forward_list<_Tp, _Alloc>::assign(_InputIterator __f, _InputIterator __l)
{
iterator __i = before_begin();
@ -1117,7 +1137,7 @@ forward_list<_Tp, _Alloc>::assign(initializer_list<value_type> __il)
template <class _Tp, class _Alloc>
template <class... _Args>
#if _LIBCPP_STD_VER > 14
#if _LIBCPP_STD_VER >= 17
typename forward_list<_Tp, _Alloc>::reference
#else
void
@ -1131,7 +1151,7 @@ forward_list<_Tp, _Alloc>::emplace_front(_Args&&... __args)
_VSTD::forward<_Args>(__args)...);
__h->__next_ = base::__before_begin()->__next_;
base::__before_begin()->__next_ = __h.release();
#if _LIBCPP_STD_VER > 14
#if _LIBCPP_STD_VER >= 17
return base::__before_begin()->__next_->__value_;
#endif
}
@ -1148,7 +1168,7 @@ forward_list<_Tp, _Alloc>::push_front(value_type&& __v)
base::__before_begin()->__next_ = __h.release();
}
#endif // _LIBCPP_CXX03_LANG
#endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Alloc>
void
@ -1205,7 +1225,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, value_type&& __v)
return iterator(__r->__next_);
}
#endif // _LIBCPP_CXX03_LANG
#endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Alloc>
typename forward_list<_Tp, _Alloc>::iterator
@ -1235,17 +1255,17 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n,
__node_traits::construct(__a, _VSTD::addressof(__h->__value_), __v);
__node_pointer __first = __h.release();
__node_pointer __last = __first;
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
for (--__n; __n != 0; --__n, __last = __last->__next_)
{
__h.reset(__node_traits::allocate(__a, 1));
__node_traits::construct(__a, _VSTD::addressof(__h->__value_), __v);
__last->__next_ = __h.release();
}
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -1258,7 +1278,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n,
}
throw;
}
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
__last->__next_ = __r->__next_;
__r->__next_ = __first;
__r = static_cast<__begin_node_pointer>(__last);
@ -1268,11 +1288,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n,
template <class _Tp, class _Alloc>
template <class _InputIterator>
typename enable_if
<
__is_input_iterator<_InputIterator>::value,
typename forward_list<_Tp, _Alloc>::iterator
>::type
__enable_if_t<__has_input_iterator_category<_InputIterator>::value, typename forward_list<_Tp, _Alloc>::iterator>
forward_list<_Tp, _Alloc>::insert_after(const_iterator __p,
_InputIterator __f, _InputIterator __l)
{
@ -1285,17 +1301,17 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p,
__node_traits::construct(__a, _VSTD::addressof(__h->__value_), *__f);
__node_pointer __first = __h.release();
__node_pointer __last = __first;
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
for (++__f; __f != __l; ++__f, ((void)(__last = __last->__next_)))
{
__h.reset(__node_traits::allocate(__a, 1));
__node_traits::construct(__a, _VSTD::addressof(__h->__value_), *__f);
__last->__next_ = __h.release();
}
#ifndef _LIBCPP_NO_EXCEPTIONS
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
}
catch (...)
{
@ -1308,7 +1324,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p,
}
throw;
}
#endif // _LIBCPP_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
__last->__next_ = __r->__next_;
__r->__next_ = __first;
__r = static_cast<__begin_node_pointer>(__last);
@ -1525,7 +1541,7 @@ forward_list<_Tp, _Alloc>::remove(const value_type& __v)
else
++__i;
}
return (__remove_return_type) __count_removed;
}
@ -1553,7 +1569,7 @@ forward_list<_Tp, _Alloc>::remove_if(_Predicate __pred)
else
++__i;
}
return (__remove_return_type) __count_removed;
}
@ -1573,7 +1589,7 @@ forward_list<_Tp, _Alloc>::unique(_BinaryPredicate __binary_pred)
__deleted_nodes.splice_after(__deleted_nodes.before_begin(), *this, __i, __j);
__i = __j;
}
return (__remove_return_type) __count_removed;
}
@ -1582,7 +1598,7 @@ template <class _Compare>
void
forward_list<_Tp, _Alloc>::merge(forward_list& __x, _Compare __comp)
{
if (this != &__x)
if (this != _VSTD::addressof(__x))
{
base::__before_begin()->__next_ = __merge(base::__before_begin()->__next_,
__x.__before_begin()->__next_,
@ -1697,6 +1713,7 @@ forward_list<_Tp, _Alloc>::reverse() _NOEXCEPT
}
template <class _Tp, class _Alloc>
_LIBCPP_HIDE_FROM_ABI
bool operator==(const forward_list<_Tp, _Alloc>& __x,
const forward_list<_Tp, _Alloc>& __y)
{
@ -1712,6 +1729,8 @@ bool operator==(const forward_list<_Tp, _Alloc>& __x,
return (__ix == __ex) == (__iy == __ey);
}
#if _LIBCPP_STD_VER <= 17
template <class _Tp, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY
bool operator!=(const forward_list<_Tp, _Alloc>& __x,
@ -1753,6 +1772,17 @@ bool operator<=(const forward_list<_Tp, _Alloc>& __x,
return !(__y < __x);
}
#else // #if _LIBCPP_STD_VER <= 17
template <class _Tp, class _Allocator>
_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>
operator<=>(const forward_list<_Tp, _Allocator>& __x, const forward_list<_Tp, _Allocator>& __y) {
return std::lexicographical_compare_three_way(
__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>);
}
#endif // #if _LIBCPP_STD_VER <= 17
template <class _Tp, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY
void
@ -1762,20 +1792,45 @@ swap(forward_list<_Tp, _Alloc>& __x, forward_list<_Tp, _Alloc>& __y)
__x.swap(__y);
}
#if _LIBCPP_STD_VER > 17
#if _LIBCPP_STD_VER >= 20
template <class _Tp, class _Allocator, class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY
void erase_if(forward_list<_Tp, _Allocator>& __c, _Predicate __pred)
{ __c.remove_if(__pred); }
typename forward_list<_Tp, _Allocator>::size_type
erase_if(forward_list<_Tp, _Allocator>& __c, _Predicate __pred) {
return __c.remove_if(__pred);
}
template <class _Tp, class _Allocator, class _Up>
inline _LIBCPP_INLINE_VISIBILITY
void erase(forward_list<_Tp, _Allocator>& __c, const _Up& __v)
{ _VSTD::erase_if(__c, [&](auto& __elem) { return __elem == __v; }); }
typename forward_list<_Tp, _Allocator>::size_type
erase(forward_list<_Tp, _Allocator>& __c, const _Up& __v) {
return _VSTD::erase_if(__c, [&](auto& __elem) { return __elem == __v; });
}
#endif
_LIBCPP_END_NAMESPACE_STD
#if _LIBCPP_STD_VER >= 17
_LIBCPP_BEGIN_NAMESPACE_STD
namespace pmr {
template <class _ValueT>
using forward_list = std::forward_list<_ValueT, polymorphic_allocator<_ValueT>>;
} // namespace pmr
_LIBCPP_END_NAMESPACE_STD
#endif
_LIBCPP_POP_MACROS
#endif // _LIBCPP_FORWARD_LIST
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <algorithm>
# include <atomic>
# include <concepts>
# include <cstdlib>
# include <functional>
# include <iosfwd>
# include <iterator>
# include <type_traits>
# include <typeinfo>
#endif
#endif // _LIBCPP_FORWARD_LIST