authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-01-26 13:23:03-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-01-26 16:36:13-07:00
log1eaf180dd04efcf65ef981b1e1064658b5ec09c3
treec12e99871e9ba098bea523da0bde266d9afbd065
parent85be0b8c6589f58d5667d0a8a8f94524d5de5ba6

update libcxx to llvm 16


770 files changed, 27324 insertions(+), 15388 deletions(-)

lib/libcxx/include/__algorithm/adjacent_find.h+4-5
......@@ -23,7 +23,7 @@
2323_LIBCPP_BEGIN_NAMESPACE_STD
2424
2525template <class _Iter, class _Sent, class _BinaryPredicate>
26_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter
26_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter
2727__adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
2828 if (__first == __last)
2929 return __first;
......@@ -37,16 +37,15 @@ __adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
3737}
3838
3939template <class _ForwardIterator, class _BinaryPredicate>
40_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
40_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
4141adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
4242 return std::__adjacent_find(std::move(__first), std::move(__last), __pred);
4343}
4444
4545template <class _ForwardIterator>
46_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
46_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
4747adjacent_find(_ForwardIterator __first, _ForwardIterator __last) {
48 typedef typename iterator_traits<_ForwardIterator>::value_type __v;
49 return std::adjacent_find(std::move(__first), std::move(__last), __equal_to<__v>());
48 return std::adjacent_find(std::move(__first), std::move(__last), __equal_to());
5049}
5150
5251_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/all_of.h+1-1
......@@ -19,7 +19,7 @@
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
2121template <class _InputIterator, class _Predicate>
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
2323all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
2424 for (; __first != __last; ++__first)
2525 if (!__pred(*__first))
lib/libcxx/include/__algorithm/any_of.h+1-1
......@@ -19,7 +19,7 @@
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
2121template <class _InputIterator, class _Predicate>
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
2323any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
2424 for (; __first != __last; ++__first)
2525 if (__pred(*__first))
lib/libcxx/include/__algorithm/binary_search.h+3-4
......@@ -23,18 +23,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323
2424template <class _ForwardIterator, class _Tp, class _Compare>
2525_LIBCPP_NODISCARD_EXT inline
26_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
26_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2727bool
2828binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp)
2929{
30 using _Comp_ref = typename __comp_ref_type<_Compare>::type;
31 __first = std::lower_bound<_ForwardIterator, _Tp, _Comp_ref>(__first, __last, __value, __comp);
30 __first = std::lower_bound<_ForwardIterator, _Tp, __comp_ref_type<_Compare> >(__first, __last, __value, __comp);
3231 return __first != __last && !__comp(__value, *__first);
3332}
3433
3534template <class _ForwardIterator, class _Tp>
3635_LIBCPP_NODISCARD_EXT inline
37_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
36_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
3837bool
3938binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
4039{
lib/libcxx/include/__algorithm/comp.h+12-38
......@@ -17,73 +17,47 @@
1717
1818_LIBCPP_BEGIN_NAMESPACE_STD
1919
20// I'd like to replace these with _VSTD::equal_to<void>, but can't because:
21// * That only works with C++14 and later, and
22// * We haven't included <functional> here.
23template <class _T1, class _T2 = _T1>
24struct __equal_to
25{
26 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
27 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T1& __x, const _T2& __y) const {return __x == __y;}
28 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T2& __x, const _T1& __y) const {return __x == __y;}
29 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T2& __x, const _T2& __y) const {return __x == __y;}
30};
31
32template <class _T1>
33struct __equal_to<_T1, _T1>
34{
35 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
36 bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
37};
38
39template <class _T1>
40struct __equal_to<const _T1, _T1>
41{
42 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
43 bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
44};
45
46template <class _T1>
47struct __equal_to<_T1, const _T1>
48{
49 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
50 bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
20struct __equal_to {
21 template <class _T1, class _T2>
22 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _T1& __x, const _T2& __y) const {
23 return __x == __y;
24 }
5125};
5226
5327template <class _T1, class _T2 = _T1>
5428struct __less
5529{
56 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
30 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
5731 bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
5832
59 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
33 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
6034 bool operator()(const _T1& __x, const _T2& __y) const {return __x < __y;}
6135
62 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
36 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
6337 bool operator()(const _T2& __x, const _T1& __y) const {return __x < __y;}
6438
65 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
39 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
6640 bool operator()(const _T2& __x, const _T2& __y) const {return __x < __y;}
6741};
6842
6943template <class _T1>
7044struct __less<_T1, _T1>
7145{
72 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
46 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
7347 bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
7448};
7549
7650template <class _T1>
7751struct __less<const _T1, _T1>
7852{
79 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
53 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
8054 bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
8155};
8256
8357template <class _T1>
8458struct __less<_T1, const _T1>
8559{
86 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
60 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
8761 bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
8862};
8963
lib/libcxx/include/__algorithm/comp_ref_type.h+13-14
......@@ -23,11 +23,11 @@ template <class _Compare>
2323struct __debug_less
2424{
2525 _Compare &__comp_;
26 _LIBCPP_CONSTEXPR_AFTER_CXX11
26 _LIBCPP_CONSTEXPR_SINCE_CXX14
2727 __debug_less(_Compare& __c) : __comp_(__c) {}
2828
2929 template <class _Tp, class _Up>
30 _LIBCPP_CONSTEXPR_AFTER_CXX11
30 _LIBCPP_CONSTEXPR_SINCE_CXX14
3131 bool operator()(const _Tp& __x, const _Up& __y)
3232 {
3333 bool __r = __comp_(__x, __y);
......@@ -37,7 +37,7 @@ struct __debug_less
3737 }
3838
3939 template <class _Tp, class _Up>
40 _LIBCPP_CONSTEXPR_AFTER_CXX11
40 _LIBCPP_CONSTEXPR_SINCE_CXX14
4141 bool operator()(_Tp& __x, _Up& __y)
4242 {
4343 bool __r = __comp_(__x, __y);
......@@ -47,10 +47,10 @@ struct __debug_less
4747 }
4848
4949 template <class _LHS, class _RHS>
50 _LIBCPP_CONSTEXPR_AFTER_CXX11
50 _LIBCPP_CONSTEXPR_SINCE_CXX14
5151 inline _LIBCPP_INLINE_VISIBILITY
52 decltype((void)declval<_Compare&>()(
53 declval<_LHS &>(), declval<_RHS &>()))
52 decltype((void)std::declval<_Compare&>()(
53 std::declval<_LHS &>(), std::declval<_RHS &>()))
5454 __do_compare_assert(int, _LHS & __l, _RHS & __r) {
5555 _LIBCPP_DEBUG_ASSERT(!__comp_(__l, __r),
5656 "Comparator does not induce a strict weak ordering");
......@@ -59,21 +59,20 @@ struct __debug_less
5959 }
6060
6161 template <class _LHS, class _RHS>
62 _LIBCPP_CONSTEXPR_AFTER_CXX11
62 _LIBCPP_CONSTEXPR_SINCE_CXX14
6363 inline _LIBCPP_INLINE_VISIBILITY
6464 void __do_compare_assert(long, _LHS &, _RHS &) {}
6565};
6666
67template <class _Comp>
68struct __comp_ref_type {
69 // Pass the comparator by lvalue reference. Or in debug mode, using a
70 // debugging wrapper that stores a reference.
67// Pass the comparator by lvalue reference. Or in debug mode, using a
68// debugging wrapper that stores a reference.
7169#ifdef _LIBCPP_ENABLE_DEBUG_MODE
72 typedef __debug_less<_Comp> type;
70template <class _Comp>
71using __comp_ref_type = __debug_less<_Comp>;
7372#else
74 typedef _Comp& type;
73template <class _Comp>
74using __comp_ref_type = _Comp&;
7575#endif
76};
7776
7877_LIBCPP_END_NAMESPACE_STD
7978
lib/libcxx/include/__algorithm/copy.h+90-72
......@@ -9,100 +9,118 @@
99#ifndef _LIBCPP___ALGORITHM_COPY_H
1010#define _LIBCPP___ALGORITHM_COPY_H
1111
12#include <__algorithm/unwrap_iter.h>
13#include <__algorithm/unwrap_range.h>
12#include <__algorithm/copy_move_common.h>
13#include <__algorithm/iterator_operations.h>
14#include <__algorithm/min.h>
1415#include <__config>
15#include <__iterator/iterator_traits.h>
16#include <__iterator/reverse_iterator.h>
16#include <__iterator/segmented_iterator.h>
17#include <__type_traits/common_type.h>
1718#include <__utility/move.h>
1819#include <__utility/pair.h>
19#include <cstring>
20#include <type_traits>
2120
2221#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2322# pragma GCC system_header
2423#endif
2524
25_LIBCPP_PUSH_MACROS
26#include <__undef_macros>
27
2628_LIBCPP_BEGIN_NAMESPACE_STD
2729
28// copy
30template <class, class _InIter, class _Sent, class _OutIter>
31inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> __copy(_InIter, _Sent, _OutIter);
32
33template <class _AlgPolicy>
34struct __copy_loop {
35 template <class _InIter, class _Sent, class _OutIter>
36 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
37 operator()(_InIter __first, _Sent __last, _OutIter __result) const {
38 while (__first != __last) {
39 *__result = *__first;
40 ++__first;
41 ++__result;
42 }
2943
30template <class _InIter, class _Sent, class _OutIter>
31inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
32pair<_InIter, _OutIter> __copy_impl(_InIter __first, _Sent __last, _OutIter __result) {
33 while (__first != __last) {
34 *__result = *__first;
35 ++__first;
36 ++__result;
44 return std::make_pair(std::move(__first), std::move(__result));
3745 }
38 return pair<_InIter, _OutIter>(std::move(__first), std::move(__result));
39}
4046
41template <class _InValueT,
42 class _OutValueT,
43 class = __enable_if_t<is_same<typename remove_const<_InValueT>::type, _OutValueT>::value
44 && is_trivially_copy_assignable<_OutValueT>::value> >
45inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
46pair<_InValueT*, _OutValueT*> __copy_impl(_InValueT* __first, _InValueT* __last, _OutValueT* __result) {
47 if (__libcpp_is_constant_evaluated()
48// TODO: Remove this once GCC supports __builtin_memmove during constant evaluation
49#ifndef _LIBCPP_COMPILER_GCC
50 && !is_trivially_copyable<_InValueT>::value
51#endif
52 )
53 return std::__copy_impl<_InValueT*, _InValueT*, _OutValueT*>(__first, __last, __result);
54 const size_t __n = static_cast<size_t>(__last - __first);
55 if (__n > 0)
56 ::__builtin_memmove(__result, __first, __n * sizeof(_OutValueT));
57 return std::make_pair(__first + __n, __result + __n);
58}
47 template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0>
48 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
49 operator()(_InIter __first, _InIter __last, _OutIter __result) const {
50 using _Traits = __segmented_iterator_traits<_InIter>;
51 auto __sfirst = _Traits::__segment(__first);
52 auto __slast = _Traits::__segment(__last);
53 if (__sfirst == __slast) {
54 auto __iters = std::__copy<_AlgPolicy>(_Traits::__local(__first), _Traits::__local(__last), std::move(__result));
55 return std::make_pair(__last, std::move(__iters.second));
56 }
5957
60template <class _InIter, class _OutIter,
61 __enable_if_t<is_same<typename remove_const<__iter_value_type<_InIter> >::type, __iter_value_type<_OutIter> >::value
62 && __is_cpp17_contiguous_iterator<typename _InIter::iterator_type>::value
63 && __is_cpp17_contiguous_iterator<typename _OutIter::iterator_type>::value
64 && is_trivially_copy_assignable<__iter_value_type<_OutIter> >::value
65 && __is_reverse_iterator<_InIter>::value
66 && __is_reverse_iterator<_OutIter>::value, int> = 0>
67inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
68pair<_InIter, _OutIter>
69__copy_impl(_InIter __first, _InIter __last, _OutIter __result) {
70 auto __first_base = std::__unwrap_iter(__first.base());
71 auto __last_base = std::__unwrap_iter(__last.base());
72 auto __result_base = std::__unwrap_iter(__result.base());
73 auto __result_first = __result_base - (__first_base - __last_base);
74 std::__copy_impl(__last_base, __first_base, __result_first);
75 return std::make_pair(__last, _OutIter(std::__rewrap_iter(__result.base(), __result_first)));
76}
58 __result = std::__copy<_AlgPolicy>(_Traits::__local(__first), _Traits::__end(__sfirst), std::move(__result)).second;
59 ++__sfirst;
60 while (__sfirst != __slast) {
61 __result =
62 std::__copy<_AlgPolicy>(_Traits::__begin(__sfirst), _Traits::__end(__sfirst), std::move(__result)).second;
63 ++__sfirst;
64 }
65 __result =
66 std::__copy<_AlgPolicy>(_Traits::__begin(__sfirst), _Traits::__local(__last), std::move(__result)).second;
67 return std::make_pair(__last, std::move(__result));
68 }
7769
78template <class _InIter, class _Sent, class _OutIter,
79 __enable_if_t<!(is_copy_constructible<_InIter>::value
80 && is_copy_constructible<_Sent>::value
81 && is_copy_constructible<_OutIter>::value), int> = 0 >
82inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
83pair<_InIter, _OutIter> __copy(_InIter __first, _Sent __last, _OutIter __result) {
84 return std::__copy_impl(std::move(__first), std::move(__last), std::move(__result));
85}
70 template <class _InIter,
71 class _OutIter,
72 __enable_if_t<__is_cpp17_random_access_iterator<_InIter>::value &&
73 !__is_segmented_iterator<_InIter>::value && __is_segmented_iterator<_OutIter>::value,
74 int> = 0>
75 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
76 operator()(_InIter __first, _InIter __last, _OutIter __result) {
77 using _Traits = __segmented_iterator_traits<_OutIter>;
78 using _DiffT = typename common_type<__iter_diff_t<_InIter>, __iter_diff_t<_OutIter> >::type;
8679
87template <class _InIter, class _Sent, class _OutIter,
88 __enable_if_t<is_copy_constructible<_InIter>::value
89 && is_copy_constructible<_Sent>::value
90 && is_copy_constructible<_OutIter>::value, int> = 0>
91inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
92pair<_InIter, _OutIter> __copy(_InIter __first, _Sent __last, _OutIter __result) {
93 auto __range = std::__unwrap_range(__first, __last);
94 auto __ret = std::__copy_impl(std::move(__range.first), std::move(__range.second), std::__unwrap_iter(__result));
95 return std::make_pair(
96 std::__rewrap_range<_Sent>(__first, __ret.first), std::__rewrap_iter(__result, __ret.second));
80 if (__first == __last)
81 return std::make_pair(std::move(__first), std::move(__result));
82
83 auto __local_first = _Traits::__local(__result);
84 auto __segment_iterator = _Traits::__segment(__result);
85 while (true) {
86 auto __local_last = _Traits::__end(__segment_iterator);
87 auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first);
88 auto __iters = std::__copy<_AlgPolicy>(__first, __first + __size, __local_first);
89 __first = std::move(__iters.first);
90
91 if (__first == __last)
92 return std::make_pair(std::move(__first), _Traits::__compose(__segment_iterator, std::move(__iters.second)));
93
94 __local_first = _Traits::__begin(++__segment_iterator);
95 }
96 }
97};
98
99struct __copy_trivial {
100 // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.
101 template <class _In, class _Out,
102 __enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0>
103 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
104 operator()(_In* __first, _In* __last, _Out* __result) const {
105 return std::__copy_trivial_impl(__first, __last, __result);
106 }
107};
108
109template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>
110pair<_InIter, _OutIter> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
111__copy(_InIter __first, _Sent __last, _OutIter __result) {
112 return std::__dispatch_copy_or_move<_AlgPolicy, __copy_loop<_AlgPolicy>, __copy_trivial>(
113 std::move(__first), std::move(__last), std::move(__result));
97114}
98115
99116template <class _InputIterator, class _OutputIterator>
100inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
101_OutputIterator
117inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
102118copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
103 return std::__copy(__first, __last, __result).second;
119 return std::__copy<_ClassicAlgPolicy>(__first, __last, __result).second;
104120}
105121
106122_LIBCPP_END_NAMESPACE_STD
107123
124_LIBCPP_POP_MACROS
125
108126#endif // _LIBCPP___ALGORITHM_COPY_H
lib/libcxx/include/__algorithm/copy_backward.h+112-30
......@@ -9,53 +9,135 @@
99#ifndef _LIBCPP___ALGORITHM_COPY_BACKWARD_H
1010#define _LIBCPP___ALGORITHM_COPY_BACKWARD_H
1111
12#include <__algorithm/copy.h>
12#include <__algorithm/copy_move_common.h>
1313#include <__algorithm/iterator_operations.h>
14#include <__algorithm/ranges_copy.h>
15#include <__algorithm/unwrap_iter.h>
16#include <__concepts/same_as.h>
14#include <__algorithm/min.h>
1715#include <__config>
18#include <__iterator/iterator_traits.h>
19#include <__iterator/reverse_iterator.h>
20#include <__ranges/subrange.h>
16#include <__iterator/segmented_iterator.h>
17#include <__type_traits/common_type.h>
18#include <__type_traits/is_copy_constructible.h>
2119#include <__utility/move.h>
2220#include <__utility/pair.h>
23#include <type_traits>
2421
2522#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2623# pragma GCC system_header
2724#endif
2825
26_LIBCPP_PUSH_MACROS
27#include <__undef_macros>
28
2929_LIBCPP_BEGIN_NAMESPACE_STD
3030
31template <class _AlgPolicy, class _InputIterator, class _OutputIterator,
32 __enable_if_t<is_same<_AlgPolicy, _ClassicAlgPolicy>::value, int> = 0>
33inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_InputIterator, _OutputIterator>
34__copy_backward(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
35 auto __ret = std::__copy(
36 __unconstrained_reverse_iterator<_InputIterator>(__last),
37 __unconstrained_reverse_iterator<_InputIterator>(__first),
38 __unconstrained_reverse_iterator<_OutputIterator>(__result));
39 return pair<_InputIterator, _OutputIterator>(__ret.first.base(), __ret.second.base());
40}
31template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>
32_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InIter, _OutIter>
33__copy_backward(_InIter __first, _Sent __last, _OutIter __result);
34
35template <class _AlgPolicy>
36struct __copy_backward_loop {
37 template <class _InIter, class _Sent, class _OutIter>
38 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
39 operator()(_InIter __first, _Sent __last, _OutIter __result) const {
40 auto __last_iter = _IterOps<_AlgPolicy>::next(__first, __last);
41 auto __original_last_iter = __last_iter;
42
43 while (__first != __last_iter) {
44 *--__result = *--__last_iter;
45 }
46
47 return std::make_pair(std::move(__original_last_iter), std::move(__result));
48 }
49
50 template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0>
51 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
52 operator()(_InIter __first, _InIter __last, _OutIter __result) const {
53 using _Traits = __segmented_iterator_traits<_InIter>;
54 auto __sfirst = _Traits::__segment(__first);
55 auto __slast = _Traits::__segment(__last);
56 if (__sfirst == __slast) {
57 auto __iters =
58 std::__copy_backward<_AlgPolicy>(_Traits::__local(__first), _Traits::__local(__last), std::move(__result));
59 return std::make_pair(__last, __iters.second);
60 }
61
62 __result =
63 std::__copy_backward<_AlgPolicy>(_Traits::__begin(__slast), _Traits::__local(__last), std::move(__result))
64 .second;
65 --__slast;
66 while (__sfirst != __slast) {
67 __result =
68 std::__copy_backward<_AlgPolicy>(_Traits::__begin(__slast), _Traits::__end(__slast), std::move(__result))
69 .second;
70 --__slast;
71 }
72 __result = std::__copy_backward<_AlgPolicy>(_Traits::__local(__first), _Traits::__end(__slast), std::move(__result))
73 .second;
74 return std::make_pair(__last, std::move(__result));
75 }
76
77 template <class _InIter,
78 class _OutIter,
79 __enable_if_t<__is_cpp17_random_access_iterator<_InIter>::value &&
80 !__is_segmented_iterator<_InIter>::value && __is_segmented_iterator<_OutIter>::value,
81 int> = 0>
82 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
83 operator()(_InIter __first, _InIter __last, _OutIter __result) {
84 using _Traits = __segmented_iterator_traits<_OutIter>;
85 auto __orig_last = __last;
86 auto __segment_iterator = _Traits::__segment(__result);
4187
42#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
43template <class _AlgPolicy, class _Iter1, class _Sent1, class _Iter2,
44 __enable_if_t<is_same<_AlgPolicy, _RangeAlgPolicy>::value, int> = 0>
45_LIBCPP_HIDE_FROM_ABI constexpr pair<_Iter1, _Iter2> __copy_backward(_Iter1 __first, _Sent1 __last, _Iter2 __result) {
46 auto __last_iter = _IterOps<_AlgPolicy>::next(__first, std::move(__last));
47 auto __reverse_range = std::__reverse_range(std::ranges::subrange(std::move(__first), __last_iter));
48 auto __ret = ranges::copy(std::move(__reverse_range), std::make_reverse_iterator(__result));
49 return std::make_pair(__last_iter, __ret.out.base());
88 // When the range contains no elements, __result might not be a valid iterator
89 if (__first == __last)
90 return std::make_pair(__first, __result);
91
92 auto __local_last = _Traits::__local(__result);
93 while (true) {
94 using _DiffT = typename common_type<__iter_diff_t<_InIter>, __iter_diff_t<_OutIter> >::type;
95
96 auto __local_first = _Traits::__begin(__segment_iterator);
97 auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first);
98 auto __iter = std::__copy_backward<_AlgPolicy>(__last - __size, __last, __local_last).second;
99 __last -= __size;
100
101 if (__first == __last)
102 return std::make_pair(std::move(__orig_last), _Traits::__compose(__segment_iterator, std::move(__iter)));
103 --__segment_iterator;
104 __local_last = _Traits::__end(__segment_iterator);
105 }
106 }
107};
108
109struct __copy_backward_trivial {
110 // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.
111 template <class _In, class _Out,
112 __enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0>
113 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
114 operator()(_In* __first, _In* __last, _Out* __result) const {
115 return std::__copy_backward_trivial_impl(__first, __last, __result);
116 }
117};
118
119template <class _AlgPolicy, class _BidirectionalIterator1, class _Sentinel, class _BidirectionalIterator2>
120_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_BidirectionalIterator1, _BidirectionalIterator2>
121__copy_backward(_BidirectionalIterator1 __first, _Sentinel __last, _BidirectionalIterator2 __result) {
122 return std::__dispatch_copy_or_move<_AlgPolicy, __copy_backward_loop<_AlgPolicy>, __copy_backward_trivial>(
123 std::move(__first), std::move(__last), std::move(__result));
50124}
51#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
52125
53126template <class _BidirectionalIterator1, class _BidirectionalIterator2>
54inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator2
55copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, _BidirectionalIterator2 __result) {
56 return std::__copy_backward<_ClassicAlgPolicy>(__first, __last, __result).second;
127inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
128_BidirectionalIterator2
129copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
130 _BidirectionalIterator2 __result)
131{
132 static_assert(std::is_copy_constructible<_BidirectionalIterator1>::value &&
133 std::is_copy_constructible<_BidirectionalIterator1>::value, "Iterators must be copy constructible.");
134
135 return std::__copy_backward<_ClassicAlgPolicy>(
136 std::move(__first), std::move(__last), std::move(__result)).second;
57137}
58138
59139_LIBCPP_END_NAMESPACE_STD
60140
141_LIBCPP_POP_MACROS
142
61143#endif // _LIBCPP___ALGORITHM_COPY_BACKWARD_H
lib/libcxx/include/__algorithm/copy_if.h+1-1
......@@ -18,7 +18,7 @@
1818_LIBCPP_BEGIN_NAMESPACE_STD
1919
2020template<class _InputIterator, class _OutputIterator, class _Predicate>
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2222_OutputIterator
2323copy_if(_InputIterator __first, _InputIterator __last,
2424 _OutputIterator __result, _Predicate __pred)
lib/libcxx/include/__algorithm/copy_move_common.h created+163
......@@ -0,0 +1,163 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_COPY_MOVE_COMMON_H
10#define _LIBCPP___ALGORITHM_COPY_MOVE_COMMON_H
11
12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/unwrap_iter.h>
14#include <__algorithm/unwrap_range.h>
15#include <__config>
16#include <__iterator/iterator_traits.h>
17#include <__memory/pointer_traits.h>
18#include <__type_traits/enable_if.h>
19#include <__type_traits/is_always_bitcastable.h>
20#include <__type_traits/is_constant_evaluated.h>
21#include <__type_traits/is_copy_constructible.h>
22#include <__type_traits/is_trivially_assignable.h>
23#include <__type_traits/is_trivially_copyable.h>
24#include <__type_traits/is_volatile.h>
25#include <__utility/move.h>
26#include <__utility/pair.h>
27#include <cstddef>
28
29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
30# pragma GCC system_header
31#endif
32
33_LIBCPP_BEGIN_NAMESPACE_STD
34
35// Type traits.
36
37template <class _From, class _To>
38struct __can_lower_copy_assignment_to_memmove {
39 static const bool value =
40 // If the types are always bitcastable, it's valid to do a bitwise copy between them.
41 __is_always_bitcastable<_From, _To>::value &&
42 // Reject conversions that wouldn't be performed by the regular built-in assignment (e.g. between arrays).
43 is_trivially_assignable<_To&, const _From&>::value &&
44 // `memmove` doesn't accept `volatile` pointers, make sure the optimization SFINAEs away in that case.
45 !is_volatile<_From>::value &&
46 !is_volatile<_To>::value;
47};
48
49template <class _From, class _To>
50struct __can_lower_move_assignment_to_memmove {
51 static const bool value =
52 __is_always_bitcastable<_From, _To>::value &&
53 is_trivially_assignable<_To&, _From&&>::value &&
54 !is_volatile<_From>::value &&
55 !is_volatile<_To>::value;
56};
57
58// `memmove` algorithms implementation.
59
60template <class _In, class _Out>
61_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
62__copy_trivial_impl(_In* __first, _In* __last, _Out* __result) {
63 const size_t __n = static_cast<size_t>(__last - __first);
64 ::__builtin_memmove(__result, __first, __n * sizeof(_Out));
65
66 return std::make_pair(__last, __result + __n);
67}
68
69template <class _In, class _Out>
70_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
71__copy_backward_trivial_impl(_In* __first, _In* __last, _Out* __result) {
72 const size_t __n = static_cast<size_t>(__last - __first);
73 __result -= __n;
74
75 ::__builtin_memmove(__result, __first, __n * sizeof(_Out));
76
77 return std::make_pair(__last, __result);
78}
79
80// Iterator unwrapping and dispatching to the correct overload.
81
82template <class _F1, class _F2>
83struct __overload : _F1, _F2 {
84 using _F1::operator();
85 using _F2::operator();
86};
87
88template <class _InIter, class _Sent, class _OutIter, class = void>
89struct __can_rewrap : false_type {};
90
91template <class _InIter, class _Sent, class _OutIter>
92struct __can_rewrap<_InIter,
93 _Sent,
94 _OutIter,
95 // Note that sentinels are always copy-constructible.
96 __enable_if_t< is_copy_constructible<_InIter>::value &&
97 is_copy_constructible<_OutIter>::value > > : true_type {};
98
99template <class _Algorithm,
100 class _InIter,
101 class _Sent,
102 class _OutIter,
103 __enable_if_t<__can_rewrap<_InIter, _Sent, _OutIter>::value, int> = 0>
104_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pair<_InIter, _OutIter>
105__unwrap_and_dispatch(_InIter __first, _Sent __last, _OutIter __out_first) {
106 auto __range = std::__unwrap_range(__first, std::move(__last));
107 auto __result = _Algorithm()(std::move(__range.first), std::move(__range.second), std::__unwrap_iter(__out_first));
108 return std::make_pair(std::__rewrap_range<_Sent>(std::move(__first), std::move(__result.first)),
109 std::__rewrap_iter(std::move(__out_first), std::move(__result.second)));
110}
111
112template <class _Algorithm,
113 class _InIter,
114 class _Sent,
115 class _OutIter,
116 __enable_if_t<!__can_rewrap<_InIter, _Sent, _OutIter>::value, int> = 0>
117_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pair<_InIter, _OutIter>
118__unwrap_and_dispatch(_InIter __first, _Sent __last, _OutIter __out_first) {
119 return _Algorithm()(std::move(__first), std::move(__last), std::move(__out_first));
120}
121
122template <class _IterOps, class _InValue, class _OutIter, class = void>
123struct __can_copy_without_conversion : false_type {};
124
125template <class _IterOps, class _InValue, class _OutIter>
126struct __can_copy_without_conversion<
127 _IterOps,
128 _InValue,
129 _OutIter,
130 __enable_if_t<is_same<_InValue, typename _IterOps::template __value_type<_OutIter> >::value> > : true_type {};
131
132template <class _AlgPolicy,
133 class _NaiveAlgorithm,
134 class _OptimizedAlgorithm,
135 class _InIter,
136 class _Sent,
137 class _OutIter>
138_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pair<_InIter, _OutIter>
139__dispatch_copy_or_move(_InIter __first, _Sent __last, _OutIter __out_first) {
140#ifdef _LIBCPP_COMPILER_GCC
141 // GCC doesn't support `__builtin_memmove` during constant evaluation.
142 if (__libcpp_is_constant_evaluated()) {
143 return std::__unwrap_and_dispatch<_NaiveAlgorithm>(std::move(__first), std::move(__last), std::move(__out_first));
144 }
145#else
146 // In Clang, `__builtin_memmove` only supports fully trivially copyable types (just having trivial copy assignment is
147 // insufficient). Also, conversions are not supported.
148 if (__libcpp_is_constant_evaluated()) {
149 using _InValue = typename _IterOps<_AlgPolicy>::template __value_type<_InIter>;
150 if (!is_trivially_copyable<_InValue>::value ||
151 !__can_copy_without_conversion<_IterOps<_AlgPolicy>, _InValue, _OutIter>::value) {
152 return std::__unwrap_and_dispatch<_NaiveAlgorithm>(std::move(__first), std::move(__last), std::move(__out_first));
153 }
154 }
155#endif // _LIBCPP_COMPILER_GCC
156
157 using _Algorithm = __overload<_NaiveAlgorithm, _OptimizedAlgorithm>;
158 return std::__unwrap_and_dispatch<_Algorithm>(std::move(__first), std::move(__last), std::move(__out_first));
159}
160
161_LIBCPP_END_NAMESPACE_STD
162
163#endif // _LIBCPP___ALGORITHM_COPY_MOVE_COMMON_H
lib/libcxx/include/__algorithm/copy_n.h+3-2
......@@ -12,6 +12,7 @@
1212#include <__algorithm/copy.h>
1313#include <__config>
1414#include <__iterator/iterator_traits.h>
15#include <__utility/convert_to_integral.h>
1516#include <type_traits>
1617
1718#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -21,7 +22,7 @@
2122_LIBCPP_BEGIN_NAMESPACE_STD
2223
2324template<class _InputIterator, class _Size, class _OutputIterator>
24inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
25inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2526typename enable_if
2627<
2728 __is_cpp17_input_iterator<_InputIterator>::value &&
......@@ -47,7 +48,7 @@ copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
4748}
4849
4950template<class _InputIterator, class _Size, class _OutputIterator>
50inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
51inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
5152typename enable_if
5253<
5354 __is_cpp17_random_access_iterator<_InputIterator>::value,
lib/libcxx/include/__algorithm/count.h+1-1
......@@ -20,7 +20,7 @@
2020_LIBCPP_BEGIN_NAMESPACE_STD
2121
2222template <class _InputIterator, class _Tp>
23_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
23_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2424 typename iterator_traits<_InputIterator>::difference_type
2525 count(_InputIterator __first, _InputIterator __last, const _Tp& __value) {
2626 typename iterator_traits<_InputIterator>::difference_type __r(0);
lib/libcxx/include/__algorithm/count_if.h+1-1
......@@ -20,7 +20,7 @@
2020_LIBCPP_BEGIN_NAMESPACE_STD
2121
2222template <class _InputIterator, class _Predicate>
23_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
23_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2424 typename iterator_traits<_InputIterator>::difference_type
2525 count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
2626 typename iterator_traits<_InputIterator>::difference_type __r(0);
lib/libcxx/include/__algorithm/equal.h+15-14
......@@ -22,7 +22,7 @@
2222_LIBCPP_BEGIN_NAMESPACE_STD
2323
2424template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
25_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
25_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
2626equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) {
2727 for (; __first1 != __last1; ++__first1, (void)++__first2)
2828 if (!__pred(*__first1, *__first2))
......@@ -31,16 +31,14 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first
3131}
3232
3333template <class _InputIterator1, class _InputIterator2>
34_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
34_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
3535equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) {
36 typedef typename iterator_traits<_InputIterator1>::value_type __v1;
37 typedef typename iterator_traits<_InputIterator2>::value_type __v2;
38 return _VSTD::equal(__first1, __last1, __first2, __equal_to<__v1, __v2>());
36 return std::equal(__first1, __last1, __first2, __equal_to());
3937}
4038
4139#if _LIBCPP_STD_VER > 11
4240template <class _BinaryPredicate, class _InputIterator1, class _InputIterator2>
43inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
41inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
4442__equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
4543 _BinaryPredicate __pred, input_iterator_tag, input_iterator_tag) {
4644 for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2)
......@@ -50,7 +48,7 @@ __equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fir
5048}
5149
5250template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
53inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
51inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
5452__equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2,
5553 _RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag,
5654 random_access_iterator_tag) {
......@@ -61,7 +59,7 @@ __equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _Random
6159}
6260
6361template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
64_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
62_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
6563equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
6664 _BinaryPredicate __pred) {
6765 return _VSTD::__equal<_BinaryPredicate&>(
......@@ -70,13 +68,16 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first
7068}
7169
7270template <class _InputIterator1, class _InputIterator2>
73_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
71_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
7472equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
75 typedef typename iterator_traits<_InputIterator1>::value_type __v1;
76 typedef typename iterator_traits<_InputIterator2>::value_type __v2;
77 return _VSTD::__equal(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>(),
78 typename iterator_traits<_InputIterator1>::iterator_category(),
79 typename iterator_traits<_InputIterator2>::iterator_category());
73 return std::__equal(
74 __first1,
75 __last1,
76 __first2,
77 __last2,
78 __equal_to(),
79 typename iterator_traits<_InputIterator1>::iterator_category(),
80 typename iterator_traits<_InputIterator2>::iterator_category());
8081}
8182#endif
8283
lib/libcxx/include/__algorithm/equal_range.h+8-5
......@@ -34,7 +34,7 @@
3434_LIBCPP_BEGIN_NAMESPACE_STD
3535
3636template <class _AlgPolicy, class _Compare, class _Iter, class _Sent, class _Tp, class _Proj>
37_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_Iter, _Iter>
37_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter, _Iter>
3838__equal_range(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp, _Proj&& __proj) {
3939 auto __len = _IterOps<_AlgPolicy>::distance(__first, __last);
4040 _Iter __end = _IterOps<_AlgPolicy>::next(__first, __last);
......@@ -58,19 +58,22 @@ __equal_range(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp
5858}
5959
6060template <class _ForwardIterator, class _Tp, class _Compare>
61_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator>
61_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator>
6262equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
6363 static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value,
6464 "The comparator has to be callable");
6565 static_assert(is_copy_constructible<_ForwardIterator>::value,
6666 "Iterator has to be copy constructible");
67 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
6867 return std::__equal_range<_ClassicAlgPolicy>(
69 std::move(__first), std::move(__last), __value, static_cast<_Comp_ref>(__comp), std::__identity());
68 std::move(__first),
69 std::move(__last),
70 __value,
71 static_cast<__comp_ref_type<_Compare> >(__comp),
72 std::__identity());
7073}
7174
7275template <class _ForwardIterator, class _Tp>
73_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator>
76_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator>
7477equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
7578 return std::equal_range(
7679 std::move(__first),
lib/libcxx/include/__algorithm/fill.h+3-3
......@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323// fill isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset.
2424
2525template <class _ForwardIterator, class _Tp>
26inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
26inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2727void
2828__fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, forward_iterator_tag)
2929{
......@@ -32,7 +32,7 @@ __fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, fo
3232}
3333
3434template <class _RandomAccessIterator, class _Tp>
35inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
35inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
3636void
3737__fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value, random_access_iterator_tag)
3838{
......@@ -40,7 +40,7 @@ __fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& _
4040}
4141
4242template <class _ForwardIterator, class _Tp>
43inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
43inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
4444void
4545fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
4646{
lib/libcxx/include/__algorithm/fill_n.h+3-2
......@@ -11,6 +11,7 @@
1111
1212#include <__config>
1313#include <__iterator/iterator_traits.h>
14#include <__utility/convert_to_integral.h>
1415#include <type_traits>
1516
1617#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -22,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2223// fill_n isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset.
2324
2425template <class _OutputIterator, class _Size, class _Tp>
25inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
26inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2627_OutputIterator
2728__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)
2829{
......@@ -32,7 +33,7 @@ __fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)
3233}
3334
3435template <class _OutputIterator, class _Size, class _Tp>
35inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
36inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
3637_OutputIterator
3738fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)
3839{
lib/libcxx/include/__algorithm/find.h+1-1
......@@ -19,7 +19,7 @@
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
2121template <class _InputIterator, class _Tp>
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
2323find(_InputIterator __first, _InputIterator __last, const _Tp& __value) {
2424 for (; __first != __last; ++__first)
2525 if (*__first == __value)
lib/libcxx/include/__algorithm/find_end.h+7-9
......@@ -37,7 +37,7 @@ template <
3737 class _Pred,
3838 class _Proj1,
3939 class _Proj2>
40_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_Iter1, _Iter1> __find_end_impl(
40_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> __find_end_impl(
4141 _Iter1 __first1,
4242 _Sent1 __last1,
4343 _Iter2 __first2,
......@@ -91,7 +91,7 @@ template <
9191 class _Sent2,
9292 class _Proj1,
9393 class _Proj2>
94_LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter1 __find_end(
94_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter1 __find_end(
9595 _Iter1 __first1,
9696 _Sent1 __sent1,
9797 _Iter2 __first2,
......@@ -144,7 +144,7 @@ template <
144144 class _Sent2,
145145 class _Proj1,
146146 class _Proj2>
147_LIBCPP_CONSTEXPR_AFTER_CXX11 _Iter1 __find_end(
147_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter1 __find_end(
148148 _Iter1 __first1,
149149 _Sent1 __sent1,
150150 _Iter2 __first2,
......@@ -189,7 +189,7 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 _Iter1 __find_end(
189189}
190190
191191template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
192_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
192_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
193193_ForwardIterator1 __find_end_classic(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
194194 _ForwardIterator2 __first2, _ForwardIterator2 __last2,
195195 _BinaryPredicate& __pred) {
......@@ -208,7 +208,7 @@ _ForwardIterator1 __find_end_classic(_ForwardIterator1 __first1, _ForwardIterato
208208}
209209
210210template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
211_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
211_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
212212_ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
213213 _ForwardIterator2 __first2, _ForwardIterator2 __last2,
214214 _BinaryPredicate __pred) {
......@@ -216,12 +216,10 @@ _ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1
216216}
217217
218218template <class _ForwardIterator1, class _ForwardIterator2>
219_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
219_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
220220_ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
221221 _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
222 using __v1 = typename iterator_traits<_ForwardIterator1>::value_type;
223 using __v2 = typename iterator_traits<_ForwardIterator2>::value_type;
224 return std::find_end(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
222 return std::find_end(__first1, __last1, __first2, __last2, __equal_to());
225223}
226224
227225_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/find_first_of.h+5-6
......@@ -21,7 +21,8 @@
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
2323template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
24_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator1 __find_first_of_ce(_ForwardIterator1 __first1,
24_LIBCPP_HIDE_FROM_ABI
25_LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator1 __find_first_of_ce(_ForwardIterator1 __first1,
2526 _ForwardIterator1 __last1,
2627 _ForwardIterator2 __first2,
2728 _ForwardIterator2 __last2,
......@@ -34,18 +35,16 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator1 __find_first_of_ce(_ForwardItera
3435}
3536
3637template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
37_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1
38_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1
3839find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
3940 _ForwardIterator2 __last2, _BinaryPredicate __pred) {
4041 return _VSTD::__find_first_of_ce(__first1, __last1, __first2, __last2, __pred);
4142}
4243
4344template <class _ForwardIterator1, class _ForwardIterator2>
44_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 find_first_of(
45_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of(
4546 _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
46 typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
47 typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
48 return _VSTD::__find_first_of_ce(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
47 return std::__find_first_of_ce(__first1, __last1, __first2, __last2, __equal_to());
4948}
5049
5150_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/find_if.h+1-1
......@@ -19,7 +19,7 @@
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
2121template <class _InputIterator, class _Predicate>
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
2323find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
2424 for (; __first != __last; ++__first)
2525 if (__pred(*__first))
lib/libcxx/include/__algorithm/find_if_not.h+1-1
......@@ -19,7 +19,7 @@
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
2121template <class _InputIterator, class _Predicate>
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
2323find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
2424 for (; __first != __last; ++__first)
2525 if (!__pred(*__first))
lib/libcxx/include/__algorithm/for_each.h+1-1
......@@ -19,7 +19,7 @@
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
2121template <class _InputIterator, class _Function>
22inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Function for_each(_InputIterator __first,
22inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _Function for_each(_InputIterator __first,
2323 _InputIterator __last,
2424 _Function __f) {
2525 for (; __first != __last; ++__first)
lib/libcxx/include/__algorithm/for_each_n.h+2-1
......@@ -11,6 +11,7 @@
1111#define _LIBCPP___ALGORITHM_FOR_EACH_N_H
1212
1313#include <__config>
14#include <__utility/convert_to_integral.h>
1415#include <type_traits>
1516
1617#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -22,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2223#if _LIBCPP_STD_VER > 14
2324
2425template <class _InputIterator, class _Size, class _Function>
25inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator for_each_n(_InputIterator __first,
26inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator for_each_n(_InputIterator __first,
2627 _Size __orig_n,
2728 _Function __f) {
2829 typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
lib/libcxx/include/__algorithm/generate.h+1-1
......@@ -18,7 +18,7 @@
1818_LIBCPP_BEGIN_NAMESPACE_STD
1919
2020template <class _ForwardIterator, class _Generator>
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2222void
2323generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen)
2424{
lib/libcxx/include/__algorithm/generate_n.h+2-1
......@@ -10,6 +10,7 @@
1010#define _LIBCPP___ALGORITHM_GENERATE_N_H
1111
1212#include <__config>
13#include <__utility/convert_to_integral.h>
1314#include <type_traits>
1415
1516#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -19,7 +20,7 @@
1920_LIBCPP_BEGIN_NAMESPACE_STD
2021
2122template <class _OutputIterator, class _Size, class _Generator>
22inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
23inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2324_OutputIterator
2425generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen)
2526{
lib/libcxx/include/__algorithm/half_positive.h+1-1
......@@ -29,7 +29,7 @@ typename enable_if
2929>::type
3030__half_positive(_Integral __value)
3131{
32 return static_cast<_Integral>(static_cast<typename make_unsigned<_Integral>::type>(__value) / 2);
32 return static_cast<_Integral>(static_cast<__make_unsigned_t<_Integral> >(__value) / 2);
3333}
3434
3535template <typename _Tp>
lib/libcxx/include/__algorithm/in_found_result.h+2-2
......@@ -18,7 +18,7 @@
1818# pragma GCC system_header
1919#endif
2020
21#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
21#if _LIBCPP_STD_VER > 17
2222
2323_LIBCPP_BEGIN_NAMESPACE_STD
2424
......@@ -44,6 +44,6 @@ struct in_found_result {
4444
4545_LIBCPP_END_NAMESPACE_STD
4646
47#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
47#endif // _LIBCPP_STD_VER > 17
4848
4949#endif // _LIBCPP___ALGORITHM_IN_FOUND_RESULT_H
lib/libcxx/include/__algorithm/in_fun_result.h+2-2
......@@ -20,7 +20,7 @@
2020
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
23#if _LIBCPP_STD_VER > 17
2424
2525namespace ranges {
2626template <class _InIter1, class _Func1>
......@@ -42,7 +42,7 @@ struct in_fun_result {
4242};
4343} // namespace ranges
4444
45#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
45#endif // _LIBCPP_STD_VER > 17
4646
4747_LIBCPP_END_NAMESPACE_STD
4848
lib/libcxx/include/__algorithm/in_in_out_result.h+2-2
......@@ -20,7 +20,7 @@
2020
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
23#if _LIBCPP_STD_VER > 17
2424
2525namespace ranges {
2626
......@@ -49,7 +49,7 @@ struct in_in_out_result {
4949
5050} // namespace ranges
5151
52#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
52#endif // _LIBCPP_STD_VER > 17
5353
5454_LIBCPP_END_NAMESPACE_STD
5555
lib/libcxx/include/__algorithm/in_in_result.h+2-2
......@@ -20,7 +20,7 @@
2020
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
23#if _LIBCPP_STD_VER > 17
2424
2525namespace ranges {
2626
......@@ -46,7 +46,7 @@ struct in_in_result {
4646
4747} // namespace ranges
4848
49#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
49#endif // _LIBCPP_STD_VER > 17
5050
5151_LIBCPP_END_NAMESPACE_STD
5252
lib/libcxx/include/__algorithm/in_out_out_result.h+2-2
......@@ -20,7 +20,7 @@
2020
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
23#if _LIBCPP_STD_VER > 17
2424
2525namespace ranges {
2626template <class _InIter1, class _OutIter1, class _OutIter2>
......@@ -47,7 +47,7 @@ struct in_out_out_result {
4747};
4848} // namespace ranges
4949
50#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
50#endif // _LIBCPP_STD_VER > 17
5151
5252_LIBCPP_END_NAMESPACE_STD
5353
lib/libcxx/include/__algorithm/in_out_result.h+2-2
......@@ -20,7 +20,7 @@
2020
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
23#if _LIBCPP_STD_VER > 17
2424
2525namespace ranges {
2626
......@@ -46,7 +46,7 @@ struct in_out_result {
4646
4747} // namespace ranges
4848
49#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
49#endif // _LIBCPP_STD_VER > 17
5050
5151_LIBCPP_END_NAMESPACE_STD
5252
lib/libcxx/include/__algorithm/includes.h+10-6
......@@ -25,7 +25,7 @@
2525_LIBCPP_BEGIN_NAMESPACE_STD
2626
2727template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Comp, class _Proj1, class _Proj2>
28_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
28_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
2929__includes(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
3030 _Comp&& __comp, _Proj1&& __proj1, _Proj2&& __proj2) {
3131 for (; __first2 != __last2; ++__first1) {
......@@ -39,7 +39,7 @@ __includes(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
3939}
4040
4141template <class _InputIterator1, class _InputIterator2, class _Compare>
42_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool includes(
42_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool includes(
4343 _InputIterator1 __first1,
4444 _InputIterator1 __last1,
4545 _InputIterator2 __first2,
......@@ -48,14 +48,18 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4848 static_assert(__is_callable<_Compare, decltype(*__first1), decltype(*__first2)>::value,
4949 "Comparator has to be callable");
5050
51 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
5251 return std::__includes(
53 std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2),
54 static_cast<_Comp_ref>(__comp), __identity(), __identity());
52 std::move(__first1),
53 std::move(__last1),
54 std::move(__first2),
55 std::move(__last2),
56 static_cast<__comp_ref_type<_Compare> >(__comp),
57 __identity(),
58 __identity());
5559}
5660
5761template <class _InputIterator1, class _InputIterator2>
58_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
62_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
5963includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
6064 return std::includes(
6165 std::move(__first1),
lib/libcxx/include/__algorithm/inplace_merge.h+8-3
......@@ -23,7 +23,11 @@
2323#include <__iterator/distance.h>
2424#include <__iterator/iterator_traits.h>
2525#include <__iterator/reverse_iterator.h>
26#include <memory>
26#include <__memory/destruct_n.h>
27#include <__memory/temporary_buffer.h>
28#include <__memory/unique_ptr.h>
29#include <__utility/pair.h>
30#include <new>
2731
2832#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2933# pragma GCC system_header
......@@ -56,6 +60,7 @@ public:
5660
5761template <class _AlgPolicy, class _Compare, class _InputIterator1, class _Sent1,
5862 class _InputIterator2, class _Sent2, class _OutputIterator>
63_LIBCPP_HIDE_FROM_ABI
5964void __half_inplace_merge(_InputIterator1 __first1, _Sent1 __last1,
6065 _InputIterator2 __first2, _Sent2 __last2,
6166 _OutputIterator __result, _Compare&& __comp)
......@@ -83,6 +88,7 @@ void __half_inplace_merge(_InputIterator1 __first1, _Sent1 __last1,
8388}
8489
8590template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
91_LIBCPP_HIDE_FROM_ABI
8692void __buffered_inplace_merge(
8793 _BidirectionalIterator __first,
8894 _BidirectionalIterator __middle,
......@@ -231,9 +237,8 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
231237template <class _BidirectionalIterator, class _Compare>
232238inline _LIBCPP_HIDE_FROM_ABI void inplace_merge(
233239 _BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare __comp) {
234 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
235240 std::__inplace_merge<_ClassicAlgPolicy>(
236 std::move(__first), std::move(__middle), std::move(__last), static_cast<_Comp_ref>(__comp));
241 std::move(__first), std::move(__middle), std::move(__last), static_cast<__comp_ref_type<_Compare> >(__comp));
237242}
238243
239244template <class _BidirectionalIterator>
lib/libcxx/include/__algorithm/is_heap.h+3-4
......@@ -23,17 +23,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323
2424template <class _RandomAccessIterator, class _Compare>
2525_LIBCPP_NODISCARD_EXT inline
26_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
26_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2727bool
2828is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
2929{
30 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
31 return std::__is_heap_until(__first, __last, static_cast<_Comp_ref>(__comp)) == __last;
30 return std::__is_heap_until(__first, __last, static_cast<__comp_ref_type<_Compare> >(__comp)) == __last;
3231}
3332
3433template<class _RandomAccessIterator>
3534_LIBCPP_NODISCARD_EXT inline
36_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
35_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
3736bool
3837is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
3938{
lib/libcxx/include/__algorithm/is_heap_until.h+4-5
......@@ -21,7 +21,7 @@
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
2323template <class _Compare, class _RandomAccessIterator>
24_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
24_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator
2525__is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp)
2626{
2727 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
......@@ -48,15 +48,14 @@ __is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co
4848}
4949
5050template <class _RandomAccessIterator, class _Compare>
51_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
51_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator
5252is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
5353{
54 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
55 return std::__is_heap_until(__first, __last, static_cast<_Comp_ref>(__comp));
54 return std::__is_heap_until(__first, __last, static_cast<__comp_ref_type<_Compare> >(__comp));
5655}
5756
5857template<class _RandomAccessIterator>
59_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
58_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator
6059is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last)
6160{
6261 return _VSTD::__is_heap_until(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
lib/libcxx/include/__algorithm/is_partitioned.h+1-1
......@@ -18,7 +18,7 @@
1818_LIBCPP_BEGIN_NAMESPACE_STD
1919
2020template <class _InputIterator, class _Predicate>
21_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
21_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
2222is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred)
2323{
2424 for (; __first != __last; ++__first)
lib/libcxx/include/__algorithm/is_permutation.h+18-19
......@@ -55,7 +55,7 @@ struct _ConstTimeDistance<_Iter1, _Iter1, _Iter2, _Iter2, __enable_if_t<
5555template <class _AlgPolicy,
5656 class _Iter1, class _Sent1, class _Iter2, class _Sent2,
5757 class _Proj1, class _Proj2, class _Pred>
58_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
58_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
5959__is_permutation_impl(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
6060 _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2) {
6161 using _D1 = __iter_diff_t<_Iter1>;
......@@ -94,7 +94,7 @@ __is_permutation_impl(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 _
9494
9595// 2+1 iterators, predicate. Not used by range algorithms.
9696template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _BinaryPredicate>
97_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
97_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
9898__is_permutation(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2,
9999 _BinaryPredicate&& __pred) {
100100 // Shorten sequences as much as possible by lopping of any equal prefix.
......@@ -122,7 +122,7 @@ __is_permutation(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterato
122122template <class _AlgPolicy,
123123 class _Iter1, class _Sent1, class _Iter2, class _Sent2,
124124 class _Proj1, class _Proj2, class _Pred>
125_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
125_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
126126__is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
127127 _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2,
128128 /*_ConstTimeDistance=*/false_type) {
......@@ -156,7 +156,7 @@ __is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last
156156template <class _AlgPolicy,
157157 class _Iter1, class _Sent1, class _Iter2, class _Sent2,
158158 class _Proj1, class _Proj2, class _Pred>
159_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
159_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
160160__is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
161161 _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2,
162162 /*_ConstTimeDistance=*/true_type) {
......@@ -172,7 +172,7 @@ __is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last
172172template <class _AlgPolicy,
173173 class _Iter1, class _Sent1, class _Iter2, class _Sent2,
174174 class _Proj1, class _Proj2, class _Pred>
175_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
175_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
176176__is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
177177 _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2) {
178178 return std::__is_permutation<_AlgPolicy>(
......@@ -185,7 +185,7 @@ __is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last
185185
186186// 2+1 iterators, predicate
187187template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
188_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
188_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
189189is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
190190 _BinaryPredicate __pred) {
191191 static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value,
......@@ -197,31 +197,30 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIt
197197
198198// 2+1 iterators
199199template <class _ForwardIterator1, class _ForwardIterator2>
200_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
200_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
201201is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {
202 using __v1 = __iter_value_type<_ForwardIterator1>;
203 using __v2 = __iter_value_type<_ForwardIterator2>;
204 return std::is_permutation(__first1, __last1, __first2, __equal_to<__v1, __v2>());
202 return std::is_permutation(__first1, __last1, __first2, __equal_to());
205203}
206204
207205#if _LIBCPP_STD_VER > 11
208206
209207// 2+2 iterators
210208template <class _ForwardIterator1, class _ForwardIterator2>
211_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
212is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
213 _ForwardIterator2 __last2) {
214 using __v1 = __iter_value_type<_ForwardIterator1>;
215 using __v2 = __iter_value_type<_ForwardIterator2>;
216
209_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation(
210 _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
217211 return std::__is_permutation<_ClassicAlgPolicy>(
218 std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2),
219 __equal_to<__v1, __v2>(), __identity(), __identity());
212 std::move(__first1),
213 std::move(__last1),
214 std::move(__first2),
215 std::move(__last2),
216 __equal_to(),
217 __identity(),
218 __identity());
220219}
221220
222221// 2+2 iterators, predicate
223222template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
224_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
223_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
225224is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
226225 _ForwardIterator2 __last2, _BinaryPredicate __pred) {
227226 static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value,
lib/libcxx/include/__algorithm/is_sorted.h+3-4
......@@ -23,17 +23,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323
2424template <class _ForwardIterator, class _Compare>
2525_LIBCPP_NODISCARD_EXT inline
26_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
26_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2727bool
2828is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
2929{
30 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
31 return _VSTD::__is_sorted_until<_Comp_ref>(__first, __last, __comp) == __last;
30 return _VSTD::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp) == __last;
3231}
3332
3433template<class _ForwardIterator>
3534_LIBCPP_NODISCARD_EXT inline
36_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
35_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
3736bool
3837is_sorted(_ForwardIterator __first, _ForwardIterator __last)
3938{
lib/libcxx/include/__algorithm/is_sorted_until.h+4-5
......@@ -21,7 +21,7 @@
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
2323template <class _Compare, class _ForwardIterator>
24_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
24_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
2525__is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
2626{
2727 if (__first != __last)
......@@ -38,15 +38,14 @@ __is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __
3838}
3939
4040template <class _ForwardIterator, class _Compare>
41_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
41_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
4242is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
4343{
44 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
45 return _VSTD::__is_sorted_until<_Comp_ref>(__first, __last, __comp);
44 return _VSTD::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp);
4645}
4746
4847template<class _ForwardIterator>
49_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
48_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
5049is_sorted_until(_ForwardIterator __first, _ForwardIterator __last)
5150{
5251 return _VSTD::is_sorted_until(__first, __last, __less<typename iterator_traits<_ForwardIterator>::value_type>());
lib/libcxx/include/__algorithm/iter_swap.h+2-2
......@@ -20,10 +20,10 @@
2020_LIBCPP_BEGIN_NAMESPACE_STD
2121
2222template <class _ForwardIterator1, class _ForwardIterator2>
23inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void iter_swap(_ForwardIterator1 __a,
23inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void iter_swap(_ForwardIterator1 __a,
2424 _ForwardIterator2 __b)
2525 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
26 _NOEXCEPT_(_NOEXCEPT_(swap(*declval<_ForwardIterator1>(), *declval<_ForwardIterator2>()))) {
26 _NOEXCEPT_(_NOEXCEPT_(swap(*std::declval<_ForwardIterator1>(), *std::declval<_ForwardIterator2>()))) {
2727 swap(*__a, *__b);
2828}
2929
lib/libcxx/include/__algorithm/iterator_operations.h+20-17
......@@ -21,10 +21,13 @@
2121#include <__iterator/next.h>
2222#include <__iterator/prev.h>
2323#include <__iterator/readable_traits.h>
24#include <__type_traits/enable_if.h>
25#include <__type_traits/is_reference.h>
26#include <__type_traits/is_same.h>
27#include <__type_traits/remove_cvref.h>
2428#include <__utility/declval.h>
2529#include <__utility/forward.h>
2630#include <__utility/move.h>
27#include <type_traits>
2831
2932#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3033# pragma GCC system_header
......@@ -34,7 +37,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3437
3538template <class _AlgPolicy> struct _IterOps;
3639
37#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
40#if _LIBCPP_STD_VER > 17
3841struct _RangeAlgPolicy {};
3942
4043template <>
......@@ -76,14 +79,14 @@ struct _IterOps<_ClassicAlgPolicy> {
7679
7780 // advance
7881 template <class _Iter, class _Distance>
79 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
82 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
8083 static void advance(_Iter& __iter, _Distance __count) {
8184 std::advance(__iter, __count);
8285 }
8386
8487 // distance
8588 template <class _Iter>
86 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
89 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
8790 static typename iterator_traits<_Iter>::difference_type distance(_Iter __first, _Iter __last) {
8891 return std::distance(__first, __last);
8992 }
......@@ -95,9 +98,9 @@ struct _IterOps<_ClassicAlgPolicy> {
9598 using __move_t = decltype(std::move(*std::declval<_Iter&>()));
9699
97100 template <class _Iter>
98 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
101 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
99102 static void __validate_iter_reference() {
100 static_assert(is_same<__deref_t<_Iter>, typename iterator_traits<__uncvref_t<_Iter> >::reference>::value,
103 static_assert(is_same<__deref_t<_Iter>, typename iterator_traits<__remove_cvref_t<_Iter> >::reference>::value,
101104 "It looks like your iterator's `iterator_traits<It>::reference` does not match the return type of "
102105 "dereferencing the iterator, i.e., calling `*it`. This is undefined behavior according to [input.iterators] "
103106 "and can lead to dangling reference issues at runtime, so we are flagging this.");
......@@ -105,7 +108,7 @@ struct _IterOps<_ClassicAlgPolicy> {
105108
106109 // iter_move
107110 template <class _Iter>
108 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static
111 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static
109112 // If the result of dereferencing `_Iter` is a reference type, deduce the result of calling `std::move` on it. Note
110113 // that the C++03 mode doesn't support `decltype(auto)` as the return type.
111114 __enable_if_t<
......@@ -118,7 +121,7 @@ struct _IterOps<_ClassicAlgPolicy> {
118121 }
119122
120123 template <class _Iter>
121 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static
124 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static
122125 // If the result of dereferencing `_Iter` is a value type, deduce the return value of this function to also be a
123126 // value -- otherwise, after `operator*` returns a temporary, this function would return a dangling reference to that
124127 // temporary. Note that the C++03 mode doesn't support `auto` as the return type.
......@@ -133,35 +136,35 @@ struct _IterOps<_ClassicAlgPolicy> {
133136
134137 // iter_swap
135138 template <class _Iter1, class _Iter2>
136 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
139 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
137140 static void iter_swap(_Iter1&& __a, _Iter2&& __b) {
138141 std::iter_swap(std::forward<_Iter1>(__a), std::forward<_Iter2>(__b));
139142 }
140143
141144 // next
142145 template <class _Iterator>
143 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11
146 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX14
144147 _Iterator next(_Iterator, _Iterator __last) {
145148 return __last;
146149 }
147150
148151 template <class _Iter>
149 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11
150 __uncvref_t<_Iter> next(_Iter&& __it,
151 typename iterator_traits<__uncvref_t<_Iter> >::difference_type __n = 1) {
152 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX14
153 __remove_cvref_t<_Iter> next(_Iter&& __it,
154 typename iterator_traits<__remove_cvref_t<_Iter> >::difference_type __n = 1) {
152155 return std::next(std::forward<_Iter>(__it), __n);
153156 }
154157
155158 // prev
156159 template <class _Iter>
157 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11
158 __uncvref_t<_Iter> prev(_Iter&& __iter,
159 typename iterator_traits<__uncvref_t<_Iter> >::difference_type __n = 1) {
160 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX14
161 __remove_cvref_t<_Iter> prev(_Iter&& __iter,
162 typename iterator_traits<__remove_cvref_t<_Iter> >::difference_type __n = 1) {
160163 return std::prev(std::forward<_Iter>(__iter), __n);
161164 }
162165
163166 template <class _Iter>
164 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11
167 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX14
165168 void __advance_to(_Iter& __first, _Iter __last) {
166169 __first = __last;
167170 }
lib/libcxx/include/__algorithm/lexicographical_compare.h+4-5
......@@ -21,7 +21,7 @@
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
2323template <class _Compare, class _InputIterator1, class _InputIterator2>
24_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
24_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
2525__lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
2626 _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)
2727{
......@@ -37,18 +37,17 @@ __lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
3737
3838template <class _InputIterator1, class _InputIterator2, class _Compare>
3939_LIBCPP_NODISCARD_EXT inline
40_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
40_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
4141bool
4242lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
4343 _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)
4444{
45 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
46 return _VSTD::__lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __comp);
45 return _VSTD::__lexicographical_compare<__comp_ref_type<_Compare> >(__first1, __last1, __first2, __last2, __comp);
4746}
4847
4948template <class _InputIterator1, class _InputIterator2>
5049_LIBCPP_NODISCARD_EXT inline
51_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
50_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
5251bool
5352lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
5453 _InputIterator2 __first2, _InputIterator2 __last2)
lib/libcxx/include/__algorithm/lower_bound.h+3-3
......@@ -29,7 +29,7 @@
2929_LIBCPP_BEGIN_NAMESPACE_STD
3030
3131template <class _AlgPolicy, class _Iter, class _Sent, class _Type, class _Proj, class _Comp>
32_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
32_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
3333_Iter __lower_bound_impl(_Iter __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) {
3434 auto __len = _IterOps<_AlgPolicy>::distance(__first, __last);
3535
......@@ -48,7 +48,7 @@ _Iter __lower_bound_impl(_Iter __first, _Sent __last, const _Type& __value, _Com
4848}
4949
5050template <class _ForwardIterator, class _Tp, class _Compare>
51_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
51_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
5252_ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
5353 static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value,
5454 "The comparator has to be callable");
......@@ -57,7 +57,7 @@ _ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last,
5757}
5858
5959template <class _ForwardIterator, class _Tp>
60_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
60_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
6161_ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
6262 return std::lower_bound(__first, __last, __value,
6363 __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
lib/libcxx/include/__algorithm/make_heap.h+4-5
......@@ -24,10 +24,9 @@
2424_LIBCPP_BEGIN_NAMESPACE_STD
2525
2626template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
27inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
27inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
2828void __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp) {
29 using _CompRef = typename __comp_ref_type<_Compare>::type;
30 _CompRef __comp_ref = __comp;
29 __comp_ref_type<_Compare> __comp_ref = __comp;
3130
3231 using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;
3332 difference_type __n = __last - __first;
......@@ -40,13 +39,13 @@ void __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _C
4039}
4140
4241template <class _RandomAccessIterator, class _Compare>
43inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
42inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
4443void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
4544 std::__make_heap<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp);
4645}
4746
4847template <class _RandomAccessIterator>
49inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
48inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
5049void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {
5150 std::make_heap(std::move(__first), std::move(__last),
5251 __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
lib/libcxx/include/__algorithm/make_projected.h+2-2
......@@ -93,7 +93,7 @@ __make_projected(_Pred& __pred, _Proj&) {
9393
9494_LIBCPP_END_NAMESPACE_STD
9595
96#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
96#if _LIBCPP_STD_VER > 17
9797
9898_LIBCPP_BEGIN_NAMESPACE_STD
9999
......@@ -121,6 +121,6 @@ decltype(auto) __make_projected_comp(_Comp& __comp, _Proj1& __proj1, _Proj2& __p
121121
122122_LIBCPP_END_NAMESPACE_STD
123123
124#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
124#endif // _LIBCPP_STD_VER > 17
125125
126126#endif // _LIBCPP___ALGORITHM_MAKE_PROJECTED_H
lib/libcxx/include/__algorithm/max.h+5-6
......@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2626
2727template <class _Tp, class _Compare>
2828_LIBCPP_NODISCARD_EXT inline
29_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
29_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
3030const _Tp&
3131max(const _Tp& __a, const _Tp& __b, _Compare __comp)
3232{
......@@ -35,7 +35,7 @@ max(const _Tp& __a, const _Tp& __b, _Compare __comp)
3535
3636template <class _Tp>
3737_LIBCPP_NODISCARD_EXT inline
38_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
38_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
3939const _Tp&
4040max(const _Tp& __a, const _Tp& __b)
4141{
......@@ -46,17 +46,16 @@ max(const _Tp& __a, const _Tp& __b)
4646
4747template<class _Tp, class _Compare>
4848_LIBCPP_NODISCARD_EXT inline
49_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
49_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
5050_Tp
5151max(initializer_list<_Tp> __t, _Compare __comp)
5252{
53 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
54 return *_VSTD::__max_element<_Comp_ref>(__t.begin(), __t.end(), __comp);
53 return *_VSTD::__max_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp);
5554}
5655
5756template<class _Tp>
5857_LIBCPP_NODISCARD_EXT inline
59_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
58_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
6059_Tp
6160max(initializer_list<_Tp> __t)
6261{
lib/libcxx/include/__algorithm/max_element.h+4-5
......@@ -21,7 +21,7 @@
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
2323template <class _Compare, class _ForwardIterator>
24inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
24inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
2525__max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
2626{
2727 static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
......@@ -37,16 +37,15 @@ __max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp
3737}
3838
3939template <class _ForwardIterator, class _Compare>
40_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
40_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
4141max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
4242{
43 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
44 return _VSTD::__max_element<_Comp_ref>(__first, __last, __comp);
43 return _VSTD::__max_element<__comp_ref_type<_Compare> >(__first, __last, __comp);
4544}
4645
4746
4847template <class _ForwardIterator>
49_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
48_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
5049max_element(_ForwardIterator __first, _ForwardIterator __last)
5150{
5251 return _VSTD::max_element(__first, __last,
lib/libcxx/include/__algorithm/merge.h+4-5
......@@ -22,7 +22,7 @@
2222_LIBCPP_BEGIN_NAMESPACE_STD
2323
2424template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
25_LIBCPP_CONSTEXPR_AFTER_CXX17
25_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2626_OutputIterator
2727__merge(_InputIterator1 __first1, _InputIterator1 __last1,
2828 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
......@@ -46,17 +46,16 @@ __merge(_InputIterator1 __first1, _InputIterator1 __last1,
4646}
4747
4848template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
49inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
49inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
5050_OutputIterator
5151merge(_InputIterator1 __first1, _InputIterator1 __last1,
5252 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
5353{
54 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
55 return _VSTD::__merge<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
54 return _VSTD::__merge<__comp_ref_type<_Compare> >(__first1, __last1, __first2, __last2, __result, __comp);
5655}
5756
5857template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
59inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
58inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
6059_OutputIterator
6160merge(_InputIterator1 __first1, _InputIterator1 __last1,
6261 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
lib/libcxx/include/__algorithm/min.h+5-6
......@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2626
2727template <class _Tp, class _Compare>
2828_LIBCPP_NODISCARD_EXT inline
29_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
29_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
3030const _Tp&
3131min(const _Tp& __a, const _Tp& __b, _Compare __comp)
3232{
......@@ -35,7 +35,7 @@ min(const _Tp& __a, const _Tp& __b, _Compare __comp)
3535
3636template <class _Tp>
3737_LIBCPP_NODISCARD_EXT inline
38_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
38_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
3939const _Tp&
4040min(const _Tp& __a, const _Tp& __b)
4141{
......@@ -46,17 +46,16 @@ min(const _Tp& __a, const _Tp& __b)
4646
4747template<class _Tp, class _Compare>
4848_LIBCPP_NODISCARD_EXT inline
49_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
49_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
5050_Tp
5151min(initializer_list<_Tp> __t, _Compare __comp)
5252{
53 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
54 return *_VSTD::__min_element<_Comp_ref>(__t.begin(), __t.end(), __comp);
53 return *_VSTD::__min_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp);
5554}
5655
5756template<class _Tp>
5857_LIBCPP_NODISCARD_EXT inline
59_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
58_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
6059_Tp
6160min(initializer_list<_Tp> __t)
6261{
lib/libcxx/include/__algorithm/min_element.h+5-6
......@@ -25,7 +25,7 @@
2525_LIBCPP_BEGIN_NAMESPACE_STD
2626
2727template <class _Comp, class _Iter, class _Sent, class _Proj>
28inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
28inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
2929_Iter __min_element(_Iter __first, _Sent __last, _Comp __comp, _Proj& __proj) {
3030 if (__first == __last)
3131 return __first;
......@@ -39,14 +39,14 @@ _Iter __min_element(_Iter __first, _Sent __last, _Comp __comp, _Proj& __proj) {
3939}
4040
4141template <class _Comp, class _Iter, class _Sent>
42_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
42_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
4343_Iter __min_element(_Iter __first, _Sent __last, _Comp __comp) {
4444 auto __proj = __identity();
4545 return std::__min_element<_Comp>(std::move(__first), std::move(__last), __comp, __proj);
4646}
4747
4848template <class _ForwardIterator, class _Compare>
49_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
49_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
5050min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
5151{
5252 static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
......@@ -54,12 +54,11 @@ min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
5454 static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__first)>::value,
5555 "The comparator has to be callable");
5656
57 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
58 return std::__min_element<_Comp_ref>(std::move(__first), std::move(__last), __comp);
57 return std::__min_element<__comp_ref_type<_Compare> >(std::move(__first), std::move(__last), __comp);
5958}
6059
6160template <class _ForwardIterator>
62_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
61_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
6362min_element(_ForwardIterator __first, _ForwardIterator __last)
6463{
6564 return _VSTD::min_element(__first, __last,
lib/libcxx/include/__algorithm/min_max_result.h+2-2
......@@ -23,7 +23,7 @@ _LIBCPP_PUSH_MACROS
2323
2424_LIBCPP_BEGIN_NAMESPACE_STD
2525
26#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
26#if _LIBCPP_STD_VER > 17
2727
2828namespace ranges {
2929
......@@ -47,7 +47,7 @@ struct min_max_result {
4747
4848} // namespace ranges
4949
50#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
50#endif // _LIBCPP_STD_VER > 17
5151
5252_LIBCPP_END_NAMESPACE_STD
5353
lib/libcxx/include/__algorithm/minmax.h+4-4
......@@ -25,7 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2525
2626template<class _Tp, class _Compare>
2727_LIBCPP_NODISCARD_EXT inline
28_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
28_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
2929pair<const _Tp&, const _Tp&>
3030minmax(const _Tp& __a, const _Tp& __b, _Compare __comp)
3131{
......@@ -35,7 +35,7 @@ minmax(const _Tp& __a, const _Tp& __b, _Compare __comp)
3535
3636template<class _Tp>
3737_LIBCPP_NODISCARD_EXT inline
38_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
38_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
3939pair<const _Tp&, const _Tp&>
4040minmax(const _Tp& __a, const _Tp& __b)
4141{
......@@ -45,7 +45,7 @@ minmax(const _Tp& __a, const _Tp& __b)
4545#ifndef _LIBCPP_CXX03_LANG
4646
4747template<class _Tp, class _Compare>
48_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
48_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
4949pair<_Tp, _Tp> minmax(initializer_list<_Tp> __t, _Compare __comp) {
5050 static_assert(__is_callable<_Compare, _Tp, _Tp>::value, "The comparator has to be callable");
5151 __identity __proj;
......@@ -55,7 +55,7 @@ pair<_Tp, _Tp> minmax(initializer_list<_Tp> __t, _Compare __comp) {
5555
5656template<class _Tp>
5757_LIBCPP_NODISCARD_EXT inline
58_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
58_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
5959pair<_Tp, _Tp>
6060minmax(initializer_list<_Tp> __t)
6161{
lib/libcxx/include/__algorithm/minmax_element.h+4-4
......@@ -32,14 +32,14 @@ public:
3232 _MinmaxElementLessFunc(_Comp& __comp, _Proj& __proj) : __comp_(__comp), __proj_(__proj) {}
3333
3434 template <class _Iter>
35 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
35 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
3636 bool operator()(_Iter& __it1, _Iter& __it2) {
3737 return std::__invoke(__comp_, std::__invoke(__proj_, *__it1), std::__invoke(__proj_, *__it2));
3838 }
3939};
4040
4141template <class _Iter, class _Sent, class _Proj, class _Comp>
42_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
42_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
4343pair<_Iter, _Iter> __minmax_element_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
4444 auto __less = _MinmaxElementLessFunc<_Comp, _Proj>(__comp, __proj);
4545
......@@ -79,7 +79,7 @@ pair<_Iter, _Iter> __minmax_element_impl(_Iter __first, _Sent __last, _Comp& __c
7979}
8080
8181template <class _ForwardIterator, class _Compare>
82_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX11
82_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
8383pair<_ForwardIterator, _ForwardIterator>
8484minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {
8585 static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
......@@ -91,7 +91,7 @@ minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __com
9191}
9292
9393template <class _ForwardIterator>
94_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
94_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
9595pair<_ForwardIterator, _ForwardIterator> minmax_element(_ForwardIterator __first, _ForwardIterator __last) {
9696 return std::minmax_element(__first, __last, __less<typename iterator_traits<_ForwardIterator>::value_type>());
9797}
lib/libcxx/include/__algorithm/mismatch.h+6-10
......@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323
2424template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
2525_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
26 _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>
26 _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
2727 mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) {
2828 for (; __first1 != __last1; ++__first1, (void)++__first2)
2929 if (!__pred(*__first1, *__first2))
......@@ -33,17 +33,15 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
3333
3434template <class _InputIterator1, class _InputIterator2>
3535_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
36 _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>
36 _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
3737 mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) {
38 typedef typename iterator_traits<_InputIterator1>::value_type __v1;
39 typedef typename iterator_traits<_InputIterator2>::value_type __v2;
40 return _VSTD::mismatch(__first1, __last1, __first2, __equal_to<__v1, __v2>());
38 return std::mismatch(__first1, __last1, __first2, __equal_to());
4139}
4240
4341#if _LIBCPP_STD_VER > 11
4442template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
4543_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
46 _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>
44 _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
4745 mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
4846 _BinaryPredicate __pred) {
4947 for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2)
......@@ -54,11 +52,9 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
5452
5553template <class _InputIterator1, class _InputIterator2>
5654_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
57 _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>
55 _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
5856 mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
59 typedef typename iterator_traits<_InputIterator1>::value_type __v1;
60 typedef typename iterator_traits<_InputIterator2>::value_type __v2;
61 return _VSTD::mismatch(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
57 return std::mismatch(__first1, __last1, __first2, __last2, __equal_to());
6258}
6359#endif
6460
lib/libcxx/include/__algorithm/move.h+93-82
......@@ -9,111 +9,122 @@
99#ifndef _LIBCPP___ALGORITHM_MOVE_H
1010#define _LIBCPP___ALGORITHM_MOVE_H
1111
12#include <__algorithm/copy_move_common.h>
1213#include <__algorithm/iterator_operations.h>
13#include <__algorithm/unwrap_iter.h>
14#include <__algorithm/min.h>
1415#include <__config>
15#include <__iterator/iterator_traits.h>
16#include <__iterator/reverse_iterator.h>
16#include <__iterator/segmented_iterator.h>
17#include <__type_traits/common_type.h>
18#include <__type_traits/is_copy_constructible.h>
1719#include <__utility/move.h>
1820#include <__utility/pair.h>
19#include <cstring>
20#include <type_traits>
2121
2222#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2323# pragma GCC system_header
2424#endif
2525
26_LIBCPP_BEGIN_NAMESPACE_STD
26_LIBCPP_PUSH_MACROS
27#include <__undef_macros>
2728
28// move
29_LIBCPP_BEGIN_NAMESPACE_STD
2930
3031template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>
31inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
32pair<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) {
33 while (__first != __last) {
34 *__result = _IterOps<_AlgPolicy>::__iter_move(__first);
35 ++__first;
36 ++__result;
32inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
33__move(_InIter __first, _Sent __last, _OutIter __result);
34
35template <class _AlgPolicy>
36struct __move_loop {
37 template <class _InIter, class _Sent, class _OutIter>
38 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
39 operator()(_InIter __first, _Sent __last, _OutIter __result) const {
40 while (__first != __last) {
41 *__result = _IterOps<_AlgPolicy>::__iter_move(__first);
42 ++__first;
43 ++__result;
44 }
45 return std::make_pair(std::move(__first), std::move(__result));
3746 }
38 return std::make_pair(std::move(__first), std::move(__result));
39}
40
41template <class _AlgPolicy,
42 class _InType,
43 class _OutType,
44 class = __enable_if_t<is_same<typename remove_const<_InType>::type, _OutType>::value
45 && is_trivially_move_assignable<_OutType>::value> >
46inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
47pair<_InType*, _OutType*> __move_impl(_InType* __first, _InType* __last, _OutType* __result) {
48 if (__libcpp_is_constant_evaluated()
49// TODO: Remove this once GCC supports __builtin_memmove during constant evaluation
50#ifndef _LIBCPP_COMPILER_GCC
51 && !is_trivially_copyable<_InType>::value
52#endif
53 )
54 return std::__move_impl<_AlgPolicy, _InType*, _InType*, _OutType*>(__first, __last, __result);
55 const size_t __n = static_cast<size_t>(__last - __first);
56 ::__builtin_memmove(__result, __first, __n * sizeof(_OutType));
57 return std::make_pair(__first + __n, __result + __n);
58}
5947
60template <class>
61struct __is_trivially_move_assignable_unwrapped_impl : false_type {};
62
63template <class _Type>
64struct __is_trivially_move_assignable_unwrapped_impl<_Type*> : is_trivially_move_assignable<_Type> {};
65
66template <class _Iter>
67struct __is_trivially_move_assignable_unwrapped
68 : __is_trivially_move_assignable_unwrapped_impl<decltype(std::__unwrap_iter<_Iter>(std::declval<_Iter>()))> {};
69
70template <class _AlgPolicy,
71 class _InIter,
72 class _OutIter,
73 __enable_if_t<is_same<typename remove_const<typename iterator_traits<_InIter>::value_type>::type,
74 typename iterator_traits<_OutIter>::value_type>::value
75 && __is_cpp17_contiguous_iterator<_InIter>::value
76 && __is_cpp17_contiguous_iterator<_OutIter>::value
77 && is_trivially_move_assignable<__iter_value_type<_OutIter> >::value, int> = 0>
78inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
79pair<reverse_iterator<_InIter>, reverse_iterator<_OutIter> >
80__move_impl(reverse_iterator<_InIter> __first,
81 reverse_iterator<_InIter> __last,
82 reverse_iterator<_OutIter> __result) {
83 auto __first_base = std::__unwrap_iter(__first.base());
84 auto __last_base = std::__unwrap_iter(__last.base());
85 auto __result_base = std::__unwrap_iter(__result.base());
86 auto __result_first = __result_base - (__first_base - __last_base);
87 std::__move_impl<_AlgPolicy>(__last_base, __first_base, __result_first);
88 return std::make_pair(__last, reverse_iterator<_OutIter>(std::__rewrap_iter(__result.base(), __result_first)));
89}
48 template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0>
49 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
50 operator()(_InIter __first, _InIter __last, _OutIter __result) const {
51 using _Traits = __segmented_iterator_traits<_InIter>;
52 auto __sfirst = _Traits::__segment(__first);
53 auto __slast = _Traits::__segment(__last);
54 if (__sfirst == __slast) {
55 auto __iters = std::__move<_AlgPolicy>(_Traits::__local(__first), _Traits::__local(__last), std::move(__result));
56 return std::make_pair(__last, std::move(__iters.second));
57 }
58
59 __result = std::__move<_AlgPolicy>(_Traits::__local(__first), _Traits::__end(__sfirst), std::move(__result)).second;
60 ++__sfirst;
61 while (__sfirst != __slast) {
62 __result =
63 std::__move<_AlgPolicy>(_Traits::__begin(__sfirst), _Traits::__end(__sfirst), std::move(__result)).second;
64 ++__sfirst;
65 }
66 __result =
67 std::__move<_AlgPolicy>(_Traits::__begin(__sfirst), _Traits::__local(__last), std::move(__result)).second;
68 return std::make_pair(__last, std::move(__result));
69 }
9070
91template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>
92inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
93__enable_if_t<is_copy_constructible<_InIter>::value
94 && is_copy_constructible<_Sent>::value
95 && is_copy_constructible<_OutIter>::value, pair<_InIter, _OutIter> >
96__move(_InIter __first, _Sent __last, _OutIter __result) {
97 auto __ret = std::__move_impl<_AlgPolicy>(
98 std::__unwrap_iter(__first), std::__unwrap_iter(__last), std::__unwrap_iter(__result));
99 return std::make_pair(std::__rewrap_iter(__first, __ret.first), std::__rewrap_iter(__result, __ret.second));
100}
71 template <class _InIter,
72 class _OutIter,
73 __enable_if_t<__is_cpp17_random_access_iterator<_InIter>::value &&
74 !__is_segmented_iterator<_InIter>::value && __is_segmented_iterator<_OutIter>::value,
75 int> = 0>
76 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
77 operator()(_InIter __first, _InIter __last, _OutIter __result) {
78 using _Traits = __segmented_iterator_traits<_OutIter>;
79 using _DiffT = typename common_type<__iter_diff_t<_InIter>, __iter_diff_t<_OutIter> >::type;
80
81 if (__first == __last)
82 return std::make_pair(std::move(__first), std::move(__result));
83
84 auto __local_first = _Traits::__local(__result);
85 auto __segment_iterator = _Traits::__segment(__result);
86 while (true) {
87 auto __local_last = _Traits::__end(__segment_iterator);
88 auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first);
89 auto __iters = std::__move<_AlgPolicy>(__first, __first + __size, __local_first);
90 __first = std::move(__iters.first);
91
92 if (__first == __last)
93 return std::make_pair(std::move(__first), _Traits::__compose(__segment_iterator, std::move(__iters.second)));
94
95 __local_first = _Traits::__begin(++__segment_iterator);
96 }
97 }
98};
99
100struct __move_trivial {
101 // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.
102 template <class _In, class _Out,
103 __enable_if_t<__can_lower_move_assignment_to_memmove<_In, _Out>::value, int> = 0>
104 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
105 operator()(_In* __first, _In* __last, _Out* __result) const {
106 return std::__copy_trivial_impl(__first, __last, __result);
107 }
108};
101109
102110template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>
103inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
104__enable_if_t<!is_copy_constructible<_InIter>::value
105 || !is_copy_constructible<_Sent>::value
106 || !is_copy_constructible<_OutIter>::value, pair<_InIter, _OutIter> >
111inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
107112__move(_InIter __first, _Sent __last, _OutIter __result) {
108 return std::__move_impl<_AlgPolicy>(std::move(__first), std::move(__last), std::move(__result));
113 return std::__dispatch_copy_or_move<_AlgPolicy, __move_loop<_AlgPolicy>, __move_trivial>(
114 std::move(__first), std::move(__last), std::move(__result));
109115}
110116
111117template <class _InputIterator, class _OutputIterator>
112inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
113_OutputIterator move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
114 return std::__move<_ClassicAlgPolicy>(__first, __last, __result).second;
118inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
119move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
120 static_assert(is_copy_constructible<_InputIterator>::value, "Iterators has to be copy constructible.");
121 static_assert(is_copy_constructible<_OutputIterator>::value, "The output iterator has to be copy constructible.");
122
123 return std::__move<_ClassicAlgPolicy>(std::move(__first), std::move(__last), std::move(__result)).second;
115124}
116125
117126_LIBCPP_END_NAMESPACE_STD
118127
128_LIBCPP_POP_MACROS
129
119130#endif // _LIBCPP___ALGORITHM_MOVE_H
lib/libcxx/include/__algorithm/move_backward.h+105-55
......@@ -9,81 +9,131 @@
99#ifndef _LIBCPP___ALGORITHM_MOVE_BACKWARD_H
1010#define _LIBCPP___ALGORITHM_MOVE_BACKWARD_H
1111
12#include <__algorithm/copy_move_common.h>
1213#include <__algorithm/iterator_operations.h>
13#include <__algorithm/unwrap_iter.h>
14#include <__algorithm/min.h>
1415#include <__config>
16#include <__iterator/segmented_iterator.h>
17#include <__type_traits/common_type.h>
18#include <__type_traits/is_copy_constructible.h>
1519#include <__utility/move.h>
16#include <cstring>
17#include <type_traits>
20#include <__utility/pair.h>
1821
1922#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2023# pragma GCC system_header
2124#endif
2225
26_LIBCPP_PUSH_MACROS
27#include <__undef_macros>
28
2329_LIBCPP_BEGIN_NAMESPACE_STD
2430
25template <class _AlgPolicy, class _InputIterator, class _OutputIterator>
26inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
27_OutputIterator
28__move_backward_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
29{
30 while (__first != __last)
31 *--__result = _IterOps<_AlgPolicy>::__iter_move(--__last);
32 return __result;
33}
31template <class _AlgPolicy, class _BidirectionalIterator1, class _Sentinel, class _BidirectionalIterator2>
32_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_BidirectionalIterator1, _BidirectionalIterator2>
33__move_backward(_BidirectionalIterator1 __first, _Sentinel __last, _BidirectionalIterator2 __result);
3434
35template <class _AlgPolicy, class _InputIterator, class _OutputIterator>
36inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
37_OutputIterator
38__move_backward_impl(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
39{
40 return _VSTD::__move_backward_constexpr<_AlgPolicy>(__first, __last, __result);
41}
35template <class _AlgPolicy>
36struct __move_backward_loop {
37 template <class _InIter, class _Sent, class _OutIter>
38 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
39 operator()(_InIter __first, _Sent __last, _OutIter __result) const {
40 auto __last_iter = _IterOps<_AlgPolicy>::next(__first, __last);
41 auto __original_last_iter = __last_iter;
4242
43template <class _AlgPolicy, class _Tp, class _Up>
44inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
45typename enable_if
46<
47 is_same<typename remove_const<_Tp>::type, _Up>::value &&
48 is_trivially_move_assignable<_Up>::value,
49 _Up*
50>::type
51__move_backward_impl(_Tp* __first, _Tp* __last, _Up* __result)
52{
53 const size_t __n = static_cast<size_t>(__last - __first);
54 if (__n > 0)
55 {
56 __result -= __n;
57 _VSTD::memmove(__result, __first, __n * sizeof(_Up));
43 while (__first != __last_iter) {
44 *--__result = _IterOps<_AlgPolicy>::__iter_move(--__last_iter);
5845 }
59 return __result;
60}
6146
62template <class _AlgPolicy, class _BidirectionalIterator1, class _BidirectionalIterator2>
63inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
64_BidirectionalIterator2
65__move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
66 _BidirectionalIterator2 __result)
67{
68 if (__libcpp_is_constant_evaluated()) {
69 return _VSTD::__move_backward_constexpr<_AlgPolicy>(__first, __last, __result);
70 } else {
71 return _VSTD::__rewrap_iter(__result,
72 _VSTD::__move_backward_impl<_AlgPolicy>(_VSTD::__unwrap_iter(__first),
73 _VSTD::__unwrap_iter(__last),
74 _VSTD::__unwrap_iter(__result)));
47 return std::make_pair(std::move(__original_last_iter), std::move(__result));
48 }
49
50 template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0>
51 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
52 operator()(_InIter __first, _InIter __last, _OutIter __result) const {
53 using _Traits = __segmented_iterator_traits<_InIter>;
54 auto __sfirst = _Traits::__segment(__first);
55 auto __slast = _Traits::__segment(__last);
56 if (__sfirst == __slast) {
57 auto __iters =
58 std::__move_backward<_AlgPolicy>(_Traits::__local(__first), _Traits::__local(__last), std::move(__result));
59 return std::make_pair(__last, __iters.second);
60 }
61
62 __result =
63 std::__move_backward<_AlgPolicy>(_Traits::__begin(__slast), _Traits::__local(__last), std::move(__result))
64 .second;
65 --__slast;
66 while (__sfirst != __slast) {
67 __result =
68 std::__move_backward<_AlgPolicy>(_Traits::__begin(__slast), _Traits::__end(__slast), std::move(__result))
69 .second;
70 --__slast;
71 }
72 __result = std::__move_backward<_AlgPolicy>(_Traits::__local(__first), _Traits::__end(__slast), std::move(__result))
73 .second;
74 return std::make_pair(__last, std::move(__result));
75 }
76
77 template <class _InIter,
78 class _OutIter,
79 __enable_if_t<__is_cpp17_random_access_iterator<_InIter>::value &&
80 !__is_segmented_iterator<_InIter>::value && __is_segmented_iterator<_OutIter>::value,
81 int> = 0>
82 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
83 operator()(_InIter __first, _InIter __last, _OutIter __result) {
84 using _Traits = __segmented_iterator_traits<_OutIter>;
85 using _DiffT = typename common_type<__iter_diff_t<_InIter>, __iter_diff_t<_OutIter> >::type;
86
87 // When the range contains no elements, __result might not be a valid iterator
88 if (__first == __last)
89 return std::make_pair(__first, __result);
90
91 auto __orig_last = __last;
92
93 auto __local_last = _Traits::__local(__result);
94 auto __segment_iterator = _Traits::__segment(__result);
95 while (true) {
96 auto __local_first = _Traits::__begin(__segment_iterator);
97 auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first);
98 auto __iter = std::__move_backward<_AlgPolicy>(__last - __size, __last, __local_last).second;
99 __last -= __size;
100
101 if (__first == __last)
102 return std::make_pair(std::move(__orig_last), _Traits::__compose(__segment_iterator, std::move(__iter)));
103
104 __local_last = _Traits::__end(--__segment_iterator);
75105 }
106 }
107};
108
109struct __move_backward_trivial {
110 // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.
111 template <class _In, class _Out,
112 __enable_if_t<__can_lower_move_assignment_to_memmove<_In, _Out>::value, int> = 0>
113 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
114 operator()(_In* __first, _In* __last, _Out* __result) const {
115 return std::__copy_backward_trivial_impl(__first, __last, __result);
116 }
117};
118
119template <class _AlgPolicy, class _BidirectionalIterator1, class _Sentinel, class _BidirectionalIterator2>
120_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_BidirectionalIterator1, _BidirectionalIterator2>
121__move_backward(_BidirectionalIterator1 __first, _Sentinel __last, _BidirectionalIterator2 __result) {
122 static_assert(std::is_copy_constructible<_BidirectionalIterator1>::value &&
123 std::is_copy_constructible<_BidirectionalIterator1>::value, "Iterators must be copy constructible.");
124
125 return std::__dispatch_copy_or_move<_AlgPolicy, __move_backward_loop<_AlgPolicy>, __move_backward_trivial>(
126 std::move(__first), std::move(__last), std::move(__result));
76127}
77128
78129template <class _BidirectionalIterator1, class _BidirectionalIterator2>
79inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
80_BidirectionalIterator2
81move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
82 _BidirectionalIterator2 __result)
83{
84 return std::__move_backward<_ClassicAlgPolicy>(std::move(__first), std::move(__last), std::move(__result));
130inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _BidirectionalIterator2
131move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, _BidirectionalIterator2 __result) {
132 return std::__move_backward<_ClassicAlgPolicy>(std::move(__first), std::move(__last), std::move(__result)).second;
85133}
86134
87135_LIBCPP_END_NAMESPACE_STD
88136
137_LIBCPP_POP_MACROS
138
89139#endif // _LIBCPP___ALGORITHM_MOVE_BACKWARD_H
lib/libcxx/include/__algorithm/next_permutation.h+4-6
......@@ -25,8 +25,7 @@
2525_LIBCPP_BEGIN_NAMESPACE_STD
2626
2727template <class _AlgPolicy, class _Compare, class _BidirectionalIterator, class _Sentinel>
28_LIBCPP_CONSTEXPR_AFTER_CXX17
29pair<_BidirectionalIterator, bool>
28_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_BidirectionalIterator, bool>
3029__next_permutation(_BidirectionalIterator __first, _Sentinel __last, _Compare&& __comp)
3130{
3231 using _Result = pair<_BidirectionalIterator, bool>;
......@@ -57,17 +56,16 @@ __next_permutation(_BidirectionalIterator __first, _Sentinel __last, _Compare&&
5756}
5857
5958template <class _BidirectionalIterator, class _Compare>
60inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
59inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
6160bool
6261next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
6362{
64 using _Comp_ref = typename __comp_ref_type<_Compare>::type;
6563 return std::__next_permutation<_ClassicAlgPolicy>(
66 std::move(__first), std::move(__last), static_cast<_Comp_ref>(__comp)).second;
64 std::move(__first), std::move(__last), static_cast<__comp_ref_type<_Compare> >(__comp)).second;
6765}
6866
6967template <class _BidirectionalIterator>
70inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
68inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
7169bool
7270next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)
7371{
lib/libcxx/include/__algorithm/none_of.h+1-1
......@@ -19,7 +19,7 @@
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
2121template <class _InputIterator, class _Predicate>
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
2323none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
2424 for (; __first != __last; ++__first)
2525 if (__pred(*__first))
lib/libcxx/include/__algorithm/nth_element.h+6-7
......@@ -26,7 +26,7 @@
2626_LIBCPP_BEGIN_NAMESPACE_STD
2727
2828template<class _Compare, class _RandomAccessIterator>
29_LIBCPP_CONSTEXPR_AFTER_CXX11 bool
29_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
3030__nth_element_find_guard(_RandomAccessIterator& __i, _RandomAccessIterator& __j,
3131 _RandomAccessIterator __m, _Compare __comp)
3232{
......@@ -42,7 +42,7 @@ __nth_element_find_guard(_RandomAccessIterator& __i, _RandomAccessIterator& __j,
4242}
4343
4444template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
45_LIBCPP_CONSTEXPR_AFTER_CXX11 void
45_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
4646__nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp)
4747{
4848 using _Ops = _IterOps<_AlgPolicy>;
......@@ -223,7 +223,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
223223}
224224
225225template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
226inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
226inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
227227void __nth_element_impl(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last,
228228 _Compare& __comp) {
229229 if (__nth == __last)
......@@ -231,8 +231,7 @@ void __nth_element_impl(_RandomAccessIterator __first, _RandomAccessIterator __n
231231
232232 std::__debug_randomize_range<_AlgPolicy>(__first, __last);
233233
234 using _Comp_ref = typename __comp_ref_type<_Compare>::type;
235 std::__nth_element<_AlgPolicy, _Comp_ref>(__first, __nth, __last, __comp);
234 std::__nth_element<_AlgPolicy, __comp_ref_type<_Compare> >(__first, __nth, __last, __comp);
236235
237236 std::__debug_randomize_range<_AlgPolicy>(__first, __nth);
238237 if (__nth != __last) {
......@@ -241,14 +240,14 @@ void __nth_element_impl(_RandomAccessIterator __first, _RandomAccessIterator __n
241240}
242241
243242template <class _RandomAccessIterator, class _Compare>
244inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
243inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
245244void nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last,
246245 _Compare __comp) {
247246 std::__nth_element_impl<_ClassicAlgPolicy>(std::move(__first), std::move(__nth), std::move(__last), __comp);
248247}
249248
250249template <class _RandomAccessIterator>
251inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
250inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
252251void nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last) {
253252 std::nth_element(std::move(__first), std::move(__nth), std::move(__last), __less<typename
254253 iterator_traits<_RandomAccessIterator>::value_type>());
lib/libcxx/include/__algorithm/partial_sort.h+6-7
......@@ -29,7 +29,7 @@
2929_LIBCPP_BEGIN_NAMESPACE_STD
3030
3131template <class _AlgPolicy, class _Compare, class _RandomAccessIterator, class _Sentinel>
32_LIBCPP_CONSTEXPR_AFTER_CXX17
32_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
3333_RandomAccessIterator __partial_sort_impl(
3434 _RandomAccessIterator __first, _RandomAccessIterator __middle, _Sentinel __last, _Compare&& __comp) {
3535 if (__first == __middle) {
......@@ -47,7 +47,6 @@ _RandomAccessIterator __partial_sort_impl(
4747 _IterOps<_AlgPolicy>::iter_swap(__i, __first);
4848 std::__sift_down<_AlgPolicy>(__first, __comp, __len, __first);
4949 }
50
5150 }
5251 std::__sort_heap<_AlgPolicy>(std::move(__first), std::move(__middle), __comp);
5352
......@@ -55,7 +54,7 @@ _RandomAccessIterator __partial_sort_impl(
5554}
5655
5756template <class _AlgPolicy, class _Compare, class _RandomAccessIterator, class _Sentinel>
58_LIBCPP_CONSTEXPR_AFTER_CXX17
57_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
5958_RandomAccessIterator __partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Sentinel __last,
6059 _Compare& __comp) {
6160 if (__first == __middle)
......@@ -63,8 +62,8 @@ _RandomAccessIterator __partial_sort(_RandomAccessIterator __first, _RandomAcces
6362
6463 std::__debug_randomize_range<_AlgPolicy>(__first, __last);
6564
66 using _Comp_ref = typename __comp_ref_type<_Compare>::type;
67 auto __last_iter = std::__partial_sort_impl<_AlgPolicy>(__first, __middle, __last, static_cast<_Comp_ref>(__comp));
65 auto __last_iter =
66 std::__partial_sort_impl<_AlgPolicy>(__first, __middle, __last, static_cast<__comp_ref_type<_Compare> >(__comp));
6867
6968 std::__debug_randomize_range<_AlgPolicy>(__middle, __last);
7069
......@@ -72,7 +71,7 @@ _RandomAccessIterator __partial_sort(_RandomAccessIterator __first, _RandomAcces
7271}
7372
7473template <class _RandomAccessIterator, class _Compare>
75inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
74inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
7675void
7776partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
7877 _Compare __comp)
......@@ -84,7 +83,7 @@ partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran
8483}
8584
8685template <class _RandomAccessIterator>
87inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
86inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
8887void
8988partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)
9089{
lib/libcxx/include/__algorithm/partial_sort_copy.h+4-5
......@@ -33,7 +33,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3333template <class _AlgPolicy, class _Compare,
3434 class _InputIterator, class _Sentinel1, class _RandomAccessIterator, class _Sentinel2,
3535 class _Proj1, class _Proj2>
36_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator, _RandomAccessIterator>
36_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator, _RandomAccessIterator>
3737__partial_sort_copy(_InputIterator __first, _Sentinel1 __last,
3838 _RandomAccessIterator __result_first, _Sentinel2 __result_last,
3939 _Compare&& __comp, _Proj1&& __proj1, _Proj2&& __proj2)
......@@ -60,7 +60,7 @@ __partial_sort_copy(_InputIterator __first, _Sentinel1 __last,
6060}
6161
6262template <class _InputIterator, class _RandomAccessIterator, class _Compare>
63inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
63inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
6464_RandomAccessIterator
6565partial_sort_copy(_InputIterator __first, _InputIterator __last,
6666 _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)
......@@ -68,14 +68,13 @@ partial_sort_copy(_InputIterator __first, _InputIterator __last,
6868 static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__result_first)>::value,
6969 "Comparator has to be callable");
7070
71 using _Comp_ref = typename __comp_ref_type<_Compare>::type;
7271 auto __result = std::__partial_sort_copy<_ClassicAlgPolicy>(__first, __last, __result_first, __result_last,
73 static_cast<_Comp_ref>(__comp), __identity(), __identity());
72 static_cast<__comp_ref_type<_Compare> >(__comp), __identity(), __identity());
7473 return __result.second;
7574}
7675
7776template <class _InputIterator, class _RandomAccessIterator>
78inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
77inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
7978_RandomAccessIterator
8079partial_sort_copy(_InputIterator __first, _InputIterator __last,
8180 _RandomAccessIterator __result_first, _RandomAccessIterator __result_last)
lib/libcxx/include/__algorithm/partition.h+5-5
......@@ -23,7 +23,7 @@
2323_LIBCPP_BEGIN_NAMESPACE_STD
2424
2525template <class _Predicate, class _AlgPolicy, class _ForwardIterator, class _Sentinel>
26_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator>
26_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator>
2727__partition_impl(_ForwardIterator __first, _Sentinel __last, _Predicate __pred, forward_iterator_tag)
2828{
2929 while (true)
......@@ -48,7 +48,7 @@ __partition_impl(_ForwardIterator __first, _Sentinel __last, _Predicate __pred,
4848}
4949
5050template <class _Predicate, class _AlgPolicy, class _BidirectionalIterator, class _Sentinel>
51_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_BidirectionalIterator, _BidirectionalIterator>
51_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_BidirectionalIterator, _BidirectionalIterator>
5252__partition_impl(_BidirectionalIterator __first, _Sentinel __sentinel, _Predicate __pred,
5353 bidirectional_iterator_tag)
5454{
......@@ -76,15 +76,15 @@ __partition_impl(_BidirectionalIterator __first, _Sentinel __sentinel, _Predicat
7676}
7777
7878template <class _AlgPolicy, class _ForwardIterator, class _Sentinel, class _Predicate, class _IterCategory>
79inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
79inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
8080pair<_ForwardIterator, _ForwardIterator> __partition(
8181 _ForwardIterator __first, _Sentinel __last, _Predicate&& __pred, _IterCategory __iter_category) {
82 return std::__partition_impl<__uncvref_t<_Predicate>&, _AlgPolicy>(
82 return std::__partition_impl<__remove_cvref_t<_Predicate>&, _AlgPolicy>(
8383 std::move(__first), std::move(__last), __pred, __iter_category);
8484}
8585
8686template <class _ForwardIterator, class _Predicate>
87inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
87inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
8888_ForwardIterator
8989partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
9090{
lib/libcxx/include/__algorithm/partition_copy.h+1-1
......@@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2121
2222template <class _InputIterator, class _OutputIterator1,
2323 class _OutputIterator2, class _Predicate>
24_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_OutputIterator1, _OutputIterator2>
24_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_OutputIterator1, _OutputIterator2>
2525partition_copy(_InputIterator __first, _InputIterator __last,
2626 _OutputIterator1 __out_true, _OutputIterator2 __out_false,
2727 _Predicate __pred)
lib/libcxx/include/__algorithm/partition_point.h+1-1
......@@ -22,7 +22,7 @@
2222_LIBCPP_BEGIN_NAMESPACE_STD
2323
2424template<class _ForwardIterator, class _Predicate>
25_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
25_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
2626partition_point(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
2727{
2828 typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
lib/libcxx/include/__algorithm/pop_heap.h+4-5
......@@ -27,13 +27,12 @@
2727_LIBCPP_BEGIN_NAMESPACE_STD
2828
2929template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
30inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
30inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
3131void __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp,
3232 typename iterator_traits<_RandomAccessIterator>::difference_type __len) {
3333 _LIBCPP_ASSERT(__len > 0, "The heap given to pop_heap must be non-empty");
3434
35 using _CompRef = typename __comp_ref_type<_Compare>::type;
36 _CompRef __comp_ref = __comp;
35 __comp_ref_type<_Compare> __comp_ref = __comp;
3736
3837 using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
3938 if (__len > 1) {
......@@ -53,7 +52,7 @@ void __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co
5352}
5453
5554template <class _RandomAccessIterator, class _Compare>
56inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
55inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
5756void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
5857 static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible.");
5958 static_assert(std::is_copy_assignable<_RandomAccessIterator>::value, "Iterators must be copy assignable.");
......@@ -63,7 +62,7 @@ void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp
6362}
6463
6564template <class _RandomAccessIterator>
66inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
65inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
6766void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {
6867 std::pop_heap(std::move(__first), std::move(__last),
6968 __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
lib/libcxx/include/__algorithm/prev_permutation.h+4-5
......@@ -25,7 +25,7 @@
2525_LIBCPP_BEGIN_NAMESPACE_STD
2626
2727template <class _AlgPolicy, class _Compare, class _BidirectionalIterator, class _Sentinel>
28_LIBCPP_CONSTEXPR_AFTER_CXX17
28_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2929pair<_BidirectionalIterator, bool>
3030__prev_permutation(_BidirectionalIterator __first, _Sentinel __last, _Compare&& __comp)
3131{
......@@ -57,17 +57,16 @@ __prev_permutation(_BidirectionalIterator __first, _Sentinel __last, _Compare&&
5757}
5858
5959template <class _BidirectionalIterator, class _Compare>
60inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
60inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
6161bool
6262prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
6363{
64 using _Comp_ref = typename __comp_ref_type<_Compare>::type;
6564 return std::__prev_permutation<_ClassicAlgPolicy>(
66 std::move(__first), std::move(__last), static_cast<_Comp_ref>(__comp)).second;
65 std::move(__first), std::move(__last), static_cast<__comp_ref_type<_Compare> >(__comp)).second;
6766}
6867
6968template <class _BidirectionalIterator>
70inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
69inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
7170bool
7271prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)
7372{
lib/libcxx/include/__algorithm/push_heap.h+5-6
......@@ -24,7 +24,7 @@
2424_LIBCPP_BEGIN_NAMESPACE_STD
2525
2626template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
27_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
27_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
2828void __sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp,
2929 typename iterator_traits<_RandomAccessIterator>::difference_type __len) {
3030 using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
......@@ -50,15 +50,14 @@ void __sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Com
5050}
5151
5252template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
53inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
53inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
5454void __push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp) {
55 using _CompRef = typename __comp_ref_type<_Compare>::type;
5655 typename iterator_traits<_RandomAccessIterator>::difference_type __len = __last - __first;
57 std::__sift_up<_AlgPolicy, _CompRef>(std::move(__first), std::move(__last), __comp, __len);
56 std::__sift_up<_AlgPolicy, __comp_ref_type<_Compare> >(std::move(__first), std::move(__last), __comp, __len);
5857}
5958
6059template <class _RandomAccessIterator, class _Compare>
61inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
60inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
6261void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
6362 static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible.");
6463 static_assert(std::is_copy_assignable<_RandomAccessIterator>::value, "Iterators must be copy assignable.");
......@@ -67,7 +66,7 @@ void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Com
6766}
6867
6968template <class _RandomAccessIterator>
70inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
69inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
7170void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {
7271 std::push_heap(std::move(__first), std::move(__last),
7372 __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
lib/libcxx/include/__algorithm/ranges_adjacent_find.h+4-4
......@@ -24,7 +24,7 @@
2424# pragma GCC system_header
2525#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27#if _LIBCPP_STD_VER > 17
2828
2929_LIBCPP_BEGIN_NAMESPACE_STD
3030
......@@ -50,7 +50,7 @@ struct __fn {
5050 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent,
5151 class _Proj = identity,
5252 indirect_binary_predicate<projected<_Iter, _Proj>, projected<_Iter, _Proj>> _Pred = ranges::equal_to>
53 _LIBCPP_HIDE_FROM_ABI constexpr
53 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
5454 _Iter operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {
5555 return __adjacent_find_impl(std::move(__first), std::move(__last), __pred, __proj);
5656 }
......@@ -59,7 +59,7 @@ struct __fn {
5959 class _Proj = identity,
6060 indirect_binary_predicate<projected<iterator_t<_Range>, _Proj>,
6161 projected<iterator_t<_Range>, _Proj>> _Pred = ranges::equal_to>
62 _LIBCPP_HIDE_FROM_ABI constexpr
62 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
6363 borrowed_iterator_t<_Range> operator()(_Range&& __range, _Pred __pred = {}, _Proj __proj = {}) const {
6464 return __adjacent_find_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
6565 }
......@@ -73,6 +73,6 @@ inline namespace __cpo {
7373
7474_LIBCPP_END_NAMESPACE_STD
7575
76#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
76#endif // _LIBCPP_STD_VER > 17
7777
7878#endif // _LIBCPP___ALGORITHM_RANGES_ADJACENT_FIND_H
lib/libcxx/include/__algorithm/ranges_all_of.h+4-4
......@@ -22,7 +22,7 @@
2222# pragma GCC system_header
2323#endif
2424
25#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
25#if _LIBCPP_STD_VER > 17
2626
2727_LIBCPP_BEGIN_NAMESPACE_STD
2828
......@@ -42,14 +42,14 @@ struct __fn {
4242
4343 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
4444 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
45 _LIBCPP_HIDE_FROM_ABI constexpr
45 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
4646 bool operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
4747 return __all_of_impl(std::move(__first), std::move(__last), __pred, __proj);
4848 }
4949
5050 template <input_range _Range, class _Proj = identity,
5151 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
52 _LIBCPP_HIDE_FROM_ABI constexpr
52 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
5353 bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
5454 return __all_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
5555 }
......@@ -63,6 +63,6 @@ inline namespace __cpo {
6363
6464_LIBCPP_END_NAMESPACE_STD
6565
66#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
66#endif // _LIBCPP_STD_VER > 17
6767
6868#endif // _LIBCPP___ALGORITHM_RANGES_ALL_OF_H
lib/libcxx/include/__algorithm/ranges_any_of.h+4-4
......@@ -22,7 +22,7 @@
2222# pragma GCC system_header
2323#endif
2424
25#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
25#if _LIBCPP_STD_VER > 17
2626
2727_LIBCPP_BEGIN_NAMESPACE_STD
2828
......@@ -42,14 +42,14 @@ struct __fn {
4242
4343 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
4444 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
45 _LIBCPP_HIDE_FROM_ABI constexpr
45 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
4646 bool operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {
4747 return __any_of_impl(std::move(__first), std::move(__last), __pred, __proj);
4848 }
4949
5050 template <input_range _Range, class _Proj = identity,
5151 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
52 _LIBCPP_HIDE_FROM_ABI constexpr
52 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
5353 bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
5454 return __any_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
5555 }
......@@ -63,6 +63,6 @@ inline namespace __cpo {
6363
6464_LIBCPP_END_NAMESPACE_STD
6565
66#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
66#endif // _LIBCPP_STD_VER > 17
6767
6868#endif // _LIBCPP___ALGORITHM_RANGES_ANY_OF_H
lib/libcxx/include/__algorithm/ranges_binary_search.h+4-4
......@@ -24,7 +24,7 @@
2424# pragma GCC system_header
2525#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27#if _LIBCPP_STD_VER > 17
2828
2929_LIBCPP_BEGIN_NAMESPACE_STD
3030
......@@ -33,7 +33,7 @@ namespace __binary_search {
3333struct __fn {
3434 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity,
3535 indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less>
36 _LIBCPP_HIDE_FROM_ABI constexpr
36 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
3737 bool operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
3838 auto __ret = std::__lower_bound_impl<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj);
3939 return __ret != __last && !std::invoke(__comp, __value, std::invoke(__proj, *__first));
......@@ -41,7 +41,7 @@ struct __fn {
4141
4242 template <forward_range _Range, class _Type, class _Proj = identity,
4343 indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
44 _LIBCPP_HIDE_FROM_ABI constexpr
44 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
4545 bool operator()(_Range&& __r, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
4646 auto __first = ranges::begin(__r);
4747 auto __last = ranges::end(__r);
......@@ -58,6 +58,6 @@ inline namespace __cpo {
5858
5959_LIBCPP_END_NAMESPACE_STD
6060
61#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
61#endif // _LIBCPP_STD_VER > 17
6262
6363#endif // _LIBCPP___ALGORITHM_RANGES_BINARY_SEARCH_H
lib/libcxx/include/__algorithm/ranges_clamp.h+3-3
......@@ -22,7 +22,7 @@
2222# pragma GCC system_header
2323#endif
2424
25#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
25#if _LIBCPP_STD_VER > 17
2626
2727_LIBCPP_BEGIN_NAMESPACE_STD
2828
......@@ -33,7 +33,7 @@ struct __fn {
3333 template <class _Type,
3434 class _Proj = identity,
3535 indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>
36 _LIBCPP_HIDE_FROM_ABI constexpr
36 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
3737 const _Type& operator()(const _Type& __value,
3838 const _Type& __low,
3939 const _Type& __high,
......@@ -60,6 +60,6 @@ inline namespace __cpo {
6060
6161_LIBCPP_END_NAMESPACE_STD
6262
63#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
63#endif // _LIBCPP_STD_VER > 17
6464
6565#endif // _LIBCPP___ALGORITHM_RANGES_CLAMP_H
lib/libcxx/include/__algorithm/ranges_copy.h+6-4
......@@ -11,6 +11,7 @@
1111
1212#include <__algorithm/copy.h>
1313#include <__algorithm/in_out_result.h>
14#include <__algorithm/iterator_operations.h>
1415#include <__config>
1516#include <__functional/identity.h>
1617#include <__iterator/concepts.h>
......@@ -18,12 +19,13 @@
1819#include <__ranges/concepts.h>
1920#include <__ranges/dangling.h>
2021#include <__utility/move.h>
22#include <__utility/pair.h>
2123
2224#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2325# pragma GCC system_header
2426#endif
2527
26#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28#if _LIBCPP_STD_VER > 17
2729
2830_LIBCPP_BEGIN_NAMESPACE_STD
2931
......@@ -39,7 +41,7 @@ struct __fn {
3941 requires indirectly_copyable<_InIter, _OutIter>
4042 _LIBCPP_HIDE_FROM_ABI constexpr
4143 copy_result<_InIter, _OutIter> operator()(_InIter __first, _Sent __last, _OutIter __result) const {
42 auto __ret = std::__copy(std::move(__first), std::move(__last), std::move(__result));
44 auto __ret = std::__copy<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__result));
4345 return {std::move(__ret.first), std::move(__ret.second)};
4446 }
4547
......@@ -47,7 +49,7 @@ struct __fn {
4749 requires indirectly_copyable<iterator_t<_Range>, _OutIter>
4850 _LIBCPP_HIDE_FROM_ABI constexpr
4951 copy_result<borrowed_iterator_t<_Range>, _OutIter> operator()(_Range&& __r, _OutIter __result) const {
50 auto __ret = std::__copy(ranges::begin(__r), ranges::end(__r), std::move(__result));
52 auto __ret = std::__copy<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), std::move(__result));
5153 return {std::move(__ret.first), std::move(__ret.second)};
5254 }
5355};
......@@ -60,6 +62,6 @@ inline namespace __cpo {
6062
6163_LIBCPP_END_NAMESPACE_STD
6264
63#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
65#endif // _LIBCPP_STD_VER > 17
6466
6567#endif // _LIBCPP___ALGORITHM_RANGES_COPY_H
lib/libcxx/include/__algorithm/ranges_copy_backward.h+2-3
......@@ -14,7 +14,6 @@
1414#include <__algorithm/iterator_operations.h>
1515#include <__config>
1616#include <__iterator/concepts.h>
17#include <__iterator/reverse_iterator.h>
1817#include <__ranges/access.h>
1918#include <__ranges/concepts.h>
2019#include <__ranges/dangling.h>
......@@ -24,7 +23,7 @@
2423# pragma GCC system_header
2524#endif
2625
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
26#if _LIBCPP_STD_VER > 17
2827
2928_LIBCPP_BEGIN_NAMESPACE_STD
3029
......@@ -61,6 +60,6 @@ inline namespace __cpo {
6160
6261_LIBCPP_END_NAMESPACE_STD
6362
64#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
63#endif // _LIBCPP_STD_VER > 17
6564
6665#endif // _LIBCPP___ALGORITHM_RANGES_COPY_BACKWARD_H
lib/libcxx/include/__algorithm/ranges_copy_if.h+2-2
......@@ -24,7 +24,7 @@
2424# pragma GCC system_header
2525#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27#if _LIBCPP_STD_VER > 17
2828
2929_LIBCPP_BEGIN_NAMESPACE_STD
3030
......@@ -76,6 +76,6 @@ inline namespace __cpo {
7676
7777_LIBCPP_END_NAMESPACE_STD
7878
79#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
79#endif // _LIBCPP_STD_VER > 17
8080
8181#endif // _LIBCPP___ALGORITHM_RANGES_COPY_IF_H
lib/libcxx/include/__algorithm/ranges_copy_n.h+4-3
......@@ -11,6 +11,7 @@
1111
1212#include <__algorithm/copy.h>
1313#include <__algorithm/in_out_result.h>
14#include <__algorithm/iterator_operations.h>
1415#include <__algorithm/ranges_copy.h>
1516#include <__config>
1617#include <__functional/identity.h>
......@@ -26,7 +27,7 @@
2627
2728_LIBCPP_BEGIN_NAMESPACE_STD
2829
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
30#if _LIBCPP_STD_VER > 17
3031
3132namespace ranges {
3233
......@@ -51,7 +52,7 @@ struct __fn {
5152 template <random_access_iterator _InIter, class _DiffType, random_access_iterator _OutIter>
5253 _LIBCPP_HIDE_FROM_ABI constexpr static
5354 copy_n_result<_InIter, _OutIter> __go(_InIter __first, _DiffType __n, _OutIter __result) {
54 auto __ret = std::__copy(__first, __first + __n, __result);
55 auto __ret = std::__copy<_RangeAlgPolicy>(__first, __first + __n, __result);
5556 return {__ret.first, __ret.second};
5657 }
5758
......@@ -69,7 +70,7 @@ inline namespace __cpo {
6970} // namespace __cpo
7071} // namespace ranges
7172
72#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
73#endif // _LIBCPP_STD_VER > 17
7374
7475_LIBCPP_END_NAMESPACE_STD
7576
lib/libcxx/include/__algorithm/ranges_count.h+4-4
......@@ -25,7 +25,7 @@
2525# pragma GCC system_header
2626#endif
2727
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28#if _LIBCPP_STD_VER > 17
2929
3030_LIBCPP_BEGIN_NAMESPACE_STD
3131
......@@ -34,7 +34,7 @@ namespace __count {
3434struct __fn {
3535 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>
3636 requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>
37 _LIBCPP_HIDE_FROM_ABI constexpr
37 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
3838 iter_difference_t<_Iter> operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const {
3939 auto __pred = [&](auto&& __e) { return __e == __value; };
4040 return ranges::__count_if_impl(std::move(__first), std::move(__last), __pred, __proj);
......@@ -42,7 +42,7 @@ struct __fn {
4242
4343 template <input_range _Range, class _Type, class _Proj = identity>
4444 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
45 _LIBCPP_HIDE_FROM_ABI constexpr
45 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
4646 range_difference_t<_Range> operator()(_Range&& __r, const _Type& __value, _Proj __proj = {}) const {
4747 auto __pred = [&](auto&& __e) { return __e == __value; };
4848 return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
......@@ -57,6 +57,6 @@ inline namespace __cpo {
5757
5858_LIBCPP_END_NAMESPACE_STD
5959
60#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
60#endif // _LIBCPP_STD_VER > 17
6161
6262#endif // _LIBCPP___ALGORITHM_RANGES_COUNT_H
lib/libcxx/include/__algorithm/ranges_count_if.h+4-4
......@@ -25,7 +25,7 @@
2525# pragma GCC system_header
2626#endif
2727
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28#if _LIBCPP_STD_VER > 17
2929
3030_LIBCPP_BEGIN_NAMESPACE_STD
3131
......@@ -46,14 +46,14 @@ namespace __count_if {
4646struct __fn {
4747 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
4848 indirect_unary_predicate<projected<_Iter, _Proj>> _Predicate>
49 _LIBCPP_HIDE_FROM_ABI constexpr
49 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
5050 iter_difference_t<_Iter> operator()(_Iter __first, _Sent __last, _Predicate __pred, _Proj __proj = {}) const {
5151 return ranges::__count_if_impl(std::move(__first), std::move(__last), __pred, __proj);
5252 }
5353
5454 template <input_range _Range, class _Proj = identity,
5555 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Predicate>
56 _LIBCPP_HIDE_FROM_ABI constexpr
56 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
5757 range_difference_t<_Range> operator()(_Range&& __r, _Predicate __pred, _Proj __proj = {}) const {
5858 return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
5959 }
......@@ -67,6 +67,6 @@ inline namespace __cpo {
6767
6868_LIBCPP_END_NAMESPACE_STD
6969
70#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
70#endif // _LIBCPP_STD_VER > 17
7171
7272#endif // _LIBCPP___ALGORITHM_RANGES_COUNT_IF_H
lib/libcxx/include/__algorithm/ranges_equal.h+4-4
......@@ -24,7 +24,7 @@
2424# pragma GCC system_header
2525#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27#if _LIBCPP_STD_VER > 17
2828
2929_LIBCPP_BEGIN_NAMESPACE_STD
3030
......@@ -60,7 +60,7 @@ public:
6060 class _Proj1 = identity,
6161 class _Proj2 = identity>
6262 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
63 _LIBCPP_HIDE_FROM_ABI constexpr
63 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
6464 bool operator()(_Iter1 __first1, _Sent1 __last1,
6565 _Iter2 __first2, _Sent2 __last2,
6666 _Pred __pred = {},
......@@ -83,7 +83,7 @@ public:
8383 class _Proj1 = identity,
8484 class _Proj2 = identity>
8585 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
86 _LIBCPP_HIDE_FROM_ABI constexpr
86 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
8787 bool operator()(_Range1&& __range1,
8888 _Range2&& __range2,
8989 _Pred __pred = {},
......@@ -110,6 +110,6 @@ inline namespace __cpo {
110110
111111_LIBCPP_END_NAMESPACE_STD
112112
113#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
113#endif // _LIBCPP_STD_VER > 17
114114
115115#endif // _LIBCPP___ALGORITHM_RANGES_EQUAL_H
lib/libcxx/include/__algorithm/ranges_equal_range.h+5-4
......@@ -24,12 +24,13 @@
2424#include <__ranges/subrange.h>
2525#include <__utility/forward.h>
2626#include <__utility/move.h>
27#include <__utility/pair.h>
2728
2829#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2930# pragma GCC system_header
3031#endif
3132
32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
33#if _LIBCPP_STD_VER > 17
3334
3435_LIBCPP_BEGIN_NAMESPACE_STD
3536
......@@ -43,7 +44,7 @@ struct __fn {
4344 class _Tp,
4445 class _Proj = identity,
4546 indirect_strict_weak_order<const _Tp*, projected<_Iter, _Proj>> _Comp = ranges::less>
46 _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
47 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
4748 operator()(_Iter __first, _Sent __last, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const {
4849 auto __ret = std::__equal_range<_RangeAlgPolicy>(
4950 std::move(__first), std::move(__last), __value, __comp, __proj);
......@@ -55,7 +56,7 @@ struct __fn {
5556 class _Tp,
5657 class _Proj = identity,
5758 indirect_strict_weak_order<const _Tp*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
58 _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>
59 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>
5960 operator()(_Range&& __range, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const {
6061 auto __ret = std::__equal_range<_RangeAlgPolicy>(
6162 ranges::begin(__range), ranges::end(__range), __value, __comp, __proj);
......@@ -72,6 +73,6 @@ inline namespace __cpo {
7273
7374_LIBCPP_END_NAMESPACE_STD
7475
75#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
76#endif // _LIBCPP_STD_VER > 17
7677
7778#endif // _LIBCPP___ALGORITHM_RANGES_EQUAL_RANGE_H
lib/libcxx/include/__algorithm/ranges_fill.h+2-2
......@@ -20,7 +20,7 @@
2020# pragma GCC system_header
2121#endif
2222
23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
23#if _LIBCPP_STD_VER > 17
2424
2525_LIBCPP_BEGIN_NAMESPACE_STD
2626
......@@ -54,6 +54,6 @@ inline namespace __cpo {
5454
5555_LIBCPP_END_NAMESPACE_STD
5656
57#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
57#endif // _LIBCPP_STD_VER > 17
5858
5959#endif // _LIBCPP___ALGORITHM_RANGES_FILL_H
lib/libcxx/include/__algorithm/ranges_fill_n.h+2-2
......@@ -17,7 +17,7 @@
1717# pragma GCC system_header
1818#endif
1919
20#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
20#if _LIBCPP_STD_VER > 17
2121
2222_LIBCPP_BEGIN_NAMESPACE_STD
2323
......@@ -43,6 +43,6 @@ inline namespace __cpo {
4343
4444_LIBCPP_END_NAMESPACE_STD
4545
46#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
46#endif // _LIBCPP_STD_VER > 17
4747
4848#endif // _LIBCPP___ALGORITHM_RANGES_FILL_N_H
lib/libcxx/include/__algorithm/ranges_find.h+4-4
......@@ -26,7 +26,7 @@
2626# pragma GCC system_header
2727#endif
2828
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
29#if _LIBCPP_STD_VER > 17
3030
3131_LIBCPP_BEGIN_NAMESPACE_STD
3232
......@@ -35,7 +35,7 @@ namespace __find {
3535struct __fn {
3636 template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, class _Proj = identity>
3737 requires indirect_binary_predicate<ranges::equal_to, projected<_Ip, _Proj>, const _Tp*>
38 _LIBCPP_HIDE_FROM_ABI constexpr
38 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
3939 _Ip operator()(_Ip __first, _Sp __last, const _Tp& __value, _Proj __proj = {}) const {
4040 auto __pred = [&](auto&& __e) { return std::forward<decltype(__e)>(__e) == __value; };
4141 return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred, __proj);
......@@ -43,7 +43,7 @@ struct __fn {
4343
4444 template <input_range _Rp, class _Tp, class _Proj = identity>
4545 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Rp>, _Proj>, const _Tp*>
46 _LIBCPP_HIDE_FROM_ABI constexpr
46 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
4747 borrowed_iterator_t<_Rp> operator()(_Rp&& __r, const _Tp& __value, _Proj __proj = {}) const {
4848 auto __pred = [&](auto&& __e) { return std::forward<decltype(__e)>(__e) == __value; };
4949 return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
......@@ -58,6 +58,6 @@ inline namespace __cpo {
5858
5959_LIBCPP_END_NAMESPACE_STD
6060
61#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
61#endif // _LIBCPP_STD_VER > 17
6262
6363#endif // _LIBCPP___ALGORITHM_RANGES_FIND_H
lib/libcxx/include/__algorithm/ranges_find_end.h+5-4
......@@ -21,12 +21,13 @@
2121#include <__ranges/access.h>
2222#include <__ranges/concepts.h>
2323#include <__ranges/subrange.h>
24#include <__utility/pair.h>
2425
2526#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2627# pragma GCC system_header
2728#endif
2829
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
30#if _LIBCPP_STD_VER > 17
3031
3132_LIBCPP_BEGIN_NAMESPACE_STD
3233
......@@ -39,7 +40,7 @@ struct __fn {
3940 class _Proj1 = identity,
4041 class _Proj2 = identity>
4142 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
42 _LIBCPP_HIDE_FROM_ABI constexpr
43 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
4344 subrange<_Iter1> operator()(_Iter1 __first1, _Sent1 __last1,
4445 _Iter2 __first2, _Sent2 __last2,
4546 _Pred __pred = {},
......@@ -64,7 +65,7 @@ struct __fn {
6465 class _Proj1 = identity,
6566 class _Proj2 = identity>
6667 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
67 _LIBCPP_HIDE_FROM_ABI constexpr
68 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
6869 borrowed_subrange_t<_Range1> operator()(_Range1&& __range1,
6970 _Range2&& __range2,
7071 _Pred __pred = {},
......@@ -92,6 +93,6 @@ inline namespace __cpo {
9293
9394_LIBCPP_END_NAMESPACE_STD
9495
95#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
96#endif // _LIBCPP_STD_VER > 17
9697
9798#endif // _LIBCPP___ALGORITHM_RANGES_FIND_END_H
lib/libcxx/include/__algorithm/ranges_find_first_of.h+4-4
......@@ -24,7 +24,7 @@
2424# pragma GCC system_header
2525#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27#if _LIBCPP_STD_VER > 17
2828
2929_LIBCPP_BEGIN_NAMESPACE_STD
3030
......@@ -54,7 +54,7 @@ struct __fn {
5454 class _Proj1 = identity,
5555 class _Proj2 = identity>
5656 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
57 _LIBCPP_HIDE_FROM_ABI constexpr
57 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
5858 _Iter1 operator()(_Iter1 __first1, _Sent1 __last1,
5959 _Iter2 __first2, _Sent2 __last2,
6060 _Pred __pred = {},
......@@ -73,7 +73,7 @@ struct __fn {
7373 class _Proj1 = identity,
7474 class _Proj2 = identity>
7575 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
76 _LIBCPP_HIDE_FROM_ABI constexpr
76 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
7777 borrowed_iterator_t<_Range1> operator()(_Range1&& __range1,
7878 _Range2&& __range2,
7979 _Pred __pred = {},
......@@ -96,6 +96,6 @@ inline namespace __cpo {
9696
9797_LIBCPP_END_NAMESPACE_STD
9898
99#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
99#endif // _LIBCPP_STD_VER > 17
100100
101101#endif // _LIBCPP___ALGORITHM_RANGES_FIND_FIRST_OF_H
lib/libcxx/include/__algorithm/ranges_find_if.h+4-4
......@@ -24,7 +24,7 @@
2424# pragma GCC system_header
2525#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27#if _LIBCPP_STD_VER > 17
2828
2929_LIBCPP_BEGIN_NAMESPACE_STD
3030
......@@ -45,14 +45,14 @@ struct __fn {
4545
4646 template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
4747 indirect_unary_predicate<projected<_Ip, _Proj>> _Pred>
48 _LIBCPP_HIDE_FROM_ABI constexpr
48 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
4949 _Ip operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const {
5050 return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred, __proj);
5151 }
5252
5353 template <input_range _Rp, class _Proj = identity,
5454 indirect_unary_predicate<projected<iterator_t<_Rp>, _Proj>> _Pred>
55 _LIBCPP_HIDE_FROM_ABI constexpr
55 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
5656 borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const {
5757 return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
5858 }
......@@ -66,6 +66,6 @@ inline namespace __cpo {
6666
6767_LIBCPP_END_NAMESPACE_STD
6868
69#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
69#endif // _LIBCPP_STD_VER > 17
7070
7171#endif // _LIBCPP___ALGORITHM_RANGES_FIND_IF_H
lib/libcxx/include/__algorithm/ranges_find_if_not.h+4-4
......@@ -26,7 +26,7 @@
2626# pragma GCC system_header
2727#endif
2828
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
29#if _LIBCPP_STD_VER > 17
3030
3131_LIBCPP_BEGIN_NAMESPACE_STD
3232
......@@ -35,7 +35,7 @@ namespace __find_if_not {
3535struct __fn {
3636 template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
3737 indirect_unary_predicate<projected<_Ip, _Proj>> _Pred>
38 _LIBCPP_HIDE_FROM_ABI constexpr
38 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
3939 _Ip operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const {
4040 auto __pred2 = [&](auto&& __e) { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); };
4141 return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred2, __proj);
......@@ -43,7 +43,7 @@ struct __fn {
4343
4444 template <input_range _Rp, class _Proj = identity,
4545 indirect_unary_predicate<projected<iterator_t<_Rp>, _Proj>> _Pred>
46 _LIBCPP_HIDE_FROM_ABI constexpr
46 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
4747 borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const {
4848 auto __pred2 = [&](auto&& __e) { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); };
4949 return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred2, __proj);
......@@ -58,6 +58,6 @@ inline namespace __cpo {
5858
5959_LIBCPP_END_NAMESPACE_STD
6060
61#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
61#endif // _LIBCPP_STD_VER > 17
6262
6363#endif // _LIBCPP___ALGORITHM_RANGES_FIND_IF_NOT_H
lib/libcxx/include/__algorithm/ranges_for_each.h+2-2
......@@ -24,7 +24,7 @@
2424# pragma GCC system_header
2525#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27#if _LIBCPP_STD_VER > 17
2828
2929_LIBCPP_BEGIN_NAMESPACE_STD
3030
......@@ -73,6 +73,6 @@ inline namespace __cpo {
7373
7474_LIBCPP_END_NAMESPACE_STD
7575
76#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
76#endif // _LIBCPP_STD_VER > 17
7777
7878#endif // _LIBCPP___ALGORITHM_RANGES_FOR_EACH_H
lib/libcxx/include/__algorithm/ranges_for_each_n.h+2-2
......@@ -24,7 +24,7 @@
2424# pragma GCC system_header
2525#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27#if _LIBCPP_STD_VER > 17
2828
2929_LIBCPP_BEGIN_NAMESPACE_STD
3030
......@@ -61,6 +61,6 @@ inline namespace __cpo {
6161
6262_LIBCPP_END_NAMESPACE_STD
6363
64#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
64#endif // _LIBCPP_STD_VER > 17
6565
6666#endif // _LIBCPP___ALGORITHM_RANGES_FOR_EACH_N_H
lib/libcxx/include/__algorithm/ranges_generate.h+2-2
......@@ -24,7 +24,7 @@
2424# pragma GCC system_header
2525#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27#if _LIBCPP_STD_VER > 17
2828
2929_LIBCPP_BEGIN_NAMESPACE_STD
3030
......@@ -68,6 +68,6 @@ inline namespace __cpo {
6868
6969_LIBCPP_END_NAMESPACE_STD
7070
71#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
71#endif // _LIBCPP_STD_VER > 17
7272
7373#endif // _LIBCPP___ALGORITHM_RANGES_GENERATE_H
lib/libcxx/include/__algorithm/ranges_generate_n.h+2-2
......@@ -25,7 +25,7 @@
2525# pragma GCC system_header
2626#endif
2727
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28#if _LIBCPP_STD_VER > 17
2929
3030_LIBCPP_BEGIN_NAMESPACE_STD
3131
......@@ -57,6 +57,6 @@ inline namespace __cpo {
5757
5858_LIBCPP_END_NAMESPACE_STD
5959
60#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
60#endif // _LIBCPP_STD_VER > 17
6161
6262#endif // _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H
lib/libcxx/include/__algorithm/ranges_includes.h+4-4
......@@ -27,7 +27,7 @@
2727# pragma GCC system_header
2828#endif
2929
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
30#if _LIBCPP_STD_VER > 17
3131
3232_LIBCPP_BEGIN_NAMESPACE_STD
3333
......@@ -43,7 +43,7 @@ struct __fn {
4343 class _Proj1 = identity,
4444 class _Proj2 = identity,
4545 indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less>
46 _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
46 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
4747 _Iter1 __first1,
4848 _Sent1 __last1,
4949 _Iter2 __first2,
......@@ -68,7 +68,7 @@ struct __fn {
6868 class _Proj2 = identity,
6969 indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>>
7070 _Comp = ranges::less>
71 _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
71 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
7272 _Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
7373 return std::__includes(
7474 ranges::begin(__range1),
......@@ -90,6 +90,6 @@ inline namespace __cpo {
9090
9191_LIBCPP_END_NAMESPACE_STD
9292
93#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
93#endif // _LIBCPP_STD_VER > 17
9494
9595#endif // _LIBCPP___ALGORITHM_RANGES_INCLUDES_H
lib/libcxx/include/__algorithm/ranges_inplace_merge.h+2-2
......@@ -31,7 +31,7 @@
3131# pragma GCC system_header
3232#endif
3333
34#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
34#if _LIBCPP_STD_VER > 17
3535
3636_LIBCPP_BEGIN_NAMESPACE_STD
3737
......@@ -80,6 +80,6 @@ inline namespace __cpo {
8080
8181_LIBCPP_END_NAMESPACE_STD
8282
83#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
83#endif // _LIBCPP_STD_VER > 17
8484
8585#endif // _LIBCPP___ALGORITHM_RANGES_INPLACE_MERGE_H
lib/libcxx/include/__algorithm/ranges_is_heap.h+4-4
......@@ -26,7 +26,7 @@
2626# pragma GCC system_header
2727#endif
2828
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
29#if _LIBCPP_STD_VER > 17
3030
3131_LIBCPP_BEGIN_NAMESPACE_STD
3232
......@@ -47,14 +47,14 @@ struct __fn {
4747
4848 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
4949 indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
50 _LIBCPP_HIDE_FROM_ABI constexpr
50 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
5151 bool operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
5252 return __is_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
5353 }
5454
5555 template <random_access_range _Range, class _Proj = identity,
5656 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
57 _LIBCPP_HIDE_FROM_ABI constexpr
57 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
5858 bool operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
5959 return __is_heap_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);
6060 }
......@@ -69,6 +69,6 @@ inline namespace __cpo {
6969
7070_LIBCPP_END_NAMESPACE_STD
7171
72#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
72#endif // _LIBCPP_STD_VER > 17
7373
7474#endif // _LIBCPP___ALGORITHM_RANGES_IS_HEAP_H
lib/libcxx/include/__algorithm/ranges_is_heap_until.h+4-4
......@@ -27,7 +27,7 @@
2727# pragma GCC system_header
2828#endif
2929
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
30#if _LIBCPP_STD_VER > 17
3131
3232_LIBCPP_BEGIN_NAMESPACE_STD
3333
......@@ -47,14 +47,14 @@ struct __fn {
4747
4848 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
4949 indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
50 _LIBCPP_HIDE_FROM_ABI constexpr
50 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
5151 _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
5252 return __is_heap_until_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
5353 }
5454
5555 template <random_access_range _Range, class _Proj = identity,
5656 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
57 _LIBCPP_HIDE_FROM_ABI constexpr
57 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
5858 borrowed_iterator_t<_Range> operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
5959 return __is_heap_until_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);
6060 }
......@@ -70,6 +70,6 @@ inline namespace __cpo {
7070
7171_LIBCPP_END_NAMESPACE_STD
7272
73#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
73#endif // _LIBCPP_STD_VER > 17
7474
7575#endif // _LIBCPP___ALGORITHM_RANGES_IS_HEAP_UNTIL_H
lib/libcxx/include/__algorithm/ranges_is_partitioned.h+4-4
......@@ -23,7 +23,7 @@
2323# pragma GCC system_header
2424#endif
2525
26#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
26#if _LIBCPP_STD_VER > 17
2727
2828_LIBCPP_BEGIN_NAMESPACE_STD
2929
......@@ -54,7 +54,7 @@ struct __fn {
5454 template <input_iterator _Iter, sentinel_for<_Iter> _Sent,
5555 class _Proj = identity,
5656 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
57 _LIBCPP_HIDE_FROM_ABI constexpr
57 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
5858 bool operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
5959 return __is_parititioned_impl(std::move(__first), std::move(__last), __pred, __proj);
6060 }
......@@ -62,7 +62,7 @@ struct __fn {
6262 template <input_range _Range,
6363 class _Proj = identity,
6464 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
65 _LIBCPP_HIDE_FROM_ABI constexpr
65 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
6666 bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
6767 return __is_parititioned_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
6868 }
......@@ -76,6 +76,6 @@ inline namespace __cpo {
7676
7777_LIBCPP_END_NAMESPACE_STD
7878
79#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
79#endif // _LIBCPP_STD_VER > 17
8080
8181#endif // _LIBCPP___ALGORITHM_RANGES_IS_PARTITIONED_H
lib/libcxx/include/__algorithm/ranges_is_permutation.h+4-4
......@@ -25,7 +25,7 @@
2525# pragma GCC system_header
2626#endif
2727
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28#if _LIBCPP_STD_VER > 17
2929
3030_LIBCPP_BEGIN_NAMESPACE_STD
3131
......@@ -49,7 +49,7 @@ struct __fn {
4949 class _Proj2 = identity,
5050 indirect_equivalence_relation<projected<_Iter1, _Proj1>,
5151 projected<_Iter2, _Proj2>> _Pred = ranges::equal_to>
52 _LIBCPP_HIDE_FROM_ABI constexpr
52 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
5353 bool operator()(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
5454 _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
5555 return __is_permutation_func_impl(
......@@ -62,7 +62,7 @@ struct __fn {
6262 class _Proj1 = identity,
6363 class _Proj2 = identity,
6464 indirect_equivalence_relation<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>> _Pred = ranges::equal_to>
65 _LIBCPP_HIDE_FROM_ABI constexpr
65 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
6666 bool operator()(_Range1&& __range1, _Range2&& __range2,
6767 _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
6868 if constexpr (sized_range<_Range1> && sized_range<_Range2>) {
......@@ -84,6 +84,6 @@ inline namespace __cpo {
8484
8585_LIBCPP_END_NAMESPACE_STD
8686
87#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
87#endif // _LIBCPP_STD_VER > 17
8888
8989#endif // _LIBCPP___ALGORITHM_RANGES_IS_PERMUTATION_H
lib/libcxx/include/__algorithm/ranges_is_sorted.h+4-4
......@@ -23,7 +23,7 @@
2323# pragma GCC system_header
2424#endif
2525
26#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
26#if _LIBCPP_STD_VER > 17
2727
2828_LIBCPP_BEGIN_NAMESPACE_STD
2929
......@@ -33,7 +33,7 @@ struct __fn {
3333 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent,
3434 class _Proj = identity,
3535 indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
36 _LIBCPP_HIDE_FROM_ABI constexpr
36 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
3737 bool operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
3838 return ranges::__is_sorted_until_impl(std::move(__first), __last, __comp, __proj) == __last;
3939 }
......@@ -41,7 +41,7 @@ struct __fn {
4141 template <forward_range _Range,
4242 class _Proj = identity,
4343 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
44 _LIBCPP_HIDE_FROM_ABI constexpr
44 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
4545 bool operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
4646 auto __last = ranges::end(__range);
4747 return ranges::__is_sorted_until_impl(ranges::begin(__range), __last, __comp, __proj) == __last;
......@@ -56,6 +56,6 @@ inline namespace __cpo {
5656
5757_LIBCPP_END_NAMESPACE_STD
5858
59#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
59#endif // _LIBCPP_STD_VER > 17
6060
6161#endif // _LIBCPP__ALGORITHM_RANGES_IS_SORTED_H
lib/libcxx/include/__algorithm/ranges_is_sorted_until.h+4-4
......@@ -24,7 +24,7 @@
2424# pragma GCC system_header
2525#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27#if _LIBCPP_STD_VER > 17
2828
2929_LIBCPP_BEGIN_NAMESPACE_STD
3030
......@@ -49,7 +49,7 @@ struct __fn {
4949 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent,
5050 class _Proj = identity,
5151 indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
52 _LIBCPP_HIDE_FROM_ABI constexpr
52 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
5353 _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
5454 return ranges::__is_sorted_until_impl(std::move(__first), std::move(__last), __comp, __proj);
5555 }
......@@ -57,7 +57,7 @@ struct __fn {
5757 template <forward_range _Range,
5858 class _Proj = identity,
5959 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
60 _LIBCPP_HIDE_FROM_ABI constexpr
60 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
6161 borrowed_iterator_t<_Range> operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
6262 return ranges::__is_sorted_until_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);
6363 }
......@@ -71,6 +71,6 @@ inline namespace __cpo {
7171
7272_LIBCPP_END_NAMESPACE_STD
7373
74#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
74#endif // _LIBCPP_STD_VER > 17
7575
7676#endif // _LIBCPP__ALGORITHM_RANGES_IS_SORTED_UNTIL_H
lib/libcxx/include/__algorithm/ranges_iterator_concept.h+4-4
......@@ -12,13 +12,13 @@
1212#include <__config>
1313#include <__iterator/concepts.h>
1414#include <__iterator/iterator_traits.h>
15#include <type_traits>
15#include <__type_traits/remove_cvref.h>
1616
1717#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1818# pragma GCC system_header
1919#endif
2020
21#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
21#if _LIBCPP_STD_VER > 17
2222
2323_LIBCPP_BEGIN_NAMESPACE_STD
2424
......@@ -26,7 +26,7 @@ namespace ranges {
2626
2727template <class _IterMaybeQualified>
2828consteval auto __get_iterator_concept() {
29 using _Iter = __uncvref_t<_IterMaybeQualified>;
29 using _Iter = __remove_cvref_t<_IterMaybeQualified>;
3030
3131 if constexpr (contiguous_iterator<_Iter>)
3232 return contiguous_iterator_tag();
......@@ -46,6 +46,6 @@ using __iterator_concept = decltype(__get_iterator_concept<_Iter>());
4646} // namespace ranges
4747_LIBCPP_END_NAMESPACE_STD
4848
49#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
49#endif // _LIBCPP_STD_VER > 17
5050
5151#endif // _LIBCPP___ALGORITHM_RANGES_ITERATOR_CONCEPT_H
lib/libcxx/include/__algorithm/ranges_lexicographical_compare.h+4-4
......@@ -23,7 +23,7 @@
2323# pragma GCC system_header
2424#endif
2525
26#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
26#if _LIBCPP_STD_VER > 17
2727
2828_LIBCPP_BEGIN_NAMESPACE_STD
2929
......@@ -55,7 +55,7 @@ struct __fn {
5555 class _Proj1 = identity,
5656 class _Proj2 = identity,
5757 indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less>
58 _LIBCPP_HIDE_FROM_ABI constexpr
58 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
5959 bool operator()(_Iter1 __first1, _Sent1 __last1,
6060 _Iter2 __first2, _Sent2 __last2,
6161 _Comp __comp = {},
......@@ -74,7 +74,7 @@ struct __fn {
7474 class _Proj2 = identity,
7575 indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>,
7676 projected<iterator_t<_Range2>, _Proj2>> _Comp = ranges::less>
77 _LIBCPP_HIDE_FROM_ABI constexpr
77 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
7878 bool operator()(_Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
7979 return __lexicographical_compare_impl(ranges::begin(__range1), ranges::end(__range1),
8080 ranges::begin(__range2), ranges::end(__range2),
......@@ -93,6 +93,6 @@ inline namespace __cpo {
9393
9494_LIBCPP_END_NAMESPACE_STD
9595
96#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
96#endif // _LIBCPP_STD_VER > 17
9797
9898#endif // _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H
lib/libcxx/include/__algorithm/ranges_lower_bound.h+4-4
......@@ -27,7 +27,7 @@
2727# pragma GCC system_header
2828#endif
2929
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
30#if _LIBCPP_STD_VER > 17
3131
3232_LIBCPP_BEGIN_NAMESPACE_STD
3333
......@@ -37,14 +37,14 @@ namespace __lower_bound {
3737struct __fn {
3838 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity,
3939 indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less>
40 _LIBCPP_HIDE_FROM_ABI constexpr
40 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
4141 _Iter operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
4242 return std::__lower_bound_impl<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj);
4343 }
4444
4545 template <forward_range _Range, class _Type, class _Proj = identity,
4646 indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
47 _LIBCPP_HIDE_FROM_ABI constexpr
47 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
4848 borrowed_iterator_t<_Range> operator()(_Range&& __r,
4949 const _Type& __value,
5050 _Comp __comp = {},
......@@ -61,6 +61,6 @@ inline namespace __cpo {
6161
6262_LIBCPP_END_NAMESPACE_STD
6363
64#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
64#endif // _LIBCPP_STD_VER > 17
6565
6666#endif // _LIBCPP___ALGORITHM_RANGES_LOWER_BOUND_H
lib/libcxx/include/__algorithm/ranges_make_heap.h+2-2
......@@ -32,7 +32,7 @@
3232# pragma GCC system_header
3333#endif
3434
35#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
35#if _LIBCPP_STD_VER > 17
3636
3737_LIBCPP_BEGIN_NAMESPACE_STD
3838
......@@ -75,6 +75,6 @@ inline namespace __cpo {
7575
7676_LIBCPP_END_NAMESPACE_STD
7777
78#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
78#endif // _LIBCPP_STD_VER > 17
7979
8080#endif // _LIBCPP___ALGORITHM_RANGES_MAKE_HEAP_H
lib/libcxx/include/__algorithm/ranges_max.h+5-5
......@@ -27,7 +27,7 @@
2727# pragma GCC system_header
2828#endif
2929
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
30#if _LIBCPP_STD_VER > 17
3131
3232_LIBCPP_PUSH_MACROS
3333#include <__undef_macros>
......@@ -39,14 +39,14 @@ namespace __max {
3939struct __fn {
4040 template <class _Tp, class _Proj = identity,
4141 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
42 _LIBCPP_HIDE_FROM_ABI constexpr
42 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
4343 const _Tp& operator()(const _Tp& __a, const _Tp& __b, _Comp __comp = {}, _Proj __proj = {}) const {
4444 return std::invoke(__comp, std::invoke(__proj, __a), std::invoke(__proj, __b)) ? __b : __a;
4545 }
4646
4747 template <copyable _Tp, class _Proj = identity,
4848 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
49 _LIBCPP_HIDE_FROM_ABI constexpr
49 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
5050 _Tp operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const {
5151 _LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list must contain at least one element");
5252
......@@ -57,7 +57,7 @@ struct __fn {
5757 template <input_range _Rp, class _Proj = identity,
5858 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
5959 requires indirectly_copyable_storable<iterator_t<_Rp>, range_value_t<_Rp>*>
60 _LIBCPP_HIDE_FROM_ABI constexpr
60 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
6161 range_value_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
6262 auto __first = ranges::begin(__r);
6363 auto __last = ranges::end(__r);
......@@ -88,6 +88,6 @@ _LIBCPP_END_NAMESPACE_STD
8888
8989_LIBCPP_POP_MACROS
9090
91#endif // _LIBCPP_STD_VER > 17 && && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
91#endif // _LIBCPP_STD_VER > 17 &&
9292
9393#endif // _LIBCPP___ALGORITHM_RANGES_MAX_H
lib/libcxx/include/__algorithm/ranges_max_element.h+4-4
......@@ -24,7 +24,7 @@
2424# pragma GCC system_header
2525#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27#if _LIBCPP_STD_VER > 17
2828
2929_LIBCPP_BEGIN_NAMESPACE_STD
3030
......@@ -33,7 +33,7 @@ namespace __max_element {
3333struct __fn {
3434 template <forward_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
3535 indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less>
36 _LIBCPP_HIDE_FROM_ABI constexpr
36 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
3737 _Ip operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
3838 auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); };
3939 return ranges::__min_element_impl(__first, __last, __comp_lhs_rhs_swapped, __proj);
......@@ -41,7 +41,7 @@ struct __fn {
4141
4242 template <forward_range _Rp, class _Proj = identity,
4343 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
44 _LIBCPP_HIDE_FROM_ABI constexpr
44 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
4545 borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
4646 auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); };
4747 return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp_lhs_rhs_swapped, __proj);
......@@ -56,6 +56,6 @@ inline namespace __cpo {
5656
5757_LIBCPP_END_NAMESPACE_STD
5858
59#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
59#endif // _LIBCPP_STD_VER > 17
6060
6161#endif // _LIBCPP___ALGORITHM_RANGES_MAX_ELEMENT_H
lib/libcxx/include/__algorithm/ranges_merge.h+4-4
......@@ -27,7 +27,7 @@
2727# pragma GCC system_header
2828#endif
2929
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
30#if _LIBCPP_STD_VER > 17
3131
3232_LIBCPP_BEGIN_NAMESPACE_STD
3333
......@@ -47,7 +47,7 @@ template <
4747 class _Comp,
4848 class _Proj1,
4949 class _Proj2>
50_LIBCPP_HIDE_FROM_ABI constexpr merge_result<__uncvref_t<_InIter1>, __uncvref_t<_InIter2>, __uncvref_t<_OutIter>>
50_LIBCPP_HIDE_FROM_ABI constexpr merge_result<__remove_cvref_t<_InIter1>, __remove_cvref_t<_InIter2>, __remove_cvref_t<_OutIter>>
5151__merge_impl(
5252 _InIter1&& __first1,
5353 _Sent1&& __last1,
......@@ -107,7 +107,7 @@ struct __fn {
107107 _OutIter,
108108 _Comp,
109109 _Proj1,
110 _Proj2>
110 _Proj2>
111111 _LIBCPP_HIDE_FROM_ABI constexpr merge_result<borrowed_iterator_t<_Range1>, borrowed_iterator_t<_Range2>, _OutIter>
112112 operator()(
113113 _Range1&& __range1,
......@@ -137,6 +137,6 @@ inline namespace __cpo {
137137
138138_LIBCPP_END_NAMESPACE_STD
139139
140#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
140#endif // _LIBCPP_STD_VER > 17
141141
142142#endif // _LIBCPP___ALGORITHM_RANGES_MERGE_H
lib/libcxx/include/__algorithm/ranges_min.h+5-5
......@@ -26,7 +26,7 @@
2626# pragma GCC system_header
2727#endif
2828
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
29#if _LIBCPP_STD_VER > 17
3030
3131_LIBCPP_PUSH_MACROS
3232#include <__undef_macros>
......@@ -38,14 +38,14 @@ namespace __min {
3838struct __fn {
3939 template <class _Tp, class _Proj = identity,
4040 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
41 _LIBCPP_HIDE_FROM_ABI constexpr
41 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
4242 const _Tp& operator()(const _Tp& __a, const _Tp& __b, _Comp __comp = {}, _Proj __proj = {}) const {
4343 return std::invoke(__comp, std::invoke(__proj, __b), std::invoke(__proj, __a)) ? __b : __a;
4444 }
4545
4646 template <copyable _Tp, class _Proj = identity,
4747 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
48 _LIBCPP_HIDE_FROM_ABI constexpr
48 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
4949 _Tp operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const {
5050 _LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list must contain at least one element");
5151 return *ranges::__min_element_impl(__il.begin(), __il.end(), __comp, __proj);
......@@ -54,7 +54,7 @@ struct __fn {
5454 template <input_range _Rp, class _Proj = identity,
5555 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
5656 requires indirectly_copyable_storable<iterator_t<_Rp>, range_value_t<_Rp>*>
57 _LIBCPP_HIDE_FROM_ABI constexpr
57 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
5858 range_value_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
5959 auto __first = ranges::begin(__r);
6060 auto __last = ranges::end(__r);
......@@ -84,6 +84,6 @@ _LIBCPP_END_NAMESPACE_STD
8484
8585_LIBCPP_POP_MACROS
8686
87#endif // _LIBCPP_STD_VER > 17 && && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
87#endif // _LIBCPP_STD_VER > 17 &&
8888
8989#endif // _LIBCPP___ALGORITHM_RANGES_MIN_H
lib/libcxx/include/__algorithm/ranges_min_element.h+4-4
......@@ -24,7 +24,7 @@
2424# pragma GCC system_header
2525#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27#if _LIBCPP_STD_VER > 17
2828
2929_LIBCPP_BEGIN_NAMESPACE_STD
3030
......@@ -48,14 +48,14 @@ namespace __min_element {
4848struct __fn {
4949 template <forward_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
5050 indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less>
51 _LIBCPP_HIDE_FROM_ABI constexpr
51 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
5252 _Ip operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
5353 return ranges::__min_element_impl(__first, __last, __comp, __proj);
5454 }
5555
5656 template <forward_range _Rp, class _Proj = identity,
5757 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
58 _LIBCPP_HIDE_FROM_ABI constexpr
58 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
5959 borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
6060 return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
6161 }
......@@ -69,6 +69,6 @@ inline namespace __cpo {
6969
7070_LIBCPP_END_NAMESPACE_STD
7171
72#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
72#endif // _LIBCPP_STD_VER > 17
7373
7474#endif // _LIBCPP___ALGORITHM_RANGES_MIN_ELEMENT_H
lib/libcxx/include/__algorithm/ranges_minmax.h+6-5
......@@ -23,13 +23,14 @@
2323#include <__ranges/concepts.h>
2424#include <__utility/forward.h>
2525#include <__utility/move.h>
26#include <__utility/pair.h>
2627#include <initializer_list>
2728
2829#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2930# pragma GCC system_header
3031#endif
3132
32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
33#if _LIBCPP_STD_VER > 17
3334
3435_LIBCPP_PUSH_MACROS
3536#include <__undef_macros>
......@@ -44,7 +45,7 @@ namespace __minmax {
4445struct __fn {
4546 template <class _Type, class _Proj = identity,
4647 indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>
47 _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result<const _Type&>
48 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result<const _Type&>
4849 operator()(const _Type& __a, const _Type& __b, _Comp __comp = {}, _Proj __proj = {}) const {
4950 if (std::invoke(__comp, std::invoke(__proj, __b), std::invoke(__proj, __a)))
5051 return {__b, __a};
......@@ -53,7 +54,7 @@ struct __fn {
5354
5455 template <copyable _Type, class _Proj = identity,
5556 indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>
56 _LIBCPP_HIDE_FROM_ABI constexpr
57 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
5758 ranges::minmax_result<_Type> operator()(initializer_list<_Type> __il, _Comp __comp = {}, _Proj __proj = {}) const {
5859 _LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list has to contain at least one element");
5960 auto __iters = std::__minmax_element_impl(__il.begin(), __il.end(), __comp, __proj);
......@@ -63,7 +64,7 @@ struct __fn {
6364 template <input_range _Range, class _Proj = identity,
6465 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
6566 requires indirectly_copyable_storable<iterator_t<_Range>, range_value_t<_Range>*>
66 _LIBCPP_HIDE_FROM_ABI constexpr
67 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
6768 ranges::minmax_result<range_value_t<_Range>> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
6869 auto __first = ranges::begin(__r);
6970 auto __last = ranges::end(__r);
......@@ -128,6 +129,6 @@ _LIBCPP_END_NAMESPACE_STD
128129
129130_LIBCPP_POP_MACROS
130131
131#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
132#endif // _LIBCPP_STD_VER > 17
132133
133134#endif // _LIBCPP___ALGORITHM_RANGES_MINMAX_H
lib/libcxx/include/__algorithm/ranges_minmax_element.h+4-4
......@@ -29,7 +29,7 @@
2929# pragma GCC system_header
3030#endif
3131
32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
32#if _LIBCPP_STD_VER > 17
3333
3434_LIBCPP_BEGIN_NAMESPACE_STD
3535
......@@ -42,7 +42,7 @@ namespace __minmax_element {
4242struct __fn {
4343 template <forward_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
4444 indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less>
45 _LIBCPP_HIDE_FROM_ABI constexpr
45 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
4646 ranges::minmax_element_result<_Ip> operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
4747 auto __ret = std::__minmax_element_impl(std::move(__first), std::move(__last), __comp, __proj);
4848 return {__ret.first, __ret.second};
......@@ -50,7 +50,7 @@ struct __fn {
5050
5151 template <forward_range _Rp, class _Proj = identity,
5252 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
53 _LIBCPP_HIDE_FROM_ABI constexpr
53 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
5454 ranges::minmax_element_result<borrowed_iterator_t<_Rp>>
5555 operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
5656 auto __ret = std::__minmax_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
......@@ -67,6 +67,6 @@ inline namespace __cpo {
6767
6868_LIBCPP_END_NAMESPACE_STD
6969
70#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
70#endif // _LIBCPP_STD_VER > 17
7171
7272#endif // _LIBCPP___ALGORITHM_RANGES_MINMAX_H
lib/libcxx/include/__algorithm/ranges_mismatch.h+4-4
......@@ -27,7 +27,7 @@
2727
2828_LIBCPP_BEGIN_NAMESPACE_STD
2929
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
30#if _LIBCPP_STD_VER > 17
3131
3232namespace ranges {
3333
......@@ -55,7 +55,7 @@ struct __fn {
5555 input_iterator _I2, sentinel_for<_I2> _S2,
5656 class _Pred = ranges::equal_to, class _Proj1 = identity, class _Proj2 = identity>
5757 requires indirectly_comparable<_I1, _I2, _Pred, _Proj1, _Proj2>
58 _LIBCPP_HIDE_FROM_ABI constexpr
58 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
5959 mismatch_result<_I1, _I2> operator()(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2,
6060 _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
6161 return __go(std::move(__first1), __last1, std::move(__first2), __last2, __pred, __proj1, __proj2);
......@@ -64,7 +64,7 @@ struct __fn {
6464 template <input_range _R1, input_range _R2,
6565 class _Pred = ranges::equal_to, class _Proj1 = identity, class _Proj2 = identity>
6666 requires indirectly_comparable<iterator_t<_R1>, iterator_t<_R2>, _Pred, _Proj1, _Proj2>
67 _LIBCPP_HIDE_FROM_ABI constexpr
67 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
6868 mismatch_result<borrowed_iterator_t<_R1>, borrowed_iterator_t<_R2>>
6969 operator()(_R1&& __r1, _R2&& __r2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
7070 return __go(ranges::begin(__r1), ranges::end(__r1), ranges::begin(__r2), ranges::end(__r2),
......@@ -78,7 +78,7 @@ inline namespace __cpo {
7878} // namespace __cpo
7979} // namespace ranges
8080
81#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
81#endif // _LIBCPP_STD_VER > 17
8282
8383_LIBCPP_END_NAMESPACE_STD
8484
lib/libcxx/include/__algorithm/ranges_move.h+2-3
......@@ -14,7 +14,6 @@
1414#include <__algorithm/move.h>
1515#include <__config>
1616#include <__iterator/concepts.h>
17#include <__iterator/iter_move.h>
1817#include <__ranges/access.h>
1918#include <__ranges/concepts.h>
2019#include <__ranges/dangling.h>
......@@ -24,7 +23,7 @@
2423# pragma GCC system_header
2524#endif
2625
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
26#if _LIBCPP_STD_VER > 17
2827
2928_LIBCPP_BEGIN_NAMESPACE_STD
3029
......@@ -67,6 +66,6 @@ inline namespace __cpo {
6766
6867_LIBCPP_END_NAMESPACE_STD
6968
70#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
69#endif // _LIBCPP_STD_VER > 17
7170
7271#endif // _LIBCPP___ALGORITHM_RANGES_MOVE_H
lib/libcxx/include/__algorithm/ranges_move_backward.h+6-9
......@@ -10,12 +10,12 @@
1010#define _LIBCPP___ALGORITHM_RANGES_MOVE_BACKWARD_H
1111
1212#include <__algorithm/in_out_result.h>
13#include <__algorithm/ranges_move.h>
13#include <__algorithm/iterator_operations.h>
14#include <__algorithm/move_backward.h>
1415#include <__config>
1516#include <__iterator/concepts.h>
1617#include <__iterator/iter_move.h>
1718#include <__iterator/next.h>
18#include <__iterator/reverse_iterator.h>
1919#include <__ranges/access.h>
2020#include <__ranges/concepts.h>
2121#include <__ranges/dangling.h>
......@@ -25,7 +25,7 @@
2525# pragma GCC system_header
2626#endif
2727
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28#if _LIBCPP_STD_VER > 17
2929
3030_LIBCPP_BEGIN_NAMESPACE_STD
3131
......@@ -40,11 +40,8 @@ struct __fn {
4040 template <class _InIter, class _Sent, class _OutIter>
4141 _LIBCPP_HIDE_FROM_ABI constexpr static
4242 move_backward_result<_InIter, _OutIter> __move_backward_impl(_InIter __first, _Sent __last, _OutIter __result) {
43 auto __last_iter = ranges::next(__first, std::move(__last));
44 auto __ret = ranges::move(std::make_reverse_iterator(__last_iter),
45 std::make_reverse_iterator(__first),
46 std::make_reverse_iterator(__result));
47 return {std::move(__last_iter), std::move(__ret.out.base())};
43 auto __ret = std::__move_backward<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__result));
44 return {std::move(__ret.first), std::move(__ret.second)};
4845 }
4946
5047 template <bidirectional_iterator _InIter, sentinel_for<_InIter> _Sent, bidirectional_iterator _OutIter>
......@@ -71,6 +68,6 @@ inline namespace __cpo {
7168
7269_LIBCPP_END_NAMESPACE_STD
7370
74#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
71#endif // _LIBCPP_STD_VER > 17
7572
7673#endif // _LIBCPP___ALGORITHM_RANGES_MOVE_BACKWARD_H
lib/libcxx/include/__algorithm/ranges_next_permutation.h+3-2
......@@ -22,12 +22,13 @@
2222#include <__ranges/concepts.h>
2323#include <__ranges/dangling.h>
2424#include <__utility/move.h>
25#include <__utility/pair.h>
2526
2627#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2728# pragma GCC system_header
2829#endif
2930
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
31#if _LIBCPP_STD_VER > 17
3132
3233_LIBCPP_BEGIN_NAMESPACE_STD
3334
......@@ -67,6 +68,6 @@ constexpr inline auto next_permutation = __next_permutation::__fn{};
6768
6869_LIBCPP_END_NAMESPACE_STD
6970
70#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
71#endif // _LIBCPP_STD_VER > 17
7172
7273#endif // _LIBCPP___ALGORITHM_RANGES_NEXT_PERMUTATION_H
lib/libcxx/include/__algorithm/ranges_none_of.h+4-4
......@@ -22,7 +22,7 @@
2222# pragma GCC system_header
2323#endif
2424
25#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
25#if _LIBCPP_STD_VER > 17
2626
2727_LIBCPP_BEGIN_NAMESPACE_STD
2828
......@@ -42,14 +42,14 @@ struct __fn {
4242
4343 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
4444 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
45 _LIBCPP_HIDE_FROM_ABI constexpr
45 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
4646 bool operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {
4747 return __none_of_impl(std::move(__first), std::move(__last), __pred, __proj);
4848 }
4949
5050 template <input_range _Range, class _Proj = identity,
5151 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
52 _LIBCPP_HIDE_FROM_ABI constexpr
52 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
5353 bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
5454 return __none_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
5555 }
......@@ -63,6 +63,6 @@ inline namespace __cpo {
6363
6464_LIBCPP_END_NAMESPACE_STD
6565
66#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
66#endif // _LIBCPP_STD_VER > 17
6767
6868#endif // _LIBCPP___ALGORITHM_RANGES_NONE_OF_H
lib/libcxx/include/__algorithm/ranges_nth_element.h+2-2
......@@ -31,7 +31,7 @@
3131# pragma GCC system_header
3232#endif
3333
34#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
34#if _LIBCPP_STD_VER > 17
3535
3636_LIBCPP_BEGIN_NAMESPACE_STD
3737
......@@ -75,6 +75,6 @@ inline namespace __cpo {
7575
7676_LIBCPP_END_NAMESPACE_STD
7777
78#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
78#endif // _LIBCPP_STD_VER > 17
7979
8080#endif // _LIBCPP___ALGORITHM_RANGES_NTH_ELEMENT_H
lib/libcxx/include/__algorithm/ranges_partial_sort.h+3-2
......@@ -27,12 +27,13 @@
2727#include <__ranges/dangling.h>
2828#include <__utility/forward.h>
2929#include <__utility/move.h>
30#include <__utility/pair.h>
3031
3132#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3233# pragma GCC system_header
3334#endif
3435
35#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
36#if _LIBCPP_STD_VER > 17
3637
3738_LIBCPP_BEGIN_NAMESPACE_STD
3839
......@@ -72,6 +73,6 @@ inline namespace __cpo {
7273
7374_LIBCPP_END_NAMESPACE_STD
7475
75#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
76#endif // _LIBCPP_STD_VER > 17
7677
7778#endif // _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_H
lib/libcxx/include/__algorithm/ranges_partial_sort_copy.h+3-2
......@@ -24,12 +24,13 @@
2424#include <__ranges/concepts.h>
2525#include <__ranges/dangling.h>
2626#include <__utility/move.h>
27#include <__utility/pair.h>
2728
2829#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2930# pragma GCC system_header
3031#endif
3132
32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
33#if _LIBCPP_STD_VER > 17
3334
3435_LIBCPP_BEGIN_NAMESPACE_STD
3536
......@@ -86,6 +87,6 @@ inline namespace __cpo {
8687
8788_LIBCPP_END_NAMESPACE_STD
8889
89#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
90#endif // _LIBCPP_STD_VER > 17
9091
9192#endif // _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_COPY_H
lib/libcxx/include/__algorithm/ranges_partition.h+4-3
......@@ -26,13 +26,14 @@
2626#include <__ranges/subrange.h>
2727#include <__utility/forward.h>
2828#include <__utility/move.h>
29#include <__utility/pair.h>
2930#include <type_traits>
3031
3132#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3233# pragma GCC system_header
3334#endif
3435
35#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
36#if _LIBCPP_STD_VER > 17
3637
3738_LIBCPP_BEGIN_NAMESPACE_STD
3839
......@@ -43,7 +44,7 @@ struct __fn {
4344
4445 template <class _Iter, class _Sent, class _Proj, class _Pred>
4546 _LIBCPP_HIDE_FROM_ABI static constexpr
46 subrange<__uncvref_t<_Iter>> __partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {
47 subrange<__remove_cvref_t<_Iter>> __partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {
4748 auto&& __projected_pred = std::__make_projected(__pred, __proj);
4849 auto __result = std::__partition<_RangeAlgPolicy>(
4950 std::move(__first), std::move(__last), __projected_pred, __iterator_concept<_Iter>());
......@@ -77,6 +78,6 @@ inline namespace __cpo {
7778
7879_LIBCPP_END_NAMESPACE_STD
7980
80#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
81#endif // _LIBCPP_STD_VER > 17
8182
8283#endif // _LIBCPP___ALGORITHM_RANGES_PARTITION_H
lib/libcxx/include/__algorithm/ranges_partition_copy.h+3-3
......@@ -26,7 +26,7 @@
2626# pragma GCC system_header
2727#endif
2828
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
29#if _LIBCPP_STD_VER > 17
3030
3131_LIBCPP_BEGIN_NAMESPACE_STD
3232
......@@ -43,7 +43,7 @@ struct __fn {
4343 template <class _InIter, class _Sent, class _OutIter1, class _OutIter2, class _Proj, class _Pred>
4444 _LIBCPP_HIDE_FROM_ABI constexpr
4545 static partition_copy_result<
46 __uncvref_t<_InIter>, __uncvref_t<_OutIter1>, __uncvref_t<_OutIter2>
46 __remove_cvref_t<_InIter>, __remove_cvref_t<_OutIter1>, __remove_cvref_t<_OutIter2>
4747 > __partition_copy_fn_impl( _InIter&& __first, _Sent&& __last, _OutIter1&& __out_true, _OutIter2&& __out_false,
4848 _Pred& __pred, _Proj& __proj) {
4949 for (; __first != __last; ++__first) {
......@@ -93,6 +93,6 @@ inline namespace __cpo {
9393
9494_LIBCPP_END_NAMESPACE_STD
9595
96#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
96#endif // _LIBCPP_STD_VER > 17
9797
9898#endif // _LIBCPP___ALGORITHM_RANGES_PARTITION_COPY_H
lib/libcxx/include/__algorithm/ranges_partition_point.h+2-2
......@@ -27,7 +27,7 @@
2727# pragma GCC system_header
2828#endif
2929
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
30#if _LIBCPP_STD_VER > 17
3131
3232_LIBCPP_BEGIN_NAMESPACE_STD
3333
......@@ -83,6 +83,6 @@ inline namespace __cpo {
8383
8484_LIBCPP_END_NAMESPACE_STD
8585
86#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
86#endif // _LIBCPP_STD_VER > 17
8787
8888#endif // _LIBCPP___ALGORITHM_RANGES_PARTITION_POINT_H
lib/libcxx/include/__algorithm/ranges_pop_heap.h+2-2
......@@ -32,7 +32,7 @@
3232# pragma GCC system_header
3333#endif
3434
35#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
35#if _LIBCPP_STD_VER > 17
3636
3737_LIBCPP_BEGIN_NAMESPACE_STD
3838
......@@ -76,6 +76,6 @@ inline namespace __cpo {
7676
7777_LIBCPP_END_NAMESPACE_STD
7878
79#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
79#endif // _LIBCPP_STD_VER > 17
8080
8181#endif // _LIBCPP___ALGORITHM_RANGES_POP_HEAP_H
lib/libcxx/include/__algorithm/ranges_prev_permutation.h+3-2
......@@ -22,12 +22,13 @@
2222#include <__ranges/concepts.h>
2323#include <__ranges/dangling.h>
2424#include <__utility/move.h>
25#include <__utility/pair.h>
2526
2627#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2728# pragma GCC system_header
2829#endif
2930
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
31#if _LIBCPP_STD_VER > 17
3132
3233_LIBCPP_BEGIN_NAMESPACE_STD
3334
......@@ -71,6 +72,6 @@ constexpr inline auto prev_permutation = __prev_permutation::__fn{};
7172
7273_LIBCPP_END_NAMESPACE_STD
7374
74#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
75#endif // _LIBCPP_STD_VER > 17
7576
7677#endif // _LIBCPP___ALGORITHM_RANGES_PREV_PERMUTATION_H
lib/libcxx/include/__algorithm/ranges_push_heap.h+2-2
......@@ -32,7 +32,7 @@
3232# pragma GCC system_header
3333#endif
3434
35#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
35#if _LIBCPP_STD_VER > 17
3636
3737_LIBCPP_BEGIN_NAMESPACE_STD
3838
......@@ -75,6 +75,6 @@ inline namespace __cpo {
7575
7676_LIBCPP_END_NAMESPACE_STD
7777
78#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
78#endif // _LIBCPP_STD_VER > 17
7979
8080#endif // _LIBCPP___ALGORITHM_RANGES_PUSH_HEAP_H
lib/libcxx/include/__algorithm/ranges_remove.h+4-4
......@@ -25,7 +25,7 @@
2525# pragma GCC system_header
2626#endif
2727
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28#if _LIBCPP_STD_VER > 17
2929
3030_LIBCPP_BEGIN_NAMESPACE_STD
3131
......@@ -35,7 +35,7 @@ struct __fn {
3535
3636 template <permutable _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>
3737 requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>
38 _LIBCPP_HIDE_FROM_ABI constexpr
38 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
3939 subrange<_Iter> operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const {
4040 auto __pred = [&](auto&& __other) { return __value == __other; };
4141 return ranges::__remove_if_impl(std::move(__first), std::move(__last), __pred, __proj);
......@@ -44,7 +44,7 @@ struct __fn {
4444 template <forward_range _Range, class _Type, class _Proj = identity>
4545 requires permutable<iterator_t<_Range>>
4646 && indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
47 _LIBCPP_HIDE_FROM_ABI constexpr
47 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
4848 borrowed_subrange_t<_Range> operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const {
4949 auto __pred = [&](auto&& __other) { return __value == __other; };
5050 return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
......@@ -59,6 +59,6 @@ inline namespace __cpo {
5959
6060_LIBCPP_END_NAMESPACE_STD
6161
62#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
62#endif // _LIBCPP_STD_VER > 17
6363
6464#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_H
lib/libcxx/include/__algorithm/ranges_remove_copy.h+2-2
......@@ -26,7 +26,7 @@
2626# pragma GCC system_header
2727#endif
2828
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
29#if _LIBCPP_STD_VER > 17
3030
3131_LIBCPP_BEGIN_NAMESPACE_STD
3232
......@@ -71,6 +71,6 @@ inline namespace __cpo {
7171
7272_LIBCPP_END_NAMESPACE_STD
7373
74#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
74#endif // _LIBCPP_STD_VER > 17
7575
7676#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_H
lib/libcxx/include/__algorithm/ranges_remove_copy_if.h+2-2
......@@ -29,7 +29,7 @@
2929# pragma GCC system_header
3030#endif
3131
32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
32#if _LIBCPP_STD_VER > 17
3333
3434_LIBCPP_BEGIN_NAMESPACE_STD
3535
......@@ -85,6 +85,6 @@ inline namespace __cpo {
8585
8686_LIBCPP_END_NAMESPACE_STD
8787
88#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
88#endif // _LIBCPP_STD_VER > 17
8989
9090#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_IF_H
lib/libcxx/include/__algorithm/ranges_remove_if.h+4-4
......@@ -27,7 +27,7 @@
2727# pragma GCC system_header
2828#endif
2929
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
30#if _LIBCPP_STD_VER > 17
3131
3232_LIBCPP_BEGIN_NAMESPACE_STD
3333
......@@ -56,7 +56,7 @@ struct __fn {
5656 template <permutable _Iter, sentinel_for<_Iter> _Sent,
5757 class _Proj = identity,
5858 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
59 _LIBCPP_HIDE_FROM_ABI constexpr
59 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
6060 subrange<_Iter> operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
6161 return ranges::__remove_if_impl(std::move(__first), std::move(__last), __pred, __proj);
6262 }
......@@ -65,7 +65,7 @@ struct __fn {
6565 class _Proj = identity,
6666 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
6767 requires permutable<iterator_t<_Range>>
68 _LIBCPP_HIDE_FROM_ABI constexpr
68 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
6969 borrowed_subrange_t<_Range> operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
7070 return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
7171 }
......@@ -80,6 +80,6 @@ inline namespace __cpo {
8080
8181_LIBCPP_END_NAMESPACE_STD
8282
83#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
83#endif // _LIBCPP_STD_VER > 17
8484
8585#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_IF_H
lib/libcxx/include/__algorithm/ranges_replace.h+2-2
......@@ -24,7 +24,7 @@
2424# pragma GCC system_header
2525#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27#if _LIBCPP_STD_VER > 17
2828
2929_LIBCPP_BEGIN_NAMESPACE_STD
3030
......@@ -69,6 +69,6 @@ inline namespace __cpo {
6969
7070_LIBCPP_END_NAMESPACE_STD
7171
72#endif // _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
72#endif // _LIBCPP_STD_VER > 17
7373
7474#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_H
lib/libcxx/include/__algorithm/ranges_replace_copy.h+2-2
......@@ -26,7 +26,7 @@
2626# pragma GCC system_header
2727#endif
2828
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
29#if _LIBCPP_STD_VER > 17
3030
3131_LIBCPP_BEGIN_NAMESPACE_STD
3232
......@@ -86,6 +86,6 @@ inline namespace __cpo {
8686
8787_LIBCPP_END_NAMESPACE_STD
8888
89#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
89#endif // _LIBCPP_STD_VER > 17
9090
9191#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_H
lib/libcxx/include/__algorithm/ranges_replace_copy_if.h+2-2
......@@ -24,7 +24,7 @@
2424# pragma GCC system_header
2525#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27#if _LIBCPP_STD_VER > 17
2828
2929_LIBCPP_BEGIN_NAMESPACE_STD
3030
......@@ -88,6 +88,6 @@ inline namespace __cpo {
8888
8989_LIBCPP_END_NAMESPACE_STD
9090
91#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
91#endif // _LIBCPP_STD_VER > 17
9292
9393#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_IF_H
lib/libcxx/include/__algorithm/ranges_replace_if.h+2-2
......@@ -23,7 +23,7 @@
2323# pragma GCC system_header
2424#endif
2525
26#if _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
26#if _LIBCPP_STD_VER > 17
2727
2828_LIBCPP_BEGIN_NAMESPACE_STD
2929
......@@ -72,6 +72,6 @@ inline namespace __cpo {
7272
7373_LIBCPP_END_NAMESPACE_STD
7474
75#endif // _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
75#endif // _LIBCPP_STD_VER > 17
7676
7777#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_IF_H
lib/libcxx/include/__algorithm/ranges_reverse.h+2-2
......@@ -22,7 +22,7 @@
2222# pragma GCC system_header
2323#endif
2424
25#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
25#if _LIBCPP_STD_VER > 17
2626
2727_LIBCPP_BEGIN_NAMESPACE_STD
2828
......@@ -78,6 +78,6 @@ inline namespace __cpo {
7878
7979_LIBCPP_END_NAMESPACE_STD
8080
81#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
81#endif // _LIBCPP_STD_VER > 17
8282
8383#endif // _LIBCPP___ALGORITHM_RANGES_REVERSE_H
lib/libcxx/include/__algorithm/ranges_reverse_copy.h+2-2
......@@ -25,7 +25,7 @@
2525# pragma GCC system_header
2626#endif
2727
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28#if _LIBCPP_STD_VER > 17
2929
3030_LIBCPP_BEGIN_NAMESPACE_STD
3131
......@@ -62,6 +62,6 @@ inline namespace __cpo {
6262
6363_LIBCPP_END_NAMESPACE_STD
6464
65#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
65#endif // _LIBCPP_STD_VER > 17
6666
6767#endif // _LIBCPP___ALGORITHM_RANGES_REVERSE_COPY_H
lib/libcxx/include/__algorithm/ranges_rotate.h+2-2
......@@ -25,7 +25,7 @@
2525# pragma GCC system_header
2626#endif
2727
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28#if _LIBCPP_STD_VER > 17
2929
3030_LIBCPP_BEGIN_NAMESPACE_STD
3131
......@@ -66,6 +66,6 @@ inline namespace __cpo {
6666
6767_LIBCPP_END_NAMESPACE_STD
6868
69#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
69#endif // _LIBCPP_STD_VER > 17
7070
7171#endif // _LIBCPP___ALGORITHM_RANGES_ROTATE_H
lib/libcxx/include/__algorithm/ranges_rotate_copy.h+2-2
......@@ -23,7 +23,7 @@
2323# pragma GCC system_header
2424#endif
2525
26#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
26#if _LIBCPP_STD_VER > 17
2727
2828_LIBCPP_BEGIN_NAMESPACE_STD
2929
......@@ -63,6 +63,6 @@ inline namespace __cpo {
6363
6464_LIBCPP_END_NAMESPACE_STD
6565
66#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
66#endif // _LIBCPP_STD_VER > 17
6767
6868#endif // _LIBCPP___ALGORITHM_RANGES_ROTATE_COPY_H
lib/libcxx/include/__algorithm/ranges_sample.h+2-2
......@@ -27,7 +27,7 @@
2727# pragma GCC system_header
2828#endif
2929
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
30#if _LIBCPP_STD_VER > 17
3131
3232_LIBCPP_BEGIN_NAMESPACE_STD
3333
......@@ -69,6 +69,6 @@ inline namespace __cpo {
6969
7070_LIBCPP_END_NAMESPACE_STD
7171
72#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
72#endif // _LIBCPP_STD_VER > 17
7373
7474#endif // _LIBCPP___ALGORITHM_RANGES_SAMPLE_H
lib/libcxx/include/__algorithm/ranges_search.h+5-4
......@@ -22,12 +22,13 @@
2222#include <__ranges/concepts.h>
2323#include <__ranges/size.h>
2424#include <__ranges/subrange.h>
25#include <__utility/pair.h>
2526
2627#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2728# pragma GCC system_header
2829#endif
2930
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
31#if _LIBCPP_STD_VER > 17
3132
3233_LIBCPP_BEGIN_NAMESPACE_STD
3334
......@@ -74,7 +75,7 @@ struct __fn {
7475 class _Proj1 = identity,
7576 class _Proj2 = identity>
7677 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
77 _LIBCPP_HIDE_FROM_ABI constexpr
78 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
7879 subrange<_Iter1> operator()(_Iter1 __first1, _Sent1 __last1,
7980 _Iter2 __first2, _Sent2 __last2,
8081 _Pred __pred = {},
......@@ -89,7 +90,7 @@ struct __fn {
8990 class _Proj1 = identity,
9091 class _Proj2 = identity>
9192 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
92 _LIBCPP_HIDE_FROM_ABI constexpr
93 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
9394 borrowed_subrange_t<_Range1> operator()(_Range1&& __range1,
9495 _Range2&& __range2,
9596 _Pred __pred = {},
......@@ -129,6 +130,6 @@ inline namespace __cpo {
129130
130131_LIBCPP_END_NAMESPACE_STD
131132
132#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
133#endif // _LIBCPP_STD_VER > 17
133134
134135#endif // _LIBCPP___ALGORITHM_RANGES_SEARCH_H
lib/libcxx/include/__algorithm/ranges_search_n.h+7-10
......@@ -25,12 +25,13 @@
2525#include <__ranges/size.h>
2626#include <__ranges/subrange.h>
2727#include <__utility/move.h>
28#include <__utility/pair.h>
2829
2930#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3031# pragma GCC system_header
3132#endif
3233
33#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
34#if _LIBCPP_STD_VER > 17
3435
3536_LIBCPP_BEGIN_NAMESPACE_STD
3637
......@@ -52,12 +53,8 @@ struct __fn {
5253 }
5354
5455 if constexpr (random_access_iterator<_Iter1>) {
55 auto __ret = __search_n_random_access_impl<_RangeAlgPolicy>(__first, __last,
56 __count,
57 __value,
58 __pred,
59 __proj,
60 __size);
56 auto __ret = std::__search_n_random_access_impl<_RangeAlgPolicy>(
57 __first, __last, __count, __value, __pred, __proj, __size);
6158 return {std::move(__ret.first), std::move(__ret.second)};
6259 }
6360 }
......@@ -75,7 +72,7 @@ struct __fn {
7572 class _Pred = ranges::equal_to,
7673 class _Proj = identity>
7774 requires indirectly_comparable<_Iter, const _Type*, _Pred, _Proj>
78 _LIBCPP_HIDE_FROM_ABI constexpr
75 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
7976 subrange<_Iter> operator()(_Iter __first, _Sent __last,
8077 iter_difference_t<_Iter> __count,
8178 const _Type& __value,
......@@ -86,7 +83,7 @@ struct __fn {
8683
8784 template <forward_range _Range, class _Type, class _Pred = ranges::equal_to, class _Proj = identity>
8885 requires indirectly_comparable<iterator_t<_Range>, const _Type*, _Pred, _Proj>
89 _LIBCPP_HIDE_FROM_ABI constexpr
86 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
9087 borrowed_subrange_t<_Range> operator()(_Range&& __range,
9188 range_difference_t<_Range> __count,
9289 const _Type& __value,
......@@ -115,6 +112,6 @@ inline namespace __cpo {
115112
116113_LIBCPP_END_NAMESPACE_STD
117114
118#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
115#endif // _LIBCPP_STD_VER > 17
119116
120117#endif // _LIBCPP___ALGORITHM_RANGES_SEARCH_N_H
lib/libcxx/include/__algorithm/ranges_set_difference.h+7-5
......@@ -10,6 +10,7 @@
1010#define _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H
1111
1212#include <__algorithm/in_out_result.h>
13#include <__algorithm/iterator_operations.h>
1314#include <__algorithm/make_projected.h>
1415#include <__algorithm/set_difference.h>
1516#include <__config>
......@@ -23,12 +24,13 @@
2324#include <__ranges/dangling.h>
2425#include <__type_traits/decay.h>
2526#include <__utility/move.h>
27#include <__utility/pair.h>
2628
2729#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2830# pragma GCC system_header
2931#endif
3032
31#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
33#if _LIBCPP_STD_VER > 17
3234
3335_LIBCPP_BEGIN_NAMESPACE_STD
3436
......@@ -59,7 +61,7 @@ struct __fn {
5961 _Comp __comp = {},
6062 _Proj1 __proj1 = {},
6163 _Proj2 __proj2 = {}) const {
62 auto __ret = std::__set_difference(
64 auto __ret = std::__set_difference<_RangeAlgPolicy>(
6365 __first1, __last1, __first2, __last2, __result, ranges::__make_projected_comp(__comp, __proj1, __proj2));
6466 return {std::move(__ret.first), std::move(__ret.second)};
6567 }
......@@ -71,7 +73,7 @@ struct __fn {
7173 class _Comp = less,
7274 class _Proj1 = identity,
7375 class _Proj2 = identity>
74 requires mergeable<iterator_t<_Range1>, iterator_t<_Range2>, _OutIter, _Comp, _Proj1, _Proj2>
76 requires mergeable<iterator_t<_Range1>, iterator_t<_Range2>, _OutIter, _Comp, _Proj1, _Proj2>
7577 _LIBCPP_HIDE_FROM_ABI constexpr set_difference_result<borrowed_iterator_t<_Range1>, _OutIter>
7678 operator()(
7779 _Range1&& __range1,
......@@ -80,7 +82,7 @@ struct __fn {
8082 _Comp __comp = {},
8183 _Proj1 __proj1 = {},
8284 _Proj2 __proj2 = {}) const {
83 auto __ret = std::__set_difference(
85 auto __ret = std::__set_difference<_RangeAlgPolicy>(
8486 ranges::begin(__range1),
8587 ranges::end(__range1),
8688 ranges::begin(__range2),
......@@ -100,5 +102,5 @@ inline namespace __cpo {
100102
101103_LIBCPP_END_NAMESPACE_STD
102104
103#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
105#endif // _LIBCPP_STD_VER > 17
104106#endif // _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H
lib/libcxx/include/__algorithm/ranges_set_intersection.h+3-3
......@@ -28,7 +28,7 @@
2828# pragma GCC system_header
2929#endif
3030
31#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
31#if _LIBCPP_STD_VER > 17
3232
3333_LIBCPP_BEGIN_NAMESPACE_STD
3434
......@@ -82,7 +82,7 @@ struct __fn {
8282 _OutIter,
8383 _Comp,
8484 _Proj1,
85 _Proj2>
85 _Proj2>
8686 _LIBCPP_HIDE_FROM_ABI constexpr set_intersection_result<borrowed_iterator_t<_Range1>,
8787 borrowed_iterator_t<_Range2>,
8888 _OutIter>
......@@ -113,5 +113,5 @@ inline namespace __cpo {
113113
114114_LIBCPP_END_NAMESPACE_STD
115115
116#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
116#endif // _LIBCPP_STD_VER > 17
117117#endif // _LIBCPP___ALGORITHM_RANGES_SET_INTERSECTION_H
lib/libcxx/include/__algorithm/ranges_set_symmetric_difference.h+6-5
......@@ -10,6 +10,7 @@
1010#define _LIBCPP___ALGORITHM_RANGES_SET_SYMMETRIC_DIFFERENCE_H
1111
1212#include <__algorithm/in_in_out_result.h>
13#include <__algorithm/iterator_operations.h>
1314#include <__algorithm/make_projected.h>
1415#include <__algorithm/set_symmetric_difference.h>
1516#include <__config>
......@@ -27,7 +28,7 @@
2728# pragma GCC system_header
2829#endif
2930
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
31#if _LIBCPP_STD_VER > 17
3132
3233_LIBCPP_BEGIN_NAMESPACE_STD
3334
......@@ -58,7 +59,7 @@ struct __fn {
5859 _Comp __comp = {},
5960 _Proj1 __proj1 = {},
6061 _Proj2 __proj2 = {}) const {
61 auto __ret = std::__set_symmetric_difference(
62 auto __ret = std::__set_symmetric_difference<_RangeAlgPolicy>(
6263 std::move(__first1),
6364 std::move(__last1),
6465 std::move(__first2),
......@@ -81,7 +82,7 @@ struct __fn {
8182 _OutIter,
8283 _Comp,
8384 _Proj1,
84 _Proj2>
85 _Proj2>
8586 _LIBCPP_HIDE_FROM_ABI constexpr set_symmetric_difference_result<borrowed_iterator_t<_Range1>,
8687 borrowed_iterator_t<_Range2>,
8788 _OutIter>
......@@ -92,7 +93,7 @@ struct __fn {
9293 _Comp __comp = {},
9394 _Proj1 __proj1 = {},
9495 _Proj2 __proj2 = {}) const {
95 auto __ret = std::__set_symmetric_difference(
96 auto __ret = std::__set_symmetric_difference<_RangeAlgPolicy>(
9697 ranges::begin(__range1),
9798 ranges::end(__range1),
9899 ranges::begin(__range2),
......@@ -112,5 +113,5 @@ inline namespace __cpo {
112113
113114_LIBCPP_END_NAMESPACE_STD
114115
115#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
116#endif // _LIBCPP_STD_VER > 17
116117#endif // _LIBCPP___ALGORITHM_RANGES_SET_SYMMETRIC_DIFFERENCE_H
lib/libcxx/include/__algorithm/ranges_set_union.h+6-5
......@@ -10,6 +10,7 @@
1010#define _LIBCPP___ALGORITHM_RANGES_SET_UNION_H
1111
1212#include <__algorithm/in_in_out_result.h>
13#include <__algorithm/iterator_operations.h>
1314#include <__algorithm/make_projected.h>
1415#include <__algorithm/set_union.h>
1516#include <__config>
......@@ -30,7 +31,7 @@
3031# pragma GCC system_header
3132#endif
3233
33#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
34#if _LIBCPP_STD_VER > 17
3435
3536_LIBCPP_BEGIN_NAMESPACE_STD
3637
......@@ -61,7 +62,7 @@ struct __fn {
6162 _Comp __comp = {},
6263 _Proj1 __proj1 = {},
6364 _Proj2 __proj2 = {}) const {
64 auto __ret = std::__set_union(
65 auto __ret = std::__set_union<_RangeAlgPolicy>(
6566 std::move(__first1),
6667 std::move(__last1),
6768 std::move(__first2),
......@@ -84,7 +85,7 @@ struct __fn {
8485 _OutIter,
8586 _Comp,
8687 _Proj1,
87 _Proj2>
88 _Proj2>
8889 _LIBCPP_HIDE_FROM_ABI constexpr set_union_result<borrowed_iterator_t<_Range1>,
8990 borrowed_iterator_t<_Range2>,
9091 _OutIter>
......@@ -95,7 +96,7 @@ struct __fn {
9596 _Comp __comp = {},
9697 _Proj1 __proj1 = {},
9798 _Proj2 __proj2 = {}) const {
98 auto __ret = std::__set_union(
99 auto __ret = std::__set_union<_RangeAlgPolicy>(
99100 ranges::begin(__range1),
100101 ranges::end(__range1),
101102 ranges::begin(__range2),
......@@ -115,6 +116,6 @@ inline namespace __cpo {
115116
116117_LIBCPP_END_NAMESPACE_STD
117118
118#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
119#endif // _LIBCPP_STD_VER > 17
119120
120121#endif // _LIBCPP___ALGORITHM_RANGES_SET_UNION_H
lib/libcxx/include/__algorithm/ranges_shuffle.h+2-2
......@@ -31,7 +31,7 @@
3131# pragma GCC system_header
3232#endif
3333
34#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
34#if _LIBCPP_STD_VER > 17
3535
3636_LIBCPP_BEGIN_NAMESPACE_STD
3737
......@@ -66,6 +66,6 @@ inline namespace __cpo {
6666
6767_LIBCPP_END_NAMESPACE_STD
6868
69#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
69#endif // _LIBCPP_STD_VER > 17
7070
7171#endif // _LIBCPP___ALGORITHM_RANGES_SHUFFLE_H
lib/libcxx/include/__algorithm/ranges_sort.h+2-2
......@@ -31,7 +31,7 @@
3131# pragma GCC system_header
3232#endif
3333
34#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
34#if _LIBCPP_STD_VER > 17
3535
3636_LIBCPP_BEGIN_NAMESPACE_STD
3737
......@@ -74,6 +74,6 @@ inline namespace __cpo {
7474
7575_LIBCPP_END_NAMESPACE_STD
7676
77#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
77#endif // _LIBCPP_STD_VER > 17
7878
7979#endif // _LIBCPP___ALGORITHM_RANGES_SORT_H
lib/libcxx/include/__algorithm/ranges_sort_heap.h+2-2
......@@ -32,7 +32,7 @@
3232# pragma GCC system_header
3333#endif
3434
35#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
35#if _LIBCPP_STD_VER > 17
3636
3737_LIBCPP_BEGIN_NAMESPACE_STD
3838
......@@ -75,6 +75,6 @@ inline namespace __cpo {
7575
7676_LIBCPP_END_NAMESPACE_STD
7777
78#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
78#endif // _LIBCPP_STD_VER > 17
7979
8080#endif // _LIBCPP___ALGORITHM_RANGES_SORT_HEAP_H
lib/libcxx/include/__algorithm/ranges_stable_partition.h+3-3
......@@ -34,7 +34,7 @@
3434# pragma GCC system_header
3535#endif
3636
37#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
37#if _LIBCPP_STD_VER > 17
3838
3939_LIBCPP_BEGIN_NAMESPACE_STD
4040
......@@ -45,7 +45,7 @@ struct __fn {
4545
4646 template <class _Iter, class _Sent, class _Proj, class _Pred>
4747 _LIBCPP_HIDE_FROM_ABI static
48 subrange<__uncvref_t<_Iter>> __stable_partition_fn_impl(
48 subrange<__remove_cvref_t<_Iter>> __stable_partition_fn_impl(
4949 _Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {
5050 auto __last_iter = ranges::next(__first, __last);
5151
......@@ -83,6 +83,6 @@ inline namespace __cpo {
8383
8484_LIBCPP_END_NAMESPACE_STD
8585
86#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
86#endif // _LIBCPP_STD_VER > 17
8787
8888#endif // _LIBCPP___ALGORITHM_RANGES_STABLE_PARTITION_H
lib/libcxx/include/__algorithm/ranges_stable_sort.h+2-2
......@@ -31,7 +31,7 @@
3131# pragma GCC system_header
3232#endif
3333
34#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
34#if _LIBCPP_STD_VER > 17
3535
3636_LIBCPP_BEGIN_NAMESPACE_STD
3737
......@@ -74,6 +74,6 @@ inline namespace __cpo {
7474
7575_LIBCPP_END_NAMESPACE_STD
7676
77#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
77#endif // _LIBCPP_STD_VER > 17
7878
7979#endif // _LIBCPP___ALGORITHM_RANGES_STABLE_SORT_H
lib/libcxx/include/__algorithm/ranges_swap_ranges.h+2-2
......@@ -24,7 +24,7 @@
2424# pragma GCC system_header
2525#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27#if _LIBCPP_STD_VER > 17
2828
2929_LIBCPP_BEGIN_NAMESPACE_STD
3030
......@@ -63,6 +63,6 @@ inline namespace __cpo {
6363
6464_LIBCPP_END_NAMESPACE_STD
6565
66#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
66#endif // _LIBCPP_STD_VER > 17
6767
6868#endif // _LIBCPP___ALGORITHM_RANGES_SWAP_RANGES_H
lib/libcxx/include/__algorithm/ranges_transform.h+2-2
......@@ -26,7 +26,7 @@
2626# pragma GCC system_header
2727#endif
2828
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
29#if _LIBCPP_STD_VER > 17
3030
3131_LIBCPP_BEGIN_NAMESPACE_STD
3232
......@@ -165,6 +165,6 @@ inline namespace __cpo {
165165
166166_LIBCPP_END_NAMESPACE_STD
167167
168#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
168#endif // _LIBCPP_STD_VER > 17
169169
170170#endif // _LIBCPP___ALGORITHM_RANGES_TRANSFORM_H
lib/libcxx/include/__algorithm/ranges_unique.h+5-4
......@@ -26,12 +26,13 @@
2626#include <__ranges/subrange.h>
2727#include <__utility/forward.h>
2828#include <__utility/move.h>
29#include <__utility/pair.h>
2930
3031#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3132# pragma GCC system_header
3233#endif
3334
34#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
35#if _LIBCPP_STD_VER > 17
3536
3637_LIBCPP_BEGIN_NAMESPACE_STD
3738
......@@ -44,7 +45,7 @@ namespace __unique {
4445 sentinel_for<_Iter> _Sent,
4546 class _Proj = identity,
4647 indirect_equivalence_relation<projected<_Iter, _Proj>> _Comp = ranges::equal_to>
47 _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
48 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
4849 operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
4950 auto __ret = std::__unique<_RangeAlgPolicy>(
5051 std::move(__first), std::move(__last), std::__make_projected(__comp, __proj));
......@@ -56,7 +57,7 @@ namespace __unique {
5657 class _Proj = identity,
5758 indirect_equivalence_relation<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::equal_to>
5859 requires permutable<iterator_t<_Range>>
59 _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>
60 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>
6061 operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
6162 auto __ret = std::__unique<_RangeAlgPolicy>(
6263 ranges::begin(__range), ranges::end(__range), std::__make_projected(__comp, __proj));
......@@ -73,6 +74,6 @@ inline namespace __cpo {
7374
7475_LIBCPP_END_NAMESPACE_STD
7576
76#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
77#endif // _LIBCPP_STD_VER > 17
7778
7879#endif // _LIBCPP___ALGORITHM_RANGES_UNIQUE_H
lib/libcxx/include/__algorithm/ranges_unique_copy.h+3-2
......@@ -27,12 +27,13 @@
2727#include <__ranges/dangling.h>
2828#include <__utility/forward.h>
2929#include <__utility/move.h>
30#include <__utility/pair.h>
3031
3132#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3233# pragma GCC system_header
3334#endif
3435
35#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
36#if _LIBCPP_STD_VER > 17
3637
3738_LIBCPP_BEGIN_NAMESPACE_STD
3839
......@@ -110,6 +111,6 @@ inline constexpr auto unique_copy = __unique_copy::__fn{};
110111
111112_LIBCPP_END_NAMESPACE_STD
112113
113#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
114#endif // _LIBCPP_STD_VER > 17
114115
115116#endif // _LIBCPP___ALGORITHM_RANGES_UNIQUE_COPY_H
lib/libcxx/include/__algorithm/ranges_upper_bound.h+4-4
......@@ -25,7 +25,7 @@
2525# pragma GCC system_header
2626#endif
2727
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
28#if _LIBCPP_STD_VER > 17
2929
3030_LIBCPP_BEGIN_NAMESPACE_STD
3131
......@@ -34,7 +34,7 @@ namespace __upper_bound {
3434struct __fn {
3535 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity,
3636 indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less>
37 _LIBCPP_HIDE_FROM_ABI constexpr
37 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
3838 _Iter operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
3939 auto __comp_lhs_rhs_swapped = [&](const auto& __lhs, const auto& __rhs) {
4040 return !std::invoke(__comp, __rhs, __lhs);
......@@ -45,7 +45,7 @@ struct __fn {
4545
4646 template <forward_range _Range, class _Type, class _Proj = identity,
4747 indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
48 _LIBCPP_HIDE_FROM_ABI constexpr
48 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
4949 borrowed_iterator_t<_Range> operator()(_Range&& __r,
5050 const _Type& __value,
5151 _Comp __comp = {},
......@@ -70,6 +70,6 @@ inline namespace __cpo {
7070
7171_LIBCPP_END_NAMESPACE_STD
7272
73#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
73#endif // _LIBCPP_STD_VER > 17
7474
7575#endif // _LIBCPP___ALGORITHM_RANGES_UPPER_BOUND_H
lib/libcxx/include/__algorithm/remove.h+1-1
......@@ -21,7 +21,7 @@
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
2323template <class _ForwardIterator, class _Tp>
24_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
24_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
2525remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
2626{
2727 __first = _VSTD::find(__first, __last, __value);
lib/libcxx/include/__algorithm/remove_copy.h+1-1
......@@ -18,7 +18,7 @@
1818_LIBCPP_BEGIN_NAMESPACE_STD
1919
2020template <class _InputIterator, class _OutputIterator, class _Tp>
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2222_OutputIterator
2323remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value)
2424{
lib/libcxx/include/__algorithm/remove_copy_if.h+1-1
......@@ -18,7 +18,7 @@
1818_LIBCPP_BEGIN_NAMESPACE_STD
1919
2020template <class _InputIterator, class _OutputIterator, class _Predicate>
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2222_OutputIterator
2323remove_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred)
2424{
lib/libcxx/include/__algorithm/remove_if.h+1-1
......@@ -20,7 +20,7 @@
2020_LIBCPP_BEGIN_NAMESPACE_STD
2121
2222template <class _ForwardIterator, class _Predicate>
23_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
23_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
2424remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
2525{
2626 __first = _VSTD::find_if<_ForwardIterator, _Predicate&>(__first, __last, __pred);
lib/libcxx/include/__algorithm/replace.h+1-1
......@@ -18,7 +18,7 @@
1818_LIBCPP_BEGIN_NAMESPACE_STD
1919
2020template <class _ForwardIterator, class _Tp>
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2222void
2323replace(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_value, const _Tp& __new_value)
2424{
lib/libcxx/include/__algorithm/replace_copy.h+1-1
......@@ -18,7 +18,7 @@
1818_LIBCPP_BEGIN_NAMESPACE_STD
1919
2020template <class _InputIterator, class _OutputIterator, class _Tp>
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2222_OutputIterator
2323replace_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
2424 const _Tp& __old_value, const _Tp& __new_value)
lib/libcxx/include/__algorithm/replace_copy_if.h+1-1
......@@ -18,7 +18,7 @@
1818_LIBCPP_BEGIN_NAMESPACE_STD
1919
2020template <class _InputIterator, class _OutputIterator, class _Predicate, class _Tp>
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2222_OutputIterator
2323replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
2424 _Predicate __pred, const _Tp& __new_value)
lib/libcxx/include/__algorithm/replace_if.h+1-1
......@@ -18,7 +18,7 @@
1818_LIBCPP_BEGIN_NAMESPACE_STD
1919
2020template <class _ForwardIterator, class _Predicate, class _Tp>
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2222void
2323replace_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, const _Tp& __new_value)
2424{
lib/libcxx/include/__algorithm/reverse.h+4-4
......@@ -22,7 +22,7 @@
2222_LIBCPP_BEGIN_NAMESPACE_STD
2323
2424template <class _AlgPolicy, class _BidirectionalIterator>
25inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
25inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2626void
2727__reverse_impl(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirectional_iterator_tag)
2828{
......@@ -36,7 +36,7 @@ __reverse_impl(_BidirectionalIterator __first, _BidirectionalIterator __last, bi
3636}
3737
3838template <class _AlgPolicy, class _RandomAccessIterator>
39inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
39inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
4040void
4141__reverse_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, random_access_iterator_tag)
4242{
......@@ -46,14 +46,14 @@ __reverse_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, rand
4646}
4747
4848template <class _AlgPolicy, class _BidirectionalIterator, class _Sentinel>
49_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
49_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
5050void __reverse(_BidirectionalIterator __first, _Sentinel __last) {
5151 using _IterCategory = typename _IterOps<_AlgPolicy>::template __iterator_category<_BidirectionalIterator>;
5252 std::__reverse_impl<_AlgPolicy>(std::move(__first), std::move(__last), _IterCategory());
5353}
5454
5555template <class _BidirectionalIterator>
56inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
56inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
5757void
5858reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
5959{
lib/libcxx/include/__algorithm/reverse_copy.h+1-1
......@@ -18,7 +18,7 @@
1818_LIBCPP_BEGIN_NAMESPACE_STD
1919
2020template <class _BidirectionalIterator, class _OutputIterator>
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2222_OutputIterator
2323reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
2424{
lib/libcxx/include/__algorithm/rotate.h+11-11
......@@ -26,7 +26,7 @@
2626_LIBCPP_BEGIN_NAMESPACE_STD
2727
2828template <class _AlgPolicy, class _ForwardIterator>
29_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
29_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
3030__rotate_left(_ForwardIterator __first, _ForwardIterator __last)
3131{
3232 typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
......@@ -40,7 +40,7 @@ __rotate_left(_ForwardIterator __first, _ForwardIterator __last)
4040}
4141
4242template <class _AlgPolicy, class _BidirectionalIterator>
43_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator
43_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _BidirectionalIterator
4444__rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)
4545{
4646 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
......@@ -48,13 +48,13 @@ __rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)
4848
4949 _BidirectionalIterator __lm1 = _Ops::prev(__last);
5050 value_type __tmp = _Ops::__iter_move(__lm1);
51 _BidirectionalIterator __fp1 = std::__move_backward<_AlgPolicy>(__first, __lm1, std::move(__last));
51 _BidirectionalIterator __fp1 = std::__move_backward<_AlgPolicy>(__first, __lm1, std::move(__last)).second;
5252 *__first = _VSTD::move(__tmp);
5353 return __fp1;
5454}
5555
5656template <class _AlgPolicy, class _ForwardIterator>
57_LIBCPP_CONSTEXPR_AFTER_CXX14 _ForwardIterator
57_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _ForwardIterator
5858__rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
5959{
6060 _ForwardIterator __i = __middle;
......@@ -90,7 +90,7 @@ __rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIt
9090
9191template<typename _Integral>
9292inline _LIBCPP_INLINE_VISIBILITY
93_LIBCPP_CONSTEXPR_AFTER_CXX14 _Integral
93_LIBCPP_CONSTEXPR_SINCE_CXX17 _Integral
9494__algo_gcd(_Integral __x, _Integral __y)
9595{
9696 do
......@@ -103,7 +103,7 @@ __algo_gcd(_Integral __x, _Integral __y)
103103}
104104
105105template <class _AlgPolicy, typename _RandomAccessIterator>
106_LIBCPP_CONSTEXPR_AFTER_CXX14 _RandomAccessIterator
106_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _RandomAccessIterator
107107__rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)
108108{
109109 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
......@@ -140,7 +140,7 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran
140140
141141template <class _AlgPolicy, class _ForwardIterator>
142142inline _LIBCPP_INLINE_VISIBILITY
143_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
143_LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
144144__rotate_impl(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last,
145145 _VSTD::forward_iterator_tag)
146146{
......@@ -155,7 +155,7 @@ __rotate_impl(_ForwardIterator __first, _ForwardIterator __middle, _ForwardItera
155155
156156template <class _AlgPolicy, class _BidirectionalIterator>
157157inline _LIBCPP_INLINE_VISIBILITY
158_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator
158_LIBCPP_CONSTEXPR_SINCE_CXX14 _BidirectionalIterator
159159__rotate_impl(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
160160 bidirectional_iterator_tag)
161161{
......@@ -172,7 +172,7 @@ __rotate_impl(_BidirectionalIterator __first, _BidirectionalIterator __middle, _
172172
173173template <class _AlgPolicy, class _RandomAccessIterator>
174174inline _LIBCPP_INLINE_VISIBILITY
175_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator
175_LIBCPP_CONSTEXPR_SINCE_CXX14 _RandomAccessIterator
176176__rotate_impl(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
177177 random_access_iterator_tag)
178178{
......@@ -189,7 +189,7 @@ __rotate_impl(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ra
189189}
190190
191191template <class _AlgPolicy, class _Iterator, class _Sentinel>
192_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
192_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
193193pair<_Iterator, _Iterator>
194194__rotate(_Iterator __first, _Iterator __middle, _Sentinel __last) {
195195 using _Ret = pair<_Iterator, _Iterator>;
......@@ -209,7 +209,7 @@ __rotate(_Iterator __first, _Iterator __middle, _Sentinel __last) {
209209
210210template <class _ForwardIterator>
211211inline _LIBCPP_INLINE_VISIBILITY
212_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
212_LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
213213rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
214214{
215215 return std::__rotate<_ClassicAlgPolicy>(
lib/libcxx/include/__algorithm/rotate_copy.h+1-1
......@@ -19,7 +19,7 @@
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
2121template <class _ForwardIterator, class _OutputIterator>
22inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
22inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2323_OutputIterator
2424rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, _OutputIterator __result)
2525{
lib/libcxx/include/__algorithm/search.h+8-10
......@@ -33,7 +33,7 @@ template <class _AlgPolicy,
3333 class _Pred,
3434 class _Proj1,
3535 class _Proj2>
36_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
36_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
3737pair<_Iter1, _Iter1> __search_forward_impl(_Iter1 __first1, _Sent1 __last1,
3838 _Iter2 __first2, _Sent2 __last2,
3939 _Pred& __pred,
......@@ -80,7 +80,7 @@ template <class _AlgPolicy,
8080 class _Proj2,
8181 class _DiffT1,
8282 class _DiffT2>
83_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
83_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
8484pair<_Iter1, _Iter1> __search_random_access_impl(_Iter1 __first1, _Sent1 __last1,
8585 _Iter2 __first2, _Sent2 __last2,
8686 _Pred& __pred,
......@@ -120,7 +120,7 @@ template <class _Iter1, class _Sent1,
120120 class _Pred,
121121 class _Proj1,
122122 class _Proj2>
123_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
123_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
124124pair<_Iter1, _Iter1> __search_impl(_Iter1 __first1, _Sent1 __last1,
125125 _Iter2 __first2, _Sent2 __last2,
126126 _Pred& __pred,
......@@ -152,7 +152,7 @@ template <class _Iter1, class _Sent1,
152152 class _Pred,
153153 class _Proj1,
154154 class _Proj2>
155_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
155_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
156156pair<_Iter1, _Iter1> __search_impl(_Iter1 __first1, _Sent1 __last1,
157157 _Iter2 __first2, _Sent2 __last2,
158158 _Pred& __pred,
......@@ -170,7 +170,7 @@ pair<_Iter1, _Iter1> __search_impl(_Iter1 __first1, _Sent1 __last1,
170170}
171171
172172template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
173_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
173_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
174174_ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
175175 _ForwardIterator2 __first2, _ForwardIterator2 __last2,
176176 _BinaryPredicate __pred) {
......@@ -181,17 +181,15 @@ _ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
181181}
182182
183183template <class _ForwardIterator1, class _ForwardIterator2>
184_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
184_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
185185_ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
186186 _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
187 using __v1 = typename iterator_traits<_ForwardIterator1>::value_type;
188 using __v2 = typename iterator_traits<_ForwardIterator2>::value_type;
189 return std::search(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
187 return std::search(__first1, __last1, __first2, __last2, __equal_to());
190188}
191189
192190#if _LIBCPP_STD_VER > 14
193191template <class _ForwardIterator, class _Searcher>
194_LIBCPP_NODISCARD_EXT _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
192_LIBCPP_NODISCARD_EXT _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
195193search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher& __s) {
196194 return __s(__f, __l).first;
197195}
lib/libcxx/include/__algorithm/search_n.h+8-8
......@@ -19,6 +19,7 @@
1919#include <__iterator/distance.h>
2020#include <__iterator/iterator_traits.h>
2121#include <__ranges/concepts.h>
22#include <__utility/convert_to_integral.h>
2223#include <__utility/pair.h>
2324#include <type_traits> // __convert_to_integral
2425
......@@ -29,7 +30,7 @@
2930_LIBCPP_BEGIN_NAMESPACE_STD
3031
3132template <class _AlgPolicy, class _Pred, class _Iter, class _Sent, class _SizeT, class _Type, class _Proj>
32_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
33_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
3334pair<_Iter, _Iter> __search_n_forward_impl(_Iter __first, _Sent __last,
3435 _SizeT __count,
3536 const _Type& __value,
......@@ -71,7 +72,7 @@ pair<_Iter, _Iter> __search_n_forward_impl(_Iter __first, _Sent __last,
7172}
7273
7374template <class _AlgPolicy, class _Pred, class _Iter, class _Sent, class _SizeT, class _Type, class _Proj, class _DiffT>
74_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
75_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
7576std::pair<_Iter, _Iter> __search_n_random_access_impl(_Iter __first, _Sent __last,
7677 _SizeT __count,
7778 const _Type& __value,
......@@ -122,7 +123,7 @@ template <class _Iter, class _Sent,
122123 class _Type,
123124 class _Pred,
124125 class _Proj>
125_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
126_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
126127pair<_Iter, _Iter> __search_n_impl(_Iter __first, _Sent __last,
127128 _DiffT __count,
128129 const _Type& __value,
......@@ -142,7 +143,7 @@ template <class _Iter1, class _Sent1,
142143 class _Type,
143144 class _Pred,
144145 class _Proj>
145_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
146_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
146147pair<_Iter1, _Iter1> __search_n_impl(_Iter1 __first, _Sent1 __last,
147148 _DiffT __count,
148149 const _Type& __value,
......@@ -158,7 +159,7 @@ pair<_Iter1, _Iter1> __search_n_impl(_Iter1 __first, _Sent1 __last,
158159}
159160
160161template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate>
161_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
162_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
162163_ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last,
163164 _Size __count,
164165 const _Tp& __value,
......@@ -170,10 +171,9 @@ _ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last,
170171}
171172
172173template <class _ForwardIterator, class _Size, class _Tp>
173_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
174_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
174175_ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value) {
175 typedef typename iterator_traits<_ForwardIterator>::value_type __v;
176 return std::search_n(__first, __last, std::__convert_to_integral(__count), __value, __equal_to<__v, _Tp>());
176 return std::search_n(__first, __last, std::__convert_to_integral(__count), __value, __equal_to());
177177}
178178
179179_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/set_difference.h+10-8
......@@ -12,6 +12,7 @@
1212#include <__algorithm/comp.h>
1313#include <__algorithm/comp_ref_type.h>
1414#include <__algorithm/copy.h>
15#include <__algorithm/iterator_operations.h>
1516#include <__config>
1617#include <__functional/identity.h>
1718#include <__functional/invoke.h>
......@@ -26,8 +27,8 @@
2627
2728_LIBCPP_BEGIN_NAMESPACE_STD
2829
29template < class _Comp, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
30_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<__uncvref_t<_InIter1>, __uncvref_t<_OutIter> >
30template <class _AlgPolicy, class _Comp, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
31_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__remove_cvref_t<_InIter1>, __remove_cvref_t<_OutIter> >
3132__set_difference(
3233 _InIter1&& __first1, _Sent1&& __last1, _InIter2&& __first2, _Sent2&& __last2, _OutIter&& __result, _Comp&& __comp) {
3334 while (__first1 != __last1 && __first2 != __last2) {
......@@ -42,29 +43,30 @@ __set_difference(
4243 ++__first2;
4344 }
4445 }
45 return std::__copy(std::move(__first1), std::move(__last1), std::move(__result));
46 return std::__copy<_AlgPolicy>(std::move(__first1), std::move(__last1), std::move(__result));
4647}
4748
4849template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
49inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_difference(
50inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_difference(
5051 _InputIterator1 __first1,
5152 _InputIterator1 __last1,
5253 _InputIterator2 __first2,
5354 _InputIterator2 __last2,
5455 _OutputIterator __result,
5556 _Compare __comp) {
56 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
57 return std::__set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp).second;
57 return std::__set_difference<_ClassicAlgPolicy, __comp_ref_type<_Compare> >(
58 __first1, __last1, __first2, __last2, __result, __comp)
59 .second;
5860}
5961
6062template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
61inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_difference(
63inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_difference(
6264 _InputIterator1 __first1,
6365 _InputIterator1 __last1,
6466 _InputIterator2 __first2,
6567 _InputIterator2 __last2,
6668 _OutputIterator __result) {
67 return std::__set_difference(
69 return std::__set_difference<_ClassicAlgPolicy>(
6870 __first1,
6971 __last1,
7072 __first2,
lib/libcxx/include/__algorithm/set_intersection.h+5-6
......@@ -30,13 +30,13 @@ struct __set_intersection_result {
3030 _OutIter __out_;
3131
3232 // need a constructor as C++03 aggregate init is hard
33 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
33 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
3434 __set_intersection_result(_InIter1&& __in_iter1, _InIter2&& __in_iter2, _OutIter&& __out_iter)
3535 : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}
3636};
3737
3838template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
39_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 __set_intersection_result<_InIter1, _InIter2, _OutIter>
39_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InIter1, _InIter2, _OutIter>
4040__set_intersection(
4141 _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {
4242 while (__first1 != __last1 && __first2 != __last2) {
......@@ -59,15 +59,14 @@ __set_intersection(
5959}
6060
6161template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
62inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_intersection(
62inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_intersection(
6363 _InputIterator1 __first1,
6464 _InputIterator1 __last1,
6565 _InputIterator2 __first2,
6666 _InputIterator2 __last2,
6767 _OutputIterator __result,
6868 _Compare __comp) {
69 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
70 return std::__set_intersection<_ClassicAlgPolicy, _Comp_ref>(
69 return std::__set_intersection<_ClassicAlgPolicy, __comp_ref_type<_Compare> >(
7170 std::move(__first1),
7271 std::move(__last1),
7372 std::move(__first2),
......@@ -78,7 +77,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_i
7877}
7978
8079template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
81inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_intersection(
80inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_intersection(
8281 _InputIterator1 __first1,
8382 _InputIterator1 __last1,
8483 _InputIterator2 __first2,
lib/libcxx/include/__algorithm/set_symmetric_difference.h+10-9
......@@ -12,9 +12,11 @@
1212#include <__algorithm/comp.h>
1313#include <__algorithm/comp_ref_type.h>
1414#include <__algorithm/copy.h>
15#include <__algorithm/iterator_operations.h>
1516#include <__config>
1617#include <__iterator/iterator_traits.h>
1718#include <__utility/move.h>
19#include <__utility/pair.h>
1820
1921#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2022# pragma GCC system_header
......@@ -29,18 +31,18 @@ struct __set_symmetric_difference_result {
2931 _OutIter __out_;
3032
3133 // need a constructor as C++03 aggregate init is hard
32 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
34 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
3335 __set_symmetric_difference_result(_InIter1&& __in_iter1, _InIter2&& __in_iter2, _OutIter&& __out_iter)
3436 : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}
3537};
3638
37template <class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
38_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>
39template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
40_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>
3941__set_symmetric_difference(
4042 _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {
4143 while (__first1 != __last1) {
4244 if (__first2 == __last2) {
43 auto __ret1 = std::__copy_impl(std::move(__first1), std::move(__last1), std::move(__result));
45 auto __ret1 = std::__copy<_AlgPolicy>(std::move(__first1), std::move(__last1), std::move(__result));
4446 return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>(
4547 std::move(__ret1.first), std::move(__first2), std::move((__ret1.second)));
4648 }
......@@ -58,21 +60,20 @@ __set_symmetric_difference(
5860 ++__first2;
5961 }
6062 }
61 auto __ret2 = std::__copy_impl(std::move(__first2), std::move(__last2), std::move(__result));
63 auto __ret2 = std::__copy<_AlgPolicy>(std::move(__first2), std::move(__last2), std::move(__result));
6264 return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>(
6365 std::move(__first1), std::move(__ret2.first), std::move((__ret2.second)));
6466}
6567
6668template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
67_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_symmetric_difference(
69_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_symmetric_difference(
6870 _InputIterator1 __first1,
6971 _InputIterator1 __last1,
7072 _InputIterator2 __first2,
7173 _InputIterator2 __last2,
7274 _OutputIterator __result,
7375 _Compare __comp) {
74 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
75 return std::__set_symmetric_difference<_Comp_ref>(
76 return std::__set_symmetric_difference<_ClassicAlgPolicy, __comp_ref_type<_Compare> >(
7677 std::move(__first1),
7778 std::move(__last1),
7879 std::move(__first2),
......@@ -83,7 +84,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_symmetri
8384}
8485
8586template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
86_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_symmetric_difference(
87_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_symmetric_difference(
8788 _InputIterator1 __first1,
8889 _InputIterator1 __last1,
8990 _InputIterator2 __first2,
lib/libcxx/include/__algorithm/set_union.h+10-9
......@@ -12,9 +12,11 @@
1212#include <__algorithm/comp.h>
1313#include <__algorithm/comp_ref_type.h>
1414#include <__algorithm/copy.h>
15#include <__algorithm/iterator_operations.h>
1516#include <__config>
1617#include <__iterator/iterator_traits.h>
1718#include <__utility/move.h>
19#include <__utility/pair.h>
1820
1921#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2022# pragma GCC system_header
......@@ -29,17 +31,17 @@ struct __set_union_result {
2931 _OutIter __out_;
3032
3133 // need a constructor as C++03 aggregate init is hard
32 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
34 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
3335 __set_union_result(_InIter1&& __in_iter1, _InIter2&& __in_iter2, _OutIter&& __out_iter)
3436 : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}
3537};
3638
37template <class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
38_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 __set_union_result<_InIter1, _InIter2, _OutIter> __set_union(
39template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
40_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_union_result<_InIter1, _InIter2, _OutIter> __set_union(
3941 _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {
4042 for (; __first1 != __last1; ++__result) {
4143 if (__first2 == __last2) {
42 auto __ret1 = std::__copy_impl(std::move(__first1), std::move(__last1), std::move(__result));
44 auto __ret1 = std::__copy<_AlgPolicy>(std::move(__first1), std::move(__last1), std::move(__result));
4345 return __set_union_result<_InIter1, _InIter2, _OutIter>(
4446 std::move(__ret1.first), std::move(__first2), std::move((__ret1.second)));
4547 }
......@@ -54,21 +56,20 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 __set_union_result<_InIter1,
5456 ++__first1;
5557 }
5658 }
57 auto __ret2 = std::__copy_impl(std::move(__first2), std::move(__last2), std::move(__result));
59 auto __ret2 = std::__copy<_AlgPolicy>(std::move(__first2), std::move(__last2), std::move(__result));
5860 return __set_union_result<_InIter1, _InIter2, _OutIter>(
5961 std::move(__first1), std::move(__ret2.first), std::move((__ret2.second)));
6062}
6163
6264template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
63_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_union(
65_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_union(
6466 _InputIterator1 __first1,
6567 _InputIterator1 __last1,
6668 _InputIterator2 __first2,
6769 _InputIterator2 __last2,
6870 _OutputIterator __result,
6971 _Compare __comp) {
70 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
71 return std::__set_union<_Comp_ref>(
72 return std::__set_union<_ClassicAlgPolicy, __comp_ref_type<_Compare> >(
7273 std::move(__first1),
7374 std::move(__last1),
7475 std::move(__first2),
......@@ -79,7 +80,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_union(
7980}
8081
8182template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
82_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_union(
83_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_union(
8384 _InputIterator1 __first1,
8485 _InputIterator1 __last1,
8586 _InputIterator2 __first2,
lib/libcxx/include/__algorithm/shuffle.h+13-12
......@@ -16,6 +16,7 @@
1616#include <__random/uniform_int_distribution.h>
1717#include <__utility/forward.h>
1818#include <__utility/move.h>
19#include <__utility/swap.h>
1920#include <cstddef>
2021#include <cstdint>
2122
......@@ -31,9 +32,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3132class _LIBCPP_TYPE_VIS __libcpp_debug_randomizer {
3233public:
3334 __libcpp_debug_randomizer() {
34 __state = __seed();
35 __inc = __state + 0xda3e39cb94b95bdbULL;
36 __inc = (__inc << 1) | 1;
35 __state_ = __seed();
36 __inc_ = __state_ + 0xda3e39cb94b95bdbULL;
37 __inc_ = (__inc_ << 1) | 1;
3738 }
3839 typedef uint_fast32_t result_type;
3940
......@@ -41,8 +42,8 @@ public:
4142 static const result_type _Max = 0xFFFFFFFF;
4243
4344 _LIBCPP_HIDE_FROM_ABI result_type operator()() {
44 uint_fast64_t __oldstate = __state;
45 __state = __oldstate * 6364136223846793005ULL + __inc;
45 uint_fast64_t __oldstate = __state_;
46 __state_ = __oldstate * 6364136223846793005ULL + __inc_;
4647 return __oldstate >> 32;
4748 }
4849
......@@ -50,8 +51,8 @@ public:
5051 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR result_type max() { return _Max; }
5152
5253private:
53 uint_fast64_t __state;
54 uint_fast64_t __inc;
54 uint_fast64_t __state_;
55 uint_fast64_t __inc_;
5556 _LIBCPP_HIDE_FROM_ABI static uint_fast64_t __seed() {
5657#ifdef _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY_SEED
5758 return _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY_SEED;
......@@ -93,7 +94,7 @@ public:
9394_LIBCPP_FUNC_VIS __rs_default __rs_get();
9495
9596template <class _RandomAccessIterator>
96_LIBCPP_DEPRECATED_IN_CXX14 void
97_LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX14 void
9798random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
9899{
99100 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
......@@ -114,7 +115,7 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
114115}
115116
116117template <class _RandomAccessIterator, class _RandomNumberGenerator>
117_LIBCPP_DEPRECATED_IN_CXX14 void
118_LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX14 void
118119random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
119120#ifndef _LIBCPP_CXX03_LANG
120121 _RandomNumberGenerator&& __rand)
......@@ -137,7 +138,7 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
137138#endif
138139
139140template <class _AlgPolicy, class _RandomAccessIterator, class _Sentinel, class _UniformRandomNumberGenerator>
140_RandomAccessIterator __shuffle(
141_LIBCPP_HIDE_FROM_ABI _RandomAccessIterator __shuffle(
141142 _RandomAccessIterator __first, _Sentinel __last_sentinel, _UniformRandomNumberGenerator&& __g) {
142143 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
143144 typedef uniform_int_distribution<ptrdiff_t> _Dp;
......@@ -161,8 +162,8 @@ _RandomAccessIterator __shuffle(
161162}
162163
163164template <class _RandomAccessIterator, class _UniformRandomNumberGenerator>
164void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
165 _UniformRandomNumberGenerator&& __g) {
165_LIBCPP_HIDE_FROM_ABI void
166shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, _UniformRandomNumberGenerator&& __g) {
166167 (void)std::__shuffle<_ClassicAlgPolicy>(
167168 std::move(__first), std::move(__last), std::forward<_UniformRandomNumberGenerator>(__g));
168169}
lib/libcxx/include/__algorithm/sift_down.h+2-2
......@@ -22,7 +22,7 @@
2222_LIBCPP_BEGIN_NAMESPACE_STD
2323
2424template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
25_LIBCPP_CONSTEXPR_AFTER_CXX11 void
25_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
2626__sift_down(_RandomAccessIterator __first, _Compare&& __comp,
2727 typename iterator_traits<_RandomAccessIterator>::difference_type __len,
2828 _RandomAccessIterator __start)
......@@ -78,7 +78,7 @@ __sift_down(_RandomAccessIterator __first, _Compare&& __comp,
7878}
7979
8080template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
81_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator
81_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _RandomAccessIterator
8282__floyd_sift_down(_RandomAccessIterator __first, _Compare&& __comp,
8383 typename iterator_traits<_RandomAccessIterator>::difference_type __len)
8484{
lib/libcxx/include/__algorithm/sort.h+470-174
......@@ -11,19 +11,29 @@
1111
1212#include <__algorithm/comp.h>
1313#include <__algorithm/comp_ref_type.h>
14#include <__algorithm/iter_swap.h>
1415#include <__algorithm/iterator_operations.h>
1516#include <__algorithm/min_element.h>
1617#include <__algorithm/partial_sort.h>
1718#include <__algorithm/unwrap_iter.h>
18#include <__bits>
19#include <__assert>
20#include <__bit/blsr.h>
21#include <__bit/countl.h>
22#include <__bit/countr.h>
1923#include <__config>
2024#include <__debug>
2125#include <__debug_utils/randomize_range.h>
2226#include <__functional/operations.h>
2327#include <__functional/ranges_operations.h>
2428#include <__iterator/iterator_traits.h>
29#include <__memory/destruct_n.h>
30#include <__memory/unique_ptr.h>
31#include <__type_traits/conditional.h>
32#include <__type_traits/is_arithmetic.h>
33#include <__utility/move.h>
34#include <__utility/pair.h>
2535#include <climits>
26#include <memory>
36#include <cstdint>
2737
2838#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2939# pragma GCC system_header
......@@ -43,7 +53,7 @@ struct _WrapAlgPolicy {
4353 using _Comp = _CompT;
4454 _Comp& __comp;
4555
46 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
56 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
4757 _WrapAlgPolicy(_Comp& __c) : __comp(__c) {}
4858};
4959
......@@ -62,7 +72,7 @@ struct _UnwrapAlgPolicy {
6272 using _AlgPolicy = _ClassicAlgPolicy;
6373 using _Comp = _CompT;
6474
65 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static
75 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static
6676 _Comp __get_comp(_Comp __comp) { return __comp; }
6777};
6878
......@@ -73,14 +83,15 @@ struct _UnwrapAlgPolicy<_WrapAlgPolicy<_Ts...> > {
7383 using _AlgPolicy = typename _Wrapped::_AlgPolicy;
7484 using _Comp = typename _Wrapped::_Comp;
7585
76 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static
86 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static
7787 _Comp __get_comp(_Wrapped& __w) { return __w.__comp; }
7888};
7989
8090// stable, 2-3 compares, 0-2 swaps
8191
8292template <class _AlgPolicy, class _Compare, class _ForwardIterator>
83_LIBCPP_CONSTEXPR_AFTER_CXX11 unsigned __sort3(_ForwardIterator __x, _ForwardIterator __y, _ForwardIterator __z,
93_LIBCPP_HIDE_FROM_ABI
94_LIBCPP_CONSTEXPR_SINCE_CXX14 unsigned __sort3(_ForwardIterator __x, _ForwardIterator __y, _ForwardIterator __z,
8495 _Compare __c) {
8596 using _Ops = _IterOps<_AlgPolicy>;
8697
......@@ -118,10 +129,10 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 unsigned __sort3(_ForwardIterator __x, _ForwardIte
118129// stable, 3-6 compares, 0-5 swaps
119130
120131template <class _AlgPolicy, class _Compare, class _ForwardIterator>
132_LIBCPP_HIDE_FROM_ABI
121133unsigned __sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, _ForwardIterator __x4,
122134 _Compare __c) {
123 using _Ops = _IterOps<_AlgPolicy>;
124
135 using _Ops = _IterOps<_AlgPolicy>;
125136 unsigned __r = std::__sort3<_AlgPolicy, _Compare>(__x1, __x2, __x3, __c);
126137 if (__c(*__x4, *__x3)) {
127138 _Ops::iter_swap(__x3, __x4);
......@@ -171,12 +182,12 @@ _LIBCPP_HIDDEN unsigned __sort5(_ForwardIterator __x1, _ForwardIterator __x2, _F
171182}
172183
173184template <class _AlgPolicy, class _Compare, class _ForwardIterator>
174_LIBCPP_HIDDEN unsigned __sort5_wrap_policy(
185_LIBCPP_HIDE_FROM_ABI unsigned __sort5_wrap_policy(
175186 _ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, _ForwardIterator __x4, _ForwardIterator __x5,
176187 _Compare __c) {
177188 using _WrappedComp = typename _WrapAlgPolicy<_AlgPolicy, _Compare>::type;
178189 _WrappedComp __wrapped_comp(__c);
179 return std::__sort5<_WrappedComp>(
190 return std::__sort5<_WrappedComp, _ForwardIterator>(
180191 std::move(__x1), std::move(__x2), std::move(__x3), std::move(__x4), std::move(__x5), __wrapped_comp);
181192}
182193
......@@ -201,6 +212,13 @@ using __use_branchless_sort =
201212 integral_constant<bool, __is_cpp17_contiguous_iterator<_Iter>::value && sizeof(_Tp) <= sizeof(void*) &&
202213 is_arithmetic<_Tp>::value && __is_simple_comparator<_Compare>::value>;
203214
215namespace __detail {
216
217// Size in bits for the bitset in use.
218enum { __block_size = sizeof(uint64_t) * 8 };
219
220} // namespace __detail
221
204222// Ensures that __c(*__x, *__y) is true by swapping *__x and *__y if necessary.
205223template <class _Compare, class _RandomAccessIterator>
206224inline _LIBCPP_HIDE_FROM_ABI void __cond_swap(_RandomAccessIterator __x, _RandomAccessIterator __y, _Compare __c) {
......@@ -231,8 +249,8 @@ template <class, class _Compare, class _RandomAccessIterator>
231249inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
232250__sort3_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
233251 _Compare __c) {
234 _VSTD::__cond_swap<_Compare>(__x2, __x3, __c);
235 _VSTD::__partially_sorted_swap<_Compare>(__x1, __x2, __x3, __c);
252 std::__cond_swap<_Compare>(__x2, __x3, __c);
253 std::__partially_sorted_swap<_Compare>(__x1, __x2, __x3, __c);
236254}
237255
238256template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
......@@ -246,11 +264,11 @@ template <class, class _Compare, class _RandomAccessIterator>
246264inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
247265__sort4_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
248266 _RandomAccessIterator __x4, _Compare __c) {
249 _VSTD::__cond_swap<_Compare>(__x1, __x3, __c);
250 _VSTD::__cond_swap<_Compare>(__x2, __x4, __c);
251 _VSTD::__cond_swap<_Compare>(__x1, __x2, __c);
252 _VSTD::__cond_swap<_Compare>(__x3, __x4, __c);
253 _VSTD::__cond_swap<_Compare>(__x2, __x3, __c);
267 std::__cond_swap<_Compare>(__x1, __x3, __c);
268 std::__cond_swap<_Compare>(__x2, __x4, __c);
269 std::__cond_swap<_Compare>(__x1, __x2, __c);
270 std::__cond_swap<_Compare>(__x3, __x4, __c);
271 std::__cond_swap<_Compare>(__x2, __x3, __c);
254272}
255273
256274template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
......@@ -260,16 +278,21 @@ __sort4_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2,
260278 std::__sort4<_AlgPolicy, _Compare>(__x1, __x2, __x3, __x4, __c);
261279}
262280
263template <class, class _Compare, class _RandomAccessIterator>
281template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
264282inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
265__sort5_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
266 _RandomAccessIterator __x4, _RandomAccessIterator __x5, _Compare __c) {
267 _VSTD::__cond_swap<_Compare>(__x1, __x2, __c);
268 _VSTD::__cond_swap<_Compare>(__x4, __x5, __c);
269 _VSTD::__partially_sorted_swap<_Compare>(__x3, __x4, __x5, __c);
270 _VSTD::__cond_swap<_Compare>(__x2, __x5, __c);
271 _VSTD::__partially_sorted_swap<_Compare>(__x1, __x3, __x4, __c);
272 _VSTD::__partially_sorted_swap<_Compare>(__x2, __x3, __x4, __c);
283__sort5_maybe_branchless(
284 _RandomAccessIterator __x1,
285 _RandomAccessIterator __x2,
286 _RandomAccessIterator __x3,
287 _RandomAccessIterator __x4,
288 _RandomAccessIterator __x5,
289 _Compare __c) {
290 std::__cond_swap<_Compare>(__x1, __x2, __c);
291 std::__cond_swap<_Compare>(__x4, __x5, __c);
292 std::__partially_sorted_swap<_Compare>(__x3, __x4, __x5, __c);
293 std::__cond_swap<_Compare>(__x2, __x5, __c);
294 std::__partially_sorted_swap<_Compare>(__x1, __x3, __x4, __c);
295 std::__partially_sorted_swap<_Compare>(__x2, __x3, __x4, __c);
273296}
274297
275298template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
......@@ -281,7 +304,8 @@ __sort5_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2,
281304
282305// Assumes size > 0
283306template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
284_LIBCPP_CONSTEXPR_AFTER_CXX11 void __selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last,
307_LIBCPP_HIDE_FROM_ABI
308_LIBCPP_CONSTEXPR_SINCE_CXX14 void __selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last,
285309 _Compare __comp) {
286310 _BidirectionalIterator __lm1 = __last;
287311 for (--__lm1; __first != __lm1; ++__first) {
......@@ -291,32 +315,48 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 void __selection_sort(_BidirectionalIterator __fir
291315 }
292316}
293317
318// Sort the iterator range [__first, __last) using the comparator __comp using
319// the insertion sort algorithm.
294320template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
321_LIBCPP_HIDE_FROM_ABI
295322void __insertion_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) {
296323 using _Ops = _IterOps<_AlgPolicy>;
297324
298325 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
299 if (__first != __last) {
300 _BidirectionalIterator __i = __first;
301 for (++__i; __i != __last; ++__i) {
302 _BidirectionalIterator __j = __i;
303 value_type __t(_Ops::__iter_move(__j));
304 for (_BidirectionalIterator __k = __i; __k != __first && __comp(__t, *--__k); --__j)
326 if (__first == __last)
327 return;
328 _BidirectionalIterator __i = __first;
329 for (++__i; __i != __last; ++__i) {
330 _BidirectionalIterator __j = __i;
331 --__j;
332 if (__comp(*__i, *__j)) {
333 value_type __t(_Ops::__iter_move(__i));
334 _BidirectionalIterator __k = __j;
335 __j = __i;
336 do {
305337 *__j = _Ops::__iter_move(__k);
306 *__j = _VSTD::move(__t);
338 __j = __k;
339 } while (__j != __first && __comp(__t, *--__k));
340 *__j = std::move(__t);
307341 }
308342 }
309343}
310344
345// Sort the iterator range [__first, __last) using the comparator __comp using
346// the insertion sort algorithm. Insertion sort has two loops, outer and inner.
347// The implementation below has not bounds check (unguarded) for the inner loop.
348// Assumes that there is an element in the position (__first - 1) and that each
349// element in the input range is greater or equal to the element at __first - 1.
311350template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
312void __insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
351_LIBCPP_HIDE_FROM_ABI void
352__insertion_sort_unguarded(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
313353 using _Ops = _IterOps<_AlgPolicy>;
314
315354 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
316355 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
317 _RandomAccessIterator __j = __first + difference_type(2);
318 std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), __j, __comp);
319 for (_RandomAccessIterator __i = __j + difference_type(1); __i != __last; ++__i) {
356 if (__first == __last)
357 return;
358 for (_RandomAccessIterator __i = __first + difference_type(1); __i != __last; ++__i) {
359 _RandomAccessIterator __j = __i - difference_type(1);
320360 if (__comp(*__i, *__j)) {
321361 value_type __t(_Ops::__iter_move(__i));
322362 _RandomAccessIterator __k = __j;
......@@ -324,15 +364,14 @@ void __insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __l
324364 do {
325365 *__j = _Ops::__iter_move(__k);
326366 __j = __k;
327 } while (__j != __first && __comp(__t, *--__k));
328 *__j = _VSTD::move(__t);
367 } while (__comp(__t, *--__k)); // No need for bounds check due to the assumption stated above.
368 *__j = std::move(__t);
329369 }
330 __j = __i;
331370 }
332371}
333372
334373template <class _WrappedComp, class _RandomAccessIterator>
335bool __insertion_sort_incomplete(
374_LIBCPP_HIDDEN bool __insertion_sort_incomplete(
336375 _RandomAccessIterator __first, _RandomAccessIterator __last, _WrappedComp __wrapped_comp) {
337376 using _Unwrap = _UnwrapAlgPolicy<_WrappedComp>;
338377 using _AlgPolicy = typename _Unwrap::_AlgPolicy;
......@@ -348,7 +387,7 @@ bool __insertion_sort_incomplete(
348387 return true;
349388 case 2:
350389 if (__comp(*--__last, *__first))
351 _IterOps<_AlgPolicy>::iter_swap(__first, __last);
390 _Ops::iter_swap(__first, __last);
352391 return true;
353392 case 3:
354393 std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), --__last, __comp);
......@@ -377,7 +416,7 @@ bool __insertion_sort_incomplete(
377416 *__j = _Ops::__iter_move(__k);
378417 __j = __k;
379418 } while (__j != __first && __comp(__t, *--__k));
380 *__j = _VSTD::move(__t);
419 *__j = std::move(__t);
381420 if (++__count == __limit)
382421 return ++__i == __last;
383422 }
......@@ -387,6 +426,7 @@ bool __insertion_sort_incomplete(
387426}
388427
389428template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
429_LIBCPP_HIDE_FROM_ABI
390430void __insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterator __last1,
391431 typename iterator_traits<_BidirectionalIterator>::value_type* __first2, _Compare __comp) {
392432 using _Ops = _IterOps<_AlgPolicy>;
......@@ -416,17 +456,336 @@ void __insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterat
416456 }
417457}
418458
419template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
420void __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
421 typename iterator_traits<_RandomAccessIterator>::difference_type __depth) {
459template <class _AlgPolicy, class _RandomAccessIterator>
460inline _LIBCPP_HIDE_FROM_ABI void __swap_bitmap_pos(
461 _RandomAccessIterator __first, _RandomAccessIterator __last, uint64_t& __left_bitset, uint64_t& __right_bitset) {
462 using _Ops = _IterOps<_AlgPolicy>;
463 typedef typename std::iterator_traits<_RandomAccessIterator>::difference_type difference_type;
464 // Swap one pair on each iteration as long as both bitsets have at least one
465 // element for swapping.
466 while (__left_bitset != 0 && __right_bitset != 0) {
467 difference_type tz_left = __libcpp_ctz(__left_bitset);
468 __left_bitset = __libcpp_blsr(__left_bitset);
469 difference_type tz_right = __libcpp_ctz(__right_bitset);
470 __right_bitset = __libcpp_blsr(__right_bitset);
471 _Ops::iter_swap(__first + tz_left, __last - tz_right);
472 }
473}
474
475template <class _Compare,
476 class _RandomAccessIterator,
477 class _ValueType = typename iterator_traits<_RandomAccessIterator>::value_type>
478inline _LIBCPP_HIDE_FROM_ABI void
479__populate_left_bitset(_RandomAccessIterator __first, _Compare __comp, _ValueType& __pivot, uint64_t& __left_bitset) {
480 // Possible vectorization. With a proper "-march" flag, the following loop
481 // will be compiled into a set of SIMD instructions.
482 _RandomAccessIterator __iter = __first;
483 for (int __j = 0; __j < __detail::__block_size;) {
484 bool __comp_result = !__comp(*__iter, __pivot);
485 __left_bitset |= (static_cast<uint64_t>(__comp_result) << __j);
486 __j++;
487 ++__iter;
488 }
489}
490
491template <class _Compare,
492 class _RandomAccessIterator,
493 class _ValueType = typename iterator_traits<_RandomAccessIterator>::value_type>
494inline _LIBCPP_HIDE_FROM_ABI void
495__populate_right_bitset(_RandomAccessIterator __lm1, _Compare __comp, _ValueType& __pivot, uint64_t& __right_bitset) {
496 // Possible vectorization. With a proper "-march" flag, the following loop
497 // will be compiled into a set of SIMD instructions.
498 _RandomAccessIterator __iter = __lm1;
499 for (int __j = 0; __j < __detail::__block_size;) {
500 bool __comp_result = __comp(*__iter, __pivot);
501 __right_bitset |= (static_cast<uint64_t>(__comp_result) << __j);
502 __j++;
503 --__iter;
504 }
505}
506
507template <class _AlgPolicy,
508 class _Compare,
509 class _RandomAccessIterator,
510 class _ValueType = typename iterator_traits<_RandomAccessIterator>::value_type>
511inline _LIBCPP_HIDE_FROM_ABI void __bitset_partition_partial_blocks(
512 _RandomAccessIterator& __first,
513 _RandomAccessIterator& __lm1,
514 _Compare __comp,
515 _ValueType& __pivot,
516 uint64_t& __left_bitset,
517 uint64_t& __right_bitset) {
518 typedef typename std::iterator_traits<_RandomAccessIterator>::difference_type difference_type;
519 difference_type __remaining_len = __lm1 - __first + 1;
520 difference_type __l_size;
521 difference_type __r_size;
522 if (__left_bitset == 0 && __right_bitset == 0) {
523 __l_size = __remaining_len / 2;
524 __r_size = __remaining_len - __l_size;
525 } else if (__left_bitset == 0) {
526 // We know at least one side is a full block.
527 __l_size = __remaining_len - __detail::__block_size;
528 __r_size = __detail::__block_size;
529 } else { // if (__right_bitset == 0)
530 __l_size = __detail::__block_size;
531 __r_size = __remaining_len - __detail::__block_size;
532 }
533 // Record the comparison outcomes for the elements currently on the left side.
534 if (__left_bitset == 0) {
535 _RandomAccessIterator __iter = __first;
536 for (int j = 0; j < __l_size; j++) {
537 bool __comp_result = !__comp(*__iter, __pivot);
538 __left_bitset |= (static_cast<uint64_t>(__comp_result) << j);
539 ++__iter;
540 }
541 }
542 // Record the comparison outcomes for the elements currently on the right
543 // side.
544 if (__right_bitset == 0) {
545 _RandomAccessIterator __iter = __lm1;
546 for (int j = 0; j < __r_size; j++) {
547 bool __comp_result = __comp(*__iter, __pivot);
548 __right_bitset |= (static_cast<uint64_t>(__comp_result) << j);
549 --__iter;
550 }
551 }
552 std::__swap_bitmap_pos<_AlgPolicy, _RandomAccessIterator>(__first, __lm1, __left_bitset, __right_bitset);
553 __first += (__left_bitset == 0) ? __l_size : 0;
554 __lm1 -= (__right_bitset == 0) ? __r_size : 0;
555}
556
557template <class _AlgPolicy, class _RandomAccessIterator>
558inline _LIBCPP_HIDE_FROM_ABI void __swap_bitmap_pos_within(
559 _RandomAccessIterator& __first, _RandomAccessIterator& __lm1, uint64_t& __left_bitset, uint64_t& __right_bitset) {
560 using _Ops = _IterOps<_AlgPolicy>;
561 typedef typename std::iterator_traits<_RandomAccessIterator>::difference_type difference_type;
562 if (__left_bitset) {
563 // Swap within the left side. Need to find set positions in the reverse
564 // order.
565 while (__left_bitset != 0) {
566 difference_type __tz_left = __detail::__block_size - 1 - __libcpp_clz(__left_bitset);
567 __left_bitset &= (static_cast<uint64_t>(1) << __tz_left) - 1;
568 _RandomAccessIterator it = __first + __tz_left;
569 if (it != __lm1) {
570 _Ops::iter_swap(it, __lm1);
571 }
572 --__lm1;
573 }
574 __first = __lm1 + difference_type(1);
575 } else if (__right_bitset) {
576 // Swap within the right side. Need to find set positions in the reverse
577 // order.
578 while (__right_bitset != 0) {
579 difference_type __tz_right = __detail::__block_size - 1 - __libcpp_clz(__right_bitset);
580 __right_bitset &= (static_cast<uint64_t>(1) << __tz_right) - 1;
581 _RandomAccessIterator it = __lm1 - __tz_right;
582 if (it != __first) {
583 _Ops::iter_swap(it, __first);
584 }
585 ++__first;
586 }
587 }
588}
589
590// Partition [__first, __last) using the comparator __comp. *__first has the
591// chosen pivot. Elements that are equivalent are kept to the left of the
592// pivot. Returns the iterator for the pivot and a bool value which is true if
593// the provided range is already sorted, false otherwise. We assume that the
594// length of the range is at least three elements.
595//
596// __bitset_partition uses bitsets for storing outcomes of the comparisons
597// between the pivot and other elements.
598template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
599_LIBCPP_HIDE_FROM_ABI std::pair<_RandomAccessIterator, bool>
600__bitset_partition(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
422601 using _Ops = _IterOps<_AlgPolicy>;
602 typedef typename std::iterator_traits<_RandomAccessIterator>::value_type value_type;
603 typedef typename std::iterator_traits<_RandomAccessIterator>::difference_type difference_type;
604 _LIBCPP_ASSERT(__last - __first >= difference_type(3), "");
605
606 _RandomAccessIterator __begin = __first;
607 value_type __pivot(_Ops::__iter_move(__first));
608 // Find the first element greater than the pivot.
609 if (__comp(__pivot, *(__last - difference_type(1)))) {
610 // Not guarded since we know the last element is greater than the pivot.
611 while (!__comp(__pivot, *++__first)) {
612 }
613 } else {
614 while (++__first < __last && !__comp(__pivot, *__first)) {
615 }
616 }
617 // Find the last element less than or equal to the pivot.
618 if (__first < __last) {
619 // It will be always guarded because __introsort will do the median-of-three
620 // before calling this.
621 while (__comp(__pivot, *--__last)) {
622 }
623 }
624 // If the first element greater than the pivot is at or after the
625 // last element less than or equal to the pivot, then we have covered the
626 // entire range without swapping elements. This implies the range is already
627 // partitioned.
628 bool __already_partitioned = __first >= __last;
629 if (!__already_partitioned) {
630 _Ops::iter_swap(__first, __last);
631 ++__first;
632 }
633
634 // In [__first, __last) __last is not inclusive. From now on, it uses last
635 // minus one to be inclusive on both sides.
636 _RandomAccessIterator __lm1 = __last - difference_type(1);
637 uint64_t __left_bitset = 0;
638 uint64_t __right_bitset = 0;
639
640 // Reminder: length = __lm1 - __first + 1.
641 while (__lm1 - __first >= 2 * __detail::__block_size - 1) {
642 // Record the comparison outcomes for the elements currently on the left
643 // side.
644 if (__left_bitset == 0)
645 std::__populate_left_bitset<_Compare>(__first, __comp, __pivot, __left_bitset);
646 // Record the comparison outcomes for the elements currently on the right
647 // side.
648 if (__right_bitset == 0)
649 std::__populate_right_bitset<_Compare>(__lm1, __comp, __pivot, __right_bitset);
650 // Swap the elements recorded to be the candidates for swapping in the
651 // bitsets.
652 std::__swap_bitmap_pos<_AlgPolicy, _RandomAccessIterator>(__first, __lm1, __left_bitset, __right_bitset);
653 // Only advance the iterator if all the elements that need to be moved to
654 // other side were moved.
655 __first += (__left_bitset == 0) ? difference_type(__detail::__block_size) : difference_type(0);
656 __lm1 -= (__right_bitset == 0) ? difference_type(__detail::__block_size) : difference_type(0);
657 }
658 // Now, we have a less-than a block worth of elements on at least one of the
659 // sides.
660 std::__bitset_partition_partial_blocks<_AlgPolicy, _Compare>(
661 __first, __lm1, __comp, __pivot, __left_bitset, __right_bitset);
662 // At least one the bitsets would be empty. For the non-empty one, we need to
663 // properly partition the elements that appear within that bitset.
664 std::__swap_bitmap_pos_within<_AlgPolicy>(__first, __lm1, __left_bitset, __right_bitset);
665
666 // Move the pivot to its correct position.
667 _RandomAccessIterator __pivot_pos = __first - difference_type(1);
668 if (__begin != __pivot_pos) {
669 *__begin = _Ops::__iter_move(__pivot_pos);
670 }
671 *__pivot_pos = std::move(__pivot);
672 return std::make_pair(__pivot_pos, __already_partitioned);
673}
423674
675// Partition [__first, __last) using the comparator __comp. *__first has the
676// chosen pivot. Elements that are equivalent are kept to the right of the
677// pivot. Returns the iterator for the pivot and a bool value which is true if
678// the provided range is already sorted, false otherwise. We assume that the
679// length of the range is at least three elements.
680template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
681_LIBCPP_HIDE_FROM_ABI std::pair<_RandomAccessIterator, bool>
682__partition_with_equals_on_right(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
683 using _Ops = _IterOps<_AlgPolicy>;
424684 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
425 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
426 const difference_type __limit =
427 is_trivially_copy_constructible<value_type>::value && is_trivially_copy_assignable<value_type>::value ? 30 : 6;
685 typedef typename std::iterator_traits<_RandomAccessIterator>::value_type value_type;
686 _LIBCPP_ASSERT(__last - __first >= difference_type(3), "");
687 _RandomAccessIterator __begin = __first;
688 value_type __pivot(_Ops::__iter_move(__first));
689 // Find the first element greater or equal to the pivot. It will be always
690 // guarded because __introsort will do the median-of-three before calling
691 // this.
692 while (__comp(*++__first, __pivot))
693 ;
694
695 // Find the last element less than the pivot.
696 if (__begin == __first - difference_type(1)) {
697 while (__first < __last && !__comp(*--__last, __pivot))
698 ;
699 } else {
700 // Guarded.
701 while (!__comp(*--__last, __pivot))
702 ;
703 }
704
705 // If the first element greater than or equal to the pivot is at or after the
706 // last element less than the pivot, then we have covered the entire range
707 // without swapping elements. This implies the range is already partitioned.
708 bool __already_partitioned = __first >= __last;
709 // Go through the remaining elements. Swap pairs of elements (one to the
710 // right of the pivot and the other to left of the pivot) that are not on the
711 // correct side of the pivot.
712 while (__first < __last) {
713 _Ops::iter_swap(__first, __last);
714 while (__comp(*++__first, __pivot))
715 ;
716 while (!__comp(*--__last, __pivot))
717 ;
718 }
719 // Move the pivot to its correct position.
720 _RandomAccessIterator __pivot_pos = __first - difference_type(1);
721 if (__begin != __pivot_pos) {
722 *__begin = _Ops::__iter_move(__pivot_pos);
723 }
724 *__pivot_pos = std::move(__pivot);
725 return std::make_pair(__pivot_pos, __already_partitioned);
726}
727
728// Similar to the above function. Elements equivalent to the pivot are put to
729// the left of the pivot. Returns the iterator to the pivot element.
730template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
731_LIBCPP_HIDE_FROM_ABI _RandomAccessIterator
732__partition_with_equals_on_left(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
733 using _Ops = _IterOps<_AlgPolicy>;
734 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
735 typedef typename std::iterator_traits<_RandomAccessIterator>::value_type value_type;
736 _RandomAccessIterator __begin = __first;
737 value_type __pivot(_Ops::__iter_move(__first));
738 if (__comp(__pivot, *(__last - difference_type(1)))) {
739 // Guarded.
740 while (!__comp(__pivot, *++__first)) {
741 }
742 } else {
743 while (++__first < __last && !__comp(__pivot, *__first)) {
744 }
745 }
746
747 if (__first < __last) {
748 // It will be always guarded because __introsort will do the
749 // median-of-three before calling this.
750 while (__comp(__pivot, *--__last)) {
751 }
752 }
753 while (__first < __last) {
754 _Ops::iter_swap(__first, __last);
755 while (!__comp(__pivot, *++__first))
756 ;
757 while (__comp(__pivot, *--__last))
758 ;
759 }
760 _RandomAccessIterator __pivot_pos = __first - difference_type(1);
761 if (__begin != __pivot_pos) {
762 *__begin = _Ops::__iter_move(__pivot_pos);
763 }
764 *__pivot_pos = std::move(__pivot);
765 return __first;
766}
767
768// The main sorting function. Implements introsort combined with other ideas:
769// - option of using block quick sort for partitioning,
770// - guarded and unguarded insertion sort for small lengths,
771// - Tuckey's ninther technique for computing the pivot,
772// - check on whether partition was not required.
773// The implementation is partly based on Orson Peters' pattern-defeating
774// quicksort, published at: <https://github.com/orlp/pdqsort>.
775template <class _AlgPolicy, class _Compare, class _RandomAccessIterator, bool _UseBitSetPartition>
776void __introsort(_RandomAccessIterator __first,
777 _RandomAccessIterator __last,
778 _Compare __comp,
779 typename iterator_traits<_RandomAccessIterator>::difference_type __depth,
780 bool __leftmost = true) {
781 using _Ops = _IterOps<_AlgPolicy>;
782 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
783 using _Comp_ref = __comp_ref_type<_Compare>;
784 // Upper bound for using insertion sort for sorting.
785 _LIBCPP_CONSTEXPR difference_type __limit = 24;
786 // Lower bound for using Tuckey's ninther technique for median computation.
787 _LIBCPP_CONSTEXPR difference_type __ninther_threshold = 128;
428788 while (true) {
429 __restart:
430789 difference_type __len = __last - __first;
431790 switch (__len) {
432791 case 0:
......@@ -434,7 +793,7 @@ void __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _C
434793 return;
435794 case 2:
436795 if (__comp(*--__last, *__first))
437 _IterOps<_AlgPolicy>::iter_swap(__first, __last);
796 _Ops::iter_swap(__first, __last);
438797 return;
439798 case 3:
440799 std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), --__last, __comp);
......@@ -449,127 +808,60 @@ void __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _C
449808 --__last, __comp);
450809 return;
451810 }
452 if (__len <= __limit) {
453 std::__insertion_sort_3<_AlgPolicy, _Compare>(__first, __last, __comp);
811 // Use insertion sort if the length of the range is below the specified limit.
812 if (__len < __limit) {
813 if (__leftmost) {
814 std::__insertion_sort<_AlgPolicy, _Compare>(__first, __last, __comp);
815 } else {
816 std::__insertion_sort_unguarded<_AlgPolicy, _Compare>(__first, __last, __comp);
817 }
454818 return;
455819 }
456 // __len > 5
457820 if (__depth == 0) {
458821 // Fallback to heap sort as Introsort suggests.
459822 std::__partial_sort<_AlgPolicy, _Compare>(__first, __last, __last, __comp);
460823 return;
461824 }
462825 --__depth;
463 _RandomAccessIterator __m = __first;
464 _RandomAccessIterator __lm1 = __last;
465 --__lm1;
466 unsigned __n_swaps;
467826 {
468 difference_type __delta;
469 if (__len >= 1000) {
470 __delta = __len / 2;
471 __m += __delta;
472 __delta /= 2;
473 __n_swaps = std::__sort5_wrap_policy<_AlgPolicy, _Compare>(
474 __first, __first + __delta, __m, __m + __delta, __lm1, __comp);
827 difference_type __half_len = __len / 2;
828 // Use Tuckey's ninther technique or median of 3 for pivot selection
829 // depending on the length of the range being sorted.
830 if (__len > __ninther_threshold) {
831 std::__sort3<_AlgPolicy, _Compare>(__first, __first + __half_len, __last - difference_type(1), __comp);
832 std::__sort3<_AlgPolicy, _Compare>(
833 __first + difference_type(1), __first + (__half_len - 1), __last - difference_type(2), __comp);
834 std::__sort3<_AlgPolicy, _Compare>(
835 __first + difference_type(2), __first + (__half_len + 1), __last - difference_type(3), __comp);
836 std::__sort3<_AlgPolicy, _Compare>(
837 __first + (__half_len - 1), __first + __half_len, __first + (__half_len + 1), __comp);
838 _Ops::iter_swap(__first, __first + __half_len);
475839 } else {
476 __delta = __len / 2;
477 __m += __delta;
478 __n_swaps = std::__sort3<_AlgPolicy, _Compare>(__first, __m, __lm1, __comp);
840 std::__sort3<_AlgPolicy, _Compare>(__first + __half_len, __first, __last - difference_type(1), __comp);
479841 }
480842 }
481 // *__m is median
482 // partition [__first, __m) < *__m and *__m <= [__m, __last)
483 // (this inhibits tossing elements equivalent to __m around unnecessarily)
484 _RandomAccessIterator __i = __first;
485 _RandomAccessIterator __j = __lm1;
486 // j points beyond range to be tested, *__m is known to be <= *__lm1
487 // The search going up is known to be guarded but the search coming down isn't.
488 // Prime the downward search with a guard.
489 if (!__comp(*__i, *__m)) // if *__first == *__m
490 {
491 // *__first == *__m, *__first doesn't go in first part
492 // manually guard downward moving __j against __i
493 while (true) {
494 if (__i == --__j) {
495 // *__first == *__m, *__m <= all other elements
496 // Parition instead into [__first, __i) == *__first and *__first < [__i, __last)
497 ++__i; // __first + 1
498 __j = __last;
499 if (!__comp(*__first, *--__j)) // we need a guard if *__first == *(__last-1)
500 {
501 while (true) {
502 if (__i == __j)
503 return; // [__first, __last) all equivalent elements
504 if (__comp(*__first, *__i)) {
505 _Ops::iter_swap(__i, __j);
506 ++__n_swaps;
507 ++__i;
508 break;
509 }
510 ++__i;
511 }
512 }
513 // [__first, __i) == *__first and *__first < [__j, __last) and __j == __last - 1
514 if (__i == __j)
515 return;
516 while (true) {
517 while (!__comp(*__first, *__i))
518 ++__i;
519 while (__comp(*__first, *--__j))
520 ;
521 if (__i >= __j)
522 break;
523 _Ops::iter_swap(__i, __j);
524 ++__n_swaps;
525 ++__i;
526 }
527 // [__first, __i) == *__first and *__first < [__i, __last)
528 // The first part is sorted, sort the second part
529 // _VSTD::__sort<_Compare>(__i, __last, __comp);
530 __first = __i;
531 goto __restart;
532 }
533 if (__comp(*__j, *__m)) {
534 _Ops::iter_swap(__i, __j);
535 ++__n_swaps;
536 break; // found guard for downward moving __j, now use unguarded partition
537 }
538 }
539 }
540 // It is known that *__i < *__m
541 ++__i;
542 // j points beyond range to be tested, *__m is known to be <= *__lm1
543 // if not yet partitioned...
544 if (__i < __j) {
545 // known that *(__i - 1) < *__m
546 // known that __i <= __m
547 while (true) {
548 // __m still guards upward moving __i
549 while (__comp(*__i, *__m))
550 ++__i;
551 // It is now known that a guard exists for downward moving __j
552 while (!__comp(*--__j, *__m))
553 ;
554 if (__i > __j)
555 break;
556 _Ops::iter_swap(__i, __j);
557 ++__n_swaps;
558 // It is known that __m != __j
559 // If __m just moved, follow it
560 if (__m == __i)
561 __m = __j;
562 ++__i;
563 }
564 }
565 // [__first, __i) < *__m and *__m <= [__i, __last)
566 if (__i != __m && __comp(*__m, *__i)) {
567 _Ops::iter_swap(__i, __m);
568 ++__n_swaps;
843 // The elements to the left of the current iterator range are already
844 // sorted. If the current iterator range to be sorted is not the
845 // leftmost part of the entire iterator range and the pivot is same as
846 // the highest element in the range to the left, then we know that all
847 // the elements in the range [first, pivot] would be equal to the pivot,
848 // assuming the equal elements are put on the left side when
849 // partitioned. This also means that we do not need to sort the left
850 // side of the partition.
851 if (!__leftmost && !__comp(*(__first - difference_type(1)), *__first)) {
852 __first = std::__partition_with_equals_on_left<_AlgPolicy, _RandomAccessIterator, _Comp_ref>(
853 __first, __last, _Comp_ref(__comp));
854 continue;
569855 }
856 // Use bitset partition only if asked for.
857 auto __ret =
858 _UseBitSetPartition
859 ? std::__bitset_partition<_AlgPolicy, _RandomAccessIterator, _Compare>(__first, __last, __comp)
860 : std::__partition_with_equals_on_right<_AlgPolicy, _RandomAccessIterator, _Compare>(__first, __last, __comp);
861 _RandomAccessIterator __i = __ret.first;
570862 // [__first, __i) < *__i and *__i <= [__i+1, __last)
571863 // If we were given a perfect partition, see if insertion sort is quick...
572 if (__n_swaps == 0) {
864 if (__ret.second) {
573865 using _WrappedComp = typename _WrapAlgPolicy<_AlgPolicy, _Compare>::type;
574866 _WrappedComp __wrapped_comp(__comp);
575867 bool __fs = std::__insertion_sort_incomplete<_WrappedComp>(__first, __i, __wrapped_comp);
......@@ -585,14 +877,11 @@ void __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _C
585877 }
586878 }
587879 }
588 // sort smaller range with recursive call and larger with tail recursion elimination
589 if (__i - __first < __last - __i) {
590 std::__introsort<_AlgPolicy, _Compare>(__first, __i, __comp, __depth);
591 __first = ++__i;
592 } else {
593 std::__introsort<_AlgPolicy, _Compare>(__i + difference_type(1), __last, __comp, __depth);
594 __last = __i;
595 }
880 // Sort the left partiton recursively and the right partition with tail recursion elimination.
881 std::__introsort<_AlgPolicy, _Compare, _RandomAccessIterator, _UseBitSetPartition>(
882 __first, __i, __comp, __depth, __leftmost);
883 __leftmost = false;
884 __first = ++__i;
596885 }
597886}
598887
......@@ -616,15 +905,22 @@ inline _LIBCPP_HIDE_FROM_ABI _Number __log2i(_Number __n) {
616905}
617906
618907template <class _WrappedComp, class _RandomAccessIterator>
619void __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _WrappedComp __wrapped_comp) {
908_LIBCPP_HIDDEN void __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _WrappedComp __wrapped_comp) {
620909 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
621 difference_type __depth_limit = 2 * __log2i(__last - __first);
910 difference_type __depth_limit = 2 * std::__log2i(__last - __first);
622911
623912 using _Unwrap = _UnwrapAlgPolicy<_WrappedComp>;
624913 using _AlgPolicy = typename _Unwrap::_AlgPolicy;
625914 using _Compare = typename _Unwrap::_Comp;
626915 _Compare __comp = _Unwrap::__get_comp(__wrapped_comp);
627 std::__introsort<_AlgPolicy, _Compare>(__first, __last, __comp, __depth_limit);
916 // Only use bitset partitioning for arithmetic types. We should also check
917 // that the default comparator is in use so that we are sure that there are no
918 // branches in the comparator.
919 std::__introsort<_AlgPolicy,
920 _Compare,
921 _RandomAccessIterator,
922 __use_branchless_sort<_Compare, _RandomAccessIterator>::value>(
923 __first, __last, __comp, __depth_limit);
628924}
629925
630926template <class _Compare, class _Tp>
......@@ -672,11 +968,11 @@ extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long do
672968extern template _LIBCPP_FUNC_VIS unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&);
673969
674970template <class _AlgPolicy, class _RandomAccessIterator, class _Comp>
675inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
971inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
676972void __sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp& __comp) {
677973 std::__debug_randomize_range<_AlgPolicy>(__first, __last);
678974
679 using _Comp_ref = typename __comp_ref_type<_Comp>::type;
975 using _Comp_ref = __comp_ref_type<_Comp>;
680976 if (__libcpp_is_constant_evaluated()) {
681977 std::__partial_sort<_AlgPolicy>(__first, __last, __last, __comp);
682978
......@@ -689,13 +985,13 @@ void __sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, _C
689985}
690986
691987template <class _RandomAccessIterator, class _Comp>
692inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
988inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
693989void sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) {
694990 std::__sort_impl<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp);
695991}
696992
697993template <class _RandomAccessIterator>
698inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
994inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
699995void sort(_RandomAccessIterator __first, _RandomAccessIterator __last) {
700996 std::sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
701997}
lib/libcxx/include/__algorithm/sort_heap.h+4-5
......@@ -25,10 +25,9 @@
2525_LIBCPP_BEGIN_NAMESPACE_STD
2626
2727template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
28inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
28inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
2929void __sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp) {
30 using _CompRef = typename __comp_ref_type<_Compare>::type;
31 _CompRef __comp_ref = __comp;
30 __comp_ref_type<_Compare> __comp_ref = __comp;
3231
3332 using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;
3433 for (difference_type __n = __last - __first; __n > 1; --__last, (void) --__n)
......@@ -36,7 +35,7 @@ void __sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _C
3635}
3736
3837template <class _RandomAccessIterator, class _Compare>
39inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
38inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
4039void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
4140 static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible.");
4241 static_assert(std::is_copy_assignable<_RandomAccessIterator>::value, "Iterators must be copy assignable.");
......@@ -45,7 +44,7 @@ void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Com
4544}
4645
4746template <class _RandomAccessIterator>
48inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
47inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
4948void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {
5049 std::sort_heap(std::move(__first), std::move(__last),
5150 __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
lib/libcxx/include/__algorithm/stable_partition.h+10-5
......@@ -15,7 +15,12 @@
1515#include <__iterator/advance.h>
1616#include <__iterator/distance.h>
1717#include <__iterator/iterator_traits.h>
18#include <memory>
18#include <__memory/destruct_n.h>
19#include <__memory/temporary_buffer.h>
20#include <__memory/unique_ptr.h>
21#include <__utility/move.h>
22#include <__utility/pair.h>
23#include <new>
1924#include <type_traits>
2025
2126#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -25,7 +30,7 @@
2530_LIBCPP_BEGIN_NAMESPACE_STD
2631
2732template <class _AlgPolicy, class _Predicate, class _ForwardIterator, class _Distance, class _Pair>
28_ForwardIterator
33_LIBCPP_HIDE_FROM_ABI _ForwardIterator
2934__stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,
3035 _Distance __len, _Pair __p, forward_iterator_tag __fit)
3136{
......@@ -114,7 +119,7 @@ __second_half_done:
114119}
115120
116121template <class _AlgPolicy, class _Predicate, class _ForwardIterator>
117_ForwardIterator
122_LIBCPP_HIDE_FROM_ABI _ForwardIterator
118123__stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,
119124 forward_iterator_tag)
120125{
......@@ -259,7 +264,7 @@ __second_half_done:
259264}
260265
261266template <class _AlgPolicy, class _Predicate, class _BidirectionalIterator>
262_BidirectionalIterator
267_LIBCPP_HIDE_FROM_ABI _BidirectionalIterator
263268__stable_partition_impl(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,
264269 bidirectional_iterator_tag)
265270{
......@@ -305,7 +310,7 @@ template <class _AlgPolicy, class _Predicate, class _ForwardIterator, class _Ite
305310_LIBCPP_HIDE_FROM_ABI
306311_ForwardIterator __stable_partition(
307312 _ForwardIterator __first, _ForwardIterator __last, _Predicate&& __pred, _IterCategory __iter_category) {
308 return std::__stable_partition_impl<_AlgPolicy, __uncvref_t<_Predicate>&>(
313 return std::__stable_partition_impl<_AlgPolicy, __remove_cvref_t<_Predicate>&>(
309314 std::move(__first), std::move(__last), __pred, __iter_category);
310315}
311316
lib/libcxx/include/__algorithm/stable_sort.h+8-5
......@@ -16,8 +16,12 @@
1616#include <__algorithm/sort.h>
1717#include <__config>
1818#include <__iterator/iterator_traits.h>
19#include <__memory/destruct_n.h>
20#include <__memory/temporary_buffer.h>
21#include <__memory/unique_ptr.h>
1922#include <__utility/move.h>
20#include <memory>
23#include <__utility/pair.h>
24#include <new>
2125#include <type_traits>
2226
2327#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -27,7 +31,7 @@
2731_LIBCPP_BEGIN_NAMESPACE_STD
2832
2933template <class _AlgPolicy, class _Compare, class _InputIterator1, class _InputIterator2>
30void
34_LIBCPP_HIDE_FROM_ABI void
3135__merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1,
3236 _InputIterator2 __first2, _InputIterator2 __last2,
3337 typename iterator_traits<_InputIterator1>::value_type* __result, _Compare __comp)
......@@ -69,7 +73,7 @@ __merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1,
6973}
7074
7175template <class _AlgPolicy, class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
72void
76_LIBCPP_HIDE_FROM_ABI void
7377__merge_move_assign(_InputIterator1 __first1, _InputIterator1 __last1,
7478 _InputIterator2 __first2, _InputIterator2 __last2,
7579 _OutputIterator __result, _Compare __comp)
......@@ -223,8 +227,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
223227 __h.reset(__buf.first);
224228 }
225229
226 using _Comp_ref = typename __comp_ref_type<_Compare>::type;
227 std::__stable_sort<_AlgPolicy, _Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second);
230 std::__stable_sort<_AlgPolicy, __comp_ref_type<_Compare> >(__first, __last, __comp, __len, __buf.first, __buf.second);
228231}
229232
230233template <class _RandomAccessIterator, class _Compare>
lib/libcxx/include/__algorithm/swap_ranges.h+3-3
......@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222
2323// 2+2 iterators: the shorter size will be used.
2424template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _Sentinel2>
25_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
25_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2626pair<_ForwardIterator1, _ForwardIterator2>
2727__swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2, _Sentinel2 __last2) {
2828 while (__first1 != __last1 && __first2 != __last2) {
......@@ -36,7 +36,7 @@ __swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2
3636
3737// 2+1 iterators: size2 >= size1.
3838template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2>
39_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
39_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
4040pair<_ForwardIterator1, _ForwardIterator2>
4141__swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2) {
4242 while (__first1 != __last1) {
......@@ -49,7 +49,7 @@ __swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2
4949}
5050
5151template <class _ForwardIterator1, class _ForwardIterator2>
52inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator2
52inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator2
5353swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {
5454 return std::__swap_ranges<_ClassicAlgPolicy>(
5555 std::move(__first1), std::move(__last1), std::move(__first2)).second;
lib/libcxx/include/__algorithm/transform.h+2-2
......@@ -18,7 +18,7 @@
1818_LIBCPP_BEGIN_NAMESPACE_STD
1919
2020template <class _InputIterator, class _OutputIterator, class _UnaryOperation>
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2222_OutputIterator
2323transform(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _UnaryOperation __op)
2424{
......@@ -28,7 +28,7 @@ transform(_InputIterator __first, _InputIterator __last, _OutputIterator __resul
2828}
2929
3030template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _BinaryOperation>
31inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
31inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
3232_OutputIterator
3333transform(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,
3434 _OutputIterator __result, _BinaryOperation __binary_op)
lib/libcxx/include/__algorithm/uniform_random_bit_generator_adaptor.h+5-5
......@@ -36,21 +36,21 @@ template <class _Gen>
3636class _ClassicGenAdaptor {
3737private:
3838 // The generator is not required to be copyable or movable, so it has to be stored as a reference.
39 _Gen& __gen;
39 _Gen& __gen_;
4040
4141public:
4242 using result_type = invoke_result_t<_Gen&>;
4343
4444 _LIBCPP_HIDE_FROM_ABI
45 static constexpr auto min() { return __uncvref_t<_Gen>::min(); }
45 static constexpr auto min() { return __remove_cvref_t<_Gen>::min(); }
4646 _LIBCPP_HIDE_FROM_ABI
47 static constexpr auto max() { return __uncvref_t<_Gen>::max(); }
47 static constexpr auto max() { return __remove_cvref_t<_Gen>::max(); }
4848
4949 _LIBCPP_HIDE_FROM_ABI
50 constexpr explicit _ClassicGenAdaptor(_Gen& __g) : __gen(__g) {}
50 constexpr explicit _ClassicGenAdaptor(_Gen& __g) : __gen_(__g) {}
5151
5252 _LIBCPP_HIDE_FROM_ABI
53 constexpr auto operator()() const { return __gen(); }
53 constexpr auto operator()() const { return __gen_(); }
5454};
5555
5656_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/unique.h+4-5
......@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2626// unique
2727
2828template <class _AlgPolicy, class _Iter, class _Sent, class _BinaryPredicate>
29_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 std::pair<_Iter, _Iter>
29_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 std::pair<_Iter, _Iter>
3030__unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
3131 __first = std::__adjacent_find(__first, __last, __pred);
3232 if (__first != __last) {
......@@ -43,16 +43,15 @@ __unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
4343}
4444
4545template <class _ForwardIterator, class _BinaryPredicate>
46_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
46_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
4747unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
4848 return std::__unique<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __pred).first;
4949}
5050
5151template <class _ForwardIterator>
52_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
52_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
5353unique(_ForwardIterator __first, _ForwardIterator __last) {
54 typedef typename iterator_traits<_ForwardIterator>::value_type __v;
55 return std::unique(__first, __last, __equal_to<__v>());
54 return std::unique(__first, __last, __equal_to());
5655}
5756
5857_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/unique_copy.h+9-10
......@@ -34,7 +34,7 @@ struct __read_from_tmp_value_tag {};
3434} // namespace __unique_copy_tags
3535
3636template <class _AlgPolicy, class _BinaryPredicate, class _InputIterator, class _Sent, class _OutputIterator>
37_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _OutputIterator>
37_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _OutputIterator>
3838__unique_copy(_InputIterator __first,
3939 _Sent __last,
4040 _OutputIterator __result,
......@@ -56,7 +56,7 @@ __unique_copy(_InputIterator __first,
5656}
5757
5858template <class _AlgPolicy, class _BinaryPredicate, class _ForwardIterator, class _Sent, class _OutputIterator>
59_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI pair<_ForwardIterator, _OutputIterator>
59_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pair<_ForwardIterator, _OutputIterator>
6060__unique_copy(_ForwardIterator __first,
6161 _Sent __last,
6262 _OutputIterator __result,
......@@ -78,7 +78,7 @@ __unique_copy(_ForwardIterator __first,
7878}
7979
8080template <class _AlgPolicy, class _BinaryPredicate, class _InputIterator, class _Sent, class _InputAndOutputIterator>
81_LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _InputAndOutputIterator>
81_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _InputAndOutputIterator>
8282__unique_copy(_InputIterator __first,
8383 _Sent __last,
8484 _InputAndOutputIterator __result,
......@@ -95,27 +95,26 @@ __unique_copy(_InputIterator __first,
9595}
9696
9797template <class _InputIterator, class _OutputIterator, class _BinaryPredicate>
98inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
98inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
9999unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred) {
100 using __algo_tag = typename conditional<
100 using __algo_tag = __conditional_t<
101101 is_base_of<forward_iterator_tag, typename iterator_traits<_InputIterator>::iterator_category>::value,
102102 __unique_copy_tags::__reread_from_input_tag,
103 typename conditional<
103 __conditional_t<
104104 is_base_of<forward_iterator_tag, typename iterator_traits<_OutputIterator>::iterator_category>::value &&
105105 is_same< typename iterator_traits<_InputIterator>::value_type,
106106 typename iterator_traits<_OutputIterator>::value_type>::value,
107107 __unique_copy_tags::__reread_from_output_tag,
108 __unique_copy_tags::__read_from_tmp_value_tag>::type >::type;
108 __unique_copy_tags::__read_from_tmp_value_tag> >;
109109 return std::__unique_copy<_ClassicAlgPolicy>(
110110 std::move(__first), std::move(__last), std::move(__result), __pred, __algo_tag())
111111 .second;
112112}
113113
114114template <class _InputIterator, class _OutputIterator>
115inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
115inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
116116unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
117 typedef typename iterator_traits<_InputIterator>::value_type __v;
118 return std::unique_copy(std::move(__first), std::move(__last), std::move(__result), __equal_to<__v>());
117 return std::unique_copy(std::move(__first), std::move(__last), std::move(__result), __equal_to());
119118}
120119
121120_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/unwrap_iter.h+4-2
......@@ -12,8 +12,10 @@
1212#include <__config>
1313#include <__iterator/iterator_traits.h>
1414#include <__memory/pointer_traits.h>
15#include <__type_traits/enable_if.h>
16#include <__type_traits/is_copy_constructible.h>
17#include <__utility/declval.h>
1518#include <__utility/move.h>
16#include <type_traits>
1719
1820#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1921# pragma GCC system_header
......@@ -57,7 +59,7 @@ struct __unwrap_iter_impl<_Iter, true> {
5759template<class _Iter,
5860 class _Impl = __unwrap_iter_impl<_Iter>,
5961 __enable_if_t<is_copy_constructible<_Iter>::value, int> = 0>
60inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
62inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
6163decltype(_Impl::__unwrap(std::declval<_Iter>())) __unwrap_iter(_Iter __i) _NOEXCEPT {
6264 return _Impl::__unwrap(__i);
6365}
lib/libcxx/include/__algorithm/unwrap_range.h+1-1
......@@ -28,7 +28,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2828// __unwrap_iter and __rewrap_iter don't work for this, because they assume that the iterator and sentinel have
2929// the same type. __unwrap_range tries to get two iterators and then forward to __unwrap_iter.
3030
31#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
31#if _LIBCPP_STD_VER > 17
3232template <class _Iter, class _Sent>
3333struct __unwrap_range_impl {
3434 _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Sent __sent)
lib/libcxx/include/__algorithm/upper_bound.h+3-3
......@@ -28,7 +28,7 @@
2828_LIBCPP_BEGIN_NAMESPACE_STD
2929
3030template <class _AlgPolicy, class _Compare, class _Iter, class _Sent, class _Tp, class _Proj>
31_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter
31_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter
3232__upper_bound(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp, _Proj&& __proj) {
3333 auto __len = _IterOps<_AlgPolicy>::distance(__first, __last);
3434 while (__len != 0) {
......@@ -45,7 +45,7 @@ __upper_bound(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp
4545}
4646
4747template <class _ForwardIterator, class _Tp, class _Compare>
48_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
48_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
4949upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
5050 static_assert(is_copy_constructible<_ForwardIterator>::value,
5151 "Iterator has to be copy constructible");
......@@ -54,7 +54,7 @@ upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu
5454}
5555
5656template <class _ForwardIterator, class _Tp>
57_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
57_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
5858upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
5959 return std::upper_bound(
6060 std::move(__first),
lib/libcxx/include/__assert+3-7
......@@ -17,13 +17,9 @@
1717# pragma GCC system_header
1818#endif
1919
20// This is for backwards compatibility with code that might have been enabling
21// assertions through the Debug mode previously.
22// TODO: In LLVM 16, make it an error to define _LIBCPP_DEBUG
20// TODO: Remove in LLVM 17.
2321#if defined(_LIBCPP_DEBUG)
24# ifndef _LIBCPP_ENABLE_ASSERTIONS
25# define _LIBCPP_ENABLE_ASSERTIONS 1
26# endif
22# error "Defining _LIBCPP_DEBUG is not supported anymore. Please use _LIBCPP_ENABLE_DEBUG_MODE instead."
2723#endif
2824
2925// Automatically enable assertions when the debug mode is enabled.
......@@ -45,7 +41,7 @@
4541# define _LIBCPP_ASSERT(expression, message) \
4642 (__builtin_expect(static_cast<bool>(expression), 1) ? \
4743 (void)0 : \
48 ::std::__libcpp_verbose_abort("%s:%d: assertion %s failed: %s", __FILE__, __LINE__, #expression, message))
44 _LIBCPP_VERBOSE_ABORT("%s:%d: assertion %s failed: %s", __FILE__, __LINE__, #expression, message))
4945#elif !defined(_LIBCPP_ASSERTIONS_DISABLE_ASSUME) && __has_builtin(__builtin_assume)
5046# define _LIBCPP_ASSERT(expression, message) \
5147 (_LIBCPP_DIAGNOSTIC_PUSH \
lib/libcxx/include/__availability+3-14
......@@ -156,20 +156,9 @@
156156# define _LIBCPP_AVAILABILITY_FORMAT
157157// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format
158158
159 // This controls whether the default verbose termination function is
160 // provided by the library.
161 //
162 // Note that when users provide their own custom function, it doesn't
163 // matter whether the dylib provides a default function, and the
164 // availability markup can actually give a false positive diagnostic
165 // (it will think that no function is provided, when in reality the
166 // user has provided their own).
167 //
168 // Users can pass -D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED
169 // to the compiler to tell the library not to define its own verbose abort.
170 // Note that defining this macro but failing to define a custom function
171 // will lead to a load-time error on back-deployment targets, so it should
172 // be avoided.
159 // This controls whether the library claims to provide a default verbose
160 // termination function, and consequently whether the headers will try
161 // to use it when the mechanism isn't overriden at compile-time.
173162// # define _LIBCPP_HAS_NO_VERBOSE_ABORT_IN_LIBRARY
174163
175164#elif defined(__APPLE__)
lib/libcxx/include/__bit/bit_cast.h+1-1
......@@ -11,7 +11,7 @@
1111#define _LIBCPP___BIT_BIT_CAST_H
1212
1313#include <__config>
14#include <type_traits>
14#include <__type_traits/is_trivially_copyable.h>
1515
1616#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1717# pragma GCC system_header
lib/libcxx/include/__bit/bit_ceil.h created+46
......@@ -0,0 +1,46 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___BIT_BIT_CEIL_H
10#define _LIBCPP___BIT_BIT_CEIL_H
11
12#include <__assert>
13#include <__bit/countl.h>
14#include <__concepts/arithmetic.h>
15#include <__config>
16#include <limits>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24#if _LIBCPP_STD_VER >= 20
25
26template <__libcpp_unsigned_integer _Tp>
27_LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_ceil(_Tp __t) noexcept {
28 if (__t < 2)
29 return 1;
30 const unsigned __n = numeric_limits<_Tp>::digits - std::countl_zero((_Tp)(__t - 1u));
31 _LIBCPP_ASSERT(__n != numeric_limits<_Tp>::digits, "Bad input to bit_ceil");
32
33 if constexpr (sizeof(_Tp) >= sizeof(unsigned))
34 return _Tp{1} << __n;
35 else {
36 const unsigned __extra = numeric_limits<unsigned>::digits - numeric_limits<_Tp>::digits;
37 const unsigned __retVal = 1u << (__n + __extra);
38 return (_Tp)(__retVal >> __extra);
39 }
40}
41
42#endif // _LIBCPP_STD_VER >= 20
43
44_LIBCPP_END_NAMESPACE_STD
45
46#endif // _LIBCPP___BIT_BIT_CEIL_H
lib/libcxx/include/__bit/bit_floor.h created+34
......@@ -0,0 +1,34 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___BIT_BIT_FLOOR_H
10#define _LIBCPP___BIT_BIT_FLOOR_H
11
12#include <__bit/bit_log2.h>
13#include <__concepts/arithmetic.h>
14#include <__config>
15#include <limits>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23#if _LIBCPP_STD_VER >= 20
24
25template <__libcpp_unsigned_integer _Tp>
26_LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_floor(_Tp __t) noexcept {
27 return __t == 0 ? 0 : _Tp{1} << std::__bit_log2(__t);
28}
29
30#endif // _LIBCPP_STD_VER >= 20
31
32_LIBCPP_END_NAMESPACE_STD
33
34#endif // _LIBCPP___BIT_BIT_FLOOR_H
lib/libcxx/include/__bit/bit_log2.h created+34
......@@ -0,0 +1,34 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___BIT_BIT_LOG2_H
10#define _LIBCPP___BIT_BIT_LOG2_H
11
12#include <__bit/countl.h>
13#include <__concepts/arithmetic.h>
14#include <__config>
15#include <limits>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23#if _LIBCPP_STD_VER >= 20
24
25template <__libcpp_unsigned_integer _Tp>
26_LIBCPP_HIDE_FROM_ABI constexpr _Tp __bit_log2(_Tp __t) noexcept {
27 return numeric_limits<_Tp>::digits - 1 - std::countl_zero(__t);
28}
29
30#endif // _LIBCPP_STD_VER >= 20
31
32_LIBCPP_END_NAMESPACE_STD
33
34#endif // _LIBCPP___BIT_BIT_LOG2_H
lib/libcxx/include/__bit/bit_width.h created+33
......@@ -0,0 +1,33 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___BIT_BIT_WIDTH_H
10#define _LIBCPP___BIT_BIT_WIDTH_H
11
12#include <__bit/bit_log2.h>
13#include <__concepts/arithmetic.h>
14#include <__config>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20#if _LIBCPP_STD_VER >= 20
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24template <__libcpp_unsigned_integer _Tp>
25_LIBCPP_HIDE_FROM_ABI constexpr int bit_width(_Tp __t) noexcept {
26 return __t == 0 ? 0 : std::__bit_log2(__t) + 1;
27}
28
29_LIBCPP_END_NAMESPACE_STD
30
31#endif // _LIBCPP_STD_VER >= 20
32
33#endif // _LIBCPP___BIT_BIT_WIDTH_H
lib/libcxx/include/__bit/blsr.h created+34
......@@ -0,0 +1,34 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___BIT_BLSR_H
10#define _LIBCPP___BIT_BLSR_H
11
12#include <__config>
13
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# pragma GCC system_header
16#endif
17
18_LIBCPP_BEGIN_NAMESPACE_STD
19
20inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unsigned __libcpp_blsr(unsigned __x) _NOEXCEPT {
21 return __x ^ (__x & -__x);
22}
23
24inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unsigned long __libcpp_blsr(unsigned long __x) _NOEXCEPT {
25 return __x ^ (__x & -__x);
26}
27
28inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unsigned long long __libcpp_blsr(unsigned long long __x) _NOEXCEPT {
29 return __x ^ (__x & -__x);
30}
31
32_LIBCPP_END_NAMESPACE_STD
33
34#endif // _LIBCPP___BIT_BLSR_H
lib/libcxx/include/__bit/countl.h created+104
......@@ -0,0 +1,104 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___BIT_COUNTL_H
10#define _LIBCPP___BIT_COUNTL_H
11
12#include <__bit/rotate.h>
13#include <__concepts/arithmetic.h>
14#include <__config>
15#include <__type_traits/is_unsigned_integer.h>
16#include <limits>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_PUSH_MACROS
23#include <__undef_macros>
24
25_LIBCPP_BEGIN_NAMESPACE_STD
26
27inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
28int __libcpp_clz(unsigned __x) _NOEXCEPT { return __builtin_clz(__x); }
29
30inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
31int __libcpp_clz(unsigned long __x) _NOEXCEPT { return __builtin_clzl(__x); }
32
33inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
34int __libcpp_clz(unsigned long long __x) _NOEXCEPT { return __builtin_clzll(__x); }
35
36# ifndef _LIBCPP_HAS_NO_INT128
37inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
38int __libcpp_clz(__uint128_t __x) _NOEXCEPT {
39 // The function is written in this form due to C++ constexpr limitations.
40 // The algorithm:
41 // - Test whether any bit in the high 64-bits is set
42 // - No bits set:
43 // - The high 64-bits contain 64 leading zeros,
44 // - Add the result of the low 64-bits.
45 // - Any bits set:
46 // - The number of leading zeros of the input is the number of leading
47 // zeros in the high 64-bits.
48 return ((__x >> 64) == 0)
49 ? (64 + __builtin_clzll(static_cast<unsigned long long>(__x)))
50 : __builtin_clzll(static_cast<unsigned long long>(__x >> 64));
51}
52# endif // _LIBCPP_HAS_NO_INT128
53
54template<class _Tp>
55_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
56int __countl_zero(_Tp __t) _NOEXCEPT
57{
58 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countl_zero requires an unsigned integer type");
59 if (__t == 0)
60 return numeric_limits<_Tp>::digits;
61
62 if (sizeof(_Tp) <= sizeof(unsigned int))
63 return std::__libcpp_clz(static_cast<unsigned int>(__t))
64 - (numeric_limits<unsigned int>::digits - numeric_limits<_Tp>::digits);
65 else if (sizeof(_Tp) <= sizeof(unsigned long))
66 return std::__libcpp_clz(static_cast<unsigned long>(__t))
67 - (numeric_limits<unsigned long>::digits - numeric_limits<_Tp>::digits);
68 else if (sizeof(_Tp) <= sizeof(unsigned long long))
69 return std::__libcpp_clz(static_cast<unsigned long long>(__t))
70 - (numeric_limits<unsigned long long>::digits - numeric_limits<_Tp>::digits);
71 else
72 {
73 int __ret = 0;
74 int __iter = 0;
75 const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits;
76 while (true) {
77 __t = std::__rotr(__t, __ulldigits);
78 if ((__iter = std::__countl_zero(static_cast<unsigned long long>(__t))) != __ulldigits)
79 break;
80 __ret += __iter;
81 }
82 return __ret + __iter;
83 }
84}
85
86#if _LIBCPP_STD_VER >= 20
87
88template <__libcpp_unsigned_integer _Tp>
89_LIBCPP_HIDE_FROM_ABI constexpr int countl_zero(_Tp __t) noexcept {
90 return std::__countl_zero(__t);
91}
92
93template <__libcpp_unsigned_integer _Tp>
94_LIBCPP_HIDE_FROM_ABI constexpr int countl_one(_Tp __t) noexcept {
95 return __t != numeric_limits<_Tp>::max() ? std::countl_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits;
96}
97
98#endif // _LIBCPP_STD_VER >= 20
99
100_LIBCPP_END_NAMESPACE_STD
101
102_LIBCPP_POP_MACROS
103
104#endif // _LIBCPP___BIT_COUNTL_H
lib/libcxx/include/__bit/countr.h created+70
......@@ -0,0 +1,70 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___BIT_COUNTR_H
10#define _LIBCPP___BIT_COUNTR_H
11
12#include <__bit/rotate.h>
13#include <__concepts/arithmetic.h>
14#include <__config>
15#include <limits>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_PUSH_MACROS
22#include <__undef_macros>
23
24_LIBCPP_BEGIN_NAMESPACE_STD
25
26inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
27int __libcpp_ctz(unsigned __x) _NOEXCEPT { return __builtin_ctz(__x); }
28
29inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
30int __libcpp_ctz(unsigned long __x) _NOEXCEPT { return __builtin_ctzl(__x); }
31
32inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
33int __libcpp_ctz(unsigned long long __x) _NOEXCEPT { return __builtin_ctzll(__x); }
34
35#if _LIBCPP_STD_VER >= 20
36
37template <__libcpp_unsigned_integer _Tp>
38_LIBCPP_HIDE_FROM_ABI constexpr int countr_zero(_Tp __t) noexcept {
39 if (__t == 0)
40 return numeric_limits<_Tp>::digits;
41
42 if (sizeof(_Tp) <= sizeof(unsigned int))
43 return std::__libcpp_ctz(static_cast<unsigned int>(__t));
44 else if (sizeof(_Tp) <= sizeof(unsigned long))
45 return std::__libcpp_ctz(static_cast<unsigned long>(__t));
46 else if (sizeof(_Tp) <= sizeof(unsigned long long))
47 return std::__libcpp_ctz(static_cast<unsigned long long>(__t));
48 else {
49 int __ret = 0;
50 const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits;
51 while (static_cast<unsigned long long>(__t) == 0uLL) {
52 __ret += __ulldigits;
53 __t >>= __ulldigits;
54 }
55 return __ret + std::__libcpp_ctz(static_cast<unsigned long long>(__t));
56 }
57}
58
59template <__libcpp_unsigned_integer _Tp>
60_LIBCPP_HIDE_FROM_ABI constexpr int countr_one(_Tp __t) noexcept {
61 return __t != numeric_limits<_Tp>::max() ? std::countr_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits;
62}
63
64#endif // _LIBCPP_STD_VER >= 20
65
66_LIBCPP_END_NAMESPACE_STD
67
68_LIBCPP_POP_MACROS
69
70#endif // _LIBCPP___BIT_COUNTR_H
lib/libcxx/include/__bit/endian.h created+38
......@@ -0,0 +1,38 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___BIT_ENDIAN_H
10#define _LIBCPP___BIT_ENDIAN_H
11
12#include <__config>
13
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# pragma GCC system_header
16#endif
17
18#if _LIBCPP_STD_VER >= 20
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22enum class endian {
23 little = 0xDEAD,
24 big = 0xFACE,
25# if defined(_LIBCPP_LITTLE_ENDIAN)
26 native = little
27# elif defined(_LIBCPP_BIG_ENDIAN)
28 native = big
29# else
30 native = 0xCAFE
31# endif
32};
33
34_LIBCPP_END_NAMESPACE_STD
35
36#endif // _LIBCPP_STD_VER >= 20
37
38#endif // _LIBCPP___BIT_ENDIAN_H
lib/libcxx/include/__bit/has_single_bit.h created+37
......@@ -0,0 +1,37 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___BIT_HAS_SINGLE_BIT_H
10#define _LIBCPP___BIT_HAS_SINGLE_BIT_H
11
12#include <__concepts/arithmetic.h>
13#include <__config>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_PUSH_MACROS
20#include <__undef_macros>
21
22#if _LIBCPP_STD_VER >= 20
23
24_LIBCPP_BEGIN_NAMESPACE_STD
25
26template <__libcpp_unsigned_integer _Tp>
27_LIBCPP_HIDE_FROM_ABI constexpr bool has_single_bit(_Tp __t) noexcept {
28 return __t != 0 && (((__t & (__t - 1)) == 0));
29}
30
31_LIBCPP_END_NAMESPACE_STD
32
33#endif // _LIBCPP_STD_VER >= 20
34
35_LIBCPP_POP_MACROS
36
37#endif // _LIBCPP___BIT_HAS_SINGLE_BIT_H
lib/libcxx/include/__bit/popcount.h created+61
......@@ -0,0 +1,61 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___BIT_POPCOUNT_H
10#define _LIBCPP___BIT_POPCOUNT_H
11
12#include <__bit/rotate.h>
13#include <__concepts/arithmetic.h>
14#include <__config>
15#include <limits>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_PUSH_MACROS
22#include <__undef_macros>
23
24_LIBCPP_BEGIN_NAMESPACE_STD
25
26inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
27int __libcpp_popcount(unsigned __x) _NOEXCEPT { return __builtin_popcount(__x); }
28
29inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
30int __libcpp_popcount(unsigned long __x) _NOEXCEPT { return __builtin_popcountl(__x); }
31
32inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
33int __libcpp_popcount(unsigned long long __x) _NOEXCEPT { return __builtin_popcountll(__x); }
34
35#if _LIBCPP_STD_VER >= 20
36
37template <__libcpp_unsigned_integer _Tp>
38_LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noexcept {
39 if (sizeof(_Tp) <= sizeof(unsigned int))
40 return std::__libcpp_popcount(static_cast<unsigned int>(__t));
41 else if (sizeof(_Tp) <= sizeof(unsigned long))
42 return std::__libcpp_popcount(static_cast<unsigned long>(__t));
43 else if (sizeof(_Tp) <= sizeof(unsigned long long))
44 return std::__libcpp_popcount(static_cast<unsigned long long>(__t));
45 else {
46 int __ret = 0;
47 while (__t != 0) {
48 __ret += std::__libcpp_popcount(static_cast<unsigned long long>(__t));
49 __t >>= numeric_limits<unsigned long long>::digits;
50 }
51 return __ret;
52 }
53}
54
55#endif // _LIBCPP_STD_VER >= 20
56
57_LIBCPP_END_NAMESPACE_STD
58
59_LIBCPP_POP_MACROS
60
61#endif // _LIBCPP___BIT_POPCOUNT_H
lib/libcxx/include/__bit/rotate.h created+53
......@@ -0,0 +1,53 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___BIT_ROTATE_H
10#define _LIBCPP___BIT_ROTATE_H
11
12#include <__concepts/arithmetic.h>
13#include <__config>
14#include <__type_traits/is_unsigned_integer.h>
15#include <limits>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23template<class _Tp>
24_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
25_Tp __rotr(_Tp __t, unsigned int __cnt) _NOEXCEPT
26{
27 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an unsigned integer type");
28 const unsigned int __dig = numeric_limits<_Tp>::digits;
29 if ((__cnt % __dig) == 0)
30 return __t;
31 return (__t >> (__cnt % __dig)) | (__t << (__dig - (__cnt % __dig)));
32}
33
34#if _LIBCPP_STD_VER >= 20
35
36template <__libcpp_unsigned_integer _Tp>
37_LIBCPP_HIDE_FROM_ABI constexpr _Tp rotl(_Tp __t, unsigned int __cnt) noexcept {
38 const unsigned int __dig = numeric_limits<_Tp>::digits;
39 if ((__cnt % __dig) == 0)
40 return __t;
41 return (__t << (__cnt % __dig)) | (__t >> (__dig - (__cnt % __dig)));
42}
43
44template <__libcpp_unsigned_integer _Tp>
45_LIBCPP_HIDE_FROM_ABI constexpr _Tp rotr(_Tp __t, unsigned int __cnt) noexcept {
46 return std::__rotr(__t, __cnt);
47}
48
49#endif // _LIBCPP_STD_VER >= 20
50
51_LIBCPP_END_NAMESPACE_STD
52
53#endif // _LIBCPP___BIT_ROTATE_H
lib/libcxx/include/__bit_reference+88-86
......@@ -13,7 +13,8 @@
1313#include <__algorithm/copy_n.h>
1414#include <__algorithm/fill_n.h>
1515#include <__algorithm/min.h>
16#include <__bits>
16#include <__bit/countr.h>
17#include <__bit/popcount.h>
1718#include <__config>
1819#include <__iterator/iterator_traits.h>
1920#include <__memory/construct_at.h>
......@@ -54,15 +55,17 @@ class __bit_reference
5455 friend class __bit_const_reference<_Cp>;
5556 friend class __bit_iterator<_Cp, false>;
5657public:
57 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
58 using __container = typename _Cp::__self;
59
60 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
5861 __bit_reference(const __bit_reference&) = default;
5962
60 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 operator bool() const _NOEXCEPT
63 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 operator bool() const _NOEXCEPT
6164 {return static_cast<bool>(*__seg_ & __mask_);}
62 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool operator ~() const _NOEXCEPT
65 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool operator ~() const _NOEXCEPT
6366 {return !static_cast<bool>(*this);}
6467
65 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
68 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
6669 __bit_reference& operator=(bool __x) _NOEXCEPT
6770 {
6871 if (__x)
......@@ -82,15 +85,15 @@ public:
8285 }
8386#endif
8487
85 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
88 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
8689 __bit_reference& operator=(const __bit_reference& __x) _NOEXCEPT
8790 {return operator=(static_cast<bool>(__x));}
8891
89 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void flip() _NOEXCEPT {*__seg_ ^= __mask_;}
90 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false> operator&() const _NOEXCEPT
91 {return __bit_iterator<_Cp, false>(__seg_, static_cast<unsigned>(__libcpp_ctz(__mask_)));}
92 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void flip() _NOEXCEPT {*__seg_ ^= __mask_;}
93 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, false> operator&() const _NOEXCEPT
94 {return __bit_iterator<_Cp, false>(__seg_, static_cast<unsigned>(std::__libcpp_ctz(__mask_)));}
9295private:
93 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
96 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
9497 explicit __bit_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT
9598 : __seg_(__s), __mask_(__m) {}
9699};
......@@ -101,7 +104,7 @@ class __bit_reference<_Cp, false>
101104};
102105
103106template <class _Cp>
104inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
107inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
105108void
106109swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT
107110{
......@@ -111,7 +114,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT
111114}
112115
113116template <class _Cp, class _Dp>
114inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
117inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
115118void
116119swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT
117120{
......@@ -121,7 +124,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT
121124}
122125
123126template <class _Cp>
124inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
127inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
125128void
126129swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT
127130{
......@@ -131,7 +134,7 @@ swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT
131134}
132135
133136template <class _Cp>
134inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
137inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
135138void
136139swap(bool& __x, __bit_reference<_Cp> __y) _NOEXCEPT
137140{
......@@ -155,15 +158,15 @@ public:
155158 _LIBCPP_INLINE_VISIBILITY
156159 __bit_const_reference(const __bit_const_reference&) = default;
157160
158 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
161 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
159162 __bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT
160163 : __seg_(__x.__seg_), __mask_(__x.__mask_) {}
161164
162165 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator bool() const _NOEXCEPT
163166 {return static_cast<bool>(*__seg_ & __mask_);}
164167
165 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, true> operator&() const _NOEXCEPT
166 {return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(__libcpp_ctz(__mask_)));}
168 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, true> operator&() const _NOEXCEPT
169 {return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(std::__libcpp_ctz(__mask_)));}
167170private:
168171 _LIBCPP_INLINE_VISIBILITY
169172 _LIBCPP_CONSTEXPR
......@@ -176,7 +179,7 @@ private:
176179// find
177180
178181template <class _Cp, bool _IsConst>
179_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, _IsConst>
182_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, _IsConst>
180183__find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
181184{
182185 typedef __bit_iterator<_Cp, _IsConst> _It;
......@@ -212,7 +215,7 @@ __find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
212215}
213216
214217template <class _Cp, bool _IsConst>
215_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, _IsConst>
218_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, _IsConst>
216219__find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
217220{
218221 typedef __bit_iterator<_Cp, _IsConst> _It;
......@@ -251,7 +254,7 @@ __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
251254}
252255
253256template <class _Cp, bool _IsConst, class _Tp>
254inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
257inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
255258__bit_iterator<_Cp, _IsConst>
256259find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value)
257260{
......@@ -263,7 +266,7 @@ find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last
263266// count
264267
265268template <class _Cp, bool _IsConst>
266typename __bit_iterator<_Cp, _IsConst>::difference_type
269_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __bit_iterator<_Cp, _IsConst>::difference_type
267270__count_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
268271{
269272 typedef __bit_iterator<_Cp, _IsConst> _It;
......@@ -294,7 +297,7 @@ __count_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
294297}
295298
296299template <class _Cp, bool _IsConst>
297typename __bit_iterator<_Cp, _IsConst>::difference_type
300_LIBCPP_HIDE_FROM_ABI typename __bit_iterator<_Cp, _IsConst>::difference_type
298301__count_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
299302{
300303 typedef __bit_iterator<_Cp, _IsConst> _It;
......@@ -337,7 +340,7 @@ count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __las
337340// fill_n
338341
339342template <class _Cp>
340_LIBCPP_CONSTEXPR_AFTER_CXX17 void
343_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
341344__fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
342345{
343346 typedef __bit_iterator<_Cp, false> _It;
......@@ -367,7 +370,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
367370}
368371
369372template <class _Cp>
370_LIBCPP_CONSTEXPR_AFTER_CXX17 void
373_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
371374__fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
372375{
373376 typedef __bit_iterator<_Cp, false> _It;
......@@ -398,7 +401,7 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
398401}
399402
400403template <class _Cp>
401inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
404inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
402405void
403406fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value)
404407{
......@@ -414,7 +417,7 @@ fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __v
414417// fill
415418
416419template <class _Cp>
417inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
420inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
418421void
419422fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool __value)
420423{
......@@ -424,8 +427,7 @@ fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool
424427// copy
425428
426429template <class _Cp, bool _IsConst>
427_LIBCPP_CONSTEXPR_AFTER_CXX17
428__bit_iterator<_Cp, false>
430_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false>
429431__copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
430432 __bit_iterator<_Cp, false> __result)
431433{
......@@ -472,8 +474,7 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon
472474}
473475
474476template <class _Cp, bool _IsConst>
475_LIBCPP_CONSTEXPR_AFTER_CXX17
476__bit_iterator<_Cp, false>
477_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false>
477478__copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
478479 __bit_iterator<_Cp, false> __result)
479480{
......@@ -551,7 +552,7 @@ __copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsC
551552}
552553
553554template <class _Cp, bool _IsConst>
554inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
555inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
555556__bit_iterator<_Cp, false>
556557copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
557558{
......@@ -563,7 +564,7 @@ copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last
563564// copy_backward
564565
565566template <class _Cp, bool _IsConst>
566_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false>
567_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false>
567568__copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
568569 __bit_iterator<_Cp, false> __result)
569570{
......@@ -610,7 +611,7 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C
610611}
611612
612613template <class _Cp, bool _IsConst>
613_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false>
614_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false>
614615__copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
615616 __bit_iterator<_Cp, false> __result)
616617{
......@@ -696,7 +697,7 @@ __copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<
696697}
697698
698699template <class _Cp, bool _IsConst>
699inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
700inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
700701__bit_iterator<_Cp, false>
701702copy_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
702703{
......@@ -728,7 +729,7 @@ move_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCons
728729// swap_ranges
729730
730731template <class __C1, class __C2>
731__bit_iterator<__C2, false>
732_LIBCPP_HIDE_FROM_ABI __bit_iterator<__C2, false>
732733__swap_ranges_aligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1, false> __last,
733734 __bit_iterator<__C2, false> __result)
734735{
......@@ -778,7 +779,7 @@ __swap_ranges_aligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1,
778779}
779780
780781template <class __C1, class __C2>
781__bit_iterator<__C2, false>
782_LIBCPP_HIDE_FROM_ABI __bit_iterator<__C2, false>
782783__swap_ranges_unaligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1, false> __last,
783784 __bit_iterator<__C2, false> __result)
784785{
......@@ -903,19 +904,19 @@ struct __bit_array
903904 difference_type __size_;
904905 __storage_type __word_[_Np];
905906
906 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 static difference_type capacity()
907 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 static difference_type capacity()
907908 {return static_cast<difference_type>(_Np * __bits_per_word);}
908 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit __bit_array(difference_type __s) : __size_(__s) {
909 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bit_array(difference_type __s) : __size_(__s) {
909910 if (__libcpp_is_constant_evaluated()) {
910911 for (size_t __i = 0; __i != __bit_array<_Cp>::_Np; ++__i)
911912 std::__construct_at(__word_ + __i, 0);
912913 }
913914 }
914 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator begin()
915 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin()
915916 {
916917 return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0);
917918 }
918 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator end()
919 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator end()
919920 {
920921 return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word,
921922 static_cast<unsigned>(__size_ % __bits_per_word));
......@@ -923,7 +924,7 @@ struct __bit_array
923924};
924925
925926template <class _Cp>
926_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false>
927_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false>
927928rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle, __bit_iterator<_Cp, false> __last)
928929{
929930 typedef __bit_iterator<_Cp, false> _I1;
......@@ -974,7 +975,7 @@ rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle,
974975// equal
975976
976977template <class _Cp, bool _IC1, bool _IC2>
977_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
978_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool
978979__equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1,
979980 __bit_iterator<_Cp, _IC2> __first2)
980981{
......@@ -1056,7 +1057,7 @@ __equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1>
10561057}
10571058
10581059template <class _Cp, bool _IC1, bool _IC2>
1059_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
1060_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool
10601061__equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1,
10611062 __bit_iterator<_Cp, _IC2> __first2)
10621063{
......@@ -1099,7 +1100,7 @@ __equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __
10991100}
11001101
11011102template <class _Cp, bool _IC1, bool _IC2>
1102inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1103inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
11031104bool
11041105equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2)
11051106{
......@@ -1117,23 +1118,23 @@ public:
11171118 typedef bool value_type;
11181119 typedef __bit_iterator pointer;
11191120#ifndef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
1120 typedef typename conditional<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >::type reference;
1121 typedef __conditional_t<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> > reference;
11211122#else
1122 using reference = typename conditional<_IsConst, bool, __bit_reference<_Cp> >::type;
1123 using reference = __conditional_t<_IsConst, bool, __bit_reference<_Cp> >;
11231124#endif
11241125 typedef random_access_iterator_tag iterator_category;
11251126
11261127private:
11271128 typedef typename _Cp::__storage_type __storage_type;
1128 typedef typename conditional<_IsConst, typename _Cp::__const_storage_pointer,
1129 typename _Cp::__storage_pointer>::type __storage_pointer;
1129 typedef __conditional_t<_IsConst, typename _Cp::__const_storage_pointer, typename _Cp::__storage_pointer>
1130 __storage_pointer;
11301131 static const unsigned __bits_per_word = _Cp::__bits_per_word;
11311132
11321133 __storage_pointer __seg_;
11331134 unsigned __ctz_;
11341135
11351136public:
1136 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator() _NOEXCEPT
1137 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator() _NOEXCEPT
11371138#if _LIBCPP_STD_VER > 11
11381139 : __seg_(nullptr), __ctz_(0)
11391140#endif
......@@ -1144,7 +1145,7 @@ public:
11441145 // When _IsConst=true, this is a converting constructor;
11451146 // the copy and move constructors are implicitly generated
11461147 // and trivial.
1147 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1148 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
11481149 __bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT
11491150 : __seg_(__it.__seg_), __ctz_(__it.__ctz_) {}
11501151
......@@ -1153,19 +1154,19 @@ public:
11531154 // the implicit generation of a defaulted one is deprecated.
11541155 // When _IsConst=true, the assignment operators are
11551156 // implicitly generated and trivial.
1156 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1157 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
11571158 __bit_iterator& operator=(const _If<_IsConst, struct __private_nat, __bit_iterator>& __it) {
11581159 __seg_ = __it.__seg_;
11591160 __ctz_ = __it.__ctz_;
11601161 return *this;
11611162 }
11621163
1163 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator*() const _NOEXCEPT {
1164 return typename conditional<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >
1165 ::type(__seg_, __storage_type(1) << __ctz_);
1164 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator*() const _NOEXCEPT {
1165 return __conditional_t<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >(
1166 __seg_, __storage_type(1) << __ctz_);
11661167 }
11671168
1168 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator++()
1169 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator& operator++()
11691170 {
11701171 if (__ctz_ != __bits_per_word-1)
11711172 ++__ctz_;
......@@ -1177,14 +1178,14 @@ public:
11771178 return *this;
11781179 }
11791180
1180 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator++(int)
1181 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator operator++(int)
11811182 {
11821183 __bit_iterator __tmp = *this;
11831184 ++(*this);
11841185 return __tmp;
11851186 }
11861187
1187 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator--()
1188 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator& operator--()
11881189 {
11891190 if (__ctz_ != 0)
11901191 --__ctz_;
......@@ -1196,14 +1197,14 @@ public:
11961197 return *this;
11971198 }
11981199
1199 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator--(int)
1200 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator operator--(int)
12001201 {
12011202 __bit_iterator __tmp = *this;
12021203 --(*this);
12031204 return __tmp;
12041205 }
12051206
1206 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator+=(difference_type __n)
1207 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator& operator+=(difference_type __n)
12071208 {
12081209 if (__n >= 0)
12091210 __seg_ += (__n + __ctz_) / __bits_per_word;
......@@ -1215,54 +1216,54 @@ public:
12151216 return *this;
12161217 }
12171218
1218 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator-=(difference_type __n)
1219 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator& operator-=(difference_type __n)
12191220 {
12201221 return *this += -__n;
12211222 }
12221223
1223 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator+(difference_type __n) const
1224 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator operator+(difference_type __n) const
12241225 {
12251226 __bit_iterator __t(*this);
12261227 __t += __n;
12271228 return __t;
12281229 }
12291230
1230 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator-(difference_type __n) const
1231 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator operator-(difference_type __n) const
12311232 {
12321233 __bit_iterator __t(*this);
12331234 __t -= __n;
12341235 return __t;
12351236 }
12361237
1237 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1238 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
12381239 friend __bit_iterator operator+(difference_type __n, const __bit_iterator& __it) {return __it + __n;}
12391240
1240 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1241 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
12411242 friend difference_type operator-(const __bit_iterator& __x, const __bit_iterator& __y)
12421243 {return (__x.__seg_ - __y.__seg_) * __bits_per_word + __x.__ctz_ - __y.__ctz_;}
12431244
1244 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator[](difference_type __n) const {return *(*this + __n);}
1245 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator[](difference_type __n) const {return *(*this + __n);}
12451246
1246 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator==(const __bit_iterator& __x, const __bit_iterator& __y)
1247 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool operator==(const __bit_iterator& __x, const __bit_iterator& __y)
12471248 {return __x.__seg_ == __y.__seg_ && __x.__ctz_ == __y.__ctz_;}
12481249
1249 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator!=(const __bit_iterator& __x, const __bit_iterator& __y)
1250 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool operator!=(const __bit_iterator& __x, const __bit_iterator& __y)
12501251 {return !(__x == __y);}
12511252
1252 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator<(const __bit_iterator& __x, const __bit_iterator& __y)
1253 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool operator<(const __bit_iterator& __x, const __bit_iterator& __y)
12531254 {return __x.__seg_ < __y.__seg_ || (__x.__seg_ == __y.__seg_ && __x.__ctz_ < __y.__ctz_);}
12541255
1255 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator>(const __bit_iterator& __x, const __bit_iterator& __y)
1256 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool operator>(const __bit_iterator& __x, const __bit_iterator& __y)
12561257 {return __y < __x;}
12571258
1258 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator<=(const __bit_iterator& __x, const __bit_iterator& __y)
1259 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool operator<=(const __bit_iterator& __x, const __bit_iterator& __y)
12591260 {return !(__y < __x);}
12601261
1261 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator>=(const __bit_iterator& __x, const __bit_iterator& __y)
1262 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool operator>=(const __bit_iterator& __x, const __bit_iterator& __y)
12621263 {return !(__x < __y);}
12631264
12641265private:
1265 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1266 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
12661267 explicit __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT
12671268 : __seg_(__s), __ctz_(__ctz) {}
12681269
......@@ -1273,40 +1274,40 @@ private:
12731274 friend class __bit_iterator<_Cp, true>;
12741275 template <class _Dp> friend struct __bit_array;
12751276 template <class _Dp>
1276 _LIBCPP_CONSTEXPR_AFTER_CXX17
1277 _LIBCPP_CONSTEXPR_SINCE_CXX20
12771278 friend void __fill_n_false(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
12781279
12791280 template <class _Dp>
1280 _LIBCPP_CONSTEXPR_AFTER_CXX17
1281 _LIBCPP_CONSTEXPR_SINCE_CXX20
12811282 friend void __fill_n_true(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
12821283
12831284 template <class _Dp, bool _IC>
1284 _LIBCPP_CONSTEXPR_AFTER_CXX17
1285 _LIBCPP_CONSTEXPR_SINCE_CXX20
12851286 friend __bit_iterator<_Dp, false> __copy_aligned(__bit_iterator<_Dp, _IC> __first,
12861287 __bit_iterator<_Dp, _IC> __last,
12871288 __bit_iterator<_Dp, false> __result);
12881289 template <class _Dp, bool _IC>
1289 _LIBCPP_CONSTEXPR_AFTER_CXX17
1290 _LIBCPP_CONSTEXPR_SINCE_CXX20
12901291 friend __bit_iterator<_Dp, false> __copy_unaligned(__bit_iterator<_Dp, _IC> __first,
12911292 __bit_iterator<_Dp, _IC> __last,
12921293 __bit_iterator<_Dp, false> __result);
12931294 template <class _Dp, bool _IC>
1294 _LIBCPP_CONSTEXPR_AFTER_CXX17
1295 _LIBCPP_CONSTEXPR_SINCE_CXX20
12951296 friend __bit_iterator<_Dp, false> copy(__bit_iterator<_Dp, _IC> __first,
12961297 __bit_iterator<_Dp, _IC> __last,
12971298 __bit_iterator<_Dp, false> __result);
12981299 template <class _Dp, bool _IC>
1299 _LIBCPP_CONSTEXPR_AFTER_CXX17
1300 _LIBCPP_CONSTEXPR_SINCE_CXX20
13001301 friend __bit_iterator<_Dp, false> __copy_backward_aligned(__bit_iterator<_Dp, _IC> __first,
13011302 __bit_iterator<_Dp, _IC> __last,
13021303 __bit_iterator<_Dp, false> __result);
13031304 template <class _Dp, bool _IC>
1304 _LIBCPP_CONSTEXPR_AFTER_CXX17
1305 _LIBCPP_CONSTEXPR_SINCE_CXX20
13051306 friend __bit_iterator<_Dp, false> __copy_backward_unaligned(__bit_iterator<_Dp, _IC> __first,
13061307 __bit_iterator<_Dp, _IC> __last,
13071308 __bit_iterator<_Dp, false> __result);
13081309 template <class _Dp, bool _IC>
1309 _LIBCPP_CONSTEXPR_AFTER_CXX17
1310 _LIBCPP_CONSTEXPR_SINCE_CXX20
13101311 friend __bit_iterator<_Dp, false> copy_backward(__bit_iterator<_Dp, _IC> __first,
13111312 __bit_iterator<_Dp, _IC> __last,
13121313 __bit_iterator<_Dp, false> __result);
......@@ -1320,32 +1321,33 @@ private:
13201321 __bit_iterator<__C1, false>,
13211322 __bit_iterator<__C2, false>);
13221323 template <class _Dp>
1323 _LIBCPP_CONSTEXPR_AFTER_CXX17
1324 _LIBCPP_CONSTEXPR_SINCE_CXX20
13241325 friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>,
13251326 __bit_iterator<_Dp, false>,
13261327 __bit_iterator<_Dp, false>);
13271328 template <class _Dp, bool _IC1, bool _IC2>
1328 _LIBCPP_CONSTEXPR_AFTER_CXX17
1329 _LIBCPP_CONSTEXPR_SINCE_CXX20
13291330 friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>,
13301331 __bit_iterator<_Dp, _IC1>,
13311332 __bit_iterator<_Dp, _IC2>);
13321333 template <class _Dp, bool _IC1, bool _IC2>
1333 _LIBCPP_CONSTEXPR_AFTER_CXX17
1334 _LIBCPP_CONSTEXPR_SINCE_CXX20
13341335 friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>,
13351336 __bit_iterator<_Dp, _IC1>,
13361337 __bit_iterator<_Dp, _IC2>);
13371338 template <class _Dp, bool _IC1, bool _IC2>
1338 _LIBCPP_CONSTEXPR_AFTER_CXX17
1339 _LIBCPP_CONSTEXPR_SINCE_CXX20
13391340 friend bool equal(__bit_iterator<_Dp, _IC1>,
13401341 __bit_iterator<_Dp, _IC1>,
13411342 __bit_iterator<_Dp, _IC2>);
13421343 template <class _Dp, bool _IC>
1343 _LIBCPP_CONSTEXPR_AFTER_CXX17
1344 _LIBCPP_CONSTEXPR_SINCE_CXX20
13441345 friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
13451346 template <class _Dp, bool _IC>
1346 _LIBCPP_CONSTEXPR_AFTER_CXX17
1347 _LIBCPP_CONSTEXPR_SINCE_CXX20
13471348 friend __bit_iterator<_Dp, _IC> __find_bool_false(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
13481349 template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type
1350 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
13491351 __count_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
13501352 template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type
13511353 __count_bool_false(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
lib/libcxx/include/__bits deleted-162
......@@ -1,162 +0,0 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___BITS
11#define _LIBCPP___BITS
12
13#include <__config>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_PUSH_MACROS
20#include <__undef_macros>
21
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25#ifndef _LIBCPP_COMPILER_MSVC
26
27inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
28int __libcpp_ctz(unsigned __x) _NOEXCEPT { return __builtin_ctz(__x); }
29
30inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
31int __libcpp_ctz(unsigned long __x) _NOEXCEPT { return __builtin_ctzl(__x); }
32
33inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
34int __libcpp_ctz(unsigned long long __x) _NOEXCEPT { return __builtin_ctzll(__x); }
35
36
37inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
38int __libcpp_clz(unsigned __x) _NOEXCEPT { return __builtin_clz(__x); }
39
40inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
41int __libcpp_clz(unsigned long __x) _NOEXCEPT { return __builtin_clzl(__x); }
42
43inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
44int __libcpp_clz(unsigned long long __x) _NOEXCEPT { return __builtin_clzll(__x); }
45
46# ifndef _LIBCPP_HAS_NO_INT128
47inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
48int __libcpp_clz(__uint128_t __x) _NOEXCEPT {
49 // The function is written in this form due to C++ constexpr limitations.
50 // The algorithm:
51 // - Test whether any bit in the high 64-bits is set
52 // - No bits set:
53 // - The high 64-bits contain 64 leading zeros,
54 // - Add the result of the low 64-bits.
55 // - Any bits set:
56 // - The number of leading zeros of the input is the number of leading
57 // zeros in the high 64-bits.
58 return ((__x >> 64) == 0)
59 ? (64 + __builtin_clzll(static_cast<unsigned long long>(__x)))
60 : __builtin_clzll(static_cast<unsigned long long>(__x >> 64));
61}
62# endif
63
64inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
65int __libcpp_popcount(unsigned __x) _NOEXCEPT { return __builtin_popcount(__x); }
66
67inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
68int __libcpp_popcount(unsigned long __x) _NOEXCEPT { return __builtin_popcountl(__x); }
69
70inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
71int __libcpp_popcount(unsigned long long __x) _NOEXCEPT { return __builtin_popcountll(__x); }
72
73#else // _LIBCPP_COMPILER_MSVC
74
75// Precondition: __x != 0
76inline _LIBCPP_INLINE_VISIBILITY
77int __libcpp_ctz(unsigned __x) {
78 static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
79 static_assert(sizeof(unsigned long) == 4, "");
80 unsigned long __where;
81 if (_BitScanForward(&__where, __x))
82 return static_cast<int>(__where);
83 return 32;
84}
85
86inline _LIBCPP_INLINE_VISIBILITY
87int __libcpp_ctz(unsigned long __x) {
88 static_assert(sizeof(unsigned long) == sizeof(unsigned), "");
89 return __ctz(static_cast<unsigned>(__x));
90}
91
92inline _LIBCPP_INLINE_VISIBILITY
93int __libcpp_ctz(unsigned long long __x) {
94 unsigned long __where;
95#if defined(_LIBCPP_HAS_BITSCAN64)
96 if (_BitScanForward64(&__where, __x))
97 return static_cast<int>(__where);
98#else
99 // Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls.
100 if (_BitScanForward(&__where, static_cast<unsigned long>(__x)))
101 return static_cast<int>(__where);
102 if (_BitScanForward(&__where, static_cast<unsigned long>(__x >> 32)))
103 return static_cast<int>(__where + 32);
104#endif
105 return 64;
106}
107
108// Precondition: __x != 0
109inline _LIBCPP_INLINE_VISIBILITY
110int __libcpp_clz(unsigned __x) {
111 static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
112 static_assert(sizeof(unsigned long) == 4, "");
113 unsigned long __where;
114 if (_BitScanReverse(&__where, __x))
115 return static_cast<int>(31 - __where);
116 return 32; // Undefined Behavior.
117}
118
119inline _LIBCPP_INLINE_VISIBILITY
120int __libcpp_clz(unsigned long __x) {
121 static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
122 return __libcpp_clz(static_cast<unsigned>(__x));
123}
124
125inline _LIBCPP_INLINE_VISIBILITY
126int __libcpp_clz(unsigned long long __x) {
127 unsigned long __where;
128#if defined(_LIBCPP_HAS_BITSCAN64)
129 if (_BitScanReverse64(&__where, __x))
130 return static_cast<int>(63 - __where);
131#else
132 // Win32 doesn't have _BitScanReverse64 so emulate it with two 32 bit calls.
133 if (_BitScanReverse(&__where, static_cast<unsigned long>(__x >> 32)))
134 return static_cast<int>(63 - (__where + 32));
135 if (_BitScanReverse(&__where, static_cast<unsigned long>(__x)))
136 return static_cast<int>(63 - __where);
137#endif
138 return 64; // Undefined Behavior.
139}
140
141inline _LIBCPP_INLINE_VISIBILITY int __libcpp_popcount(unsigned __x) {
142 static_assert(sizeof(unsigned) == 4, "");
143 return __popcnt(__x);
144}
145
146inline _LIBCPP_INLINE_VISIBILITY int __libcpp_popcount(unsigned long __x) {
147 static_assert(sizeof(unsigned long) == 4, "");
148 return __popcnt(__x);
149}
150
151inline _LIBCPP_INLINE_VISIBILITY int __libcpp_popcount(unsigned long long __x) {
152 static_assert(sizeof(unsigned long long) == 8, "");
153 return __popcnt64(__x);
154}
155
156#endif // _LIBCPP_COMPILER_MSVC
157
158_LIBCPP_END_NAMESPACE_STD
159
160_LIBCPP_POP_MACROS
161
162#endif // _LIBCPP___BITS
lib/libcxx/include/__bsd_locale_fallbacks.h-1
......@@ -13,7 +13,6 @@
1313#ifndef _LIBCPP___BSD_LOCALE_FALLBACKS_H
1414#define _LIBCPP___BSD_LOCALE_FALLBACKS_H
1515
16#include <memory>
1716#include <stdarg.h>
1817#include <stdlib.h>
1918
lib/libcxx/include/__charconv/chars_format.h+5-5
......@@ -19,7 +19,7 @@
1919
2020_LIBCPP_BEGIN_NAMESPACE_STD
2121
22#ifndef _LIBCPP_CXX03_LANG
22#if _LIBCPP_STD_VER > 14
2323
2424enum class _LIBCPP_ENUM_VIS chars_format
2525{
......@@ -52,25 +52,25 @@ operator^(chars_format __x, chars_format __y) {
5252 _VSTD::__to_underlying(__y));
5353}
5454
55inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format&
55inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format&
5656operator&=(chars_format& __x, chars_format __y) {
5757 __x = __x & __y;
5858 return __x;
5959}
6060
61inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format&
61inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format&
6262operator|=(chars_format& __x, chars_format __y) {
6363 __x = __x | __y;
6464 return __x;
6565}
6666
67inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format&
67inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format&
6868operator^=(chars_format& __x, chars_format __y) {
6969 __x = __x ^ __y;
7070 return __x;
7171}
7272
73#endif // _LIBCPP_CXX03_LANG
73#endif // _LIBCPP_STD_VER > 14
7474
7575_LIBCPP_END_NAMESPACE_STD
7676
lib/libcxx/include/__charconv/from_chars_result.h+2-2
......@@ -19,7 +19,7 @@
1919
2020_LIBCPP_BEGIN_NAMESPACE_STD
2121
22#ifndef _LIBCPP_CXX03_LANG
22#if _LIBCPP_STD_VER > 14
2323
2424struct _LIBCPP_TYPE_VIS from_chars_result
2525{
......@@ -30,7 +30,7 @@ struct _LIBCPP_TYPE_VIS from_chars_result
3030# endif
3131};
3232
33#endif // _LIBCPP_CXX03_LANG
33#endif // _LIBCPP_STD_VER > 14
3434
3535_LIBCPP_END_NAMESPACE_STD
3636
lib/libcxx/include/__charconv/tables.h+10-36
......@@ -19,38 +19,16 @@
1919
2020_LIBCPP_BEGIN_NAMESPACE_STD
2121
22#ifndef _LIBCPP_CXX03_LANG
22#if _LIBCPP_STD_VER > 14
2323
2424namespace __itoa {
2525
26/// Contains the charconv helper tables.
27///
28/// In C++17 these could be inline constexpr variable, but libc++ supports
29/// charconv for integrals in C++11 mode.
30template <class = void>
31struct __table {
32 static const char __base_2_lut[64];
33 static const char __base_8_lut[128];
34 static const char __base_16_lut[512];
35
36 static const uint32_t __pow10_32[10];
37 static const uint64_t __pow10_64[20];
38# ifndef _LIBCPP_HAS_NO_INT128
39 // TODO FMT Reduce the number of entries in this table.
40 static const __uint128_t __pow10_128[40];
41 static const int __pow10_128_offset = 0;
42# endif
43 static const char __digits_base_10[200];
44};
45
46template <class _Tp>
47const char __table<_Tp>::__base_2_lut[64] = {
26inline constexpr char __base_2_lut[64] = {
4827 '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '1', '0', '0', '0', '1', '1', '0', '1', '0', '0', '0', '1',
4928 '0', '1', '0', '1', '1', '0', '0', '1', '1', '1', '1', '0', '0', '0', '1', '0', '0', '1', '1', '0', '1', '0',
5029 '1', '0', '1', '1', '1', '1', '0', '0', '1', '1', '0', '1', '1', '1', '1', '0', '1', '1', '1', '1'};
5130
52template <class _Tp>
53const char __table<_Tp>::__base_8_lut[128] = {
31inline constexpr char __base_8_lut[128] = {
5432 '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '1', '0', '1', '1', '1', '2',
5533 '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5',
5634 '2', '6', '2', '7', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '4', '0',
......@@ -58,8 +36,7 @@ const char __table<_Tp>::__base_8_lut[128] = {
5836 '5', '4', '5', '5', '5', '6', '5', '7', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6',
5937 '6', '7', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7'};
6038
61template <class _Tp>
62const char __table<_Tp>::__base_16_lut[512] = {
39inline constexpr char __base_16_lut[512] = {
6340 '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', '0', 'a', '0',
6441 'b', '0', 'c', '0', 'd', '0', 'e', '0', 'f', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6',
6542 '1', '7', '1', '8', '1', '9', '1', 'a', '1', 'b', '1', 'c', '1', 'd', '1', 'e', '1', 'f', '2', '0', '2', '1', '2',
......@@ -84,13 +61,11 @@ const char __table<_Tp>::__base_16_lut[512] = {
8461 '1', 'f', '2', 'f', '3', 'f', '4', 'f', '5', 'f', '6', 'f', '7', 'f', '8', 'f', '9', 'f', 'a', 'f', 'b', 'f', 'c',
8562 'f', 'd', 'f', 'e', 'f', 'f'};
8663
87template <class _Tp>
88const uint32_t __table<_Tp>::__pow10_32[10] = {
64inline constexpr uint32_t __pow10_32[10] = {
8965 UINT32_C(0), UINT32_C(10), UINT32_C(100), UINT32_C(1000), UINT32_C(10000),
9066 UINT32_C(100000), UINT32_C(1000000), UINT32_C(10000000), UINT32_C(100000000), UINT32_C(1000000000)};
9167
92template <class _Tp>
93const uint64_t __table<_Tp>::__pow10_64[20] = {UINT64_C(0),
68inline constexpr uint64_t __pow10_64[20] = {UINT64_C(0),
9469 UINT64_C(10),
9570 UINT64_C(100),
9671 UINT64_C(1000),
......@@ -112,8 +87,8 @@ const uint64_t __table<_Tp>::__pow10_64[20] = {UINT64_C(0),
11287 UINT64_C(10000000000000000000)};
11388
11489# ifndef _LIBCPP_HAS_NO_INT128
115template <class _Tp>
116const __uint128_t __table<_Tp>::__pow10_128[40] = {
90inline constexpr int __pow10_128_offset = 0;
91inline constexpr __uint128_t __pow10_128[40] = {
11792 UINT64_C(0),
11893 UINT64_C(10),
11994 UINT64_C(100),
......@@ -156,8 +131,7 @@ const __uint128_t __table<_Tp>::__pow10_128[40] = {
156131 (__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000000)) * 10};
157132# endif
158133
159template <class _Tp>
160const char __table<_Tp>::__digits_base_10[200] = {
134inline constexpr char __digits_base_10[200] = {
161135 // clang-format off
162136 '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9',
163137 '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '1', '8', '1', '9',
......@@ -173,7 +147,7 @@ const char __table<_Tp>::__digits_base_10[200] = {
173147
174148} // namespace __itoa
175149
176#endif // _LIBCPP_CXX03_LANG
150#endif // _LIBCPP_STD_VER > 14
177151
178152_LIBCPP_END_NAMESPACE_STD
179153
lib/libcxx/include/__charconv/to_chars_base_10.h+19-19
......@@ -25,54 +25,54 @@ _LIBCPP_PUSH_MACROS
2525
2626_LIBCPP_BEGIN_NAMESPACE_STD
2727
28#ifndef _LIBCPP_CXX03_LANG
28#if _LIBCPP_STD_VER > 14
2929
3030namespace __itoa {
3131
32_LIBCPP_HIDE_FROM_ABI inline char* __append1(char* __first, uint32_t __value) noexcept {
32_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append1(char* __first, uint32_t __value) noexcept {
3333 *__first = '0' + static_cast<char>(__value);
3434 return __first + 1;
3535}
3636
37_LIBCPP_HIDE_FROM_ABI inline char* __append2(char* __first, uint32_t __value) noexcept {
38 return std::copy_n(&__table<>::__digits_base_10[__value * 2], 2, __first);
37_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append2(char* __first, uint32_t __value) noexcept {
38 return std::copy_n(&__digits_base_10[__value * 2], 2, __first);
3939}
4040
41_LIBCPP_HIDE_FROM_ABI inline char* __append3(char* __first, uint32_t __value) noexcept {
41_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append3(char* __first, uint32_t __value) noexcept {
4242 return __itoa::__append2(__itoa::__append1(__first, __value / 100), __value % 100);
4343}
4444
45_LIBCPP_HIDE_FROM_ABI inline char* __append4(char* __first, uint32_t __value) noexcept {
45_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append4(char* __first, uint32_t __value) noexcept {
4646 return __itoa::__append2(__itoa::__append2(__first, __value / 100), __value % 100);
4747}
4848
49_LIBCPP_HIDE_FROM_ABI inline char* __append5(char* __first, uint32_t __value) noexcept {
49_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append5(char* __first, uint32_t __value) noexcept {
5050 return __itoa::__append4(__itoa::__append1(__first, __value / 10000), __value % 10000);
5151}
5252
53_LIBCPP_HIDE_FROM_ABI inline char* __append6(char* __first, uint32_t __value) noexcept {
53_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append6(char* __first, uint32_t __value) noexcept {
5454 return __itoa::__append4(__itoa::__append2(__first, __value / 10000), __value % 10000);
5555}
5656
57_LIBCPP_HIDE_FROM_ABI inline char* __append7(char* __first, uint32_t __value) noexcept {
57_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append7(char* __first, uint32_t __value) noexcept {
5858 return __itoa::__append6(__itoa::__append1(__first, __value / 1000000), __value % 1000000);
5959}
6060
61_LIBCPP_HIDE_FROM_ABI inline char* __append8(char* __first, uint32_t __value) noexcept {
61_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append8(char* __first, uint32_t __value) noexcept {
6262 return __itoa::__append6(__itoa::__append2(__first, __value / 1000000), __value % 1000000);
6363}
6464
65_LIBCPP_HIDE_FROM_ABI inline char* __append9(char* __first, uint32_t __value) noexcept {
65_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append9(char* __first, uint32_t __value) noexcept {
6666 return __itoa::__append8(__itoa::__append1(__first, __value / 100000000), __value % 100000000);
6767}
6868
6969template <class _Tp>
70_LIBCPP_HIDE_FROM_ABI char* __append10(char* __first, _Tp __value) noexcept {
70_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI char* __append10(char* __first, _Tp __value) noexcept {
7171 return __itoa::__append8(__itoa::__append2(__first, static_cast<uint32_t>(__value / 100000000)),
7272 static_cast<uint32_t>(__value % 100000000));
7373}
7474
75_LIBCPP_HIDE_FROM_ABI inline char* __base_10_u32(char* __first, uint32_t __value) noexcept {
75_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __base_10_u32(char* __first, uint32_t __value) noexcept {
7676 if (__value < 1000000) {
7777 if (__value < 10000) {
7878 if (__value < 100) {
......@@ -107,7 +107,7 @@ _LIBCPP_HIDE_FROM_ABI inline char* __base_10_u32(char* __first, uint32_t __value
107107 return __itoa::__append10(__first, __value);
108108}
109109
110_LIBCPP_HIDE_FROM_ABI inline char* __base_10_u64(char* __buffer, uint64_t __value) noexcept {
110_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __base_10_u64(char* __buffer, uint64_t __value) noexcept {
111111 if (__value <= UINT32_MAX)
112112 return __itoa::__base_10_u32(__buffer, static_cast<uint32_t>(__value));
113113
......@@ -129,12 +129,12 @@ _LIBCPP_HIDE_FROM_ABI inline char* __base_10_u64(char* __buffer, uint64_t __valu
129129/// \note The lookup table contains a partial set of exponents limiting the
130130/// range that can be used. However the range is sufficient for
131131/// \ref __base_10_u128.
132_LIBCPP_HIDE_FROM_ABI inline __uint128_t __pow_10(int __exp) noexcept {
133 _LIBCPP_ASSERT(__exp >= __table<>::__pow10_128_offset, "Index out of bounds");
134 return __table<>::__pow10_128[__exp - __table<>::__pow10_128_offset];
132_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline __uint128_t __pow_10(int __exp) noexcept {
133 _LIBCPP_ASSERT(__exp >= __pow10_128_offset, "Index out of bounds");
134 return __pow10_128[__exp - __pow10_128_offset];
135135}
136136
137_LIBCPP_HIDE_FROM_ABI inline char* __base_10_u128(char* __buffer, __uint128_t __value) noexcept {
137_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __base_10_u128(char* __buffer, __uint128_t __value) noexcept {
138138 _LIBCPP_ASSERT(
139139 __value > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fail when this isn't true.");
140140
......@@ -176,7 +176,7 @@ _LIBCPP_HIDE_FROM_ABI inline char* __base_10_u128(char* __buffer, __uint128_t __
176176# endif
177177} // namespace __itoa
178178
179#endif // _LIBCPP_CXX03_LANG
179#endif // _LIBCPP_STD_VER > 14
180180
181181_LIBCPP_END_NAMESPACE_STD
182182
lib/libcxx/include/__charconv/to_chars_result.h+2-2
......@@ -19,7 +19,7 @@
1919
2020_LIBCPP_BEGIN_NAMESPACE_STD
2121
22#ifndef _LIBCPP_CXX03_LANG
22#if _LIBCPP_STD_VER > 14
2323
2424struct _LIBCPP_TYPE_VIS to_chars_result
2525{
......@@ -30,7 +30,7 @@ struct _LIBCPP_TYPE_VIS to_chars_result
3030# endif
3131};
3232
33#endif // _LIBCPP_CXX03_LANG
33#endif // _LIBCPP_STD_VER > 14
3434
3535_LIBCPP_END_NAMESPACE_STD
3636
lib/libcxx/include/__chrono/convert_to_timespec.h+1
......@@ -6,6 +6,7 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___CHRONO_CONVERT_TO_TIMESPEC_H
1011#define _LIBCPP___CHRONO_CONVERT_TO_TIMESPEC_H
1112
lib/libcxx/include/__chrono/convert_to_tm.h created+127
......@@ -0,0 +1,127 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___CHRONO_CONVERT_TO_TM_H
11#define _LIBCPP___CHRONO_CONVERT_TO_TM_H
12
13#include <__chrono/day.h>
14#include <__chrono/duration.h>
15#include <__chrono/hh_mm_ss.h>
16#include <__chrono/month.h>
17#include <__chrono/month_weekday.h>
18#include <__chrono/monthday.h>
19#include <__chrono/statically_widen.h>
20#include <__chrono/system_clock.h>
21#include <__chrono/time_point.h>
22#include <__chrono/weekday.h>
23#include <__chrono/year.h>
24#include <__chrono/year_month.h>
25#include <__chrono/year_month_day.h>
26#include <__chrono/year_month_weekday.h>
27#include <__concepts/same_as.h>
28#include <__config>
29#include <__memory/addressof.h>
30#include <cstdint>
31#include <ctime>
32
33#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
34# pragma GCC system_header
35#endif
36
37_LIBCPP_BEGIN_NAMESPACE_STD
38
39#if _LIBCPP_STD_VER > 17
40
41// Conerts a chrono date and weekday to a given _Tm type.
42//
43// This is an implementation detail for the function
44// template <class _Tm, class _ChronoT>
45// _Tm __convert_to_tm(const _ChronoT& __value)
46//
47// This manually converts the two values to the proper type. It is possible to
48// convert from sys_days to time_t and then to _Tm. But this leads to the Y2K
49// bug when time_t is a 32-bit signed integer. Chrono considers years beyond
50// the year 2038 valid, so instead do the transformation manually.
51template <class _Tm, class _Date>
52 requires(same_as<_Date, chrono::year_month_day> || same_as<_Date, chrono::year_month_day_last>)
53_LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _Date& __date, chrono::weekday __weekday) {
54 _Tm __result = {};
55# ifdef __GLIBC__
56 __result.tm_zone = "UTC";
57# endif
58 __result.tm_year = static_cast<int>(__date.year()) - 1900;
59 __result.tm_mon = static_cast<unsigned>(__date.month()) - 1;
60 __result.tm_mday = static_cast<unsigned>(__date.day());
61 __result.tm_wday = static_cast<unsigned>(__weekday.c_encoding());
62 __result.tm_yday =
63 (static_cast<chrono::sys_days>(__date) -
64 static_cast<chrono::sys_days>(chrono::year_month_day{__date.year(), chrono::January, chrono::day{1}}))
65 .count();
66
67 return __result;
68}
69
70// Convert a chrono (calendar) time point, or dururation to the given _Tm type,
71// which must have the same properties as std::tm.
72template <class _Tm, class _ChronoT>
73_LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& __value) {
74 _Tm __result = {};
75# ifdef __GLIBC__
76 __result.tm_zone = "UTC";
77# endif
78
79 if constexpr (chrono::__is_duration<_ChronoT>::value) {
80 // [time.format]/6
81 // ... However, if a flag refers to a "time of day" (e.g. %H, %I, %p,
82 // etc.), then a specialization of duration is interpreted as the time of
83 // day elapsed since midnight.
84 uint64_t __sec = chrono::duration_cast<chrono::seconds>(__value).count();
85 __sec %= 24 * 3600;
86 __result.tm_hour = __sec / 3600;
87 __sec %= 3600;
88 __result.tm_min = __sec / 60;
89 __result.tm_sec = __sec % 60;
90 } else if constexpr (same_as<_ChronoT, chrono::day>)
91 __result.tm_mday = static_cast<unsigned>(__value);
92 else if constexpr (same_as<_ChronoT, chrono::month>)
93 __result.tm_mon = static_cast<unsigned>(__value) - 1;
94 else if constexpr (same_as<_ChronoT, chrono::year>)
95 __result.tm_year = static_cast<int>(__value) - 1900;
96 else if constexpr (same_as<_ChronoT, chrono::weekday>)
97 __result.tm_wday = __value.c_encoding();
98 else if constexpr (same_as<_ChronoT, chrono::weekday_indexed> || same_as<_ChronoT, chrono::weekday_last>)
99 __result.tm_wday = __value.weekday().c_encoding();
100 else if constexpr (same_as<_ChronoT, chrono::month_day>) {
101 __result.tm_mday = static_cast<unsigned>(__value.day());
102 __result.tm_mon = static_cast<unsigned>(__value.month()) - 1;
103 } else if constexpr (same_as<_ChronoT, chrono::month_day_last>) {
104 __result.tm_mon = static_cast<unsigned>(__value.month()) - 1;
105 } else if constexpr (same_as<_ChronoT, chrono::month_weekday> || same_as<_ChronoT, chrono::month_weekday_last>) {
106 __result.tm_wday = __value.weekday_indexed().weekday().c_encoding();
107 __result.tm_mon = static_cast<unsigned>(__value.month()) - 1;
108 } else if constexpr (same_as<_ChronoT, chrono::year_month>) {
109 __result.tm_year = static_cast<int>(__value.year()) - 1900;
110 __result.tm_mon = static_cast<unsigned>(__value.month()) - 1;
111 } else if constexpr (same_as<_ChronoT, chrono::year_month_day> || same_as<_ChronoT, chrono::year_month_day_last>) {
112 return std::__convert_to_tm<_Tm>(
113 chrono::year_month_day{__value}, chrono::weekday{static_cast<chrono::sys_days>(__value)});
114 } else if constexpr (same_as<_ChronoT, chrono::year_month_weekday> ||
115 same_as<_ChronoT, chrono::year_month_weekday_last>) {
116 return std::__convert_to_tm<_Tm>(chrono::year_month_day{static_cast<chrono::sys_days>(__value)}, __value.weekday());
117 } else
118 static_assert(sizeof(_ChronoT) == 0, "Add the missing type specialization");
119
120 return __result;
121}
122
123#endif //if _LIBCPP_STD_VER > 17
124
125_LIBCPP_END_NAMESPACE_STD
126
127#endif // _LIBCPP___CHRONO_CONVERT_TO_TM_H
lib/libcxx/include/__chrono/day.h+6-6
......@@ -27,18 +27,18 @@ namespace chrono
2727
2828class day {
2929private:
30 unsigned char __d;
30 unsigned char __d_;
3131public:
3232 _LIBCPP_HIDE_FROM_ABI day() = default;
33 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr day(unsigned __val) noexcept : __d(static_cast<unsigned char>(__val)) {}
34 _LIBCPP_HIDE_FROM_ABI inline constexpr day& operator++() noexcept { ++__d; return *this; }
33 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr day(unsigned __val) noexcept : __d_(static_cast<unsigned char>(__val)) {}
34 _LIBCPP_HIDE_FROM_ABI inline constexpr day& operator++() noexcept { ++__d_; return *this; }
3535 _LIBCPP_HIDE_FROM_ABI inline constexpr day operator++(int) noexcept { day __tmp = *this; ++(*this); return __tmp; }
36 _LIBCPP_HIDE_FROM_ABI inline constexpr day& operator--() noexcept { --__d; return *this; }
36 _LIBCPP_HIDE_FROM_ABI inline constexpr day& operator--() noexcept { --__d_; return *this; }
3737 _LIBCPP_HIDE_FROM_ABI inline constexpr day operator--(int) noexcept { day __tmp = *this; --(*this); return __tmp; }
3838 _LIBCPP_HIDE_FROM_ABI constexpr day& operator+=(const days& __dd) noexcept;
3939 _LIBCPP_HIDE_FROM_ABI constexpr day& operator-=(const days& __dd) noexcept;
40 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator unsigned() const noexcept { return __d; }
41 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __d >= 1 && __d <= 31; }
40 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator unsigned() const noexcept { return __d_; }
41 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __d_ >= 1 && __d_ <= 31; }
4242 };
4343
4444
lib/libcxx/include/__chrono/duration.h+33-26
......@@ -11,9 +11,12 @@
1111#define _LIBCPP___CHRONO_DURATION_H
1212
1313#include <__config>
14#include <__type_traits/common_type.h>
15#include <__type_traits/enable_if.h>
16#include <__type_traits/is_convertible.h>
17#include <__type_traits/is_floating_point.h>
1418#include <limits>
1519#include <ratio>
16#include <type_traits>
1720
1821#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1922# pragma GCC system_header
......@@ -151,7 +154,7 @@ typename enable_if
151154>::type
152155floor(const duration<_Rep, _Period>& __d)
153156{
154 _ToDuration __t = duration_cast<_ToDuration>(__d);
157 _ToDuration __t = chrono::duration_cast<_ToDuration>(__d);
155158 if (__t > __d)
156159 __t = __t - _ToDuration{1};
157160 return __t;
......@@ -166,7 +169,7 @@ typename enable_if
166169>::type
167170ceil(const duration<_Rep, _Period>& __d)
168171{
169 _ToDuration __t = duration_cast<_ToDuration>(__d);
172 _ToDuration __t = chrono::duration_cast<_ToDuration>(__d);
170173 if (__t < __d)
171174 __t = __t + _ToDuration{1};
172175 return __t;
......@@ -181,7 +184,7 @@ typename enable_if
181184>::type
182185round(const duration<_Rep, _Period>& __d)
183186{
184 _ToDuration __lower = floor<_ToDuration>(__d);
187 _ToDuration __lower = chrono::floor<_ToDuration>(__d);
185188 _ToDuration __upper = __lower + _ToDuration{1};
186189 auto __lowerDiff = __d - __lower;
187190 auto __upperDiff = __upper - __d;
......@@ -278,18 +281,18 @@ public:
278281
279282 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator+() const {return typename common_type<duration>::type(*this);}
280283 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator-() const {return typename common_type<duration>::type(-__rep_);}
281 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator++() {++__rep_; return *this;}
282 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration operator++(int) {return duration(__rep_++);}
283 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator--() {--__rep_; return *this;}
284 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration operator--(int) {return duration(__rep_--);}
284 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator++() {++__rep_; return *this;}
285 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration operator++(int) {return duration(__rep_++);}
286 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator--() {--__rep_; return *this;}
287 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration operator--(int) {return duration(__rep_--);}
285288
286 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;}
287 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;}
289 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;}
290 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;}
288291
289 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator*=(const rep& __rhs) {__rep_ *= __rhs; return *this;}
290 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator/=(const rep& __rhs) {__rep_ /= __rhs; return *this;}
291 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const rep& __rhs) {__rep_ %= __rhs; return *this;}
292 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const duration& __rhs) {__rep_ %= __rhs.count(); return *this;}
292 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator*=(const rep& __rhs) {__rep_ *= __rhs; return *this;}
293 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator/=(const rep& __rhs) {__rep_ /= __rhs; return *this;}
294 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator%=(const rep& __rhs) {__rep_ %= __rhs; return *this;}
295 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator%=(const duration& __rhs) {__rep_ %= __rhs.count(); return *this;}
293296
294297 // special values
295298
......@@ -534,67 +537,67 @@ inline namespace literals
534537 inline namespace chrono_literals
535538 {
536539
537 constexpr chrono::hours operator""h(unsigned long long __h)
540 _LIBCPP_HIDE_FROM_ABI constexpr chrono::hours operator""h(unsigned long long __h)
538541 {
539542 return chrono::hours(static_cast<chrono::hours::rep>(__h));
540543 }
541544
542 constexpr chrono::duration<long double, ratio<3600,1>> operator""h(long double __h)
545 _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, ratio<3600,1>> operator""h(long double __h)
543546 {
544547 return chrono::duration<long double, ratio<3600,1>>(__h);
545548 }
546549
547550
548 constexpr chrono::minutes operator""min(unsigned long long __m)
551 _LIBCPP_HIDE_FROM_ABI constexpr chrono::minutes operator""min(unsigned long long __m)
549552 {
550553 return chrono::minutes(static_cast<chrono::minutes::rep>(__m));
551554 }
552555
553 constexpr chrono::duration<long double, ratio<60,1>> operator""min(long double __m)
556 _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, ratio<60,1>> operator""min(long double __m)
554557 {
555558 return chrono::duration<long double, ratio<60,1>> (__m);
556559 }
557560
558561
559 constexpr chrono::seconds operator""s(unsigned long long __s)
562 _LIBCPP_HIDE_FROM_ABI constexpr chrono::seconds operator""s(unsigned long long __s)
560563 {
561564 return chrono::seconds(static_cast<chrono::seconds::rep>(__s));
562565 }
563566
564 constexpr chrono::duration<long double> operator""s(long double __s)
567 _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double> operator""s(long double __s)
565568 {
566569 return chrono::duration<long double> (__s);
567570 }
568571
569572
570 constexpr chrono::milliseconds operator""ms(unsigned long long __ms)
573 _LIBCPP_HIDE_FROM_ABI constexpr chrono::milliseconds operator""ms(unsigned long long __ms)
571574 {
572575 return chrono::milliseconds(static_cast<chrono::milliseconds::rep>(__ms));
573576 }
574577
575 constexpr chrono::duration<long double, milli> operator""ms(long double __ms)
578 _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, milli> operator""ms(long double __ms)
576579 {
577580 return chrono::duration<long double, milli>(__ms);
578581 }
579582
580583
581 constexpr chrono::microseconds operator""us(unsigned long long __us)
584 _LIBCPP_HIDE_FROM_ABI constexpr chrono::microseconds operator""us(unsigned long long __us)
582585 {
583586 return chrono::microseconds(static_cast<chrono::microseconds::rep>(__us));
584587 }
585588
586 constexpr chrono::duration<long double, micro> operator""us(long double __us)
589 _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, micro> operator""us(long double __us)
587590 {
588591 return chrono::duration<long double, micro> (__us);
589592 }
590593
591594
592 constexpr chrono::nanoseconds operator""ns(unsigned long long __ns)
595 _LIBCPP_HIDE_FROM_ABI constexpr chrono::nanoseconds operator""ns(unsigned long long __ns)
593596 {
594597 return chrono::nanoseconds(static_cast<chrono::nanoseconds::rep>(__ns));
595598 }
596599
597 constexpr chrono::duration<long double, nano> operator""ns(long double __ns)
600 _LIBCPP_HIDE_FROM_ABI constexpr chrono::duration<long double, nano> operator""ns(long double __ns)
598601 {
599602 return chrono::duration<long double, nano> (__ns);
600603 }
......@@ -612,4 +615,8 @@ _LIBCPP_END_NAMESPACE_STD
612615
613616_LIBCPP_POP_MACROS
614617
618#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
619# include <type_traits>
620#endif
621
615622#endif // _LIBCPP___CHRONO_DURATION_H
lib/libcxx/include/__chrono/file_clock.h+1-1
......@@ -61,7 +61,7 @@ struct _FilesystemClock {
6161 typedef chrono::time_point<_FilesystemClock> time_point;
6262
6363 _LIBCPP_EXPORTED_FROM_ABI
64 static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false;
64 static _LIBCPP_CONSTEXPR_SINCE_CXX14 const bool is_steady = false;
6565
6666 _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_FUNC_VIS static time_point now() noexcept;
6767
lib/libcxx/include/__chrono/formatter.h created+716
......@@ -0,0 +1,716 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___CHRONO_FORMATTER_H
11#define _LIBCPP___CHRONO_FORMATTER_H
12
13#include <__chrono/calendar.h>
14#include <__chrono/convert_to_tm.h>
15#include <__chrono/day.h>
16#include <__chrono/duration.h>
17#include <__chrono/hh_mm_ss.h>
18#include <__chrono/month.h>
19#include <__chrono/month_weekday.h>
20#include <__chrono/monthday.h>
21#include <__chrono/ostream.h>
22#include <__chrono/parser_std_format_spec.h>
23#include <__chrono/statically_widen.h>
24#include <__chrono/time_point.h>
25#include <__chrono/weekday.h>
26#include <__chrono/year.h>
27#include <__chrono/year_month.h>
28#include <__chrono/year_month_day.h>
29#include <__chrono/year_month_weekday.h>
30#include <__concepts/arithmetic.h>
31#include <__concepts/same_as.h>
32#include <__config>
33#include <__format/concepts.h>
34#include <__format/format_error.h>
35#include <__format/format_functions.h>
36#include <__format/format_parse_context.h>
37#include <__format/formatter.h>
38#include <__format/formatter_output.h>
39#include <__format/parser_std_format_spec.h>
40#include <__memory/addressof.h>
41#include <cmath>
42#include <ctime>
43#include <sstream>
44#include <string>
45#include <string_view>
46
47#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
48# pragma GCC system_header
49#endif
50
51_LIBCPP_BEGIN_NAMESPACE_STD
52
53#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
54
55namespace __formatter {
56
57/// Formats a time based on a tm struct.
58///
59/// This formatter passes the formatting to time_put which uses strftime. When
60/// the value is outside the valid range it's unspecified what strftime will
61/// output. For example weekday 8 can print 1 when the day is processed modulo
62/// 7 since that handles the Sunday for 0-based weekday. It can also print 8 if
63/// 7 is handled as a special case.
64///
65/// The Standard doesn't specify what to do in this case so the result depends
66/// on the result of the underlying code.
67///
68/// \pre When the (abbreviated) weekday or month name are used, the caller
69/// validates whether the value is valid. So the caller handles that
70/// requirement of Table 97: Meaning of conversion specifiers
71/// [tab:time.format.spec].
72///
73/// When no chrono-specs are provided it uses the stream formatter.
74
75// For tiny ratios it's not possible to convert a duration to a hh_mm_ss. This
76// fails compile-time due to the limited precision of the ratio (64-bit is too
77// small). Therefore a duration uses its own conversion.
78template <class _CharT, class _Tp>
79 requires(chrono::__is_duration<_Tp>::value)
80_LIBCPP_HIDE_FROM_ABI void __format_sub_seconds(const _Tp& __value, basic_stringstream<_CharT>& __sstr) {
81 __sstr << std::use_facet<numpunct<_CharT>>(__sstr.getloc()).decimal_point();
82
83 auto __fraction = __value - chrono::duration_cast<chrono::seconds>(__value);
84 if constexpr (chrono::treat_as_floating_point_v<typename _Tp::rep>)
85 // When the floating-point value has digits itself they are ignored based
86 // on the wording in [tab:time.format.spec]
87 // If the precision of the input cannot be exactly represented with
88 // seconds, then the format is a decimal floating-point number with a
89 // fixed format and a precision matching that of the precision of the
90 // input (or to a microseconds precision if the conversion to
91 // floating-point decimal seconds cannot be made within 18 fractional
92 // digits).
93 //
94 // This matches the behaviour of MSVC STL, fmtlib interprets this
95 // differently and uses 3 decimals.
96 // https://godbolt.org/z/6dsbnW8ba
97 std::format_to(std::ostreambuf_iterator<_CharT>{__sstr},
98 _LIBCPP_STATICALLY_WIDEN(_CharT, "{:0{}.0f}"),
99 __fraction.count(),
100 chrono::hh_mm_ss<_Tp>::fractional_width);
101 else
102 std::format_to(std::ostreambuf_iterator<_CharT>{__sstr},
103 _LIBCPP_STATICALLY_WIDEN(_CharT, "{:0{}}"),
104 __fraction.count(),
105 chrono::hh_mm_ss<_Tp>::fractional_width);
106}
107
108template <class _Tp>
109consteval bool __use_fraction() {
110 if constexpr (chrono::__is_duration<_Tp>::value)
111 return chrono::hh_mm_ss<_Tp>::fractional_width;
112 else
113 return false;
114}
115
116template <class _CharT>
117_LIBCPP_HIDE_FROM_ABI void __format_year(int __year, basic_stringstream<_CharT>& __sstr) {
118 if (__year < 0) {
119 __sstr << _CharT('-');
120 __year = -__year;
121 }
122
123 // TODO FMT Write an issue
124 // If the result has less than four digits it is zero-padded with 0 to two digits.
125 // is less -> has less
126 // left-padded -> zero-padded, otherwise the proper value would be 000-0.
127
128 // Note according to the wording it should be left padded, which is odd.
129 __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:04}"), __year);
130}
131
132template <class _CharT>
133_LIBCPP_HIDE_FROM_ABI void __format_century(int __year, basic_stringstream<_CharT>& __sstr) {
134 // TODO FMT Write an issue
135 // [tab:time.format.spec]
136 // %C The year divided by 100 using floored division. If the result is a
137 // single decimal digit, it is prefixed with 0.
138
139 bool __negative = __year < 0;
140 int __century = (__year - (99 * __negative)) / 100; // floored division
141 __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), __century);
142}
143
144template <class _CharT, class _Tp>
145_LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
146 const _Tp& __value, basic_stringstream<_CharT>& __sstr, basic_string_view<_CharT> __chrono_specs) {
147 tm __t = std::__convert_to_tm<tm>(__value);
148 const auto& __facet = std::use_facet<time_put<_CharT>>(__sstr.getloc());
149 for (auto __it = __chrono_specs.begin(); __it != __chrono_specs.end(); ++__it) {
150 if (*__it == _CharT('%')) {
151 auto __s = __it;
152 ++__it;
153 // We only handle the types that can't be directly handled by time_put.
154 // (as an optimization n, t, and % are also handled directly.)
155 switch (*__it) {
156 case _CharT('n'):
157 __sstr << _CharT('\n');
158 break;
159 case _CharT('t'):
160 __sstr << _CharT('\t');
161 break;
162 case _CharT('%'):
163 __sstr << *__it;
164 break;
165
166 case _CharT('C'): {
167 // strftime's output is only defined in the range [00, 99].
168 int __year = __t.tm_year + 1900;
169 if (__year < 1000 || __year > 9999)
170 __formatter::__format_century(__year, __sstr);
171 else
172 __facet.put({__sstr}, __sstr, _CharT(' '), std::addressof(__t), __s, __it + 1);
173 } break;
174
175 case _CharT('j'):
176 if constexpr (chrono::__is_duration<_Tp>::value)
177 // Converting a duration where the period has a small ratio to days
178 // may fail to compile. This due to loss of precision in the
179 // conversion. In order to avoid that issue convert to seconds as
180 // an intemediate step.
181 __sstr << chrono::duration_cast<chrono::days>(chrono::duration_cast<chrono::seconds>(__value)).count();
182 else
183 __facet.put({__sstr}, __sstr, _CharT(' '), std::addressof(__t), __s, __it + 1);
184 break;
185
186 case _CharT('q'):
187 if constexpr (chrono::__is_duration<_Tp>::value) {
188 __sstr << chrono::__units_suffix<_CharT, typename _Tp::period>();
189 break;
190 }
191 __builtin_unreachable();
192
193 case _CharT('Q'):
194 // TODO FMT Determine the proper ideas
195 // - Should it honour the precision?
196 // - Shoult it honour the locale setting for the separators?
197 // The wording for Q doesn't use the word locale and the effect of
198 // precision is unspecified.
199 //
200 // MSVC STL ignores precision but uses separator
201 // FMT honours precision and has a bug for separator
202 // https://godbolt.org/z/78b7sMxns
203 if constexpr (chrono::__is_duration<_Tp>::value) {
204 __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{}"), __value.count());
205 break;
206 }
207 __builtin_unreachable();
208
209 case _CharT('S'):
210 case _CharT('T'):
211 __facet.put({__sstr}, __sstr, _CharT(' '), std::addressof(__t), __s, __it + 1);
212 if constexpr (__use_fraction<_Tp>())
213 __formatter::__format_sub_seconds(__value, __sstr);
214 break;
215
216 // Unlike time_put and strftime the formatting library requires %Y
217 //
218 // [tab:time.format.spec]
219 // The year as a decimal number. If the result is less than four digits
220 // it is left-padded with 0 to four digits.
221 //
222 // This means years in the range (-1000, 1000) need manual formatting.
223 // It's unclear whether %EY needs the same treatment. For example the
224 // Japanese EY contains the era name and year. This is zero-padded to 2
225 // digits in time_put (note that older glibc versions didn't do
226 // padding.) However most eras won't reach 100 years, let alone 1000.
227 // So padding to 4 digits seems unwanted for Japanese.
228 //
229 // The same applies to %Ex since that too depends on the era.
230 //
231 // %x the locale's date representation is currently doesn't handle the
232 // zero-padding too.
233 //
234 // The 4 digits can be implemented better at a later time. On POSIX
235 // systems the required information can be extracted by nl_langinfo
236 // https://man7.org/linux/man-pages/man3/nl_langinfo.3.html
237 //
238 // Note since year < -1000 is expected to be rare it uses the more
239 // expensive year routine.
240 //
241 // TODO FMT evaluate the comment above.
242
243# if defined(__GLIBC__) || defined(_AIX)
244 case _CharT('y'):
245 // Glibc fails for negative values, AIX for positive values too.
246 __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), (std::abs(__t.tm_year + 1900)) % 100);
247 break;
248# endif // defined(__GLIBC__) || defined(_AIX)
249
250 case _CharT('Y'): {
251 int __year = __t.tm_year + 1900;
252 if (__year < 1000)
253 __formatter::__format_year(__year, __sstr);
254 else
255 __facet.put({__sstr}, __sstr, _CharT(' '), std::addressof(__t), __s, __it + 1);
256 } break;
257
258 case _CharT('F'): {
259 int __year = __t.tm_year + 1900;
260 if (__year < 1000) {
261 __formatter::__format_year(__year, __sstr);
262 __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "-{:02}-{:02}"), __t.tm_mon + 1, __t.tm_mday);
263 } else
264 __facet.put({__sstr}, __sstr, _CharT(' '), std::addressof(__t), __s, __it + 1);
265 } break;
266
267 case _CharT('O'):
268 if constexpr (__use_fraction<_Tp>()) {
269 // Handle OS using the normal representation for the non-fractional
270 // part. There seems to be no locale information regarding how the
271 // fractional part should be formatted.
272 if (*(__it + 1) == 'S') {
273 ++__it;
274 __facet.put({__sstr}, __sstr, _CharT(' '), std::addressof(__t), __s, __it + 1);
275 __formatter::__format_sub_seconds(__value, __sstr);
276 break;
277 }
278 }
279 [[fallthrough]];
280 case _CharT('E'):
281 ++__it;
282 [[fallthrough]];
283 default:
284 __facet.put({__sstr}, __sstr, _CharT(' '), std::addressof(__t), __s, __it + 1);
285 break;
286 }
287 } else {
288 __sstr << *__it;
289 }
290 }
291}
292
293template <class _Tp>
294_LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_ok(const _Tp& __value) {
295 if constexpr (same_as<_Tp, chrono::day>)
296 return true;
297 else if constexpr (same_as<_Tp, chrono::month>)
298 return __value.ok();
299 else if constexpr (same_as<_Tp, chrono::year>)
300 return true;
301 else if constexpr (same_as<_Tp, chrono::weekday>)
302 return true;
303 else if constexpr (same_as<_Tp, chrono::weekday_indexed>)
304 return true;
305 else if constexpr (same_as<_Tp, chrono::weekday_last>)
306 return true;
307 else if constexpr (same_as<_Tp, chrono::month_day>)
308 return true;
309 else if constexpr (same_as<_Tp, chrono::month_day_last>)
310 return true;
311 else if constexpr (same_as<_Tp, chrono::month_weekday>)
312 return true;
313 else if constexpr (same_as<_Tp, chrono::month_weekday_last>)
314 return true;
315 else if constexpr (same_as<_Tp, chrono::year_month>)
316 return true;
317 else if constexpr (same_as<_Tp, chrono::year_month_day>)
318 return __value.ok();
319 else if constexpr (same_as<_Tp, chrono::year_month_day_last>)
320 return __value.ok();
321 else if constexpr (same_as<_Tp, chrono::year_month_weekday>)
322 return __value.weekday().ok();
323 else if constexpr (same_as<_Tp, chrono::year_month_weekday_last>)
324 return __value.weekday().ok();
325 else
326 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
327}
328
329template <class _Tp>
330_LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_name_ok(const _Tp& __value) {
331 if constexpr (same_as<_Tp, chrono::day>)
332 return true;
333 else if constexpr (same_as<_Tp, chrono::month>)
334 return __value.ok();
335 else if constexpr (same_as<_Tp, chrono::year>)
336 return true;
337 else if constexpr (same_as<_Tp, chrono::weekday>)
338 return __value.ok();
339 else if constexpr (same_as<_Tp, chrono::weekday_indexed>)
340 return __value.weekday().ok();
341 else if constexpr (same_as<_Tp, chrono::weekday_last>)
342 return __value.weekday().ok();
343 else if constexpr (same_as<_Tp, chrono::month_day>)
344 return true;
345 else if constexpr (same_as<_Tp, chrono::month_day_last>)
346 return true;
347 else if constexpr (same_as<_Tp, chrono::month_weekday>)
348 return __value.weekday_indexed().ok();
349 else if constexpr (same_as<_Tp, chrono::month_weekday_last>)
350 return __value.weekday_indexed().ok();
351 else if constexpr (same_as<_Tp, chrono::year_month>)
352 return true;
353 else if constexpr (same_as<_Tp, chrono::year_month_day>)
354 return __value.ok();
355 else if constexpr (same_as<_Tp, chrono::year_month_day_last>)
356 return __value.ok();
357 else if constexpr (same_as<_Tp, chrono::year_month_weekday>)
358 return __value.weekday().ok();
359 else if constexpr (same_as<_Tp, chrono::year_month_weekday_last>)
360 return __value.weekday().ok();
361 else
362 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
363}
364
365template <class _Tp>
366_LIBCPP_HIDE_FROM_ABI constexpr bool __date_ok(const _Tp& __value) {
367 if constexpr (same_as<_Tp, chrono::day>)
368 return true;
369 else if constexpr (same_as<_Tp, chrono::month>)
370 return __value.ok();
371 else if constexpr (same_as<_Tp, chrono::year>)
372 return true;
373 else if constexpr (same_as<_Tp, chrono::weekday>)
374 return true;
375 else if constexpr (same_as<_Tp, chrono::weekday_indexed>)
376 return true;
377 else if constexpr (same_as<_Tp, chrono::weekday_last>)
378 return true;
379 else if constexpr (same_as<_Tp, chrono::month_day>)
380 return true;
381 else if constexpr (same_as<_Tp, chrono::month_day_last>)
382 return true;
383 else if constexpr (same_as<_Tp, chrono::month_weekday>)
384 return true;
385 else if constexpr (same_as<_Tp, chrono::month_weekday_last>)
386 return true;
387 else if constexpr (same_as<_Tp, chrono::year_month>)
388 return true;
389 else if constexpr (same_as<_Tp, chrono::year_month_day>)
390 return __value.ok();
391 else if constexpr (same_as<_Tp, chrono::year_month_day_last>)
392 return __value.ok();
393 else if constexpr (same_as<_Tp, chrono::year_month_weekday>)
394 return __value.ok();
395 else if constexpr (same_as<_Tp, chrono::year_month_weekday_last>)
396 return __value.ok();
397 else
398 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
399}
400
401template <class _Tp>
402_LIBCPP_HIDE_FROM_ABI constexpr bool __month_name_ok(const _Tp& __value) {
403 if constexpr (same_as<_Tp, chrono::day>)
404 return true;
405 else if constexpr (same_as<_Tp, chrono::month>)
406 return __value.ok();
407 else if constexpr (same_as<_Tp, chrono::year>)
408 return true;
409 else if constexpr (same_as<_Tp, chrono::weekday>)
410 return true;
411 else if constexpr (same_as<_Tp, chrono::weekday_indexed>)
412 return true;
413 else if constexpr (same_as<_Tp, chrono::weekday_last>)
414 return true;
415 else if constexpr (same_as<_Tp, chrono::month_day>)
416 return __value.month().ok();
417 else if constexpr (same_as<_Tp, chrono::month_day_last>)
418 return __value.month().ok();
419 else if constexpr (same_as<_Tp, chrono::month_weekday>)
420 return __value.month().ok();
421 else if constexpr (same_as<_Tp, chrono::month_weekday_last>)
422 return __value.month().ok();
423 else if constexpr (same_as<_Tp, chrono::year_month>)
424 return __value.month().ok();
425 else if constexpr (same_as<_Tp, chrono::year_month_day>)
426 return __value.month().ok();
427 else if constexpr (same_as<_Tp, chrono::year_month_day_last>)
428 return __value.month().ok();
429 else if constexpr (same_as<_Tp, chrono::year_month_weekday>)
430 return __value.month().ok();
431 else if constexpr (same_as<_Tp, chrono::year_month_weekday_last>)
432 return __value.month().ok();
433 else
434 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
435}
436
437template <class _CharT, class _Tp>
438_LIBCPP_HIDE_FROM_ABI auto
439__format_chrono(const _Tp& __value,
440 auto& __ctx,
441 __format_spec::__parsed_specifications<_CharT> __specs,
442 basic_string_view<_CharT> __chrono_specs) -> decltype(__ctx.out()) {
443 basic_stringstream<_CharT> __sstr;
444 // [time.format]/2
445 // 2.1 - the "C" locale if the L option is not present in chrono-format-spec, otherwise
446 // 2.2 - the locale passed to the formatting function if any, otherwise
447 // 2.3 - the global locale.
448 // Note that the __ctx's locale() call does 2.2 and 2.3.
449 if (__specs.__chrono_.__locale_specific_form_)
450 __sstr.imbue(__ctx.locale());
451 else
452 __sstr.imbue(locale::classic());
453
454 if (__chrono_specs.empty())
455 __sstr << __value;
456 else {
457 if constexpr (chrono::__is_duration<_Tp>::value) {
458 if (__value < __value.zero())
459 __sstr << _CharT('-');
460 __formatter::__format_chrono_using_chrono_specs(chrono::abs(__value), __sstr, __chrono_specs);
461 // TODO FMT When keeping the precision it will truncate the string.
462 // Note that the behaviour what the precision does isn't specified.
463 __specs.__precision_ = -1;
464 } else {
465 // Test __weekday_name_ before __weekday_ to give a better error.
466 if (__specs.__chrono_.__weekday_name_ && !__formatter::__weekday_name_ok(__value))
467 std::__throw_format_error("formatting a weekday name needs a valid weekday");
468
469 if (__specs.__chrono_.__weekday_ && !__formatter::__weekday_ok(__value))
470 std::__throw_format_error("formatting a weekday needs a valid weekday");
471
472 if (__specs.__chrono_.__day_of_year_ && !__formatter::__date_ok(__value))
473 std::__throw_format_error("formatting a day of year needs a valid date");
474
475 if (__specs.__chrono_.__week_of_year_ && !__formatter::__date_ok(__value))
476 std::__throw_format_error("formatting a week of year needs a valid date");
477
478 if (__specs.__chrono_.__month_name_ && !__formatter::__month_name_ok(__value))
479 std::__throw_format_error("formatting a month name from an invalid month number");
480
481 __formatter::__format_chrono_using_chrono_specs(__value, __sstr, __chrono_specs);
482 }
483 }
484
485 // TODO FMT Use the stringstream's view after P0408R7 has been implemented.
486 basic_string<_CharT> __str = __sstr.str();
487 return __formatter::__write_string(basic_string_view<_CharT>{__str}, __ctx.out(), __specs);
488}
489
490} // namespace __formatter
491
492template <__fmt_char_type _CharT>
493struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_chrono {
494public:
495 _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(
496 basic_format_parse_context<_CharT>& __parse_ctx, __format_spec::__fields __fields, __format_spec::__flags __flags)
497 -> decltype(__parse_ctx.begin()) {
498 return __parser_.__parse(__parse_ctx, __fields, __flags);
499 }
500
501 template <class _Tp>
502 _LIBCPP_HIDE_FROM_ABI auto format(const _Tp& __value, auto& __ctx) const -> decltype(__ctx.out()) const {
503 return __formatter::__format_chrono(
504 __value, __ctx, __parser_.__parser_.__get_parsed_chrono_specifications(__ctx), __parser_.__chrono_specs_);
505 }
506
507 __format_spec::__parser_chrono<_CharT> __parser_;
508};
509
510template <class _Rep, class _Period, __fmt_char_type _CharT>
511struct formatter<chrono::duration<_Rep, _Period>, _CharT> : public __formatter_chrono<_CharT> {
512public:
513 using _Base = __formatter_chrono<_CharT>;
514
515 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
516 -> decltype(__parse_ctx.begin()) {
517 // [time.format]/1
518 // Giving a precision specification in the chrono-format-spec is valid only
519 // for std::chrono::duration types where the representation type Rep is a
520 // floating-point type. For all other Rep types, an exception of type
521 // format_error is thrown if the chrono-format-spec contains a precision
522 // specification.
523 //
524 // Note this doesn't refer to chrono::treat_as_floating_point_v<_Rep>.
525 if constexpr (std::floating_point<_Rep>)
526 return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono_fractional, __format_spec::__flags::__duration);
527 else
528 return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__duration);
529 }
530};
531
532template <__fmt_char_type _CharT>
533struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::day, _CharT>
534 : public __formatter_chrono<_CharT> {
535public:
536 using _Base = __formatter_chrono<_CharT>;
537
538 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
539 -> decltype(__parse_ctx.begin()) {
540 return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__day);
541 }
542};
543
544template <__fmt_char_type _CharT>
545struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::month, _CharT>
546 : public __formatter_chrono<_CharT> {
547public:
548 using _Base = __formatter_chrono<_CharT>;
549
550 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
551 -> decltype(__parse_ctx.begin()) {
552 return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month);
553 }
554};
555
556template <__fmt_char_type _CharT>
557struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::year, _CharT>
558 : public __formatter_chrono<_CharT> {
559public:
560 using _Base = __formatter_chrono<_CharT>;
561
562 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
563 -> decltype(__parse_ctx.begin()) {
564 return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__year);
565 }
566};
567
568template <__fmt_char_type _CharT>
569struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::weekday, _CharT>
570 : public __formatter_chrono<_CharT> {
571public:
572 using _Base = __formatter_chrono<_CharT>;
573
574 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
575 -> decltype(__parse_ctx.begin()) {
576 return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__weekday);
577 }
578};
579
580template <__fmt_char_type _CharT>
581struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::weekday_indexed, _CharT>
582 : public __formatter_chrono<_CharT> {
583public:
584 using _Base = __formatter_chrono<_CharT>;
585
586 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
587 -> decltype(__parse_ctx.begin()) {
588 return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__weekday);
589 }
590};
591
592template <__fmt_char_type _CharT>
593struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::weekday_last, _CharT>
594 : public __formatter_chrono<_CharT> {
595public:
596 using _Base = __formatter_chrono<_CharT>;
597
598 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
599 -> decltype(__parse_ctx.begin()) {
600 return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__weekday);
601 }
602};
603
604template <__fmt_char_type _CharT>
605struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::month_day, _CharT>
606 : public __formatter_chrono<_CharT> {
607public:
608 using _Base = __formatter_chrono<_CharT>;
609
610 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
611 -> decltype(__parse_ctx.begin()) {
612 return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month_day);
613 }
614};
615
616template <__fmt_char_type _CharT>
617struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::month_day_last, _CharT>
618 : public __formatter_chrono<_CharT> {
619public:
620 using _Base = __formatter_chrono<_CharT>;
621
622 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
623 -> decltype(__parse_ctx.begin()) {
624 return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month);
625 }
626};
627
628template <__fmt_char_type _CharT>
629struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::month_weekday, _CharT>
630 : public __formatter_chrono<_CharT> {
631public:
632 using _Base = __formatter_chrono<_CharT>;
633
634 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
635 -> decltype(__parse_ctx.begin()) {
636 return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month_weekday);
637 }
638};
639
640template <__fmt_char_type _CharT>
641struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::month_weekday_last, _CharT>
642 : public __formatter_chrono<_CharT> {
643public:
644 using _Base = __formatter_chrono<_CharT>;
645
646 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
647 -> decltype(__parse_ctx.begin()) {
648 return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__month_weekday);
649 }
650};
651
652template <__fmt_char_type _CharT>
653struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::year_month, _CharT>
654 : public __formatter_chrono<_CharT> {
655public:
656 using _Base = __formatter_chrono<_CharT>;
657
658 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
659 -> decltype(__parse_ctx.begin()) {
660 return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__year_month);
661 }
662};
663
664template <__fmt_char_type _CharT>
665struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::year_month_day, _CharT>
666 : public __formatter_chrono<_CharT> {
667public:
668 using _Base = __formatter_chrono<_CharT>;
669
670 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
671 -> decltype(__parse_ctx.begin()) {
672 return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__date);
673 }
674};
675
676template <__fmt_char_type _CharT>
677struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::year_month_day_last, _CharT>
678 : public __formatter_chrono<_CharT> {
679public:
680 using _Base = __formatter_chrono<_CharT>;
681
682 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
683 -> decltype(__parse_ctx.begin()) {
684 return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__date);
685 }
686};
687
688template <__fmt_char_type _CharT>
689struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::year_month_weekday, _CharT>
690 : public __formatter_chrono<_CharT> {
691public:
692 using _Base = __formatter_chrono<_CharT>;
693
694 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
695 -> decltype(__parse_ctx.begin()) {
696 return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__date);
697 }
698};
699
700template <__fmt_char_type _CharT>
701struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<chrono::year_month_weekday_last, _CharT>
702 : public __formatter_chrono<_CharT> {
703public:
704 using _Base = __formatter_chrono<_CharT>;
705
706 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
707 -> decltype(__parse_ctx.begin()) {
708 return _Base::__parse(__parse_ctx, __format_spec::__fields_chrono, __format_spec::__flags::__date);
709 }
710};
711
712#endif // if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
713
714_LIBCPP_END_NAMESPACE_STD
715
716#endif // _LIBCPP___CHRONO_FORMATTER_H
lib/libcxx/include/__chrono/hh_mm_ss.h+17-17
......@@ -57,33 +57,33 @@ public:
5757 _LIBCPP_HIDE_FROM_ABI constexpr hh_mm_ss() noexcept : hh_mm_ss{_Duration::zero()} {}
5858
5959 _LIBCPP_HIDE_FROM_ABI constexpr explicit hh_mm_ss(_Duration __d) noexcept :
60 __is_neg(__d < _Duration(0)),
61 __h(duration_cast<chrono::hours> (abs(__d))),
62 __m(duration_cast<chrono::minutes>(abs(__d) - hours())),
63 __s(duration_cast<chrono::seconds>(abs(__d) - hours() - minutes())),
64 __f(duration_cast<precision> (abs(__d) - hours() - minutes() - seconds()))
60 __is_neg_(__d < _Duration(0)),
61 __h_(chrono::duration_cast<chrono::hours> (chrono::abs(__d))),
62 __m_(chrono::duration_cast<chrono::minutes>(chrono::abs(__d) - hours())),
63 __s_(chrono::duration_cast<chrono::seconds>(chrono::abs(__d) - hours() - minutes())),
64 __f_(chrono::duration_cast<precision> (chrono::abs(__d) - hours() - minutes() - seconds()))
6565 {}
6666
67 _LIBCPP_HIDE_FROM_ABI constexpr bool is_negative() const noexcept { return __is_neg; }
68 _LIBCPP_HIDE_FROM_ABI constexpr chrono::hours hours() const noexcept { return __h; }
69 _LIBCPP_HIDE_FROM_ABI constexpr chrono::minutes minutes() const noexcept { return __m; }
70 _LIBCPP_HIDE_FROM_ABI constexpr chrono::seconds seconds() const noexcept { return __s; }
71 _LIBCPP_HIDE_FROM_ABI constexpr precision subseconds() const noexcept { return __f; }
67 _LIBCPP_HIDE_FROM_ABI constexpr bool is_negative() const noexcept { return __is_neg_; }
68 _LIBCPP_HIDE_FROM_ABI constexpr chrono::hours hours() const noexcept { return __h_; }
69 _LIBCPP_HIDE_FROM_ABI constexpr chrono::minutes minutes() const noexcept { return __m_; }
70 _LIBCPP_HIDE_FROM_ABI constexpr chrono::seconds seconds() const noexcept { return __s_; }
71 _LIBCPP_HIDE_FROM_ABI constexpr precision subseconds() const noexcept { return __f_; }
7272
7373 _LIBCPP_HIDE_FROM_ABI constexpr precision to_duration() const noexcept
7474 {
75 auto __dur = __h + __m + __s + __f;
76 return __is_neg ? -__dur : __dur;
75 auto __dur = __h_ + __m_ + __s_ + __f_;
76 return __is_neg_ ? -__dur : __dur;
7777 }
7878
7979 _LIBCPP_HIDE_FROM_ABI constexpr explicit operator precision() const noexcept { return to_duration(); }
8080
8181private:
82 bool __is_neg;
83 chrono::hours __h;
84 chrono::minutes __m;
85 chrono::seconds __s;
86 precision __f;
82 bool __is_neg_;
83 chrono::hours __h_;
84 chrono::minutes __m_;
85 chrono::seconds __s_;
86 precision __f_;
8787};
8888
8989_LIBCPP_HIDE_FROM_ABI constexpr bool is_am(const hours& __h) noexcept { return __h >= hours( 0) && __h < hours(12); }
lib/libcxx/include/__chrono/month.h+10-25
......@@ -12,6 +12,7 @@
1212
1313#include <__chrono/duration.h>
1414#include <__config>
15#include <compare>
1516
1617#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1718# pragma GCC system_header
......@@ -26,18 +27,18 @@ namespace chrono
2627
2728class month {
2829private:
29 unsigned char __m;
30 unsigned char __m_;
3031public:
3132 _LIBCPP_HIDE_FROM_ABI month() = default;
32 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr month(unsigned __val) noexcept : __m(static_cast<unsigned char>(__val)) {}
33 _LIBCPP_HIDE_FROM_ABI inline constexpr month& operator++() noexcept { ++__m; return *this; }
33 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr month(unsigned __val) noexcept : __m_(static_cast<unsigned char>(__val)) {}
34 _LIBCPP_HIDE_FROM_ABI inline constexpr month& operator++() noexcept { ++__m_; return *this; }
3435 _LIBCPP_HIDE_FROM_ABI inline constexpr month operator++(int) noexcept { month __tmp = *this; ++(*this); return __tmp; }
35 _LIBCPP_HIDE_FROM_ABI inline constexpr month& operator--() noexcept { --__m; return *this; }
36 _LIBCPP_HIDE_FROM_ABI inline constexpr month& operator--() noexcept { --__m_; return *this; }
3637 _LIBCPP_HIDE_FROM_ABI inline constexpr month operator--(int) noexcept { month __tmp = *this; --(*this); return __tmp; }
3738 _LIBCPP_HIDE_FROM_ABI constexpr month& operator+=(const months& __m1) noexcept;
3839 _LIBCPP_HIDE_FROM_ABI constexpr month& operator-=(const months& __m1) noexcept;
39 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator unsigned() const noexcept { return __m; }
40 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m >= 1 && __m <= 12; }
40 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator unsigned() const noexcept { return __m_; }
41 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_ >= 1 && __m_ <= 12; }
4142};
4243
4344
......@@ -45,25 +46,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
4546bool operator==(const month& __lhs, const month& __rhs) noexcept
4647{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
4748
48_LIBCPP_HIDE_FROM_ABI inline constexpr
49bool operator!=(const month& __lhs, const month& __rhs) noexcept
50{ return !(__lhs == __rhs); }
51
52_LIBCPP_HIDE_FROM_ABI inline constexpr
53bool operator< (const month& __lhs, const month& __rhs) noexcept
54{ return static_cast<unsigned>(__lhs) < static_cast<unsigned>(__rhs); }
55
56_LIBCPP_HIDE_FROM_ABI inline constexpr
57bool operator> (const month& __lhs, const month& __rhs) noexcept
58{ return __rhs < __lhs; }
59
60_LIBCPP_HIDE_FROM_ABI inline constexpr
61bool operator<=(const month& __lhs, const month& __rhs) noexcept
62{ return !(__rhs < __lhs); }
63
64_LIBCPP_HIDE_FROM_ABI inline constexpr
65bool operator>=(const month& __lhs, const month& __rhs) noexcept
66{ return !(__lhs < __rhs); }
49_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const month& __lhs, const month& __rhs) noexcept {
50 return static_cast<unsigned>(__lhs) <=> static_cast<unsigned>(__rhs);
51}
6752
6853_LIBCPP_HIDE_FROM_ABI inline constexpr
6954month operator+ (const month& __lhs, const months& __rhs) noexcept
lib/libcxx/include/__chrono/month_weekday.h+12-12
......@@ -27,14 +27,14 @@ namespace chrono
2727
2828class month_weekday {
2929private:
30 chrono::month __m;
31 chrono::weekday_indexed __wdi;
30 chrono::month __m_;
31 chrono::weekday_indexed __wdi_;
3232public:
3333 _LIBCPP_HIDE_FROM_ABI constexpr month_weekday(const chrono::month& __mval, const chrono::weekday_indexed& __wdival) noexcept
34 : __m{__mval}, __wdi{__wdival} {}
35 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
36 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; }
37 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m.ok() && __wdi.ok(); }
34 : __m_{__mval}, __wdi_{__wdival} {}
35 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
36 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi_; }
37 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_.ok() && __wdi_.ok(); }
3838};
3939
4040_LIBCPP_HIDE_FROM_ABI inline constexpr
......@@ -63,14 +63,14 @@ month_weekday operator/(const weekday_indexed& __lhs, int __rhs) noexcept
6363
6464
6565class month_weekday_last {
66 chrono::month __m;
67 chrono::weekday_last __wdl;
66 chrono::month __m_;
67 chrono::weekday_last __wdl_;
6868 public:
6969 _LIBCPP_HIDE_FROM_ABI constexpr month_weekday_last(const chrono::month& __mval, const chrono::weekday_last& __wdlval) noexcept
70 : __m{__mval}, __wdl{__wdlval} {}
71 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
72 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; }
73 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m.ok() && __wdl.ok(); }
70 : __m_{__mval}, __wdl_{__wdlval} {}
71 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
72 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl_; }
73 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_.ok() && __wdl_.ok(); }
7474};
7575
7676_LIBCPP_HIDE_FROM_ABI inline constexpr
lib/libcxx/include/__chrono/monthday.h+22-53
......@@ -14,6 +14,7 @@
1414#include <__chrono/day.h>
1515#include <__chrono/month.h>
1616#include <__config>
17#include <compare>
1718
1819#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1920# pragma GCC system_header
......@@ -28,26 +29,26 @@ namespace chrono
2829
2930class month_day {
3031private:
31 chrono::month __m;
32 chrono::day __d;
32 chrono::month __m_;
33 chrono::day __d_;
3334public:
3435 _LIBCPP_HIDE_FROM_ABI month_day() = default;
3536 _LIBCPP_HIDE_FROM_ABI constexpr month_day(const chrono::month& __mval, const chrono::day& __dval) noexcept
36 : __m{__mval}, __d{__dval} {}
37 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
38 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::day day() const noexcept { return __d; }
37 : __m_{__mval}, __d_{__dval} {}
38 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
39 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::day day() const noexcept { return __d_; }
3940 _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept;
4041};
4142
4243_LIBCPP_HIDE_FROM_ABI inline constexpr
4344bool month_day::ok() const noexcept
4445{
45 if (!__m.ok()) return false;
46 const unsigned __dval = static_cast<unsigned>(__d);
46 if (!__m_.ok()) return false;
47 const unsigned __dval = static_cast<unsigned>(__d_);
4748 if (__dval < 1 || __dval > 31) return false;
4849 if (__dval <= 29) return true;
4950// Now we've got either 30 or 31
50 const unsigned __mval = static_cast<unsigned>(__m);
51 const unsigned __mval = static_cast<unsigned>(__m_);
5152 if (__mval == 2) return false;
5253 if (__mval == 4 || __mval == 6 || __mval == 9 || __mval == 11)
5354 return __dval == 30;
......@@ -58,9 +59,11 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
5859bool operator==(const month_day& __lhs, const month_day& __rhs) noexcept
5960{ return __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
6061
61_LIBCPP_HIDE_FROM_ABI inline constexpr
62bool operator!=(const month_day& __lhs, const month_day& __rhs) noexcept
63{ return !(__lhs == __rhs); }
62_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const month_day& __lhs, const month_day& __rhs) noexcept {
63 if (auto __c = __lhs.month() <=> __rhs.month(); __c != 0)
64 return __c;
65 return __lhs.day() <=> __rhs.day();
66}
6467
6568_LIBCPP_HIDE_FROM_ABI inline constexpr
6669month_day operator/(const month& __lhs, const day& __rhs) noexcept
......@@ -82,58 +85,24 @@ _LIBCPP_HIDE_FROM_ABI constexpr
8285month_day operator/(const day& __lhs, int __rhs) noexcept
8386{ return month(__rhs) / __lhs; }
8487
85
86_LIBCPP_HIDE_FROM_ABI inline constexpr
87bool operator< (const month_day& __lhs, const month_day& __rhs) noexcept
88{ return __lhs.month() != __rhs.month() ? __lhs.month() < __rhs.month() : __lhs.day() < __rhs.day(); }
89
90_LIBCPP_HIDE_FROM_ABI inline constexpr
91bool operator> (const month_day& __lhs, const month_day& __rhs) noexcept
92{ return __rhs < __lhs; }
93
94_LIBCPP_HIDE_FROM_ABI inline constexpr
95bool operator<=(const month_day& __lhs, const month_day& __rhs) noexcept
96{ return !(__rhs < __lhs);}
97
98_LIBCPP_HIDE_FROM_ABI inline constexpr
99bool operator>=(const month_day& __lhs, const month_day& __rhs) noexcept
100{ return !(__lhs < __rhs); }
101
102
103
10488class month_day_last {
10589private:
106 chrono::month __m;
90 chrono::month __m_;
10791public:
10892 _LIBCPP_HIDE_FROM_ABI explicit constexpr month_day_last(const chrono::month& __val) noexcept
109 : __m{__val} {}
110 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
111 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m.ok(); }
93 : __m_{__val} {}
94 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
95 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_.ok(); }
11296};
11397
11498_LIBCPP_HIDE_FROM_ABI inline constexpr
11599bool operator==(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
116100{ return __lhs.month() == __rhs.month(); }
117101
118_LIBCPP_HIDE_FROM_ABI inline constexpr
119bool operator!=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
120{ return !(__lhs == __rhs); }
121
122_LIBCPP_HIDE_FROM_ABI inline constexpr
123bool operator< (const month_day_last& __lhs, const month_day_last& __rhs) noexcept
124{ return __lhs.month() < __rhs.month(); }
125
126_LIBCPP_HIDE_FROM_ABI inline constexpr
127bool operator> (const month_day_last& __lhs, const month_day_last& __rhs) noexcept
128{ return __rhs < __lhs; }
129
130_LIBCPP_HIDE_FROM_ABI inline constexpr
131bool operator<=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
132{ return !(__rhs < __lhs);}
133
134_LIBCPP_HIDE_FROM_ABI inline constexpr
135bool operator>=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
136{ return !(__lhs < __rhs); }
102_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering
103operator<=>(const month_day_last& __lhs, const month_day_last& __rhs) noexcept {
104 return __lhs.month() <=> __rhs.month();
105}
137106
138107_LIBCPP_HIDE_FROM_ABI inline constexpr
139108month_day_last operator/(const month& __lhs, last_spec) noexcept
lib/libcxx/include/__chrono/ostream.h created+238
......@@ -0,0 +1,238 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___CHRONO_OSTREAM_H
11#define _LIBCPP___CHRONO_OSTREAM_H
12
13#include <__chrono/day.h>
14#include <__chrono/duration.h>
15#include <__chrono/month.h>
16#include <__chrono/month_weekday.h>
17#include <__chrono/monthday.h>
18#include <__chrono/statically_widen.h>
19#include <__chrono/weekday.h>
20#include <__chrono/year.h>
21#include <__chrono/year_month.h>
22#include <__chrono/year_month_day.h>
23#include <__chrono/year_month_weekday.h>
24#include <__concepts/same_as.h>
25#include <__config>
26#include <__format/format_functions.h>
27#include <ostream>
28#include <ratio>
29
30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
31# pragma GCC system_header
32#endif
33
34_LIBCPP_BEGIN_NAMESPACE_STD
35
36#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
37
38namespace chrono {
39
40// Depending on the type the return is a const _CharT* or a basic_string<_CharT>
41template <class _CharT, class _Period>
42_LIBCPP_HIDE_FROM_ABI auto __units_suffix() {
43 // TODO FMT LWG issue the suffixes are always char and not STATICALLY-WIDEN'ed.
44 if constexpr (same_as<typename _Period::type, atto>)
45 return _LIBCPP_STATICALLY_WIDEN(_CharT, "as");
46 else if constexpr (same_as<typename _Period::type, femto>)
47 return _LIBCPP_STATICALLY_WIDEN(_CharT, "fs");
48 else if constexpr (same_as<typename _Period::type, pico>)
49 return _LIBCPP_STATICALLY_WIDEN(_CharT, "ps");
50 else if constexpr (same_as<typename _Period::type, nano>)
51 return _LIBCPP_STATICALLY_WIDEN(_CharT, "ns");
52 else if constexpr (same_as<typename _Period::type, micro>)
53# ifndef _LIBCPP_HAS_NO_UNICODE
54 return _LIBCPP_STATICALLY_WIDEN(_CharT, "\u00b5s");
55# else
56 return _LIBCPP_STATICALLY_WIDEN(_CharT, "us");
57# endif
58 else if constexpr (same_as<typename _Period::type, milli>)
59 return _LIBCPP_STATICALLY_WIDEN(_CharT, "ms");
60 else if constexpr (same_as<typename _Period::type, centi>)
61 return _LIBCPP_STATICALLY_WIDEN(_CharT, "cs");
62 else if constexpr (same_as<typename _Period::type, deci>)
63 return _LIBCPP_STATICALLY_WIDEN(_CharT, "ds");
64 else if constexpr (same_as<typename _Period::type, ratio<1>>)
65 return _LIBCPP_STATICALLY_WIDEN(_CharT, "s");
66 else if constexpr (same_as<typename _Period::type, deca>)
67 return _LIBCPP_STATICALLY_WIDEN(_CharT, "das");
68 else if constexpr (same_as<typename _Period::type, hecto>)
69 return _LIBCPP_STATICALLY_WIDEN(_CharT, "hs");
70 else if constexpr (same_as<typename _Period::type, kilo>)
71 return _LIBCPP_STATICALLY_WIDEN(_CharT, "ks");
72 else if constexpr (same_as<typename _Period::type, mega>)
73 return _LIBCPP_STATICALLY_WIDEN(_CharT, "Ms");
74 else if constexpr (same_as<typename _Period::type, giga>)
75 return _LIBCPP_STATICALLY_WIDEN(_CharT, "Gs");
76 else if constexpr (same_as<typename _Period::type, tera>)
77 return _LIBCPP_STATICALLY_WIDEN(_CharT, "Ts");
78 else if constexpr (same_as<typename _Period::type, peta>)
79 return _LIBCPP_STATICALLY_WIDEN(_CharT, "Ps");
80 else if constexpr (same_as<typename _Period::type, exa>)
81 return _LIBCPP_STATICALLY_WIDEN(_CharT, "Es");
82 else if constexpr (same_as<typename _Period::type, ratio<60>>)
83 return _LIBCPP_STATICALLY_WIDEN(_CharT, "min");
84 else if constexpr (same_as<typename _Period::type, ratio<3600>>)
85 return _LIBCPP_STATICALLY_WIDEN(_CharT, "h");
86 else if constexpr (same_as<typename _Period::type, ratio<86400>>)
87 return _LIBCPP_STATICALLY_WIDEN(_CharT, "d");
88 else if constexpr (_Period::den == 1)
89 return std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "[{}]s"), _Period::num);
90 else
91 return std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "[{}/{}]s"), _Period::num, _Period::den);
92}
93
94template <class _CharT, class _Traits, class _Rep, class _Period>
95_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
96operator<<(basic_ostream<_CharT, _Traits>& __os, const duration<_Rep, _Period>& __d) {
97 basic_ostringstream<_CharT, _Traits> __s;
98 __s.flags(__os.flags());
99 __s.imbue(__os.getloc());
100 __s.precision(__os.precision());
101 __s << __d.count() << chrono::__units_suffix<_CharT, _Period>();
102 return __os << __s.str();
103}
104
105template <class _CharT, class _Traits>
106_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
107operator<<(basic_ostream<_CharT, _Traits>& __os, const day& __d) {
108 return __os
109 << (__d.ok()
110 ? std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:%d}"), __d)
111 // Note this error differs from the wording of the Standard. The
112 // Standard wording doesn't work well on AIX or Windows. There
113 // the formatted day seems to be either modulo 100 or completely
114 // omitted. Judging by the wording this is valid.
115 // TODO FMT Write a paper of file an LWG issue.
116 : std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:02} is not a valid day"), static_cast<unsigned>(__d)));
117}
118
119template <class _CharT, class _Traits>
120_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
121operator<<(basic_ostream<_CharT, _Traits>& __os, const month& __m) {
122 return __os << (__m.ok() ? std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%b}"), __m)
123 : std::format(__os.getloc(),
124 _LIBCPP_STATICALLY_WIDEN(_CharT, "{} is not a valid month"),
125 static_cast<unsigned>(__m))); // TODO FMT Standard mandated locale isn't used.
126}
127
128template <class _CharT, class _Traits>
129_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
130operator<<(basic_ostream<_CharT, _Traits>& __os, const year& __y) {
131 return __os << (__y.ok() ? std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:%Y}"), __y)
132 : std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:%Y} is not a valid year"), __y));
133}
134
135template <class _CharT, class _Traits>
136_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
137operator<<(basic_ostream<_CharT, _Traits>& __os, const weekday& __wd) {
138 return __os << (__wd.ok() ? std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%a}"), __wd)
139 : std::format(__os.getloc(), // TODO FMT Standard mandated locale isn't used.
140 _LIBCPP_STATICALLY_WIDEN(_CharT, "{} is not a valid weekday"),
141 static_cast<unsigned>(__wd.c_encoding())));
142}
143
144template <class _CharT, class _Traits>
145_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
146operator<<(basic_ostream<_CharT, _Traits>& __os, const weekday_indexed& __wdi) {
147 auto __i = __wdi.index();
148 return __os << (__i >= 1 && __i <= 5
149 ? std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L}[{}]"), __wdi.weekday(), __i)
150 : std::format(__os.getloc(),
151 _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L}[{} is not a valid index]"),
152 __wdi.weekday(),
153 __i));
154}
155
156template <class _CharT, class _Traits>
157_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
158operator<<(basic_ostream<_CharT, _Traits>& __os, const weekday_last& __wdl) {
159 return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L}[last]"), __wdl.weekday());
160}
161
162template <class _CharT, class _Traits>
163_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
164operator<<(basic_ostream<_CharT, _Traits>& __os, const month_day& __md) {
165 // TODO FMT The Standard allows 30th of February to be printed.
166 // It would be nice to show an error message instead.
167 return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L}/{}"), __md.month(), __md.day());
168}
169
170template <class _CharT, class _Traits>
171_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
172operator<<(basic_ostream<_CharT, _Traits>& __os, const month_day_last& __mdl) {
173 return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L}/last"), __mdl.month());
174}
175
176template <class _CharT, class _Traits>
177_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
178operator<<(basic_ostream<_CharT, _Traits>& __os, const month_weekday& __mwd) {
179 return __os << std::format(
180 __os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L}/{:L}"), __mwd.month(), __mwd.weekday_indexed());
181}
182
183template <class _CharT, class _Traits>
184_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
185operator<<(basic_ostream<_CharT, _Traits>& __os, const month_weekday_last& __mwdl) {
186 return __os << std::format(
187 __os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L}/{:L}"), __mwdl.month(), __mwdl.weekday_last());
188}
189
190template <class _CharT, class _Traits>
191_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
192operator<<(basic_ostream<_CharT, _Traits>& __os, const year_month& __ym) {
193 return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{}/{:L}"), __ym.year(), __ym.month());
194}
195
196template <class _CharT, class _Traits>
197_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
198operator<<(basic_ostream<_CharT, _Traits>& __os, const year_month_day& __ymd) {
199 return __os << (__ymd.ok() ? std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:%F}"), __ymd)
200 : std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:%F} is not a valid date"), __ymd));
201}
202
203template <class _CharT, class _Traits>
204_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
205operator<<(basic_ostream<_CharT, _Traits>& __os, const year_month_day_last& __ymdl) {
206 return __os << std::format(
207 __os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{}/{:L}"), __ymdl.year(), __ymdl.month_day_last());
208}
209
210template <class _CharT, class _Traits>
211_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
212operator<<(basic_ostream<_CharT, _Traits>& __os, const year_month_weekday& __ymwd) {
213 return __os << std::format(
214 __os.getloc(),
215 _LIBCPP_STATICALLY_WIDEN(_CharT, "{}/{:L}/{:L}"),
216 __ymwd.year(),
217 __ymwd.month(),
218 __ymwd.weekday_indexed());
219}
220
221template <class _CharT, class _Traits>
222_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT basic_ostream<_CharT, _Traits>&
223operator<<(basic_ostream<_CharT, _Traits>& __os, const year_month_weekday_last& __ymwdl) {
224 return __os << std::format(
225 __os.getloc(),
226 _LIBCPP_STATICALLY_WIDEN(_CharT, "{}/{:L}/{:L}"),
227 __ymwdl.year(),
228 __ymwdl.month(),
229 __ymwdl.weekday_last());
230}
231
232} // namespace chrono
233
234#endif //if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
235
236_LIBCPP_END_NAMESPACE_STD
237
238#endif // _LIBCPP___CHRONO_OSTREAM_H
lib/libcxx/include/__chrono/parser_std_format_spec.h created+410
......@@ -0,0 +1,410 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___CHRONO_PARSER_STD_FORMAT_SPEC_H
11#define _LIBCPP___CHRONO_PARSER_STD_FORMAT_SPEC_H
12
13#include <__config>
14#include <__format/concepts.h>
15#include <__format/format_error.h>
16#include <__format/format_parse_context.h>
17#include <__format/formatter_string.h>
18#include <__format/parser_std_format_spec.h>
19#include <string_view>
20
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header
23#endif
24
25_LIBCPP_BEGIN_NAMESPACE_STD
26
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
28
29namespace __format_spec {
30
31// By not placing this constant in the formatter class it's not duplicated for char and wchar_t
32inline constexpr __fields __fields_chrono_fractional{
33 .__precision_ = true, .__locale_specific_form_ = true, .__type_ = false};
34inline constexpr __fields __fields_chrono{.__locale_specific_form_ = true, .__type_ = false};
35
36/// Flags available or required in a chrono type.
37///
38/// The caller of the chrono formatter lists the types it has available and the
39/// validation tests whether the requested type spec (e.g. %M) is available in
40/// the formatter.
41/// When the type in the chrono-format-spec isn't present in the data a
42/// \ref format_error is thrown.
43enum class __flags {
44 __second = 0x1,
45 __minute = 0x2,
46 __hour = 0x4,
47 __time = __hour | __minute | __second,
48
49 __day = 0x8,
50 __month = 0x10,
51 __year = 0x20,
52
53 __weekday = 0x40,
54
55 __month_day = __day | __month,
56 __month_weekday = __weekday | __month,
57 __year_month = __month | __year,
58 __date = __day | __month | __year | __weekday,
59
60 __date_time = __date | __time,
61
62 __duration = 0x80 | __time,
63
64 __time_zone = 0x100,
65
66 __clock = __date_time | __time_zone
67};
68
69_LIBCPP_HIDE_FROM_ABI constexpr __flags operator&(__flags __lhs, __flags __rhs) {
70 return static_cast<__flags>(static_cast<unsigned>(__lhs) & static_cast<unsigned>(__rhs));
71}
72
73_LIBCPP_HIDE_FROM_ABI constexpr void __validate_second(__flags __flags) {
74 if ((__flags & __flags::__second) != __flags::__second)
75 std::__throw_format_error("The supplied date time doesn't contain a second");
76}
77
78_LIBCPP_HIDE_FROM_ABI constexpr void __validate_minute(__flags __flags) {
79 if ((__flags & __flags::__minute) != __flags::__minute)
80 std::__throw_format_error("The supplied date time doesn't contain a minute");
81}
82
83_LIBCPP_HIDE_FROM_ABI constexpr void __validate_hour(__flags __flags) {
84 if ((__flags & __flags::__hour) != __flags::__hour)
85 std::__throw_format_error("The supplied date time doesn't contain an hour");
86}
87
88_LIBCPP_HIDE_FROM_ABI constexpr void __validate_time(__flags __flags) {
89 if ((__flags & __flags::__time) != __flags::__time)
90 std::__throw_format_error("The supplied date time doesn't contain a time");
91}
92
93_LIBCPP_HIDE_FROM_ABI constexpr void __validate_day(__flags __flags) {
94 if ((__flags & __flags::__day) != __flags::__day)
95 std::__throw_format_error("The supplied date time doesn't contain a day");
96}
97
98_LIBCPP_HIDE_FROM_ABI constexpr void __validate_month(__flags __flags) {
99 if ((__flags & __flags::__month) != __flags::__month)
100 std::__throw_format_error("The supplied date time doesn't contain a month");
101}
102
103_LIBCPP_HIDE_FROM_ABI constexpr void __validate_year(__flags __flags) {
104 if ((__flags & __flags::__year) != __flags::__year)
105 std::__throw_format_error("The supplied date time doesn't contain a year");
106}
107
108_LIBCPP_HIDE_FROM_ABI constexpr void __validate_date(__flags __flags) {
109 if ((__flags & __flags::__date) != __flags::__date)
110 std::__throw_format_error("The supplied date time doesn't contain a date");
111}
112
113_LIBCPP_HIDE_FROM_ABI constexpr void __validate_date_or_duration(__flags __flags) {
114 if (((__flags & __flags::__date) != __flags::__date) && ((__flags & __flags::__duration) != __flags::__duration))
115 std::__throw_format_error("The supplied date time doesn't contain a date or duration");
116}
117
118_LIBCPP_HIDE_FROM_ABI constexpr void __validate_date_time(__flags __flags) {
119 if ((__flags & __flags::__date_time) != __flags::__date_time)
120 std::__throw_format_error("The supplied date time doesn't contain a date and time");
121}
122
123_LIBCPP_HIDE_FROM_ABI constexpr void __validate_weekday(__flags __flags) {
124 if ((__flags & __flags::__weekday) != __flags::__weekday)
125 std::__throw_format_error("The supplied date time doesn't contain a weekday");
126}
127
128_LIBCPP_HIDE_FROM_ABI constexpr void __validate_duration(__flags __flags) {
129 if ((__flags & __flags::__duration) != __flags::__duration)
130 std::__throw_format_error("The supplied date time doesn't contain a duration");
131}
132
133_LIBCPP_HIDE_FROM_ABI constexpr void __validate_time_zone(__flags __flags) {
134 if ((__flags & __flags::__time_zone) != __flags::__time_zone)
135 std::__throw_format_error("The supplied date time doesn't contain a time zone");
136}
137
138template <class _CharT>
139class _LIBCPP_TEMPLATE_VIS __parser_chrono {
140public:
141 _LIBCPP_HIDE_FROM_ABI constexpr auto
142 __parse(basic_format_parse_context<_CharT>& __parse_ctx, __fields __fields, __flags __flags)
143 -> decltype(__parse_ctx.begin()) {
144 const _CharT* __begin = __parser_.__parse(__parse_ctx, __fields);
145 const _CharT* __end = __parse_ctx.end();
146 if (__begin == __end)
147 return __begin;
148
149 const _CharT* __last = __parse_chrono_specs(__begin, __end, __flags);
150 __chrono_specs_ = basic_string_view<_CharT>{__begin, __last};
151
152 return __last;
153 }
154
155 __parser<_CharT> __parser_;
156 basic_string_view<_CharT> __chrono_specs_;
157
158private:
159 _LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
160 __parse_chrono_specs(const _CharT* __begin, const _CharT* __end, __flags __flags) {
161 _LIBCPP_ASSERT(__begin != __end,
162 "When called with an empty input the function will cause "
163 "undefined behavior by evaluating data not in the input");
164
165 if (*__begin != _CharT('%') && *__begin != _CharT('}'))
166 std::__throw_format_error("Expected '%' or '}' in the chrono format-string");
167
168 do {
169 switch (*__begin) {
170 case _CharT('{'):
171 std::__throw_format_error("The chrono-specs contains a '{'");
172
173 case _CharT('}'):
174 return __begin;
175
176 case _CharT('%'):
177 __parse_conversion_spec(__begin, __end, __flags);
178 [[fallthrough]];
179
180 default:
181 // All other literals
182 ++__begin;
183 }
184
185 } while (__begin != __end && *__begin != _CharT('}'));
186
187 return __begin;
188 }
189
190 /// \pre *__begin == '%'
191 /// \post __begin points at the end parsed conversion-spec
192 _LIBCPP_HIDE_FROM_ABI constexpr void
193 __parse_conversion_spec(const _CharT*& __begin, const _CharT* __end, __flags __flags) {
194 ++__begin;
195 if (__begin == __end)
196 std::__throw_format_error("End of input while parsing the modifier chrono conversion-spec");
197
198 switch (*__begin) {
199 case _CharT('n'):
200 case _CharT('t'):
201 case _CharT('%'):
202 break;
203
204 case _CharT('S'):
205 __format_spec::__validate_second(__flags);
206 break;
207
208 case _CharT('M'):
209 __format_spec::__validate_minute(__flags);
210 break;
211
212 case _CharT('p'): // TODO FMT does the formater require an hour or a time?
213 case _CharT('H'):
214 case _CharT('I'):
215 __validate_hour(__flags);
216 break;
217
218 case _CharT('r'):
219 case _CharT('R'):
220 case _CharT('T'):
221 case _CharT('X'):
222 __format_spec::__validate_time(__flags);
223 break;
224
225 case _CharT('d'):
226 case _CharT('e'):
227 __format_spec::__validate_day(__flags);
228 break;
229
230 case _CharT('b'):
231 case _CharT('h'):
232 case _CharT('B'):
233 __parser_.__month_name_ = true;
234 [[fallthrough]];
235 case _CharT('m'):
236 __format_spec::__validate_month(__flags);
237 break;
238
239 case _CharT('y'):
240 case _CharT('C'):
241 case _CharT('Y'):
242 __format_spec::__validate_year(__flags);
243 break;
244
245 case _CharT('j'):
246 __parser_.__day_of_year_ = true;
247 __format_spec::__validate_date_or_duration(__flags);
248 break;
249
250 case _CharT('g'):
251 case _CharT('G'):
252 case _CharT('U'):
253 case _CharT('V'):
254 case _CharT('W'):
255 __parser_.__week_of_year_ = true;
256 [[fallthrough]];
257 case _CharT('x'):
258 case _CharT('D'):
259 case _CharT('F'):
260 __format_spec::__validate_date(__flags);
261 break;
262
263 case _CharT('c'):
264 __format_spec::__validate_date_time(__flags);
265 break;
266
267 case _CharT('a'):
268 case _CharT('A'):
269 __parser_.__weekday_name_ = true;
270 [[fallthrough]];
271 case _CharT('u'):
272 case _CharT('w'):
273 __parser_.__weekday_ = true;
274 __validate_weekday(__flags);
275 __format_spec::__validate_weekday(__flags);
276 break;
277
278 case _CharT('q'):
279 case _CharT('Q'):
280 __format_spec::__validate_duration(__flags);
281 break;
282
283 case _CharT('E'):
284 __parse_modifier_E(__begin, __end, __flags);
285 break;
286
287 case _CharT('O'):
288 __parse_modifier_O(__begin, __end, __flags);
289 break;
290
291 case _CharT('z'):
292 case _CharT('Z'):
293 // Currently there's no time zone information. However some clocks have a
294 // hard-coded "time zone", for these clocks the information can be used.
295 // TODO FMT implement time zones.
296 __format_spec::__validate_time_zone(__flags);
297 break;
298
299 default: // unknown type;
300 std::__throw_format_error("The date time type specifier is invalid");
301 }
302 }
303
304 /// \pre *__begin == 'E'
305 /// \post __begin is incremented by one.
306 _LIBCPP_HIDE_FROM_ABI constexpr void
307 __parse_modifier_E(const _CharT*& __begin, const _CharT* __end, __flags __flags) {
308 ++__begin;
309 if (__begin == __end)
310 std::__throw_format_error("End of input while parsing the modifier E");
311
312 switch (*__begin) {
313 case _CharT('X'):
314 __format_spec::__validate_time(__flags);
315 break;
316
317 case _CharT('y'):
318 case _CharT('C'):
319 case _CharT('Y'):
320 __format_spec::__validate_year(__flags);
321 break;
322
323 case _CharT('x'):
324 __format_spec::__validate_date(__flags);
325 break;
326
327 case _CharT('c'):
328 __format_spec::__validate_date_time(__flags);
329 break;
330
331 case _CharT('z'):
332 // Currently there's no time zone information. However some clocks have a
333 // hard-coded "time zone", for these clocks the information can be used.
334 // TODO FMT implement time zones.
335 __format_spec::__validate_time_zone(__flags);
336 break;
337
338 default:
339 std::__throw_format_error("The date time type specifier for modifier E is invalid");
340 }
341 }
342
343 /// \pre *__begin == 'O'
344 /// \post __begin is incremented by one.
345 _LIBCPP_HIDE_FROM_ABI constexpr void
346 __parse_modifier_O(const _CharT*& __begin, const _CharT* __end, __flags __flags) {
347 ++__begin;
348 if (__begin == __end)
349 std::__throw_format_error("End of input while parsing the modifier O");
350
351 switch (*__begin) {
352 case _CharT('S'):
353 __format_spec::__validate_second(__flags);
354 break;
355
356 case _CharT('M'):
357 __format_spec::__validate_minute(__flags);
358 break;
359
360 case _CharT('I'):
361 case _CharT('H'):
362 __format_spec::__validate_hour(__flags);
363 break;
364
365 case _CharT('d'):
366 case _CharT('e'):
367 __format_spec::__validate_day(__flags);
368 break;
369
370 case _CharT('m'):
371 __format_spec::__validate_month(__flags);
372 break;
373
374 case _CharT('y'):
375 __format_spec::__validate_year(__flags);
376 break;
377
378 case _CharT('U'):
379 case _CharT('V'):
380 case _CharT('W'):
381 __parser_.__week_of_year_ = true;
382 __format_spec::__validate_date(__flags);
383 break;
384
385 case _CharT('u'):
386 case _CharT('w'):
387 __parser_.__weekday_ = true;
388 __format_spec::__validate_weekday(__flags);
389 break;
390
391 case _CharT('z'):
392 // Currently there's no time zone information. However some clocks have a
393 // hard-coded "time zone", for these clocks the information can be used.
394 // TODO FMT implement time zones.
395 __format_spec::__validate_time_zone(__flags);
396 break;
397
398 default:
399 std::__throw_format_error("The date time type specifier for modifier O is invalid");
400 }
401 }
402};
403
404} // namespace __format_spec
405
406#endif //_LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
407
408_LIBCPP_END_NAMESPACE_STD
409
410#endif // _LIBCPP___CHRONO_PARSER_STD_FORMAT_SPEC_H
lib/libcxx/include/__chrono/statically_widen.h created+52
......@@ -0,0 +1,52 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___CHRONO_STATICALLY_WIDEN_H
11#define _LIBCPP___CHRONO_STATICALLY_WIDEN_H
12
13// Implements the STATICALLY-WIDEN exposition-only function. ([time.general]/2)
14
15#include <__concepts/same_as.h>
16#include <__config>
17#include <__format/concepts.h>
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25#if _LIBCPP_STD_VER > 17
26
27# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
28template <__fmt_char_type _CharT>
29_LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __statically_widen(const char* __str, const wchar_t* __wstr) {
30 if constexpr (same_as<_CharT, char>)
31 return __str;
32 else
33 return __wstr;
34}
35# define _LIBCPP_STATICALLY_WIDEN(_CharT, __str) ::std::__statically_widen<_CharT>(__str, L##__str)
36# else // _LIBCPP_HAS_NO_WIDE_CHARACTERS
37
38// Without this indirection the unit test test/libcxx/modules_include.sh.cpp
39// fails for the CI build "No wide characters". This seems like a bug.
40// TODO FMT investigate why this is needed.
41template <__fmt_char_type _CharT>
42_LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __statically_widen(const char* __str) {
43 return __str;
44}
45# define _LIBCPP_STATICALLY_WIDEN(_CharT, __str) ::std::__statically_widen<_CharT>(__str)
46# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
47
48#endif //_LIBCPP_STD_VER > 17
49
50_LIBCPP_END_NAMESPACE_STD
51
52#endif // _LIBCPP___CHRONO_STATICALLY_WIDEN_H
lib/libcxx/include/__chrono/steady_clock.h+1-1
......@@ -31,7 +31,7 @@ public:
3131 typedef duration::rep rep;
3232 typedef duration::period period;
3333 typedef chrono::time_point<steady_clock, duration> time_point;
34 static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = true;
34 static _LIBCPP_CONSTEXPR_SINCE_CXX14 const bool is_steady = true;
3535
3636 static time_point now() _NOEXCEPT;
3737};
lib/libcxx/include/__chrono/system_clock.h+1-1
......@@ -31,7 +31,7 @@ public:
3131 typedef duration::rep rep;
3232 typedef duration::period period;
3333 typedef chrono::time_point<system_clock> time_point;
34 static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false;
34 static _LIBCPP_CONSTEXPR_SINCE_CXX14 const bool is_steady = false;
3535
3636 static time_point now() _NOEXCEPT;
3737 static time_t to_time_t (const time_point& __t) _NOEXCEPT;
lib/libcxx/include/__chrono/time_point.h+23-21
......@@ -12,8 +12,10 @@
1212
1313#include <__chrono/duration.h>
1414#include <__config>
15#include <__type_traits/common_type.h>
16#include <__type_traits/enable_if.h>
17#include <__type_traits/is_convertible.h>
1518#include <limits>
16#include <type_traits>
1719
1820#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1921# pragma GCC system_header
......@@ -41,12 +43,12 @@ private:
4143 duration __d_;
4244
4345public:
44 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point() : __d_(duration::zero()) {}
45 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit time_point(const duration& __d) : __d_(__d) {}
46 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 time_point() : __d_(duration::zero()) {}
47 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit time_point(const duration& __d) : __d_(__d) {}
4648
4749 // conversions
4850 template <class _Duration2>
49 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
51 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
5052 time_point(const time_point<clock, _Duration2>& __t,
5153 typename enable_if
5254 <
......@@ -56,12 +58,12 @@ public:
5658
5759 // observer
5860
59 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 duration time_since_epoch() const {return __d_;}
61 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 duration time_since_epoch() const {return __d_;}
6062
6163 // arithmetic
6264
63 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 time_point& operator+=(const duration& __d) {__d_ += __d; return *this;}
64 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 time_point& operator-=(const duration& __d) {__d_ -= __d; return *this;}
65 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 time_point& operator+=(const duration& __d) {__d_ += __d; return *this;}
66 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 time_point& operator-=(const duration& __d) {__d_ -= __d; return *this;}
6567
6668 // special values
6769
......@@ -81,7 +83,7 @@ struct _LIBCPP_TEMPLATE_VIS common_type<chrono::time_point<_Clock, _Duration1>,
8183namespace chrono {
8284
8385template <class _ToDuration, class _Clock, class _Duration>
84inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
86inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
8587time_point<_Clock, _ToDuration>
8688time_point_cast(const time_point<_Clock, _Duration>& __t)
8789{
......@@ -98,7 +100,7 @@ typename enable_if
98100>::type
99101floor(const time_point<_Clock, _Duration>& __t)
100102{
101 return time_point<_Clock, _ToDuration>{floor<_ToDuration>(__t.time_since_epoch())};
103 return time_point<_Clock, _ToDuration>{chrono::floor<_ToDuration>(__t.time_since_epoch())};
102104}
103105
104106template <class _ToDuration, class _Clock, class _Duration>
......@@ -110,7 +112,7 @@ typename enable_if
110112>::type
111113ceil(const time_point<_Clock, _Duration>& __t)
112114{
113 return time_point<_Clock, _ToDuration>{ceil<_ToDuration>(__t.time_since_epoch())};
115 return time_point<_Clock, _ToDuration>{chrono::ceil<_ToDuration>(__t.time_since_epoch())};
114116}
115117
116118template <class _ToDuration, class _Clock, class _Duration>
......@@ -122,7 +124,7 @@ typename enable_if
122124>::type
123125round(const time_point<_Clock, _Duration>& __t)
124126{
125 return time_point<_Clock, _ToDuration>{round<_ToDuration>(__t.time_since_epoch())};
127 return time_point<_Clock, _ToDuration>{chrono::round<_ToDuration>(__t.time_since_epoch())};
126128}
127129
128130template <class _Rep, class _Period>
......@@ -141,7 +143,7 @@ abs(duration<_Rep, _Period> __d)
141143// time_point ==
142144
143145template <class _Clock, class _Duration1, class _Duration2>
144inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
146inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
145147bool
146148operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
147149{
......@@ -151,7 +153,7 @@ operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
151153// time_point !=
152154
153155template <class _Clock, class _Duration1, class _Duration2>
154inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
156inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
155157bool
156158operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
157159{
......@@ -161,7 +163,7 @@ operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
161163// time_point <
162164
163165template <class _Clock, class _Duration1, class _Duration2>
164inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
166inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
165167bool
166168operator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
167169{
......@@ -171,7 +173,7 @@ operator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
171173// time_point >
172174
173175template <class _Clock, class _Duration1, class _Duration2>
174inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
176inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
175177bool
176178operator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
177179{
......@@ -181,7 +183,7 @@ operator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
181183// time_point <=
182184
183185template <class _Clock, class _Duration1, class _Duration2>
184inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
186inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
185187bool
186188operator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
187189{
......@@ -191,7 +193,7 @@ operator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
191193// time_point >=
192194
193195template <class _Clock, class _Duration1, class _Duration2>
194inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
196inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
195197bool
196198operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
197199{
......@@ -201,7 +203,7 @@ operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
201203// time_point operator+(time_point x, duration y);
202204
203205template <class _Clock, class _Duration1, class _Rep2, class _Period2>
204inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
206inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
205207time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
206208operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
207209{
......@@ -212,7 +214,7 @@ operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Pe
212214// time_point operator+(duration x, time_point y);
213215
214216template <class _Rep1, class _Period1, class _Clock, class _Duration2>
215inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
217inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
216218time_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type>
217219operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
218220{
......@@ -222,7 +224,7 @@ operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Dura
222224// time_point operator-(time_point x, duration y);
223225
224226template <class _Clock, class _Duration1, class _Rep2, class _Period2>
225inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
227inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
226228time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
227229operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
228230{
......@@ -233,7 +235,7 @@ operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Pe
233235// duration operator-(time_point x, time_point y);
234236
235237template <class _Clock, class _Duration1, class _Duration2>
236inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
238inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
237239typename common_type<_Duration1, _Duration2>::type
238240operator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
239241{
lib/libcxx/include/__chrono/weekday.h+19-19
......@@ -32,25 +32,25 @@ class weekday_last;
3232
3333class weekday {
3434private:
35 unsigned char __wd;
35 unsigned char __wd_;
3636 _LIBCPP_HIDE_FROM_ABI static constexpr unsigned char __weekday_from_days(int __days) noexcept;
3737public:
3838 _LIBCPP_HIDE_FROM_ABI weekday() = default;
39 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr weekday(unsigned __val) noexcept : __wd(static_cast<unsigned char>(__val == 7 ? 0 : __val)) {}
39 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr weekday(unsigned __val) noexcept : __wd_(static_cast<unsigned char>(__val == 7 ? 0 : __val)) {}
4040 _LIBCPP_HIDE_FROM_ABI inline constexpr weekday(const sys_days& __sysd) noexcept
41 : __wd(__weekday_from_days(__sysd.time_since_epoch().count())) {}
41 : __wd_(__weekday_from_days(__sysd.time_since_epoch().count())) {}
4242 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr weekday(const local_days& __locd) noexcept
43 : __wd(__weekday_from_days(__locd.time_since_epoch().count())) {}
43 : __wd_(__weekday_from_days(__locd.time_since_epoch().count())) {}
4444
45 _LIBCPP_HIDE_FROM_ABI inline constexpr weekday& operator++() noexcept { __wd = (__wd == 6 ? 0 : __wd + 1); return *this; }
45 _LIBCPP_HIDE_FROM_ABI inline constexpr weekday& operator++() noexcept { __wd_ = (__wd_ == 6 ? 0 : __wd_ + 1); return *this; }
4646 _LIBCPP_HIDE_FROM_ABI inline constexpr weekday operator++(int) noexcept { weekday __tmp = *this; ++(*this); return __tmp; }
47 _LIBCPP_HIDE_FROM_ABI inline constexpr weekday& operator--() noexcept { __wd = (__wd == 0 ? 6 : __wd - 1); return *this; }
47 _LIBCPP_HIDE_FROM_ABI inline constexpr weekday& operator--() noexcept { __wd_ = (__wd_ == 0 ? 6 : __wd_ - 1); return *this; }
4848 _LIBCPP_HIDE_FROM_ABI inline constexpr weekday operator--(int) noexcept { weekday __tmp = *this; --(*this); return __tmp; }
4949 _LIBCPP_HIDE_FROM_ABI constexpr weekday& operator+=(const days& __dd) noexcept;
5050 _LIBCPP_HIDE_FROM_ABI constexpr weekday& operator-=(const days& __dd) noexcept;
51 _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned c_encoding() const noexcept { return __wd; }
52 _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned iso_encoding() const noexcept { return __wd == 0u ? 7 : __wd; }
53 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __wd <= 6; }
51 _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned c_encoding() const noexcept { return __wd_; }
52 _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned iso_encoding() const noexcept { return __wd_ == 0u ? 7 : __wd_; }
53 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __wd_ <= 6; }
5454 _LIBCPP_HIDE_FROM_ABI constexpr weekday_indexed operator[](unsigned __index) const noexcept;
5555 _LIBCPP_HIDE_FROM_ABI constexpr weekday_last operator[](last_spec) const noexcept;
5656};
......@@ -123,15 +123,15 @@ weekday& weekday::operator-=(const days& __dd) noexcept
123123
124124class weekday_indexed {
125125private:
126 chrono::weekday __wd;
127 unsigned char __idx;
126 chrono::weekday __wd_;
127 unsigned char __idx_;
128128public:
129129 _LIBCPP_HIDE_FROM_ABI weekday_indexed() = default;
130130 _LIBCPP_HIDE_FROM_ABI inline constexpr weekday_indexed(const chrono::weekday& __wdval, unsigned __idxval) noexcept
131 : __wd{__wdval}, __idx(__idxval) {}
132 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wd; }
133 _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned index() const noexcept { return __idx; }
134 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __wd.ok() && __idx >= 1 && __idx <= 5; }
131 : __wd_{__wdval}, __idx_(__idxval) {}
132 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wd_; }
133 _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned index() const noexcept { return __idx_; }
134 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __wd_.ok() && __idx_ >= 1 && __idx_ <= 5; }
135135};
136136
137137_LIBCPP_HIDE_FROM_ABI inline constexpr
......@@ -145,12 +145,12 @@ bool operator!=(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noex
145145
146146class weekday_last {
147147private:
148 chrono::weekday __wd;
148 chrono::weekday __wd_;
149149public:
150150 _LIBCPP_HIDE_FROM_ABI explicit constexpr weekday_last(const chrono::weekday& __val) noexcept
151 : __wd{__val} {}
152 _LIBCPP_HIDE_FROM_ABI constexpr chrono::weekday weekday() const noexcept { return __wd; }
153 _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept { return __wd.ok(); }
151 : __wd_{__val} {}
152 _LIBCPP_HIDE_FROM_ABI constexpr chrono::weekday weekday() const noexcept { return __wd_; }
153 _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept { return __wd_.ok(); }
154154};
155155
156156_LIBCPP_HIDE_FROM_ABI inline constexpr
lib/libcxx/include/__chrono/year.h+13-28
......@@ -12,6 +12,7 @@
1212
1313#include <__chrono/duration.h>
1414#include <__config>
15#include <compare>
1516#include <limits>
1617
1718#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -30,22 +31,22 @@ namespace chrono
3031
3132class year {
3233private:
33 short __y;
34 short __y_;
3435public:
3536 _LIBCPP_HIDE_FROM_ABI year() = default;
36 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr year(int __val) noexcept : __y(static_cast<short>(__val)) {}
37 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr year(int __val) noexcept : __y_(static_cast<short>(__val)) {}
3738
38 _LIBCPP_HIDE_FROM_ABI inline constexpr year& operator++() noexcept { ++__y; return *this; }
39 _LIBCPP_HIDE_FROM_ABI inline constexpr year& operator++() noexcept { ++__y_; return *this; }
3940 _LIBCPP_HIDE_FROM_ABI inline constexpr year operator++(int) noexcept { year __tmp = *this; ++(*this); return __tmp; }
40 _LIBCPP_HIDE_FROM_ABI inline constexpr year& operator--() noexcept { --__y; return *this; }
41 _LIBCPP_HIDE_FROM_ABI inline constexpr year& operator--() noexcept { --__y_; return *this; }
4142 _LIBCPP_HIDE_FROM_ABI inline constexpr year operator--(int) noexcept { year __tmp = *this; --(*this); return __tmp; }
4243 _LIBCPP_HIDE_FROM_ABI constexpr year& operator+=(const years& __dy) noexcept;
4344 _LIBCPP_HIDE_FROM_ABI constexpr year& operator-=(const years& __dy) noexcept;
4445 _LIBCPP_HIDE_FROM_ABI inline constexpr year operator+() const noexcept { return *this; }
45 _LIBCPP_HIDE_FROM_ABI inline constexpr year operator-() const noexcept { return year{-__y}; }
46 _LIBCPP_HIDE_FROM_ABI inline constexpr year operator-() const noexcept { return year{-__y_}; }
4647
47 _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_leap() const noexcept { return __y % 4 == 0 && (__y % 100 != 0 || __y % 400 == 0); }
48 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator int() const noexcept { return __y; }
48 _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_leap() const noexcept { return __y_ % 4 == 0 && (__y_ % 100 != 0 || __y_ % 400 == 0); }
49 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator int() const noexcept { return __y_; }
4950 _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept;
5051 _LIBCPP_HIDE_FROM_ABI static inline constexpr year min() noexcept { return year{-32767}; }
5152 _LIBCPP_HIDE_FROM_ABI static inline constexpr year max() noexcept { return year{ 32767}; }
......@@ -56,25 +57,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
5657bool operator==(const year& __lhs, const year& __rhs) noexcept
5758{ return static_cast<int>(__lhs) == static_cast<int>(__rhs); }
5859
59_LIBCPP_HIDE_FROM_ABI inline constexpr
60bool operator!=(const year& __lhs, const year& __rhs) noexcept
61{ return !(__lhs == __rhs); }
62
63_LIBCPP_HIDE_FROM_ABI inline constexpr
64bool operator< (const year& __lhs, const year& __rhs) noexcept
65{ return static_cast<int>(__lhs) < static_cast<int>(__rhs); }
66
67_LIBCPP_HIDE_FROM_ABI inline constexpr
68bool operator> (const year& __lhs, const year& __rhs) noexcept
69{ return __rhs < __lhs; }
70
71_LIBCPP_HIDE_FROM_ABI inline constexpr
72bool operator<=(const year& __lhs, const year& __rhs) noexcept
73{ return !(__rhs < __lhs); }
74
75_LIBCPP_HIDE_FROM_ABI inline constexpr
76bool operator>=(const year& __lhs, const year& __rhs) noexcept
77{ return !(__lhs < __rhs); }
60_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const year& __lhs, const year& __rhs) noexcept {
61 return static_cast<int>(__lhs) <=> static_cast<int>(__rhs);
62}
7863
7964_LIBCPP_HIDE_FROM_ABI inline constexpr
8065year operator+ (const year& __lhs, const years& __rhs) noexcept
......@@ -102,8 +87,8 @@ year& year::operator-=(const years& __dy) noexcept
10287{ *this = *this - __dy; return *this; }
10388
10489_LIBCPP_HIDE_FROM_ABI constexpr bool year::ok() const noexcept {
105 static_assert(static_cast<int>(std::numeric_limits<decltype(__y)>::max()) == static_cast<int>(max()));
106 return static_cast<int>(min()) <= __y;
90 static_assert(static_cast<int>(std::numeric_limits<decltype(__y_)>::max()) == static_cast<int>(max()));
91 return static_cast<int>(min()) <= __y_;
10792}
10893
10994} // namespace chrono
lib/libcxx/include/__chrono/year_month.h+16-29
......@@ -14,6 +14,7 @@
1414#include <__chrono/month.h>
1515#include <__chrono/year.h>
1616#include <__config>
17#include <compare>
1718
1819#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1920# pragma GCC system_header
......@@ -27,19 +28,19 @@ namespace chrono
2728{
2829
2930class year_month {
30 chrono::year __y;
31 chrono::month __m;
31 chrono::year __y_;
32 chrono::month __m_;
3233public:
3334 _LIBCPP_HIDE_FROM_ABI year_month() = default;
3435 _LIBCPP_HIDE_FROM_ABI constexpr year_month(const chrono::year& __yval, const chrono::month& __mval) noexcept
35 : __y{__yval}, __m{__mval} {}
36 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; }
37 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
38 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator+=(const months& __dm) noexcept { this->__m += __dm; return *this; }
39 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator-=(const months& __dm) noexcept { this->__m -= __dm; return *this; }
40 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator+=(const years& __dy) noexcept { this->__y += __dy; return *this; }
41 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator-=(const years& __dy) noexcept { this->__y -= __dy; return *this; }
42 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok(); }
36 : __y_{__yval}, __m_{__mval} {}
37 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y_; }
38 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
39 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator+=(const months& __dm) noexcept { this->__m_ += __dm; return *this; }
40 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator-=(const months& __dm) noexcept { this->__m_ -= __dm; return *this; }
41 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator+=(const years& __dy) noexcept { this->__y_ += __dy; return *this; }
42 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator-=(const years& __dy) noexcept { this->__y_ -= __dy; return *this; }
43 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y_.ok() && __m_.ok(); }
4344};
4445
4546_LIBCPP_HIDE_FROM_ABI inline constexpr
......@@ -52,25 +53,11 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
5253bool operator==(const year_month& __lhs, const year_month& __rhs) noexcept
5354{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month(); }
5455
55_LIBCPP_HIDE_FROM_ABI inline constexpr
56bool operator!=(const year_month& __lhs, const year_month& __rhs) noexcept
57{ return !(__lhs == __rhs); }
58
59_LIBCPP_HIDE_FROM_ABI inline constexpr
60bool operator< (const year_month& __lhs, const year_month& __rhs) noexcept
61{ return __lhs.year() != __rhs.year() ? __lhs.year() < __rhs.year() : __lhs.month() < __rhs.month(); }
62
63_LIBCPP_HIDE_FROM_ABI inline constexpr
64bool operator> (const year_month& __lhs, const year_month& __rhs) noexcept
65{ return __rhs < __lhs; }
66
67_LIBCPP_HIDE_FROM_ABI inline constexpr
68bool operator<=(const year_month& __lhs, const year_month& __rhs) noexcept
69{ return !(__rhs < __lhs);}
70
71_LIBCPP_HIDE_FROM_ABI inline constexpr
72bool operator>=(const year_month& __lhs, const year_month& __rhs) noexcept
73{ return !(__lhs < __rhs); }
56_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const year_month& __lhs, const year_month& __rhs) noexcept {
57 if (auto __c = __lhs.year() <=> __rhs.year(); __c != 0)
58 return __c;
59 return __lhs.month() <=> __rhs.month();
60}
7461
7562_LIBCPP_HIDE_FROM_ABI constexpr
7663year_month operator+(const year_month& __lhs, const months& __rhs) noexcept
lib/libcxx/include/__chrono/year_month_day.h+29-45
......@@ -20,6 +20,7 @@
2020#include <__chrono/year.h>
2121#include <__chrono/year_month.h>
2222#include <__config>
23#include <compare>
2324#include <limits>
2425
2526#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -37,14 +38,14 @@ class year_month_day_last;
3738
3839class year_month_day {
3940private:
40 chrono::year __y;
41 chrono::month __m;
42 chrono::day __d;
41 chrono::year __y_;
42 chrono::month __m_;
43 chrono::day __d_;
4344public:
4445 _LIBCPP_HIDE_FROM_ABI year_month_day() = default;
4546 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day(
4647 const chrono::year& __yval, const chrono::month& __mval, const chrono::day& __dval) noexcept
47 : __y{__yval}, __m{__mval}, __d{__dval} {}
48 : __y_{__yval}, __m_{__mval}, __d_{__dval} {}
4849 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day(const year_month_day_last& __ymdl) noexcept;
4950 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day(const sys_days& __sysd) noexcept
5051 : year_month_day(__from_days(__sysd.time_since_epoch())) {}
......@@ -56,9 +57,9 @@ public:
5657 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day& operator+=(const years& __dy) noexcept;
5758 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day& operator-=(const years& __dy) noexcept;
5859
59 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; }
60 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
61 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::day day() const noexcept { return __d; }
60 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y_; }
61 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
62 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::day day() const noexcept { return __d_; }
6263 _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
6364 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
6465
......@@ -94,9 +95,9 @@ days year_month_day::__to_days() const noexcept
9495 static_assert(numeric_limits<unsigned>::digits >= 18, "");
9596 static_assert(numeric_limits<int>::digits >= 20 , "");
9697
97 const int __yr = static_cast<int>(__y) - (__m <= February);
98 const unsigned __mth = static_cast<unsigned>(__m);
99 const unsigned __dy = static_cast<unsigned>(__d);
98 const int __yr = static_cast<int>(__y_) - (__m_ <= February);
99 const unsigned __mth = static_cast<unsigned>(__m_);
100 const unsigned __dy = static_cast<unsigned>(__d_);
100101
101102 const int __era = (__yr >= 0 ? __yr : __yr - 399) / 400;
102103 const unsigned __yoe = static_cast<unsigned>(__yr - __era * 400); // [0, 399]
......@@ -109,32 +110,15 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
109110bool operator==(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
110111{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
111112
112_LIBCPP_HIDE_FROM_ABI inline constexpr
113bool operator!=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
114{ return !(__lhs == __rhs); }
115
116_LIBCPP_HIDE_FROM_ABI inline constexpr
117bool operator< (const year_month_day& __lhs, const year_month_day& __rhs) noexcept
118{
119 if (__lhs.year() < __rhs.year()) return true;
120 if (__lhs.year() > __rhs.year()) return false;
121 if (__lhs.month() < __rhs.month()) return true;
122 if (__lhs.month() > __rhs.month()) return false;
123 return __lhs.day() < __rhs.day();
113_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering
114operator<=>(const year_month_day& __lhs, const year_month_day& __rhs) noexcept {
115 if (auto __c = __lhs.year() <=> __rhs.year(); __c != 0)
116 return __c;
117 if (auto __c = __lhs.month() <=> __rhs.month(); __c != 0)
118 return __c;
119 return __lhs.day() <=> __rhs.day();
124120}
125121
126_LIBCPP_HIDE_FROM_ABI inline constexpr
127bool operator> (const year_month_day& __lhs, const year_month_day& __rhs) noexcept
128{ return __rhs < __lhs; }
129
130_LIBCPP_HIDE_FROM_ABI inline constexpr
131bool operator<=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
132{ return !(__rhs < __lhs);}
133
134_LIBCPP_HIDE_FROM_ABI inline constexpr
135bool operator>=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
136{ return !(__lhs < __rhs); }
137
138122_LIBCPP_HIDE_FROM_ABI inline constexpr
139123year_month_day operator/(const year_month& __lhs, const day& __rhs) noexcept
140124{ return year_month_day{__lhs.year(), __lhs.month(), __rhs}; }
......@@ -191,24 +175,24 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day& year_month_day::operator-
191175
192176class year_month_day_last {
193177private:
194 chrono::year __y;
195 chrono::month_day_last __mdl;
178 chrono::year __y_;
179 chrono::month_day_last __mdl_;
196180public:
197181 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last(const year& __yval, const month_day_last& __mdlval) noexcept
198 : __y{__yval}, __mdl{__mdlval} {}
182 : __y_{__yval}, __mdl_{__mdlval} {}
199183
200184 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator+=(const months& __m) noexcept;
201185 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator-=(const months& __m) noexcept;
202186 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator+=(const years& __y) noexcept;
203187 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator-=(const years& __y) noexcept;
204188
205 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; }
206 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __mdl.month(); }
207 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month_day_last month_day_last() const noexcept { return __mdl; }
189 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y_; }
190 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __mdl_.month(); }
191 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month_day_last month_day_last() const noexcept { return __mdl_; }
208192 _LIBCPP_HIDE_FROM_ABI constexpr chrono::day day() const noexcept;
209193 _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{year()/month()/day()}; }
210194 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{year()/month()/day()}; }
211 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y.ok() && __mdl.ok(); }
195 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y_.ok() && __mdl_.ok(); }
212196};
213197
214198_LIBCPP_HIDE_FROM_ABI inline constexpr
......@@ -221,7 +205,7 @@ chrono::day year_month_day_last::day() const noexcept
221205 chrono::day(31), chrono::day(31), chrono::day(30),
222206 chrono::day(31), chrono::day(30), chrono::day(31)
223207 };
224 return (month() != February || !__y.is_leap()) && month().ok() ?
208 return (month() != February || !__y_.is_leap()) && month().ok() ?
225209 __d[static_cast<unsigned>(month()) - 1] : chrono::day{29};
226210}
227211
......@@ -305,13 +289,13 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last& year_month_day_last:
305289
306290_LIBCPP_HIDE_FROM_ABI inline constexpr
307291year_month_day::year_month_day(const year_month_day_last& __ymdl) noexcept
308 : __y{__ymdl.year()}, __m{__ymdl.month()}, __d{__ymdl.day()} {}
292 : __y_{__ymdl.year()}, __m_{__ymdl.month()}, __d_{__ymdl.day()} {}
309293
310294_LIBCPP_HIDE_FROM_ABI inline constexpr
311295bool year_month_day::ok() const noexcept
312296{
313 if (!__y.ok() || !__m.ok()) return false;
314 return chrono::day{1} <= __d && __d <= (__y / __m / last).day();
297 if (!__y_.ok() || !__m_.ok()) return false;
298 return chrono::day{1} <= __d_ && __d_ <= (__y_ / __m_ / last).day();
315299}
316300
317301} // namespace chrono
lib/libcxx/include/__chrono/year_month_weekday.h+28-28
......@@ -35,14 +35,14 @@ namespace chrono
3535{
3636
3737class year_month_weekday {
38 chrono::year __y;
39 chrono::month __m;
40 chrono::weekday_indexed __wdi;
38 chrono::year __y_;
39 chrono::month __m_;
40 chrono::weekday_indexed __wdi_;
4141public:
4242 _LIBCPP_HIDE_FROM_ABI year_month_weekday() = default;
4343 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday(const chrono::year& __yval, const chrono::month& __mval,
4444 const chrono::weekday_indexed& __wdival) noexcept
45 : __y{__yval}, __m{__mval}, __wdi{__wdival} {}
45 : __y_{__yval}, __m_{__mval}, __wdi_{__wdival} {}
4646 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday(const sys_days& __sysd) noexcept
4747 : year_month_weekday(__from_days(__sysd.time_since_epoch())) {}
4848 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr year_month_weekday(const local_days& __locd) noexcept
......@@ -52,24 +52,24 @@ public:
5252 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday& operator+=(const years&) noexcept;
5353 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday& operator-=(const years&) noexcept;
5454
55 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; }
56 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
57 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wdi.weekday(); }
58 _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned index() const noexcept { return __wdi.index(); }
59 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; }
55 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y_; }
56 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
57 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wdi_.weekday(); }
58 _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned index() const noexcept { return __wdi_.index(); }
59 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi_; }
6060
6161 _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
6262 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
6363 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept
6464 {
65 if (!__y.ok() || !__m.ok() || !__wdi.ok()) return false;
66 if (__wdi.index() <= 4) return true;
65 if (!__y_.ok() || !__m_.ok() || !__wdi_.ok()) return false;
66 if (__wdi_.index() <= 4) return true;
6767 auto __nth_weekday_day =
68 __wdi.weekday() -
69 chrono::weekday{static_cast<sys_days>(__y / __m / 1)} +
70 days{(__wdi.index() - 1) * 7 + 1};
68 __wdi_.weekday() -
69 chrono::weekday{static_cast<sys_days>(__y_ / __m_ / 1)} +
70 days{(__wdi_.index() - 1) * 7 + 1};
7171 return static_cast<unsigned>(__nth_weekday_day.count()) <=
72 static_cast<unsigned>((__y / __m / last).day());
72 static_cast<unsigned>((__y_ / __m_ / last).day());
7373 }
7474
7575 _LIBCPP_HIDE_FROM_ABI static constexpr year_month_weekday __from_days(days __d) noexcept;
......@@ -89,8 +89,8 @@ year_month_weekday year_month_weekday::__from_days(days __d) noexcept
8989_LIBCPP_HIDE_FROM_ABI inline constexpr
9090days year_month_weekday::__to_days() const noexcept
9191{
92 const sys_days __sysd = sys_days(__y/__m/1);
93 return (__sysd + (__wdi.weekday() - chrono::weekday(__sysd) + days{(__wdi.index()-1)*7}))
92 const sys_days __sysd = sys_days(__y_/__m_/1);
93 return (__sysd + (__wdi_.weekday() - chrono::weekday(__sysd) + days{(__wdi_.index()-1)*7}))
9494 .time_since_epoch();
9595}
9696
......@@ -155,25 +155,25 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday& year_month_weekday::o
155155
156156class year_month_weekday_last {
157157private:
158 chrono::year __y;
159 chrono::month __m;
160 chrono::weekday_last __wdl;
158 chrono::year __y_;
159 chrono::month __m_;
160 chrono::weekday_last __wdl_;
161161public:
162162 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last(const chrono::year& __yval, const chrono::month& __mval,
163163 const chrono::weekday_last& __wdlval) noexcept
164 : __y{__yval}, __m{__mval}, __wdl{__wdlval} {}
164 : __y_{__yval}, __m_{__mval}, __wdl_{__wdlval} {}
165165 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator+=(const months& __dm) noexcept;
166166 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator-=(const months& __dm) noexcept;
167167 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator+=(const years& __dy) noexcept;
168168 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator-=(const years& __dy) noexcept;
169169
170 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; }
171 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }
172 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wdl.weekday(); }
173 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; }
170 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y_; }
171 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
172 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wdl_.weekday(); }
173 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl_; }
174174 _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
175175 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
176 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok() && __wdl.ok(); }
176 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y_.ok() && __m_.ok() && __wdl_.ok(); }
177177
178178 _LIBCPP_HIDE_FROM_ABI constexpr days __to_days() const noexcept;
179179
......@@ -182,8 +182,8 @@ public:
182182_LIBCPP_HIDE_FROM_ABI inline constexpr
183183days year_month_weekday_last::__to_days() const noexcept
184184{
185 const sys_days __last = sys_days{__y/__m/last};
186 return (__last - (chrono::weekday{__last} - __wdl.weekday())).time_since_epoch();
185 const sys_days __last = sys_days{__y_/__m_/last};
186 return (__last - (chrono::weekday{__last} - __wdl_.weekday())).time_since_epoch();
187187
188188}
189189
lib/libcxx/include/__compare/common_comparison_category.h+3-2
......@@ -11,7 +11,8 @@
1111
1212#include <__compare/ordering.h>
1313#include <__config>
14#include <type_traits>
14#include <__type_traits/is_same.h>
15#include <cstddef>
1516
1617#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1718# pragma GCC system_header
......@@ -64,7 +65,7 @@ _LIBCPP_HIDE_FROM_ABI
6465constexpr auto __get_comp_type() {
6566 using _CCC = _ClassifyCompCategory;
6667 constexpr _CCC __type_kinds[] = {_StrongOrd, __type_to_enum<_Ts>()...};
67 constexpr _CCC _Cat = __compute_comp_type(__type_kinds);
68 constexpr _CCC _Cat = __comp_detail::__compute_comp_type(__type_kinds);
6869 if constexpr (_Cat == _None)
6970 return void();
7071 else if constexpr (_Cat == _PartialOrd)
lib/libcxx/include/__compare/compare_partial_order_fallback.h+2-1
......@@ -12,9 +12,10 @@
1212#include <__compare/ordering.h>
1313#include <__compare/partial_order.h>
1414#include <__config>
15#include <__type_traits/decay.h>
16#include <__type_traits/is_same.h>
1517#include <__utility/forward.h>
1618#include <__utility/priority_tag.h>
17#include <type_traits>
1819
1920#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
2021# pragma GCC system_header
lib/libcxx/include/__compare/compare_strong_order_fallback.h+2-1
......@@ -12,9 +12,10 @@
1212#include <__compare/ordering.h>
1313#include <__compare/strong_order.h>
1414#include <__config>
15#include <__type_traits/decay.h>
16#include <__type_traits/is_same.h>
1517#include <__utility/forward.h>
1618#include <__utility/priority_tag.h>
17#include <type_traits>
1819
1920#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
2021# pragma GCC system_header
lib/libcxx/include/__compare/compare_three_way_result.h+4-3
......@@ -10,7 +10,8 @@
1010#define _LIBCPP___COMPARE_COMPARE_THREE_WAY_RESULT_H
1111
1212#include <__config>
13#include <type_traits>
13#include <__type_traits/make_const_lvalue_ref.h>
14#include <__utility/declval.h>
1415
1516#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1617# pragma GCC system_header
......@@ -25,9 +26,9 @@ struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result { };
2526
2627template<class _Tp, class _Up>
2728struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result<_Tp, _Up, decltype(
28 declval<__make_const_lvalue_ref<_Tp>>() <=> declval<__make_const_lvalue_ref<_Up>>(), void()
29 std::declval<__make_const_lvalue_ref<_Tp>>() <=> std::declval<__make_const_lvalue_ref<_Up>>(), void()
2930)> {
30 using type = decltype(declval<__make_const_lvalue_ref<_Tp>>() <=> declval<__make_const_lvalue_ref<_Up>>());
31 using type = decltype(std::declval<__make_const_lvalue_ref<_Tp>>() <=> std::declval<__make_const_lvalue_ref<_Up>>());
3132};
3233
3334template<class _Tp, class _Up = _Tp>
lib/libcxx/include/__compare/compare_weak_order_fallback.h+2-1
......@@ -12,9 +12,10 @@
1212#include <__compare/ordering.h>
1313#include <__compare/weak_order.h>
1414#include <__config>
15#include <__type_traits/decay.h>
16#include <__type_traits/is_same.h>
1517#include <__utility/forward.h>
1618#include <__utility/priority_tag.h>
17#include <type_traits>
1819
1920#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
2021# pragma GCC system_header
lib/libcxx/include/__compare/ordering.h+8-1
......@@ -10,7 +10,8 @@
1010#define _LIBCPP___COMPARE_ORDERING_H
1111
1212#include <__config>
13#include <type_traits>
13#include <__type_traits/enable_if.h>
14#include <__type_traits/is_same.h>
1415
1516#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1617# pragma GCC system_header
......@@ -312,6 +313,12 @@ inline constexpr strong_ordering strong_ordering::equal(_OrdResult::__equiv);
312313inline constexpr strong_ordering strong_ordering::equivalent(_OrdResult::__equiv);
313314inline constexpr strong_ordering strong_ordering::greater(_OrdResult::__greater);
314315
316/// [cmp.categories.pre]/1
317/// The types partial_ordering, weak_ordering, and strong_ordering are
318/// collectively termed the comparison category types.
319template <class _Tp>
320concept __comparison_category = __one_of_v<_Tp, partial_ordering, weak_ordering, strong_ordering>;
321
315322#endif // _LIBCPP_STD_VER > 17
316323
317324_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__compare/partial_order.h+4-1
......@@ -13,9 +13,10 @@
1313#include <__compare/ordering.h>
1414#include <__compare/weak_order.h>
1515#include <__config>
16#include <__type_traits/decay.h>
17#include <__type_traits/is_same.h>
1618#include <__utility/forward.h>
1719#include <__utility/priority_tag.h>
18#include <type_traits>
1920
2021#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
2122# pragma GCC system_header
......@@ -28,6 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2829// [cmp.alg]
2930namespace __partial_order {
3031 struct __fn {
32 // NOLINTBEGIN(libcpp-robust-against-adl) partial_order should use ADL, but only here
3133 template<class _Tp, class _Up>
3234 requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
3335 _LIBCPP_HIDE_FROM_ABI static constexpr auto
......@@ -35,6 +37,7 @@ namespace __partial_order {
3537 noexcept(noexcept(partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
3638 -> decltype( partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
3739 { return partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
40 // NOLINTEND(libcpp-robust-against-adl)
3841
3942 template<class _Tp, class _Up>
4043 requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
lib/libcxx/include/__compare/strong_order.h+4-1
......@@ -13,12 +13,13 @@
1313#include <__compare/compare_three_way.h>
1414#include <__compare/ordering.h>
1515#include <__config>
16#include <__type_traits/conditional.h>
17#include <__type_traits/decay.h>
1618#include <__utility/forward.h>
1719#include <__utility/priority_tag.h>
1820#include <cmath>
1921#include <cstdint>
2022#include <limits>
21#include <type_traits>
2223
2324#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
2425# pragma GCC system_header
......@@ -34,6 +35,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3435// [cmp.alg]
3536namespace __strong_order {
3637 struct __fn {
38 // NOLINTBEGIN(libcpp-robust-against-adl) strong_order should use ADL, but only here
3739 template<class _Tp, class _Up>
3840 requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
3941 _LIBCPP_HIDE_FROM_ABI static constexpr auto
......@@ -41,6 +43,7 @@ namespace __strong_order {
4143 noexcept(noexcept(strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
4244 -> decltype( strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
4345 { return strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
46 // NOLINTEND(libcpp-robust-against-adl)
4447
4548 template<class _Tp, class _Up, class _Dp = decay_t<_Tp>>
4649 requires is_same_v<_Dp, decay_t<_Up>> && is_floating_point_v<_Dp>
lib/libcxx/include/__compare/synth_three_way.h+1-1
......@@ -42,7 +42,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way =
4242 };
4343
4444template <class _Tp, class _Up = _Tp>
45using __synth_three_way_result = decltype(std::__synth_three_way(declval<_Tp&>(), declval<_Up&>()));
45using __synth_three_way_result = decltype(std::__synth_three_way(std::declval<_Tp&>(), std::declval<_Up&>()));
4646
4747#endif // _LIBCPP_STD_VER > 17
4848
lib/libcxx/include/__compare/three_way_comparable.h+2-1
......@@ -16,7 +16,8 @@
1616#include <__concepts/same_as.h>
1717#include <__concepts/totally_ordered.h>
1818#include <__config>
19#include <type_traits>
19#include <__type_traits/common_reference.h>
20#include <__type_traits/make_const_lvalue_ref.h>
2021
2122#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2223# pragma GCC system_header
lib/libcxx/include/__compare/weak_order.h+3-1
......@@ -13,10 +13,10 @@
1313#include <__compare/ordering.h>
1414#include <__compare/strong_order.h>
1515#include <__config>
16#include <__type_traits/decay.h>
1617#include <__utility/forward.h>
1718#include <__utility/priority_tag.h>
1819#include <cmath>
19#include <type_traits>
2020
2121#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
2222# pragma GCC system_header
......@@ -29,6 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2929// [cmp.alg]
3030namespace __weak_order {
3131 struct __fn {
32 // NOLINTBEGIN(libcpp-robust-against-adl) weak_order should use ADL, but only here
3233 template<class _Tp, class _Up>
3334 requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
3435 _LIBCPP_HIDE_FROM_ABI static constexpr auto
......@@ -36,6 +37,7 @@ namespace __weak_order {
3637 noexcept(noexcept(weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
3738 -> decltype( weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
3839 { return weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
40 // NOLINTEND(libcpp-robust-against-adl)
3941
4042 template<class _Tp, class _Up, class _Dp = decay_t<_Tp>>
4143 requires is_same_v<_Dp, decay_t<_Up>> && is_floating_point_v<_Dp>
lib/libcxx/include/__concepts/arithmetic.h+3-1
......@@ -10,9 +10,11 @@
1010#define _LIBCPP___CONCEPTS_ARITHMETIC_H
1111
1212#include <__config>
13#include <__type_traits/is_floating_point.h>
14#include <__type_traits/is_integral.h>
15#include <__type_traits/is_signed.h>
1316#include <__type_traits/is_signed_integer.h>
1417#include <__type_traits/is_unsigned_integer.h>
15#include <type_traits>
1618
1719#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1820# pragma GCC system_header
lib/libcxx/include/__concepts/assignable.h+2-1
......@@ -12,8 +12,9 @@
1212#include <__concepts/common_reference_with.h>
1313#include <__concepts/same_as.h>
1414#include <__config>
15#include <__type_traits/is_reference.h>
16#include <__type_traits/make_const_lvalue_ref.h>
1517#include <__utility/forward.h>
16#include <type_traits>
1718
1819#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1920# pragma GCC system_header
lib/libcxx/include/__concepts/class_or_enum.h+5-2
......@@ -10,7 +10,10 @@
1010#define _LIBCPP___CONCEPTS_CLASS_OR_ENUM_H
1111
1212#include <__config>
13#include <type_traits>
13#include <__type_traits/is_class.h>
14#include <__type_traits/is_enum.h>
15#include <__type_traits/is_union.h>
16#include <__type_traits/remove_cvref.h>
1417
1518#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1619# pragma GCC system_header
......@@ -28,7 +31,7 @@ concept __class_or_enum = is_class_v<_Tp> || is_union_v<_Tp> || is_enum_v<_Tp>;
2831// Work around Clang bug https://llvm.org/PR52970
2932// TODO: remove this workaround once libc++ no longer has to support Clang 13 (it was fixed in Clang 14).
3033template<class _Tp>
31concept __workaround_52970 = is_class_v<__uncvref_t<_Tp>> || is_union_v<__uncvref_t<_Tp>>;
34concept __workaround_52970 = is_class_v<__remove_cvref_t<_Tp>> || is_union_v<__remove_cvref_t<_Tp>>;
3235
3336#endif // _LIBCPP_STD_VER > 17
3437
lib/libcxx/include/__concepts/common_reference_with.h+1-1
......@@ -12,7 +12,7 @@
1212#include <__concepts/convertible_to.h>
1313#include <__concepts/same_as.h>
1414#include <__config>
15#include <type_traits>
15#include <__type_traits/common_reference.h>
1616
1717#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1818# pragma GCC system_header
lib/libcxx/include/__concepts/common_with.h+6-3
......@@ -12,7 +12,10 @@
1212#include <__concepts/common_reference_with.h>
1313#include <__concepts/same_as.h>
1414#include <__config>
15#include <type_traits>
15#include <__type_traits/add_lvalue_reference.h>
16#include <__type_traits/common_reference.h>
17#include <__type_traits/common_type.h>
18#include <__utility/declval.h>
1619
1720#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1821# pragma GCC system_header
......@@ -28,8 +31,8 @@ template<class _Tp, class _Up>
2831concept common_with =
2932 same_as<common_type_t<_Tp, _Up>, common_type_t<_Up, _Tp>> &&
3033 requires {
31 static_cast<common_type_t<_Tp, _Up>>(declval<_Tp>());
32 static_cast<common_type_t<_Tp, _Up>>(declval<_Up>());
34 static_cast<common_type_t<_Tp, _Up>>(std::declval<_Tp>());
35 static_cast<common_type_t<_Tp, _Up>>(std::declval<_Up>());
3336 } &&
3437 common_reference_with<
3538 add_lvalue_reference_t<const _Tp>,
lib/libcxx/include/__concepts/constructible.h+1-1
......@@ -12,7 +12,7 @@
1212#include <__concepts/convertible_to.h>
1313#include <__concepts/destructible.h>
1414#include <__config>
15#include <type_traits>
15#include <__type_traits/is_constructible.h>
1616
1717#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1818# pragma GCC system_header
lib/libcxx/include/__concepts/convertible_to.h+2-2
......@@ -10,8 +10,8 @@
1010#define _LIBCPP___CONCEPTS_CONVERTIBLE_TO_H
1111
1212#include <__config>
13#include <__type_traits/is_convertible.h>
1314#include <__utility/declval.h>
14#include <type_traits>
1515
1616#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1717# pragma GCC system_header
......@@ -27,7 +27,7 @@ template<class _From, class _To>
2727concept convertible_to =
2828 is_convertible_v<_From, _To> &&
2929 requires {
30 static_cast<_To>(declval<_From>());
30 static_cast<_To>(std::declval<_From>());
3131 };
3232
3333#endif // _LIBCPP_STD_VER > 17
lib/libcxx/include/__concepts/derived_from.h+2-1
......@@ -10,7 +10,8 @@
1010#define _LIBCPP___CONCEPTS_DERIVED_FROM_H
1111
1212#include <__config>
13#include <type_traits>
13#include <__type_traits/is_base_of.h>
14#include <__type_traits/is_convertible.h>
1415
1516#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1617# pragma GCC system_header
lib/libcxx/include/__concepts/destructible.h+1-1
......@@ -10,7 +10,7 @@
1010#define _LIBCPP___CONCEPTS_DESTRUCTIBLE_H
1111
1212#include <__config>
13#include <type_traits>
13#include <__type_traits/is_nothrow_destructible.h>
1414
1515#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1616# pragma GCC system_header
lib/libcxx/include/__concepts/different_from.h+1-1
......@@ -11,7 +11,7 @@
1111
1212#include <__concepts/same_as.h>
1313#include <__config>
14#include <type_traits>
14#include <__type_traits/remove_cvref.h>
1515
1616#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1717# pragma GCC system_header
lib/libcxx/include/__concepts/equality_comparable.h+2-1
......@@ -12,7 +12,8 @@
1212#include <__concepts/boolean_testable.h>
1313#include <__concepts/common_reference_with.h>
1414#include <__config>
15#include <type_traits>
15#include <__type_traits/common_reference.h>
16#include <__type_traits/make_const_lvalue_ref.h>
1617
1718#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1819# pragma GCC system_header
lib/libcxx/include/__concepts/invocable.h-1
......@@ -12,7 +12,6 @@
1212#include <__config>
1313#include <__functional/invoke.h>
1414#include <__utility/forward.h>
15#include <type_traits>
1615
1716#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1817# pragma GCC system_header
lib/libcxx/include/__concepts/movable.h+1-1
......@@ -13,7 +13,7 @@
1313#include <__concepts/constructible.h>
1414#include <__concepts/swappable.h>
1515#include <__config>
16#include <type_traits>
16#include <__type_traits/is_object.h>
1717
1818#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1919# pragma GCC system_header
lib/libcxx/include/__concepts/predicate.h+1-1
......@@ -12,7 +12,7 @@
1212#include <__concepts/boolean_testable.h>
1313#include <__concepts/invocable.h>
1414#include <__config>
15#include <type_traits>
15#include <__functional/invoke.h>
1616
1717#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1818# pragma GCC system_header
lib/libcxx/include/__concepts/same_as.h+1-1
......@@ -10,7 +10,7 @@
1010#define _LIBCPP___CONCEPTS_SAME_AS_H
1111
1212#include <__config>
13#include <type_traits>
13#include <__type_traits/is_same.h>
1414
1515#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1616# pragma GCC system_header
lib/libcxx/include/__concepts/swappable.h+6-1
......@@ -14,10 +14,15 @@
1414#include <__concepts/common_reference_with.h>
1515#include <__concepts/constructible.h>
1616#include <__config>
17#include <__type_traits/extent.h>
18#include <__type_traits/is_nothrow_move_assignable.h>
19#include <__type_traits/is_nothrow_move_constructible.h>
20#include <__type_traits/remove_cvref.h>
1721#include <__utility/exchange.h>
1822#include <__utility/forward.h>
1923#include <__utility/move.h>
20#include <type_traits>
24#include <__utility/swap.h>
25#include <cstddef>
2126
2227#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2328# pragma GCC system_header
lib/libcxx/include/__concepts/totally_ordered.h+2-1
......@@ -12,7 +12,8 @@
1212#include <__concepts/boolean_testable.h>
1313#include <__concepts/equality_comparable.h>
1414#include <__config>
15#include <type_traits>
15#include <__type_traits/common_reference.h>
16#include <__type_traits/make_const_lvalue_ref.h>
1617
1718#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1819# pragma GCC system_header
lib/libcxx/include/__config+114-93
......@@ -10,6 +10,8 @@
1010#ifndef _LIBCPP___CONFIG
1111#define _LIBCPP___CONFIG
1212
13#include <__config_site>
14
1315#if defined(_MSC_VER) && !defined(__clang__)
1416# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1517# define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
......@@ -28,13 +30,14 @@
2830# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
2931#elif defined(__GNUC__)
3032# define _LIBCPP_COMPILER_GCC
31#elif defined(_MSC_VER)
32# define _LIBCPP_COMPILER_MSVC
3333#endif
3434
3535#ifdef __cplusplus
3636
37# define _LIBCPP_VERSION 15003
37// _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM.
38// Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 16.0.1 == 16.00.01), _LIBCPP_VERSION is
39// defined to XXYYZZ.
40# define _LIBCPP_VERSION 160000
3841
3942# define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
4043# define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)
......@@ -57,7 +60,8 @@
5760# elif __cplusplus <= 202002L
5861# define _LIBCPP_STD_VER 20
5962# else
60# define _LIBCPP_STD_VER 22 // current year, or date of c++2b ratification
63// Expected release year of the next C++ standard
64# define _LIBCPP_STD_VER 23
6165# endif
6266# endif // _LIBCPP_STD_VER
6367
......@@ -148,7 +152,7 @@
148152# endif
149153// Feature macros for disabling pre ABI v1 features. All of these options
150154// are deprecated.
151# if defined(__FreeBSD__) || defined(__DragonFly__)
155# if defined(__FreeBSD__)
152156# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
153157# endif
154158# endif
......@@ -165,7 +169,7 @@
165169# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
166170# endif
167171
168# define _LIBCPP_TOSTRING2(x) # x
172# define _LIBCPP_TOSTRING2(x) #x
169173# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
170174
171175# if __cplusplus < 201103L
......@@ -192,6 +196,10 @@
192196# define __has_cpp_attribute(__x) 0
193197# endif
194198
199# ifndef __has_constexpr_builtin
200# define __has_constexpr_builtin(x) 0
201# endif
202
195203// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
196204// the compiler and '1' otherwise.
197205# ifndef __is_identifier
......@@ -212,12 +220,6 @@
212220# error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11"
213221# endif
214222
215# ifdef _LIBCPP_COMPILER_MSVC
216# error If you successfully use libc++ with MSVC please tell the libc++ developers and consider upstreaming your \
217changes. We are not aware of anybody using this configuration and know that at least some code is currently broken. \
218If there are users of this configuration we are happy to provide support.
219# endif
220
221223// FIXME: ABI detection should be done via compiler builtin macros. This
222224// is just a placeholder until Clang implements such macros. For now assume
223225// that Windows compilers pretending to be MSVC++ target the Microsoft ABI,
......@@ -251,7 +253,6 @@ If there are users of this configuration we are happy to provide support.
251253// easier to grep for target specific flags once the feature is complete.
252254# if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY)
253255# define _LIBCPP_HAS_NO_INCOMPLETE_FORMAT
254# define _LIBCPP_HAS_NO_INCOMPLETE_RANGES
255256# endif
256257
257258// Need to detect which libc we're using if we're on Linux.
......@@ -416,17 +417,21 @@ If there are users of this configuration we are happy to provide support.
416417# define _LIBCPP_NORETURN [[noreturn]]
417418# define _NOEXCEPT noexcept
418419# define _NOEXCEPT_(x) noexcept(x)
420# define _LIBCPP_CONSTEXPR constexpr
419421
420422# else
421423
422424# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
423425# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
424426# define _ALIGNAS(x) __attribute__((__aligned__(x)))
425# define _LIBCPP_NORETURN __attribute__((noreturn))
427# define _LIBCPP_NORETURN __attribute__((__noreturn__))
426428# define _LIBCPP_HAS_NO_NOEXCEPT
427429# define nullptr __nullptr
428430# define _NOEXCEPT throw()
429431# define _NOEXCEPT_(x)
432# define static_assert(...) _Static_assert(__VA_ARGS__)
433# define decltype(...) __decltype(__VA_ARGS__)
434# define _LIBCPP_CONSTEXPR
430435
431436typedef __char16_t char16_t;
432437typedef __char32_t char32_t;
......@@ -485,27 +490,7 @@ typedef __char32_t char32_t;
485490
486491# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
487492
488# elif defined(_LIBCPP_COMPILER_MSVC)
489
490# define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
491
492# if _MSC_VER < 1900
493# error "MSVC versions prior to Visual Studio 2015 are not supported"
494# endif
495
496# define _LIBCPP_NORETURN __declspec(noreturn)
497
498# define _LIBCPP_WEAK
499
500# define _LIBCPP_HAS_NO_ASAN
501
502# define _LIBCPP_ALWAYS_INLINE __forceinline
503
504# define _LIBCPP_HAS_NO_VECTOR_EXTENSION
505
506# define _LIBCPP_DISABLE_EXTENSION_WARNING
507
508# endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC]
493# endif // _LIBCPP_COMPILER_[CLANG|GCC]
509494
510495# if defined(_LIBCPP_OBJECT_FORMAT_COFF)
511496
......@@ -625,6 +610,15 @@ typedef __char32_t char32_t;
625610// Note that we use _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION to ensure that we don't depend
626611// on _LIBCPP_HIDE_FROM_ABI methods of classes explicitly instantiated in the dynamic library.
627612//
613// Also note that the _LIBCPP_HIDE_FROM_ABI_VIRTUAL macro should be used on virtual functions
614// instead of _LIBCPP_HIDE_FROM_ABI. That macro does not use an ABI tag. Indeed, the mangled
615// name of a virtual function is part of its ABI, since some architectures like arm64e can sign
616// the virtual function pointer in the vtable based on the mangled name of the function. Since
617// we use an ABI tag that changes with each released version, the mangled name of the virtual
618// function would change, which is incorrect. Note that it doesn't make much sense to change
619// the implementation of a virtual function in an ABI-incompatible way in the first place,
620// since that would be an ABI break anyway. Hence, the lack of ABI tag should not be noticeable.
621//
628622// TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing
629623// the length of symbols with an ABI tag. In practice, we should remove the escape hatch and
630624// use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70.
......@@ -635,6 +629,7 @@ typedef __char32_t char32_t;
635629# else
636630# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
637631# endif
632# define _LIBCPP_HIDE_FROM_ABI_VIRTUAL _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
638633
639634# ifdef _LIBCPP_BUILDING_LIBRARY
640635# if _LIBCPP_ABI_VERSION > 1
......@@ -678,31 +673,20 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
678673# define _LIBCPP_HAS_NO_INT128
679674# endif
680675
681# ifdef _LIBCPP_CXX03_LANG
682# define static_assert(...) _Static_assert(__VA_ARGS__)
683# define decltype(...) __decltype(__VA_ARGS__)
684# endif // _LIBCPP_CXX03_LANG
685
686# ifdef _LIBCPP_CXX03_LANG
687# define _LIBCPP_CONSTEXPR
688# else
689# define _LIBCPP_CONSTEXPR constexpr
690# endif
691
692676# ifndef __cpp_consteval
693677# define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR
694678# else
695679# define _LIBCPP_CONSTEVAL consteval
696680# endif
697681
698# ifdef __GNUC__
682# if __has_attribute(__malloc__)
699683# define _LIBCPP_NOALIAS __attribute__((__malloc__))
700684# else
701685# define _LIBCPP_NOALIAS
702686# endif
703687
704# if __has_attribute(using_if_exists)
705# define _LIBCPP_USING_IF_EXISTS __attribute__((using_if_exists))
688# if __has_attribute(__using_if_exists__)
689# define _LIBCPP_USING_IF_EXISTS __attribute__((__using_if_exists__))
706690# else
707691# define _LIBCPP_USING_IF_EXISTS
708692# endif
......@@ -726,11 +710,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
726710# endif // _LIBCPP_CXX03_LANG
727711
728712# if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__sun__) || \
729 defined(__NetBSD__) || defined(__DragonFly__)
713 defined(__NetBSD__)
730714# define _LIBCPP_LOCALE__L_EXTENSIONS 1
731715# endif
732716
733# if defined(__FreeBSD__) || defined(__DragonFly__)
717# ifdef __FreeBSD__
734718# define _DECLARE_C99_LDBL_MATH 1
735719# endif
736720
......@@ -750,11 +734,23 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
750734# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
751735# endif
752736
753# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__)
737// It is not yet possible to use aligned_alloc() on all Apple platforms since
738// 10.15 was the first version to ship an implementation of aligned_alloc().
739# if defined(__APPLE__)
740# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
741 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500)
742# define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC
743# endif
744# elif defined(__ANDROID__) && __ANDROID_API__ < 28
745// Android only provides aligned_alloc when targeting API 28 or higher.
746# define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC
747# endif
748
749# if defined(__APPLE__) || defined(__FreeBSD__)
754750# define _LIBCPP_HAS_DEFAULTRUNELOCALE
755751# endif
756752
757# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) || defined(__DragonFly__)
753# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
758754# define _LIBCPP_WCTYPE_IS_MASK
759755# endif
760756
......@@ -769,7 +765,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
769765# if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
770766# if __has_attribute(deprecated)
771767# define _LIBCPP_DEPRECATED __attribute__((deprecated))
772# define _LIBCPP_DEPRECATED_(m) __attribute__((deprected(m)))
768# define _LIBCPP_DEPRECATED_(m) __attribute__((deprecated(m)))
773769# elif _LIBCPP_STD_VER > 11
774770# define _LIBCPP_DEPRECATED [[deprecated]]
775771# define _LIBCPP_DEPRECATED_(m) [[deprecated(m)]]
......@@ -806,6 +802,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
806802# define _LIBCPP_DEPRECATED_IN_CXX20
807803# endif
808804
805#if _LIBCPP_STD_VER >= 23
806# define _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_DEPRECATED
807#else
808# define _LIBCPP_DEPRECATED_IN_CXX23
809#endif
810
809811# if !defined(_LIBCPP_HAS_NO_CHAR8_T)
810812# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
811813# else
......@@ -830,27 +832,31 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
830832# endif
831833
832834# if _LIBCPP_STD_VER > 11
833# define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
835# define _LIBCPP_CONSTEXPR_SINCE_CXX14 constexpr
834836# else
835# define _LIBCPP_CONSTEXPR_AFTER_CXX11
837# define _LIBCPP_CONSTEXPR_SINCE_CXX14
836838# endif
837839
838840# if _LIBCPP_STD_VER > 14
839# define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
841# define _LIBCPP_CONSTEXPR_SINCE_CXX17 constexpr
840842# else
841# define _LIBCPP_CONSTEXPR_AFTER_CXX14
843# define _LIBCPP_CONSTEXPR_SINCE_CXX17
842844# endif
843845
844846# if _LIBCPP_STD_VER > 17
845# define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
847# define _LIBCPP_CONSTEXPR_SINCE_CXX20 constexpr
846848# else
847# define _LIBCPP_CONSTEXPR_AFTER_CXX17
849# define _LIBCPP_CONSTEXPR_SINCE_CXX20
848850# endif
849851
850# if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)
852# if _LIBCPP_STD_VER > 20
853# define _LIBCPP_CONSTEXPR_SINCE_CXX23 constexpr
854# else
855# define _LIBCPP_CONSTEXPR_SINCE_CXX23
856# endif
857
858# if __has_cpp_attribute(nodiscard)
851859# define _LIBCPP_NODISCARD [[nodiscard]]
852# elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG)
853# define _LIBCPP_NODISCARD [[clang::warn_unused_result]]
854860# else
855861// We can't use GCC's [[gnu::warn_unused_result]] and
856862// __attribute__((warn_unused_result)), because GCC does not silence them via
......@@ -860,19 +866,19 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
860866
861867// _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not
862868// specified as such as an extension.
863# if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
869# if !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
864870# define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD
865871# else
866872# define _LIBCPP_NODISCARD_EXT
867873# endif
868874
869# if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD))
875# if _LIBCPP_STD_VER > 17 || !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
870876# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD
871877# else
872878# define _LIBCPP_NODISCARD_AFTER_CXX17
873879# endif
874880
875# if __has_attribute(no_destroy)
881# if __has_attribute(__no_destroy__)
876882# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
877883# else
878884# define _LIBCPP_NO_DESTROY
......@@ -901,7 +907,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
901907
902908# if defined(__FreeBSD__) || \
903909 defined(__wasi__) || \
904 defined(__DragonFly__) || \
905910 defined(__NetBSD__) || \
906911 defined(__OpenBSD__) || \
907912 defined(__NuttX__) || \
......@@ -1035,18 +1040,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
10351040
10361041# if _LIBCPP_STD_VER > 17
10371042# define _LIBCPP_CONSTINIT constinit
1038# elif __has_attribute(require_constant_initialization)
1043# elif __has_attribute(__require_constant_initialization__)
10391044# define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__))
10401045# else
10411046# define _LIBCPP_CONSTINIT
10421047# endif
10431048
1044# if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
1045# define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((diagnose_if(__VA_ARGS__, "warning")))
1046# define _LIBCPP_DIAGNOSE_ERROR(...) __attribute__((diagnose_if(__VA_ARGS__, "error")))
1049# if __has_attribute(__diagnose_if__) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
1050# define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((__diagnose_if__(__VA_ARGS__, "warning")))
10471051# else
10481052# define _LIBCPP_DIAGNOSE_WARNING(...)
1049# define _LIBCPP_DIAGNOSE_ERROR(...)
10501053# endif
10511054
10521055// Use a function like macro to imply that it must be followed by a semicolon
......@@ -1058,6 +1061,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
10581061# define _LIBCPP_FALLTHROUGH() ((void)0)
10591062# endif
10601063
1064# if __has_cpp_attribute(_Clang::__lifetimebound__)
1065# define _LIBCPP_LIFETIMEBOUND [[_Clang::__lifetimebound__]]
1066# else
1067# define _LIBCPP_LIFETIMEBOUND
1068# endif
1069
10611070# if __has_attribute(__nodebug__)
10621071# define _LIBCPP_NODEBUG __attribute__((__nodebug__))
10631072# else
......@@ -1086,7 +1095,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
10861095# define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__
10871096# endif
10881097
1089# if defined(_LIBCPP_ABI_MICROSOFT) && (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
1098# if defined(_LIBCPP_ABI_MICROSOFT) && __has_declspec_attribute(empty_bases)
10901099# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
10911100# else
10921101# define _LIBCPP_DECLSPEC_EMPTY_BASES
......@@ -1100,13 +1109,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
11001109# define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
11011110# endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
11021111
1103// Leave the deprecation notices in by default, but don't remove unary_function and
1104// binary_function entirely just yet. That way, folks will have one release to act
1105// on the deprecation warnings.
1106# ifndef _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
1107# define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
1108# endif
1109
11101112# if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)
11111113# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
11121114# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION
......@@ -1116,10 +1118,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
11161118# define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS
11171119# endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES
11181120
1119# if !defined(__cpp_impl_coroutine) || __cpp_impl_coroutine < 201902L
1120# define _LIBCPP_HAS_NO_CXX20_COROUTINES
1121# endif
1122
11231121# define _LIBCPP_PUSH_MACROS _Pragma("push_macro(\"min\")") _Pragma("push_macro(\"max\")")
11241122# define _LIBCPP_POP_MACROS _Pragma("pop_macro(\"min\")") _Pragma("pop_macro(\"max\")")
11251123
......@@ -1151,19 +1149,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
11511149# define _LIBCPP_HAS_NO_FGETPOS_FSETPOS
11521150# endif
11531151
1154# if __has_attribute(init_priority)
1155// TODO: Remove this once we drop support for building libc++ with old Clangs
1156# if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) || \
1157 (defined(__apple_build_version__) && __apple_build_version__ < 13000000)
1158# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
1159# else
1160# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100)))
1161# endif
1152# if __has_attribute(__init_priority__)
1153# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((__init_priority__(100)))
11621154# else
11631155# define _LIBCPP_INIT_PRIORITY_MAX
11641156# endif
11651157
1166# if defined(__GNUC__) || defined(__clang__)
1158# if __has_attribute(__format__)
11671159// The attribute uses 1-based indices for ordinary and static member functions.
11681160// The attribute uses 2-based indices for non-static member functions.
11691161# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \
......@@ -1225,6 +1217,35 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
12251217# define _LIBCPP_PACKED
12261218# endif
12271219
1220// c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these
1221// functions is gradually being added to existing C libraries. The conditions
1222// below check for known C library versions and conditions under which these
1223// functions are declared by the C library.
1224# define _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8
1225// GNU libc 2.36 and newer declare c8rtomb() and mbrtoc8() in C++ modes if
1226// __cpp_char8_t is defined or if C2X extensions are enabled. Unfortunately,
1227// determining the latter depends on internal GNU libc details. If the
1228// __cpp_char8_t feature test macro is not defined, then a char8_t typedef
1229// will be declared as well.
1230# if defined(_LIBCPP_GLIBC_PREREQ) && defined(__GLIBC_USE)
1231# if _LIBCPP_GLIBC_PREREQ(2, 36) && (defined(__cpp_char8_t) || __GLIBC_USE(ISOC2X))
1232# undef _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8
1233# endif
1234# endif
1235
1236// There are a handful of public standard library types that are intended to
1237// support CTAD but don't need any explicit deduction guides to do so. This
1238// macro is used to mark them as such, which suppresses the
1239// '-Wctad-maybe-unsupported' compiler warning when CTAD is used in user code
1240// with these classes.
1241#if _LIBCPP_STD_VER >= 17
1242# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) \
1243 template <class ..._Tag> \
1244 _ClassName(typename _Tag::__allow_ctad...) -> _ClassName<_Tag...>
1245#else
1246# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "")
1247#endif
1248
12281249#endif // __cplusplus
12291250
12301251#endif // _LIBCPP___CONFIG
lib/libcxx/include/__coroutine/coroutine_handle.h+5-4
......@@ -13,14 +13,15 @@
1313#include <__config>
1414#include <__functional/hash.h>
1515#include <__memory/addressof.h>
16#include <__type_traits/remove_cv.h>
1617#include <compare>
17#include <type_traits>
18#include <cstddef>
1819
1920#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2021# pragma GCC system_header
2122#endif
2223
23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
24#if _LIBCPP_STD_VER > 17
2425
2526_LIBCPP_BEGIN_NAMESPACE_STD
2627
......@@ -115,7 +116,7 @@ public:
115116
116117 _LIBCPP_HIDE_FROM_ABI
117118 static coroutine_handle from_promise(_Promise& __promise) {
118 using _RawPromise = typename remove_cv<_Promise>::type;
119 using _RawPromise = __remove_cv_t<_Promise>;
119120 coroutine_handle __tmp;
120121 __tmp.__handle_ =
121122 __builtin_coro_promise(_VSTD::addressof(const_cast<_RawPromise&>(__promise)), alignof(_Promise), true);
......@@ -197,6 +198,6 @@ struct hash<coroutine_handle<_Tp>> {
197198
198199_LIBCPP_END_NAMESPACE_STD
199200
200#endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
201#endif // __LIBCPP_STD_VER > 17
201202
202203#endif // _LIBCPP___COROUTINE_COROUTINE_HANDLE_H
lib/libcxx/include/__coroutine/coroutine_traits.h+4-4
......@@ -10,13 +10,13 @@
1010#define _LIBCPP___COROUTINE_COROUTINE_TRAITS_H
1111
1212#include <__config>
13#include <type_traits>
13#include <__type_traits/void_t.h>
1414
1515#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1616# pragma GCC system_header
1717#endif
1818
19#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
19#if _LIBCPP_STD_VER > 17
2020
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
......@@ -35,7 +35,7 @@ struct __coroutine_traits_sfinae {};
3535
3636template <class _Tp>
3737struct __coroutine_traits_sfinae<
38 _Tp, typename __void_t<typename _Tp::promise_type>::type>
38 _Tp, __void_t<typename _Tp::promise_type> >
3939{
4040 using promise_type = typename _Tp::promise_type;
4141};
......@@ -48,6 +48,6 @@ struct coroutine_traits
4848
4949_LIBCPP_END_NAMESPACE_STD
5050
51#endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
51#endif // __LIBCPP_STD_VER > 17
5252
5353#endif // _LIBCPP___COROUTINE_COROUTINE_TRAITS_H
lib/libcxx/include/__coroutine/noop_coroutine_handle.h+2-2
......@@ -16,7 +16,7 @@
1616# pragma GCC system_header
1717#endif
1818
19#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
19#if _LIBCPP_STD_VER > 17
2020
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
......@@ -107,6 +107,6 @@ noop_coroutine_handle noop_coroutine() noexcept { return noop_coroutine_handle()
107107
108108_LIBCPP_END_NAMESPACE_STD
109109
110#endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
110#endif // __LIBCPP_STD_VER > 17
111111
112112#endif // _LIBCPP___COROUTINE_NOOP_COROUTINE_HANDLE_H
lib/libcxx/include/__coroutine/trivial_awaitables.h+2-2
......@@ -16,7 +16,7 @@
1616# pragma GCC system_header
1717#endif
1818
19#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
19#if _LIBCPP_STD_VER > 17
2020
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
......@@ -41,6 +41,6 @@ struct suspend_always {
4141
4242_LIBCPP_END_NAMESPACE_STD
4343
44#endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)
44#endif // __LIBCPP_STD_VER > 17
4545
4646#endif // __LIBCPP___COROUTINE_TRIVIAL_AWAITABLES_H
lib/libcxx/include/__debug+14-15
......@@ -12,22 +12,21 @@
1212
1313#include <__assert>
1414#include <__config>
15#include <__type_traits/is_constant_evaluated.h>
1516#include <cstddef>
16#include <type_traits>
1717
1818#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1919# pragma GCC system_header
2020#endif
2121
22// Catch invalid uses of the legacy _LIBCPP_DEBUG toggle.
23#if defined(_LIBCPP_DEBUG) && _LIBCPP_DEBUG != 0 && !defined(_LIBCPP_ENABLE_DEBUG_MODE)
24# error "Enabling the debug mode now requires having configured the library with support for the debug mode"
25#endif
26
2722#if defined(_LIBCPP_ENABLE_DEBUG_MODE) && !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
2823# define _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
2924#endif
3025
26#if defined(_LIBCPP_ENABLE_DEBUG_MODE) && !defined(_LIBCPP_DEBUG_ITERATOR_BOUNDS_CHECKING)
27# define _LIBCPP_DEBUG_ITERATOR_BOUNDS_CHECKING
28#endif
29
3130#ifdef _LIBCPP_ENABLE_DEBUG_MODE
3231# define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(::std::__libcpp_is_constant_evaluated() || (x), m)
3332#else
......@@ -87,10 +86,10 @@ struct _C_node
8786 explicit _C_node(void* __c, __c_node* __n)
8887 : __c_node(__c, __n) {}
8988
90 virtual bool __dereferenceable(const void*) const;
91 virtual bool __decrementable(const void*) const;
92 virtual bool __addable(const void*, ptrdiff_t) const;
93 virtual bool __subscriptable(const void*, ptrdiff_t) const;
89 bool __dereferenceable(const void*) const override;
90 bool __decrementable(const void*) const override;
91 bool __addable(const void*, ptrdiff_t) const override;
92 bool __subscriptable(const void*, ptrdiff_t) const override;
9493};
9594
9695template <class _Cont>
......@@ -212,7 +211,7 @@ _LIBCPP_END_NAMESPACE_STD
212211_LIBCPP_BEGIN_NAMESPACE_STD
213212
214213template <class _Tp>
215_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_insert_c(_Tp* __c) {
214_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 inline void __debug_db_insert_c(_Tp* __c) {
216215#ifdef _LIBCPP_ENABLE_DEBUG_MODE
217216 if (!__libcpp_is_constant_evaluated())
218217 __get_db()->__insert_c(__c);
......@@ -222,7 +221,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_inser
222221}
223222
224223template <class _Tp>
225_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_insert_i(_Tp* __i) {
224_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 inline void __debug_db_insert_i(_Tp* __i) {
226225#ifdef _LIBCPP_ENABLE_DEBUG_MODE
227226 if (!__libcpp_is_constant_evaluated())
228227 __get_db()->__insert_i(__i);
......@@ -232,7 +231,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_inser
232231}
233232
234233template <class _Tp>
235_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_erase_c(_Tp* __c) {
234_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 inline void __debug_db_erase_c(_Tp* __c) {
236235#ifdef _LIBCPP_ENABLE_DEBUG_MODE
237236 if (!__libcpp_is_constant_evaluated())
238237 __get_db()->__erase_c(__c);
......@@ -242,7 +241,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_erase
242241}
243242
244243template <class _Tp>
245_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_swap(_Tp* __lhs, _Tp* __rhs) {
244_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 inline void __debug_db_swap(_Tp* __lhs, _Tp* __rhs) {
246245#ifdef _LIBCPP_ENABLE_DEBUG_MODE
247246 if (!__libcpp_is_constant_evaluated())
248247 __get_db()->swap(__lhs, __rhs);
......@@ -253,7 +252,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_swap(
253252}
254253
255254template <class _Tp>
256_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_invalidate_all(_Tp* __c) {
255_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 inline void __debug_db_invalidate_all(_Tp* __c) {
257256#ifdef _LIBCPP_ENABLE_DEBUG_MODE
258257 if (!__libcpp_is_constant_evaluated())
259258 __get_db()->__invalidate_all(__c);
lib/libcxx/include/__debug_utils/randomize_range.h+1-1
......@@ -23,7 +23,7 @@
2323_LIBCPP_BEGIN_NAMESPACE_STD
2424
2525template <class _AlgPolicy, class _Iterator, class _Sentinel>
26_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
26_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
2727void __debug_randomize_range(_Iterator __first, _Sentinel __last) {
2828#ifdef _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
2929# ifdef _LIBCPP_CXX03_LANG
lib/libcxx/include/__expected/bad_expected_access.h created+64
......@@ -0,0 +1,64 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9#ifndef _LIBCPP___EXPECTED_BAD_EXPECTED_ACCESS_H
10#define _LIBCPP___EXPECTED_BAD_EXPECTED_ACCESS_H
11
12#include <__config>
13#include <__utility/move.h>
14
15#include <exception>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21#if _LIBCPP_STD_VER >= 23
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25template <class _Err>
26class bad_expected_access;
27
28template <>
29class bad_expected_access<void> : public exception {
30protected:
31 _LIBCPP_HIDE_FROM_ABI bad_expected_access() noexcept = default;
32 _LIBCPP_HIDE_FROM_ABI bad_expected_access(const bad_expected_access&) = default;
33 _LIBCPP_HIDE_FROM_ABI bad_expected_access(bad_expected_access&&) = default;
34 _LIBCPP_HIDE_FROM_ABI bad_expected_access& operator=(const bad_expected_access&) = default;
35 _LIBCPP_HIDE_FROM_ABI bad_expected_access& operator=(bad_expected_access&&) = default;
36 ~bad_expected_access() override = default;
37
38public:
39 // The way this has been designed (by using a class template below) means that we'll already
40 // have a profusion of these vtables in TUs, and the dynamic linker will already have a bunch
41 // of work to do. So it is not worth hiding the <void> specialization in the dylib, given that
42 // it adds deployment target restrictions.
43 const char* what() const noexcept override { return "bad access to std::expected"; }
44};
45
46template <class _Err>
47class bad_expected_access : public bad_expected_access<void> {
48public:
49 _LIBCPP_HIDE_FROM_ABI explicit bad_expected_access(_Err __e) : __unex_(std::move(__e)) {}
50
51 _LIBCPP_HIDE_FROM_ABI _Err& error() & noexcept { return __unex_; }
52 _LIBCPP_HIDE_FROM_ABI const _Err& error() const& noexcept { return __unex_; }
53 _LIBCPP_HIDE_FROM_ABI _Err&& error() && noexcept { return std::move(__unex_); }
54 _LIBCPP_HIDE_FROM_ABI const _Err&& error() const&& noexcept { return std::move(__unex_); }
55
56private:
57 _Err __unex_;
58};
59
60_LIBCPP_END_NAMESPACE_STD
61
62#endif // _LIBCPP_STD_VER >= 23
63
64#endif // _LIBCPP___EXPECTED_BAD_EXPECTED_ACCESS_H
lib/libcxx/include/__expected/expected.h created+973
......@@ -0,0 +1,973 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9#ifndef _LIBCPP___EXPECTED_EXPECTED_H
10#define _LIBCPP___EXPECTED_EXPECTED_H
11
12#include <__assert>
13#include <__config>
14#include <__expected/bad_expected_access.h>
15#include <__expected/unexpect.h>
16#include <__expected/unexpected.h>
17#include <__memory/addressof.h>
18#include <__memory/construct_at.h>
19#include <__type_traits/conjunction.h>
20#include <__type_traits/disjunction.h>
21#include <__type_traits/is_assignable.h>
22#include <__type_traits/is_constructible.h>
23#include <__type_traits/is_convertible.h>
24#include <__type_traits/is_copy_assignable.h>
25#include <__type_traits/is_copy_constructible.h>
26#include <__type_traits/is_default_constructible.h>
27#include <__type_traits/is_function.h>
28#include <__type_traits/is_move_assignable.h>
29#include <__type_traits/is_move_constructible.h>
30#include <__type_traits/is_nothrow_constructible.h>
31#include <__type_traits/is_nothrow_copy_assignable.h>
32#include <__type_traits/is_nothrow_copy_constructible.h>
33#include <__type_traits/is_nothrow_default_constructible.h>
34#include <__type_traits/is_nothrow_move_assignable.h>
35#include <__type_traits/is_nothrow_move_constructible.h>
36#include <__type_traits/is_reference.h>
37#include <__type_traits/is_same.h>
38#include <__type_traits/is_swappable.h>
39#include <__type_traits/is_trivially_copy_constructible.h>
40#include <__type_traits/is_trivially_destructible.h>
41#include <__type_traits/is_trivially_move_constructible.h>
42#include <__type_traits/is_void.h>
43#include <__type_traits/lazy.h>
44#include <__type_traits/negation.h>
45#include <__type_traits/remove_cv.h>
46#include <__type_traits/remove_cvref.h>
47#include <__utility/exception_guard.h>
48#include <__utility/forward.h>
49#include <__utility/in_place.h>
50#include <__utility/move.h>
51#include <__utility/swap.h>
52#include <cstdlib> // for std::abort
53#include <initializer_list>
54
55#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
56# pragma GCC system_header
57#endif
58
59#if _LIBCPP_STD_VER >= 23
60
61_LIBCPP_BEGIN_NAMESPACE_STD
62
63namespace __expected {
64
65template <class _Err, class _Arg>
66_LIBCPP_HIDE_FROM_ABI void __throw_bad_expected_access(_Arg&& __arg) {
67# ifndef _LIBCPP_NO_EXCEPTIONS
68 throw bad_expected_access<_Err>(std::forward<_Arg>(__arg));
69# else
70 (void)__arg;
71 std::abort();
72# endif
73}
74
75} // namespace __expected
76
77template <class _Tp, class _Err>
78class expected {
79 static_assert(
80 !is_reference_v<_Tp> &&
81 !is_function_v<_Tp> &&
82 !is_same_v<remove_cv_t<_Tp>, in_place_t> &&
83 !is_same_v<remove_cv_t<_Tp>, unexpect_t> &&
84 !__is_std_unexpected<remove_cv_t<_Tp>>::value &&
85 __valid_std_unexpected<_Err>::value
86 ,
87 "[expected.object.general] A program that instantiates the definition of template expected<T, E> for a "
88 "reference type, a function type, or for possibly cv-qualified types in_place_t, unexpect_t, or a "
89 "specialization of unexpected for the T parameter is ill-formed. A program that instantiates the "
90 "definition of the template expected<T, E> with a type for the E parameter that is not a valid "
91 "template argument for unexpected is ill-formed.");
92
93 template <class _Up, class _OtherErr>
94 friend class expected;
95
96public:
97 using value_type = _Tp;
98 using error_type = _Err;
99 using unexpected_type = unexpected<_Err>;
100
101 template <class _Up>
102 using rebind = expected<_Up, error_type>;
103
104 // [expected.object.ctor], constructors
105 _LIBCPP_HIDE_FROM_ABI constexpr expected()
106 noexcept(is_nothrow_default_constructible_v<_Tp>) // strengthened
107 requires is_default_constructible_v<_Tp>
108 : __has_val_(true) {
109 std::construct_at(std::addressof(__union_.__val_));
110 }
111
112 _LIBCPP_HIDE_FROM_ABI constexpr expected(const expected&) = delete;
113
114 _LIBCPP_HIDE_FROM_ABI constexpr expected(const expected&)
115 requires(is_copy_constructible_v<_Tp> &&
116 is_copy_constructible_v<_Err> &&
117 is_trivially_copy_constructible_v<_Tp> &&
118 is_trivially_copy_constructible_v<_Err>)
119 = default;
120
121 _LIBCPP_HIDE_FROM_ABI constexpr expected(const expected& __other)
122 noexcept(is_nothrow_copy_constructible_v<_Tp> && is_nothrow_copy_constructible_v<_Err>) // strengthened
123 requires(is_copy_constructible_v<_Tp> && is_copy_constructible_v<_Err> &&
124 !(is_trivially_copy_constructible_v<_Tp> && is_trivially_copy_constructible_v<_Err>))
125 : __has_val_(__other.__has_val_) {
126 if (__has_val_) {
127 std::construct_at(std::addressof(__union_.__val_), __other.__union_.__val_);
128 } else {
129 std::construct_at(std::addressof(__union_.__unex_), __other.__union_.__unex_);
130 }
131 }
132
133
134 _LIBCPP_HIDE_FROM_ABI constexpr expected(expected&&)
135 requires(is_move_constructible_v<_Tp> && is_move_constructible_v<_Err>
136 && is_trivially_move_constructible_v<_Tp> && is_trivially_move_constructible_v<_Err>)
137 = default;
138
139 _LIBCPP_HIDE_FROM_ABI constexpr expected(expected&& __other)
140 noexcept(is_nothrow_move_constructible_v<_Tp> && is_nothrow_move_constructible_v<_Err>)
141 requires(is_move_constructible_v<_Tp> && is_move_constructible_v<_Err> &&
142 !(is_trivially_move_constructible_v<_Tp> && is_trivially_move_constructible_v<_Err>))
143 : __has_val_(__other.__has_val_) {
144 if (__has_val_) {
145 std::construct_at(std::addressof(__union_.__val_), std::move(__other.__union_.__val_));
146 } else {
147 std::construct_at(std::addressof(__union_.__unex_), std::move(__other.__union_.__unex_));
148 }
149 }
150
151private:
152 template <class _Up, class _OtherErr, class _UfQual, class _OtherErrQual>
153 using __can_convert =
154 _And< is_constructible<_Tp, _UfQual>,
155 is_constructible<_Err, _OtherErrQual>,
156 _Not<is_constructible<_Tp, expected<_Up, _OtherErr>&>>,
157 _Not<is_constructible<_Tp, expected<_Up, _OtherErr>>>,
158 _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>&>>,
159 _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>>>,
160 _Not<is_convertible<expected<_Up, _OtherErr>&, _Tp>>,
161 _Not<is_convertible<expected<_Up, _OtherErr>&&, _Tp>>,
162 _Not<is_convertible<const expected<_Up, _OtherErr>&, _Tp>>,
163 _Not<is_convertible<const expected<_Up, _OtherErr>&&, _Tp>>,
164 _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>&>>,
165 _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>>>,
166 _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>&>>,
167 _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>>> >;
168
169
170public:
171 template <class _Up, class _OtherErr>
172 requires __can_convert<_Up, _OtherErr, const _Up&, const _OtherErr&>::value
173 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<const _Up&, _Tp> ||
174 !is_convertible_v<const _OtherErr&, _Err>)
175 expected(const expected<_Up, _OtherErr>& __other)
176 noexcept(is_nothrow_constructible_v<_Tp, const _Up&> &&
177 is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened
178 : __has_val_(__other.__has_val_) {
179 if (__has_val_) {
180 std::construct_at(std::addressof(__union_.__val_), __other.__union_.__val_);
181 } else {
182 std::construct_at(std::addressof(__union_.__unex_), __other.__union_.__unex_);
183 }
184 }
185
186 template <class _Up, class _OtherErr>
187 requires __can_convert<_Up, _OtherErr, _Up, _OtherErr>::value
188 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_Up, _Tp> || !is_convertible_v<_OtherErr, _Err>)
189 expected(expected<_Up, _OtherErr>&& __other)
190 noexcept(is_nothrow_constructible_v<_Tp, _Up> && is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened
191 : __has_val_(__other.__has_val_) {
192 if (__has_val_) {
193 std::construct_at(std::addressof(__union_.__val_), std::move(__other.__union_.__val_));
194 } else {
195 std::construct_at(std::addressof(__union_.__unex_), std::move(__other.__union_.__unex_));
196 }
197 }
198
199 template <class _Up = _Tp>
200 requires(!is_same_v<remove_cvref_t<_Up>, in_place_t> && !is_same_v<expected, remove_cvref_t<_Up>> &&
201 !__is_std_unexpected<remove_cvref_t<_Up>>::value && is_constructible_v<_Tp, _Up>)
202 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_Up, _Tp>)
203 expected(_Up&& __u)
204 noexcept(is_nothrow_constructible_v<_Tp, _Up>) // strengthened
205 : __has_val_(true) {
206 std::construct_at(std::addressof(__union_.__val_), std::forward<_Up>(__u));
207 }
208
209
210 template <class _OtherErr>
211 requires is_constructible_v<_Err, const _OtherErr&>
212 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<const _OtherErr&, _Err>)
213 expected(const unexpected<_OtherErr>& __unex)
214 noexcept(is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened
215 : __has_val_(false) {
216 std::construct_at(std::addressof(__union_.__unex_), __unex.error());
217 }
218
219 template <class _OtherErr>
220 requires is_constructible_v<_Err, _OtherErr>
221 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_OtherErr, _Err>)
222 expected(unexpected<_OtherErr>&& __unex)
223 noexcept(is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened
224 : __has_val_(false) {
225 std::construct_at(std::addressof(__union_.__unex_), std::move(__unex.error()));
226 }
227
228 template <class... _Args>
229 requires is_constructible_v<_Tp, _Args...>
230 _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(in_place_t, _Args&&... __args)
231 noexcept(is_nothrow_constructible_v<_Tp, _Args...>) // strengthened
232 : __has_val_(true) {
233 std::construct_at(std::addressof(__union_.__val_), std::forward<_Args>(__args)...);
234 }
235
236 template <class _Up, class... _Args>
237 requires is_constructible_v< _Tp, initializer_list<_Up>&, _Args... >
238 _LIBCPP_HIDE_FROM_ABI constexpr explicit
239 expected(in_place_t, initializer_list<_Up> __il, _Args&&... __args)
240 noexcept(is_nothrow_constructible_v<_Tp, initializer_list<_Up>&, _Args...>) // strengthened
241 : __has_val_(true) {
242 std::construct_at(std::addressof(__union_.__val_), __il, std::forward<_Args>(__args)...);
243 }
244
245 template <class... _Args>
246 requires is_constructible_v<_Err, _Args...>
247 _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(unexpect_t, _Args&&... __args)
248 noexcept(is_nothrow_constructible_v<_Err, _Args...>) // strengthened
249 : __has_val_(false) {
250 std::construct_at(std::addressof(__union_.__unex_), std::forward<_Args>(__args)...);
251 }
252
253 template <class _Up, class... _Args>
254 requires is_constructible_v< _Err, initializer_list<_Up>&, _Args... >
255 _LIBCPP_HIDE_FROM_ABI constexpr explicit
256 expected(unexpect_t, initializer_list<_Up> __il, _Args&&... __args)
257 noexcept(is_nothrow_constructible_v<_Err, initializer_list<_Up>&, _Args...>) // strengthened
258 : __has_val_(false) {
259 std::construct_at(std::addressof(__union_.__unex_), __il, std::forward<_Args>(__args)...);
260 }
261
262 // [expected.object.dtor], destructor
263
264 _LIBCPP_HIDE_FROM_ABI constexpr ~expected()
265 requires(is_trivially_destructible_v<_Tp> && is_trivially_destructible_v<_Err>)
266 = default;
267
268 _LIBCPP_HIDE_FROM_ABI constexpr ~expected()
269 requires(!is_trivially_destructible_v<_Tp> || !is_trivially_destructible_v<_Err>)
270 {
271 if (__has_val_) {
272 std::destroy_at(std::addressof(__union_.__val_));
273 } else {
274 std::destroy_at(std::addressof(__union_.__unex_));
275 }
276 }
277
278private:
279 template <class _T1, class _T2, class... _Args>
280 _LIBCPP_HIDE_FROM_ABI static constexpr void __reinit_expected(_T1& __newval, _T2& __oldval, _Args&&... __args) {
281 if constexpr (is_nothrow_constructible_v<_T1, _Args...>) {
282 std::destroy_at(std::addressof(__oldval));
283 std::construct_at(std::addressof(__newval), std::forward<_Args>(__args)...);
284 } else if constexpr (is_nothrow_move_constructible_v<_T1>) {
285 _T1 __tmp(std::forward<_Args>(__args)...);
286 std::destroy_at(std::addressof(__oldval));
287 std::construct_at(std::addressof(__newval), std::move(__tmp));
288 } else {
289 static_assert(
290 is_nothrow_move_constructible_v<_T2>,
291 "To provide strong exception guarantee, T2 has to satisfy `is_nothrow_move_constructible_v` so that it can "
292 "be reverted to the previous state in case an exception is thrown during the assignment.");
293 _T2 __tmp(std::move(__oldval));
294 std::destroy_at(std::addressof(__oldval));
295 __exception_guard __trans([&] { std::construct_at(std::addressof(__oldval), std::move(__tmp)); });
296 std::construct_at(std::addressof(__newval), std::forward<_Args>(__args)...);
297 __trans.__complete();
298 }
299 }
300
301public:
302 // [expected.object.assign], assignment
303 _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(const expected&) = delete;
304
305 _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(const expected& __rhs)
306 noexcept(is_nothrow_copy_assignable_v<_Tp> &&
307 is_nothrow_copy_constructible_v<_Tp> &&
308 is_nothrow_copy_assignable_v<_Err> &&
309 is_nothrow_copy_constructible_v<_Err>) // strengthened
310 requires(is_copy_assignable_v<_Tp> &&
311 is_copy_constructible_v<_Tp> &&
312 is_copy_assignable_v<_Err> &&
313 is_copy_constructible_v<_Err> &&
314 (is_nothrow_move_constructible_v<_Tp> ||
315 is_nothrow_move_constructible_v<_Err>))
316 {
317 if (__has_val_ && __rhs.__has_val_) {
318 __union_.__val_ = __rhs.__union_.__val_;
319 } else if (__has_val_) {
320 __reinit_expected(__union_.__unex_, __union_.__val_, __rhs.__union_.__unex_);
321 } else if (__rhs.__has_val_) {
322 __reinit_expected(__union_.__val_, __union_.__unex_, __rhs.__union_.__val_);
323 } else {
324 __union_.__unex_ = __rhs.__union_.__unex_;
325 }
326 // note: only reached if no exception+rollback was done inside __reinit_expected
327 __has_val_ = __rhs.__has_val_;
328 return *this;
329 }
330
331 _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(expected&& __rhs)
332 noexcept(is_nothrow_move_assignable_v<_Tp> &&
333 is_nothrow_move_constructible_v<_Tp> &&
334 is_nothrow_move_assignable_v<_Err> &&
335 is_nothrow_move_constructible_v<_Err>)
336 requires(is_move_constructible_v<_Tp> &&
337 is_move_assignable_v<_Tp> &&
338 is_move_constructible_v<_Err> &&
339 is_move_assignable_v<_Err> &&
340 (is_nothrow_move_constructible_v<_Tp> ||
341 is_nothrow_move_constructible_v<_Err>))
342 {
343 if (__has_val_ && __rhs.__has_val_) {
344 __union_.__val_ = std::move(__rhs.__union_.__val_);
345 } else if (__has_val_) {
346 __reinit_expected(__union_.__unex_, __union_.__val_, std::move(__rhs.__union_.__unex_));
347 } else if (__rhs.__has_val_) {
348 __reinit_expected(__union_.__val_, __union_.__unex_, std::move(__rhs.__union_.__val_));
349 } else {
350 __union_.__unex_ = std::move(__rhs.__union_.__unex_);
351 }
352 // note: only reached if no exception+rollback was done inside __reinit_expected
353 __has_val_ = __rhs.__has_val_;
354 return *this;
355 }
356
357 template <class _Up = _Tp>
358 _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(_Up&& __v)
359 requires(!is_same_v<expected, remove_cvref_t<_Up>> &&
360 !__is_std_unexpected<remove_cvref_t<_Up>>::value &&
361 is_constructible_v<_Tp, _Up> &&
362 is_assignable_v<_Tp&, _Up> &&
363 (is_nothrow_constructible_v<_Tp, _Up> ||
364 is_nothrow_move_constructible_v<_Tp> ||
365 is_nothrow_move_constructible_v<_Err>))
366 {
367 if (__has_val_) {
368 __union_.__val_ = std::forward<_Up>(__v);
369 } else {
370 __reinit_expected(__union_.__val_, __union_.__unex_, std::forward<_Up>(__v));
371 __has_val_ = true;
372 }
373 return *this;
374 }
375
376private:
377 template <class _OtherErrQual>
378 static constexpr bool __can_assign_from_unexpected =
379 _And< is_constructible<_Err, _OtherErrQual>,
380 is_assignable<_Err&, _OtherErrQual>,
381 _Lazy<_Or,
382 is_nothrow_constructible<_Err, _OtherErrQual>,
383 is_nothrow_move_constructible<_Tp>,
384 is_nothrow_move_constructible<_Err>> >::value;
385
386public:
387 template <class _OtherErr>
388 requires(__can_assign_from_unexpected<const _OtherErr&>)
389 _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(const unexpected<_OtherErr>& __un) {
390 if (__has_val_) {
391 __reinit_expected(__union_.__unex_, __union_.__val_, __un.error());
392 __has_val_ = false;
393 } else {
394 __union_.__unex_ = __un.error();
395 }
396 return *this;
397 }
398
399 template <class _OtherErr>
400 requires(__can_assign_from_unexpected<_OtherErr>)
401 _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(unexpected<_OtherErr>&& __un) {
402 if (__has_val_) {
403 __reinit_expected(__union_.__unex_, __union_.__val_, std::move(__un.error()));
404 __has_val_ = false;
405 } else {
406 __union_.__unex_ = std::move(__un.error());
407 }
408 return *this;
409 }
410
411 template <class... _Args>
412 requires is_nothrow_constructible_v<_Tp, _Args...>
413 _LIBCPP_HIDE_FROM_ABI constexpr _Tp& emplace(_Args&&... __args) noexcept {
414 if (__has_val_) {
415 std::destroy_at(std::addressof(__union_.__val_));
416 } else {
417 std::destroy_at(std::addressof(__union_.__unex_));
418 __has_val_ = true;
419 }
420 return *std::construct_at(std::addressof(__union_.__val_), std::forward<_Args>(__args)...);
421 }
422
423 template <class _Up, class... _Args>
424 requires is_nothrow_constructible_v< _Tp, initializer_list<_Up>&, _Args... >
425 _LIBCPP_HIDE_FROM_ABI constexpr _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) noexcept {
426 if (__has_val_) {
427 std::destroy_at(std::addressof(__union_.__val_));
428 } else {
429 std::destroy_at(std::addressof(__union_.__unex_));
430 __has_val_ = true;
431 }
432 return *std::construct_at(std::addressof(__union_.__val_), __il, std::forward<_Args>(__args)...);
433 }
434
435
436public:
437 // [expected.object.swap], swap
438 _LIBCPP_HIDE_FROM_ABI constexpr void swap(expected& __rhs)
439 noexcept(is_nothrow_move_constructible_v<_Tp> &&
440 is_nothrow_swappable_v<_Tp> &&
441 is_nothrow_move_constructible_v<_Err> &&
442 is_nothrow_swappable_v<_Err>)
443 requires(is_swappable_v<_Tp> &&
444 is_swappable_v<_Err> &&
445 is_move_constructible_v<_Tp> &&
446 is_move_constructible_v<_Err> &&
447 (is_nothrow_move_constructible_v<_Tp> ||
448 is_nothrow_move_constructible_v<_Err>))
449 {
450 auto __swap_val_unex_impl = [&](expected& __with_val, expected& __with_err) {
451 if constexpr (is_nothrow_move_constructible_v<_Err>) {
452 _Err __tmp(std::move(__with_err.__union_.__unex_));
453 std::destroy_at(std::addressof(__with_err.__union_.__unex_));
454 __exception_guard __trans([&] {
455 std::construct_at(std::addressof(__with_err.__union_.__unex_), std::move(__tmp));
456 });
457 std::construct_at(std::addressof(__with_err.__union_.__val_), std::move(__with_val.__union_.__val_));
458 __trans.__complete();
459 std::destroy_at(std::addressof(__with_val.__union_.__val_));
460 std::construct_at(std::addressof(__with_val.__union_.__unex_), std::move(__tmp));
461 } else {
462 static_assert(is_nothrow_move_constructible_v<_Tp>,
463 "To provide strong exception guarantee, Tp has to satisfy `is_nothrow_move_constructible_v` so "
464 "that it can be reverted to the previous state in case an exception is thrown during swap.");
465 _Tp __tmp(std::move(__with_val.__union_.__val_));
466 std::destroy_at(std::addressof(__with_val.__union_.__val_));
467 __exception_guard __trans([&] {
468 std::construct_at(std::addressof(__with_val.__union_.__val_), std::move(__tmp));
469 });
470 std::construct_at(std::addressof(__with_val.__union_.__unex_), std::move(__with_err.__union_.__unex_));
471 __trans.__complete();
472 std::destroy_at(std::addressof(__with_err.__union_.__unex_));
473 std::construct_at(std::addressof(__with_err.__union_.__val_), std::move(__tmp));
474 }
475 __with_val.__has_val_ = false;
476 __with_err.__has_val_ = true;
477 };
478
479 if (__has_val_) {
480 if (__rhs.__has_val_) {
481 using std::swap;
482 swap(__union_.__val_, __rhs.__union_.__val_);
483 } else {
484 __swap_val_unex_impl(*this, __rhs);
485 }
486 } else {
487 if (__rhs.__has_val_) {
488 __swap_val_unex_impl(__rhs, *this);
489 } else {
490 using std::swap;
491 swap(__union_.__unex_, __rhs.__union_.__unex_);
492 }
493 }
494 }
495
496 _LIBCPP_HIDE_FROM_ABI friend constexpr void swap(expected& __x, expected& __y)
497 noexcept(noexcept(__x.swap(__y)))
498 requires requires { __x.swap(__y); }
499 {
500 __x.swap(__y);
501 }
502
503 // [expected.object.obs], observers
504 _LIBCPP_HIDE_FROM_ABI constexpr const _Tp* operator->() const noexcept {
505 _LIBCPP_ASSERT(__has_val_, "expected::operator-> requires the expected to contain a value");
506 return std::addressof(__union_.__val_);
507 }
508
509 _LIBCPP_HIDE_FROM_ABI constexpr _Tp* operator->() noexcept {
510 _LIBCPP_ASSERT(__has_val_, "expected::operator-> requires the expected to contain a value");
511 return std::addressof(__union_.__val_);
512 }
513
514 _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator*() const& noexcept {
515 _LIBCPP_ASSERT(__has_val_, "expected::operator* requires the expected to contain a value");
516 return __union_.__val_;
517 }
518
519 _LIBCPP_HIDE_FROM_ABI constexpr _Tp& operator*() & noexcept {
520 _LIBCPP_ASSERT(__has_val_, "expected::operator* requires the expected to contain a value");
521 return __union_.__val_;
522 }
523
524 _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& operator*() const&& noexcept {
525 _LIBCPP_ASSERT(__has_val_, "expected::operator* requires the expected to contain a value");
526 return std::move(__union_.__val_);
527 }
528
529 _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& operator*() && noexcept {
530 _LIBCPP_ASSERT(__has_val_, "expected::operator* requires the expected to contain a value");
531 return std::move(__union_.__val_);
532 }
533
534 _LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const noexcept { return __has_val_; }
535
536 _LIBCPP_HIDE_FROM_ABI constexpr bool has_value() const noexcept { return __has_val_; }
537
538 _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& value() const& {
539 if (!__has_val_) {
540 __expected::__throw_bad_expected_access<_Err>(__union_.__unex_);
541 }
542 return __union_.__val_;
543 }
544
545 _LIBCPP_HIDE_FROM_ABI constexpr _Tp& value() & {
546 if (!__has_val_) {
547 __expected::__throw_bad_expected_access<_Err>(__union_.__unex_);
548 }
549 return __union_.__val_;
550 }
551
552 _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& value() const&& {
553 if (!__has_val_) {
554 __expected::__throw_bad_expected_access<_Err>(std::move(__union_.__unex_));
555 }
556 return std::move(__union_.__val_);
557 }
558
559 _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& value() && {
560 if (!__has_val_) {
561 __expected::__throw_bad_expected_access<_Err>(std::move(__union_.__unex_));
562 }
563 return std::move(__union_.__val_);
564 }
565
566 _LIBCPP_HIDE_FROM_ABI constexpr const _Err& error() const& noexcept {
567 _LIBCPP_ASSERT(!__has_val_, "expected::error requires the expected to contain an error");
568 return __union_.__unex_;
569 }
570
571 _LIBCPP_HIDE_FROM_ABI constexpr _Err& error() & noexcept {
572 _LIBCPP_ASSERT(!__has_val_, "expected::error requires the expected to contain an error");
573 return __union_.__unex_;
574 }
575
576 _LIBCPP_HIDE_FROM_ABI constexpr const _Err&& error() const&& noexcept {
577 _LIBCPP_ASSERT(!__has_val_, "expected::error requires the expected to contain an error");
578 return std::move(__union_.__unex_);
579 }
580
581 _LIBCPP_HIDE_FROM_ABI constexpr _Err&& error() && noexcept {
582 _LIBCPP_ASSERT(!__has_val_, "expected::error requires the expected to contain an error");
583 return std::move(__union_.__unex_);
584 }
585
586 template <class _Up>
587 _LIBCPP_HIDE_FROM_ABI constexpr _Tp value_or(_Up&& __v) const& {
588 static_assert(is_copy_constructible_v<_Tp>, "value_type has to be copy constructible");
589 static_assert(is_convertible_v<_Up, _Tp>, "argument has to be convertible to value_type");
590 return __has_val_ ? __union_.__val_ : static_cast<_Tp>(std::forward<_Up>(__v));
591 }
592
593 template <class _Up>
594 _LIBCPP_HIDE_FROM_ABI constexpr _Tp value_or(_Up&& __v) && {
595 static_assert(is_move_constructible_v<_Tp>, "value_type has to be move constructible");
596 static_assert(is_convertible_v<_Up, _Tp>, "argument has to be convertible to value_type");
597 return __has_val_ ? std::move(__union_.__val_) : static_cast<_Tp>(std::forward<_Up>(__v));
598 }
599
600 // [expected.object.eq], equality operators
601 template <class _T2, class _E2>
602 requires(!is_void_v<_T2>)
603 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const expected<_T2, _E2>& __y) {
604 if (__x.__has_val_ != __y.__has_val_) {
605 return false;
606 } else {
607 if (__x.__has_val_) {
608 return __x.__union_.__val_ == __y.__union_.__val_;
609 } else {
610 return __x.__union_.__unex_ == __y.__union_.__unex_;
611 }
612 }
613 }
614
615 template <class _T2>
616 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const _T2& __v) {
617 return __x.__has_val_ && static_cast<bool>(__x.__union_.__val_ == __v);
618 }
619
620 template <class _E2>
621 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const unexpected<_E2>& __e) {
622 return !__x.__has_val_ && static_cast<bool>(__x.__union_.__unex_ == __e.error());
623 }
624
625private:
626 struct __empty_t {};
627 // use named union because [[no_unique_address]] cannot be applied to an unnamed union
628 _LIBCPP_NO_UNIQUE_ADDRESS union __union_t {
629 _LIBCPP_HIDE_FROM_ABI constexpr __union_t() : __empty_() {}
630
631 _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t()
632 requires(is_trivially_destructible_v<_Tp> && is_trivially_destructible_v<_Err>)
633 = default;
634
635 // the expected's destructor handles this
636 _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t()
637 requires(!is_trivially_destructible_v<_Tp> || !is_trivially_destructible_v<_Err>)
638 {}
639
640 _LIBCPP_NO_UNIQUE_ADDRESS __empty_t __empty_;
641 _LIBCPP_NO_UNIQUE_ADDRESS _Tp __val_;
642 _LIBCPP_NO_UNIQUE_ADDRESS _Err __unex_;
643 } __union_;
644
645 bool __has_val_;
646};
647
648template <class _Tp, class _Err>
649 requires is_void_v<_Tp>
650class expected<_Tp, _Err> {
651 static_assert(__valid_std_unexpected<_Err>::value,
652 "[expected.void.general] A program that instantiates expected<T, E> with a E that is not a "
653 "valid argument for unexpected<E> is ill-formed");
654
655 template <class, class>
656 friend class expected;
657
658 template <class _Up, class _OtherErr, class _OtherErrQual>
659 using __can_convert =
660 _And< is_void<_Up>,
661 is_constructible<_Err, _OtherErrQual>,
662 _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>&>>,
663 _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>>>,
664 _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>&>>,
665 _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>>>>;
666
667public:
668 using value_type = _Tp;
669 using error_type = _Err;
670 using unexpected_type = unexpected<_Err>;
671
672 template <class _Up>
673 using rebind = expected<_Up, error_type>;
674
675 // [expected.void.ctor], constructors
676 _LIBCPP_HIDE_FROM_ABI constexpr expected() noexcept : __has_val_(true) {}
677
678 _LIBCPP_HIDE_FROM_ABI constexpr expected(const expected&) = delete;
679
680 _LIBCPP_HIDE_FROM_ABI constexpr expected(const expected&)
681 requires(is_copy_constructible_v<_Err> && is_trivially_copy_constructible_v<_Err>)
682 = default;
683
684 _LIBCPP_HIDE_FROM_ABI constexpr expected(const expected& __rhs)
685 noexcept(is_nothrow_copy_constructible_v<_Err>) // strengthened
686 requires(is_copy_constructible_v<_Err> && !is_trivially_copy_constructible_v<_Err>)
687 : __has_val_(__rhs.__has_val_) {
688 if (!__rhs.__has_val_) {
689 std::construct_at(std::addressof(__union_.__unex_), __rhs.__union_.__unex_);
690 }
691 }
692
693 _LIBCPP_HIDE_FROM_ABI constexpr expected(expected&&)
694 requires(is_move_constructible_v<_Err> && is_trivially_move_constructible_v<_Err>)
695 = default;
696
697 _LIBCPP_HIDE_FROM_ABI constexpr expected(expected&& __rhs)
698 noexcept(is_nothrow_move_constructible_v<_Err>)
699 requires(is_move_constructible_v<_Err> && !is_trivially_move_constructible_v<_Err>)
700 : __has_val_(__rhs.__has_val_) {
701 if (!__rhs.__has_val_) {
702 std::construct_at(std::addressof(__union_.__unex_), std::move(__rhs.__union_.__unex_));
703 }
704 }
705
706 template <class _Up, class _OtherErr>
707 requires __can_convert<_Up, _OtherErr, const _OtherErr&>::value
708 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<const _OtherErr&, _Err>)
709 expected(const expected<_Up, _OtherErr>& __rhs)
710 noexcept(is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened
711 : __has_val_(__rhs.__has_val_) {
712 if (!__rhs.__has_val_) {
713 std::construct_at(std::addressof(__union_.__unex_), __rhs.__union_.__unex_);
714 }
715 }
716
717 template <class _Up, class _OtherErr>
718 requires __can_convert<_Up, _OtherErr, _OtherErr>::value
719 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_OtherErr, _Err>)
720 expected(expected<_Up, _OtherErr>&& __rhs)
721 noexcept(is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened
722 : __has_val_(__rhs.__has_val_) {
723 if (!__rhs.__has_val_) {
724 std::construct_at(std::addressof(__union_.__unex_), std::move(__rhs.__union_.__unex_));
725 }
726 }
727
728 template <class _OtherErr>
729 requires is_constructible_v<_Err, const _OtherErr&>
730 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<const _OtherErr&, _Err>)
731 expected(const unexpected<_OtherErr>& __unex)
732 noexcept(is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened
733 : __has_val_(false) {
734 std::construct_at(std::addressof(__union_.__unex_), __unex.error());
735 }
736
737 template <class _OtherErr>
738 requires is_constructible_v<_Err, _OtherErr>
739 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_OtherErr, _Err>)
740 expected(unexpected<_OtherErr>&& __unex)
741 noexcept(is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened
742 : __has_val_(false) {
743 std::construct_at(std::addressof(__union_.__unex_), std::move(__unex.error()));
744 }
745
746 _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(in_place_t) noexcept : __has_val_(true) {}
747
748 template <class... _Args>
749 requires is_constructible_v<_Err, _Args...>
750 _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(unexpect_t, _Args&&... __args)
751 noexcept(is_nothrow_constructible_v<_Err, _Args...>) // strengthened
752 : __has_val_(false) {
753 std::construct_at(std::addressof(__union_.__unex_), std::forward<_Args>(__args)...);
754 }
755
756 template <class _Up, class... _Args>
757 requires is_constructible_v< _Err, initializer_list<_Up>&, _Args... >
758 _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(unexpect_t, initializer_list<_Up> __il, _Args&&... __args)
759 noexcept(is_nothrow_constructible_v<_Err, initializer_list<_Up>&, _Args...>) // strengthened
760 : __has_val_(false) {
761 std::construct_at(std::addressof(__union_.__unex_), __il, std::forward<_Args>(__args)...);
762 }
763
764 // [expected.void.dtor], destructor
765
766 _LIBCPP_HIDE_FROM_ABI constexpr ~expected()
767 requires is_trivially_destructible_v<_Err>
768 = default;
769
770 _LIBCPP_HIDE_FROM_ABI constexpr ~expected()
771 requires(!is_trivially_destructible_v<_Err>)
772 {
773 if (!__has_val_) {
774 std::destroy_at(std::addressof(__union_.__unex_));
775 }
776 }
777
778 // [expected.void.assign], assignment
779
780 _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(const expected&) = delete;
781
782 _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(const expected& __rhs)
783 noexcept(is_nothrow_copy_assignable_v<_Err> && is_nothrow_copy_constructible_v<_Err>) // strengthened
784 requires(is_copy_assignable_v<_Err> && is_copy_constructible_v<_Err>)
785 {
786 if (__has_val_) {
787 if (!__rhs.__has_val_) {
788 std::construct_at(std::addressof(__union_.__unex_), __rhs.__union_.__unex_);
789 __has_val_ = false;
790 }
791 } else {
792 if (__rhs.__has_val_) {
793 std::destroy_at(std::addressof(__union_.__unex_));
794 __has_val_ = true;
795 } else {
796 __union_.__unex_ = __rhs.__union_.__unex_;
797 }
798 }
799 return *this;
800 }
801
802 _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(expected&&) = delete;
803
804 _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(expected&& __rhs)
805 noexcept(is_nothrow_move_assignable_v<_Err> &&
806 is_nothrow_move_constructible_v<_Err>)
807 requires(is_move_assignable_v<_Err> &&
808 is_move_constructible_v<_Err>)
809 {
810 if (__has_val_) {
811 if (!__rhs.__has_val_) {
812 std::construct_at(std::addressof(__union_.__unex_), std::move(__rhs.__union_.__unex_));
813 __has_val_ = false;
814 }
815 } else {
816 if (__rhs.__has_val_) {
817 std::destroy_at(std::addressof(__union_.__unex_));
818 __has_val_ = true;
819 } else {
820 __union_.__unex_ = std::move(__rhs.__union_.__unex_);
821 }
822 }
823 return *this;
824 }
825
826 template <class _OtherErr>
827 requires(is_constructible_v<_Err, const _OtherErr&> && is_assignable_v<_Err&, const _OtherErr&>)
828 _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(const unexpected<_OtherErr>& __un) {
829 if (__has_val_) {
830 std::construct_at(std::addressof(__union_.__unex_), __un.error());
831 __has_val_ = false;
832 } else {
833 __union_.__unex_ = __un.error();
834 }
835 return *this;
836 }
837
838 template <class _OtherErr>
839 requires(is_constructible_v<_Err, _OtherErr> && is_assignable_v<_Err&, _OtherErr>)
840 _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(unexpected<_OtherErr>&& __un) {
841 if (__has_val_) {
842 std::construct_at(std::addressof(__union_.__unex_), std::move(__un.error()));
843 __has_val_ = false;
844 } else {
845 __union_.__unex_ = std::move(__un.error());
846 }
847 return *this;
848 }
849
850 _LIBCPP_HIDE_FROM_ABI constexpr void emplace() noexcept {
851 if (!__has_val_) {
852 std::destroy_at(std::addressof(__union_.__unex_));
853 __has_val_ = true;
854 }
855 }
856
857 // [expected.void.swap], swap
858 _LIBCPP_HIDE_FROM_ABI constexpr void swap(expected& __rhs)
859 noexcept(is_nothrow_move_constructible_v<_Err> && is_nothrow_swappable_v<_Err>)
860 requires(is_swappable_v<_Err> && is_move_constructible_v<_Err>)
861 {
862 auto __swap_val_unex_impl = [&](expected& __with_val, expected& __with_err) {
863 std::construct_at(std::addressof(__with_val.__union_.__unex_), std::move(__with_err.__union_.__unex_));
864 std::destroy_at(std::addressof(__with_err.__union_.__unex_));
865 __with_val.__has_val_ = false;
866 __with_err.__has_val_ = true;
867 };
868
869 if (__has_val_) {
870 if (!__rhs.__has_val_) {
871 __swap_val_unex_impl(*this, __rhs);
872 }
873 } else {
874 if (__rhs.__has_val_) {
875 __swap_val_unex_impl(__rhs, *this);
876 } else {
877 using std::swap;
878 swap(__union_.__unex_, __rhs.__union_.__unex_);
879 }
880 }
881 }
882
883 _LIBCPP_HIDE_FROM_ABI friend constexpr void swap(expected& __x, expected& __y)
884 noexcept(noexcept(__x.swap(__y)))
885 requires requires { __x.swap(__y); }
886 {
887 __x.swap(__y);
888 }
889
890 // [expected.void.obs], observers
891 _LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const noexcept { return __has_val_; }
892
893 _LIBCPP_HIDE_FROM_ABI constexpr bool has_value() const noexcept { return __has_val_; }
894
895 _LIBCPP_HIDE_FROM_ABI constexpr void operator*() const noexcept {
896 _LIBCPP_ASSERT(__has_val_, "expected::operator* requires the expected to contain a value");
897 }
898
899 _LIBCPP_HIDE_FROM_ABI constexpr void value() const& {
900 if (!__has_val_) {
901 __expected::__throw_bad_expected_access<_Err>(__union_.__unex_);
902 }
903 }
904
905 _LIBCPP_HIDE_FROM_ABI constexpr void value() && {
906 if (!__has_val_) {
907 __expected::__throw_bad_expected_access<_Err>(std::move(__union_.__unex_));
908 }
909 }
910
911 _LIBCPP_HIDE_FROM_ABI constexpr const _Err& error() const& noexcept {
912 _LIBCPP_ASSERT(!__has_val_, "expected::error requires the expected to contain an error");
913 return __union_.__unex_;
914 }
915
916 _LIBCPP_HIDE_FROM_ABI constexpr _Err& error() & noexcept {
917 _LIBCPP_ASSERT(!__has_val_, "expected::error requires the expected to contain an error");
918 return __union_.__unex_;
919 }
920
921 _LIBCPP_HIDE_FROM_ABI constexpr const _Err&& error() const&& noexcept {
922 _LIBCPP_ASSERT(!__has_val_, "expected::error requires the expected to contain an error");
923 return std::move(__union_.__unex_);
924 }
925
926 _LIBCPP_HIDE_FROM_ABI constexpr _Err&& error() && noexcept {
927 _LIBCPP_ASSERT(!__has_val_, "expected::error requires the expected to contain an error");
928 return std::move(__union_.__unex_);
929 }
930
931 // [expected.void.eq], equality operators
932 template <class _T2, class _E2>
933 requires is_void_v<_T2>
934 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const expected<_T2, _E2>& __y) {
935 if (__x.__has_val_ != __y.__has_val_) {
936 return false;
937 } else {
938 return __x.__has_val_ || static_cast<bool>(__x.__union_.__unex_ == __y.__union_.__unex_);
939 }
940 }
941
942 template <class _E2>
943 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const unexpected<_E2>& __y) {
944 return !__x.__has_val_ && static_cast<bool>(__x.__union_.__unex_ == __y.error());
945 }
946
947private:
948 struct __empty_t {};
949 // use named union because [[no_unique_address]] cannot be applied to an unnamed union
950 _LIBCPP_NO_UNIQUE_ADDRESS union __union_t {
951 _LIBCPP_HIDE_FROM_ABI constexpr __union_t() : __empty_() {}
952
953 _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t()
954 requires(is_trivially_destructible_v<_Err>)
955 = default;
956
957 // the expected's destructor handles this
958 _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t()
959 requires(!is_trivially_destructible_v<_Err>)
960 {}
961
962 _LIBCPP_NO_UNIQUE_ADDRESS __empty_t __empty_;
963 _LIBCPP_NO_UNIQUE_ADDRESS _Err __unex_;
964 } __union_;
965
966 bool __has_val_;
967};
968
969_LIBCPP_END_NAMESPACE_STD
970
971#endif // _LIBCPP_STD_VER >= 23
972
973#endif // _LIBCPP___EXPECTED_EXPECTED_H
lib/libcxx/include/__expected/unexpect.h created+32
......@@ -0,0 +1,32 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9#ifndef _LIBCPP___EXPECTED_UNEXPECT_H
10#define _LIBCPP___EXPECTED_UNEXPECT_H
11
12#include <__config>
13
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# pragma GCC system_header
16#endif
17
18#if _LIBCPP_STD_VER >= 23
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22struct unexpect_t {
23 _LIBCPP_HIDE_FROM_ABI explicit unexpect_t() = default;
24};
25
26inline constexpr unexpect_t unexpect{};
27
28_LIBCPP_END_NAMESPACE_STD
29
30#endif // _LIBCPP_STD_VER >= 23
31
32#endif // _LIBCPP___EXPECTED_UNEXPECT_H
lib/libcxx/include/__expected/unexpected.h created+122
......@@ -0,0 +1,122 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9#ifndef _LIBCPP___EXPECTED_UNEXPECTED_H
10#define _LIBCPP___EXPECTED_UNEXPECTED_H
11
12#include <__config>
13#include <__type_traits/conjunction.h>
14#include <__type_traits/is_array.h>
15#include <__type_traits/is_const.h>
16#include <__type_traits/is_constructible.h>
17#include <__type_traits/is_nothrow_constructible.h>
18#include <__type_traits/is_object.h>
19#include <__type_traits/is_same.h>
20#include <__type_traits/is_swappable.h>
21#include <__type_traits/is_volatile.h>
22#include <__type_traits/negation.h>
23#include <__type_traits/remove_cvref.h>
24#include <__utility/forward.h>
25#include <__utility/in_place.h>
26#include <__utility/move.h>
27#include <__utility/swap.h>
28#include <initializer_list>
29
30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
31# pragma GCC system_header
32#endif
33
34#if _LIBCPP_STD_VER >= 23
35
36_LIBCPP_BEGIN_NAMESPACE_STD
37
38template <class _Err>
39class unexpected;
40
41template <class _Tp>
42struct __is_std_unexpected : false_type {};
43
44template <class _Err>
45struct __is_std_unexpected<unexpected<_Err>> : true_type {};
46
47template <class _Tp>
48using __valid_std_unexpected = _BoolConstant< //
49 is_object_v<_Tp> && //
50 !is_array_v<_Tp> && //
51 !__is_std_unexpected<_Tp>::value && //
52 !is_const_v<_Tp> && //
53 !is_volatile_v<_Tp> //
54 >;
55
56template <class _Err>
57class unexpected {
58 static_assert(__valid_std_unexpected<_Err>::value,
59 "[expected.un.general] states a program that instantiates std::unexpected for a non-object type, an "
60 "array type, a specialization of unexpected, or a cv-qualified type is ill-formed.");
61
62public:
63 _LIBCPP_HIDE_FROM_ABI constexpr unexpected(const unexpected&) = default;
64 _LIBCPP_HIDE_FROM_ABI constexpr unexpected(unexpected&&) = default;
65
66 template <class _Error = _Err>
67 requires(!is_same_v<remove_cvref_t<_Error>, unexpected> && //
68 !is_same_v<remove_cvref_t<_Error>, in_place_t> && //
69 is_constructible_v<_Err, _Error>)
70 _LIBCPP_HIDE_FROM_ABI constexpr explicit unexpected(_Error&& __error) //
71 noexcept(is_nothrow_constructible_v<_Err, _Error>) // strengthened
72 : __unex_(std::forward<_Error>(__error)) {}
73
74 template <class... _Args>
75 requires is_constructible_v<_Err, _Args...>
76 _LIBCPP_HIDE_FROM_ABI constexpr explicit unexpected(in_place_t, _Args&&... __args) //
77 noexcept(is_nothrow_constructible_v<_Err, _Args...>) // strengthened
78 : __unex_(std::forward<_Args>(__args)...) {}
79
80 template <class _Up, class... _Args>
81 requires is_constructible_v<_Err, initializer_list<_Up>&, _Args...>
82 _LIBCPP_HIDE_FROM_ABI constexpr explicit unexpected(in_place_t, initializer_list<_Up> __il, _Args&&... __args) //
83 noexcept(is_nothrow_constructible_v<_Err, initializer_list<_Up>&, _Args...>) // strengthened
84 : __unex_(__il, std::forward<_Args>(__args)...) {}
85
86 _LIBCPP_HIDE_FROM_ABI constexpr unexpected& operator=(const unexpected&) = default;
87 _LIBCPP_HIDE_FROM_ABI constexpr unexpected& operator=(unexpected&&) = default;
88
89 _LIBCPP_HIDE_FROM_ABI constexpr const _Err& error() const& noexcept { return __unex_; }
90 _LIBCPP_HIDE_FROM_ABI constexpr _Err& error() & noexcept { return __unex_; }
91 _LIBCPP_HIDE_FROM_ABI constexpr const _Err&& error() const&& noexcept { return std::move(__unex_); }
92 _LIBCPP_HIDE_FROM_ABI constexpr _Err&& error() && noexcept { return std::move(__unex_); }
93
94 _LIBCPP_HIDE_FROM_ABI constexpr void swap(unexpected& __other) noexcept(is_nothrow_swappable_v<_Err>) {
95 static_assert(is_swappable_v<_Err>, "unexpected::swap requires is_swappable_v<E> to be true");
96 using std::swap;
97 swap(__unex_, __other.__unex_);
98 }
99
100 _LIBCPP_HIDE_FROM_ABI friend constexpr void swap(unexpected& __x, unexpected& __y) noexcept(noexcept(__x.swap(__y)))
101 requires is_swappable_v<_Err>
102 {
103 __x.swap(__y);
104 }
105
106 template <class _Err2>
107 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const unexpected& __x, const unexpected<_Err2>& __y) {
108 return __x.__unex_ == __y.__unex_;
109 }
110
111private:
112 _Err __unex_;
113};
114
115template <class _Err>
116unexpected(_Err) -> unexpected<_Err>;
117
118_LIBCPP_END_NAMESPACE_STD
119
120#endif // _LIBCPP_STD_VER >= 23
121
122#endif // _LIBCPP___EXPECTED_UNEXPECTED_H
lib/libcxx/include/__filesystem/directory_entry.h+15-4
......@@ -215,21 +215,23 @@ public:
215215 return __get_symlink_status(&__ec);
216216 }
217217
218 _LIBCPP_INLINE_VISIBILITY
219 bool operator<(directory_entry const& __rhs) const noexcept {
220 return __p_ < __rhs.__p_;
221 }
222218
223219 _LIBCPP_INLINE_VISIBILITY
224220 bool operator==(directory_entry const& __rhs) const noexcept {
225221 return __p_ == __rhs.__p_;
226222 }
227223
224#if _LIBCPP_STD_VER <= 17
228225 _LIBCPP_INLINE_VISIBILITY
229226 bool operator!=(directory_entry const& __rhs) const noexcept {
230227 return __p_ != __rhs.__p_;
231228 }
232229
230 _LIBCPP_INLINE_VISIBILITY
231 bool operator<(directory_entry const& __rhs) const noexcept {
232 return __p_ < __rhs.__p_;
233 }
234
233235 _LIBCPP_INLINE_VISIBILITY
234236 bool operator<=(directory_entry const& __rhs) const noexcept {
235237 return __p_ <= __rhs.__p_;
......@@ -245,6 +247,15 @@ public:
245247 return __p_ >= __rhs.__p_;
246248 }
247249
250#else // _LIBCPP_STD_VER <= 17
251
252 _LIBCPP_HIDE_FROM_ABI
253 strong_ordering operator<=>(const directory_entry& __rhs) const noexcept {
254 return __p_ <=> __rhs.__p_;
255 }
256
257#endif // _LIBCPP_STD_VER <= 17
258
248259 template <class _CharT, class _Traits>
249260 _LIBCPP_INLINE_VISIBILITY
250261 friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const directory_entry& __d) {
lib/libcxx/include/__filesystem/filesystem_error.h+2-1
......@@ -14,6 +14,7 @@
1414#include <__config>
1515#include <__filesystem/path.h>
1616#include <__memory/shared_ptr.h>
17#include <__utility/forward.h>
1718#include <iosfwd>
1819#include <new>
1920#include <system_error>
......@@ -60,7 +61,7 @@ public:
6061 filesystem_error(const filesystem_error&) = default;
6162 ~filesystem_error() override; // key function
6263
63 _LIBCPP_INLINE_VISIBILITY
64 _LIBCPP_HIDE_FROM_ABI_VIRTUAL
6465 const char* what() const noexcept override {
6566 return __storage_->__what_.c_str();
6667 }
lib/libcxx/include/__filesystem/path.h+37-30
......@@ -141,15 +141,15 @@ struct __is_pathable_string<
141141
142142template <class _Source, class _DS = typename decay<_Source>::type,
143143 class _UnqualPtrType =
144 typename remove_const<typename remove_pointer<_DS>::type>::type,
144 __remove_const_t<__remove_pointer_t<_DS> >,
145145 bool _IsCharPtr = is_pointer<_DS>::value&&
146146 __can_convert_char<_UnqualPtrType>::value>
147147struct __is_pathable_char_array : false_type {};
148148
149149template <class _Source, class _ECharT, class _UPtr>
150150struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true>
151 : __can_convert_char<typename remove_const<_ECharT>::type> {
152 using _Base = __can_convert_char<typename remove_const<_ECharT>::type>;
151 : __can_convert_char<__remove_const_t<_ECharT> > {
152 using _Base = __can_convert_char<__remove_const_t<_ECharT> >;
153153
154154 _LIBCPP_HIDE_FROM_ABI
155155 static _ECharT const* __range_begin(const _ECharT* __b) { return __b; }
......@@ -619,7 +619,7 @@ public:
619619 _EnableIfPathable<_Source> append(const _Source& __src) {
620620 using _Traits = __is_pathable<_Source>;
621621 using _CVT = _PathCVT<_SourceChar<_Source> >;
622 bool __source_is_absolute = __is_separator(_Traits::__first_or_null(__src));
622 bool __source_is_absolute = _VSTD_FS::__is_separator(_Traits::__first_or_null(__src));
623623 if (__source_is_absolute)
624624 __pn_.clear();
625625 else if (has_filename())
......@@ -634,7 +634,7 @@ public:
634634 typedef typename iterator_traits<_InputIt>::value_type _ItVal;
635635 static_assert(__can_convert_char<_ItVal>::value, "Must convertible");
636636 using _CVT = _PathCVT<_ItVal>;
637 if (__first != __last && __is_separator(*__first))
637 if (__first != __last && _VSTD_FS::__is_separator(*__first))
638638 __pn_.clear();
639639 else if (has_filename())
640640 __pn_ += preferred_separator;
......@@ -732,6 +732,37 @@ public:
732732
733733 path& replace_extension(const path& __replacement = path());
734734
735 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const path& __lhs, const path& __rhs) noexcept {
736 return __lhs.__compare(__rhs.__pn_) == 0;
737 }
738# if _LIBCPP_STD_VER <= 17
739 friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const path& __lhs, const path& __rhs) noexcept {
740 return __lhs.__compare(__rhs.__pn_) != 0;
741 }
742 friend _LIBCPP_HIDE_FROM_ABI bool operator<(const path& __lhs, const path& __rhs) noexcept {
743 return __lhs.__compare(__rhs.__pn_) < 0;
744 }
745 friend _LIBCPP_HIDE_FROM_ABI bool operator<=(const path& __lhs, const path& __rhs) noexcept {
746 return __lhs.__compare(__rhs.__pn_) <= 0;
747 }
748 friend _LIBCPP_HIDE_FROM_ABI bool operator>(const path& __lhs, const path& __rhs) noexcept {
749 return __lhs.__compare(__rhs.__pn_) > 0;
750 }
751 friend _LIBCPP_HIDE_FROM_ABI bool operator>=(const path& __lhs, const path& __rhs) noexcept {
752 return __lhs.__compare(__rhs.__pn_) >= 0;
753 }
754# else // _LIBCPP_STD_VER <= 17
755 friend _LIBCPP_HIDE_FROM_ABI strong_ordering operator<=>(const path& __lhs, const path& __rhs) noexcept {
756 return __lhs.__compare(__rhs.__pn_) <=> 0;
757 }
758# endif // _LIBCPP_STD_VER <= 17
759
760 friend _LIBCPP_HIDE_FROM_ABI path operator/(const path& __lhs, const path& __rhs) {
761 path __result(__lhs);
762 __result /= __rhs;
763 return __result;
764 }
765
735766 _LIBCPP_HIDE_FROM_ABI
736767 void swap(path& __rhs) noexcept { __pn_.swap(__rhs.__pn_); }
737768
......@@ -835,7 +866,7 @@ public:
835866 using _Str = basic_string<_ECharT, _Traits, _Allocator>;
836867 _Str __s(__a);
837868 __s.reserve(__pn_.size());
838 _CVT()(back_inserter(__s), __pn_.data(), __pn_.data() + __pn_.size());
869 _CVT()(std::back_inserter(__s), __pn_.data(), __pn_.data() + __pn_.size());
839870 return __s;
840871 }
841872
......@@ -1035,30 +1066,6 @@ public:
10351066 }
10361067#endif // !_LIBCPP_HAS_NO_LOCALIZATION
10371068
1038 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const path& __lhs, const path& __rhs) noexcept {
1039 return __lhs.__compare(__rhs.__pn_) == 0;
1040 }
1041 friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const path& __lhs, const path& __rhs) noexcept {
1042 return __lhs.__compare(__rhs.__pn_) != 0;
1043 }
1044 friend _LIBCPP_HIDE_FROM_ABI bool operator<(const path& __lhs, const path& __rhs) noexcept {
1045 return __lhs.__compare(__rhs.__pn_) < 0;
1046 }
1047 friend _LIBCPP_HIDE_FROM_ABI bool operator<=(const path& __lhs, const path& __rhs) noexcept {
1048 return __lhs.__compare(__rhs.__pn_) <= 0;
1049 }
1050 friend _LIBCPP_HIDE_FROM_ABI bool operator>(const path& __lhs, const path& __rhs) noexcept {
1051 return __lhs.__compare(__rhs.__pn_) > 0;
1052 }
1053 friend _LIBCPP_HIDE_FROM_ABI bool operator>=(const path& __lhs, const path& __rhs) noexcept {
1054 return __lhs.__compare(__rhs.__pn_) >= 0;
1055 }
1056
1057 friend _LIBCPP_HIDE_FROM_ABI path operator/(const path& __lhs, const path& __rhs) {
1058 path __result(__lhs);
1059 __result /= __rhs;
1060 return __result;
1061 }
10621069private:
10631070 inline _LIBCPP_HIDE_FROM_ABI path&
10641071 __assign_view(__string_view const& __s) noexcept {
lib/libcxx/include/__filesystem/space_info.h+4
......@@ -28,6 +28,10 @@ struct _LIBCPP_TYPE_VIS space_info {
2828 uintmax_t capacity;
2929 uintmax_t free;
3030 uintmax_t available;
31
32# if _LIBCPP_STD_VER > 17
33 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const space_info&, const space_info&) = default;
34# endif
3135};
3236
3337_LIBCPP_AVAILABILITY_FILESYSTEM_POP
lib/libcxx/include/__format/buffer.h+283-79
......@@ -11,22 +11,27 @@
1111#define _LIBCPP___FORMAT_BUFFER_H
1212
1313#include <__algorithm/copy_n.h>
14#include <__algorithm/fill_n.h>
1415#include <__algorithm/max.h>
1516#include <__algorithm/min.h>
17#include <__algorithm/ranges_copy_n.h>
18#include <__algorithm/transform.h>
1619#include <__algorithm/unwrap_iter.h>
20#include <__concepts/same_as.h>
1721#include <__config>
22#include <__format/concepts.h>
1823#include <__format/enable_insertable.h>
1924#include <__format/format_to_n_result.h>
20#include <__format/formatter.h> // for __char_type TODO FMT Move the concept?
2125#include <__iterator/back_insert_iterator.h>
2226#include <__iterator/concepts.h>
2327#include <__iterator/incrementable_traits.h>
2428#include <__iterator/iterator_traits.h>
2529#include <__iterator/wrap_iter.h>
2630#include <__utility/move.h>
27#include <concepts>
2831#include <cstddef>
32#include <string_view>
2933#include <type_traits>
34#include <vector>
3035
3136#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3237# pragma GCC system_header
......@@ -46,41 +51,125 @@ namespace __format {
4651/// This helper is used together with the @ref back_insert_iterator to offer
4752/// type-erasure for the formatting functions. This reduces the number to
4853/// template instantiations.
49template <__formatter::__char_type _CharT>
54template <__fmt_char_type _CharT>
5055class _LIBCPP_TEMPLATE_VIS __output_buffer {
5156public:
5257 using value_type = _CharT;
5358
5459 template <class _Tp>
55 _LIBCPP_HIDE_FROM_ABI explicit __output_buffer(_CharT* __ptr,
56 size_t __capacity, _Tp* __obj)
57 : __ptr_(__ptr), __capacity_(__capacity),
58 __flush_([](_CharT* __p, size_t __size, void* __o) {
59 static_cast<_Tp*>(__o)->flush(__p, __size);
60 }),
60 _LIBCPP_HIDE_FROM_ABI explicit __output_buffer(_CharT* __ptr, size_t __capacity, _Tp* __obj)
61 : __ptr_(__ptr),
62 __capacity_(__capacity),
63 __flush_([](_CharT* __p, size_t __n, void* __o) { static_cast<_Tp*>(__o)->__flush(__p, __n); }),
6164 __obj_(__obj) {}
6265
63 _LIBCPP_HIDE_FROM_ABI void reset(_CharT* __ptr, size_t __capacity) {
66 _LIBCPP_HIDE_FROM_ABI void __reset(_CharT* __ptr, size_t __capacity) {
6467 __ptr_ = __ptr;
6568 __capacity_ = __capacity;
6669 }
6770
68 _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() {
69 return back_insert_iterator{*this};
70 }
71 _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return std::back_insert_iterator{*this}; }
7172
72 // TODO FMT It would be nice to have an overload taking a
73 // basic_string_view<_CharT> and append it directly.
73 // Used in std::back_insert_iterator.
7474 _LIBCPP_HIDE_FROM_ABI void push_back(_CharT __c) {
7575 __ptr_[__size_++] = __c;
7676
7777 // Profiling showed flushing after adding is more efficient than flushing
7878 // when entering the function.
7979 if (__size_ == __capacity_)
80 flush();
80 __flush();
81 }
82
83 /// Copies the input __str to the buffer.
84 ///
85 /// Since some of the input is generated by std::to_chars, there needs to be a
86 /// conversion when _CharT is wchar_t.
87 template <__fmt_char_type _InCharT>
88 _LIBCPP_HIDE_FROM_ABI void __copy(basic_string_view<_InCharT> __str) {
89 // When the underlying iterator is a simple iterator the __capacity_ is
90 // infinite. For a string or container back_inserter it isn't. This means
91 // adding a large string the the buffer can cause some overhead. In that
92 // case a better approach could be:
93 // - flush the buffer
94 // - container.append(__str.begin(), __str.end());
95 // The same holds true for the fill.
96 // For transform it might be slightly harder, however the use case for
97 // transform is slightly less common; it converts hexadecimal values to
98 // upper case. For integral these strings are short.
99 // TODO FMT Look at the improvements above.
100 size_t __n = __str.size();
101
102 __flush_on_overflow(__n);
103 if (__n <= __capacity_) {
104 _VSTD::copy_n(__str.data(), __n, _VSTD::addressof(__ptr_[__size_]));
105 __size_ += __n;
106 return;
107 }
108
109 // The output doesn't fit in the internal buffer.
110 // Copy the data in "__capacity_" sized chunks.
111 _LIBCPP_ASSERT(__size_ == 0, "the buffer should be flushed by __flush_on_overflow");
112 const _InCharT* __first = __str.data();
113 do {
114 size_t __chunk = _VSTD::min(__n, __capacity_);
115 _VSTD::copy_n(__first, __chunk, _VSTD::addressof(__ptr_[__size_]));
116 __size_ = __chunk;
117 __first += __chunk;
118 __n -= __chunk;
119 __flush();
120 } while (__n);
121 }
122
123 /// A std::transform wrapper.
124 ///
125 /// Like @ref __copy it may need to do type conversion.
126 template <__fmt_char_type _InCharT, class _UnaryOperation>
127 _LIBCPP_HIDE_FROM_ABI void __transform(const _InCharT* __first, const _InCharT* __last, _UnaryOperation __operation) {
128 _LIBCPP_ASSERT(__first <= __last, "not a valid range");
129
130 size_t __n = static_cast<size_t>(__last - __first);
131 __flush_on_overflow(__n);
132 if (__n <= __capacity_) {
133 _VSTD::transform(__first, __last, _VSTD::addressof(__ptr_[__size_]), _VSTD::move(__operation));
134 __size_ += __n;
135 return;
136 }
137
138 // The output doesn't fit in the internal buffer.
139 // Transform the data in "__capacity_" sized chunks.
140 _LIBCPP_ASSERT(__size_ == 0, "the buffer should be flushed by __flush_on_overflow");
141 do {
142 size_t __chunk = _VSTD::min(__n, __capacity_);
143 _VSTD::transform(__first, __first + __chunk, _VSTD::addressof(__ptr_[__size_]), __operation);
144 __size_ = __chunk;
145 __first += __chunk;
146 __n -= __chunk;
147 __flush();
148 } while (__n);
149 }
150
151 /// A \c fill_n wrapper.
152 _LIBCPP_HIDE_FROM_ABI void __fill(size_t __n, _CharT __value) {
153 __flush_on_overflow(__n);
154 if (__n <= __capacity_) {
155 _VSTD::fill_n(_VSTD::addressof(__ptr_[__size_]), __n, __value);
156 __size_ += __n;
157 return;
158 }
159
160 // The output doesn't fit in the internal buffer.
161 // Fill the buffer in "__capacity_" sized chunks.
162 _LIBCPP_ASSERT(__size_ == 0, "the buffer should be flushed by __flush_on_overflow");
163 do {
164 size_t __chunk = _VSTD::min(__n, __capacity_);
165 _VSTD::fill_n(_VSTD::addressof(__ptr_[__size_]), __chunk, __value);
166 __size_ = __chunk;
167 __n -= __chunk;
168 __flush();
169 } while (__n);
81170 }
82171
83 _LIBCPP_HIDE_FROM_ABI void flush() {
172 _LIBCPP_HIDE_FROM_ABI void __flush() {
84173 __flush_(__ptr_, __size_, __obj_);
85174 __size_ = 0;
86175 }
......@@ -91,16 +180,54 @@ private:
91180 size_t __size_{0};
92181 void (*__flush_)(_CharT*, size_t, void*);
93182 void* __obj_;
183
184 /// Flushes the buffer when the output operation would overflow the buffer.
185 ///
186 /// A simple approach for the overflow detection would be something along the
187 /// lines:
188 /// \code
189 /// // The internal buffer is large enough.
190 /// if (__n <= __capacity_) {
191 /// // Flush when we really would overflow.
192 /// if (__size_ + __n >= __capacity_)
193 /// __flush();
194 /// ...
195 /// }
196 /// \endcode
197 ///
198 /// This approach works for all cases but one:
199 /// A __format_to_n_buffer_base where \ref __enable_direct_output is true.
200 /// In that case the \ref __capacity_ of the buffer changes during the first
201 /// \ref __flush. During that operation the output buffer switches from its
202 /// __writer_ to its __storage_. The \ref __capacity_ of the former depends
203 /// on the value of n, of the latter is a fixed size. For example:
204 /// - a format_to_n call with a 10'000 char buffer,
205 /// - the buffer is filled with 9'500 chars,
206 /// - adding 1'000 elements would overflow the buffer so the buffer gets
207 /// changed and the \ref __capacity_ decreases from 10'000 to
208 /// __buffer_size (256 at the time of writing).
209 ///
210 /// This means that the \ref __flush for this class may need to copy a part of
211 /// the internal buffer to the proper output. In this example there will be
212 /// 500 characters that need this copy operation.
213 ///
214 /// Note it would be more efficient to write 500 chars directly and then swap
215 /// the buffers. This would make the code more complex and \ref format_to_n is
216 /// not the most common use case. Therefore the optimization isn't done.
217 _LIBCPP_HIDE_FROM_ABI void __flush_on_overflow(size_t __n) {
218 if (__size_ + __n >= __capacity_)
219 __flush();
220 }
94221};
95222
96223/// A storage using an internal buffer.
97224///
98225/// This storage is used when writing a single element to the output iterator
99226/// is expensive.
100template <__formatter::__char_type _CharT>
227template <__fmt_char_type _CharT>
101228class _LIBCPP_TEMPLATE_VIS __internal_storage {
102229public:
103 _LIBCPP_HIDE_FROM_ABI _CharT* begin() { return __buffer_; }
230 _LIBCPP_HIDE_FROM_ABI _CharT* __begin() { return __buffer_; }
104231
105232 static constexpr size_t __buffer_size = 256 / sizeof(_CharT);
106233
......@@ -113,11 +240,11 @@ private:
113240/// This requires the storage to be a contiguous buffer of \a _CharT.
114241/// Since the output is directly written to the underlying storage this class
115242/// is just an empty class.
116template <__formatter::__char_type _CharT>
243template <__fmt_char_type _CharT>
117244class _LIBCPP_TEMPLATE_VIS __direct_storage {};
118245
119246template <class _OutIt, class _CharT>
120concept __enable_direct_output = __formatter::__char_type<_CharT> &&
247concept __enable_direct_output = __fmt_char_type<_CharT> &&
121248 (same_as<_OutIt, _CharT*>
122249#ifndef _LIBCPP_ENABLE_DEBUG_MODE
123250 || same_as<_OutIt, __wrap_iter<_CharT*>>
......@@ -125,18 +252,18 @@ concept __enable_direct_output = __formatter::__char_type<_CharT> &&
125252 );
126253
127254/// Write policy for directly writing to the underlying output.
128template <class _OutIt, __formatter::__char_type _CharT>
255template <class _OutIt, __fmt_char_type _CharT>
129256class _LIBCPP_TEMPLATE_VIS __writer_direct {
130257public:
131258 _LIBCPP_HIDE_FROM_ABI explicit __writer_direct(_OutIt __out_it)
132259 : __out_it_(__out_it) {}
133260
134 _LIBCPP_HIDE_FROM_ABI auto out() { return __out_it_; }
261 _LIBCPP_HIDE_FROM_ABI _OutIt __out_it() { return __out_it_; }
135262
136 _LIBCPP_HIDE_FROM_ABI void flush(_CharT*, size_t __size) {
263 _LIBCPP_HIDE_FROM_ABI void __flush(_CharT*, size_t __n) {
137264 // _OutIt can be a __wrap_iter<CharT*>. Therefore the original iterator
138265 // is adjusted.
139 __out_it_ += __size;
266 __out_it_ += __n;
140267 }
141268
142269private:
......@@ -144,16 +271,16 @@ private:
144271};
145272
146273/// Write policy for copying the buffer to the output.
147template <class _OutIt, __formatter::__char_type _CharT>
274template <class _OutIt, __fmt_char_type _CharT>
148275class _LIBCPP_TEMPLATE_VIS __writer_iterator {
149276public:
150277 _LIBCPP_HIDE_FROM_ABI explicit __writer_iterator(_OutIt __out_it)
151278 : __out_it_{_VSTD::move(__out_it)} {}
152279
153 _LIBCPP_HIDE_FROM_ABI auto out() { return __out_it_; }
280 _LIBCPP_HIDE_FROM_ABI _OutIt __out_it() && { return std::move(__out_it_); }
154281
155 _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) {
156 __out_it_ = _VSTD::copy_n(__ptr, __size, _VSTD::move(__out_it_));
282 _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) {
283 __out_it_ = std::ranges::copy_n(__ptr, __n, std::move(__out_it_)).out;
157284 }
158285
159286private:
......@@ -169,7 +296,7 @@ private:
169296/// \ref __enable_insertable.
170297template <class _Container>
171298concept __insertable =
172 __enable_insertable<_Container> && __formatter::__char_type<typename _Container::value_type> &&
299 __enable_insertable<_Container> && __fmt_char_type<typename _Container::value_type> &&
173300 requires(_Container& __t, add_pointer_t<typename _Container::value_type> __first,
174301 add_pointer_t<typename _Container::value_type> __last) { __t.insert(__t.end(), __first, __last); };
175302
......@@ -193,10 +320,10 @@ public:
193320 _LIBCPP_HIDE_FROM_ABI explicit __writer_container(back_insert_iterator<_Container> __out_it)
194321 : __container_{__out_it.__get_container()} {}
195322
196 _LIBCPP_HIDE_FROM_ABI auto out() { return back_inserter(*__container_); }
323 _LIBCPP_HIDE_FROM_ABI auto __out_it() { return std::back_inserter(*__container_); }
197324
198 _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) {
199 __container_->insert(__container_->end(), __ptr, __ptr + __size);
325 _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) {
326 __container_->insert(__container_->end(), __ptr, __ptr + __n);
200327 }
201328
202329private:
......@@ -215,7 +342,7 @@ public:
215342};
216343
217344/// The generic formatting buffer.
218template <class _OutIt, __formatter::__char_type _CharT>
345template <class _OutIt, __fmt_char_type _CharT>
219346requires(output_iterator<_OutIt, const _CharT&>) class _LIBCPP_TEMPLATE_VIS
220347 __format_buffer {
221348 using _Storage =
......@@ -225,24 +352,20 @@ requires(output_iterator<_OutIt, const _CharT&>) class _LIBCPP_TEMPLATE_VIS
225352public:
226353 _LIBCPP_HIDE_FROM_ABI explicit __format_buffer(_OutIt __out_it)
227354 requires(same_as<_Storage, __internal_storage<_CharT>>)
228 : __output_(__storage_.begin(), __storage_.__buffer_size, this), __writer_(_VSTD::move(__out_it)) {}
355 : __output_(__storage_.__begin(), __storage_.__buffer_size, this), __writer_(_VSTD::move(__out_it)) {}
229356
230357 _LIBCPP_HIDE_FROM_ABI explicit __format_buffer(_OutIt __out_it) requires(
231358 same_as<_Storage, __direct_storage<_CharT>>)
232359 : __output_(_VSTD::__unwrap_iter(__out_it), size_t(-1), this),
233360 __writer_(_VSTD::move(__out_it)) {}
234361
235 _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() {
236 return __output_.make_output_iterator();
237 }
362 _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return __output_.__make_output_iterator(); }
238363
239 _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) {
240 __writer_.flush(__ptr, __size);
241 }
364 _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) { __writer_.__flush(__ptr, __n); }
242365
243 _LIBCPP_HIDE_FROM_ABI _OutIt out() && {
244 __output_.flush();
245 return _VSTD::move(__writer_).out();
366 _LIBCPP_HIDE_FROM_ABI _OutIt __out_it() && {
367 __output_.__flush();
368 return _VSTD::move(__writer_).__out_it();
246369 }
247370
248371private:
......@@ -255,46 +378,46 @@ private:
255378///
256379/// Since \ref formatted_size only needs to know the size, the output itself is
257380/// discarded.
258template <__formatter::__char_type _CharT>
381template <__fmt_char_type _CharT>
259382class _LIBCPP_TEMPLATE_VIS __formatted_size_buffer {
260383public:
261 _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() { return __output_.make_output_iterator(); }
384 _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return __output_.__make_output_iterator(); }
262385
263 _LIBCPP_HIDE_FROM_ABI void flush(const _CharT*, size_t __size) { __size_ += __size; }
386 _LIBCPP_HIDE_FROM_ABI void __flush(const _CharT*, size_t __n) { __size_ += __n; }
264387
265 _LIBCPP_HIDE_FROM_ABI size_t result() && {
266 __output_.flush();
388 _LIBCPP_HIDE_FROM_ABI size_t __result() && {
389 __output_.__flush();
267390 return __size_;
268391 }
269392
270393private:
271394 __internal_storage<_CharT> __storage_;
272 __output_buffer<_CharT> __output_{__storage_.begin(), __storage_.__buffer_size, this};
395 __output_buffer<_CharT> __output_{__storage_.__begin(), __storage_.__buffer_size, this};
273396 size_t __size_{0};
274397};
275398
276399/// The base of a buffer that counts and limits the number of insertions.
277template <class _OutIt, __formatter::__char_type _CharT, bool>
400template <class _OutIt, __fmt_char_type _CharT, bool>
278401 requires(output_iterator<_OutIt, const _CharT&>)
279402struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer_base {
280403 using _Size = iter_difference_t<_OutIt>;
281404
282405public:
283 _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __n)
284 : __writer_(_VSTD::move(__out_it)), __n_(_VSTD::max(_Size(0), __n)) {}
406 _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __max_size)
407 : __writer_(_VSTD::move(__out_it)), __max_size_(_VSTD::max(_Size(0), __max_size)) {}
285408
286 _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) {
287 if (_Size(__size_) <= __n_)
288 __writer_.flush(__ptr, _VSTD::min(_Size(__size), __n_ - __size_));
289 __size_ += __size;
409 _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) {
410 if (_Size(__size_) <= __max_size_)
411 __writer_.__flush(__ptr, _VSTD::min(_Size(__n), __max_size_ - __size_));
412 __size_ += __n;
290413 }
291414
292415protected:
293416 __internal_storage<_CharT> __storage_;
294 __output_buffer<_CharT> __output_{__storage_.begin(), __storage_.__buffer_size, this};
417 __output_buffer<_CharT> __output_{__storage_.__begin(), __storage_.__buffer_size, this};
295418 typename __writer_selector<_OutIt, _CharT>::type __writer_;
296419
297 _Size __n_;
420 _Size __max_size_;
298421 _Size __size_{0};
299422};
300423
......@@ -302,35 +425,46 @@ protected:
302425///
303426/// This version is used when \c __enable_direct_output<_OutIt, _CharT> == true.
304427///
305/// This class limits the size available the the direct writer so it will not
428/// This class limits the size available to the direct writer so it will not
306429/// exceed the maximum number of code units.
307template <class _OutIt, __formatter::__char_type _CharT>
430template <class _OutIt, __fmt_char_type _CharT>
308431 requires(output_iterator<_OutIt, const _CharT&>)
309432class _LIBCPP_TEMPLATE_VIS __format_to_n_buffer_base<_OutIt, _CharT, true> {
310433 using _Size = iter_difference_t<_OutIt>;
311434
312435public:
313 _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __n)
314 : __output_(_VSTD::__unwrap_iter(__out_it), __n, this), __writer_(_VSTD::move(__out_it)) {
315 if (__n <= 0) [[unlikely]]
316 __output_.reset(__storage_.begin(), __storage_.__buffer_size);
436 _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __max_size)
437 : __output_(_VSTD::__unwrap_iter(__out_it), __max_size, this),
438 __writer_(_VSTD::move(__out_it)),
439 __max_size_(__max_size) {
440 if (__max_size <= 0) [[unlikely]]
441 __output_.__reset(__storage_.__begin(), __storage_.__buffer_size);
317442 }
318443
319 _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) {
320 // A flush to the direct writer happens in two occasions:
444 _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) {
445 // A __flush to the direct writer happens in the following occasions:
321446 // - The format function has written the maximum number of allowed code
322447 // units. At this point it's no longer valid to write to this writer. So
323448 // switch to the internal storage. This internal storage doesn't need to
324 // be written anywhere so the flush for that storage writes no output.
449 // be written anywhere so the __flush for that storage writes no output.
450 // - Like above, but the next "mass write" operation would overflow the
451 // buffer. In that case the buffer is pre-emptively switched. The still
452 // valid code units will be written separately.
325453 // - The format_to_n function is finished. In this case there's no need to
326454 // switch the buffer, but for simplicity the buffers are still switched.
327 // When the __n <= 0 the constructor already switched the buffers.
328 if (__size_ == 0 && __ptr != __storage_.begin()) {
329 __writer_.flush(__ptr, __size);
330 __output_.reset(__storage_.begin(), __storage_.__buffer_size);
455 // When the __max_size <= 0 the constructor already switched the buffers.
456 if (__size_ == 0 && __ptr != __storage_.__begin()) {
457 __writer_.__flush(__ptr, __n);
458 __output_.__reset(__storage_.__begin(), __storage_.__buffer_size);
459 } else if (__size_ < __max_size_) {
460 // Copies a part of the internal buffer to the output up to n characters.
461 // See __output_buffer<_CharT>::__flush_on_overflow for more information.
462 _Size __s = _VSTD::min(_Size(__n), __max_size_ - __size_);
463 std::copy_n(__ptr, __s, __writer_.__out_it());
464 __writer_.__flush(__ptr, __s);
331465 }
332466
333 __size_ += __size;
467 __size_ += __n;
334468 }
335469
336470protected:
......@@ -338,11 +472,12 @@ protected:
338472 __output_buffer<_CharT> __output_;
339473 __writer_direct<_OutIt, _CharT> __writer_;
340474
475 _Size __max_size_;
341476 _Size __size_{0};
342477};
343478
344479/// The buffer that counts and limits the number of insertions.
345template <class _OutIt, __formatter::__char_type _CharT>
480template <class _OutIt, __fmt_char_type _CharT>
346481 requires(output_iterator<_OutIt, const _CharT&>)
347482struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer final
348483 : public __format_to_n_buffer_base< _OutIt, _CharT, __enable_direct_output<_OutIt, _CharT>> {
......@@ -350,14 +485,83 @@ struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer final
350485 using _Size = iter_difference_t<_OutIt>;
351486
352487public:
353 _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer(_OutIt __out_it, _Size __n) : _Base(_VSTD::move(__out_it), __n) {}
354 _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() { return this->__output_.make_output_iterator(); }
488 _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer(_OutIt __out_it, _Size __max_size)
489 : _Base(_VSTD::move(__out_it), __max_size) {}
490 _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return this->__output_.__make_output_iterator(); }
491
492 _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __result() && {
493 this->__output_.__flush();
494 return {_VSTD::move(this->__writer_).__out_it(), this->__size_};
495 }
496};
497
498// A dynamically growing buffer intended to be used for retargeting a context.
499//
500// P2286 Formatting ranges adds range formatting support. It allows the user to
501// specify the minimum width for the entire formatted range. The width of the
502// range is not known until the range is formatted. Formatting is done to an
503// output_iterator so there's no guarantee it would be possible to add the fill
504// to the front of the output. Instead the range is formatted to a temporary
505// buffer and that buffer is formatted as a string.
506//
507// There is an issue with that approach, the format context used in
508// std::formatter<T>::format contains the output iterator used as part of its
509// type. So using this output iterator means there needs to be a new format
510// context and the format arguments need to be retargeted to the new context.
511// This retargeting is done by a basic_format_context specialized for the
512// __iterator of this container.
513template <__fmt_char_type _CharT>
514class _LIBCPP_TEMPLATE_VIS __retarget_buffer {
515public:
516 using value_type = _CharT;
517
518 struct __iterator {
519 using difference_type = ptrdiff_t;
520
521 _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(__retarget_buffer& __buffer)
522 : __buffer_(std::addressof(__buffer)) {}
523 _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator=(const _CharT& __c) {
524 __buffer_->push_back(__c);
525 return *this;
526 }
527 _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator=(_CharT&& __c) {
528 __buffer_->push_back(__c);
529 return *this;
530 }
531
532 _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator*() { return *this; }
533 _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator++() { return *this; }
534 _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator++(int) { return *this; }
535 __retarget_buffer* __buffer_;
536 };
355537
356 _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> result() && {
357 this->__output_.flush();
358 return {_VSTD::move(this->__writer_).out(), this->__size_};
538 _LIBCPP_HIDE_FROM_ABI explicit __retarget_buffer(size_t __size_hint) { __buffer_.reserve(__size_hint); }
539
540 _LIBCPP_HIDE_FROM_ABI __iterator __make_output_iterator() { return __iterator{*this}; }
541
542 _LIBCPP_HIDE_FROM_ABI void push_back(_CharT __c) { __buffer_.push_back(__c); }
543
544 template <__fmt_char_type _InCharT>
545 _LIBCPP_HIDE_FROM_ABI void __copy(basic_string_view<_InCharT> __str) {
546 __buffer_.insert(__buffer_.end(), __str.begin(), __str.end());
547 }
548
549 template <__fmt_char_type _InCharT, class _UnaryOperation>
550 _LIBCPP_HIDE_FROM_ABI void __transform(const _InCharT* __first, const _InCharT* __last, _UnaryOperation __operation) {
551 _LIBCPP_ASSERT(__first <= __last, "not a valid range");
552 std::transform(__first, __last, std::back_inserter(__buffer_), std::move(__operation));
359553 }
554
555 _LIBCPP_HIDE_FROM_ABI void __fill(size_t __n, _CharT __value) { __buffer_.insert(__buffer_.end(), __n, __value); }
556
557 _LIBCPP_HIDE_FROM_ABI basic_string_view<_CharT> __view() { return {__buffer_.data(), __buffer_.size()}; }
558
559private:
560 // Use vector instead of string to avoid adding zeros after every append
561 // operation. The buffer is exposed as a string_view and not as a c-string.
562 vector<_CharT> __buffer_;
360563};
564
361565} // namespace __format
362566
363567#endif //_LIBCPP_STD_VER > 17
lib/libcxx/include/__format/concepts.h+37-12
......@@ -15,6 +15,9 @@
1515#include <__config>
1616#include <__format/format_fwd.h>
1717#include <__format/format_parse_context.h>
18#include <__type_traits/is_specialization.h>
19#include <__utility/pair.h>
20#include <tuple>
1821#include <type_traits>
1922
2023#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -25,6 +28,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2528
2629#if _LIBCPP_STD_VER > 17
2730
31/// The character type specializations of \ref formatter.
32template <class _CharT>
33concept __fmt_char_type =
34 same_as<_CharT, char>
35# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
36 || same_as<_CharT, wchar_t>
37# endif
38 ;
39
2840// The output iterator isn't specified. A formatter should accept any
2941// output_iterator. This iterator is a minimal iterator to test the concept.
3042// (Note testing for (w)format_context would be a valid choice, but requires
......@@ -32,20 +44,33 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3244template <class _CharT>
3345using __fmt_iter_for = _CharT*;
3446
35// The concept is based on P2286R6
36// It lacks the const of __cf as required by, the not yet accepted, LWG-3636.
37// The current formatters can't be easily adapted, but that is WIP.
38// TODO FMT properly implement this concepts once accepted.
3947template <class _Tp, class _CharT>
40concept __formattable = (semiregular<formatter<remove_cvref_t<_Tp>, _CharT>>) &&
41 requires(formatter<remove_cvref_t<_Tp>, _CharT> __f,
42 formatter<remove_cvref_t<_Tp>, _CharT> __cf, _Tp __t,
43 basic_format_context<__fmt_iter_for<_CharT>, _CharT> __fc,
44 basic_format_parse_context<_CharT> __pc) {
45 { __f.parse(__pc) } -> same_as<typename basic_format_parse_context<_CharT>::iterator>;
46 { __cf.format(__t, __fc) } -> same_as<__fmt_iter_for<_CharT>>;
47 };
48concept __formattable =
49 (semiregular<formatter<remove_cvref_t<_Tp>, _CharT>>) &&
50 requires(formatter<remove_cvref_t<_Tp>, _CharT> __f,
51 const formatter<remove_cvref_t<_Tp>, _CharT> __cf,
52 _Tp __t,
53 basic_format_context<__fmt_iter_for<_CharT>, _CharT> __fc,
54 basic_format_parse_context<_CharT> __pc) {
55 { __f.parse(__pc) } -> same_as<typename basic_format_parse_context<_CharT>::iterator>;
56 { __cf.format(__t, __fc) } -> same_as<__fmt_iter_for<_CharT>>;
57 };
58
59# if _LIBCPP_STD_VER > 20
60template <class _Tp, class _CharT>
61concept formattable = __formattable<_Tp, _CharT>;
62
63// [tuple.like] defines a tuple-like exposition only concept. This concept is
64// not related to that. Therefore it uses a different name for the concept.
65//
66// TODO FMT Add a test to validate we fail when using that concept after P2165
67// has been implemented.
68template <class _Tp>
69concept __fmt_pair_like = __is_specialization_v<_Tp, pair> ||
70 // Use a requires since tuple_size_v may fail to instantiate,
71 (__is_specialization_v<_Tp, tuple> && requires { tuple_size_v<_Tp> == 2; });
4872
73# endif //_LIBCPP_STD_VER > 20
4974#endif //_LIBCPP_STD_VER > 17
5075
5176_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__format/container_adaptor.h created+70
......@@ -0,0 +1,70 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___FORMAT_CONTAINER_ADAPTOR_H
11#define _LIBCPP___FORMAT_CONTAINER_ADAPTOR_H
12
13#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
14# pragma GCC system_header
15#endif
16
17#include <__availability>
18#include <__config>
19#include <__format/concepts.h>
20#include <__format/formatter.h>
21#include <__format/range_default_formatter.h>
22#include <queue>
23#include <stack>
24
25_LIBCPP_BEGIN_NAMESPACE_STD
26
27#if _LIBCPP_STD_VER > 20
28
29// [container.adaptors.format] only specifies the library should provide the
30// formatter specializations, not which header should provide them.
31// Since <format> includes a lot of headers, add these headers here instead of
32// adding more dependencies like, locale, optinal, string, tuple, etc. to the
33// adaptor headers. To use the format functions users already include <format>.
34
35template <class _Adaptor, class _CharT>
36struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_container_adaptor {
37private:
38 using __maybe_const_adaptor = __fmt_maybe_const<_Adaptor, _CharT>;
39 formatter<typename _Adaptor::container_type, _CharT> __underlying_;
40
41public:
42 template <class _ParseContext>
43 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
44 return __underlying_.parse(__ctx);
45 }
46
47 template <class _FormatContext>
48 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator
49 format(__maybe_const_adaptor& __adaptor, _FormatContext& __ctx) const {
50 return __underlying_.format(__adaptor.__get_container(), __ctx);
51 }
52};
53
54template <class _CharT, class _Tp, formattable<_CharT> _Container>
55struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<queue<_Tp, _Container>, _CharT>
56 : public __formatter_container_adaptor<queue<_Tp, _Container>, _CharT> {};
57
58template <class _CharT, class _Tp, class _Container, class _Compare>
59struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<priority_queue<_Tp, _Container, _Compare>, _CharT>
60 : public __formatter_container_adaptor<priority_queue<_Tp, _Container, _Compare>, _CharT> {};
61
62template <class _CharT, class _Tp, formattable<_CharT> _Container>
63struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<stack<_Tp, _Container>, _CharT>
64 : public __formatter_container_adaptor<stack<_Tp, _Container>, _CharT> {};
65
66#endif //_LIBCPP_STD_VER > 20
67
68_LIBCPP_END_NAMESPACE_STD
69
70#endif // _LIBCPP___FORMAT_CONTAINER_ADAPTOR_H
lib/libcxx/include/__format/escaped_output_table.h created+1038
......@@ -0,0 +1,1038 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10// WARNING, this entire header is generated by
11// utils/generate_escaped_output_table.py
12// DO NOT MODIFY!
13
14// UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
15//
16// See Terms of Use <https://www.unicode.org/copyright.html>
17// for definitions of Unicode Inc.'s Data Files and Software.
18//
19// NOTICE TO USER: Carefully read the following legal agreement.
20// BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S
21// DATA FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"),
22// YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
23// TERMS AND CONDITIONS OF THIS AGREEMENT.
24// IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE
25// THE DATA FILES OR SOFTWARE.
26//
27// COPYRIGHT AND PERMISSION NOTICE
28//
29// Copyright (c) 1991-2022 Unicode, Inc. All rights reserved.
30// Distributed under the Terms of Use in https://www.unicode.org/copyright.html.
31//
32// Permission is hereby granted, free of charge, to any person obtaining
33// a copy of the Unicode data files and any associated documentation
34// (the "Data Files") or Unicode software and any associated documentation
35// (the "Software") to deal in the Data Files or Software
36// without restriction, including without limitation the rights to use,
37// copy, modify, merge, publish, distribute, and/or sell copies of
38// the Data Files or Software, and to permit persons to whom the Data Files
39// or Software are furnished to do so, provided that either
40// (a) this copyright and permission notice appear with all copies
41// of the Data Files or Software, or
42// (b) this copyright and permission notice appear in associated
43// Documentation.
44//
45// THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
46// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
47// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
48// NONINFRINGEMENT OF THIRD PARTY RIGHTS.
49// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS
50// NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL
51// DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
52// DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
53// TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
54// PERFORMANCE OF THE DATA FILES OR SOFTWARE.
55//
56// Except as contained in this notice, the name of a copyright holder
57// shall not be used in advertising or otherwise to promote the sale,
58// use or other dealings in these Data Files or Software without prior
59// written authorization of the copyright holder.
60
61#ifndef _LIBCPP___FORMAT_ESCAPED_OUTPUT_TABLE_H
62#define _LIBCPP___FORMAT_ESCAPED_OUTPUT_TABLE_H
63
64#include <__algorithm/ranges_upper_bound.h>
65#include <__config>
66#include <cstddef>
67#include <cstdint>
68
69#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
70# pragma GCC system_header
71#endif
72
73_LIBCPP_BEGIN_NAMESPACE_STD
74
75#if _LIBCPP_STD_VER > 20
76
77namespace __escaped_output_table {
78
79/// The entries of the characters to escape in format's debug string.
80///
81/// Contains the entries for [format.string.escaped]/2.2.1.2.1
82/// CE is a Unicode encoding and C corresponds to either a UCS scalar value
83/// whose Unicode property General_Category has a value in the groups
84/// Separator (Z) or Other (C) or to a UCS scalar value which has the Unicode
85/// property Grapheme_Extend=Yes, as described by table 12 of UAX #44
86///
87/// Separator (Z) consists of General_Category
88/// - Space_Separator,
89/// - Line_Separator,
90/// - Paragraph_Separator.
91///
92/// Other (C) consists of General_Category
93/// - Control,
94/// - Format,
95/// - Surrogate,
96/// - Private_Use,
97/// - Unassigned.
98///
99/// The data is generated from
100/// - https://www.unicode.org/Public/UCD/latest/ucd/DerivedCoreProperties.txt
101/// - https://www.unicode.org/Public/UCD/latest/ucd/extracted/DerivedGeneralCategory.txt
102///
103/// The table is similar to the table
104/// __extended_grapheme_custer_property_boundary::__entries
105/// which explains the details of these classes. The only difference is this
106/// table lacks a property, thus having more bits available for the size.
107///
108/// The data has 2 values:
109/// - bits [0, 10] The size of the range, allowing 2048 elements.
110/// - bits [11, 31] The lower bound code point of the range. The upper bound of
111/// the range is lower bound + size.
112inline constexpr uint32_t __entries[893] = {
113 0x00000020,
114 0x0003f821,
115 0x00056800,
116 0x0018006f,
117 0x001bc001,
118 0x001c0003,
119 0x001c5800,
120 0x001c6800,
121 0x001d1000,
122 0x00241806,
123 0x00298000,
124 0x002ab801,
125 0x002c5801,
126 0x002c802d,
127 0x002df800,
128 0x002e0801,
129 0x002e2001,
130 0x002e3808,
131 0x002f5803,
132 0x002fa810,
133 0x0030800a,
134 0x0030e000,
135 0x00325814,
136 0x00338000,
137 0x0036b007,
138 0x0036f805,
139 0x00373801,
140 0x00375003,
141 0x00387001,
142 0x00388800,
143 0x0039801c,
144 0x003d300a,
145 0x003d900d,
146 0x003f5808,
147 0x003fd802,
148 0x0040b003,
149 0x0040d808,
150 0x00412802,
151 0x00414806,
152 0x0041f800,
153 0x0042c804,
154 0x0042f800,
155 0x00435804,
156 0x00447810,
157 0x00465038,
158 0x0049d000,
159 0x0049e000,
160 0x004a0807,
161 0x004a6800,
162 0x004a8806,
163 0x004b1001,
164 0x004c0800,
165 0x004c2000,
166 0x004c6801,
167 0x004c8801,
168 0x004d4800,
169 0x004d8800,
170 0x004d9802,
171 0x004dd002,
172 0x004df000,
173 0x004e0805,
174 0x004e4801,
175 0x004e6800,
176 0x004e780c,
177 0x004ef000,
178 0x004f1003,
179 0x004ff004,
180 0x00502000,
181 0x00505803,
182 0x00508801,
183 0x00514800,
184 0x00518800,
185 0x0051a000,
186 0x0051b800,
187 0x0051d003,
188 0x00520817,
189 0x0052e800,
190 0x0052f806,
191 0x00538001,
192 0x0053a800,
193 0x0053b80b,
194 0x00542000,
195 0x00547000,
196 0x00549000,
197 0x00554800,
198 0x00558800,
199 0x0055a000,
200 0x0055d002,
201 0x00560807,
202 0x00565000,
203 0x00566802,
204 0x0056880e,
205 0x00571003,
206 0x00579006,
207 0x0057d007,
208 0x00582000,
209 0x00586801,
210 0x00588801,
211 0x00594800,
212 0x00598800,
213 0x0059a000,
214 0x0059d002,
215 0x0059f001,
216 0x005a0805,
217 0x005a4801,
218 0x005a680e,
219 0x005af000,
220 0x005b1003,
221 0x005bc00a,
222 0x005c2000,
223 0x005c5802,
224 0x005c8800,
225 0x005cb002,
226 0x005cd800,
227 0x005ce800,
228 0x005d0002,
229 0x005d2802,
230 0x005d5802,
231 0x005dd004,
232 0x005e0000,
233 0x005e1802,
234 0x005e4800,
235 0x005e6802,
236 0x005e8814,
237 0x005fd805,
238 0x00602000,
239 0x00606800,
240 0x00608800,
241 0x00614800,
242 0x0061d002,
243 0x0061f002,
244 0x00622812,
245 0x0062d801,
246 0x0062f001,
247 0x00631003,
248 0x00638006,
249 0x00640800,
250 0x00646800,
251 0x00648800,
252 0x00654800,
253 0x0065a000,
254 0x0065d002,
255 0x0065f800,
256 0x00661000,
257 0x00662801,
258 0x00664800,
259 0x00666010,
260 0x0066f800,
261 0x00671003,
262 0x00678000,
263 0x0067a00d,
264 0x00686800,
265 0x00688800,
266 0x0069d801,
267 0x0069f000,
268 0x006a0804,
269 0x006a4800,
270 0x006a6800,
271 0x006a8003,
272 0x006ab800,
273 0x006b1003,
274 0x006c0001,
275 0x006c2000,
276 0x006cb802,
277 0x006d9000,
278 0x006de000,
279 0x006df001,
280 0x006e3808,
281 0x006e9005,
282 0x006ef806,
283 0x006f8001,
284 0x006fa80b,
285 0x00718800,
286 0x0071a00a,
287 0x00723807,
288 0x0072e024,
289 0x00741800,
290 0x00742800,
291 0x00745800,
292 0x00752000,
293 0x00753000,
294 0x00758800,
295 0x0075a008,
296 0x0075f001,
297 0x00762800,
298 0x00763808,
299 0x0076d001,
300 0x0077001f,
301 0x0078c001,
302 0x0079a800,
303 0x0079b800,
304 0x0079c800,
305 0x007a4000,
306 0x007b6811,
307 0x007c0004,
308 0x007c3001,
309 0x007c6830,
310 0x007e3000,
311 0x007e6800,
312 0x007ed824,
313 0x00816803,
314 0x00819005,
315 0x0081c801,
316 0x0081e801,
317 0x0082c001,
318 0x0082f002,
319 0x00838803,
320 0x00841000,
321 0x00842801,
322 0x00846800,
323 0x0084e800,
324 0x00863000,
325 0x00864004,
326 0x00867001,
327 0x00924800,
328 0x00927001,
329 0x0092b800,
330 0x0092c800,
331 0x0092f001,
332 0x00944800,
333 0x00947001,
334 0x00958800,
335 0x0095b001,
336 0x0095f800,
337 0x00960800,
338 0x00963001,
339 0x0096b800,
340 0x00988800,
341 0x0098b001,
342 0x009ad804,
343 0x009be802,
344 0x009cd005,
345 0x009fb001,
346 0x009ff001,
347 0x00b40000,
348 0x00b4e802,
349 0x00b7c806,
350 0x00b89002,
351 0x00b8b008,
352 0x00b99001,
353 0x00b9b808,
354 0x00ba900d,
355 0x00bb6800,
356 0x00bb880e,
357 0x00bda001,
358 0x00bdb806,
359 0x00be3000,
360 0x00be480a,
361 0x00bee802,
362 0x00bf5005,
363 0x00bfd005,
364 0x00c05804,
365 0x00c0d005,
366 0x00c3c806,
367 0x00c42801,
368 0x00c54800,
369 0x00c55804,
370 0x00c7b009,
371 0x00c8f803,
372 0x00c93801,
373 0x00c96003,
374 0x00c99000,
375 0x00c9c806,
376 0x00ca0802,
377 0x00cb7001,
378 0x00cba80a,
379 0x00cd6003,
380 0x00ce5005,
381 0x00ced802,
382 0x00d0b801,
383 0x00d0d802,
384 0x00d2b000,
385 0x00d2c008,
386 0x00d31000,
387 0x00d32807,
388 0x00d3980c,
389 0x00d45005,
390 0x00d4d005,
391 0x00d57055,
392 0x00d9a006,
393 0x00d9e000,
394 0x00da1000,
395 0x00da6802,
396 0x00db5808,
397 0x00dbf802,
398 0x00dd1003,
399 0x00dd4001,
400 0x00dd5802,
401 0x00df3000,
402 0x00df4001,
403 0x00df6800,
404 0x00df7802,
405 0x00dfa007,
406 0x00e16007,
407 0x00e1b004,
408 0x00e25002,
409 0x00e44806,
410 0x00e5d801,
411 0x00e6400a,
412 0x00e6a00c,
413 0x00e71006,
414 0x00e76800,
415 0x00e7a000,
416 0x00e7c001,
417 0x00e7d804,
418 0x00ee003f,
419 0x00f8b001,
420 0x00f8f001,
421 0x00fa3001,
422 0x00fa7001,
423 0x00fac000,
424 0x00fad000,
425 0x00fae000,
426 0x00faf000,
427 0x00fbf001,
428 0x00fda800,
429 0x00fe2800,
430 0x00fea001,
431 0x00fee000,
432 0x00ff8001,
433 0x00ffa800,
434 0x00fff810,
435 0x01014007,
436 0x0102f810,
437 0x01039001,
438 0x01047800,
439 0x0104e802,
440 0x0106083e,
441 0x010c6003,
442 0x01213818,
443 0x01225814,
444 0x015ba001,
445 0x015cb000,
446 0x01677802,
447 0x0167a004,
448 0x01693000,
449 0x01694004,
450 0x01697001,
451 0x016b4006,
452 0x016b880e,
453 0x016cb808,
454 0x016d3800,
455 0x016d7800,
456 0x016db800,
457 0x016df800,
458 0x016e3800,
459 0x016e7800,
460 0x016eb800,
461 0x016ef820,
462 0x0172f021,
463 0x0174d000,
464 0x0177a00b,
465 0x017eb019,
466 0x017fe004,
467 0x01815005,
468 0x01820000,
469 0x0184b803,
470 0x01880004,
471 0x01898000,
472 0x018c7800,
473 0x018f200b,
474 0x0190f800,
475 0x05246802,
476 0x05263808,
477 0x05316013,
478 0x05337803,
479 0x0533a009,
480 0x0534f001,
481 0x05378001,
482 0x0537c007,
483 0x053e5804,
484 0x053e9000,
485 0x053ea000,
486 0x053ed017,
487 0x05401000,
488 0x05403000,
489 0x05405800,
490 0x05412801,
491 0x05416003,
492 0x0541d005,
493 0x0543c007,
494 0x05462009,
495 0x0546d017,
496 0x0547f800,
497 0x05493007,
498 0x054a380a,
499 0x054aa00a,
500 0x054be805,
501 0x054d9800,
502 0x054db003,
503 0x054de001,
504 0x054e7000,
505 0x054ed003,
506 0x054f2800,
507 0x054ff800,
508 0x05514805,
509 0x05518801,
510 0x0551a80a,
511 0x05521800,
512 0x05526000,
513 0x05527001,
514 0x0552d001,
515 0x0553e000,
516 0x05558000,
517 0x05559002,
518 0x0555b801,
519 0x0555f001,
520 0x05560800,
521 0x05561817,
522 0x05576001,
523 0x0557b00a,
524 0x05583801,
525 0x05587801,
526 0x0558b808,
527 0x05593800,
528 0x05597800,
529 0x055b6003,
530 0x055f2800,
531 0x055f4000,
532 0x055f6802,
533 0x055fd005,
534 0x06bd200b,
535 0x06be3803,
536 0x06bfe7ff,
537 0x06ffe7ff,
538 0x073fe7ff,
539 0x077fe7ff,
540 0x07bfe103,
541 0x07d37001,
542 0x07d6d025,
543 0x07d8380b,
544 0x07d8c004,
545 0x07d8f000,
546 0x07d9b800,
547 0x07d9e800,
548 0x07d9f800,
549 0x07da1000,
550 0x07da2800,
551 0x07de180f,
552 0x07ec8001,
553 0x07ee4006,
554 0x07ee801f,
555 0x07f0000f,
556 0x07f0d015,
557 0x07f29800,
558 0x07f33800,
559 0x07f36003,
560 0x07f3a800,
561 0x07f7e803,
562 0x07fcf001,
563 0x07fdf802,
564 0x07fe4001,
565 0x07fe8001,
566 0x07fec001,
567 0x07fee802,
568 0x07ff3800,
569 0x07ff780c,
570 0x07fff001,
571 0x08006000,
572 0x08013800,
573 0x0801d800,
574 0x0801f000,
575 0x08027001,
576 0x0802f021,
577 0x0807d804,
578 0x08081803,
579 0x0809a002,
580 0x080c7800,
581 0x080ce802,
582 0x080d082e,
583 0x080fe882,
584 0x0814e802,
585 0x0816880f,
586 0x0817e003,
587 0x08192008,
588 0x081a5804,
589 0x081bb009,
590 0x081cf000,
591 0x081e2003,
592 0x081eb029,
593 0x0824f001,
594 0x08255005,
595 0x0826a003,
596 0x0827e003,
597 0x08294007,
598 0x082b200a,
599 0x082bd800,
600 0x082c5800,
601 0x082c9800,
602 0x082cb000,
603 0x082d1000,
604 0x082d9000,
605 0x082dd000,
606 0x082de842,
607 0x0839b808,
608 0x083ab009,
609 0x083b4017,
610 0x083c3000,
611 0x083d8800,
612 0x083dd844,
613 0x08403001,
614 0x08404800,
615 0x0841b000,
616 0x0841c802,
617 0x0841e801,
618 0x0842b000,
619 0x0844f807,
620 0x0845802f,
621 0x08479800,
622 0x0847b004,
623 0x0848e002,
624 0x0849d004,
625 0x084a003f,
626 0x084dc003,
627 0x084e8001,
628 0x0850080e,
629 0x0850a000,
630 0x0850c000,
631 0x0851b009,
632 0x08524806,
633 0x0852c806,
634 0x0855001f,
635 0x08572805,
636 0x0857b808,
637 0x0859b002,
638 0x085ab001,
639 0x085b9804,
640 0x085c9006,
641 0x085ce80b,
642 0x085d804f,
643 0x08624836,
644 0x0865980c,
645 0x08679806,
646 0x0869200b,
647 0x0869d125,
648 0x0873f800,
649 0x08755002,
650 0x08757001,
651 0x0875904d,
652 0x08794007,
653 0x087a300a,
654 0x087ad015,
655 0x087c1003,
656 0x087c5025,
657 0x087e6013,
658 0x087fb808,
659 0x08800800,
660 0x0881c00e,
661 0x08827003,
662 0x08838000,
663 0x08839801,
664 0x0883b00b,
665 0x08859803,
666 0x0885c801,
667 0x0885e800,
668 0x0886100d,
669 0x08874806,
670 0x0887d008,
671 0x08893804,
672 0x08896808,
673 0x088a4007,
674 0x088b9800,
675 0x088bb80a,
676 0x088db008,
677 0x088e4803,
678 0x088e7800,
679 0x088f0000,
680 0x088fa80a,
681 0x08909000,
682 0x08917802,
683 0x0891a000,
684 0x0891b001,
685 0x0891f000,
686 0x0892083e,
687 0x08943800,
688 0x08944800,
689 0x08947000,
690 0x0894f000,
691 0x08955005,
692 0x0896f800,
693 0x0897180c,
694 0x0897d007,
695 0x08982000,
696 0x08986801,
697 0x08988801,
698 0x08994800,
699 0x08998800,
700 0x0899a000,
701 0x0899d002,
702 0x0899f000,
703 0x089a0000,
704 0x089a2801,
705 0x089a4801,
706 0x089a7001,
707 0x089a880b,
708 0x089b209b,
709 0x08a1c007,
710 0x08a21002,
711 0x08a23000,
712 0x08a2e000,
713 0x08a2f000,
714 0x08a3101d,
715 0x08a58000,
716 0x08a59805,
717 0x08a5d000,
718 0x08a5e800,
719 0x08a5f801,
720 0x08a61001,
721 0x08a64007,
722 0x08a6d0a5,
723 0x08ad7800,
724 0x08ad9005,
725 0x08ade001,
726 0x08adf801,
727 0x08aee023,
728 0x08b19807,
729 0x08b1e800,
730 0x08b1f801,
731 0x08b2280a,
732 0x08b2d005,
733 0x08b36812,
734 0x08b55800,
735 0x08b56800,
736 0x08b58005,
737 0x08b5b800,
738 0x08b5d005,
739 0x08b65035,
740 0x08b8d804,
741 0x08b91003,
742 0x08b93808,
743 0x08ba38b8,
744 0x08c17808,
745 0x08c1c801,
746 0x08c1e063,
747 0x08c7980b,
748 0x08c83801,
749 0x08c85001,
750 0x08c8a000,
751 0x08c8b800,
752 0x08c98000,
753 0x08c9b000,
754 0x08c9c803,
755 0x08c9f000,
756 0x08ca1800,
757 0x08ca3808,
758 0x08cad045,
759 0x08cd4001,
760 0x08cea007,
761 0x08cf0000,
762 0x08cf281a,
763 0x08d00809,
764 0x08d19805,
765 0x08d1d803,
766 0x08d23808,
767 0x08d28805,
768 0x08d2c802,
769 0x08d4500c,
770 0x08d4c001,
771 0x08d5180c,
772 0x08d7c806,
773 0x08d850f5,
774 0x08e04800,
775 0x08e1800d,
776 0x08e1f800,
777 0x08e23009,
778 0x08e36802,
779 0x08e48018,
780 0x08e55006,
781 0x08e59001,
782 0x08e5a84a,
783 0x08e83800,
784 0x08e85000,
785 0x08e98814,
786 0x08ea3808,
787 0x08ead005,
788 0x08eb3000,
789 0x08eb4800,
790 0x08ec7803,
791 0x08eca800,
792 0x08ecb800,
793 0x08ecc806,
794 0x08ed5135,
795 0x08f79801,
796 0x08f7c808,
797 0x08f88800,
798 0x08f9b007,
799 0x08fa0000,
800 0x08fa1000,
801 0x08fad055,
802 0x08fd880e,
803 0x08ff900c,
804 0x091cd065,
805 0x09237800,
806 0x0923a80a,
807 0x092a27ff,
808 0x096a224b,
809 0x097f980c,
810 0x09a18010,
811 0x09a23fff,
812 0x09e23fb8,
813 0x0a323fff,
814 0x0a723fff,
815 0x0ab23fff,
816 0x0af23fff,
817 0x0b3239b8,
818 0x0b51c806,
819 0x0b52f800,
820 0x0b535003,
821 0x0b55f800,
822 0x0b565005,
823 0x0b577006,
824 0x0b57b009,
825 0x0b598006,
826 0x0b5a3009,
827 0x0b5ad000,
828 0x0b5b1000,
829 0x0b5bc004,
830 0x0b5c82af,
831 0x0b74d864,
832 0x0b7a5804,
833 0x0b7c400a,
834 0x0b7d003f,
835 0x0b7f200b,
836 0x0b7f900d,
837 0x0c3fc007,
838 0x0c66b029,
839 0x0c684fff,
840 0x0ca84fff,
841 0x0ce84fff,
842 0x0d284fff,
843 0x0d684ae6,
844 0x0d7fa000,
845 0x0d7fe000,
846 0x0d7ff800,
847 0x0d89180e,
848 0x0d89981c,
849 0x0d8a9801,
850 0x0d8ab00d,
851 0x0d8b4007,
852 0x0d97e7ff,
853 0x0dd7e103,
854 0x0de35804,
855 0x0de3e802,
856 0x0de44806,
857 0x0de4d001,
858 0x0de4e801,
859 0x0de507ff,
860 0x0e2507ff,
861 0x0e6502af,
862 0x0e7e203b,
863 0x0e87b009,
864 0x0e893801,
865 0x0e8b2800,
866 0x0e8b3802,
867 0x0e8b7014,
868 0x0e8c2806,
869 0x0e8d5003,
870 0x0e8f5814,
871 0x0e921002,
872 0x0e923079,
873 0x0e96a00b,
874 0x0e97a00b,
875 0x0e9ab808,
876 0x0e9bc886,
877 0x0ea2a800,
878 0x0ea4e800,
879 0x0ea50001,
880 0x0ea51801,
881 0x0ea53801,
882 0x0ea56800,
883 0x0ea5d000,
884 0x0ea5e000,
885 0x0ea62000,
886 0x0ea83000,
887 0x0ea85801,
888 0x0ea8a800,
889 0x0ea8e800,
890 0x0ea9d000,
891 0x0ea9f800,
892 0x0eaa2800,
893 0x0eaa3802,
894 0x0eaa8800,
895 0x0eb53001,
896 0x0ebe6001,
897 0x0ed00036,
898 0x0ed1d831,
899 0x0ed3a800,
900 0x0ed42000,
901 0x0ed46473,
902 0x0ef8f805,
903 0x0ef95904,
904 0x0f037091,
905 0x0f096809,
906 0x0f09f001,
907 0x0f0a5003,
908 0x0f0a813f,
909 0x0f157011,
910 0x0f176003,
911 0x0f17d004,
912 0x0f1801cf,
913 0x0f276003,
914 0x0f27d2e5,
915 0x0f3f3800,
916 0x0f3f6000,
917 0x0f3f7800,
918 0x0f3ff800,
919 0x0f462801,
920 0x0f46802f,
921 0x0f4a2006,
922 0x0f4a6003,
923 0x0f4ad003,
924 0x0f4b0310,
925 0x0f65a84b,
926 0x0f69f0c1,
927 0x0f702000,
928 0x0f710000,
929 0x0f711800,
930 0x0f712801,
931 0x0f714000,
932 0x0f719800,
933 0x0f71c000,
934 0x0f71d000,
935 0x0f71e005,
936 0x0f721803,
937 0x0f724000,
938 0x0f725000,
939 0x0f726000,
940 0x0f728000,
941 0x0f729800,
942 0x0f72a801,
943 0x0f72c000,
944 0x0f72d000,
945 0x0f72e000,
946 0x0f72f000,
947 0x0f730000,
948 0x0f731800,
949 0x0f732801,
950 0x0f735800,
951 0x0f739800,
952 0x0f73c000,
953 0x0f73e800,
954 0x0f73f800,
955 0x0f745000,
956 0x0f74e004,
957 0x0f752000,
958 0x0f755000,
959 0x0f75e033,
960 0x0f77910d,
961 0x0f816003,
962 0x0f84a00b,
963 0x0f857801,
964 0x0f860000,
965 0x0f868000,
966 0x0f87b009,
967 0x0f8d7037,
968 0x0f90180c,
969 0x0f91e003,
970 0x0f924806,
971 0x0f92900d,
972 0x0f933099,
973 0x0fb6c003,
974 0x0fb76802,
975 0x0fb7e802,
976 0x0fbbb803,
977 0x0fbed005,
978 0x0fbf6003,
979 0x0fbf880e,
980 0x0fc06003,
981 0x0fc24007,
982 0x0fc2d005,
983 0x0fc44007,
984 0x0fc57001,
985 0x0fc5904d,
986 0x0fd2a00b,
987 0x0fd37001,
988 0x0fd3e802,
989 0x0fd44806,
990 0x0fd5f000,
991 0x0fd63007,
992 0x0fd6e003,
993 0x0fd74806,
994 0x0fd7c806,
995 0x0fdc9800,
996 0x0fde5824,
997 0x0fdfd405,
998 0x1537001f,
999 0x15b9d005,
1000 0x15c0f001,
1001 0x1675100d,
1002 0x175f0fff,
1003 0x179f0c1e,
1004 0x17d0f5e1,
1005 0x189a5804};
1006
1007/// At the end of the valid Unicode code points space a lot of code points are
1008/// either reserved or a noncharacter. Adding all these entries to the
1009/// lookup table would add 446 entries to the table (in Unicode 14).
1010/// Instead the only the start of the region is stored, every code point in
1011/// this region needs to be escaped.
1012inline constexpr uint32_t __unallocated_region_lower_bound = 0x000323b0;
1013
1014/// Returns whether the code unit needs to be escaped.
1015///
1016/// \pre The code point is a valid Unicode code point.
1017[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool __needs_escape(const char32_t __code_point) noexcept {
1018 // Since __unallocated_region_lower_bound contains the unshifted range do the
1019 // comparison without shifting.
1020 if (__code_point >= __unallocated_region_lower_bound)
1021 return true;
1022
1023 ptrdiff_t __i = std::ranges::upper_bound(__entries, (__code_point << 11) | 0x7ffu) - __entries;
1024 if (__i == 0)
1025 return false;
1026
1027 --__i;
1028 uint32_t __upper_bound = (__entries[__i] >> 11) + (__entries[__i] & 0x7ffu);
1029 return __code_point <= __upper_bound;
1030}
1031
1032} // namespace __escaped_output_table
1033
1034#endif //_LIBCPP_STD_VER > 20
1035
1036_LIBCPP_END_NAMESPACE_STD
1037
1038#endif // _LIBCPP___FORMAT_ESCAPED_OUTPUT_TABLE_H
lib/libcxx/include/__format/extended_grapheme_cluster_table.h+1501-172
......@@ -8,7 +8,7 @@
88//===----------------------------------------------------------------------===//
99
1010// WARNING, this entire header is generated by
11// utiles/generate_extended_grapheme_cluster_table.py
11// utils/generate_extended_grapheme_cluster_table.py
1212// DO NOT MODIFY!
1313
1414// UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
......@@ -61,7 +61,7 @@
6161#ifndef _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H
6262#define _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H
6363
64#include <__algorithm/upper_bound.h>
64#include <__algorithm/ranges_upper_bound.h>
6565#include <__config>
6666#include <__iterator/access.h>
6767#include <cstddef>
......@@ -111,7 +111,7 @@ enum class __property : uint8_t {
111111/// - https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt
112112///
113113/// The data has 3 values
114/// - bits [0, 3] The property. One of the values generated form the datafiles
114/// - bits [0, 3] The property. One of the values generated from the datafiles
115115/// of \ref __property
116116/// - bits [4, 10] The size of the range.
117117/// - bits [11, 31] The lower bound code point of the range. The upper bound of
......@@ -124,177 +124,1506 @@ enum class __property : uint8_t {
124124/// this approach uses less space for the data and is about 4% faster in the
125125/// following benchmark.
126126/// libcxx/benchmarks/std_format_spec_string_unicode.bench.cpp
127inline constexpr uint32_t __entries[1480] = {
128 0x00000091, 0x00005005, 0x00005811, 0x00006800, 0x00007111, 0x0003fa01, 0x00054803, 0x00056801, 0x00057003,
129 0x001806f2, 0x00241862, 0x002c8ac2, 0x002df802, 0x002e0812, 0x002e2012, 0x002e3802, 0x00300058, 0x003080a2,
130 0x0030e001, 0x00325942, 0x00338002, 0x0036b062, 0x0036e808, 0x0036f852, 0x00373812, 0x00375032, 0x00387808,
131 0x00388802, 0x003981a2, 0x003d30a2, 0x003f5882, 0x003fe802, 0x0040b032, 0x0040d882, 0x00412822, 0x00414842,
132 0x0042c822, 0x00448018, 0x0044c072, 0x00465172, 0x00471008, 0x004719f2, 0x0048180a, 0x0049d002, 0x0049d80a,
133 0x0049e002, 0x0049f02a, 0x004a0872, 0x004a483a, 0x004a6802, 0x004a701a, 0x004a8862, 0x004b1012, 0x004c0802,
134 0x004c101a, 0x004de002, 0x004df002, 0x004df81a, 0x004e0832, 0x004e381a, 0x004e581a, 0x004e6802, 0x004eb802,
135 0x004f1012, 0x004ff002, 0x00500812, 0x0050180a, 0x0051e002, 0x0051f02a, 0x00520812, 0x00523812, 0x00525822,
136 0x00528802, 0x00538012, 0x0053a802, 0x00540812, 0x0054180a, 0x0055e002, 0x0055f02a, 0x00560842, 0x00563812,
137 0x0056480a, 0x0056581a, 0x00566802, 0x00571012, 0x0057d052, 0x00580802, 0x0058101a, 0x0059e002, 0x0059f012,
138 0x005a000a, 0x005a0832, 0x005a381a, 0x005a581a, 0x005a6802, 0x005aa822, 0x005b1012, 0x005c1002, 0x005df002,
139 0x005df80a, 0x005e0002, 0x005e081a, 0x005e302a, 0x005e502a, 0x005e6802, 0x005eb802, 0x00600002, 0x0060082a,
140 0x00602002, 0x0061e002, 0x0061f022, 0x0062083a, 0x00623022, 0x00625032, 0x0062a812, 0x00631012, 0x00640802,
141 0x0064101a, 0x0065e002, 0x0065f00a, 0x0065f802, 0x0066001a, 0x00661002, 0x0066181a, 0x00663002, 0x0066381a,
142 0x0066501a, 0x00666012, 0x0066a812, 0x00671012, 0x00680012, 0x0068101a, 0x0069d812, 0x0069f002, 0x0069f81a,
143 0x006a0832, 0x006a302a, 0x006a502a, 0x006a6802, 0x006a7008, 0x006ab802, 0x006b1012, 0x006c0802, 0x006c101a,
144 0x006e5002, 0x006e7802, 0x006e801a, 0x006e9022, 0x006eb002, 0x006ec06a, 0x006ef802, 0x006f901a, 0x00718802,
145 0x0071980a, 0x0071a062, 0x00723872, 0x00758802, 0x0075980a, 0x0075a082, 0x00764052, 0x0078c012, 0x0079a802,
146 0x0079b802, 0x0079c802, 0x0079f01a, 0x007b88d2, 0x007bf80a, 0x007c0042, 0x007c3012, 0x007c68a2, 0x007cca32,
147 0x007e3002, 0x00816832, 0x0081880a, 0x00819052, 0x0081c812, 0x0081d81a, 0x0081e812, 0x0082b01a, 0x0082c012,
148 0x0082f022, 0x00838832, 0x00841002, 0x0084200a, 0x00842812, 0x00846802, 0x0084e802, 0x008805f4, 0x008b047c,
149 0x008d457b, 0x009ae822, 0x00b89022, 0x00b8a80a, 0x00b99012, 0x00b9a00a, 0x00ba9012, 0x00bb9012, 0x00bda012,
150 0x00bdb00a, 0x00bdb862, 0x00bdf07a, 0x00be3002, 0x00be381a, 0x00be48a2, 0x00bee802, 0x00c05822, 0x00c07001,
151 0x00c07802, 0x00c42812, 0x00c54802, 0x00c90022, 0x00c9183a, 0x00c93812, 0x00c9482a, 0x00c9801a, 0x00c99002,
152 0x00c9985a, 0x00c9c822, 0x00d0b812, 0x00d0c81a, 0x00d0d802, 0x00d2a80a, 0x00d2b002, 0x00d2b80a, 0x00d2c062,
153 0x00d30002, 0x00d31002, 0x00d32872, 0x00d3685a, 0x00d39892, 0x00d3f802, 0x00d581e2, 0x00d80032, 0x00d8200a,
154 0x00d9a062, 0x00d9d80a, 0x00d9e002, 0x00d9e84a, 0x00da1002, 0x00da181a, 0x00db5882, 0x00dc0012, 0x00dc100a,
155 0x00dd080a, 0x00dd1032, 0x00dd301a, 0x00dd4012, 0x00dd500a, 0x00dd5822, 0x00df3002, 0x00df380a, 0x00df4012,
156 0x00df502a, 0x00df6802, 0x00df700a, 0x00df7822, 0x00df901a, 0x00e1207a, 0x00e16072, 0x00e1a01a, 0x00e1b012,
157 0x00e68022, 0x00e6a0c2, 0x00e7080a, 0x00e71062, 0x00e76802, 0x00e7a002, 0x00e7b80a, 0x00e7c012, 0x00ee03f2,
158 0x01005801, 0x01006002, 0x0100680d, 0x01007011, 0x01014061, 0x0101e003, 0x01024803, 0x010300f1, 0x01068202,
159 0x01091003, 0x0109c803, 0x010ca053, 0x010d4813, 0x0118d013, 0x01194003, 0x011c4003, 0x011e7803, 0x011f48a3,
160 0x011fc023, 0x01261003, 0x012d5013, 0x012db003, 0x012e0003, 0x012fd833, 0x01300053, 0x013038b3, 0x0130a713,
161 0x01348753, 0x013840a3, 0x0138a003, 0x0138b003, 0x0138e803, 0x01390803, 0x01394003, 0x01399813, 0x013a2003,
162 0x013a3803, 0x013a6003, 0x013a7003, 0x013a9823, 0x013ab803, 0x013b1843, 0x013ca823, 0x013d0803, 0x013d8003,
163 0x013df803, 0x0149a013, 0x01582823, 0x0158d813, 0x015a8003, 0x015aa803, 0x01677822, 0x016bf802, 0x016f01f2,
164 0x01815052, 0x01818003, 0x0181e803, 0x0184c812, 0x0194b803, 0x0194c803, 0x05337832, 0x0533a092, 0x0534f012,
165 0x05378012, 0x05401002, 0x05403002, 0x05405802, 0x0541181a, 0x05412812, 0x0541380a, 0x05416002, 0x0544001a,
166 0x0545a0fa, 0x05462012, 0x05470112, 0x0547f802, 0x05493072, 0x054a38a2, 0x054a901a, 0x054b01c4, 0x054c0022,
167 0x054c180a, 0x054d9802, 0x054da01a, 0x054db032, 0x054dd01a, 0x054de012, 0x054df02a, 0x054f2802, 0x05514852,
168 0x0551781a, 0x05518812, 0x0551981a, 0x0551a812, 0x05521802, 0x05526002, 0x0552680a, 0x0553e002, 0x05558002,
169 0x05559022, 0x0555b812, 0x0555f012, 0x05560802, 0x0557580a, 0x05576012, 0x0557701a, 0x0557a80a, 0x0557b002,
170 0x055f181a, 0x055f2802, 0x055f301a, 0x055f4002, 0x055f481a, 0x055f600a, 0x055f6802, 0x05600006, 0x056009a7,
171 0x0560e006, 0x0560e9a7, 0x0561c006, 0x0561c9a7, 0x0562a006, 0x0562a9a7, 0x05638006, 0x056389a7, 0x05646006,
172 0x056469a7, 0x05654006, 0x056549a7, 0x05662006, 0x056629a7, 0x05670006, 0x056709a7, 0x0567e006, 0x0567e9a7,
173 0x0568c006, 0x0568c9a7, 0x0569a006, 0x0569a9a7, 0x056a8006, 0x056a89a7, 0x056b6006, 0x056b69a7, 0x056c4006,
174 0x056c49a7, 0x056d2006, 0x056d29a7, 0x056e0006, 0x056e09a7, 0x056ee006, 0x056ee9a7, 0x056fc006, 0x056fc9a7,
175 0x0570a006, 0x0570a9a7, 0x05718006, 0x057189a7, 0x05726006, 0x057269a7, 0x05734006, 0x057349a7, 0x05742006,
176 0x057429a7, 0x05750006, 0x057509a7, 0x0575e006, 0x0575e9a7, 0x0576c006, 0x0576c9a7, 0x0577a006, 0x0577a9a7,
177 0x05788006, 0x057889a7, 0x05796006, 0x057969a7, 0x057a4006, 0x057a49a7, 0x057b2006, 0x057b29a7, 0x057c0006,
178 0x057c09a7, 0x057ce006, 0x057ce9a7, 0x057dc006, 0x057dc9a7, 0x057ea006, 0x057ea9a7, 0x057f8006, 0x057f89a7,
179 0x05806006, 0x058069a7, 0x05814006, 0x058149a7, 0x05822006, 0x058229a7, 0x05830006, 0x058309a7, 0x0583e006,
180 0x0583e9a7, 0x0584c006, 0x0584c9a7, 0x0585a006, 0x0585a9a7, 0x05868006, 0x058689a7, 0x05876006, 0x058769a7,
181 0x05884006, 0x058849a7, 0x05892006, 0x058929a7, 0x058a0006, 0x058a09a7, 0x058ae006, 0x058ae9a7, 0x058bc006,
182 0x058bc9a7, 0x058ca006, 0x058ca9a7, 0x058d8006, 0x058d89a7, 0x058e6006, 0x058e69a7, 0x058f4006, 0x058f49a7,
183 0x05902006, 0x059029a7, 0x05910006, 0x059109a7, 0x0591e006, 0x0591e9a7, 0x0592c006, 0x0592c9a7, 0x0593a006,
184 0x0593a9a7, 0x05948006, 0x059489a7, 0x05956006, 0x059569a7, 0x05964006, 0x059649a7, 0x05972006, 0x059729a7,
185 0x05980006, 0x059809a7, 0x0598e006, 0x0598e9a7, 0x0599c006, 0x0599c9a7, 0x059aa006, 0x059aa9a7, 0x059b8006,
186 0x059b89a7, 0x059c6006, 0x059c69a7, 0x059d4006, 0x059d49a7, 0x059e2006, 0x059e29a7, 0x059f0006, 0x059f09a7,
187 0x059fe006, 0x059fe9a7, 0x05a0c006, 0x05a0c9a7, 0x05a1a006, 0x05a1a9a7, 0x05a28006, 0x05a289a7, 0x05a36006,
188 0x05a369a7, 0x05a44006, 0x05a449a7, 0x05a52006, 0x05a529a7, 0x05a60006, 0x05a609a7, 0x05a6e006, 0x05a6e9a7,
189 0x05a7c006, 0x05a7c9a7, 0x05a8a006, 0x05a8a9a7, 0x05a98006, 0x05a989a7, 0x05aa6006, 0x05aa69a7, 0x05ab4006,
190 0x05ab49a7, 0x05ac2006, 0x05ac29a7, 0x05ad0006, 0x05ad09a7, 0x05ade006, 0x05ade9a7, 0x05aec006, 0x05aec9a7,
191 0x05afa006, 0x05afa9a7, 0x05b08006, 0x05b089a7, 0x05b16006, 0x05b169a7, 0x05b24006, 0x05b249a7, 0x05b32006,
192 0x05b329a7, 0x05b40006, 0x05b409a7, 0x05b4e006, 0x05b4e9a7, 0x05b5c006, 0x05b5c9a7, 0x05b6a006, 0x05b6a9a7,
193 0x05b78006, 0x05b789a7, 0x05b86006, 0x05b869a7, 0x05b94006, 0x05b949a7, 0x05ba2006, 0x05ba29a7, 0x05bb0006,
194 0x05bb09a7, 0x05bbe006, 0x05bbe9a7, 0x05bcc006, 0x05bcc9a7, 0x05bda006, 0x05bda9a7, 0x05be8006, 0x05be89a7,
195 0x05bf6006, 0x05bf69a7, 0x05c04006, 0x05c049a7, 0x05c12006, 0x05c129a7, 0x05c20006, 0x05c209a7, 0x05c2e006,
196 0x05c2e9a7, 0x05c3c006, 0x05c3c9a7, 0x05c4a006, 0x05c4a9a7, 0x05c58006, 0x05c589a7, 0x05c66006, 0x05c669a7,
197 0x05c74006, 0x05c749a7, 0x05c82006, 0x05c829a7, 0x05c90006, 0x05c909a7, 0x05c9e006, 0x05c9e9a7, 0x05cac006,
198 0x05cac9a7, 0x05cba006, 0x05cba9a7, 0x05cc8006, 0x05cc89a7, 0x05cd6006, 0x05cd69a7, 0x05ce4006, 0x05ce49a7,
199 0x05cf2006, 0x05cf29a7, 0x05d00006, 0x05d009a7, 0x05d0e006, 0x05d0e9a7, 0x05d1c006, 0x05d1c9a7, 0x05d2a006,
200 0x05d2a9a7, 0x05d38006, 0x05d389a7, 0x05d46006, 0x05d469a7, 0x05d54006, 0x05d549a7, 0x05d62006, 0x05d629a7,
201 0x05d70006, 0x05d709a7, 0x05d7e006, 0x05d7e9a7, 0x05d8c006, 0x05d8c9a7, 0x05d9a006, 0x05d9a9a7, 0x05da8006,
202 0x05da89a7, 0x05db6006, 0x05db69a7, 0x05dc4006, 0x05dc49a7, 0x05dd2006, 0x05dd29a7, 0x05de0006, 0x05de09a7,
203 0x05dee006, 0x05dee9a7, 0x05dfc006, 0x05dfc9a7, 0x05e0a006, 0x05e0a9a7, 0x05e18006, 0x05e189a7, 0x05e26006,
204 0x05e269a7, 0x05e34006, 0x05e349a7, 0x05e42006, 0x05e429a7, 0x05e50006, 0x05e509a7, 0x05e5e006, 0x05e5e9a7,
205 0x05e6c006, 0x05e6c9a7, 0x05e7a006, 0x05e7a9a7, 0x05e88006, 0x05e889a7, 0x05e96006, 0x05e969a7, 0x05ea4006,
206 0x05ea49a7, 0x05eb2006, 0x05eb29a7, 0x05ec0006, 0x05ec09a7, 0x05ece006, 0x05ece9a7, 0x05edc006, 0x05edc9a7,
207 0x05eea006, 0x05eea9a7, 0x05ef8006, 0x05ef89a7, 0x05f06006, 0x05f069a7, 0x05f14006, 0x05f149a7, 0x05f22006,
208 0x05f229a7, 0x05f30006, 0x05f309a7, 0x05f3e006, 0x05f3e9a7, 0x05f4c006, 0x05f4c9a7, 0x05f5a006, 0x05f5a9a7,
209 0x05f68006, 0x05f689a7, 0x05f76006, 0x05f769a7, 0x05f84006, 0x05f849a7, 0x05f92006, 0x05f929a7, 0x05fa0006,
210 0x05fa09a7, 0x05fae006, 0x05fae9a7, 0x05fbc006, 0x05fbc9a7, 0x05fca006, 0x05fca9a7, 0x05fd8006, 0x05fd89a7,
211 0x05fe6006, 0x05fe69a7, 0x05ff4006, 0x05ff49a7, 0x06002006, 0x060029a7, 0x06010006, 0x060109a7, 0x0601e006,
212 0x0601e9a7, 0x0602c006, 0x0602c9a7, 0x0603a006, 0x0603a9a7, 0x06048006, 0x060489a7, 0x06056006, 0x060569a7,
213 0x06064006, 0x060649a7, 0x06072006, 0x060729a7, 0x06080006, 0x060809a7, 0x0608e006, 0x0608e9a7, 0x0609c006,
214 0x0609c9a7, 0x060aa006, 0x060aa9a7, 0x060b8006, 0x060b89a7, 0x060c6006, 0x060c69a7, 0x060d4006, 0x060d49a7,
215 0x060e2006, 0x060e29a7, 0x060f0006, 0x060f09a7, 0x060fe006, 0x060fe9a7, 0x0610c006, 0x0610c9a7, 0x0611a006,
216 0x0611a9a7, 0x06128006, 0x061289a7, 0x06136006, 0x061369a7, 0x06144006, 0x061449a7, 0x06152006, 0x061529a7,
217 0x06160006, 0x061609a7, 0x0616e006, 0x0616e9a7, 0x0617c006, 0x0617c9a7, 0x0618a006, 0x0618a9a7, 0x06198006,
218 0x061989a7, 0x061a6006, 0x061a69a7, 0x061b4006, 0x061b49a7, 0x061c2006, 0x061c29a7, 0x061d0006, 0x061d09a7,
219 0x061de006, 0x061de9a7, 0x061ec006, 0x061ec9a7, 0x061fa006, 0x061fa9a7, 0x06208006, 0x062089a7, 0x06216006,
220 0x062169a7, 0x06224006, 0x062249a7, 0x06232006, 0x062329a7, 0x06240006, 0x062409a7, 0x0624e006, 0x0624e9a7,
221 0x0625c006, 0x0625c9a7, 0x0626a006, 0x0626a9a7, 0x06278006, 0x062789a7, 0x06286006, 0x062869a7, 0x06294006,
222 0x062949a7, 0x062a2006, 0x062a29a7, 0x062b0006, 0x062b09a7, 0x062be006, 0x062be9a7, 0x062cc006, 0x062cc9a7,
223 0x062da006, 0x062da9a7, 0x062e8006, 0x062e89a7, 0x062f6006, 0x062f69a7, 0x06304006, 0x063049a7, 0x06312006,
224 0x063129a7, 0x06320006, 0x063209a7, 0x0632e006, 0x0632e9a7, 0x0633c006, 0x0633c9a7, 0x0634a006, 0x0634a9a7,
225 0x06358006, 0x063589a7, 0x06366006, 0x063669a7, 0x06374006, 0x063749a7, 0x06382006, 0x063829a7, 0x06390006,
226 0x063909a7, 0x0639e006, 0x0639e9a7, 0x063ac006, 0x063ac9a7, 0x063ba006, 0x063ba9a7, 0x063c8006, 0x063c89a7,
227 0x063d6006, 0x063d69a7, 0x063e4006, 0x063e49a7, 0x063f2006, 0x063f29a7, 0x06400006, 0x064009a7, 0x0640e006,
228 0x0640e9a7, 0x0641c006, 0x0641c9a7, 0x0642a006, 0x0642a9a7, 0x06438006, 0x064389a7, 0x06446006, 0x064469a7,
229 0x06454006, 0x064549a7, 0x06462006, 0x064629a7, 0x06470006, 0x064709a7, 0x0647e006, 0x0647e9a7, 0x0648c006,
230 0x0648c9a7, 0x0649a006, 0x0649a9a7, 0x064a8006, 0x064a89a7, 0x064b6006, 0x064b69a7, 0x064c4006, 0x064c49a7,
231 0x064d2006, 0x064d29a7, 0x064e0006, 0x064e09a7, 0x064ee006, 0x064ee9a7, 0x064fc006, 0x064fc9a7, 0x0650a006,
232 0x0650a9a7, 0x06518006, 0x065189a7, 0x06526006, 0x065269a7, 0x06534006, 0x065349a7, 0x06542006, 0x065429a7,
233 0x06550006, 0x065509a7, 0x0655e006, 0x0655e9a7, 0x0656c006, 0x0656c9a7, 0x0657a006, 0x0657a9a7, 0x06588006,
234 0x065889a7, 0x06596006, 0x065969a7, 0x065a4006, 0x065a49a7, 0x065b2006, 0x065b29a7, 0x065c0006, 0x065c09a7,
235 0x065ce006, 0x065ce9a7, 0x065dc006, 0x065dc9a7, 0x065ea006, 0x065ea9a7, 0x065f8006, 0x065f89a7, 0x06606006,
236 0x066069a7, 0x06614006, 0x066149a7, 0x06622006, 0x066229a7, 0x06630006, 0x066309a7, 0x0663e006, 0x0663e9a7,
237 0x0664c006, 0x0664c9a7, 0x0665a006, 0x0665a9a7, 0x06668006, 0x066689a7, 0x06676006, 0x066769a7, 0x06684006,
238 0x066849a7, 0x06692006, 0x066929a7, 0x066a0006, 0x066a09a7, 0x066ae006, 0x066ae9a7, 0x066bc006, 0x066bc9a7,
239 0x066ca006, 0x066ca9a7, 0x066d8006, 0x066d89a7, 0x066e6006, 0x066e69a7, 0x066f4006, 0x066f49a7, 0x06702006,
240 0x067029a7, 0x06710006, 0x067109a7, 0x0671e006, 0x0671e9a7, 0x0672c006, 0x0672c9a7, 0x0673a006, 0x0673a9a7,
241 0x06748006, 0x067489a7, 0x06756006, 0x067569a7, 0x06764006, 0x067649a7, 0x06772006, 0x067729a7, 0x06780006,
242 0x067809a7, 0x0678e006, 0x0678e9a7, 0x0679c006, 0x0679c9a7, 0x067aa006, 0x067aa9a7, 0x067b8006, 0x067b89a7,
243 0x067c6006, 0x067c69a7, 0x067d4006, 0x067d49a7, 0x067e2006, 0x067e29a7, 0x067f0006, 0x067f09a7, 0x067fe006,
244 0x067fe9a7, 0x0680c006, 0x0680c9a7, 0x0681a006, 0x0681a9a7, 0x06828006, 0x068289a7, 0x06836006, 0x068369a7,
245 0x06844006, 0x068449a7, 0x06852006, 0x068529a7, 0x06860006, 0x068609a7, 0x0686e006, 0x0686e9a7, 0x0687c006,
246 0x0687c9a7, 0x0688a006, 0x0688a9a7, 0x06898006, 0x068989a7, 0x068a6006, 0x068a69a7, 0x068b4006, 0x068b49a7,
247 0x068c2006, 0x068c29a7, 0x068d0006, 0x068d09a7, 0x068de006, 0x068de9a7, 0x068ec006, 0x068ec9a7, 0x068fa006,
248 0x068fa9a7, 0x06908006, 0x069089a7, 0x06916006, 0x069169a7, 0x06924006, 0x069249a7, 0x06932006, 0x069329a7,
249 0x06940006, 0x069409a7, 0x0694e006, 0x0694e9a7, 0x0695c006, 0x0695c9a7, 0x0696a006, 0x0696a9a7, 0x06978006,
250 0x069789a7, 0x06986006, 0x069869a7, 0x06994006, 0x069949a7, 0x069a2006, 0x069a29a7, 0x069b0006, 0x069b09a7,
251 0x069be006, 0x069be9a7, 0x069cc006, 0x069cc9a7, 0x069da006, 0x069da9a7, 0x069e8006, 0x069e89a7, 0x069f6006,
252 0x069f69a7, 0x06a04006, 0x06a049a7, 0x06a12006, 0x06a129a7, 0x06a20006, 0x06a209a7, 0x06a2e006, 0x06a2e9a7,
253 0x06a3c006, 0x06a3c9a7, 0x06a4a006, 0x06a4a9a7, 0x06a58006, 0x06a589a7, 0x06a66006, 0x06a669a7, 0x06a74006,
254 0x06a749a7, 0x06a82006, 0x06a829a7, 0x06a90006, 0x06a909a7, 0x06a9e006, 0x06a9e9a7, 0x06aac006, 0x06aac9a7,
255 0x06aba006, 0x06aba9a7, 0x06ac8006, 0x06ac89a7, 0x06ad6006, 0x06ad69a7, 0x06ae4006, 0x06ae49a7, 0x06af2006,
256 0x06af29a7, 0x06b00006, 0x06b009a7, 0x06b0e006, 0x06b0e9a7, 0x06b1c006, 0x06b1c9a7, 0x06b2a006, 0x06b2a9a7,
257 0x06b38006, 0x06b389a7, 0x06b46006, 0x06b469a7, 0x06b54006, 0x06b549a7, 0x06b62006, 0x06b629a7, 0x06b70006,
258 0x06b709a7, 0x06b7e006, 0x06b7e9a7, 0x06b8c006, 0x06b8c9a7, 0x06b9a006, 0x06b9a9a7, 0x06ba8006, 0x06ba89a7,
259 0x06bb6006, 0x06bb69a7, 0x06bc4006, 0x06bc49a7, 0x06bd816c, 0x06be5b0b, 0x07d8f002, 0x07f000f2, 0x07f100f2,
260 0x07f7f801, 0x07fcf012, 0x07ff80b1, 0x080fe802, 0x08170002, 0x081bb042, 0x08500822, 0x08502812, 0x08506032,
261 0x0851c022, 0x0851f802, 0x08572812, 0x08692032, 0x08755812, 0x087a30a2, 0x087c1032, 0x0880000a, 0x08800802,
262 0x0880100a, 0x0881c0e2, 0x08838002, 0x08839812, 0x0883f822, 0x0884100a, 0x0885802a, 0x08859832, 0x0885b81a,
263 0x0885c812, 0x0885e808, 0x08861002, 0x08866808, 0x08880022, 0x08893842, 0x0889600a, 0x08896872, 0x088a281a,
264 0x088b9802, 0x088c0012, 0x088c100a, 0x088d982a, 0x088db082, 0x088df81a, 0x088e1018, 0x088e4832, 0x088e700a,
265 0x088e7802, 0x0891602a, 0x08917822, 0x0891901a, 0x0891a002, 0x0891a80a, 0x0891b012, 0x0891f002, 0x0896f802,
266 0x0897002a, 0x08971872, 0x08980012, 0x0898101a, 0x0899d812, 0x0899f002, 0x0899f80a, 0x089a0002, 0x089a083a,
267 0x089a381a, 0x089a582a, 0x089ab802, 0x089b101a, 0x089b3062, 0x089b8042, 0x08a1a82a, 0x08a1c072, 0x08a2001a,
268 0x08a21022, 0x08a2280a, 0x08a23002, 0x08a2f002, 0x08a58002, 0x08a5881a, 0x08a59852, 0x08a5c80a, 0x08a5d002,
269 0x08a5d81a, 0x08a5e802, 0x08a5f00a, 0x08a5f812, 0x08a6080a, 0x08a61012, 0x08ad7802, 0x08ad801a, 0x08ad9032,
270 0x08adc03a, 0x08ade012, 0x08adf00a, 0x08adf812, 0x08aee012, 0x08b1802a, 0x08b19872, 0x08b1d81a, 0x08b1e802,
271 0x08b1f00a, 0x08b1f812, 0x08b55802, 0x08b5600a, 0x08b56802, 0x08b5701a, 0x08b58052, 0x08b5b00a, 0x08b5b802,
272 0x08b8e822, 0x08b91032, 0x08b9300a, 0x08b93842, 0x08c1602a, 0x08c17882, 0x08c1c00a, 0x08c1c812, 0x08c98002,
273 0x08c9884a, 0x08c9b81a, 0x08c9d812, 0x08c9e80a, 0x08c9f002, 0x08c9f808, 0x08ca000a, 0x08ca0808, 0x08ca100a,
274 0x08ca1802, 0x08ce882a, 0x08cea032, 0x08ced012, 0x08cee03a, 0x08cf0002, 0x08cf200a, 0x08d00892, 0x08d19852,
275 0x08d1c80a, 0x08d1d008, 0x08d1d832, 0x08d23802, 0x08d28852, 0x08d2b81a, 0x08d2c822, 0x08d42058, 0x08d450c2,
276 0x08d4b80a, 0x08d4c012, 0x08e1780a, 0x08e18062, 0x08e1c052, 0x08e1f00a, 0x08e1f802, 0x08e49152, 0x08e5480a,
277 0x08e55062, 0x08e5880a, 0x08e59012, 0x08e5a00a, 0x08e5a812, 0x08e98852, 0x08e9d002, 0x08e9e012, 0x08e9f862,
278 0x08ea3008, 0x08ea3802, 0x08ec504a, 0x08ec8012, 0x08ec981a, 0x08eca802, 0x08ecb00a, 0x08ecb802, 0x08f79812,
279 0x08f7a81a, 0x09a18081, 0x0b578042, 0x0b598062, 0x0b7a7802, 0x0b7a8b6a, 0x0b7c7832, 0x0b7f2002, 0x0b7f801a,
280 0x0de4e812, 0x0de50031, 0x0e7802d2, 0x0e798162, 0x0e8b2802, 0x0e8b300a, 0x0e8b3822, 0x0e8b680a, 0x0e8b7042,
281 0x0e8b9871, 0x0e8bd872, 0x0e8c2862, 0x0e8d5032, 0x0e921022, 0x0ed00362, 0x0ed1db12, 0x0ed3a802, 0x0ed42002,
282 0x0ed4d842, 0x0ed508e2, 0x0f000062, 0x0f004102, 0x0f00d862, 0x0f011812, 0x0f013042, 0x0f098062, 0x0f157002,
283 0x0f176032, 0x0f468062, 0x0f4a2062, 0x0f8007f3, 0x0f8407f3, 0x0f886823, 0x0f897803, 0x0f8b6053, 0x0f8bf013,
284 0x0f8c7003, 0x0f8c8893, 0x0f8d6b83, 0x0f8f3199, 0x0f9008e3, 0x0f90d003, 0x0f917803, 0x0f919083, 0x0f91e033,
285 0x0f924ff3, 0x0f964ff3, 0x0f9a4ff3, 0x0f9e4b13, 0x0f9fd842, 0x0fa007f3, 0x0fa407f3, 0x0fa803d3, 0x0faa37f3,
286 0x0fae37f3, 0x0fb23093, 0x0fb407f3, 0x0fbba0b3, 0x0fbeaaa3, 0x0fc06033, 0x0fc24073, 0x0fc2d053, 0x0fc44073,
287 0x0fc57513, 0x0fc862e3, 0x0fc9e093, 0x0fca3ff3, 0x0fce3ff3, 0x0fd23ff3, 0x0fd63b83, 0x0fe007f3, 0x0fe407f3,
288 0x0fe807f3, 0x0fec07f3, 0x0ff007f3, 0x0ff407f3, 0x0ff807f3, 0x0ffc07d3, 0x700001f1, 0x700105f2, 0x700407f1,
289 0x700807f2, 0x700c06f2, 0x700f87f1, 0x701387f1, 0x701787f1, 0x701b87f1, 0x701f87f1, 0x702387f1, 0x702787f1,
290 0x702b87f1, 0x702f87f1, 0x703387f1, 0x703787f1, 0x703b87f1, 0x703f87f1, 0x704387f1, 0x704787f1, 0x704b87f1,
291 0x704f87f1, 0x705387f1, 0x705787f1, 0x705b87f1, 0x705f87f1, 0x706387f1, 0x706787f1, 0x706b87f1, 0x706f87f1,
292 0x707387f1, 0x707787f1, 0x707b87f1, 0x707f80f1};
127inline constexpr uint32_t __entries[1496] = {
128 0x00000091,
129 0x00005005,
130 0x00005811,
131 0x00006800,
132 0x00007111,
133 0x0003fa01,
134 0x00054803,
135 0x00056801,
136 0x00057003,
137 0x001806f2,
138 0x00241862,
139 0x002c8ac2,
140 0x002df802,
141 0x002e0812,
142 0x002e2012,
143 0x002e3802,
144 0x00300058,
145 0x003080a2,
146 0x0030e001,
147 0x00325942,
148 0x00338002,
149 0x0036b062,
150 0x0036e808,
151 0x0036f852,
152 0x00373812,
153 0x00375032,
154 0x00387808,
155 0x00388802,
156 0x003981a2,
157 0x003d30a2,
158 0x003f5882,
159 0x003fe802,
160 0x0040b032,
161 0x0040d882,
162 0x00412822,
163 0x00414842,
164 0x0042c822,
165 0x00448018,
166 0x0044c072,
167 0x00465172,
168 0x00471008,
169 0x004719f2,
170 0x0048180a,
171 0x0049d002,
172 0x0049d80a,
173 0x0049e002,
174 0x0049f02a,
175 0x004a0872,
176 0x004a483a,
177 0x004a6802,
178 0x004a701a,
179 0x004a8862,
180 0x004b1012,
181 0x004c0802,
182 0x004c101a,
183 0x004de002,
184 0x004df002,
185 0x004df81a,
186 0x004e0832,
187 0x004e381a,
188 0x004e581a,
189 0x004e6802,
190 0x004eb802,
191 0x004f1012,
192 0x004ff002,
193 0x00500812,
194 0x0050180a,
195 0x0051e002,
196 0x0051f02a,
197 0x00520812,
198 0x00523812,
199 0x00525822,
200 0x00528802,
201 0x00538012,
202 0x0053a802,
203 0x00540812,
204 0x0054180a,
205 0x0055e002,
206 0x0055f02a,
207 0x00560842,
208 0x00563812,
209 0x0056480a,
210 0x0056581a,
211 0x00566802,
212 0x00571012,
213 0x0057d052,
214 0x00580802,
215 0x0058101a,
216 0x0059e002,
217 0x0059f012,
218 0x005a000a,
219 0x005a0832,
220 0x005a381a,
221 0x005a581a,
222 0x005a6802,
223 0x005aa822,
224 0x005b1012,
225 0x005c1002,
226 0x005df002,
227 0x005df80a,
228 0x005e0002,
229 0x005e081a,
230 0x005e302a,
231 0x005e502a,
232 0x005e6802,
233 0x005eb802,
234 0x00600002,
235 0x0060082a,
236 0x00602002,
237 0x0061e002,
238 0x0061f022,
239 0x0062083a,
240 0x00623022,
241 0x00625032,
242 0x0062a812,
243 0x00631012,
244 0x00640802,
245 0x0064101a,
246 0x0065e002,
247 0x0065f00a,
248 0x0065f802,
249 0x0066001a,
250 0x00661002,
251 0x0066181a,
252 0x00663002,
253 0x0066381a,
254 0x0066501a,
255 0x00666012,
256 0x0066a812,
257 0x00671012,
258 0x0067980a,
259 0x00680012,
260 0x0068101a,
261 0x0069d812,
262 0x0069f002,
263 0x0069f81a,
264 0x006a0832,
265 0x006a302a,
266 0x006a502a,
267 0x006a6802,
268 0x006a7008,
269 0x006ab802,
270 0x006b1012,
271 0x006c0802,
272 0x006c101a,
273 0x006e5002,
274 0x006e7802,
275 0x006e801a,
276 0x006e9022,
277 0x006eb002,
278 0x006ec06a,
279 0x006ef802,
280 0x006f901a,
281 0x00718802,
282 0x0071980a,
283 0x0071a062,
284 0x00723872,
285 0x00758802,
286 0x0075980a,
287 0x0075a082,
288 0x00764062,
289 0x0078c012,
290 0x0079a802,
291 0x0079b802,
292 0x0079c802,
293 0x0079f01a,
294 0x007b88d2,
295 0x007bf80a,
296 0x007c0042,
297 0x007c3012,
298 0x007c68a2,
299 0x007cca32,
300 0x007e3002,
301 0x00816832,
302 0x0081880a,
303 0x00819052,
304 0x0081c812,
305 0x0081d81a,
306 0x0081e812,
307 0x0082b01a,
308 0x0082c012,
309 0x0082f022,
310 0x00838832,
311 0x00841002,
312 0x0084200a,
313 0x00842812,
314 0x00846802,
315 0x0084e802,
316 0x008805f4,
317 0x008b047c,
318 0x008d457b,
319 0x009ae822,
320 0x00b89022,
321 0x00b8a80a,
322 0x00b99012,
323 0x00b9a00a,
324 0x00ba9012,
325 0x00bb9012,
326 0x00bda012,
327 0x00bdb00a,
328 0x00bdb862,
329 0x00bdf07a,
330 0x00be3002,
331 0x00be381a,
332 0x00be48a2,
333 0x00bee802,
334 0x00c05822,
335 0x00c07001,
336 0x00c07802,
337 0x00c42812,
338 0x00c54802,
339 0x00c90022,
340 0x00c9183a,
341 0x00c93812,
342 0x00c9482a,
343 0x00c9801a,
344 0x00c99002,
345 0x00c9985a,
346 0x00c9c822,
347 0x00d0b812,
348 0x00d0c81a,
349 0x00d0d802,
350 0x00d2a80a,
351 0x00d2b002,
352 0x00d2b80a,
353 0x00d2c062,
354 0x00d30002,
355 0x00d31002,
356 0x00d32872,
357 0x00d3685a,
358 0x00d39892,
359 0x00d3f802,
360 0x00d581e2,
361 0x00d80032,
362 0x00d8200a,
363 0x00d9a062,
364 0x00d9d80a,
365 0x00d9e002,
366 0x00d9e84a,
367 0x00da1002,
368 0x00da181a,
369 0x00db5882,
370 0x00dc0012,
371 0x00dc100a,
372 0x00dd080a,
373 0x00dd1032,
374 0x00dd301a,
375 0x00dd4012,
376 0x00dd500a,
377 0x00dd5822,
378 0x00df3002,
379 0x00df380a,
380 0x00df4012,
381 0x00df502a,
382 0x00df6802,
383 0x00df700a,
384 0x00df7822,
385 0x00df901a,
386 0x00e1207a,
387 0x00e16072,
388 0x00e1a01a,
389 0x00e1b012,
390 0x00e68022,
391 0x00e6a0c2,
392 0x00e7080a,
393 0x00e71062,
394 0x00e76802,
395 0x00e7a002,
396 0x00e7b80a,
397 0x00e7c012,
398 0x00ee03f2,
399 0x01005801,
400 0x01006002,
401 0x0100680d,
402 0x01007011,
403 0x01014061,
404 0x0101e003,
405 0x01024803,
406 0x010300f1,
407 0x01068202,
408 0x01091003,
409 0x0109c803,
410 0x010ca053,
411 0x010d4813,
412 0x0118d013,
413 0x01194003,
414 0x011c4003,
415 0x011e7803,
416 0x011f48a3,
417 0x011fc023,
418 0x01261003,
419 0x012d5013,
420 0x012db003,
421 0x012e0003,
422 0x012fd833,
423 0x01300053,
424 0x013038b3,
425 0x0130a713,
426 0x01348753,
427 0x013840a3,
428 0x0138a003,
429 0x0138b003,
430 0x0138e803,
431 0x01390803,
432 0x01394003,
433 0x01399813,
434 0x013a2003,
435 0x013a3803,
436 0x013a6003,
437 0x013a7003,
438 0x013a9823,
439 0x013ab803,
440 0x013b1843,
441 0x013ca823,
442 0x013d0803,
443 0x013d8003,
444 0x013df803,
445 0x0149a013,
446 0x01582823,
447 0x0158d813,
448 0x015a8003,
449 0x015aa803,
450 0x01677822,
451 0x016bf802,
452 0x016f01f2,
453 0x01815052,
454 0x01818003,
455 0x0181e803,
456 0x0184c812,
457 0x0194b803,
458 0x0194c803,
459 0x05337832,
460 0x0533a092,
461 0x0534f012,
462 0x05378012,
463 0x05401002,
464 0x05403002,
465 0x05405802,
466 0x0541181a,
467 0x05412812,
468 0x0541380a,
469 0x05416002,
470 0x0544001a,
471 0x0545a0fa,
472 0x05462012,
473 0x05470112,
474 0x0547f802,
475 0x05493072,
476 0x054a38a2,
477 0x054a901a,
478 0x054b01c4,
479 0x054c0022,
480 0x054c180a,
481 0x054d9802,
482 0x054da01a,
483 0x054db032,
484 0x054dd01a,
485 0x054de012,
486 0x054df02a,
487 0x054f2802,
488 0x05514852,
489 0x0551781a,
490 0x05518812,
491 0x0551981a,
492 0x0551a812,
493 0x05521802,
494 0x05526002,
495 0x0552680a,
496 0x0553e002,
497 0x05558002,
498 0x05559022,
499 0x0555b812,
500 0x0555f012,
501 0x05560802,
502 0x0557580a,
503 0x05576012,
504 0x0557701a,
505 0x0557a80a,
506 0x0557b002,
507 0x055f181a,
508 0x055f2802,
509 0x055f301a,
510 0x055f4002,
511 0x055f481a,
512 0x055f600a,
513 0x055f6802,
514 0x05600006,
515 0x056009a7,
516 0x0560e006,
517 0x0560e9a7,
518 0x0561c006,
519 0x0561c9a7,
520 0x0562a006,
521 0x0562a9a7,
522 0x05638006,
523 0x056389a7,
524 0x05646006,
525 0x056469a7,
526 0x05654006,
527 0x056549a7,
528 0x05662006,
529 0x056629a7,
530 0x05670006,
531 0x056709a7,
532 0x0567e006,
533 0x0567e9a7,
534 0x0568c006,
535 0x0568c9a7,
536 0x0569a006,
537 0x0569a9a7,
538 0x056a8006,
539 0x056a89a7,
540 0x056b6006,
541 0x056b69a7,
542 0x056c4006,
543 0x056c49a7,
544 0x056d2006,
545 0x056d29a7,
546 0x056e0006,
547 0x056e09a7,
548 0x056ee006,
549 0x056ee9a7,
550 0x056fc006,
551 0x056fc9a7,
552 0x0570a006,
553 0x0570a9a7,
554 0x05718006,
555 0x057189a7,
556 0x05726006,
557 0x057269a7,
558 0x05734006,
559 0x057349a7,
560 0x05742006,
561 0x057429a7,
562 0x05750006,
563 0x057509a7,
564 0x0575e006,
565 0x0575e9a7,
566 0x0576c006,
567 0x0576c9a7,
568 0x0577a006,
569 0x0577a9a7,
570 0x05788006,
571 0x057889a7,
572 0x05796006,
573 0x057969a7,
574 0x057a4006,
575 0x057a49a7,
576 0x057b2006,
577 0x057b29a7,
578 0x057c0006,
579 0x057c09a7,
580 0x057ce006,
581 0x057ce9a7,
582 0x057dc006,
583 0x057dc9a7,
584 0x057ea006,
585 0x057ea9a7,
586 0x057f8006,
587 0x057f89a7,
588 0x05806006,
589 0x058069a7,
590 0x05814006,
591 0x058149a7,
592 0x05822006,
593 0x058229a7,
594 0x05830006,
595 0x058309a7,
596 0x0583e006,
597 0x0583e9a7,
598 0x0584c006,
599 0x0584c9a7,
600 0x0585a006,
601 0x0585a9a7,
602 0x05868006,
603 0x058689a7,
604 0x05876006,
605 0x058769a7,
606 0x05884006,
607 0x058849a7,
608 0x05892006,
609 0x058929a7,
610 0x058a0006,
611 0x058a09a7,
612 0x058ae006,
613 0x058ae9a7,
614 0x058bc006,
615 0x058bc9a7,
616 0x058ca006,
617 0x058ca9a7,
618 0x058d8006,
619 0x058d89a7,
620 0x058e6006,
621 0x058e69a7,
622 0x058f4006,
623 0x058f49a7,
624 0x05902006,
625 0x059029a7,
626 0x05910006,
627 0x059109a7,
628 0x0591e006,
629 0x0591e9a7,
630 0x0592c006,
631 0x0592c9a7,
632 0x0593a006,
633 0x0593a9a7,
634 0x05948006,
635 0x059489a7,
636 0x05956006,
637 0x059569a7,
638 0x05964006,
639 0x059649a7,
640 0x05972006,
641 0x059729a7,
642 0x05980006,
643 0x059809a7,
644 0x0598e006,
645 0x0598e9a7,
646 0x0599c006,
647 0x0599c9a7,
648 0x059aa006,
649 0x059aa9a7,
650 0x059b8006,
651 0x059b89a7,
652 0x059c6006,
653 0x059c69a7,
654 0x059d4006,
655 0x059d49a7,
656 0x059e2006,
657 0x059e29a7,
658 0x059f0006,
659 0x059f09a7,
660 0x059fe006,
661 0x059fe9a7,
662 0x05a0c006,
663 0x05a0c9a7,
664 0x05a1a006,
665 0x05a1a9a7,
666 0x05a28006,
667 0x05a289a7,
668 0x05a36006,
669 0x05a369a7,
670 0x05a44006,
671 0x05a449a7,
672 0x05a52006,
673 0x05a529a7,
674 0x05a60006,
675 0x05a609a7,
676 0x05a6e006,
677 0x05a6e9a7,
678 0x05a7c006,
679 0x05a7c9a7,
680 0x05a8a006,
681 0x05a8a9a7,
682 0x05a98006,
683 0x05a989a7,
684 0x05aa6006,
685 0x05aa69a7,
686 0x05ab4006,
687 0x05ab49a7,
688 0x05ac2006,
689 0x05ac29a7,
690 0x05ad0006,
691 0x05ad09a7,
692 0x05ade006,
693 0x05ade9a7,
694 0x05aec006,
695 0x05aec9a7,
696 0x05afa006,
697 0x05afa9a7,
698 0x05b08006,
699 0x05b089a7,
700 0x05b16006,
701 0x05b169a7,
702 0x05b24006,
703 0x05b249a7,
704 0x05b32006,
705 0x05b329a7,
706 0x05b40006,
707 0x05b409a7,
708 0x05b4e006,
709 0x05b4e9a7,
710 0x05b5c006,
711 0x05b5c9a7,
712 0x05b6a006,
713 0x05b6a9a7,
714 0x05b78006,
715 0x05b789a7,
716 0x05b86006,
717 0x05b869a7,
718 0x05b94006,
719 0x05b949a7,
720 0x05ba2006,
721 0x05ba29a7,
722 0x05bb0006,
723 0x05bb09a7,
724 0x05bbe006,
725 0x05bbe9a7,
726 0x05bcc006,
727 0x05bcc9a7,
728 0x05bda006,
729 0x05bda9a7,
730 0x05be8006,
731 0x05be89a7,
732 0x05bf6006,
733 0x05bf69a7,
734 0x05c04006,
735 0x05c049a7,
736 0x05c12006,
737 0x05c129a7,
738 0x05c20006,
739 0x05c209a7,
740 0x05c2e006,
741 0x05c2e9a7,
742 0x05c3c006,
743 0x05c3c9a7,
744 0x05c4a006,
745 0x05c4a9a7,
746 0x05c58006,
747 0x05c589a7,
748 0x05c66006,
749 0x05c669a7,
750 0x05c74006,
751 0x05c749a7,
752 0x05c82006,
753 0x05c829a7,
754 0x05c90006,
755 0x05c909a7,
756 0x05c9e006,
757 0x05c9e9a7,
758 0x05cac006,
759 0x05cac9a7,
760 0x05cba006,
761 0x05cba9a7,
762 0x05cc8006,
763 0x05cc89a7,
764 0x05cd6006,
765 0x05cd69a7,
766 0x05ce4006,
767 0x05ce49a7,
768 0x05cf2006,
769 0x05cf29a7,
770 0x05d00006,
771 0x05d009a7,
772 0x05d0e006,
773 0x05d0e9a7,
774 0x05d1c006,
775 0x05d1c9a7,
776 0x05d2a006,
777 0x05d2a9a7,
778 0x05d38006,
779 0x05d389a7,
780 0x05d46006,
781 0x05d469a7,
782 0x05d54006,
783 0x05d549a7,
784 0x05d62006,
785 0x05d629a7,
786 0x05d70006,
787 0x05d709a7,
788 0x05d7e006,
789 0x05d7e9a7,
790 0x05d8c006,
791 0x05d8c9a7,
792 0x05d9a006,
793 0x05d9a9a7,
794 0x05da8006,
795 0x05da89a7,
796 0x05db6006,
797 0x05db69a7,
798 0x05dc4006,
799 0x05dc49a7,
800 0x05dd2006,
801 0x05dd29a7,
802 0x05de0006,
803 0x05de09a7,
804 0x05dee006,
805 0x05dee9a7,
806 0x05dfc006,
807 0x05dfc9a7,
808 0x05e0a006,
809 0x05e0a9a7,
810 0x05e18006,
811 0x05e189a7,
812 0x05e26006,
813 0x05e269a7,
814 0x05e34006,
815 0x05e349a7,
816 0x05e42006,
817 0x05e429a7,
818 0x05e50006,
819 0x05e509a7,
820 0x05e5e006,
821 0x05e5e9a7,
822 0x05e6c006,
823 0x05e6c9a7,
824 0x05e7a006,
825 0x05e7a9a7,
826 0x05e88006,
827 0x05e889a7,
828 0x05e96006,
829 0x05e969a7,
830 0x05ea4006,
831 0x05ea49a7,
832 0x05eb2006,
833 0x05eb29a7,
834 0x05ec0006,
835 0x05ec09a7,
836 0x05ece006,
837 0x05ece9a7,
838 0x05edc006,
839 0x05edc9a7,
840 0x05eea006,
841 0x05eea9a7,
842 0x05ef8006,
843 0x05ef89a7,
844 0x05f06006,
845 0x05f069a7,
846 0x05f14006,
847 0x05f149a7,
848 0x05f22006,
849 0x05f229a7,
850 0x05f30006,
851 0x05f309a7,
852 0x05f3e006,
853 0x05f3e9a7,
854 0x05f4c006,
855 0x05f4c9a7,
856 0x05f5a006,
857 0x05f5a9a7,
858 0x05f68006,
859 0x05f689a7,
860 0x05f76006,
861 0x05f769a7,
862 0x05f84006,
863 0x05f849a7,
864 0x05f92006,
865 0x05f929a7,
866 0x05fa0006,
867 0x05fa09a7,
868 0x05fae006,
869 0x05fae9a7,
870 0x05fbc006,
871 0x05fbc9a7,
872 0x05fca006,
873 0x05fca9a7,
874 0x05fd8006,
875 0x05fd89a7,
876 0x05fe6006,
877 0x05fe69a7,
878 0x05ff4006,
879 0x05ff49a7,
880 0x06002006,
881 0x060029a7,
882 0x06010006,
883 0x060109a7,
884 0x0601e006,
885 0x0601e9a7,
886 0x0602c006,
887 0x0602c9a7,
888 0x0603a006,
889 0x0603a9a7,
890 0x06048006,
891 0x060489a7,
892 0x06056006,
893 0x060569a7,
894 0x06064006,
895 0x060649a7,
896 0x06072006,
897 0x060729a7,
898 0x06080006,
899 0x060809a7,
900 0x0608e006,
901 0x0608e9a7,
902 0x0609c006,
903 0x0609c9a7,
904 0x060aa006,
905 0x060aa9a7,
906 0x060b8006,
907 0x060b89a7,
908 0x060c6006,
909 0x060c69a7,
910 0x060d4006,
911 0x060d49a7,
912 0x060e2006,
913 0x060e29a7,
914 0x060f0006,
915 0x060f09a7,
916 0x060fe006,
917 0x060fe9a7,
918 0x0610c006,
919 0x0610c9a7,
920 0x0611a006,
921 0x0611a9a7,
922 0x06128006,
923 0x061289a7,
924 0x06136006,
925 0x061369a7,
926 0x06144006,
927 0x061449a7,
928 0x06152006,
929 0x061529a7,
930 0x06160006,
931 0x061609a7,
932 0x0616e006,
933 0x0616e9a7,
934 0x0617c006,
935 0x0617c9a7,
936 0x0618a006,
937 0x0618a9a7,
938 0x06198006,
939 0x061989a7,
940 0x061a6006,
941 0x061a69a7,
942 0x061b4006,
943 0x061b49a7,
944 0x061c2006,
945 0x061c29a7,
946 0x061d0006,
947 0x061d09a7,
948 0x061de006,
949 0x061de9a7,
950 0x061ec006,
951 0x061ec9a7,
952 0x061fa006,
953 0x061fa9a7,
954 0x06208006,
955 0x062089a7,
956 0x06216006,
957 0x062169a7,
958 0x06224006,
959 0x062249a7,
960 0x06232006,
961 0x062329a7,
962 0x06240006,
963 0x062409a7,
964 0x0624e006,
965 0x0624e9a7,
966 0x0625c006,
967 0x0625c9a7,
968 0x0626a006,
969 0x0626a9a7,
970 0x06278006,
971 0x062789a7,
972 0x06286006,
973 0x062869a7,
974 0x06294006,
975 0x062949a7,
976 0x062a2006,
977 0x062a29a7,
978 0x062b0006,
979 0x062b09a7,
980 0x062be006,
981 0x062be9a7,
982 0x062cc006,
983 0x062cc9a7,
984 0x062da006,
985 0x062da9a7,
986 0x062e8006,
987 0x062e89a7,
988 0x062f6006,
989 0x062f69a7,
990 0x06304006,
991 0x063049a7,
992 0x06312006,
993 0x063129a7,
994 0x06320006,
995 0x063209a7,
996 0x0632e006,
997 0x0632e9a7,
998 0x0633c006,
999 0x0633c9a7,
1000 0x0634a006,
1001 0x0634a9a7,
1002 0x06358006,
1003 0x063589a7,
1004 0x06366006,
1005 0x063669a7,
1006 0x06374006,
1007 0x063749a7,
1008 0x06382006,
1009 0x063829a7,
1010 0x06390006,
1011 0x063909a7,
1012 0x0639e006,
1013 0x0639e9a7,
1014 0x063ac006,
1015 0x063ac9a7,
1016 0x063ba006,
1017 0x063ba9a7,
1018 0x063c8006,
1019 0x063c89a7,
1020 0x063d6006,
1021 0x063d69a7,
1022 0x063e4006,
1023 0x063e49a7,
1024 0x063f2006,
1025 0x063f29a7,
1026 0x06400006,
1027 0x064009a7,
1028 0x0640e006,
1029 0x0640e9a7,
1030 0x0641c006,
1031 0x0641c9a7,
1032 0x0642a006,
1033 0x0642a9a7,
1034 0x06438006,
1035 0x064389a7,
1036 0x06446006,
1037 0x064469a7,
1038 0x06454006,
1039 0x064549a7,
1040 0x06462006,
1041 0x064629a7,
1042 0x06470006,
1043 0x064709a7,
1044 0x0647e006,
1045 0x0647e9a7,
1046 0x0648c006,
1047 0x0648c9a7,
1048 0x0649a006,
1049 0x0649a9a7,
1050 0x064a8006,
1051 0x064a89a7,
1052 0x064b6006,
1053 0x064b69a7,
1054 0x064c4006,
1055 0x064c49a7,
1056 0x064d2006,
1057 0x064d29a7,
1058 0x064e0006,
1059 0x064e09a7,
1060 0x064ee006,
1061 0x064ee9a7,
1062 0x064fc006,
1063 0x064fc9a7,
1064 0x0650a006,
1065 0x0650a9a7,
1066 0x06518006,
1067 0x065189a7,
1068 0x06526006,
1069 0x065269a7,
1070 0x06534006,
1071 0x065349a7,
1072 0x06542006,
1073 0x065429a7,
1074 0x06550006,
1075 0x065509a7,
1076 0x0655e006,
1077 0x0655e9a7,
1078 0x0656c006,
1079 0x0656c9a7,
1080 0x0657a006,
1081 0x0657a9a7,
1082 0x06588006,
1083 0x065889a7,
1084 0x06596006,
1085 0x065969a7,
1086 0x065a4006,
1087 0x065a49a7,
1088 0x065b2006,
1089 0x065b29a7,
1090 0x065c0006,
1091 0x065c09a7,
1092 0x065ce006,
1093 0x065ce9a7,
1094 0x065dc006,
1095 0x065dc9a7,
1096 0x065ea006,
1097 0x065ea9a7,
1098 0x065f8006,
1099 0x065f89a7,
1100 0x06606006,
1101 0x066069a7,
1102 0x06614006,
1103 0x066149a7,
1104 0x06622006,
1105 0x066229a7,
1106 0x06630006,
1107 0x066309a7,
1108 0x0663e006,
1109 0x0663e9a7,
1110 0x0664c006,
1111 0x0664c9a7,
1112 0x0665a006,
1113 0x0665a9a7,
1114 0x06668006,
1115 0x066689a7,
1116 0x06676006,
1117 0x066769a7,
1118 0x06684006,
1119 0x066849a7,
1120 0x06692006,
1121 0x066929a7,
1122 0x066a0006,
1123 0x066a09a7,
1124 0x066ae006,
1125 0x066ae9a7,
1126 0x066bc006,
1127 0x066bc9a7,
1128 0x066ca006,
1129 0x066ca9a7,
1130 0x066d8006,
1131 0x066d89a7,
1132 0x066e6006,
1133 0x066e69a7,
1134 0x066f4006,
1135 0x066f49a7,
1136 0x06702006,
1137 0x067029a7,
1138 0x06710006,
1139 0x067109a7,
1140 0x0671e006,
1141 0x0671e9a7,
1142 0x0672c006,
1143 0x0672c9a7,
1144 0x0673a006,
1145 0x0673a9a7,
1146 0x06748006,
1147 0x067489a7,
1148 0x06756006,
1149 0x067569a7,
1150 0x06764006,
1151 0x067649a7,
1152 0x06772006,
1153 0x067729a7,
1154 0x06780006,
1155 0x067809a7,
1156 0x0678e006,
1157 0x0678e9a7,
1158 0x0679c006,
1159 0x0679c9a7,
1160 0x067aa006,
1161 0x067aa9a7,
1162 0x067b8006,
1163 0x067b89a7,
1164 0x067c6006,
1165 0x067c69a7,
1166 0x067d4006,
1167 0x067d49a7,
1168 0x067e2006,
1169 0x067e29a7,
1170 0x067f0006,
1171 0x067f09a7,
1172 0x067fe006,
1173 0x067fe9a7,
1174 0x0680c006,
1175 0x0680c9a7,
1176 0x0681a006,
1177 0x0681a9a7,
1178 0x06828006,
1179 0x068289a7,
1180 0x06836006,
1181 0x068369a7,
1182 0x06844006,
1183 0x068449a7,
1184 0x06852006,
1185 0x068529a7,
1186 0x06860006,
1187 0x068609a7,
1188 0x0686e006,
1189 0x0686e9a7,
1190 0x0687c006,
1191 0x0687c9a7,
1192 0x0688a006,
1193 0x0688a9a7,
1194 0x06898006,
1195 0x068989a7,
1196 0x068a6006,
1197 0x068a69a7,
1198 0x068b4006,
1199 0x068b49a7,
1200 0x068c2006,
1201 0x068c29a7,
1202 0x068d0006,
1203 0x068d09a7,
1204 0x068de006,
1205 0x068de9a7,
1206 0x068ec006,
1207 0x068ec9a7,
1208 0x068fa006,
1209 0x068fa9a7,
1210 0x06908006,
1211 0x069089a7,
1212 0x06916006,
1213 0x069169a7,
1214 0x06924006,
1215 0x069249a7,
1216 0x06932006,
1217 0x069329a7,
1218 0x06940006,
1219 0x069409a7,
1220 0x0694e006,
1221 0x0694e9a7,
1222 0x0695c006,
1223 0x0695c9a7,
1224 0x0696a006,
1225 0x0696a9a7,
1226 0x06978006,
1227 0x069789a7,
1228 0x06986006,
1229 0x069869a7,
1230 0x06994006,
1231 0x069949a7,
1232 0x069a2006,
1233 0x069a29a7,
1234 0x069b0006,
1235 0x069b09a7,
1236 0x069be006,
1237 0x069be9a7,
1238 0x069cc006,
1239 0x069cc9a7,
1240 0x069da006,
1241 0x069da9a7,
1242 0x069e8006,
1243 0x069e89a7,
1244 0x069f6006,
1245 0x069f69a7,
1246 0x06a04006,
1247 0x06a049a7,
1248 0x06a12006,
1249 0x06a129a7,
1250 0x06a20006,
1251 0x06a209a7,
1252 0x06a2e006,
1253 0x06a2e9a7,
1254 0x06a3c006,
1255 0x06a3c9a7,
1256 0x06a4a006,
1257 0x06a4a9a7,
1258 0x06a58006,
1259 0x06a589a7,
1260 0x06a66006,
1261 0x06a669a7,
1262 0x06a74006,
1263 0x06a749a7,
1264 0x06a82006,
1265 0x06a829a7,
1266 0x06a90006,
1267 0x06a909a7,
1268 0x06a9e006,
1269 0x06a9e9a7,
1270 0x06aac006,
1271 0x06aac9a7,
1272 0x06aba006,
1273 0x06aba9a7,
1274 0x06ac8006,
1275 0x06ac89a7,
1276 0x06ad6006,
1277 0x06ad69a7,
1278 0x06ae4006,
1279 0x06ae49a7,
1280 0x06af2006,
1281 0x06af29a7,
1282 0x06b00006,
1283 0x06b009a7,
1284 0x06b0e006,
1285 0x06b0e9a7,
1286 0x06b1c006,
1287 0x06b1c9a7,
1288 0x06b2a006,
1289 0x06b2a9a7,
1290 0x06b38006,
1291 0x06b389a7,
1292 0x06b46006,
1293 0x06b469a7,
1294 0x06b54006,
1295 0x06b549a7,
1296 0x06b62006,
1297 0x06b629a7,
1298 0x06b70006,
1299 0x06b709a7,
1300 0x06b7e006,
1301 0x06b7e9a7,
1302 0x06b8c006,
1303 0x06b8c9a7,
1304 0x06b9a006,
1305 0x06b9a9a7,
1306 0x06ba8006,
1307 0x06ba89a7,
1308 0x06bb6006,
1309 0x06bb69a7,
1310 0x06bc4006,
1311 0x06bc49a7,
1312 0x06bd816c,
1313 0x06be5b0b,
1314 0x07d8f002,
1315 0x07f000f2,
1316 0x07f100f2,
1317 0x07f7f801,
1318 0x07fcf012,
1319 0x07ff80b1,
1320 0x080fe802,
1321 0x08170002,
1322 0x081bb042,
1323 0x08500822,
1324 0x08502812,
1325 0x08506032,
1326 0x0851c022,
1327 0x0851f802,
1328 0x08572812,
1329 0x08692032,
1330 0x08755812,
1331 0x0877e822,
1332 0x087a30a2,
1333 0x087c1032,
1334 0x0880000a,
1335 0x08800802,
1336 0x0880100a,
1337 0x0881c0e2,
1338 0x08838002,
1339 0x08839812,
1340 0x0883f822,
1341 0x0884100a,
1342 0x0885802a,
1343 0x08859832,
1344 0x0885b81a,
1345 0x0885c812,
1346 0x0885e808,
1347 0x08861002,
1348 0x08866808,
1349 0x08880022,
1350 0x08893842,
1351 0x0889600a,
1352 0x08896872,
1353 0x088a281a,
1354 0x088b9802,
1355 0x088c0012,
1356 0x088c100a,
1357 0x088d982a,
1358 0x088db082,
1359 0x088df81a,
1360 0x088e1018,
1361 0x088e4832,
1362 0x088e700a,
1363 0x088e7802,
1364 0x0891602a,
1365 0x08917822,
1366 0x0891901a,
1367 0x0891a002,
1368 0x0891a80a,
1369 0x0891b012,
1370 0x0891f002,
1371 0x08920802,
1372 0x0896f802,
1373 0x0897002a,
1374 0x08971872,
1375 0x08980012,
1376 0x0898101a,
1377 0x0899d812,
1378 0x0899f002,
1379 0x0899f80a,
1380 0x089a0002,
1381 0x089a083a,
1382 0x089a381a,
1383 0x089a582a,
1384 0x089ab802,
1385 0x089b101a,
1386 0x089b3062,
1387 0x089b8042,
1388 0x08a1a82a,
1389 0x08a1c072,
1390 0x08a2001a,
1391 0x08a21022,
1392 0x08a2280a,
1393 0x08a23002,
1394 0x08a2f002,
1395 0x08a58002,
1396 0x08a5881a,
1397 0x08a59852,
1398 0x08a5c80a,
1399 0x08a5d002,
1400 0x08a5d81a,
1401 0x08a5e802,
1402 0x08a5f00a,
1403 0x08a5f812,
1404 0x08a6080a,
1405 0x08a61012,
1406 0x08ad7802,
1407 0x08ad801a,
1408 0x08ad9032,
1409 0x08adc03a,
1410 0x08ade012,
1411 0x08adf00a,
1412 0x08adf812,
1413 0x08aee012,
1414 0x08b1802a,
1415 0x08b19872,
1416 0x08b1d81a,
1417 0x08b1e802,
1418 0x08b1f00a,
1419 0x08b1f812,
1420 0x08b55802,
1421 0x08b5600a,
1422 0x08b56802,
1423 0x08b5701a,
1424 0x08b58052,
1425 0x08b5b00a,
1426 0x08b5b802,
1427 0x08b8e822,
1428 0x08b91032,
1429 0x08b9300a,
1430 0x08b93842,
1431 0x08c1602a,
1432 0x08c17882,
1433 0x08c1c00a,
1434 0x08c1c812,
1435 0x08c98002,
1436 0x08c9884a,
1437 0x08c9b81a,
1438 0x08c9d812,
1439 0x08c9e80a,
1440 0x08c9f002,
1441 0x08c9f808,
1442 0x08ca000a,
1443 0x08ca0808,
1444 0x08ca100a,
1445 0x08ca1802,
1446 0x08ce882a,
1447 0x08cea032,
1448 0x08ced012,
1449 0x08cee03a,
1450 0x08cf0002,
1451 0x08cf200a,
1452 0x08d00892,
1453 0x08d19852,
1454 0x08d1c80a,
1455 0x08d1d008,
1456 0x08d1d832,
1457 0x08d23802,
1458 0x08d28852,
1459 0x08d2b81a,
1460 0x08d2c822,
1461 0x08d42058,
1462 0x08d450c2,
1463 0x08d4b80a,
1464 0x08d4c012,
1465 0x08e1780a,
1466 0x08e18062,
1467 0x08e1c052,
1468 0x08e1f00a,
1469 0x08e1f802,
1470 0x08e49152,
1471 0x08e5480a,
1472 0x08e55062,
1473 0x08e5880a,
1474 0x08e59012,
1475 0x08e5a00a,
1476 0x08e5a812,
1477 0x08e98852,
1478 0x08e9d002,
1479 0x08e9e012,
1480 0x08e9f862,
1481 0x08ea3008,
1482 0x08ea3802,
1483 0x08ec504a,
1484 0x08ec8012,
1485 0x08ec981a,
1486 0x08eca802,
1487 0x08ecb00a,
1488 0x08ecb802,
1489 0x08f79812,
1490 0x08f7a81a,
1491 0x08f80012,
1492 0x08f81008,
1493 0x08f8180a,
1494 0x08f9a01a,
1495 0x08f9b042,
1496 0x08f9f01a,
1497 0x08fa0002,
1498 0x08fa080a,
1499 0x08fa1002,
1500 0x09a180f1,
1501 0x09a20002,
1502 0x09a238e2,
1503 0x0b578042,
1504 0x0b598062,
1505 0x0b7a7802,
1506 0x0b7a8b6a,
1507 0x0b7c7832,
1508 0x0b7f2002,
1509 0x0b7f801a,
1510 0x0de4e812,
1511 0x0de50031,
1512 0x0e7802d2,
1513 0x0e798162,
1514 0x0e8b2802,
1515 0x0e8b300a,
1516 0x0e8b3822,
1517 0x0e8b680a,
1518 0x0e8b7042,
1519 0x0e8b9871,
1520 0x0e8bd872,
1521 0x0e8c2862,
1522 0x0e8d5032,
1523 0x0e921022,
1524 0x0ed00362,
1525 0x0ed1db12,
1526 0x0ed3a802,
1527 0x0ed42002,
1528 0x0ed4d842,
1529 0x0ed508e2,
1530 0x0f000062,
1531 0x0f004102,
1532 0x0f00d862,
1533 0x0f011812,
1534 0x0f013042,
1535 0x0f047802,
1536 0x0f098062,
1537 0x0f157002,
1538 0x0f176032,
1539 0x0f276032,
1540 0x0f468062,
1541 0x0f4a2062,
1542 0x0f8007f3,
1543 0x0f8407f3,
1544 0x0f886823,
1545 0x0f897803,
1546 0x0f8b6053,
1547 0x0f8bf013,
1548 0x0f8c7003,
1549 0x0f8c8893,
1550 0x0f8d6b83,
1551 0x0f8f3199,
1552 0x0f9008e3,
1553 0x0f90d003,
1554 0x0f917803,
1555 0x0f919083,
1556 0x0f91e033,
1557 0x0f924ff3,
1558 0x0f964ff3,
1559 0x0f9a4ff3,
1560 0x0f9e4b13,
1561 0x0f9fd842,
1562 0x0fa007f3,
1563 0x0fa407f3,
1564 0x0fa803d3,
1565 0x0faa37f3,
1566 0x0fae37f3,
1567 0x0fb23093,
1568 0x0fb407f3,
1569 0x0fbba0b3,
1570 0x0fbeaaa3,
1571 0x0fc06033,
1572 0x0fc24073,
1573 0x0fc2d053,
1574 0x0fc44073,
1575 0x0fc57513,
1576 0x0fc862e3,
1577 0x0fc9e093,
1578 0x0fca3ff3,
1579 0x0fce3ff3,
1580 0x0fd23ff3,
1581 0x0fd63b83,
1582 0x0fe007f3,
1583 0x0fe407f3,
1584 0x0fe807f3,
1585 0x0fec07f3,
1586 0x0ff007f3,
1587 0x0ff407f3,
1588 0x0ff807f3,
1589 0x0ffc07d3,
1590 0x700001f1,
1591 0x700105f2,
1592 0x700407f1,
1593 0x700807f2,
1594 0x700c06f2,
1595 0x700f87f1,
1596 0x701387f1,
1597 0x701787f1,
1598 0x701b87f1,
1599 0x701f87f1,
1600 0x702387f1,
1601 0x702787f1,
1602 0x702b87f1,
1603 0x702f87f1,
1604 0x703387f1,
1605 0x703787f1,
1606 0x703b87f1,
1607 0x703f87f1,
1608 0x704387f1,
1609 0x704787f1,
1610 0x704b87f1,
1611 0x704f87f1,
1612 0x705387f1,
1613 0x705787f1,
1614 0x705b87f1,
1615 0x705f87f1,
1616 0x706387f1,
1617 0x706787f1,
1618 0x706b87f1,
1619 0x706f87f1,
1620 0x707387f1,
1621 0x707787f1,
1622 0x707b87f1,
1623 0x707f80f1};
2931624
2941625/// Returns the extended grapheme cluster bondary property of a code point.
2951626[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __property __get_property(const char32_t __code_point) noexcept {
296 // TODO FMT use std::ranges::upper_bound.
297
2981627 // The algorithm searches for the upper bound of the range and, when found,
2991628 // steps back one entry. This algorithm is used since the code point can be
3001629 // anywhere in the range. After a lower bound is found the next step is to
......@@ -311,7 +1640,7 @@ inline constexpr uint32_t __entries[1480] = {
3111640 // size. Then the upper bound for code point 3 will return the entry after
3121641 // 0x1810. After moving to the previous entry the algorithm arrives at the
3131642 // correct entry.
314 ptrdiff_t __i = std::upper_bound(__entries, std::end(__entries), (__code_point << 11) | 0x7ffu) - __entries;
1643 ptrdiff_t __i = std::ranges::upper_bound(__entries, (__code_point << 11) | 0x7ffu) - __entries;
3151644 if (__i == 0)
3161645 return __property::__none;
3171646
lib/libcxx/include/__format/format_arg.h+35-5
......@@ -45,16 +45,22 @@ namespace __format {
4545/// It could be packed in 4-bits but that means a new type directly becomes an
4646/// ABI break. The packed type is 64-bit so this reduces the maximum number of
4747/// packed elements from 16 to 12.
48///
49/// @note Some members of this enum are an extension. These extensions need
50/// special behaviour in visit_format_arg. There they need to be wrapped in a
51/// handle to satisfy the user observable behaviour. The internal function
52/// __visit_format_arg doesn't do this wrapping. So in the format functions
53/// this function is used to avoid unneeded overhead.
4854enum class _LIBCPP_ENUM_VIS __arg_t : uint8_t {
4955 __none,
5056 __boolean,
5157 __char_type,
5258 __int,
5359 __long_long,
54 __i128,
60 __i128, // extension
5561 __unsigned,
5662 __unsigned_long_long,
57 __u128,
63 __u128, // extension
5864 __float,
5965 __double,
6066 __long_double,
......@@ -85,9 +91,11 @@ constexpr __arg_t __get_packed_type(uint64_t __types, size_t __id) {
8591
8692} // namespace __format
8793
94// This function is not user obervable, so it can directly use the non-standard
95// types of the "variant". See __arg_t for more details.
8896template <class _Visitor, class _Context>
89_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT decltype(auto) visit_format_arg(_Visitor&& __vis,
90 basic_format_arg<_Context> __arg) {
97_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT decltype(auto)
98__visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) {
9199 switch (__arg.__type_) {
92100 case __format::__arg_t::__none:
93101 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__monostate_);
......@@ -153,7 +161,7 @@ public:
153161 using _Dp = remove_cvref_t<_Tp>;
154162 using _Formatter = typename _Context::template formatter_type<_Dp>;
155163 constexpr bool __const_formattable =
156 requires { _Formatter().format(declval<const _Dp&>(), declval<_Context&>()); };
164 requires { _Formatter().format(std::declval<const _Dp&>(), std::declval<_Context&>()); };
157165 using _Qp = conditional_t<__const_formattable, const _Dp, _Dp>;
158166
159167 static_assert(__const_formattable || !is_const_v<remove_reference_t<_Tp>>, "Mandated by [format.arg]/18");
......@@ -265,6 +273,28 @@ private:
265273 typename __basic_format_arg_value<_Context>::__handle& __handle_;
266274};
267275
276// This function is user facing, so it must wrap the non-standard types of
277// the "variant" in a handle to stay conforming. See __arg_t for more details.
278template <class _Visitor, class _Context>
279_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT decltype(auto)
280visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) {
281 switch (__arg.__type_) {
282# ifndef _LIBCPP_HAS_NO_INT128
283 case __format::__arg_t::__i128: {
284 typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__i128_};
285 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});
286 }
287
288 case __format::__arg_t::__u128: {
289 typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__u128_};
290 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});
291 }
292# endif
293 default:
294 return _VSTD::__visit_format_arg(_VSTD::forward<_Visitor>(__vis), __arg);
295 }
296}
297
268298#endif //_LIBCPP_STD_VER > 17
269299
270300_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__format/format_arg_store.h+3-2
......@@ -19,6 +19,7 @@
1919#include <__config>
2020#include <__format/concepts.h>
2121#include <__format/format_arg.h>
22#include <__utility/forward.h>
2223#include <cstring>
2324#include <string>
2425#include <string_view>
......@@ -197,7 +198,7 @@ _LIBCPP_HIDE_FROM_ABI void __create_packed_storage(uint64_t& __types, __basic_fo
197198 int __shift = 0;
198199 (
199200 [&] {
200 basic_format_arg<_Context> __arg = __create_format_arg<_Context>(__args);
201 basic_format_arg<_Context> __arg = __format::__create_format_arg<_Context>(__args);
201202 if (__shift != 0)
202203 __types |= static_cast<uint64_t>(__arg.__type_) << __shift;
203204 else
......@@ -211,7 +212,7 @@ _LIBCPP_HIDE_FROM_ABI void __create_packed_storage(uint64_t& __types, __basic_fo
211212
212213template <class _Context, class... _Args>
213214_LIBCPP_HIDE_FROM_ABI void __store_basic_format_arg(basic_format_arg<_Context>* __data, _Args&&... __args) noexcept {
214 ([&] { *__data++ = __create_format_arg<_Context>(__args); }(), ...);
215 ([&] { *__data++ = __format::__create_format_arg<_Context>(__args); }(), ...);
215216}
216217
217218template <class _Context, size_t N>
lib/libcxx/include/__format/format_args.h+1
......@@ -71,6 +71,7 @@ private:
7171 const basic_format_arg<_Context>* __args_;
7272 };
7373};
74_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_format_args);
7475
7576#endif //_LIBCPP_STD_VER > 17
7677
lib/libcxx/include/__format/format_context.h+80-8
......@@ -11,14 +11,19 @@
1111#define _LIBCPP___FORMAT_FORMAT_CONTEXT_H
1212
1313#include <__availability>
14#include <__concepts/same_as.h>
1415#include <__config>
1516#include <__format/buffer.h>
17#include <__format/format_arg.h>
18#include <__format/format_arg_store.h>
1619#include <__format/format_args.h>
20#include <__format/format_error.h>
1721#include <__format/format_fwd.h>
1822#include <__iterator/back_insert_iterator.h>
1923#include <__iterator/concepts.h>
24#include <__memory/addressof.h>
2025#include <__utility/move.h>
21#include <concepts>
26#include <__variant/monostate.h>
2227#include <cstddef>
2328
2429#ifndef _LIBCPP_HAS_NO_LOCALIZATION
......@@ -50,8 +55,7 @@ __format_context_create(
5055 _OutIt __out_it,
5156 basic_format_args<basic_format_context<_OutIt, _CharT>> __args,
5257 optional<_VSTD::locale>&& __loc = nullopt) {
53 return _VSTD::basic_format_context(_VSTD::move(__out_it), __args,
54 _VSTD::move(__loc));
58 return _VSTD::basic_format_context(_VSTD::move(__out_it), __args, _VSTD::move(__loc));
5559}
5660#else
5761template <class _OutIt, class _CharT>
......@@ -87,9 +91,6 @@ public:
8791 template <class _Tp>
8892 using formatter_type = formatter<_Tp, _CharT>;
8993
90 basic_format_context(const basic_format_context&) = delete;
91 basic_format_context& operator=(const basic_format_context&) = delete;
92
9394 _LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context>
9495 arg(size_t __id) const noexcept {
9596 return __args_.get(__id);
......@@ -101,8 +102,8 @@ public:
101102 return *__loc_;
102103 }
103104#endif
104 _LIBCPP_HIDE_FROM_ABI iterator out() { return __out_it_; }
105 _LIBCPP_HIDE_FROM_ABI void advance_to(iterator __it) { __out_it_ = __it; }
105 _LIBCPP_HIDE_FROM_ABI iterator out() { return std::move(__out_it_); }
106 _LIBCPP_HIDE_FROM_ABI void advance_to(iterator __it) { __out_it_ = std::move(__it); }
106107
107108private:
108109 iterator __out_it_;
......@@ -144,6 +145,77 @@ private:
144145#endif
145146};
146147
148// A specialization for __retarget_buffer
149//
150// See __retarget_buffer for the motivation for this specialization.
151//
152// This context holds a reference to the instance of the basic_format_context
153// that is retargeted. It converts a formatting argument when it is requested
154// during formatting. It is expected that the usage of the arguments is rare so
155// the lookups are not expected to be used often. An alternative would be to
156// convert all elements during construction.
157//
158// The elements of the retargets context are only used when an underlying
159// formatter uses a locale specific formatting or an formatting argument is
160// part for the format spec. For example
161// format("{:256:{}}", input, 8);
162// Here the width of an element in input is determined dynamically.
163// Note when the top-level element has no width the retargeting is not needed.
164template <class _CharT>
165class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT
166 basic_format_context<typename __format::__retarget_buffer<_CharT>::__iterator, _CharT> {
167public:
168 using iterator = typename __format::__retarget_buffer<_CharT>::__iterator;
169 using char_type = _CharT;
170 template <class _Tp>
171 using formatter_type = formatter<_Tp, _CharT>;
172
173 template <class _Context>
174 _LIBCPP_HIDE_FROM_ABI explicit basic_format_context(iterator __out_it, _Context& __ctx)
175 : __out_it_(std::move(__out_it)),
176# ifndef _LIBCPP_HAS_NO_LOCALIZATION
177 __loc_([](void* __c) { return static_cast<_Context*>(__c)->locale(); }),
178# endif
179 __ctx_(std::addressof(__ctx)),
180 __arg_([](void* __c, size_t __id) {
181 return std::visit_format_arg(
182 [&](auto __arg) -> basic_format_arg<basic_format_context> {
183 if constexpr (same_as<decltype(__arg), monostate>)
184 return {};
185 else if constexpr (same_as<decltype(__arg), typename basic_format_arg<_Context>::handle>)
186 // At the moment it's not possible for formatting to use a re-targeted handle.
187 // TODO FMT add this when support is needed.
188 std::__throw_format_error("Re-targeting handle not supported");
189 else
190 return basic_format_arg<basic_format_context>{
191 __format::__determine_arg_t<basic_format_context, decltype(__arg)>(),
192 __basic_format_arg_value<basic_format_context>(__arg)};
193 },
194 static_cast<_Context*>(__c)->arg(__id));
195 }) {
196 }
197
198 _LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context> arg(size_t __id) const noexcept {
199 return __arg_(__ctx_, __id);
200 }
201# ifndef _LIBCPP_HAS_NO_LOCALIZATION
202 _LIBCPP_HIDE_FROM_ABI _VSTD::locale locale() { return __loc_(__ctx_); }
203# endif
204 _LIBCPP_HIDE_FROM_ABI iterator out() { return std::move(__out_it_); }
205 _LIBCPP_HIDE_FROM_ABI void advance_to(iterator __it) { __out_it_ = std::move(__it); }
206
207private:
208 iterator __out_it_;
209
210# ifndef _LIBCPP_HAS_NO_LOCALIZATION
211 std::locale (*__loc_)(void* __ctx);
212# endif
213
214 void* __ctx_;
215 basic_format_arg<basic_format_context> (*__arg_)(void* __ctx, size_t __id);
216};
217
218_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_format_context);
147219#endif //_LIBCPP_STD_VER > 17
148220
149221_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__format/format_error.h+9-5
......@@ -11,11 +11,8 @@
1111#define _LIBCPP___FORMAT_FORMAT_ERROR_H
1212
1313#include <__config>
14#include <stdexcept>
15
16#ifdef _LIBCPP_NO_EXCEPTIONS
1714#include <cstdlib>
18#endif
15#include <stdexcept>
1916
2017#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2118# pragma GCC system_header
......@@ -31,7 +28,14 @@ public:
3128 : runtime_error(__s) {}
3229 _LIBCPP_HIDE_FROM_ABI explicit format_error(const char* __s)
3330 : runtime_error(__s) {}
34 virtual ~format_error() noexcept;
31 // TODO FMT Remove when format is no longer experimental.
32 // Avoids linker errors when building the Clang-cl Windows DLL which doesn't
33 // support the experimental library.
34# ifndef _LIBCPP_INLINE_FORMAT_ERROR_DTOR
35 ~format_error() noexcept override;
36# else
37 ~format_error() noexcept override {}
38# endif
3539};
3640
3741_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void
lib/libcxx/include/__format/format_functions.h created+661
......@@ -0,0 +1,661 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___FORMAT_FORMAT_FUNCTIONS
11#define _LIBCPP___FORMAT_FORMAT_FUNCTIONS
12
13// TODO FMT This is added to fix Apple back-deployment.
14#include <version>
15#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
16
17#include <__algorithm/clamp.h>
18#include <__availability>
19#include <__concepts/convertible_to.h>
20#include <__concepts/same_as.h>
21#include <__config>
22#include <__debug>
23#include <__format/buffer.h>
24#include <__format/format_arg.h>
25#include <__format/format_arg_store.h>
26#include <__format/format_args.h>
27#include <__format/format_context.h>
28#include <__format/format_error.h>
29#include <__format/format_parse_context.h>
30#include <__format/format_string.h>
31#include <__format/format_to_n_result.h>
32#include <__format/formatter.h>
33#include <__format/formatter_bool.h>
34#include <__format/formatter_char.h>
35#include <__format/formatter_floating_point.h>
36#include <__format/formatter_integer.h>
37#include <__format/formatter_pointer.h>
38#include <__format/formatter_string.h>
39#include <__format/parser_std_format_spec.h>
40#include <__iterator/back_insert_iterator.h>
41#include <__iterator/incrementable_traits.h>
42#include <__variant/monostate.h>
43#include <array>
44#include <string>
45#include <string_view>
46
47#ifndef _LIBCPP_HAS_NO_LOCALIZATION
48#include <locale>
49#endif
50
51#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
52# pragma GCC system_header
53#endif
54
55_LIBCPP_BEGIN_NAMESPACE_STD
56
57#if _LIBCPP_STD_VER > 17
58
59// TODO FMT Evaluate which templates should be external templates. This
60// improves the efficiency of the header. However since the header is still
61// under heavy development and not all classes are stable it makes no sense
62// to do this optimization now.
63
64using format_args = basic_format_args<format_context>;
65#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
66using wformat_args = basic_format_args<wformat_context>;
67#endif
68
69template <class _Context = format_context, class... _Args>
70_LIBCPP_HIDE_FROM_ABI __format_arg_store<_Context, _Args...> make_format_args(_Args&&... __args) {
71 return _VSTD::__format_arg_store<_Context, _Args...>(__args...);
72}
73
74#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
75template <class... _Args>
76_LIBCPP_HIDE_FROM_ABI __format_arg_store<wformat_context, _Args...> make_wformat_args(_Args&&... __args) {
77 return _VSTD::__format_arg_store<wformat_context, _Args...>(__args...);
78}
79#endif
80
81namespace __format {
82
83/// Helper class parse and handle argument.
84///
85/// When parsing a handle which is not enabled the code is ill-formed.
86/// This helper uses the parser of the appropriate formatter for the stored type.
87template <class _CharT>
88class _LIBCPP_TEMPLATE_VIS __compile_time_handle {
89public:
90 _LIBCPP_HIDE_FROM_ABI
91 constexpr void __parse(basic_format_parse_context<_CharT>& __parse_ctx) const { __parse_(__parse_ctx); }
92
93 template <class _Tp>
94 _LIBCPP_HIDE_FROM_ABI constexpr void __enable() {
95 __parse_ = [](basic_format_parse_context<_CharT>& __parse_ctx) {
96 formatter<_Tp, _CharT> __f;
97 __parse_ctx.advance_to(__f.parse(__parse_ctx));
98 };
99 }
100
101 // Before calling __parse the proper handler needs to be set with __enable.
102 // The default handler isn't a core constant expression.
103 _LIBCPP_HIDE_FROM_ABI constexpr __compile_time_handle()
104 : __parse_([](basic_format_parse_context<_CharT>&) { std::__throw_format_error("Not a handle"); }) {}
105
106private:
107 void (*__parse_)(basic_format_parse_context<_CharT>&);
108};
109
110// Dummy format_context only providing the parts used during constant
111// validation of the basic_format_string.
112template <class _CharT>
113struct _LIBCPP_TEMPLATE_VIS __compile_time_basic_format_context {
114public:
115 using char_type = _CharT;
116
117 _LIBCPP_HIDE_FROM_ABI constexpr explicit __compile_time_basic_format_context(
118 const __arg_t* __args, const __compile_time_handle<_CharT>* __handles, size_t __size)
119 : __args_(__args), __handles_(__handles), __size_(__size) {}
120
121 // During the compile-time validation nothing needs to be written.
122 // Therefore all operations of this iterator are a NOP.
123 struct iterator {
124 _LIBCPP_HIDE_FROM_ABI constexpr iterator& operator=(_CharT) { return *this; }
125 _LIBCPP_HIDE_FROM_ABI constexpr iterator& operator*() { return *this; }
126 _LIBCPP_HIDE_FROM_ABI constexpr iterator operator++(int) { return *this; }
127 };
128
129 _LIBCPP_HIDE_FROM_ABI constexpr __arg_t arg(size_t __id) const {
130 if (__id >= __size_)
131 std::__throw_format_error("Argument index out of bounds");
132 return __args_[__id];
133 }
134
135 _LIBCPP_HIDE_FROM_ABI constexpr const __compile_time_handle<_CharT>& __handle(size_t __id) const {
136 if (__id >= __size_)
137 std::__throw_format_error("Argument index out of bounds");
138 return __handles_[__id];
139 }
140
141 _LIBCPP_HIDE_FROM_ABI constexpr iterator out() { return {}; }
142 _LIBCPP_HIDE_FROM_ABI constexpr void advance_to(iterator) {}
143
144private:
145 const __arg_t* __args_;
146 const __compile_time_handle<_CharT>* __handles_;
147 size_t __size_;
148};
149
150_LIBCPP_HIDE_FROM_ABI
151constexpr void __compile_time_validate_integral(__arg_t __type) {
152 switch (__type) {
153 case __arg_t::__int:
154 case __arg_t::__long_long:
155 case __arg_t::__i128:
156 case __arg_t::__unsigned:
157 case __arg_t::__unsigned_long_long:
158 case __arg_t::__u128:
159 return;
160
161 default:
162 std::__throw_format_error("Argument isn't an integral type");
163 }
164}
165
166// _HasPrecision does the formatter have a precision?
167template <class _CharT, class _Tp, bool _HasPrecision = false>
168_LIBCPP_HIDE_FROM_ABI constexpr void
169__compile_time_validate_argument(basic_format_parse_context<_CharT>& __parse_ctx,
170 __compile_time_basic_format_context<_CharT>& __ctx) {
171 formatter<_Tp, _CharT> __formatter;
172 __parse_ctx.advance_to(__formatter.parse(__parse_ctx));
173 // [format.string.std]/7
174 // ... If the corresponding formatting argument is not of integral type, or
175 // its value is negative for precision or non-positive for width, an
176 // exception of type format_error is thrown.
177 //
178 // Validate whether the arguments are integrals.
179 if (__formatter.__parser_.__width_as_arg_)
180 __format::__compile_time_validate_integral(__ctx.arg(__formatter.__parser_.__width_));
181
182 if constexpr (_HasPrecision)
183 if (__formatter.__parser_.__precision_as_arg_)
184 __format::__compile_time_validate_integral(__ctx.arg(__formatter.__parser_.__precision_));
185}
186
187// This function is not user facing, so it can directly use the non-standard types of the "variant".
188template <class _CharT>
189_LIBCPP_HIDE_FROM_ABI constexpr void __compile_time_visit_format_arg(basic_format_parse_context<_CharT>& __parse_ctx,
190 __compile_time_basic_format_context<_CharT>& __ctx,
191 __arg_t __type) {
192 switch (__type) {
193 case __arg_t::__none:
194 std::__throw_format_error("Invalid argument");
195 case __arg_t::__boolean:
196 return __format::__compile_time_validate_argument<_CharT, bool>(__parse_ctx, __ctx);
197 case __arg_t::__char_type:
198 return __format::__compile_time_validate_argument<_CharT, _CharT>(__parse_ctx, __ctx);
199 case __arg_t::__int:
200 return __format::__compile_time_validate_argument<_CharT, int>(__parse_ctx, __ctx);
201 case __arg_t::__long_long:
202 return __format::__compile_time_validate_argument<_CharT, long long>(__parse_ctx, __ctx);
203 case __arg_t::__i128:
204# ifndef _LIBCPP_HAS_NO_INT128
205 return __format::__compile_time_validate_argument<_CharT, __int128_t>(__parse_ctx, __ctx);
206# else
207 std::__throw_format_error("Invalid argument");
208# endif
209 return;
210 case __arg_t::__unsigned:
211 return __format::__compile_time_validate_argument<_CharT, unsigned>(__parse_ctx, __ctx);
212 case __arg_t::__unsigned_long_long:
213 return __format::__compile_time_validate_argument<_CharT, unsigned long long>(__parse_ctx, __ctx);
214 case __arg_t::__u128:
215# ifndef _LIBCPP_HAS_NO_INT128
216 return __format::__compile_time_validate_argument<_CharT, __uint128_t>(__parse_ctx, __ctx);
217# else
218 std::__throw_format_error("Invalid argument");
219# endif
220 return;
221 case __arg_t::__float:
222 return __format::__compile_time_validate_argument<_CharT, float, true>(__parse_ctx, __ctx);
223 case __arg_t::__double:
224 return __format::__compile_time_validate_argument<_CharT, double, true>(__parse_ctx, __ctx);
225 case __arg_t::__long_double:
226 return __format::__compile_time_validate_argument<_CharT, long double, true>(__parse_ctx, __ctx);
227 case __arg_t::__const_char_type_ptr:
228 return __format::__compile_time_validate_argument<_CharT, const _CharT*, true>(__parse_ctx, __ctx);
229 case __arg_t::__string_view:
230 return __format::__compile_time_validate_argument<_CharT, basic_string_view<_CharT>, true>(__parse_ctx, __ctx);
231 case __arg_t::__ptr:
232 return __format::__compile_time_validate_argument<_CharT, const void*>(__parse_ctx, __ctx);
233 case __arg_t::__handle:
234 std::__throw_format_error("Handle should use __compile_time_validate_handle_argument");
235 }
236 std::__throw_format_error("Invalid argument");
237}
238
239template <class _CharT, class _ParseCtx, class _Ctx>
240_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
241__handle_replacement_field(const _CharT* __begin, const _CharT* __end,
242 _ParseCtx& __parse_ctx, _Ctx& __ctx) {
243 __format::__parse_number_result __r = __format::__parse_arg_id(__begin, __end, __parse_ctx);
244
245 bool __parse = *__r.__ptr == _CharT(':');
246 switch (*__r.__ptr) {
247 case _CharT(':'):
248 // The arg-id has a format-specifier, advance the input to the format-spec.
249 __parse_ctx.advance_to(__r.__ptr + 1);
250 break;
251 case _CharT('}'):
252 // The arg-id has no format-specifier.
253 __parse_ctx.advance_to(__r.__ptr);
254 break;
255 default:
256 std::__throw_format_error("The replacement field arg-id should terminate at a ':' or '}'");
257 }
258
259 if constexpr (same_as<_Ctx, __compile_time_basic_format_context<_CharT>>) {
260 __arg_t __type = __ctx.arg(__r.__value);
261 if (__type == __arg_t::__handle)
262 __ctx.__handle(__r.__value).__parse(__parse_ctx);
263 else
264 __format::__compile_time_visit_format_arg(__parse_ctx, __ctx, __type);
265 } else
266 _VSTD::__visit_format_arg(
267 [&](auto __arg) {
268 if constexpr (same_as<decltype(__arg), monostate>)
269 std::__throw_format_error("Argument index out of bounds");
270 else if constexpr (same_as<decltype(__arg), typename basic_format_arg<_Ctx>::handle>)
271 __arg.format(__parse_ctx, __ctx);
272 else {
273 formatter<decltype(__arg), _CharT> __formatter;
274 if (__parse)
275 __parse_ctx.advance_to(__formatter.parse(__parse_ctx));
276 __ctx.advance_to(__formatter.format(__arg, __ctx));
277 }
278 },
279 __ctx.arg(__r.__value));
280
281 __begin = __parse_ctx.begin();
282 if (__begin == __end || *__begin != _CharT('}'))
283 std::__throw_format_error("The replacement field misses a terminating '}'");
284
285 return ++__begin;
286}
287
288template <class _ParseCtx, class _Ctx>
289_LIBCPP_HIDE_FROM_ABI constexpr typename _Ctx::iterator
290__vformat_to(_ParseCtx&& __parse_ctx, _Ctx&& __ctx) {
291 using _CharT = typename _ParseCtx::char_type;
292 static_assert(same_as<typename _Ctx::char_type, _CharT>);
293
294 const _CharT* __begin = __parse_ctx.begin();
295 const _CharT* __end = __parse_ctx.end();
296 typename _Ctx::iterator __out_it = __ctx.out();
297 while (__begin != __end) {
298 switch (*__begin) {
299 case _CharT('{'):
300 ++__begin;
301 if (__begin == __end)
302 std::__throw_format_error("The format string terminates at a '{'");
303
304 if (*__begin != _CharT('{')) [[likely]] {
305 __ctx.advance_to(_VSTD::move(__out_it));
306 __begin =
307 __format::__handle_replacement_field(__begin, __end, __parse_ctx, __ctx);
308 __out_it = __ctx.out();
309
310 // The output is written and __begin points to the next character. So
311 // start the next iteration.
312 continue;
313 }
314 // The string is an escape character.
315 break;
316
317 case _CharT('}'):
318 ++__begin;
319 if (__begin == __end || *__begin != _CharT('}'))
320 std::__throw_format_error("The format string contains an invalid escape sequence");
321
322 break;
323 }
324
325 // Copy the character to the output verbatim.
326 *__out_it++ = *__begin++;
327 }
328 return __out_it;
329}
330
331} // namespace __format
332
333template <class _CharT, class... _Args>
334struct _LIBCPP_TEMPLATE_VIS basic_format_string {
335 template <class _Tp>
336 requires convertible_to<const _Tp&, basic_string_view<_CharT>>
337 consteval basic_format_string(const _Tp& __str) : __str_{__str} {
338 __format::__vformat_to(basic_format_parse_context<_CharT>{__str_, sizeof...(_Args)},
339 _Context{__types_.data(), __handles_.data(), sizeof...(_Args)});
340 }
341
342 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT constexpr basic_string_view<_CharT> get() const noexcept {
343 return __str_;
344 }
345
346private:
347 basic_string_view<_CharT> __str_;
348
349 using _Context = __format::__compile_time_basic_format_context<_CharT>;
350
351 static constexpr array<__format::__arg_t, sizeof...(_Args)> __types_{
352 __format::__determine_arg_t<_Context, remove_cvref_t<_Args>>()...};
353
354 // TODO FMT remove this work-around when the AIX ICE has been resolved.
355# if defined(_AIX) && defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1400
356 template <class _Tp>
357 static constexpr __format::__compile_time_handle<_CharT> __get_handle() {
358 __format::__compile_time_handle<_CharT> __handle;
359 if (__format::__determine_arg_t<_Context, _Tp>() == __format::__arg_t::__handle)
360 __handle.template __enable<_Tp>();
361
362 return __handle;
363 }
364
365 static constexpr array<__format::__compile_time_handle<_CharT>, sizeof...(_Args)> __handles_{
366 __get_handle<_Args>()...};
367# else
368 static constexpr array<__format::__compile_time_handle<_CharT>, sizeof...(_Args)> __handles_{[] {
369 using _Tp = remove_cvref_t<_Args>;
370 __format::__compile_time_handle<_CharT> __handle;
371 if (__format::__determine_arg_t<_Context, _Tp>() == __format::__arg_t::__handle)
372 __handle.template __enable<_Tp>();
373
374 return __handle;
375 }()...};
376# endif
377};
378
379template <class... _Args>
380using format_string = basic_format_string<char, type_identity_t<_Args>...>;
381
382#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
383template <class... _Args>
384using wformat_string = basic_format_string<wchar_t, type_identity_t<_Args>...>;
385#endif
386
387template <class _OutIt, class _CharT, class _FormatOutIt>
388requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt
389 __vformat_to(
390 _OutIt __out_it, basic_string_view<_CharT> __fmt,
391 basic_format_args<basic_format_context<_FormatOutIt, _CharT>> __args) {
392 if constexpr (same_as<_OutIt, _FormatOutIt>)
393 return _VSTD::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()},
394 _VSTD::__format_context_create(_VSTD::move(__out_it), __args));
395 else {
396 __format::__format_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it)};
397 _VSTD::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()},
398 _VSTD::__format_context_create(__buffer.__make_output_iterator(), __args));
399 return _VSTD::move(__buffer).__out_it();
400 }
401}
402
403// The function is _LIBCPP_ALWAYS_INLINE since the compiler is bad at inlining
404// https://reviews.llvm.org/D110499#inline-1180704
405// TODO FMT Evaluate whether we want to file a Clang bug report regarding this.
406template <output_iterator<const char&> _OutIt>
407_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
408vformat_to(_OutIt __out_it, string_view __fmt, format_args __args) {
409 return _VSTD::__vformat_to(_VSTD::move(__out_it), __fmt, __args);
410}
411
412#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
413template <output_iterator<const wchar_t&> _OutIt>
414_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
415vformat_to(_OutIt __out_it, wstring_view __fmt, wformat_args __args) {
416 return _VSTD::__vformat_to(_VSTD::move(__out_it), __fmt, __args);
417}
418#endif
419
420template <output_iterator<const char&> _OutIt, class... _Args>
421_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
422format_to(_OutIt __out_it, format_string<_Args...> __fmt, _Args&&... __args) {
423 return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.get(),
424 _VSTD::make_format_args(__args...));
425}
426
427#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
428template <output_iterator<const wchar_t&> _OutIt, class... _Args>
429_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
430format_to(_OutIt __out_it, wformat_string<_Args...> __fmt, _Args&&... __args) {
431 return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.get(),
432 _VSTD::make_wformat_args(__args...));
433}
434#endif
435
436_LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string
437vformat(string_view __fmt, format_args __args) {
438 string __res;
439 _VSTD::vformat_to(_VSTD::back_inserter(__res), __fmt, __args);
440 return __res;
441}
442
443#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
444_LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring
445vformat(wstring_view __fmt, wformat_args __args) {
446 wstring __res;
447 _VSTD::vformat_to(_VSTD::back_inserter(__res), __fmt, __args);
448 return __res;
449}
450#endif
451
452template <class... _Args>
453_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string format(format_string<_Args...> __fmt,
454 _Args&&... __args) {
455 return _VSTD::vformat(__fmt.get(), _VSTD::make_format_args(__args...));
456}
457
458#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
459template <class... _Args>
460_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring
461format(wformat_string<_Args...> __fmt, _Args&&... __args) {
462 return _VSTD::vformat(__fmt.get(), _VSTD::make_wformat_args(__args...));
463}
464#endif
465
466template <class _Context, class _OutIt, class _CharT>
467_LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n,
468 basic_string_view<_CharT> __fmt,
469 basic_format_args<_Context> __args) {
470 __format::__format_to_n_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it), __n};
471 _VSTD::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()},
472 _VSTD::__format_context_create(__buffer.__make_output_iterator(), __args));
473 return _VSTD::move(__buffer).__result();
474}
475
476template <output_iterator<const char&> _OutIt, class... _Args>
477_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
478format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, format_string<_Args...> __fmt, _Args&&... __args) {
479 return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, __fmt.get(), _VSTD::make_format_args(__args...));
480}
481
482#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
483template <output_iterator<const wchar_t&> _OutIt, class... _Args>
484_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
485format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, wformat_string<_Args...> __fmt,
486 _Args&&... __args) {
487 return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, __fmt.get(), _VSTD::make_wformat_args(__args...));
488}
489#endif
490
491template <class _CharT>
492_LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(basic_string_view<_CharT> __fmt, auto __args) {
493 __format::__formatted_size_buffer<_CharT> __buffer;
494 _VSTD::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()},
495 _VSTD::__format_context_create(__buffer.__make_output_iterator(), __args));
496 return _VSTD::move(__buffer).__result();
497}
498
499template <class... _Args>
500_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
501formatted_size(format_string<_Args...> __fmt, _Args&&... __args) {
502 return _VSTD::__vformatted_size(__fmt.get(), basic_format_args{_VSTD::make_format_args(__args...)});
503}
504
505#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
506template <class... _Args>
507_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
508formatted_size(wformat_string<_Args...> __fmt, _Args&&... __args) {
509 return _VSTD::__vformatted_size(__fmt.get(), basic_format_args{_VSTD::make_wformat_args(__args...)});
510}
511#endif
512
513#ifndef _LIBCPP_HAS_NO_LOCALIZATION
514
515template <class _OutIt, class _CharT, class _FormatOutIt>
516requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt
517 __vformat_to(
518 _OutIt __out_it, locale __loc, basic_string_view<_CharT> __fmt,
519 basic_format_args<basic_format_context<_FormatOutIt, _CharT>> __args) {
520 if constexpr (same_as<_OutIt, _FormatOutIt>)
521 return _VSTD::__format::__vformat_to(
522 basic_format_parse_context{__fmt, __args.__size()},
523 _VSTD::__format_context_create(_VSTD::move(__out_it), __args, _VSTD::move(__loc)));
524 else {
525 __format::__format_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it)};
526 _VSTD::__format::__vformat_to(
527 basic_format_parse_context{__fmt, __args.__size()},
528 _VSTD::__format_context_create(__buffer.__make_output_iterator(), __args, _VSTD::move(__loc)));
529 return _VSTD::move(__buffer).__out_it();
530 }
531}
532
533template <output_iterator<const char&> _OutIt>
534_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt vformat_to(
535 _OutIt __out_it, locale __loc, string_view __fmt, format_args __args) {
536 return _VSTD::__vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt,
537 __args);
538}
539
540#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
541template <output_iterator<const wchar_t&> _OutIt>
542_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt vformat_to(
543 _OutIt __out_it, locale __loc, wstring_view __fmt, wformat_args __args) {
544 return _VSTD::__vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt,
545 __args);
546}
547#endif
548
549template <output_iterator<const char&> _OutIt, class... _Args>
550_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
551format_to(_OutIt __out_it, locale __loc, format_string<_Args...> __fmt, _Args&&... __args) {
552 return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.get(),
553 _VSTD::make_format_args(__args...));
554}
555
556#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
557template <output_iterator<const wchar_t&> _OutIt, class... _Args>
558_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
559format_to(_OutIt __out_it, locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
560 return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.get(),
561 _VSTD::make_wformat_args(__args...));
562}
563#endif
564
565_LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string
566vformat(locale __loc, string_view __fmt, format_args __args) {
567 string __res;
568 _VSTD::vformat_to(_VSTD::back_inserter(__res), _VSTD::move(__loc), __fmt,
569 __args);
570 return __res;
571}
572
573#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
574_LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring
575vformat(locale __loc, wstring_view __fmt, wformat_args __args) {
576 wstring __res;
577 _VSTD::vformat_to(_VSTD::back_inserter(__res), _VSTD::move(__loc), __fmt,
578 __args);
579 return __res;
580}
581#endif
582
583template <class... _Args>
584_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string format(locale __loc,
585 format_string<_Args...> __fmt,
586 _Args&&... __args) {
587 return _VSTD::vformat(_VSTD::move(__loc), __fmt.get(),
588 _VSTD::make_format_args(__args...));
589}
590
591#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
592template <class... _Args>
593_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring
594format(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
595 return _VSTD::vformat(_VSTD::move(__loc), __fmt.get(),
596 _VSTD::make_wformat_args(__args...));
597}
598#endif
599
600template <class _Context, class _OutIt, class _CharT>
601_LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n,
602 locale __loc, basic_string_view<_CharT> __fmt,
603 basic_format_args<_Context> __args) {
604 __format::__format_to_n_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it), __n};
605 _VSTD::__format::__vformat_to(
606 basic_format_parse_context{__fmt, __args.__size()},
607 _VSTD::__format_context_create(__buffer.__make_output_iterator(), __args, _VSTD::move(__loc)));
608 return _VSTD::move(__buffer).__result();
609}
610
611template <output_iterator<const char&> _OutIt, class... _Args>
612_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
613format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, format_string<_Args...> __fmt,
614 _Args&&... __args) {
615 return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.get(),
616 _VSTD::make_format_args(__args...));
617}
618
619#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
620template <output_iterator<const wchar_t&> _OutIt, class... _Args>
621_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
622format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, wformat_string<_Args...> __fmt,
623 _Args&&... __args) {
624 return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.get(),
625 _VSTD::make_wformat_args(__args...));
626}
627#endif
628
629template <class _CharT>
630_LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(locale __loc, basic_string_view<_CharT> __fmt, auto __args) {
631 __format::__formatted_size_buffer<_CharT> __buffer;
632 _VSTD::__format::__vformat_to(
633 basic_format_parse_context{__fmt, __args.__size()},
634 _VSTD::__format_context_create(__buffer.__make_output_iterator(), __args, _VSTD::move(__loc)));
635 return _VSTD::move(__buffer).__result();
636}
637
638template <class... _Args>
639_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
640formatted_size(locale __loc, format_string<_Args...> __fmt, _Args&&... __args) {
641 return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.get(), basic_format_args{_VSTD::make_format_args(__args...)});
642}
643
644#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
645template <class... _Args>
646_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
647formatted_size(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
648 return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.get(), basic_format_args{_VSTD::make_wformat_args(__args...)});
649}
650#endif
651
652#endif // _LIBCPP_HAS_NO_LOCALIZATION
653
654
655#endif //_LIBCPP_STD_VER > 17
656
657_LIBCPP_END_NAMESPACE_STD
658
659#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
660
661#endif // _LIBCPP___FORMAT_FORMAT_FUNCTIONS
lib/libcxx/include/__format/format_parse_context.h+4-5
......@@ -54,8 +54,7 @@ public:
5454
5555 _LIBCPP_HIDE_FROM_ABI constexpr size_t next_arg_id() {
5656 if (__indexing_ == __manual)
57 __throw_format_error("Using automatic argument numbering in manual "
58 "argument numbering mode");
57 std::__throw_format_error("Using automatic argument numbering in manual argument numbering mode");
5958
6059 if (__indexing_ == __unknown)
6160 __indexing_ = __automatic;
......@@ -63,8 +62,7 @@ public:
6362 }
6463 _LIBCPP_HIDE_FROM_ABI constexpr void check_arg_id(size_t __id) {
6564 if (__indexing_ == __automatic)
66 __throw_format_error("Using manual argument numbering in automatic "
67 "argument numbering mode");
65 std::__throw_format_error("Using manual argument numbering in automatic argument numbering mode");
6866
6967 if (__indexing_ == __unknown)
7068 __indexing_ = __manual;
......@@ -77,7 +75,7 @@ public:
7775 // Note: the Throws clause [format.parse.ctx]/10 doesn't specify the
7876 // behavior when id >= num_args_.
7977 if (is_constant_evaluated() && __id >= __num_args_)
80 __throw_format_error("Argument index outside the valid range");
78 std::__throw_format_error("Argument index outside the valid range");
8179 }
8280
8381private:
......@@ -88,6 +86,7 @@ private:
8886 size_t __next_arg_id_;
8987 size_t __num_args_;
9088};
89_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_format_parse_context);
9190
9291using format_parse_context = basic_format_parse_context<char>;
9392#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
lib/libcxx/include/__format/format_string.h+6-4
......@@ -32,6 +32,9 @@ struct _LIBCPP_TEMPLATE_VIS __parse_number_result {
3232 uint32_t __value;
3333};
3434
35template <class _CharT>
36__parse_number_result(const _CharT*, uint32_t) -> __parse_number_result<_CharT>;
37
3538template <class _CharT>
3639_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT>
3740__parse_number(const _CharT* __begin, const _CharT* __end);
......@@ -70,7 +73,7 @@ __parse_automatic(const _CharT* __begin, const _CharT*, auto& __parse_ctx) {
7073template <class _CharT>
7174_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT>
7275__parse_manual(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
73 __parse_number_result<_CharT> __r = __parse_number(__begin, __end);
76 __parse_number_result<_CharT> __r = __format::__parse_number(__begin, __end);
7477 __parse_ctx.check_arg_id(__r.__value);
7578 return __r;
7679}
......@@ -117,7 +120,7 @@ __parse_number(const _CharT* __begin, const _CharT* __end_input) {
117120 if (__v > __number_max ||
118121 (__begin != __end_input && *__begin >= _CharT('0') &&
119122 *__begin <= _CharT('9')))
120 __throw_format_error("The numeric value of the format-spec is too large");
123 std::__throw_format_error("The numeric value of the format-spec is too large");
121124
122125 __value = __v;
123126 }
......@@ -146,8 +149,7 @@ __parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
146149 return __detail::__parse_automatic(__begin, __end, __parse_ctx);
147150 }
148151 if (*__begin < _CharT('0') || *__begin > _CharT('9'))
149 __throw_format_error(
150 "The arg-id of the format-spec starts with an invalid character");
152 std::__throw_format_error("The arg-id of the format-spec starts with an invalid character");
151153
152154 return __detail::__parse_manual(__begin, __end, __parse_ctx);
153155}
lib/libcxx/include/__format/format_to_n_result.h+1
......@@ -26,6 +26,7 @@ struct _LIBCPP_TEMPLATE_VIS format_to_n_result {
2626 _OutIt out;
2727 iter_difference_t<_OutIt> size;
2828};
29_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(format_to_n_result);
2930
3031#endif //_LIBCPP_STD_VER > 17
3132
lib/libcxx/include/__format/formatter.h+8-8
......@@ -11,7 +11,6 @@
1111#define _LIBCPP___FORMAT_FORMATTER_H
1212
1313#include <__availability>
14#include <__concepts/same_as.h>
1514#include <__config>
1615#include <__format/format_fwd.h>
1716
......@@ -39,15 +38,16 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter {
3938 formatter& operator=(const formatter&) = delete;
4039};
4140
42namespace __formatter {
41# if _LIBCPP_STD_VER > 20
4342
44/** The character types that formatters are specialized for. */
45template <class _CharT>
46concept __char_type = same_as<_CharT, char> || same_as<_CharT, wchar_t>;
43template <class _Tp>
44_LIBCPP_HIDE_FROM_ABI constexpr void __set_debug_format(_Tp& __formatter) {
45 if constexpr (requires { __formatter.set_debug_format(); })
46 __formatter.set_debug_format();
47}
4748
48} // namespace __formatter
49
50#endif //_LIBCPP_STD_VER > 17
49# endif // _LIBCPP_STD_VER > 20
50#endif // _LIBCPP_STD_VER > 17
5151
5252_LIBCPP_END_NAMESPACE_STD
5353
lib/libcxx/include/__format/formatter_bool.h+2-2
......@@ -14,8 +14,8 @@
1414#include <__availability>
1515#include <__config>
1616#include <__debug>
17#include <__format/concepts.h>
1718#include <__format/format_error.h>
18#include <__format/format_fwd.h>
1919#include <__format/format_parse_context.h>
2020#include <__format/formatter.h>
2121#include <__format/formatter_integral.h>
......@@ -35,7 +35,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3535
3636#if _LIBCPP_STD_VER > 17
3737
38template <__formatter::__char_type _CharT>
38template <__fmt_char_type _CharT>
3939struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<bool, _CharT> {
4040public:
4141 _LIBCPP_HIDE_FROM_ABI constexpr auto
lib/libcxx/include/__format/formatter_char.h+11-2
......@@ -13,7 +13,7 @@
1313#include <__availability>
1414#include <__concepts/same_as.h>
1515#include <__config>
16#include <__format/format_fwd.h>
16#include <__format/concepts.h>
1717#include <__format/format_parse_context.h>
1818#include <__format/formatter.h>
1919#include <__format/formatter_integral.h>
......@@ -30,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3030
3131#if _LIBCPP_STD_VER > 17
3232
33template <__formatter::__char_type _CharT>
33template <__fmt_char_type _CharT>
3434struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_char {
3535public:
3636 _LIBCPP_HIDE_FROM_ABI constexpr auto
......@@ -44,6 +44,11 @@ public:
4444 if (__parser_.__type_ == __format_spec::__type::__default || __parser_.__type_ == __format_spec::__type::__char)
4545 return __formatter::__format_char(__value, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx));
4646
47# if _LIBCPP_STD_VER > 20
48 if (__parser_.__type_ == __format_spec::__type::__debug)
49 return __formatter::__format_escaped_char(__value, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx));
50# endif
51
4752 if constexpr (sizeof(_CharT) <= sizeof(int))
4853 // Promotes _CharT to an integral type. This reduces the number of
4954 // instantiations of __format_integer reducing code size.
......@@ -61,6 +66,10 @@ public:
6166 return format(static_cast<wchar_t>(__value), __ctx);
6267 }
6368
69# if _LIBCPP_STD_VER > 20
70 _LIBCPP_HIDE_FROM_ABI constexpr void set_debug_format() { __parser_.__type_ = __format_spec::__type::__debug; }
71# endif
72
6473 __format_spec::__parser<_CharT> __parser_;
6574};
6675
lib/libcxx/include/__format/formatter_floating_point.h+72-36
......@@ -10,17 +10,16 @@
1010#ifndef _LIBCPP___FORMAT_FORMATTER_FLOATING_POINT_H
1111#define _LIBCPP___FORMAT_FORMATTER_FLOATING_POINT_H
1212
13#include <__algorithm/copy.h>
1413#include <__algorithm/copy_n.h>
15#include <__algorithm/fill_n.h>
1614#include <__algorithm/find.h>
15#include <__algorithm/max.h>
1716#include <__algorithm/min.h>
1817#include <__algorithm/rotate.h>
1918#include <__algorithm/transform.h>
2019#include <__concepts/arithmetic.h>
2120#include <__concepts/same_as.h>
2221#include <__config>
23#include <__format/format_fwd.h>
22#include <__format/concepts.h>
2423#include <__format/format_parse_context.h>
2524#include <__format/formatter.h>
2625#include <__format/formatter_integral.h>
......@@ -103,7 +102,7 @@ template <class _Tp>
103102struct __traits;
104103
105104template <floating_point _Fp>
106static constexpr size_t __float_buffer_size(int __precision) {
105_LIBCPP_HIDE_FROM_ABI constexpr size_t __float_buffer_size(int __precision) {
107106 using _Traits = __traits<_Fp>;
108107 return 4 + _Traits::__max_integral + __precision + _Traits::__max_fractional_value;
109108}
......@@ -183,6 +182,7 @@ public:
183182 _LIBCPP_HIDE_FROM_ABI int __precision() const { return __precision_; }
184183 _LIBCPP_HIDE_FROM_ABI int __num_trailing_zeros() const { return __num_trailing_zeros_; }
185184 _LIBCPP_HIDE_FROM_ABI void __remove_trailing_zeros() { __num_trailing_zeros_ = 0; }
185 _LIBCPP_HIDE_FROM_ABI void __add_trailing_zeros(int __zeros) { __num_trailing_zeros_ += __zeros; }
186186
187187private:
188188 int __precision_;
......@@ -216,7 +216,7 @@ struct __float_result {
216216/// \returns a pointer to the exponent or __last when not found.
217217constexpr inline _LIBCPP_HIDE_FROM_ABI char* __find_exponent(char* __first, char* __last) {
218218 ptrdiff_t __size = __last - __first;
219 if (__size > 4) {
219 if (__size >= 4) {
220220 __first = __last - _VSTD::min(__size, ptrdiff_t(6));
221221 for (; __first != __last - 3; ++__first) {
222222 if (*__first == 'e')
......@@ -404,6 +404,7 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_lower_case(__float_
404404 // In fixed mode the algorithm truncates trailing spaces and possibly the
405405 // radix point. There's no good guess for the position of the radix point
406406 // therefore scan the output after the first digit.
407
407408 __result.__radix_point = _VSTD::find(__first, __result.__last, '.');
408409 }
409410 }
......@@ -454,7 +455,10 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer(
454455 char* __first = __formatter::__insert_sign(__buffer.begin(), __negative, __sign);
455456 switch (__type) {
456457 case __format_spec::__type::__default:
457 return __formatter::__format_buffer_default(__buffer, __value, __first);
458 if (__has_precision)
459 return __formatter::__format_buffer_general_lower_case(__buffer, __value, __buffer.__precision(), __first);
460 else
461 return __formatter::__format_buffer_default(__buffer, __value, __first);
458462
459463 case __format_spec::__type::__hexfloat_lower_case:
460464 return __formatter::__format_buffer_hexadecimal_lower_case(
......@@ -494,7 +498,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(
494498 const __float_result& __result,
495499 _VSTD::locale __loc,
496500 __format_spec::__parsed_specifications<_CharT> __specs) {
497 const auto& __np = use_facet<numpunct<_CharT>>(__loc);
501 const auto& __np = std::use_facet<numpunct<_CharT>>(__loc);
498502 string __grouping = __np.grouping();
499503 char* __first = __result.__integral;
500504 // When no radix point or exponent are present __last will be __result.__last.
......@@ -528,13 +532,13 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(
528532 // sign and (zero padding or alignment)
529533 if (__zero_padding && __first != __buffer.begin())
530534 *__out_it++ = *__buffer.begin();
531 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
535 __out_it = __formatter::__fill(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
532536 if (!__zero_padding && __first != __buffer.begin())
533537 *__out_it++ = *__buffer.begin();
534538
535539 // integral part
536540 if (__grouping.empty()) {
537 __out_it = _VSTD::copy_n(__first, __digits, _VSTD::move(__out_it));
541 __out_it = __formatter::__copy(__first, __digits, _VSTD::move(__out_it));
538542 } else {
539543 auto __r = __grouping.rbegin();
540544 auto __e = __grouping.rend() - 1;
......@@ -546,7 +550,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(
546550 // This loop achieves that process by testing the termination condition
547551 // midway in the loop.
548552 while (true) {
549 __out_it = _VSTD::copy_n(__first, *__r, _VSTD::move(__out_it));
553 __out_it = __formatter::__copy(__first, *__r, _VSTD::move(__out_it));
550554 __first += *__r;
551555
552556 if (__r == __e)
......@@ -560,16 +564,16 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(
560564 // fractional part
561565 if (__result.__radix_point != __result.__last) {
562566 *__out_it++ = __np.decimal_point();
563 __out_it = _VSTD::copy(__result.__radix_point + 1, __result.__exponent, _VSTD::move(__out_it));
564 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __buffer.__num_trailing_zeros(), _CharT('0'));
567 __out_it = __formatter::__copy(__result.__radix_point + 1, __result.__exponent, _VSTD::move(__out_it));
568 __out_it = __formatter::__fill(_VSTD::move(__out_it), __buffer.__num_trailing_zeros(), _CharT('0'));
565569 }
566570
567571 // exponent
568572 if (__result.__exponent != __result.__last)
569 __out_it = _VSTD::copy(__result.__exponent, __result.__last, _VSTD::move(__out_it));
573 __out_it = __formatter::__copy(__result.__exponent, __result.__last, _VSTD::move(__out_it));
570574
571575 // alignment
572 return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
576 return __formatter::__fill(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
573577}
574578# endif // _LIBCPP_HAS_NO_LOCALIZATION
575579
......@@ -625,20 +629,51 @@ __format_floating_point(_Tp __value, auto& __ctx, __format_spec::__parsed_specif
625629 __float_result __result = __formatter::__format_buffer(
626630 __buffer, __value, __negative, (__specs.__has_precision()), __specs.__std_.__sign_, __specs.__std_.__type_);
627631
628 if (__specs.__std_.__alternate_form_ && __result.__radix_point == __result.__last) {
629 *__result.__last++ = '.';
630
631 // When there is an exponent the point needs to be moved before the
632 // exponent. When there's no exponent the rotate does nothing. Since
633 // rotate tests whether the operation is a nop, call it unconditionally.
634 _VSTD::rotate(__result.__exponent, __result.__last - 1, __result.__last);
635 __result.__radix_point = __result.__exponent;
632 if (__specs.__std_.__alternate_form_) {
633 if (__result.__radix_point == __result.__last) {
634 *__result.__last++ = '.';
635
636 // When there is an exponent the point needs to be moved before the
637 // exponent. When there's no exponent the rotate does nothing. Since
638 // rotate tests whether the operation is a nop, call it unconditionally.
639 _VSTD::rotate(__result.__exponent, __result.__last - 1, __result.__last);
640 __result.__radix_point = __result.__exponent;
641
642 // The radix point is always placed before the exponent.
643 // - No exponent needs to point to the new last.
644 // - An exponent needs to move one position to the right.
645 // So it's safe to increment the value unconditionally.
646 ++__result.__exponent;
647 }
636648
637 // The radix point is always placed before the exponent.
638 // - No exponent needs to point to the new last.
639 // - An exponent needs to move one position to the right.
640 // So it's safe to increment the value unconditionally.
641 ++__result.__exponent;
649 // [format.string.std]/6
650 // In addition, for g and G conversions, trailing zeros are not removed
651 // from the result.
652 //
653 // If the type option for a floating-point type is none it may use the
654 // general formatting, but it's not a g or G conversion. So in that case
655 // the formatting should not append trailing zeros.
656 bool __is_general = __specs.__std_.__type_ == __format_spec::__type::__general_lower_case ||
657 __specs.__std_.__type_ == __format_spec::__type::__general_upper_case;
658
659 if (__is_general) {
660 // https://en.cppreference.com/w/c/io/fprintf
661 // Let P equal the precision if nonzero, 6 if the precision is not
662 // specified, or 1 if the precision is 0. Then, if a conversion with
663 // style E would have an exponent of X:
664 int __p = _VSTD::max(1, (__specs.__has_precision() ? __specs.__precision_ : 6));
665 if (__result.__exponent == __result.__last)
666 // if P > X >= -4, the conversion is with style f or F and precision P - 1 - X.
667 // By including the radix point it calculates P - (1 + X)
668 __p -= __result.__radix_point - __buffer.begin();
669 else
670 // otherwise, the conversion is with style e or E and precision P - 1.
671 --__p;
672
673 ptrdiff_t __precision = (__result.__exponent - __result.__radix_point) - 1;
674 if (__precision < __p)
675 __buffer.__add_trailing_zeros(__p - __precision);
676 }
642677 }
643678
644679# ifndef _LIBCPP_HAS_NO_LOCALIZATION
......@@ -651,14 +686,15 @@ __format_floating_point(_Tp __value, auto& __ctx, __format_spec::__parsed_specif
651686 if (__size + __num_trailing_zeros >= __specs.__width_) {
652687 if (__num_trailing_zeros && __result.__exponent != __result.__last)
653688 // Insert trailing zeros before exponent character.
654 return _VSTD::copy(
689 return __formatter::__copy(
655690 __result.__exponent,
656691 __result.__last,
657 _VSTD::fill_n(
658 _VSTD::copy(__buffer.begin(), __result.__exponent, __ctx.out()), __num_trailing_zeros, _CharT('0')));
692 __formatter::__fill(__formatter::__copy(__buffer.begin(), __result.__exponent, __ctx.out()),
693 __num_trailing_zeros,
694 _CharT('0')));
659695
660 return _VSTD::fill_n(
661 _VSTD::copy(__buffer.begin(), __result.__last, __ctx.out()), __num_trailing_zeros, _CharT('0'));
696 return __formatter::__fill(
697 __formatter::__copy(__buffer.begin(), __result.__last, __ctx.out()), __num_trailing_zeros, _CharT('0'));
662698 }
663699
664700 auto __out_it = __ctx.out();
......@@ -684,7 +720,7 @@ __format_floating_point(_Tp __value, auto& __ctx, __format_spec::__parsed_specif
684720
685721} // namespace __formatter
686722
687template <__formatter::__char_type _CharT>
723template <__fmt_char_type _CharT>
688724struct _LIBCPP_TEMPLATE_VIS __formatter_floating_point {
689725public:
690726 _LIBCPP_HIDE_FROM_ABI constexpr auto
......@@ -702,13 +738,13 @@ public:
702738 __format_spec::__parser<_CharT> __parser_;
703739};
704740
705template <__formatter::__char_type _CharT>
741template <__fmt_char_type _CharT>
706742struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<float, _CharT>
707743 : public __formatter_floating_point<_CharT> {};
708template <__formatter::__char_type _CharT>
744template <__fmt_char_type _CharT>
709745struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<double, _CharT>
710746 : public __formatter_floating_point<_CharT> {};
711template <__formatter::__char_type _CharT>
747template <__fmt_char_type _CharT>
712748struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long double, _CharT>
713749 : public __formatter_floating_point<_CharT> {};
714750
lib/libcxx/include/__format/formatter_integer.h+14-14
......@@ -13,7 +13,7 @@
1313#include <__availability>
1414#include <__concepts/arithmetic.h>
1515#include <__config>
16#include <__format/format_fwd.h>
16#include <__format/concepts.h>
1717#include <__format/format_parse_context.h>
1818#include <__format/formatter.h>
1919#include <__format/formatter_integral.h>
......@@ -30,7 +30,7 @@
3030
3131#if _LIBCPP_STD_VER > 17
3232
33 template <__formatter::__char_type _CharT>
33 template <__fmt_char_type _CharT>
3434 struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_integer {
3535
3636public:
......@@ -59,43 +59,43 @@ public:
5959};
6060
6161// Signed integral types.
62template <__formatter::__char_type _CharT>
62template <__fmt_char_type _CharT>
6363struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<signed char, _CharT>
6464 : public __formatter_integer<_CharT> {};
65template <__formatter::__char_type _CharT>
65template <__fmt_char_type _CharT>
6666struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<short, _CharT> : public __formatter_integer<_CharT> {
6767};
68template <__formatter::__char_type _CharT>
68template <__fmt_char_type _CharT>
6969struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<int, _CharT> : public __formatter_integer<_CharT> {};
70template <__formatter::__char_type _CharT>
70template <__fmt_char_type _CharT>
7171struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long, _CharT> : public __formatter_integer<_CharT> {};
72template <__formatter::__char_type _CharT>
72template <__fmt_char_type _CharT>
7373struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long long, _CharT>
7474 : public __formatter_integer<_CharT> {};
7575# ifndef _LIBCPP_HAS_NO_INT128
76template <__formatter::__char_type _CharT>
76template <__fmt_char_type _CharT>
7777struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<__int128_t, _CharT>
7878 : public __formatter_integer<_CharT> {};
7979# endif
8080
8181// Unsigned integral types.
82template <__formatter::__char_type _CharT>
82template <__fmt_char_type _CharT>
8383struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned char, _CharT>
8484 : public __formatter_integer<_CharT> {};
85template <__formatter::__char_type _CharT>
85template <__fmt_char_type _CharT>
8686struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned short, _CharT>
8787 : public __formatter_integer<_CharT> {};
88template <__formatter::__char_type _CharT>
88template <__fmt_char_type _CharT>
8989struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned, _CharT>
9090 : public __formatter_integer<_CharT> {};
91template <__formatter::__char_type _CharT>
91template <__fmt_char_type _CharT>
9292struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned long, _CharT>
9393 : public __formatter_integer<_CharT> {};
94template <__formatter::__char_type _CharT>
94template <__fmt_char_type _CharT>
9595struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned long long, _CharT>
9696 : public __formatter_integer<_CharT> {};
9797# ifndef _LIBCPP_HAS_NO_INT128
98template <__formatter::__char_type _CharT>
98template <__fmt_char_type _CharT>
9999struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<__uint128_t, _CharT>
100100 : public __formatter_integer<_CharT> {};
101101# endif
lib/libcxx/include/__format/formatter_integral.h+7-6
......@@ -13,11 +13,12 @@
1313#include <__concepts/arithmetic.h>
1414#include <__concepts/same_as.h>
1515#include <__config>
16#include <__format/concepts.h>
1617#include <__format/format_error.h>
17#include <__format/formatter.h> // for __char_type TODO FMT Move the concept?
1818#include <__format/formatter_output.h>
1919#include <__format/parser_std_format_spec.h>
2020#include <__utility/unreachable.h>
21#include <array>
2122#include <charconv>
2223#include <limits>
2324#include <string>
......@@ -112,7 +113,7 @@ _LIBCPP_HIDE_FROM_ABI inline string __determine_grouping(ptrdiff_t __size, const
112113// Char
113114//
114115
115template <__formatter::__char_type _CharT>
116template <__fmt_char_type _CharT>
116117_LIBCPP_HIDE_FROM_ABI auto __format_char(
117118 integral auto __value,
118119 output_iterator<const _CharT&> auto __out_it,
......@@ -216,7 +217,7 @@ _LIBCPP_HIDE_FROM_ABI auto __format_integer(
216217
217218# ifndef _LIBCPP_HAS_NO_LOCALIZATION
218219 if (__specs.__std_.__locale_specific_form_) {
219 const auto& __np = use_facet<numpunct<_CharT>>(__ctx.locale());
220 const auto& __np = std::use_facet<numpunct<_CharT>>(__ctx.locale());
220221 string __grouping = __np.grouping();
221222 ptrdiff_t __size = __last - __first;
222223 // Writing the grouped form has more overhead than the normal output
......@@ -243,7 +244,7 @@ _LIBCPP_HIDE_FROM_ABI auto __format_integer(
243244 // The zero padding is done like:
244245 // - Write [sign][prefix]
245246 // - Write data right aligned with '0' as fill character.
246 __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it));
247 __out_it = __formatter::__copy(__begin, __first, _VSTD::move(__out_it));
247248 __specs.__alignment_ = __format_spec::__alignment::__right;
248249 __specs.__fill_ = _CharT('0');
249250 int32_t __size = __first - __begin;
......@@ -309,7 +310,7 @@ __format_integer(_Tp __value, auto& __ctx, __format_spec::__parsed_specification
309310 auto __r = std::__to_unsigned_like(__value);
310311 bool __negative = __value < 0;
311312 if (__negative)
312 __r = __complement(__r);
313 __r = std::__complement(__r);
313314
314315 return __formatter::__format_integer(__r, __ctx, __specs, __negative);
315316}
......@@ -341,7 +342,7 @@ __format_bool(bool __value, auto& __ctx, __format_spec::__parsed_specifications<
341342 -> decltype(__ctx.out()) {
342343# ifndef _LIBCPP_HAS_NO_LOCALIZATION
343344 if (__specs.__std_.__locale_specific_form_) {
344 const auto& __np = use_facet<numpunct<_CharT>>(__ctx.locale());
345 const auto& __np = std::use_facet<numpunct<_CharT>>(__ctx.locale());
345346 basic_string<_CharT> __str = __value ? __np.truename() : __np.falsename();
346347 return __formatter::__write_string_no_precision(basic_string_view<_CharT>{__str}, __ctx.out(), __specs);
347348 }
lib/libcxx/include/__format/formatter_output.h+308-46
......@@ -10,16 +10,23 @@
1010#ifndef _LIBCPP___FORMAT_FORMATTER_OUTPUT_H
1111#define _LIBCPP___FORMAT_FORMATTER_OUTPUT_H
1212
13#include <__algorithm/copy.h>
14#include <__algorithm/copy_n.h>
15#include <__algorithm/fill_n.h>
16#include <__algorithm/transform.h>
13#include <__algorithm/ranges_copy.h>
14#include <__algorithm/ranges_fill_n.h>
15#include <__algorithm/ranges_transform.h>
16#include <__chrono/statically_widen.h>
17#include <__concepts/same_as.h>
1718#include <__config>
19#include <__format/buffer.h>
20#include <__format/concepts.h>
21#include <__format/escaped_output_table.h>
1822#include <__format/formatter.h>
1923#include <__format/parser_std_format_spec.h>
2024#include <__format/unicode.h>
25#include <__iterator/back_insert_iterator.h>
26#include <__type_traits/make_unsigned.h>
2127#include <__utility/move.h>
2228#include <__utility/unreachable.h>
29#include <charconv>
2330#include <cstddef>
2431#include <string>
2532#include <string_view>
......@@ -86,6 +93,74 @@ __padding_size(size_t __size, size_t __width, __format_spec::__alignment __align
8693 __libcpp_unreachable();
8794}
8895
96/// Copy wrapper.
97///
98/// This uses a "mass output function" of __format::__output_buffer when possible.
99template <__fmt_char_type _CharT, __fmt_char_type _OutCharT = _CharT>
100_LIBCPP_HIDE_FROM_ABI auto __copy(basic_string_view<_CharT> __str, output_iterator<const _OutCharT&> auto __out_it)
101 -> decltype(__out_it) {
102 if constexpr (_VSTD::same_as<decltype(__out_it), _VSTD::back_insert_iterator<__format::__output_buffer<_OutCharT>>>) {
103 __out_it.__get_container()->__copy(__str);
104 return __out_it;
105 } else if constexpr (_VSTD::same_as<decltype(__out_it),
106 typename __format::__retarget_buffer<_OutCharT>::__iterator>) {
107 __out_it.__buffer_->__copy(__str);
108 return __out_it;
109 } else {
110 return std::ranges::copy(__str, _VSTD::move(__out_it)).out;
111 }
112}
113
114template <__fmt_char_type _CharT, __fmt_char_type _OutCharT = _CharT>
115_LIBCPP_HIDE_FROM_ABI auto
116__copy(const _CharT* __first, const _CharT* __last, output_iterator<const _OutCharT&> auto __out_it)
117 -> decltype(__out_it) {
118 return __formatter::__copy(basic_string_view{__first, __last}, _VSTD::move(__out_it));
119}
120
121template <__fmt_char_type _CharT, __fmt_char_type _OutCharT = _CharT>
122_LIBCPP_HIDE_FROM_ABI auto __copy(const _CharT* __first, size_t __n, output_iterator<const _OutCharT&> auto __out_it)
123 -> decltype(__out_it) {
124 return __formatter::__copy(basic_string_view{__first, __n}, _VSTD::move(__out_it));
125}
126
127/// Transform wrapper.
128///
129/// This uses a "mass output function" of __format::__output_buffer when possible.
130template <__fmt_char_type _CharT, __fmt_char_type _OutCharT = _CharT, class _UnaryOperation>
131_LIBCPP_HIDE_FROM_ABI auto
132__transform(const _CharT* __first,
133 const _CharT* __last,
134 output_iterator<const _OutCharT&> auto __out_it,
135 _UnaryOperation __operation) -> decltype(__out_it) {
136 if constexpr (_VSTD::same_as<decltype(__out_it), _VSTD::back_insert_iterator<__format::__output_buffer<_OutCharT>>>) {
137 __out_it.__get_container()->__transform(__first, __last, _VSTD::move(__operation));
138 return __out_it;
139 } else if constexpr (_VSTD::same_as<decltype(__out_it),
140 typename __format::__retarget_buffer<_OutCharT>::__iterator>) {
141 __out_it.__buffer_->__transform(__first, __last, _VSTD::move(__operation));
142 return __out_it;
143 } else {
144 return std::ranges::transform(__first, __last, _VSTD::move(__out_it), __operation).out;
145 }
146}
147
148/// Fill wrapper.
149///
150/// This uses a "mass output function" of __format::__output_buffer when possible.
151template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt>
152_LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, _CharT __value) {
153 if constexpr (_VSTD::same_as<decltype(__out_it), _VSTD::back_insert_iterator<__format::__output_buffer<_CharT>>>) {
154 __out_it.__get_container()->__fill(__n, __value);
155 return __out_it;
156 } else if constexpr (_VSTD::same_as<decltype(__out_it), typename __format::__retarget_buffer<_CharT>::__iterator>) {
157 __out_it.__buffer_->__fill(__n, __value);
158 return __out_it;
159 } else {
160 return std::ranges::fill_n(_VSTD::move(__out_it), __n, __value);
161 }
162}
163
89164template <class _OutIt, class _CharT>
90165_LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, const char* __begin, const char* __first,
91166 const char* __last, string&& __grouping, _CharT __sep,
......@@ -97,22 +172,22 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, c
97172 __padding_size_result __padding = {0, 0};
98173 if (__specs.__alignment_ == __format_spec::__alignment::__zero_padding) {
99174 // Write [sign][prefix].
100 __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it));
175 __out_it = __formatter::__copy(__begin, __first, _VSTD::move(__out_it));
101176
102177 if (__specs.__width_ > __size) {
103178 // Write zero padding.
104179 __padding.__before_ = __specs.__width_ - __size;
105 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __specs.__width_ - __size, _CharT('0'));
180 __out_it = __formatter::__fill(_VSTD::move(__out_it), __specs.__width_ - __size, _CharT('0'));
106181 }
107182 } else {
108183 if (__specs.__width_ > __size) {
109184 // Determine padding and write padding.
110 __padding = __padding_size(__size, __specs.__width_, __specs.__alignment_);
185 __padding = __formatter::__padding_size(__size, __specs.__width_, __specs.__alignment_);
111186
112 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
187 __out_it = __formatter::__fill(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
113188 }
114189 // Write [sign][prefix].
115 __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it));
190 __out_it = __formatter::__copy(__begin, __first, _VSTD::move(__out_it));
116191 }
117192
118193 auto __r = __grouping.rbegin();
......@@ -133,10 +208,10 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, c
133208 while (true) {
134209 if (__specs.__std_.__type_ == __format_spec::__type::__hexadecimal_upper_case) {
135210 __last = __first + *__r;
136 __out_it = _VSTD::transform(__first, __last, _VSTD::move(__out_it), __hex_to_upper);
211 __out_it = __formatter::__transform(__first, __last, _VSTD::move(__out_it), __hex_to_upper);
137212 __first = __last;
138213 } else {
139 __out_it = _VSTD::copy_n(__first, *__r, _VSTD::move(__out_it));
214 __out_it = __formatter::__copy(__first, *__r, _VSTD::move(__out_it));
140215 __first += *__r;
141216 }
142217
......@@ -147,7 +222,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, c
147222 *__out_it++ = __sep;
148223 }
149224
150 return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
225 return __formatter::__fill(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
151226}
152227
153228/// Writes the input to the output with the required padding.
......@@ -155,12 +230,10 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, c
155230/// Since the output column width is specified the function can be used for
156231/// ASCII and Unicode output.
157232///
158/// \pre [\a __first, \a __last) is a valid range.
159233/// \pre \a __size <= \a __width. Using this function when this pre-condition
160234/// doesn't hold incurs an unwanted overhead.
161235///
162/// \param __first Pointer to the first element to write.
163/// \param __last Pointer beyond the last element to write.
236/// \param __str The string to write.
164237/// \param __out_it The output iterator to write to.
165238/// \param __specs The parsed formatting specifications.
166239/// \param __size The (estimated) output column width. When the elements
......@@ -174,31 +247,42 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, c
174247/// conversion, which means the [\a __first, \a __last) always contains elements
175248/// of the type \c char.
176249template <class _CharT, class _ParserCharT>
177_LIBCPP_HIDE_FROM_ABI auto __write(
178 const _CharT* __first,
179 const _CharT* __last,
180 output_iterator<const _CharT&> auto __out_it,
181 __format_spec::__parsed_specifications<_ParserCharT> __specs,
182 ptrdiff_t __size) -> decltype(__out_it) {
183 _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
184
250_LIBCPP_HIDE_FROM_ABI auto
251__write(basic_string_view<_CharT> __str,
252 output_iterator<const _CharT&> auto __out_it,
253 __format_spec::__parsed_specifications<_ParserCharT> __specs,
254 ptrdiff_t __size) -> decltype(__out_it) {
185255 if (__size >= __specs.__width_)
186 return _VSTD::copy(__first, __last, _VSTD::move(__out_it));
256 return __formatter::__copy(__str, _VSTD::move(__out_it));
187257
188258 __padding_size_result __padding = __formatter::__padding_size(__size, __specs.__width_, __specs.__std_.__alignment_);
189 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
190 __out_it = _VSTD::copy(__first, __last, _VSTD::move(__out_it));
191 return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
259 __out_it = __formatter::__fill(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
260 __out_it = __formatter::__copy(__str, _VSTD::move(__out_it));
261 return __formatter::__fill(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
262}
263
264template <class _CharT, class _ParserCharT>
265_LIBCPP_HIDE_FROM_ABI auto
266__write(const _CharT* __first,
267 const _CharT* __last,
268 output_iterator<const _CharT&> auto __out_it,
269 __format_spec::__parsed_specifications<_ParserCharT> __specs,
270 ptrdiff_t __size) -> decltype(__out_it) {
271 _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
272 return __formatter::__write(basic_string_view{__first, __last}, _VSTD::move(__out_it), __specs, __size);
192273}
193274
194275/// \overload
195276///
196277/// Calls the function above where \a __size = \a __last - \a __first.
197278template <class _CharT, class _ParserCharT>
198_LIBCPP_HIDE_FROM_ABI auto __write(const _CharT* __first, const _CharT* __last,
199 output_iterator<const _CharT&> auto __out_it,
200 __format_spec::__parsed_specifications<_ParserCharT> __specs) -> decltype(__out_it) {
201 return __write(__first, __last, _VSTD::move(__out_it), __specs, __last - __first);
279_LIBCPP_HIDE_FROM_ABI auto
280__write(const _CharT* __first,
281 const _CharT* __last,
282 output_iterator<const _CharT&> auto __out_it,
283 __format_spec::__parsed_specifications<_ParserCharT> __specs) -> decltype(__out_it) {
284 _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
285 return __formatter::__write(__first, __last, _VSTD::move(__out_it), __specs, __last - __first);
202286}
203287
204288template <class _CharT, class _ParserCharT, class _UnaryOperation>
......@@ -210,12 +294,12 @@ _LIBCPP_HIDE_FROM_ABI auto __write_transformed(const _CharT* __first, const _Cha
210294
211295 ptrdiff_t __size = __last - __first;
212296 if (__size >= __specs.__width_)
213 return _VSTD::transform(__first, __last, _VSTD::move(__out_it), __op);
297 return __formatter::__transform(__first, __last, _VSTD::move(__out_it), __op);
214298
215 __padding_size_result __padding = __padding_size(__size, __specs.__width_, __specs.__alignment_);
216 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
217 __out_it = _VSTD::transform(__first, __last, _VSTD::move(__out_it), __op);
218 return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
299 __padding_size_result __padding = __formatter::__padding_size(__size, __specs.__width_, __specs.__alignment_);
300 __out_it = __formatter::__fill(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
301 __out_it = __formatter::__transform(__first, __last, _VSTD::move(__out_it), __op);
302 return __formatter::__fill(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
219303}
220304
221305/// Writes additional zero's for the precision before the exponent.
......@@ -239,12 +323,12 @@ _LIBCPP_HIDE_FROM_ABI auto __write_using_trailing_zeros(
239323 _LIBCPP_ASSERT(__num_trailing_zeros > 0, "The overload not writing trailing zeros should have been used");
240324
241325 __padding_size_result __padding =
242 __padding_size(__size + __num_trailing_zeros, __specs.__width_, __specs.__alignment_);
243 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
244 __out_it = _VSTD::copy(__first, __exponent, _VSTD::move(__out_it));
245 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __num_trailing_zeros, _CharT('0'));
246 __out_it = _VSTD::copy(__exponent, __last, _VSTD::move(__out_it));
247 return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
326 __formatter::__padding_size(__size + __num_trailing_zeros, __specs.__width_, __specs.__alignment_);
327 __out_it = __formatter::__fill(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
328 __out_it = __formatter::__copy(__first, __exponent, _VSTD::move(__out_it));
329 __out_it = __formatter::__fill(_VSTD::move(__out_it), __num_trailing_zeros, _CharT('0'));
330 __out_it = __formatter::__copy(__exponent, __last, _VSTD::move(__out_it));
331 return __formatter::__fill(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
248332}
249333
250334/// Writes a string using format's width estimation algorithm.
......@@ -262,7 +346,7 @@ _LIBCPP_HIDE_FROM_ABI auto __write_string_no_precision(
262346
263347 // No padding -> copy the string
264348 if (!__specs.__has_width())
265 return _VSTD::copy(__str.begin(), __str.end(), _VSTD::move(__out_it));
349 return __formatter::__copy(__str, _VSTD::move(__out_it));
266350
267351 // Note when the estimated width is larger than size there's no padding. So
268352 // there's no reason to get the real size when the estimate is larger than or
......@@ -270,8 +354,7 @@ _LIBCPP_HIDE_FROM_ABI auto __write_string_no_precision(
270354 size_t __size =
271355 __format_spec::__estimate_column_width(__str, __specs.__width_, __format_spec::__column_width_rounding::__up)
272356 .__width_;
273
274 return __formatter::__write(__str.begin(), __str.end(), _VSTD::move(__out_it), __specs, __size);
357 return __formatter::__write(__str, _VSTD::move(__out_it), __specs, __size);
275358}
276359
277360template <class _CharT>
......@@ -296,9 +379,188 @@ _LIBCPP_HIDE_FROM_ABI auto __write_string(
296379
297380 int __size = __formatter::__truncate(__str, __specs.__precision_);
298381
299 return __write(__str.begin(), __str.end(), _VSTD::move(__out_it), __specs, __size);
382 return __formatter::__write(__str.begin(), __str.end(), _VSTD::move(__out_it), __specs, __size);
383}
384
385# if _LIBCPP_STD_VER > 20
386
387struct __nul_terminator {};
388
389template <class _CharT>
390_LIBCPP_HIDE_FROM_ABI bool operator==(const _CharT* __cstr, __nul_terminator) {
391 return *__cstr == _CharT('\0');
392}
393
394template <class _CharT>
395_LIBCPP_HIDE_FROM_ABI void
396__write_escaped_code_unit(basic_string<_CharT>& __str, char32_t __value, const _CharT* __prefix) {
397 back_insert_iterator __out_it{__str};
398 std::ranges::copy(__prefix, __nul_terminator{}, __out_it);
399
400 char __buffer[8];
401 to_chars_result __r = std::to_chars(std::begin(__buffer), std::end(__buffer), __value, 16);
402 _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small");
403 std::ranges::copy(std::begin(__buffer), __r.ptr, __out_it);
404
405 __str += _CharT('}');
406}
407
408// [format.string.escaped]/2.2.1.2
409// ...
410// then the sequence \u{hex-digit-sequence} is appended to E, where
411// hex-digit-sequence is the shortest hexadecimal representation of C using
412// lower-case hexadecimal digits.
413template <class _CharT>
414_LIBCPP_HIDE_FROM_ABI void __write_well_formed_escaped_code_unit(basic_string<_CharT>& __str, char32_t __value) {
415 __formatter::__write_escaped_code_unit(__str, __value, _LIBCPP_STATICALLY_WIDEN(_CharT, "\\u{"));
416}
417
418// [format.string.escaped]/2.2.3
419// Otherwise (X is a sequence of ill-formed code units), each code unit U is
420// appended to E in order as the sequence \x{hex-digit-sequence}, where
421// hex-digit-sequence is the shortest hexadecimal representation of U using
422// lower-case hexadecimal digits.
423template <class _CharT>
424_LIBCPP_HIDE_FROM_ABI void __write_escape_ill_formed_code_unit(basic_string<_CharT>& __str, char32_t __value) {
425 __formatter::__write_escaped_code_unit(__str, __value, _LIBCPP_STATICALLY_WIDEN(_CharT, "\\x{"));
426}
427
428template <class _CharT>
429[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool __is_escaped_sequence_written(basic_string<_CharT>& __str, char32_t __value) {
430# ifdef _LIBCPP_HAS_NO_UNICODE
431 // For ASCII assume everything above 127 is printable.
432 if (__value > 127)
433 return false;
434# endif
435
436 if (!__escaped_output_table::__needs_escape(__value))
437 return false;
438
439 __formatter::__write_well_formed_escaped_code_unit(__str, __value);
440 return true;
441}
442
443template <class _CharT>
444[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr char32_t __to_char32(_CharT __value) {
445 return static_cast<make_unsigned_t<_CharT>>(__value);
446}
447
448enum class _LIBCPP_ENUM_VIS __escape_quotation_mark { __apostrophe, __double_quote };
449
450// [format.string.escaped]/2
451template <class _CharT>
452[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool
453__is_escaped_sequence_written(basic_string<_CharT>& __str, char32_t __value, __escape_quotation_mark __mark) {
454 // 2.2.1.1 - Mapped character in [tab:format.escape.sequences]
455 switch (__value) {
456 case _CharT('\t'):
457 __str += _LIBCPP_STATICALLY_WIDEN(_CharT, "\\t");
458 return true;
459 case _CharT('\n'):
460 __str += _LIBCPP_STATICALLY_WIDEN(_CharT, "\\n");
461 return true;
462 case _CharT('\r'):
463 __str += _LIBCPP_STATICALLY_WIDEN(_CharT, "\\r");
464 return true;
465 case _CharT('\''):
466 if (__mark == __escape_quotation_mark::__apostrophe)
467 __str += _LIBCPP_STATICALLY_WIDEN(_CharT, R"(\')");
468 else
469 __str += __value;
470 return true;
471 case _CharT('"'):
472 if (__mark == __escape_quotation_mark::__double_quote)
473 __str += _LIBCPP_STATICALLY_WIDEN(_CharT, R"(\")");
474 else
475 __str += __value;
476 return true;
477 case _CharT('\\'):
478 __str += _LIBCPP_STATICALLY_WIDEN(_CharT, R"(\\)");
479 return true;
480
481 // 2.2.1.2 - Space
482 case _CharT(' '):
483 __str += __value;
484 return true;
485 }
486
487 // 2.2.2
488 // Otherwise, if X is a shift sequence, the effect on E and further
489 // decoding of S is unspecified.
490 // For now shift sequences are ignored and treated as Unicode. Other parts
491 // of the format library do the same. It's unknown how ostream treats them.
492 // TODO FMT determine what to do with shift sequences.
493
494 // 2.2.1.2.1 and 2.2.1.2.2 - Escape
495 return __formatter::__is_escaped_sequence_written(__str, __formatter::__to_char32(__value));
300496}
301497
498template <class _CharT>
499_LIBCPP_HIDE_FROM_ABI void
500__escape(basic_string<_CharT>& __str, basic_string_view<_CharT> __values, __escape_quotation_mark __mark) {
501 __unicode::__code_point_view<_CharT> __view{__values.begin(), __values.end()};
502
503 while (!__view.__at_end()) {
504 const _CharT* __first = __view.__position();
505 typename __unicode::__consume_p2286_result __result = __view.__consume_p2286();
506 if (__result.__ill_formed_size == 0) {
507 if (!__formatter::__is_escaped_sequence_written(__str, __result.__value, __mark))
508 // 2.2.1.3 - Add the character
509 ranges::copy(__first, __view.__position(), std::back_insert_iterator(__str));
510
511 } else {
512 // 2.2.3 sequence of ill-formed code units
513 // The number of code-units in __result.__value depends on the character type being used.
514 if constexpr (sizeof(_CharT) == 1) {
515 _LIBCPP_ASSERT(__result.__ill_formed_size == 1 || __result.__ill_formed_size == 4,
516 "illegal number of invalid code units.");
517 if (__result.__ill_formed_size == 1) // ill-formed, one code unit
518 __formatter::__write_escape_ill_formed_code_unit(__str, __result.__value & 0xff);
519 else { // out of valid range, four code units
520 // The code point was properly encoded, decode the value.
521 __formatter::__write_escape_ill_formed_code_unit(__str, __result.__value >> 18 | 0xf0);
522 __formatter::__write_escape_ill_formed_code_unit(__str, (__result.__value >> 12 & 0x3f) | 0x80);
523 __formatter::__write_escape_ill_formed_code_unit(__str, (__result.__value >> 6 & 0x3f) | 0x80);
524 __formatter::__write_escape_ill_formed_code_unit(__str, (__result.__value & 0x3f) | 0x80);
525 }
526 } else if constexpr (sizeof(_CharT) == 2) {
527 _LIBCPP_ASSERT(__result.__ill_formed_size == 1, "for UTF-16 at most one invalid code unit");
528 __formatter::__write_escape_ill_formed_code_unit(__str, __result.__value & 0xffff);
529 } else {
530 static_assert(sizeof(_CharT) == 4, "unsupported character width");
531 _LIBCPP_ASSERT(__result.__ill_formed_size == 1, "for UTF-32 one code unit is one code point");
532 __formatter::__write_escape_ill_formed_code_unit(__str, __result.__value);
533 }
534 }
535 }
536}
537
538template <class _CharT>
539_LIBCPP_HIDE_FROM_ABI auto
540__format_escaped_char(_CharT __value,
541 output_iterator<const _CharT&> auto __out_it,
542 __format_spec::__parsed_specifications<_CharT> __specs) -> decltype(__out_it) {
543 basic_string<_CharT> __str;
544 __str += _CharT('\'');
545 __formatter::__escape(__str, basic_string_view{std::addressof(__value), 1}, __escape_quotation_mark::__apostrophe);
546 __str += _CharT('\'');
547 return __formatter::__write(__str.data(), __str.data() + __str.size(), _VSTD::move(__out_it), __specs, __str.size());
548}
549
550template <class _CharT>
551_LIBCPP_HIDE_FROM_ABI auto
552__format_escaped_string(basic_string_view<_CharT> __values,
553 output_iterator<const _CharT&> auto __out_it,
554 __format_spec::__parsed_specifications<_CharT> __specs) -> decltype(__out_it) {
555 basic_string<_CharT> __str;
556 __str += _CharT('"');
557 __formatter::__escape(__str, __values, __escape_quotation_mark::__double_quote);
558 __str += _CharT('"');
559 return __formatter::__write_string(basic_string_view{__str}, _VSTD::move(__out_it), __specs);
560}
561
562# endif // _LIBCPP_STD_VER > 20
563
302564} // namespace __formatter
303565
304566#endif //_LIBCPP_STD_VER > 17
lib/libcxx/include/__format/formatter_pointer.h+5-5
......@@ -12,7 +12,7 @@
1212
1313#include <__availability>
1414#include <__config>
15#include <__format/format_fwd.h>
15#include <__format/concepts.h>
1616#include <__format/format_parse_context.h>
1717#include <__format/formatter.h>
1818#include <__format/formatter_integral.h>
......@@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2929
3030#if _LIBCPP_STD_VER > 17
3131
32template <__formatter::__char_type _CharT>
32template <__fmt_char_type _CharT>
3333struct _LIBCPP_TEMPLATE_VIS __formatter_pointer {
3434public:
3535 constexpr __formatter_pointer() { __parser_.__alignment_ = __format_spec::__alignment::__right; }
......@@ -56,13 +56,13 @@ public:
5656// - struct formatter<nullptr_t, charT>;
5757// - template<> struct formatter<void*, charT>;
5858// - template<> struct formatter<const void*, charT>;
59template <__formatter::__char_type _CharT>
59template <__fmt_char_type _CharT>
6060struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<nullptr_t, _CharT>
6161 : public __formatter_pointer<_CharT> {};
62template <__formatter::__char_type _CharT>
62template <__fmt_char_type _CharT>
6363struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<void*, _CharT> : public __formatter_pointer<_CharT> {
6464};
65template <__formatter::__char_type _CharT>
65template <__fmt_char_type _CharT>
6666struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const void*, _CharT>
6767 : public __formatter_pointer<_CharT> {};
6868
lib/libcxx/include/__format/formatter_string.h+24-10
......@@ -12,7 +12,7 @@
1212
1313#include <__availability>
1414#include <__config>
15#include <__format/format_fwd.h>
15#include <__format/concepts.h>
1616#include <__format/format_parse_context.h>
1717#include <__format/formatter.h>
1818#include <__format/formatter_output.h>
......@@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2929
3030#if _LIBCPP_STD_VER > 17
3131
32template <__formatter::__char_type _CharT>
32template <__fmt_char_type _CharT>
3333struct _LIBCPP_TEMPLATE_VIS __formatter_string {
3434public:
3535 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
......@@ -40,14 +40,23 @@ public:
4040 }
4141
4242 _LIBCPP_HIDE_FROM_ABI auto format(basic_string_view<_CharT> __str, auto& __ctx) const -> decltype(__ctx.out()) {
43# if _LIBCPP_STD_VER > 20
44 if (__parser_.__type_ == __format_spec::__type::__debug)
45 return __formatter::__format_escaped_string(__str, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx));
46# endif
47
4348 return __formatter::__write_string(__str, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx));
4449 }
4550
46 __format_spec::__parser<_CharT> __parser_;
51# if _LIBCPP_STD_VER > 20
52 _LIBCPP_HIDE_FROM_ABI constexpr void set_debug_format() { __parser_.__type_ = __format_spec::__type::__debug; }
53# endif
54
55 __format_spec::__parser<_CharT> __parser_{.__alignment_ = __format_spec::__alignment::__left};
4756};
4857
4958// Formatter const char*.
50template <__formatter::__char_type _CharT>
59template <__fmt_char_type _CharT>
5160struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT*, _CharT>
5261 : public __formatter_string<_CharT> {
5362 using _Base = __formatter_string<_CharT>;
......@@ -56,6 +65,12 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT*,
5665 _LIBCPP_ASSERT(__str, "The basic_format_arg constructor should have "
5766 "prevented an invalid pointer.");
5867
68 __format_spec::__parsed_specifications<_CharT> __specs = _Base::__parser_.__get_parsed_std_specifications(__ctx);
69# if _LIBCPP_STD_VER > 20
70 if (_Base::__parser_.__type_ == __format_spec::__type::__debug)
71 return __formatter::__format_escaped_string(basic_string_view<_CharT>{__str}, __ctx.out(), __specs);
72# endif
73
5974 // When using a center or right alignment and the width option the length
6075 // of __str must be known to add the padding upfront. This case is handled
6176 // by the base class by converting the argument to a basic_string_view.
......@@ -67,7 +82,6 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT*,
6782 // now these optimizations aren't implemented. Instead the base class
6883 // handles these options.
6984 // TODO FMT Implement these improvements.
70 __format_spec::__parsed_specifications<_CharT> __specs = _Base::__parser_.__get_parsed_std_specifications(__ctx);
7185 if (__specs.__has_width() || __specs.__has_precision())
7286 return __formatter::__write_string(basic_string_view<_CharT>{__str}, __ctx.out(), __specs);
7387
......@@ -80,7 +94,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT*,
8094};
8195
8296// Formatter char*.
83template <__formatter::__char_type _CharT>
97template <__fmt_char_type _CharT>
8498struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT*, _CharT>
8599 : public formatter<const _CharT*, _CharT> {
86100 using _Base = formatter<const _CharT*, _CharT>;
......@@ -91,7 +105,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT*, _Char
91105};
92106
93107// Formatter char[].
94template <__formatter::__char_type _CharT, size_t _Size>
108template <__fmt_char_type _CharT, size_t _Size>
95109struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT[_Size], _CharT>
96110 : public __formatter_string<_CharT> {
97111 using _Base = __formatter_string<_CharT>;
......@@ -102,7 +116,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT[_Size],
102116};
103117
104118// Formatter const char[].
105template <__formatter::__char_type _CharT, size_t _Size>
119template <__fmt_char_type _CharT, size_t _Size>
106120struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT[_Size], _CharT>
107121 : public __formatter_string<_CharT> {
108122 using _Base = __formatter_string<_CharT>;
......@@ -113,7 +127,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT[_
113127};
114128
115129// Formatter std::string.
116template <__formatter::__char_type _CharT, class _Traits, class _Allocator>
130template <__fmt_char_type _CharT, class _Traits, class _Allocator>
117131struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string<_CharT, _Traits, _Allocator>, _CharT>
118132 : public __formatter_string<_CharT> {
119133 using _Base = __formatter_string<_CharT>;
......@@ -126,7 +140,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string<_
126140};
127141
128142// Formatter std::string_view.
129template <__formatter::__char_type _CharT, class _Traits>
143template <__fmt_char_type _CharT, class _Traits>
130144struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string_view<_CharT, _Traits>, _CharT>
131145 : public __formatter_string<_CharT> {
132146 using _Base = __formatter_string<_CharT>;
lib/libcxx/include/__format/formatter_tuple.h created+178
......@@ -0,0 +1,178 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___FORMAT_FORMATTER_TUPLE_H
11#define _LIBCPP___FORMAT_FORMATTER_TUPLE_H
12
13#include <__algorithm/ranges_copy.h>
14#include <__availability>
15#include <__chrono/statically_widen.h>
16#include <__config>
17#include <__format/concepts.h>
18#include <__format/format_args.h>
19#include <__format/format_context.h>
20#include <__format/format_error.h>
21#include <__format/format_parse_context.h>
22#include <__format/formatter.h>
23#include <__format/formatter_output.h>
24#include <__format/parser_std_format_spec.h>
25#include <__iterator/back_insert_iterator.h>
26#include <__type_traits/remove_cvref.h>
27#include <__utility/integer_sequence.h>
28#include <__utility/pair.h>
29#include <string_view>
30#include <tuple>
31
32#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
33# pragma GCC system_header
34#endif
35
36_LIBCPP_BEGIN_NAMESPACE_STD
37
38#if _LIBCPP_STD_VER > 20
39
40template <__fmt_char_type _CharT, class _Tuple, formattable<_CharT>... _Args>
41struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_tuple {
42 _LIBCPP_HIDE_FROM_ABI constexpr void set_separator(basic_string_view<_CharT> __separator) {
43 __separator_ = __separator;
44 }
45 _LIBCPP_HIDE_FROM_ABI constexpr void
46 set_brackets(basic_string_view<_CharT> __opening_bracket, basic_string_view<_CharT> __closing_bracket) {
47 __opening_bracket_ = __opening_bracket;
48 __closing_bracket_ = __closing_bracket;
49 }
50
51 template <class _ParseContext>
52 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __parse_ctx) {
53 const _CharT* __begin = __parser_.__parse(__parse_ctx, __format_spec::__fields_tuple);
54
55 // [format.tuple]/7
56 // ... For each element e in underlying_, if e.set_debug_format()
57 // is a valid expression, calls e.set_debug_format().
58 // TODO FMT this can be removed when P2733 is accepted.
59 std::__for_each_index_sequence(make_index_sequence<sizeof...(_Args)>(), [&]<size_t _Index> {
60 std::__set_debug_format(std::get<_Index>(__underlying_));
61 });
62
63 const _CharT* __end = __parse_ctx.end();
64 if (__begin == __end)
65 return __begin;
66
67 if (*__begin == _CharT('m')) {
68 if constexpr (sizeof...(_Args) == 2) {
69 set_separator(_LIBCPP_STATICALLY_WIDEN(_CharT, ": "));
70 set_brackets({}, {});
71 ++__begin;
72 } else
73 std::__throw_format_error("The format specifier m requires a pair or a two-element tuple");
74 } else if (*__begin == _CharT('n')) {
75 set_brackets({}, {});
76 ++__begin;
77 }
78
79 if (__begin != __end && *__begin != _CharT('}'))
80 std::__throw_format_error("The format-spec should consume the input or end with a '}'");
81
82 return __begin;
83 }
84
85 template <class _FormatContext>
86 typename _FormatContext::iterator _LIBCPP_HIDE_FROM_ABI
87 format(conditional_t<(formattable<const _Args, _CharT> && ...), const _Tuple&, _Tuple&> __tuple,
88 _FormatContext& __ctx) const {
89 __format_spec::__parsed_specifications<_CharT> __specs = __parser_.__get_parsed_std_specifications(__ctx);
90
91 if (!__specs.__has_width())
92 return __format_tuple(__tuple, __ctx);
93
94 basic_string<_CharT> __str;
95
96 // Since the output is written to a different iterator a new context is
97 // created. Since the underlying formatter uses the default formatting it
98 // doesn't need a locale or the formatting arguments. So creating a new
99 // context works.
100 //
101 // This solution works for this formatter, but it will not work for the
102 // range_formatter. In that patch a generic solution is work in progress.
103 // Once that is finished it can be used here. (The range_formatter will use
104 // these features so it's easier to add it there and then port it.)
105 //
106 // TODO FMT Use formatting wrapping used in the range_formatter.
107 basic_format_context __c = std::__format_context_create(
108 back_insert_iterator{__str},
109 basic_format_args<basic_format_context<back_insert_iterator<basic_string<_CharT>>, _CharT>>{});
110
111 __format_tuple(__tuple, __c);
112
113 return __formatter::__write_string_no_precision(basic_string_view{__str}, __ctx.out(), __specs);
114 }
115
116 template <class _FormatContext>
117 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator __format_tuple(auto&& __tuple, _FormatContext& __ctx) const {
118 __ctx.advance_to(std::ranges::copy(__opening_bracket_, __ctx.out()).out);
119
120 std::__for_each_index_sequence(make_index_sequence<sizeof...(_Args)>(), [&]<size_t _Index> {
121 if constexpr (_Index)
122 __ctx.advance_to(std::ranges::copy(__separator_, __ctx.out()).out);
123
124 // During review Victor suggested to make the exposition only
125 // __underlying_ member a local variable. Currently the Standard
126 // requires nested debug-enabled formatter specializations not to
127 // output escaped output. P2733 fixes that bug, once accepted the
128 // code below can be used.
129 // (Note when a paper allows parsing a tuple-underlying-spec the
130 // exposition only member needs to be a class member. Earlier
131 // revisions of P2286 proposed that, but this was not pursued,
132 // due to time constrains and complexity of the matter.)
133 // TODO FMT This can be updated after P2733 is accepted.
134# if 0
135 // P2286 uses an exposition only member in the formatter
136 // tuple<formatter<remove_cvref_t<_Args>, _CharT>...> __underlying_;
137 // This was used in earlier versions of the paper since
138 // __underlying_.parse(...) was called. This is no longer the case
139 // so we can reduce the scope of the formatter.
140 //
141 // It does require the underlying's parse effect to be moved here too.
142 using _Arg = tuple_element<_Index, decltype(__tuple)>;
143 formatter<remove_cvref_t<_Args>, _CharT> __underlying;
144
145 // [format.tuple]/7
146 // ... For each element e in underlying_, if e.set_debug_format()
147 // is a valid expression, calls e.set_debug_format().
148 std::__set_debug_format(__underlying);
149# else
150 __ctx.advance_to(std::get<_Index>(__underlying_).format(std::get<_Index>(__tuple), __ctx));
151# endif
152 });
153
154 return std::ranges::copy(__closing_bracket_, __ctx.out()).out;
155 }
156
157 __format_spec::__parser<_CharT> __parser_{.__alignment_ = __format_spec::__alignment::__left};
158
159private:
160 tuple<formatter<remove_cvref_t<_Args>, _CharT>...> __underlying_;
161 basic_string_view<_CharT> __separator_ = _LIBCPP_STATICALLY_WIDEN(_CharT, ", ");
162 basic_string_view<_CharT> __opening_bracket_ = _LIBCPP_STATICALLY_WIDEN(_CharT, "(");
163 basic_string_view<_CharT> __closing_bracket_ = _LIBCPP_STATICALLY_WIDEN(_CharT, ")");
164};
165
166template <__fmt_char_type _CharT, formattable<_CharT>... _Args>
167struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<pair<_Args...>, _CharT>
168 : public __formatter_tuple<_CharT, pair<_Args...>, _Args...> {};
169
170template <__fmt_char_type _CharT, formattable<_CharT>... _Args>
171struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<tuple<_Args...>, _CharT>
172 : public __formatter_tuple<_CharT, tuple<_Args...>, _Args...> {};
173
174#endif //_LIBCPP_STD_VER > 20
175
176_LIBCPP_END_NAMESPACE_STD
177
178#endif // _LIBCPP___FORMAT_FORMATTER_TUPLE_H
lib/libcxx/include/__format/parser_std_format_spec.h+90-42
......@@ -19,6 +19,8 @@
1919#include <__algorithm/find_if.h>
2020#include <__algorithm/min.h>
2121#include <__assert>
22#include <__concepts/arithmetic.h>
23#include <__concepts/same_as.h>
2224#include <__config>
2325#include <__debug>
2426#include <__format/format_arg.h>
......@@ -28,7 +30,6 @@
2830#include <__format/unicode.h>
2931#include <__variant/monostate.h>
3032#include <bit>
31#include <concepts>
3233#include <cstdint>
3334#include <string_view>
3435#include <type_traits>
......@@ -52,13 +53,12 @@ __parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
5253 // This function is a wrapper to call the real parser. But it does the
5354 // validation for the pre-conditions and post-conditions.
5455 if (__begin == __end)
55 __throw_format_error("End of input while parsing format-spec arg-id");
56 std::__throw_format_error("End of input while parsing format-spec arg-id");
5657
57 __format::__parse_number_result __r =
58 __format::__parse_arg_id(__begin, __end, __parse_ctx);
58 __format::__parse_number_result __r = __format::__parse_arg_id(__begin, __end, __parse_ctx);
5959
6060 if (__r.__ptr == __end || *__r.__ptr != _CharT('}'))
61 __throw_format_error("Invalid arg-id");
61 std::__throw_format_error("Invalid arg-id");
6262
6363 ++__r.__ptr;
6464 return __r;
......@@ -67,28 +67,33 @@ __parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
6767template <class _Context>
6868_LIBCPP_HIDE_FROM_ABI constexpr uint32_t
6969__substitute_arg_id(basic_format_arg<_Context> __format_arg) {
70 return visit_format_arg(
70 // [format.string.std]/8
71 // If the corresponding formatting argument is not of integral type...
72 // This wording allows char and bool too. LWG-3720 changes the wording to
73 // If the corresponding formatting argument is not of standard signed or
74 // unsigned integer type,
75 // This means the 128-bit will not be valid anymore.
76 // TODO FMT Verify this resolution is accepted and add a test to verify
77 // 128-bit integrals fail and switch to visit_format_arg.
78 return _VSTD::__visit_format_arg(
7179 [](auto __arg) -> uint32_t {
7280 using _Type = decltype(__arg);
7381 if constexpr (integral<_Type>) {
7482 if constexpr (signed_integral<_Type>) {
7583 if (__arg < 0)
76 __throw_format_error("A format-spec arg-id replacement shouldn't "
77 "have a negative value");
84 std::__throw_format_error("A format-spec arg-id replacement shouldn't have a negative value");
7885 }
7986
8087 using _CT = common_type_t<_Type, decltype(__format::__number_max)>;
8188 if (static_cast<_CT>(__arg) >
8289 static_cast<_CT>(__format::__number_max))
83 __throw_format_error("A format-spec arg-id replacement exceeds "
84 "the maximum supported value");
90 std::__throw_format_error("A format-spec arg-id replacement exceeds the maximum supported value");
8591
8692 return __arg;
8793 } else if constexpr (same_as<_Type, monostate>)
88 __throw_format_error("Argument index out of bounds");
94 std::__throw_format_error("Argument index out of bounds");
8995 else
90 __throw_format_error("A format-spec arg-id replacement argument "
91 "isn't an integral type");
96 std::__throw_format_error("A format-spec arg-id replacement argument isn't an integral type");
9297 },
9398 __format_arg);
9499}
......@@ -97,6 +102,7 @@ __substitute_arg_id(basic_format_arg<_Context> __format_arg) {
97102///
98103/// They default to false so when a new field is added it needs to be opted in
99104/// explicitly.
105// TODO FMT Use an ABI tag for this struct.
100106struct __fields {
101107 uint8_t __sign_ : 1 {false};
102108 uint8_t __alternate_form_ : 1 {false};
......@@ -104,6 +110,13 @@ struct __fields {
104110 uint8_t __precision_ : 1 {false};
105111 uint8_t __locale_specific_form_ : 1 {false};
106112 uint8_t __type_ : 1 {false};
113 // Determines the valid values for fill.
114 //
115 // Originally the fill could be any character except { and }. Range-based
116 // formatters use the colon to mark the beginning of the
117 // underlying-format-spec. To avoid parsing ambiguities these formatter
118 // specializations prohibit the use of the colon as a fill character.
119 uint8_t __allow_colon_in_fill_ : 1 {false};
107120};
108121
109122// By not placing this constant in the formatter class it's not duplicated for
......@@ -124,6 +137,11 @@ inline constexpr __fields __fields_floating_point{
124137inline constexpr __fields __fields_string{.__precision_ = true, .__type_ = true};
125138inline constexpr __fields __fields_pointer{.__type_ = true};
126139
140# if _LIBCPP_STD_VER > 20
141inline constexpr __fields __fields_tuple{.__type_ = false, .__allow_colon_in_fill_ = true};
142inline constexpr __fields __fields_range{.__type_ = false, .__allow_colon_in_fill_ = true};
143# endif
144
127145enum class _LIBCPP_ENUM_VIS __alignment : uint8_t {
128146 /// No alignment is set in the format string.
129147 __default,
......@@ -163,7 +181,8 @@ enum class _LIBCPP_ENUM_VIS __type : uint8_t {
163181 __fixed_lower_case,
164182 __fixed_upper_case,
165183 __general_lower_case,
166 __general_upper_case
184 __general_upper_case,
185 __debug
167186};
168187
169188struct __std {
......@@ -176,7 +195,11 @@ struct __std {
176195
177196struct __chrono {
178197 __alignment __alignment_ : 3;
198 bool __locale_specific_form_ : 1;
179199 bool __weekday_name_ : 1;
200 bool __weekday_ : 1;
201 bool __day_of_year_ : 1;
202 bool __week_of_year_ : 1;
180203 bool __month_name_ : 1;
181204};
182205
......@@ -250,7 +273,7 @@ public:
250273 if (__begin == __end)
251274 return __begin;
252275
253 if (__parse_fill_align(__begin, __end) && __begin == __end)
276 if (__parse_fill_align(__begin, __end, __fields.__allow_colon_in_fill_) && __begin == __end)
254277 return __begin;
255278
256279 if (__fields.__sign_ && __parse_sign(__begin) && __begin == __end)
......@@ -278,7 +301,7 @@ public:
278301 // parsing. In that case that parser should do the end of format string
279302 // validation.
280303 if (__begin != __end && *__begin != _CharT('}'))
281 __throw_format_error("The format-spec should consume the input or end with a '}'");
304 std::__throw_format_error("The format-spec should consume the input or end with a '}'");
282305 }
283306
284307 return __begin;
......@@ -288,12 +311,26 @@ public:
288311 _LIBCPP_HIDE_FROM_ABI
289312 __parsed_specifications<_CharT> __get_parsed_std_specifications(auto& __ctx) const {
290313 return __parsed_specifications<_CharT>{
291 .__std_ =
292 __std{.__alignment_ = __alignment_,
293 .__sign_ = __sign_,
294 .__alternate_form_ = __alternate_form_,
295 .__locale_specific_form_ = __locale_specific_form_,
296 .__type_ = __type_},
314 .__std_ = __std{.__alignment_ = __alignment_,
315 .__sign_ = __sign_,
316 .__alternate_form_ = __alternate_form_,
317 .__locale_specific_form_ = __locale_specific_form_,
318 .__type_ = __type_},
319 .__width_{__get_width(__ctx)},
320 .__precision_{__get_precision(__ctx)},
321 .__fill_{__fill_}};
322 }
323
324 _LIBCPP_HIDE_FROM_ABI __parsed_specifications<_CharT> __get_parsed_chrono_specifications(auto& __ctx) const {
325 return __parsed_specifications<_CharT>{
326 .__chrono_ =
327 __chrono{.__alignment_ = __alignment_,
328 .__locale_specific_form_ = __locale_specific_form_,
329 .__weekday_name_ = __weekday_name_,
330 .__weekday_ = __weekday_,
331 .__day_of_year_ = __day_of_year_,
332 .__week_of_year_ = __week_of_year_,
333 .__month_name_ = __month_name_},
297334 .__width_{__get_width(__ctx)},
298335 .__precision_{__get_precision(__ctx)},
299336 .__fill_{__fill_}};
......@@ -306,12 +343,17 @@ public:
306343 bool __reserved_0_ : 1 {false};
307344 __type __type_{__type::__default};
308345
309 // These two flags are used for formatting chrono. Since the struct has
346 // These flags are only used for formatting chrono. Since the struct has
310347 // padding space left it's added to this structure.
311348 bool __weekday_name_ : 1 {false};
349 bool __weekday_ : 1 {false};
350
351 bool __day_of_year_ : 1 {false};
352 bool __week_of_year_ : 1 {false};
353
312354 bool __month_name_ : 1 {false};
313355
314 uint8_t __reserved_1_ : 6 {0};
356 uint8_t __reserved_1_ : 3 {0};
315357 uint8_t __reserved_2_ : 6 {0};
316358 // These two flags are only used internally and not part of the
317359 // __parsed_specifications. Therefore put them at the end.
......@@ -348,13 +390,17 @@ private:
348390 return false;
349391 }
350392
351 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(const _CharT*& __begin, const _CharT* __end) {
393 // range-fill and tuple-fill are identical
394 _LIBCPP_HIDE_FROM_ABI constexpr bool
395 __parse_fill_align(const _CharT*& __begin, const _CharT* __end, bool __use_range_fill) {
352396 _LIBCPP_ASSERT(__begin != __end, "when called with an empty input the function will cause "
353397 "undefined behavior by evaluating data not in the input");
354398 if (__begin + 1 != __end) {
355399 if (__parse_alignment(*(__begin + 1))) {
356 if (*__begin == _CharT('{') || *__begin == _CharT('}'))
357 __throw_format_error("The format-spec fill field contains an invalid character");
400 if (__use_range_fill && (*__begin == _CharT('{') || *__begin == _CharT('}') || *__begin == _CharT(':')))
401 std::__throw_format_error("The format-spec range-fill field contains an invalid character");
402 else if (*__begin == _CharT('{') || *__begin == _CharT('}'))
403 std::__throw_format_error("The format-spec fill field contains an invalid character");
358404
359405 __fill_ = *__begin;
360406 __begin += 2;
......@@ -408,7 +454,7 @@ private:
408454
409455 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_width(const _CharT*& __begin, const _CharT* __end, auto& __parse_ctx) {
410456 if (*__begin == _CharT('0'))
411 __throw_format_error("A format-spec width field shouldn't have a leading zero");
457 std::__throw_format_error("A format-spec width field shouldn't have a leading zero");
412458
413459 if (*__begin == _CharT('{')) {
414460 __format::__parse_number_result __r = __format_spec::__parse_arg_id(++__begin, __end, __parse_ctx);
......@@ -436,7 +482,7 @@ private:
436482
437483 ++__begin;
438484 if (__begin == __end)
439 __throw_format_error("End of input while parsing format-spec precision");
485 std::__throw_format_error("End of input while parsing format-spec precision");
440486
441487 if (*__begin == _CharT('{')) {
442488 __format::__parse_number_result __arg_id = __format_spec::__parse_arg_id(++__begin, __end, __parse_ctx);
......@@ -447,7 +493,7 @@ private:
447493 }
448494
449495 if (*__begin < _CharT('0') || *__begin > _CharT('9'))
450 __throw_format_error("The format-spec precision field doesn't contain a value or arg-id");
496 std::__throw_format_error("The format-spec precision field doesn't contain a value or arg-id");
451497
452498 __format::__parse_number_result __r = __format::__parse_number(__begin, __end);
453499 __precision_ = __r.__value;
......@@ -523,6 +569,11 @@ private:
523569 case 'x':
524570 __type_ = __type::__hexadecimal_lower_case;
525571 break;
572# if _LIBCPP_STD_VER > 20
573 case '?':
574 __type_ = __type::__debug;
575 break;
576# endif
526577 default:
527578 return;
528579 }
......@@ -534,10 +585,7 @@ private:
534585 if (!__width_as_arg_)
535586 return __width_;
536587
537 int32_t __result = __format_spec::__substitute_arg_id(__ctx.arg(__width_));
538 if (__result == 0)
539 __throw_format_error("A format-spec width field replacement should have a positive value");
540 return __result;
588 return __format_spec::__substitute_arg_id(__ctx.arg(__width_));
541589 }
542590
543591 _LIBCPP_HIDE_FROM_ABI
......@@ -559,6 +607,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_string(__format_spec
559607 switch (__type) {
560608 case __format_spec::__type::__default:
561609 case __format_spec::__type::__string:
610 case __format_spec::__type::__debug:
562611 break;
563612
564613 default:
......@@ -612,6 +661,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_char(__parser<_CharT>& __p
612661 switch (__parser.__type_) {
613662 case __format_spec::__type::__default:
614663 case __format_spec::__type::__char:
664 case __format_spec::__type::__debug:
615665 __format_spec::__process_display_type_char(__parser);
616666 break;
617667
......@@ -653,11 +703,6 @@ template <class _CharT>
653703_LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_floating_point(__parser<_CharT>& __parser) {
654704 switch (__parser.__type_) {
655705 case __format_spec::__type::__default:
656 // When no precision specified then it keeps default since that
657 // formatting differs from the other types.
658 if (__parser.__precision_as_arg_ || __parser.__precision_ != -1)
659 __parser.__type_ = __format_spec::__type::__general_lower_case;
660 break;
661706 case __format_spec::__type::__hexfloat_lower_case:
662707 case __format_spec::__type::__hexfloat_upper_case:
663708 // Precision specific behavior will be handled later.
......@@ -699,6 +744,9 @@ struct __column_width_result {
699744 const _CharT* __last_;
700745};
701746
747template <class _CharT>
748__column_width_result(size_t, const _CharT*) -> __column_width_result<_CharT>;
749
702750/// Since a column width can be two it's possible that the requested column
703751/// width can't be achieved. Depending on the intended usage the policy can be
704752/// selected.
......@@ -857,7 +905,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> __estimate_column_
857905 // unit is non-ASCII we omit the current code unit and let the Grapheme
858906 // clustering algorithm do its work.
859907 const _CharT* __it = __str.begin();
860 if (__is_ascii(*__it)) {
908 if (__format_spec::__is_ascii(*__it)) {
861909 do {
862910 --__maximum;
863911 ++__it;
......@@ -865,12 +913,12 @@ _LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> __estimate_column_
865913 return {__str.size(), __str.end()};
866914
867915 if (__maximum == 0) {
868 if (__is_ascii(*__it))
916 if (__format_spec::__is_ascii(*__it))
869917 return {static_cast<size_t>(__it - __str.begin()), __it};
870918
871919 break;
872920 }
873 } while (__is_ascii(*__it));
921 } while (__format_spec::__is_ascii(*__it));
874922 --__it;
875923 ++__maximum;
876924 }
lib/libcxx/include/__format/range_default_formatter.h created+201
......@@ -0,0 +1,201 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___FORMAT_RANGE_DEFAULT_FORMATTER_H
11#define _LIBCPP___FORMAT_RANGE_DEFAULT_FORMATTER_H
12
13#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
14# pragma GCC system_header
15#endif
16
17#include <__availability>
18#include <__chrono/statically_widen.h>
19#include <__concepts/same_as.h>
20#include <__config>
21#include <__format/concepts.h>
22#include <__format/formatter.h>
23#include <__format/range_formatter.h>
24#include <__ranges/concepts.h>
25#include <__type_traits/remove_cvref.h>
26#include <__utility/pair.h>
27#include <string_view>
28#include <tuple>
29
30_LIBCPP_BEGIN_NAMESPACE_STD
31
32#if _LIBCPP_STD_VER > 20
33
34template <class _Rp, class _CharT>
35concept __const_formattable_range =
36 ranges::input_range<const _Rp> && formattable<ranges::range_reference_t<const _Rp>, _CharT>;
37
38template <class _Rp, class _CharT>
39using __fmt_maybe_const = conditional_t<__const_formattable_range<_Rp, _CharT>, const _Rp, _Rp>;
40
41_LIBCPP_DIAGNOSTIC_PUSH
42_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wshadow")
43_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wshadow")
44// This shadows map, set, and string.
45enum class range_format { disabled, map, set, sequence, string, debug_string };
46_LIBCPP_DIAGNOSTIC_POP
47
48// There is no definition of this struct, it's purely intended to be used to
49// generate diagnostics.
50template <class _Rp>
51struct _LIBCPP_TEMPLATE_VIS __instantiated_the_primary_template_of_format_kind;
52
53template <class _Rp>
54constexpr range_format format_kind = [] {
55 // [format.range.fmtkind]/1
56 // A program that instantiates the primary template of format_kind is ill-formed.
57 static_assert(sizeof(_Rp) != sizeof(_Rp), "create a template specialization of format_kind for your type");
58 return range_format::disabled;
59}();
60
61template <ranges::input_range _Rp>
62 requires same_as<_Rp, remove_cvref_t<_Rp>>
63inline constexpr range_format format_kind<_Rp> = [] {
64 // [format.range.fmtkind]/2
65
66 // 2.1 If same_as<remove_cvref_t<ranges::range_reference_t<R>>, R> is true,
67 // Otherwise format_kind<R> is range_format::disabled.
68 if constexpr (same_as<remove_cvref_t<ranges::range_reference_t<_Rp>>, _Rp>)
69 return range_format::disabled;
70 // 2.2 Otherwise, if the qualified-id R::key_type is valid and denotes a type:
71 else if constexpr (requires { typename _Rp::key_type; }) {
72 // 2.2.1 If the qualified-id R::mapped_type is valid and denotes a type ...
73 if constexpr (requires { typename _Rp::mapped_type; } &&
74 // 2.2.1 ... If either U is a specialization of pair or U is a specialization
75 // of tuple and tuple_size_v<U> == 2
76 __fmt_pair_like<remove_cvref_t<ranges::range_reference_t<_Rp>>>)
77 return range_format::map;
78 else
79 // 2.2.2 Otherwise format_kind<R> is range_format::set.
80 return range_format::set;
81 } else
82 // 2.3 Otherwise, format_kind<R> is range_format::sequence.
83 return range_format::sequence;
84}();
85
86// This is a non-standard work-around to fix instantiation of
87// formatter<const _CharT[N], _CharT>
88// const _CharT[N] satisfies the ranges::input_range concept.
89// remove_cvref_t<const _CharT[N]> is _CharT[N] so it does not satisfy the
90// requirement of the above specialization. Instead it will instantiate the
91// primary template, which is ill-formed.
92//
93// An alternative solution is to remove the offending formatter.
94//
95// https://godbolt.org/z/bqjhhaexx
96//
97// The removal is proposed in LWG3833, but use the work-around until the issue
98// has been adopted.
99// TODO FMT Implement LWG3833.
100template <class _CharT, size_t N>
101inline constexpr range_format format_kind<const _CharT[N]> = range_format::disabled;
102
103template <range_format _Kp, ranges::input_range _Rp, class _CharT>
104struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __range_default_formatter;
105
106// Required specializations
107
108template <ranges::input_range _Rp, class _CharT>
109struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __range_default_formatter<range_format::sequence, _Rp, _CharT> {
110private:
111 using __maybe_const_r = __fmt_maybe_const<_Rp, _CharT>;
112 range_formatter<remove_cvref_t<ranges::range_reference_t<__maybe_const_r>>, _CharT> __underlying_;
113
114public:
115 _LIBCPP_HIDE_FROM_ABI constexpr void set_separator(basic_string_view<_CharT> __separator) {
116 __underlying_.set_separator(__separator);
117 }
118 _LIBCPP_HIDE_FROM_ABI constexpr void
119 set_brackets(basic_string_view<_CharT> __opening_bracket, basic_string_view<_CharT> __closing_bracket) {
120 __underlying_.set_brackets(__opening_bracket, __closing_bracket);
121 }
122
123 template <class _ParseContext>
124 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
125 return __underlying_.parse(__ctx);
126 }
127
128 template <class FormatContext>
129 _LIBCPP_HIDE_FROM_ABI typename FormatContext::iterator format(__maybe_const_r& __range, FormatContext& __ctx) const {
130 return __underlying_.format(__range, __ctx);
131 }
132};
133
134template <ranges::input_range _Rp, class _CharT>
135struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __range_default_formatter<range_format::map, _Rp, _CharT> {
136private:
137 using __maybe_const_map = __fmt_maybe_const<_Rp, _CharT>;
138 using __element_type = remove_cvref_t<ranges::range_reference_t<__maybe_const_map>>;
139 range_formatter<__element_type, _CharT> __underlying_;
140
141public:
142 _LIBCPP_HIDE_FROM_ABI constexpr __range_default_formatter()
143 requires(__fmt_pair_like<__element_type>)
144 {
145 __underlying_.set_brackets(_LIBCPP_STATICALLY_WIDEN(_CharT, "{"), _LIBCPP_STATICALLY_WIDEN(_CharT, "}"));
146 __underlying_.underlying().set_brackets({}, {});
147 __underlying_.underlying().set_separator(_LIBCPP_STATICALLY_WIDEN(_CharT, ": "));
148 }
149
150 template <class _ParseContext>
151 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
152 return __underlying_.parse(__ctx);
153 }
154
155 template <class _FormatContext>
156 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator
157 format(__maybe_const_map& __range, _FormatContext& __ctx) const {
158 return __underlying_.format(__range, __ctx);
159 }
160};
161
162template <ranges::input_range _Rp, class _CharT>
163struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __range_default_formatter<range_format::set, _Rp, _CharT> {
164private:
165 using __maybe_const_set = __fmt_maybe_const<_Rp, _CharT>;
166 using __element_type = remove_cvref_t<ranges::range_reference_t<__maybe_const_set>>;
167 range_formatter<__element_type, _CharT> __underlying_;
168
169public:
170 _LIBCPP_HIDE_FROM_ABI constexpr __range_default_formatter() {
171 __underlying_.set_brackets(_LIBCPP_STATICALLY_WIDEN(_CharT, "{"), _LIBCPP_STATICALLY_WIDEN(_CharT, "}"));
172 }
173
174 template <class _ParseContext>
175 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
176 return __underlying_.parse(__ctx);
177 }
178
179 template <class _FormatContext>
180 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator
181 format(__maybe_const_set& __range, _FormatContext& __ctx) const {
182 return __underlying_.format(__range, __ctx);
183 }
184};
185
186template <range_format _Kp, ranges::input_range _Rp, class _CharT>
187 requires(_Kp == range_format::string || _Kp == range_format::debug_string)
188struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __range_default_formatter<_Kp, _Rp, _CharT> {
189 __range_default_formatter() = delete; // TODO FMT Implement
190};
191
192template <ranges::input_range _Rp, class _CharT>
193 requires(format_kind<_Rp> != range_format::disabled && formattable<ranges::range_reference_t<_Rp>, _CharT>)
194struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_Rp, _CharT>
195 : __range_default_formatter<format_kind<_Rp>, _Rp, _CharT> {};
196
197#endif //_LIBCPP_STD_VER > 20
198
199_LIBCPP_END_NAMESPACE_STD
200
201#endif // _LIBCPP___FORMAT_RANGE_DEFAULT_FORMATTER_H
lib/libcxx/include/__format/range_formatter.h created+255
......@@ -0,0 +1,255 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___FORMAT_RANGE_FORMATTER_H
11#define _LIBCPP___FORMAT_RANGE_FORMATTER_H
12
13#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
14# pragma GCC system_header
15#endif
16
17#include <__algorithm/ranges_copy.h>
18#include <__availability>
19#include <__chrono/statically_widen.h>
20#include <__concepts/same_as.h>
21#include <__config>
22#include <__format/buffer.h>
23#include <__format/concepts.h>
24#include <__format/format_args.h>
25#include <__format/format_context.h>
26#include <__format/format_error.h>
27#include <__format/formatter.h>
28#include <__format/formatter_output.h>
29#include <__format/parser_std_format_spec.h>
30#include <__iterator/back_insert_iterator.h>
31#include <__ranges/concepts.h>
32#include <__ranges/data.h>
33#include <__ranges/size.h>
34#include <__type_traits/remove_cvref.h>
35#include <string_view>
36
37_LIBCPP_BEGIN_NAMESPACE_STD
38
39#if _LIBCPP_STD_VER > 20
40
41template <class _Tp, class _CharT = char>
42 requires same_as<remove_cvref_t<_Tp>, _Tp> && formattable<_Tp, _CharT>
43struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT range_formatter {
44 _LIBCPP_HIDE_FROM_ABI constexpr void set_separator(basic_string_view<_CharT> __separator) {
45 __separator_ = __separator;
46 }
47 _LIBCPP_HIDE_FROM_ABI constexpr void
48 set_brackets(basic_string_view<_CharT> __opening_bracket, basic_string_view<_CharT> __closing_bracket) {
49 __opening_bracket_ = __opening_bracket;
50 __closing_bracket_ = __closing_bracket;
51 }
52
53 _LIBCPP_HIDE_FROM_ABI constexpr formatter<_Tp, _CharT>& underlying() { return __underlying_; }
54 _LIBCPP_HIDE_FROM_ABI constexpr const formatter<_Tp, _CharT>& underlying() const { return __underlying_; }
55
56 template <class _ParseContext>
57 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __parse_ctx) {
58 const _CharT* __begin = __parser_.__parse(__parse_ctx, __format_spec::__fields_range);
59 const _CharT* __end = __parse_ctx.end();
60 if (__begin == __end)
61 return __begin;
62
63 // The n field overrides a possible m type, therefore delay applying the
64 // effect of n until the type has been procesed.
65 bool __clear_brackets = (*__begin == _CharT('n'));
66 if (__clear_brackets) {
67 ++__begin;
68 if (__begin == __end) {
69 // Since there is no more data, clear the brackets before returning.
70 set_brackets({}, {});
71 return __begin;
72 }
73 }
74
75 __parse_type(__begin, __end);
76 if (__clear_brackets)
77 set_brackets({}, {});
78 if (__begin == __end)
79 return __begin;
80
81 bool __has_range_underlying_spec = *__begin == _CharT(':');
82 if (__parser_.__type_ != __format_spec::__type::__default) {
83 // [format.range.formatter]/6
84 // If the range-type is s or ?s, then there shall be no n option and no
85 // range-underlying-spec.
86 if (__clear_brackets) {
87 if (__parser_.__type_ == __format_spec::__type::__string)
88 std::__throw_format_error("The n option and type s can't be used together");
89 std::__throw_format_error("The n option and type ?s can't be used together");
90 }
91 if (__has_range_underlying_spec) {
92 if (__parser_.__type_ == __format_spec::__type::__string)
93 std::__throw_format_error("Type s and an underlying format specification can't be used together");
94 std::__throw_format_error("Type ?s and an underlying format specification can't be used together");
95 }
96 } else if (!__has_range_underlying_spec)
97 std::__set_debug_format(__underlying_);
98
99 if (__has_range_underlying_spec) {
100 // range-underlying-spec:
101 // : format-spec
102 ++__begin;
103 if (__begin == __end)
104 return __begin;
105
106 __parse_ctx.advance_to(__begin);
107 __begin = __underlying_.parse(__parse_ctx);
108 }
109
110 if (__begin != __end && *__begin != _CharT('}'))
111 std::__throw_format_error("The format-spec should consume the input or end with a '}'");
112
113 return __begin;
114 }
115
116 template <ranges::input_range _Rp, class _FormatContext>
117 requires formattable<ranges::range_reference_t<_Rp>, _CharT> &&
118 same_as<remove_cvref_t<ranges::range_reference_t<_Rp>>, _Tp>
119 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(_Rp&& __range, _FormatContext& __ctx) const {
120 __format_spec::__parsed_specifications<_CharT> __specs = __parser_.__get_parsed_std_specifications(__ctx);
121
122 if (!__specs.__has_width())
123 return __format_range(__range, __ctx, __specs);
124
125 // The size of the buffer needed is:
126 // - open bracket characters
127 // - close bracket character
128 // - n elements where every element may have a different size
129 // - (n -1) separators
130 // The size of the element is hard to predict, knowing the type helps but
131 // it depends on the format-spec. As an initial estimate we guess 6
132 // characters.
133 // Typically both brackets are 1 character and the separator is 2
134 // characters. Which means there will be
135 // (n - 1) * 2 + 1 + 1 = n * 2 character
136 // So estimate 8 times the range size as buffer.
137 std::size_t __capacity_hint = 0;
138 if constexpr (std::ranges::sized_range<_Rp>)
139 __capacity_hint = 8 * ranges::size(__range);
140 __format::__retarget_buffer<_CharT> __buffer{__capacity_hint};
141 basic_format_context<typename __format::__retarget_buffer<_CharT>::__iterator, _CharT> __c{
142 __buffer.__make_output_iterator(), __ctx};
143
144 __format_range(__range, __c, __specs);
145
146 return __formatter::__write_string_no_precision(__buffer.__view(), __ctx.out(), __specs);
147 }
148
149 template <ranges::input_range _Rp, class _FormatContext>
150 typename _FormatContext::iterator _LIBCPP_HIDE_FROM_ABI
151 __format_range(_Rp&& __range, _FormatContext& __ctx, __format_spec::__parsed_specifications<_CharT> __specs) const {
152 if constexpr (same_as<_Tp, _CharT>) {
153 switch (__specs.__std_.__type_) {
154 case __format_spec::__type::__string:
155 case __format_spec::__type::__debug:
156 return __format_as_string(__range, __ctx, __specs.__std_.__type_ == __format_spec::__type::__debug);
157 default:
158 return __format_as_sequence(__range, __ctx);
159 }
160 } else
161 return __format_as_sequence(__range, __ctx);
162 }
163
164 template <ranges::input_range _Rp, class _FormatContext>
165 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator
166 __format_as_string(_Rp&& __range, _FormatContext& __ctx, bool __debug_format) const {
167 // When the range is contiguous use a basic_string_view instead to avoid a
168 // copy of the underlying data. The basic_string_view formatter
169 // specialization is the "basic" string formatter in libc++.
170 if constexpr (ranges::contiguous_range<_Rp> && std::ranges::sized_range<_Rp>) {
171 std::formatter<basic_string_view<_CharT>, _CharT> __formatter;
172 if (__debug_format)
173 __formatter.set_debug_format();
174 return __formatter.format(
175 basic_string_view<_CharT>{
176 ranges::data(__range),
177 ranges::size(__range),
178 },
179 __ctx);
180 } else {
181 std::formatter<basic_string<_CharT>, _CharT> __formatter;
182 if (__debug_format)
183 __formatter.set_debug_format();
184 // P2106's from_range has not been implemented yet. Instead use a simple
185 // copy operation.
186 // TODO FMT use basic_string's "from_range" constructor.
187 // return std::formatter<basic_string<_CharT>, _CharT>{}.format(basic_string<_CharT>{from_range, __range}, __ctx);
188 basic_string<_CharT> __str;
189 ranges::copy(__range, back_insert_iterator{__str});
190 return __formatter.format(__str, __ctx);
191 }
192 }
193
194 template <ranges::input_range _Rp, class _FormatContext>
195 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator
196 __format_as_sequence(_Rp&& __range, _FormatContext& __ctx) const {
197 __ctx.advance_to(ranges::copy(__opening_bracket_, __ctx.out()).out);
198 bool __use_separator = false;
199 for (auto&& __e : __range) {
200 if (__use_separator)
201 __ctx.advance_to(ranges::copy(__separator_, __ctx.out()).out);
202 else
203 __use_separator = true;
204
205 __ctx.advance_to(__underlying_.format(__e, __ctx));
206 }
207
208 return ranges::copy(__closing_bracket_, __ctx.out()).out;
209 }
210
211 __format_spec::__parser<_CharT> __parser_{.__alignment_ = __format_spec::__alignment::__left};
212
213private:
214 _LIBCPP_HIDE_FROM_ABI constexpr void __parse_type(const _CharT*& __begin, const _CharT* __end) {
215 switch (*__begin) {
216 case _CharT('m'):
217 if constexpr (__fmt_pair_like<_Tp>) {
218 set_brackets(_LIBCPP_STATICALLY_WIDEN(_CharT, "{"), _LIBCPP_STATICALLY_WIDEN(_CharT, "}"));
219 set_separator(_LIBCPP_STATICALLY_WIDEN(_CharT, ", "));
220 ++__begin;
221 } else
222 std::__throw_format_error("The range-format-spec type m requires two elements for a pair or tuple");
223 break;
224
225 case _CharT('s'):
226 if constexpr (same_as<_Tp, _CharT>) {
227 __parser_.__type_ = __format_spec::__type::__string;
228 ++__begin;
229 } else
230 std::__throw_format_error("The range-format-spec type s requires formatting a character type");
231 break;
232
233 case _CharT('?'):
234 ++__begin;
235 if (__begin == __end || *__begin != _CharT('s'))
236 std::__throw_format_error("The format-spec should consume the input or end with a '}'");
237 if constexpr (same_as<_Tp, _CharT>) {
238 __parser_.__type_ = __format_spec::__type::__debug;
239 ++__begin;
240 } else
241 std::__throw_format_error("The range-format-spec type ?s requires formatting a character type");
242 }
243 }
244
245 formatter<_Tp, _CharT> __underlying_;
246 basic_string_view<_CharT> __separator_ = _LIBCPP_STATICALLY_WIDEN(_CharT, ", ");
247 basic_string_view<_CharT> __opening_bracket_ = _LIBCPP_STATICALLY_WIDEN(_CharT, "[");
248 basic_string_view<_CharT> __closing_bracket_ = _LIBCPP_STATICALLY_WIDEN(_CharT, "]");
249};
250
251#endif //_LIBCPP_STD_VER > 20
252
253_LIBCPP_END_NAMESPACE_STD
254
255#endif // _LIBCPP___FORMAT_RANGE_FORMATTER_H
lib/libcxx/include/__format/unicode.h+161-11
......@@ -13,6 +13,7 @@
1313#include <__assert>
1414#include <__config>
1515#include <__format/extended_grapheme_cluster_table.h>
16#include <__type_traits/make_unsigned.h>
1617#include <__utility/unreachable.h>
1718#include <bit>
1819
......@@ -24,6 +25,26 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2425
2526#if _LIBCPP_STD_VER > 17
2627
28namespace __unicode {
29
30# if _LIBCPP_STD_VER > 20
31
32/// The result of consuming a code point using P2286' semantics
33///
34/// TODO FMT Combine __consume and __consume_p2286 in one function.
35struct __consume_p2286_result {
36 // A size of 0 means well formed. This to differenciate between
37 // a valid code point and a code unit that's invalid like 0b11111xxx.
38 int __ill_formed_size;
39
40 // If well formed the consumed code point.
41 // Otherwise the ill-formed code units as unsigned 8-bit values. They are
42 // stored in reverse order, to make it easier to extract the values.
43 char32_t __value;
44};
45
46# endif // _LIBCPP_STD_VER > 20
47
2748# ifndef _LIBCPP_HAS_NO_UNICODE
2849
2950/// Implements the grapheme cluster boundary rules
......@@ -39,8 +60,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3960/// https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt
4061/// https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt (for testing only)
4162
42namespace __unicode {
43
4463inline constexpr char32_t __replacement_character = U'\ufffd';
4564
4665_LIBCPP_HIDE_FROM_ABI constexpr bool __is_continuation(const char* __char, int __count) {
......@@ -123,18 +142,92 @@ public:
123142 return __replacement_character;
124143 }
125144
145# if _LIBCPP_STD_VER > 20
146 _LIBCPP_HIDE_FROM_ABI constexpr __consume_p2286_result __consume_p2286() noexcept {
147 _LIBCPP_ASSERT(__first_ != __last_, "can't move beyond the end of input");
148
149 // Based on the number of leading 1 bits the number of code units in the
150 // code point can be determined. See
151 // https://en.wikipedia.org/wiki/UTF-8#Encoding
152 switch (std::countl_one(static_cast<unsigned char>(*__first_))) {
153 case 0:
154 return {0, static_cast<unsigned char>(*__first_++)};
155
156 case 2:
157 if (__last_ - __first_ < 2) [[unlikely]]
158 break;
159
160 if (__unicode::__is_continuation(__first_ + 1, 1)) {
161 char32_t __value = static_cast<unsigned char>(*__first_++) & 0x1f;
162 __value <<= 6;
163 __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
164 return {0, __value};
165 }
166 break;
167
168 case 3:
169 if (__last_ - __first_ < 3) [[unlikely]]
170 break;
171
172 if (__unicode::__is_continuation(__first_ + 1, 2)) {
173 char32_t __value = static_cast<unsigned char>(*__first_++) & 0x0f;
174 __value <<= 6;
175 __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
176 __value <<= 6;
177 __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
178 return {0, __value};
179 }
180 break;
181
182 case 4:
183 if (__last_ - __first_ < 4) [[unlikely]]
184 break;
185
186 if (__unicode::__is_continuation(__first_ + 1, 3)) {
187 char32_t __value = static_cast<unsigned char>(*__first_++) & 0x07;
188 __value <<= 6;
189 __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
190 __value <<= 6;
191 __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
192 __value <<= 6;
193 __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
194
195 if (__value > 0x10FFFF) // Outside the valid Unicode range?
196 return {4, __value};
197
198 return {0, __value};
199 }
200 break;
201 }
202 // An invalid number of leading ones can be garbage or a code unit in the
203 // middle of a code point. By consuming one code unit the parser may get
204 // "in sync" after a few code units.
205 return {1, static_cast<unsigned char>(*__first_++)};
206 }
207# endif // _LIBCPP_STD_VER > 20
208
126209private:
127210 const char* __first_;
128211 const char* __last_;
129212};
130213
131# ifndef TEST_HAS_NO_WIDE_CHARACTERS
214# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
215_LIBCPP_HIDE_FROM_ABI constexpr bool __is_surrogate_pair_high(wchar_t __value) {
216 return __value >= 0xd800 && __value <= 0xdbff;
217}
218
219_LIBCPP_HIDE_FROM_ABI constexpr bool __is_surrogate_pair_low(wchar_t __value) {
220 return __value >= 0xdc00 && __value <= 0xdfff;
221}
222
132223/// This specialization depends on the size of wchar_t
133224/// - 2 UTF-16 (for example Windows and AIX)
134225/// - 4 UTF-32 (for example Linux)
135226template <>
136227class __code_point_view<wchar_t> {
137228public:
229 static_assert(sizeof(wchar_t) == 2 || sizeof(wchar_t) == 4, "sizeof(wchar_t) has a not implemented value");
230
138231 _LIBCPP_HIDE_FROM_ABI constexpr explicit __code_point_view(const wchar_t* __first, const wchar_t* __last)
139232 : __first_(__first), __last_(__last) {}
140233
......@@ -166,17 +259,43 @@ public:
166259 return __replacement_character;
167260 return __result;
168261 } else {
169 // TODO FMT P2593R0 Use static_assert(false, "sizeof(wchar_t) has a not implemented value");
170 _LIBCPP_ASSERT(sizeof(wchar_t) == 0, "sizeof(wchar_t) has a not implemented value");
171262 __libcpp_unreachable();
172263 }
173264 }
174265
266# if _LIBCPP_STD_VER > 20
267 _LIBCPP_HIDE_FROM_ABI constexpr __consume_p2286_result __consume_p2286() noexcept {
268 _LIBCPP_ASSERT(__first_ != __last_, "can't move beyond the end of input");
269
270 char32_t __result = *__first_++;
271 if constexpr (sizeof(wchar_t) == 2) {
272 // https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF
273 if (__is_surrogate_pair_high(__result)) {
274 // Malformed Unicode.
275 if (__first_ == __last_ || !__is_surrogate_pair_low(*(__first_ + 1))) [[unlikely]]
276 return {1, __result};
277
278 __result -= 0xd800;
279 __result <<= 10;
280 __result += *__first_++ - 0xdc00;
281 __result += 0x10000;
282 } else if (__is_surrogate_pair_low(__result))
283 // A code point shouldn't start with the low surrogate pair
284 return {1, __result};
285 } else {
286 if (__result > 0x10FFFF) [[unlikely]]
287 return {1, __result};
288 }
289
290 return {0, __result};
291 }
292# endif // _LIBCPP_STD_VER > 20
293
175294private:
176295 const wchar_t* __first_;
177296 const wchar_t* __last_;
178297};
179# endif
298# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
180299
181300_LIBCPP_HIDE_FROM_ABI constexpr bool __at_extended_grapheme_cluster_break(
182301 bool& __ri_break_allowed,
......@@ -251,10 +370,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __at_extended_grapheme_cluster_break(
251370
252371 if (__prev == __property::__Regional_Indicator && __next == __property::__Regional_Indicator) { // GB12 + GB13
253372 __ri_break_allowed = !__ri_break_allowed;
254 if (__ri_break_allowed)
255 return true;
256
257 return false;
373 return __ri_break_allowed;
258374 }
259375
260376 // *** Otherwise, break everywhere. ***
......@@ -328,10 +444,44 @@ private:
328444 }
329445};
330446
331} // namespace __unicode
447template <class _CharT>
448__extended_grapheme_cluster_view(const _CharT*, const _CharT*) -> __extended_grapheme_cluster_view<_CharT>;
449
450# else // _LIBCPP_HAS_NO_UNICODE
451
452// For ASCII every character is a "code point".
453// This makes it easier to write code agnostic of the _LIBCPP_HAS_NO_UNICODE define.
454template <class _CharT>
455class __code_point_view {
456public:
457 _LIBCPP_HIDE_FROM_ABI constexpr explicit __code_point_view(const _CharT* __first, const _CharT* __last)
458 : __first_(__first), __last_(__last) {}
459
460 _LIBCPP_HIDE_FROM_ABI constexpr bool __at_end() const noexcept { return __first_ == __last_; }
461 _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __position() const noexcept { return __first_; }
462
463 _LIBCPP_HIDE_FROM_ABI constexpr char32_t __consume() noexcept {
464 _LIBCPP_ASSERT(__first_ != __last_, "can't move beyond the end of input");
465 return *__first_++;
466 }
467
468# if _LIBCPP_STD_VER > 20
469 _LIBCPP_HIDE_FROM_ABI constexpr __consume_p2286_result __consume_p2286() noexcept {
470 _LIBCPP_ASSERT(__first_ != __last_, "can't move beyond the end of input");
471
472 return {0, std::make_unsigned_t<_CharT>(*__first_++)};
473 }
474# endif // _LIBCPP_STD_VER > 20
475
476private:
477 const _CharT* __first_;
478 const _CharT* __last_;
479};
332480
333481# endif // _LIBCPP_HAS_NO_UNICODE
334482
483} // namespace __unicode
484
335485#endif //_LIBCPP_STD_VER > 17
336486
337487_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__functional/binary_negate.h+3-3
......@@ -29,17 +29,17 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 binary_negate
2929{
3030 _Predicate __pred_;
3131public:
32 _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11
32 _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_SINCE_CXX14
3333 binary_negate(const _Predicate& __pred) : __pred_(__pred) {}
3434
35 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
35 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
3636 bool operator()(const typename _Predicate::first_argument_type& __x,
3737 const typename _Predicate::second_argument_type& __y) const
3838 {return !__pred_(__x, __y);}
3939};
4040
4141template <class _Predicate>
42_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
42_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
4343binary_negate<_Predicate>
4444not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);}
4545
lib/libcxx/include/__functional/bind.h+14-14
......@@ -25,9 +25,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2525
2626template<class _Tp>
2727struct is_bind_expression : _If<
28 _IsSame<_Tp, __uncvref_t<_Tp> >::value,
28 _IsSame<_Tp, __remove_cvref_t<_Tp> >::value,
2929 false_type,
30 is_bind_expression<__uncvref_t<_Tp> >
30 is_bind_expression<__remove_cvref_t<_Tp> >
3131> {};
3232
3333#if _LIBCPP_STD_VER > 14
......@@ -37,9 +37,9 @@ inline constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value;
3737
3838template<class _Tp>
3939struct is_placeholder : _If<
40 _IsSame<_Tp, __uncvref_t<_Tp> >::value,
40 _IsSame<_Tp, __remove_cvref_t<_Tp> >::value,
4141 integral_constant<int, 0>,
42 is_placeholder<__uncvref_t<_Tp> >
42 is_placeholder<__remove_cvref_t<_Tp> >
4343> {};
4444
4545#if _LIBCPP_STD_VER > 14
......@@ -279,16 +279,16 @@ public:
279279 class = typename enable_if
280280 <
281281 is_constructible<_Fd, _Gp>::value &&
282 !is_same<typename remove_reference<_Gp>::type,
282 !is_same<__libcpp_remove_reference_t<_Gp>,
283283 __bind>::value
284284 >::type>
285 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
285 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
286286 explicit __bind(_Gp&& __f, _BA&& ...__bound_args)
287287 : __f_(_VSTD::forward<_Gp>(__f)),
288288 __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {}
289289
290290 template <class ..._Args>
291 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
291 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
292292 typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type
293293 operator()(_Args&& ...__args)
294294 {
......@@ -297,7 +297,7 @@ public:
297297 }
298298
299299 template <class ..._Args>
300 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
300 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
301301 typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
302302 operator()(_Args&& ...__args) const
303303 {
......@@ -324,16 +324,16 @@ public:
324324 class = typename enable_if
325325 <
326326 is_constructible<_Fd, _Gp>::value &&
327 !is_same<typename remove_reference<_Gp>::type,
327 !is_same<__libcpp_remove_reference_t<_Gp>,
328328 __bind_r>::value
329329 >::type>
330 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
330 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
331331 explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args)
332332 : base(_VSTD::forward<_Gp>(__f),
333333 _VSTD::forward<_BA>(__bound_args)...) {}
334334
335335 template <class ..._Args>
336 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
336 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
337337 typename enable_if
338338 <
339339 is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type,
......@@ -347,7 +347,7 @@ public:
347347 }
348348
349349 template <class ..._Args>
350 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
350 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
351351 typename enable_if
352352 <
353353 is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,
......@@ -365,7 +365,7 @@ template<class _Rp, class _Fp, class ..._BoundArgs>
365365struct is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {};
366366
367367template<class _Fp, class ..._BoundArgs>
368inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
368inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
369369__bind<_Fp, _BoundArgs...>
370370bind(_Fp&& __f, _BoundArgs&&... __bound_args)
371371{
......@@ -374,7 +374,7 @@ bind(_Fp&& __f, _BoundArgs&&... __bound_args)
374374}
375375
376376template<class _Rp, class _Fp, class ..._BoundArgs>
377inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
377inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
378378__bind_r<_Rp, _Fp, _BoundArgs...>
379379bind(_Fp&& __f, _BoundArgs&&... __bound_args)
380380{
lib/libcxx/include/__functional/boyer_moore_searcher.h+2
......@@ -223,6 +223,7 @@ private:
223223 }
224224 }
225225};
226_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(boyer_moore_searcher);
226227
227228template <class _RandomAccessIterator1,
228229 class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
......@@ -303,6 +304,7 @@ private:
303304 return std::make_pair(__l, __l);
304305 }
305306};
307_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(boyer_moore_horspool_searcher);
306308
307309_LIBCPP_END_NAMESPACE_STD
308310
lib/libcxx/include/__functional/default_searcher.h+3-2
......@@ -29,13 +29,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2929template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
3030class _LIBCPP_TEMPLATE_VIS default_searcher {
3131public:
32 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
32 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
3333 default_searcher(_ForwardIterator __f, _ForwardIterator __l,
3434 _BinaryPredicate __p = _BinaryPredicate())
3535 : __first_(__f), __last_(__l), __pred_(__p) {}
3636
3737 template <typename _ForwardIterator2>
38 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
38 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
3939 pair<_ForwardIterator2, _ForwardIterator2>
4040 operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const
4141 {
......@@ -48,6 +48,7 @@ private:
4848 _ForwardIterator __last_;
4949 _BinaryPredicate __pred_;
5050};
51_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(default_searcher);
5152
5253#endif // _LIBCPP_STD_VER > 14
5354
lib/libcxx/include/__functional/function.h+29-1636
......@@ -17,20 +17,29 @@
1717#include <__functional/unary_function.h>
1818#include <__iterator/iterator_traits.h>
1919#include <__memory/addressof.h>
20#include <__memory/allocator.h>
21#include <__memory/allocator_destructor.h>
2022#include <__memory/allocator_traits.h>
23#include <__memory/builtin_new_allocator.h>
2124#include <__memory/compressed_pair.h>
22#include <__memory/shared_ptr.h>
25#include <__memory/unique_ptr.h>
26#include <__type_traits/strip_signature.h>
2327#include <__utility/forward.h>
2428#include <__utility/move.h>
29#include <__utility/piecewise_construct.h>
2530#include <__utility/swap.h>
2631#include <exception>
27#include <memory> // TODO: replace with <__memory/__builtin_new_allocator.h>
32#include <new>
33#include <tuple>
2834#include <type_traits>
35#include <typeinfo>
2936
3037#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3138# pragma GCC system_header
3239#endif
3340
41#ifndef _LIBCPP_CXX03_LANG
42
3443_LIBCPP_BEGIN_NAMESPACE_STD
3544
3645// bad_function_call
......@@ -45,13 +54,13 @@ public:
4554// bad_function_call will end up containing a weak definition of the vtable and
4655// typeinfo.
4756#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
48 virtual ~bad_function_call() _NOEXCEPT;
57 ~bad_function_call() _NOEXCEPT override;
4958#else
50 virtual ~bad_function_call() _NOEXCEPT {}
59 ~bad_function_call() _NOEXCEPT override {}
5160#endif
5261
5362#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
54 virtual const char* what() const _NOEXCEPT;
63 const char* what() const _NOEXCEPT override;
5564#endif
5665};
5766_LIBCPP_DIAGNOSTIC_POP
......@@ -66,14 +75,7 @@ void __throw_bad_function_call()
6675#endif
6776}
6877
69#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) && __has_attribute(deprecated)
70# define _LIBCPP_DEPRECATED_CXX03_FUNCTION \
71 __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type")))
72#else
73# define _LIBCPP_DEPRECATED_CXX03_FUNCTION /* nothing */
74#endif
75
76template<class _Fp> class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined
78template<class _Fp> class _LIBCPP_TEMPLATE_VIS function; // undefined
7779
7880namespace __function
7981{
......@@ -124,8 +126,6 @@ bool __not_null(_Rp (^__p)(_Args...)) { return __p; }
124126
125127} // namespace __function
126128
127#ifndef _LIBCPP_CXX03_LANG
128
129129namespace __function {
130130
131131// __alloc_func holds a functor and an allocator.
......@@ -190,9 +190,7 @@ class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)>
190190 __alloc_func* __clone() const
191191 {
192192 typedef allocator_traits<_Alloc> __alloc_traits;
193 typedef
194 typename __rebind_alloc_helper<__alloc_traits, __alloc_func>::type
195 _AA;
193 typedef __rebind_alloc<__alloc_traits, __alloc_func> _AA;
196194 _AA __a(__f_.second());
197195 typedef __allocator_destructor<_AA> _Dp;
198196 unique_ptr<__alloc_func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
......@@ -205,8 +203,7 @@ class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)>
205203
206204 static void __destroy_and_delete(__alloc_func* __f) {
207205 typedef allocator_traits<_Alloc> __alloc_traits;
208 typedef typename __rebind_alloc_helper<__alloc_traits, __alloc_func>::type
209 _FunAlloc;
206 typedef __rebind_alloc<__alloc_traits, __alloc_func> _FunAlloc;
210207 _FunAlloc __a(__f->__get_allocator());
211208 __f->destroy();
212209 __a.deallocate(__f, 1);
......@@ -265,7 +262,7 @@ class __base<_Rp(_ArgTypes...)>
265262 __base& operator=(const __base&);
266263public:
267264 _LIBCPP_INLINE_VISIBILITY __base() {}
268 _LIBCPP_INLINE_VISIBILITY virtual ~__base() {}
265 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual ~__base() {}
269266 virtual __base* __clone() const = 0;
270267 virtual void __clone(__base*) const = 0;
271268 virtual void destroy() _NOEXCEPT = 0;
......@@ -319,7 +316,7 @@ __base<_Rp(_ArgTypes...)>*
319316__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const
320317{
321318 typedef allocator_traits<_Alloc> __alloc_traits;
322 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
319 typedef __rebind_alloc<__alloc_traits, __func> _Ap;
323320 _Ap __a(__f_.__get_allocator());
324321 typedef __allocator_destructor<_Ap> _Dp;
325322 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
......@@ -346,7 +343,7 @@ void
346343__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT
347344{
348345 typedef allocator_traits<_Alloc> __alloc_traits;
349 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
346 typedef __rebind_alloc<__alloc_traits, __func> _Ap;
350347 _Ap __a(__f_.__get_allocator());
351348 __f_.destroy();
352349 __a.deallocate(this, 1);
......@@ -385,7 +382,9 @@ template <class _Fp> class __value_func;
385382
386383template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
387384{
385 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
388386 typename aligned_storage<3 * sizeof(void*)>::type __buf_;
387 _LIBCPP_SUPPRESS_DEPRECATED_POP
389388
390389 typedef __base<_Rp(_ArgTypes...)> __func;
391390 __func* __f_;
......@@ -405,8 +404,7 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
405404 {
406405 typedef allocator_traits<_Alloc> __alloc_traits;
407406 typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun;
408 typedef typename __rebind_alloc_helper<__alloc_traits, _Fun>::type
409 _FunAlloc;
407 typedef __rebind_alloc<__alloc_traits, _Fun> _FunAlloc;
410408
411409 if (__function::__not_null(__f))
412410 {
......@@ -519,7 +517,9 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
519517 return;
520518 if ((void*)__f_ == &__buf_ && (void*)__f.__f_ == &__f.__buf_)
521519 {
520 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
522521 typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
522 _LIBCPP_SUPPRESS_DEPRECATED_POP
523523 __func* __t = __as_base(&__tempbuf);
524524 __f_->__clone(__t);
525525 __f_->destroy();
......@@ -670,8 +670,7 @@ struct __policy
670670// Used to choose between perfect forwarding or pass-by-value. Pass-by-value is
671671// faster for types that can be passed in registers.
672672template <typename _Tp>
673using __fast_forward =
674 typename conditional<is_scalar<_Tp>::value, _Tp, _Tp&&>::type;
673using __fast_forward = __conditional_t<is_scalar<_Tp>::value, _Tp, _Tp&&>;
675674
676675// __policy_invoker calls an instance of __alloc_func held in __policy_storage.
677676
......@@ -747,8 +746,7 @@ template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)>
747746 {
748747 typedef __alloc_func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun;
749748 typedef allocator_traits<_Alloc> __alloc_traits;
750 typedef typename __rebind_alloc_helper<__alloc_traits, _Fun>::type
751 _FunAlloc;
749 typedef __rebind_alloc<__alloc_traits, _Fun> _FunAlloc;
752750
753751 if (__function::__not_null(__f))
754752 {
......@@ -978,7 +976,7 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
978976 __func __f_;
979977
980978 template <class _Fp, bool = _And<
981 _IsNotSame<__uncvref_t<_Fp>, function>,
979 _IsNotSame<__remove_cvref_t<_Fp>, function>,
982980 __invokable<_Fp, _ArgTypes...>
983981 >::value>
984982 struct __callable;
......@@ -1070,45 +1068,6 @@ public:
10701068template<class _Rp, class ..._Ap>
10711069function(_Rp(*)(_Ap...)) -> function<_Rp(_Ap...)>;
10721070
1073template<class _Fp>
1074struct __strip_signature;
1075
1076template<class _Rp, class _Gp, class ..._Ap>
1077struct __strip_signature<_Rp (_Gp::*) (_Ap...)> { using type = _Rp(_Ap...); };
1078template<class _Rp, class _Gp, class ..._Ap>
1079struct __strip_signature<_Rp (_Gp::*) (_Ap...) const> { using type = _Rp(_Ap...); };
1080template<class _Rp, class _Gp, class ..._Ap>
1081struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile> { using type = _Rp(_Ap...); };
1082template<class _Rp, class _Gp, class ..._Ap>
1083struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile> { using type = _Rp(_Ap...); };
1084
1085template<class _Rp, class _Gp, class ..._Ap>
1086struct __strip_signature<_Rp (_Gp::*) (_Ap...) &> { using type = _Rp(_Ap...); };
1087template<class _Rp, class _Gp, class ..._Ap>
1088struct __strip_signature<_Rp (_Gp::*) (_Ap...) const &> { using type = _Rp(_Ap...); };
1089template<class _Rp, class _Gp, class ..._Ap>
1090struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile &> { using type = _Rp(_Ap...); };
1091template<class _Rp, class _Gp, class ..._Ap>
1092struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile &> { using type = _Rp(_Ap...); };
1093
1094template<class _Rp, class _Gp, class ..._Ap>
1095struct __strip_signature<_Rp (_Gp::*) (_Ap...) noexcept> { using type = _Rp(_Ap...); };
1096template<class _Rp, class _Gp, class ..._Ap>
1097struct __strip_signature<_Rp (_Gp::*) (_Ap...) const noexcept> { using type = _Rp(_Ap...); };
1098template<class _Rp, class _Gp, class ..._Ap>
1099struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile noexcept> { using type = _Rp(_Ap...); };
1100template<class _Rp, class _Gp, class ..._Ap>
1101struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile noexcept> { using type = _Rp(_Ap...); };
1102
1103template<class _Rp, class _Gp, class ..._Ap>
1104struct __strip_signature<_Rp (_Gp::*) (_Ap...) & noexcept> { using type = _Rp(_Ap...); };
1105template<class _Rp, class _Gp, class ..._Ap>
1106struct __strip_signature<_Rp (_Gp::*) (_Ap...) const & noexcept> { using type = _Rp(_Ap...); };
1107template<class _Rp, class _Gp, class ..._Ap>
1108struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile & noexcept> { using type = _Rp(_Ap...); };
1109template<class _Rp, class _Gp, class ..._Ap>
1110struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile & noexcept> { using type = _Rp(_Ap...); };
1111
11121071template<class _Fp, class _Stripped = typename __strip_signature<decltype(&_Fp::operator())>::type>
11131072function(_Fp) -> function<_Stripped>;
11141073#endif // _LIBCPP_STD_VER >= 17
......@@ -1250,1574 +1209,8 @@ void
12501209swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT
12511210{return __x.swap(__y);}
12521211
1253#elif defined(_LIBCPP_ENABLE_CXX03_FUNCTION)
1254
1255namespace __function {
1256
1257template<class _Fp> class __base;
1258
1259template<class _Rp>
1260class __base<_Rp()>
1261{
1262 __base(const __base&);
1263 __base& operator=(const __base&);
1264public:
1265 __base() {}
1266 virtual ~__base() {}
1267 virtual __base* __clone() const = 0;
1268 virtual void __clone(__base*) const = 0;
1269 virtual void destroy() = 0;
1270 virtual void destroy_deallocate() = 0;
1271 virtual _Rp operator()() = 0;
1272#ifndef _LIBCPP_NO_RTTI
1273 virtual const void* target(const type_info&) const = 0;
1274 virtual const std::type_info& target_type() const = 0;
1275#endif // _LIBCPP_NO_RTTI
1276};
1277
1278template<class _Rp, class _A0>
1279class __base<_Rp(_A0)>
1280{
1281 __base(const __base&);
1282 __base& operator=(const __base&);
1283public:
1284 __base() {}
1285 virtual ~__base() {}
1286 virtual __base* __clone() const = 0;
1287 virtual void __clone(__base*) const = 0;
1288 virtual void destroy() = 0;
1289 virtual void destroy_deallocate() = 0;
1290 virtual _Rp operator()(_A0) = 0;
1291#ifndef _LIBCPP_NO_RTTI
1292 virtual const void* target(const type_info&) const = 0;
1293 virtual const std::type_info& target_type() const = 0;
1294#endif // _LIBCPP_NO_RTTI
1295};
1296
1297template<class _Rp, class _A0, class _A1>
1298class __base<_Rp(_A0, _A1)>
1299{
1300 __base(const __base&);
1301 __base& operator=(const __base&);
1302public:
1303 __base() {}
1304 virtual ~__base() {}
1305 virtual __base* __clone() const = 0;
1306 virtual void __clone(__base*) const = 0;
1307 virtual void destroy() = 0;
1308 virtual void destroy_deallocate() = 0;
1309 virtual _Rp operator()(_A0, _A1) = 0;
1310#ifndef _LIBCPP_NO_RTTI
1311 virtual const void* target(const type_info&) const = 0;
1312 virtual const std::type_info& target_type() const = 0;
1313#endif // _LIBCPP_NO_RTTI
1314};
1315
1316template<class _Rp, class _A0, class _A1, class _A2>
1317class __base<_Rp(_A0, _A1, _A2)>
1318{
1319 __base(const __base&);
1320 __base& operator=(const __base&);
1321public:
1322 __base() {}
1323 virtual ~__base() {}
1324 virtual __base* __clone() const = 0;
1325 virtual void __clone(__base*) const = 0;
1326 virtual void destroy() = 0;
1327 virtual void destroy_deallocate() = 0;
1328 virtual _Rp operator()(_A0, _A1, _A2) = 0;
1329#ifndef _LIBCPP_NO_RTTI
1330 virtual const void* target(const type_info&) const = 0;
1331 virtual const std::type_info& target_type() const = 0;
1332#endif // _LIBCPP_NO_RTTI
1333};
1334
1335template<class _FD, class _Alloc, class _FB> class __func;
1336
1337template<class _Fp, class _Alloc, class _Rp>
1338class __func<_Fp, _Alloc, _Rp()>
1339 : public __base<_Rp()>
1340{
1341 __compressed_pair<_Fp, _Alloc> __f_;
1342public:
1343 explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {}
1344 explicit __func(_Fp __f, _Alloc __a) : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
1345 virtual __base<_Rp()>* __clone() const;
1346 virtual void __clone(__base<_Rp()>*) const;
1347 virtual void destroy();
1348 virtual void destroy_deallocate();
1349 virtual _Rp operator()();
1350#ifndef _LIBCPP_NO_RTTI
1351 virtual const void* target(const type_info&) const;
1352 virtual const std::type_info& target_type() const;
1353#endif // _LIBCPP_NO_RTTI
1354};
1355
1356template<class _Fp, class _Alloc, class _Rp>
1357__base<_Rp()>*
1358__func<_Fp, _Alloc, _Rp()>::__clone() const
1359{
1360 typedef allocator_traits<_Alloc> __alloc_traits;
1361 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
1362 _Ap __a(__f_.second());
1363 typedef __allocator_destructor<_Ap> _Dp;
1364 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1365 ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
1366 return __hold.release();
1367}
1368
1369template<class _Fp, class _Alloc, class _Rp>
1370void
1371__func<_Fp, _Alloc, _Rp()>::__clone(__base<_Rp()>* __p) const
1372{
1373 ::new ((void*)__p) __func(__f_.first(), __f_.second());
1374}
1375
1376template<class _Fp, class _Alloc, class _Rp>
1377void
1378__func<_Fp, _Alloc, _Rp()>::destroy()
1379{
1380 __f_.~__compressed_pair<_Fp, _Alloc>();
1381}
1382
1383template<class _Fp, class _Alloc, class _Rp>
1384void
1385__func<_Fp, _Alloc, _Rp()>::destroy_deallocate()
1386{
1387 typedef allocator_traits<_Alloc> __alloc_traits;
1388 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
1389 _Ap __a(__f_.second());
1390 __f_.~__compressed_pair<_Fp, _Alloc>();
1391 __a.deallocate(this, 1);
1392}
1393
1394template<class _Fp, class _Alloc, class _Rp>
1395_Rp
1396__func<_Fp, _Alloc, _Rp()>::operator()()
1397{
1398 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
1399 return _Invoker::__call(__f_.first());
1400}
1401
1402#ifndef _LIBCPP_NO_RTTI
1403
1404template<class _Fp, class _Alloc, class _Rp>
1405const void*
1406__func<_Fp, _Alloc, _Rp()>::target(const type_info& __ti) const
1407{
1408 if (__ti == typeid(_Fp))
1409 return _VSTD::addressof(__f_.first());
1410 return (const void*)0;
1411}
1412
1413template<class _Fp, class _Alloc, class _Rp>
1414const std::type_info&
1415__func<_Fp, _Alloc, _Rp()>::target_type() const
1416{
1417 return typeid(_Fp);
1418}
1419
1420#endif // _LIBCPP_NO_RTTI
1421
1422template<class _Fp, class _Alloc, class _Rp, class _A0>
1423class __func<_Fp, _Alloc, _Rp(_A0)>
1424 : public __base<_Rp(_A0)>
1425{
1426 __compressed_pair<_Fp, _Alloc> __f_;
1427public:
1428 _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {}
1429 _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a)
1430 : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
1431 virtual __base<_Rp(_A0)>* __clone() const;
1432 virtual void __clone(__base<_Rp(_A0)>*) const;
1433 virtual void destroy();
1434 virtual void destroy_deallocate();
1435 virtual _Rp operator()(_A0);
1436#ifndef _LIBCPP_NO_RTTI
1437 virtual const void* target(const type_info&) const;
1438 virtual const std::type_info& target_type() const;
1439#endif // _LIBCPP_NO_RTTI
1440};
1441
1442template<class _Fp, class _Alloc, class _Rp, class _A0>
1443__base<_Rp(_A0)>*
1444__func<_Fp, _Alloc, _Rp(_A0)>::__clone() const
1445{
1446 typedef allocator_traits<_Alloc> __alloc_traits;
1447 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
1448 _Ap __a(__f_.second());
1449 typedef __allocator_destructor<_Ap> _Dp;
1450 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1451 ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
1452 return __hold.release();
1453}
1454
1455template<class _Fp, class _Alloc, class _Rp, class _A0>
1456void
1457__func<_Fp, _Alloc, _Rp(_A0)>::__clone(__base<_Rp(_A0)>* __p) const
1458{
1459 ::new ((void*)__p) __func(__f_.first(), __f_.second());
1460}
1461
1462template<class _Fp, class _Alloc, class _Rp, class _A0>
1463void
1464__func<_Fp, _Alloc, _Rp(_A0)>::destroy()
1465{
1466 __f_.~__compressed_pair<_Fp, _Alloc>();
1467}
1468
1469template<class _Fp, class _Alloc, class _Rp, class _A0>
1470void
1471__func<_Fp, _Alloc, _Rp(_A0)>::destroy_deallocate()
1472{
1473 typedef allocator_traits<_Alloc> __alloc_traits;
1474 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
1475 _Ap __a(__f_.second());
1476 __f_.~__compressed_pair<_Fp, _Alloc>();
1477 __a.deallocate(this, 1);
1478}
1479
1480template<class _Fp, class _Alloc, class _Rp, class _A0>
1481_Rp
1482__func<_Fp, _Alloc, _Rp(_A0)>::operator()(_A0 __a0)
1483{
1484 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
1485 return _Invoker::__call(__f_.first(), __a0);
1486}
1487
1488#ifndef _LIBCPP_NO_RTTI
1489
1490template<class _Fp, class _Alloc, class _Rp, class _A0>
1491const void*
1492__func<_Fp, _Alloc, _Rp(_A0)>::target(const type_info& __ti) const
1493{
1494 if (__ti == typeid(_Fp))
1495 return &__f_.first();
1496 return (const void*)0;
1497}
1498
1499template<class _Fp, class _Alloc, class _Rp, class _A0>
1500const std::type_info&
1501__func<_Fp, _Alloc, _Rp(_A0)>::target_type() const
1502{
1503 return typeid(_Fp);
1504}
1505
1506#endif // _LIBCPP_NO_RTTI
1507
1508template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
1509class __func<_Fp, _Alloc, _Rp(_A0, _A1)>
1510 : public __base<_Rp(_A0, _A1)>
1511{
1512 __compressed_pair<_Fp, _Alloc> __f_;
1513public:
1514 _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {}
1515 _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a)
1516 : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
1517 virtual __base<_Rp(_A0, _A1)>* __clone() const;
1518 virtual void __clone(__base<_Rp(_A0, _A1)>*) const;
1519 virtual void destroy();
1520 virtual void destroy_deallocate();
1521 virtual _Rp operator()(_A0, _A1);
1522#ifndef _LIBCPP_NO_RTTI
1523 virtual const void* target(const type_info&) const;
1524 virtual const std::type_info& target_type() const;
1525#endif // _LIBCPP_NO_RTTI
1526};
1527
1528template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
1529__base<_Rp(_A0, _A1)>*
1530__func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone() const
1531{
1532 typedef allocator_traits<_Alloc> __alloc_traits;
1533 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
1534 _Ap __a(__f_.second());
1535 typedef __allocator_destructor<_Ap> _Dp;
1536 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1537 ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
1538 return __hold.release();
1539}
1540
1541template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
1542void
1543__func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone(__base<_Rp(_A0, _A1)>* __p) const
1544{
1545 ::new ((void*)__p) __func(__f_.first(), __f_.second());
1546}
1547
1548template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
1549void
1550__func<_Fp, _Alloc, _Rp(_A0, _A1)>::destroy()
1551{
1552 __f_.~__compressed_pair<_Fp, _Alloc>();
1553}
1554
1555template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
1556void
1557__func<_Fp, _Alloc, _Rp(_A0, _A1)>::destroy_deallocate()
1558{
1559 typedef allocator_traits<_Alloc> __alloc_traits;
1560 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
1561 _Ap __a(__f_.second());
1562 __f_.~__compressed_pair<_Fp, _Alloc>();
1563 __a.deallocate(this, 1);
1564}
1565
1566template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
1567_Rp
1568__func<_Fp, _Alloc, _Rp(_A0, _A1)>::operator()(_A0 __a0, _A1 __a1)
1569{
1570 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
1571 return _Invoker::__call(__f_.first(), __a0, __a1);
1572}
1573
1574#ifndef _LIBCPP_NO_RTTI
1575
1576template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
1577const void*
1578__func<_Fp, _Alloc, _Rp(_A0, _A1)>::target(const type_info& __ti) const
1579{
1580 if (__ti == typeid(_Fp))
1581 return &__f_.first();
1582 return (const void*)0;
1583}
1584
1585template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
1586const std::type_info&
1587__func<_Fp, _Alloc, _Rp(_A0, _A1)>::target_type() const
1588{
1589 return typeid(_Fp);
1590}
1591
1592#endif // _LIBCPP_NO_RTTI
1593
1594template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
1595class __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>
1596 : public __base<_Rp(_A0, _A1, _A2)>
1597{
1598 __compressed_pair<_Fp, _Alloc> __f_;
1599public:
1600 _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {}
1601 _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a)
1602 : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
1603 virtual __base<_Rp(_A0, _A1, _A2)>* __clone() const;
1604 virtual void __clone(__base<_Rp(_A0, _A1, _A2)>*) const;
1605 virtual void destroy();
1606 virtual void destroy_deallocate();
1607 virtual _Rp operator()(_A0, _A1, _A2);
1608#ifndef _LIBCPP_NO_RTTI
1609 virtual const void* target(const type_info&) const;
1610 virtual const std::type_info& target_type() const;
1611#endif // _LIBCPP_NO_RTTI
1612};
1613
1614template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
1615__base<_Rp(_A0, _A1, _A2)>*
1616__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone() const
1617{
1618 typedef allocator_traits<_Alloc> __alloc_traits;
1619 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
1620 _Ap __a(__f_.second());
1621 typedef __allocator_destructor<_Ap> _Dp;
1622 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1623 ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a));
1624 return __hold.release();
1625}
1626
1627template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
1628void
1629__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone(__base<_Rp(_A0, _A1, _A2)>* __p) const
1630{
1631 ::new ((void*)__p) __func(__f_.first(), __f_.second());
1632}
1633
1634template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
1635void
1636__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::destroy()
1637{
1638 __f_.~__compressed_pair<_Fp, _Alloc>();
1639}
1640
1641template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
1642void
1643__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::destroy_deallocate()
1644{
1645 typedef allocator_traits<_Alloc> __alloc_traits;
1646 typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
1647 _Ap __a(__f_.second());
1648 __f_.~__compressed_pair<_Fp, _Alloc>();
1649 __a.deallocate(this, 1);
1650}
1651
1652template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
1653_Rp
1654__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::operator()(_A0 __a0, _A1 __a1, _A2 __a2)
1655{
1656 typedef __invoke_void_return_wrapper<_Rp> _Invoker;
1657 return _Invoker::__call(__f_.first(), __a0, __a1, __a2);
1658}
1659
1660#ifndef _LIBCPP_NO_RTTI
1661
1662template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
1663const void*
1664__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::target(const type_info& __ti) const
1665{
1666 if (__ti == typeid(_Fp))
1667 return &__f_.first();
1668 return (const void*)0;
1669}
1670
1671template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
1672const std::type_info&
1673__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::target_type() const
1674{
1675 return typeid(_Fp);
1676}
1677
1678#endif // _LIBCPP_NO_RTTI
1679
1680} // namespace __function
1681
1682template<class _Rp>
1683class _LIBCPP_TEMPLATE_VIS function<_Rp()>
1684{
1685 typedef __function::__base<_Rp()> __base;
1686 aligned_storage<3*sizeof(void*)>::type __buf_;
1687 __base* __f_;
1688
1689public:
1690 typedef _Rp result_type;
1691
1692 // 20.7.16.2.1, construct/copy/destroy:
1693 _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {}
1694 _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {}
1695 function(const function&);
1696 template<class _Fp>
1697 function(_Fp,
1698 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
1699
1700 template<class _Alloc>
1701 _LIBCPP_INLINE_VISIBILITY
1702 function(allocator_arg_t, const _Alloc&) : __f_(0) {}
1703 template<class _Alloc>
1704 _LIBCPP_INLINE_VISIBILITY
1705 function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {}
1706 template<class _Alloc>
1707 function(allocator_arg_t, const _Alloc&, const function&);
1708 template<class _Fp, class _Alloc>
1709 function(allocator_arg_t, const _Alloc& __a, _Fp __f,
1710 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
1711
1712 function& operator=(const function&);
1713 function& operator=(nullptr_t);
1714 template<class _Fp>
1715 typename enable_if
1716 <
1717 !is_integral<_Fp>::value,
1718 function&
1719 >::type
1720 operator=(_Fp);
1721
1722 ~function();
1723
1724 // 20.7.16.2.2, function modifiers:
1725 void swap(function&);
1726 template<class _Fp, class _Alloc>
1727 _LIBCPP_INLINE_VISIBILITY
1728 void assign(_Fp __f, const _Alloc& __a)
1729 {function(allocator_arg, __a, __f).swap(*this);}
1730
1731 // 20.7.16.2.3, function capacity:
1732 _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;}
1733
1734 template<class _R2>
1735 bool operator==(const function<_R2()>&) const = delete;
1736 template<class _R2>
1737 bool operator!=(const function<_R2()>&) const = delete;
1738
1739 // 20.7.16.2.4, function invocation:
1740 _Rp operator()() const;
1741
1742#ifndef _LIBCPP_NO_RTTI
1743 // 20.7.16.2.5, function target access:
1744 const std::type_info& target_type() const;
1745 template <typename _Tp> _Tp* target();
1746 template <typename _Tp> const _Tp* target() const;
1747#endif // _LIBCPP_NO_RTTI
1748};
1749
1750template<class _Rp>
1751function<_Rp()>::function(const function& __f)
1752{
1753 if (__f.__f_ == 0)
1754 __f_ = 0;
1755 else if (__f.__f_ == (const __base*)&__f.__buf_)
1756 {
1757 __f_ = (__base*)&__buf_;
1758 __f.__f_->__clone(__f_);
1759 }
1760 else
1761 __f_ = __f.__f_->__clone();
1762}
1763
1764template<class _Rp>
1765template<class _Alloc>
1766function<_Rp()>::function(allocator_arg_t, const _Alloc&, const function& __f)
1767{
1768 if (__f.__f_ == 0)
1769 __f_ = 0;
1770 else if (__f.__f_ == (const __base*)&__f.__buf_)
1771 {
1772 __f_ = (__base*)&__buf_;
1773 __f.__f_->__clone(__f_);
1774 }
1775 else
1776 __f_ = __f.__f_->__clone();
1777}
1778
1779template<class _Rp>
1780template <class _Fp>
1781function<_Rp()>::function(_Fp __f,
1782 typename enable_if<!is_integral<_Fp>::value>::type*)
1783 : __f_(0)
1784{
1785 if (__function::__not_null(__f))
1786 {
1787 typedef __function::__func<_Fp, allocator<_Fp>, _Rp()> _FF;
1788 if (sizeof(_FF) <= sizeof(__buf_))
1789 {
1790 __f_ = (__base*)&__buf_;
1791 ::new ((void*)__f_) _FF(__f);
1792 }
1793 else
1794 {
1795 typedef allocator<_FF> _Ap;
1796 _Ap __a;
1797 typedef __allocator_destructor<_Ap> _Dp;
1798 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1799 ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a));
1800 __f_ = __hold.release();
1801 }
1802 }
1803}
1804
1805template<class _Rp>
1806template <class _Fp, class _Alloc>
1807function<_Rp()>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
1808 typename enable_if<!is_integral<_Fp>::value>::type*)
1809 : __f_(0)
1810{
1811 typedef allocator_traits<_Alloc> __alloc_traits;
1812 if (__function::__not_null(__f))
1813 {
1814 typedef __function::__func<_Fp, _Alloc, _Rp()> _FF;
1815 if (sizeof(_FF) <= sizeof(__buf_))
1816 {
1817 __f_ = (__base*)&__buf_;
1818 ::new ((void*)__f_) _FF(__f, __a0);
1819 }
1820 else
1821 {
1822 typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
1823 _Ap __a(__a0);
1824 typedef __allocator_destructor<_Ap> _Dp;
1825 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
1826 ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a));
1827 __f_ = __hold.release();
1828 }
1829 }
1830}
1831
1832template<class _Rp>
1833function<_Rp()>&
1834function<_Rp()>::operator=(const function& __f)
1835{
1836 if (__f)
1837 function(__f).swap(*this);
1838 else
1839 *this = nullptr;
1840 return *this;
1841}
1842
1843template<class _Rp>
1844function<_Rp()>&
1845function<_Rp()>::operator=(nullptr_t)
1846{
1847 __base* __t = __f_;
1848 __f_ = 0;
1849 if (__t == (__base*)&__buf_)
1850 __t->destroy();
1851 else if (__t)
1852 __t->destroy_deallocate();
1853 return *this;
1854}
1855
1856template<class _Rp>
1857template <class _Fp>
1858typename enable_if
1859<
1860 !is_integral<_Fp>::value,
1861 function<_Rp()>&
1862>::type
1863function<_Rp()>::operator=(_Fp __f)
1864{
1865 function(_VSTD::move(__f)).swap(*this);
1866 return *this;
1867}
1868
1869template<class _Rp>
1870function<_Rp()>::~function()
1871{
1872 if (__f_ == (__base*)&__buf_)
1873 __f_->destroy();
1874 else if (__f_)
1875 __f_->destroy_deallocate();
1876}
1877
1878template<class _Rp>
1879void
1880function<_Rp()>::swap(function& __f)
1881{
1882 if (_VSTD::addressof(__f) == this)
1883 return;
1884 if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
1885 {
1886 typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
1887 __base* __t = (__base*)&__tempbuf;
1888 __f_->__clone(__t);
1889 __f_->destroy();
1890 __f_ = 0;
1891 __f.__f_->__clone((__base*)&__buf_);
1892 __f.__f_->destroy();
1893 __f.__f_ = 0;
1894 __f_ = (__base*)&__buf_;
1895 __t->__clone((__base*)&__f.__buf_);
1896 __t->destroy();
1897 __f.__f_ = (__base*)&__f.__buf_;
1898 }
1899 else if (__f_ == (__base*)&__buf_)
1900 {
1901 __f_->__clone((__base*)&__f.__buf_);
1902 __f_->destroy();
1903 __f_ = __f.__f_;
1904 __f.__f_ = (__base*)&__f.__buf_;
1905 }
1906 else if (__f.__f_ == (__base*)&__f.__buf_)
1907 {
1908 __f.__f_->__clone((__base*)&__buf_);
1909 __f.__f_->destroy();
1910 __f.__f_ = __f_;
1911 __f_ = (__base*)&__buf_;
1912 }
1913 else
1914 _VSTD::swap(__f_, __f.__f_);
1915}
1916
1917template<class _Rp>
1918_Rp
1919function<_Rp()>::operator()() const
1920{
1921 if (__f_ == 0)
1922 __throw_bad_function_call();
1923 return (*__f_)();
1924}
1925
1926#ifndef _LIBCPP_NO_RTTI
1927
1928template<class _Rp>
1929const std::type_info&
1930function<_Rp()>::target_type() const
1931{
1932 if (__f_ == 0)
1933 return typeid(void);
1934 return __f_->target_type();
1935}
1936
1937template<class _Rp>
1938template <typename _Tp>
1939_Tp*
1940function<_Rp()>::target()
1941{
1942 if (__f_ == 0)
1943 return (_Tp*)0;
1944 return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
1945}
1946
1947template<class _Rp>
1948template <typename _Tp>
1949const _Tp*
1950function<_Rp()>::target() const
1951{
1952 if (__f_ == 0)
1953 return (const _Tp*)0;
1954 return (const _Tp*)__f_->target(typeid(_Tp));
1955}
1956
1957#endif // _LIBCPP_NO_RTTI
1958
1959template<class _Rp, class _A0>
1960class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0)>
1961 : public unary_function<_A0, _Rp>
1962{
1963 typedef __function::__base<_Rp(_A0)> __base;
1964 aligned_storage<3*sizeof(void*)>::type __buf_;
1965 __base* __f_;
1966
1967public:
1968 typedef _Rp result_type;
1969
1970 // 20.7.16.2.1, construct/copy/destroy:
1971 _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {}
1972 _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {}
1973 function(const function&);
1974 template<class _Fp>
1975 function(_Fp,
1976 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
1977
1978 template<class _Alloc>
1979 _LIBCPP_INLINE_VISIBILITY
1980 function(allocator_arg_t, const _Alloc&) : __f_(0) {}
1981 template<class _Alloc>
1982 _LIBCPP_INLINE_VISIBILITY
1983 function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {}
1984 template<class _Alloc>
1985 function(allocator_arg_t, const _Alloc&, const function&);
1986 template<class _Fp, class _Alloc>
1987 function(allocator_arg_t, const _Alloc& __a, _Fp __f,
1988 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
1989
1990 function& operator=(const function&);
1991 function& operator=(nullptr_t);
1992 template<class _Fp>
1993 typename enable_if
1994 <
1995 !is_integral<_Fp>::value,
1996 function&
1997 >::type
1998 operator=(_Fp);
1999
2000 ~function();
2001
2002 // 20.7.16.2.2, function modifiers:
2003 void swap(function&);
2004 template<class _Fp, class _Alloc>
2005 _LIBCPP_INLINE_VISIBILITY
2006 void assign(_Fp __f, const _Alloc& __a)
2007 {function(allocator_arg, __a, __f).swap(*this);}
2008
2009 // 20.7.16.2.3, function capacity:
2010 _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;}
2011
2012 template<class _R2, class _B0>
2013 bool operator==(const function<_R2(_B0)>&) const = delete;
2014 template<class _R2, class _B0>
2015 bool operator!=(const function<_R2(_B0)>&) const = delete;
2016
2017 // 20.7.16.2.4, function invocation:
2018 _Rp operator()(_A0) const;
2019
2020#ifndef _LIBCPP_NO_RTTI
2021 // 20.7.16.2.5, function target access:
2022 const std::type_info& target_type() const;
2023 template <typename _Tp> _Tp* target();
2024 template <typename _Tp> const _Tp* target() const;
2025#endif // _LIBCPP_NO_RTTI
2026};
2027
2028template<class _Rp, class _A0>
2029function<_Rp(_A0)>::function(const function& __f)
2030{
2031 if (__f.__f_ == 0)
2032 __f_ = 0;
2033 else if (__f.__f_ == (const __base*)&__f.__buf_)
2034 {
2035 __f_ = (__base*)&__buf_;
2036 __f.__f_->__clone(__f_);
2037 }
2038 else
2039 __f_ = __f.__f_->__clone();
2040}
2041
2042template<class _Rp, class _A0>
2043template<class _Alloc>
2044function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc&, const function& __f)
2045{
2046 if (__f.__f_ == 0)
2047 __f_ = 0;
2048 else if (__f.__f_ == (const __base*)&__f.__buf_)
2049 {
2050 __f_ = (__base*)&__buf_;
2051 __f.__f_->__clone(__f_);
2052 }
2053 else
2054 __f_ = __f.__f_->__clone();
2055}
2056
2057template<class _Rp, class _A0>
2058template <class _Fp>
2059function<_Rp(_A0)>::function(_Fp __f,
2060 typename enable_if<!is_integral<_Fp>::value>::type*)
2061 : __f_(0)
2062{
2063 if (__function::__not_null(__f))
2064 {
2065 typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0)> _FF;
2066 if (sizeof(_FF) <= sizeof(__buf_))
2067 {
2068 __f_ = (__base*)&__buf_;
2069 ::new ((void*)__f_) _FF(__f);
2070 }
2071 else
2072 {
2073 typedef allocator<_FF> _Ap;
2074 _Ap __a;
2075 typedef __allocator_destructor<_Ap> _Dp;
2076 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
2077 ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a));
2078 __f_ = __hold.release();
2079 }
2080 }
2081}
2082
2083template<class _Rp, class _A0>
2084template <class _Fp, class _Alloc>
2085function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
2086 typename enable_if<!is_integral<_Fp>::value>::type*)
2087 : __f_(0)
2088{
2089 typedef allocator_traits<_Alloc> __alloc_traits;
2090 if (__function::__not_null(__f))
2091 {
2092 typedef __function::__func<_Fp, _Alloc, _Rp(_A0)> _FF;
2093 if (sizeof(_FF) <= sizeof(__buf_))
2094 {
2095 __f_ = (__base*)&__buf_;
2096 ::new ((void*)__f_) _FF(__f, __a0);
2097 }
2098 else
2099 {
2100 typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
2101 _Ap __a(__a0);
2102 typedef __allocator_destructor<_Ap> _Dp;
2103 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
2104 ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a));
2105 __f_ = __hold.release();
2106 }
2107 }
2108}
2109
2110template<class _Rp, class _A0>
2111function<_Rp(_A0)>&
2112function<_Rp(_A0)>::operator=(const function& __f)
2113{
2114 if (__f)
2115 function(__f).swap(*this);
2116 else
2117 *this = nullptr;
2118 return *this;
2119}
2120
2121template<class _Rp, class _A0>
2122function<_Rp(_A0)>&
2123function<_Rp(_A0)>::operator=(nullptr_t)
2124{
2125 __base* __t = __f_;
2126 __f_ = 0;
2127 if (__t == (__base*)&__buf_)
2128 __t->destroy();
2129 else if (__t)
2130 __t->destroy_deallocate();
2131 return *this;
2132}
2133
2134template<class _Rp, class _A0>
2135template <class _Fp>
2136typename enable_if
2137<
2138 !is_integral<_Fp>::value,
2139 function<_Rp(_A0)>&
2140>::type
2141function<_Rp(_A0)>::operator=(_Fp __f)
2142{
2143 function(_VSTD::move(__f)).swap(*this);
2144 return *this;
2145}
2146
2147template<class _Rp, class _A0>
2148function<_Rp(_A0)>::~function()
2149{
2150 if (__f_ == (__base*)&__buf_)
2151 __f_->destroy();
2152 else if (__f_)
2153 __f_->destroy_deallocate();
2154}
2155
2156template<class _Rp, class _A0>
2157void
2158function<_Rp(_A0)>::swap(function& __f)
2159{
2160 if (_VSTD::addressof(__f) == this)
2161 return;
2162 if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
2163 {
2164 typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
2165 __base* __t = (__base*)&__tempbuf;
2166 __f_->__clone(__t);
2167 __f_->destroy();
2168 __f_ = 0;
2169 __f.__f_->__clone((__base*)&__buf_);
2170 __f.__f_->destroy();
2171 __f.__f_ = 0;
2172 __f_ = (__base*)&__buf_;
2173 __t->__clone((__base*)&__f.__buf_);
2174 __t->destroy();
2175 __f.__f_ = (__base*)&__f.__buf_;
2176 }
2177 else if (__f_ == (__base*)&__buf_)
2178 {
2179 __f_->__clone((__base*)&__f.__buf_);
2180 __f_->destroy();
2181 __f_ = __f.__f_;
2182 __f.__f_ = (__base*)&__f.__buf_;
2183 }
2184 else if (__f.__f_ == (__base*)&__f.__buf_)
2185 {
2186 __f.__f_->__clone((__base*)&__buf_);
2187 __f.__f_->destroy();
2188 __f.__f_ = __f_;
2189 __f_ = (__base*)&__buf_;
2190 }
2191 else
2192 _VSTD::swap(__f_, __f.__f_);
2193}
2194
2195template<class _Rp, class _A0>
2196_Rp
2197function<_Rp(_A0)>::operator()(_A0 __a0) const
2198{
2199 if (__f_ == 0)
2200 __throw_bad_function_call();
2201 return (*__f_)(__a0);
2202}
2203
2204#ifndef _LIBCPP_NO_RTTI
2205
2206template<class _Rp, class _A0>
2207const std::type_info&
2208function<_Rp(_A0)>::target_type() const
2209{
2210 if (__f_ == 0)
2211 return typeid(void);
2212 return __f_->target_type();
2213}
2214
2215template<class _Rp, class _A0>
2216template <typename _Tp>
2217_Tp*
2218function<_Rp(_A0)>::target()
2219{
2220 if (__f_ == 0)
2221 return (_Tp*)0;
2222 return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
2223}
2224
2225template<class _Rp, class _A0>
2226template <typename _Tp>
2227const _Tp*
2228function<_Rp(_A0)>::target() const
2229{
2230 if (__f_ == 0)
2231 return (const _Tp*)0;
2232 return (const _Tp*)__f_->target(typeid(_Tp));
2233}
2234
2235#endif // _LIBCPP_NO_RTTI
2236
2237template<class _Rp, class _A0, class _A1>
2238class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0, _A1)>
2239 : public binary_function<_A0, _A1, _Rp>
2240{
2241 typedef __function::__base<_Rp(_A0, _A1)> __base;
2242 aligned_storage<3*sizeof(void*)>::type __buf_;
2243 __base* __f_;
2244
2245public:
2246 typedef _Rp result_type;
2247
2248 // 20.7.16.2.1, construct/copy/destroy:
2249 _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {}
2250 _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {}
2251 function(const function&);
2252 template<class _Fp>
2253 function(_Fp,
2254 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
2255
2256 template<class _Alloc>
2257 _LIBCPP_INLINE_VISIBILITY
2258 function(allocator_arg_t, const _Alloc&) : __f_(0) {}
2259 template<class _Alloc>
2260 _LIBCPP_INLINE_VISIBILITY
2261 function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {}
2262 template<class _Alloc>
2263 function(allocator_arg_t, const _Alloc&, const function&);
2264 template<class _Fp, class _Alloc>
2265 function(allocator_arg_t, const _Alloc& __a, _Fp __f,
2266 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
2267
2268 function& operator=(const function&);
2269 function& operator=(nullptr_t);
2270 template<class _Fp>
2271 typename enable_if
2272 <
2273 !is_integral<_Fp>::value,
2274 function&
2275 >::type
2276 operator=(_Fp);
2277
2278 ~function();
2279
2280 // 20.7.16.2.2, function modifiers:
2281 void swap(function&);
2282 template<class _Fp, class _Alloc>
2283 _LIBCPP_INLINE_VISIBILITY
2284 void assign(_Fp __f, const _Alloc& __a)
2285 {function(allocator_arg, __a, __f).swap(*this);}
2286
2287 // 20.7.16.2.3, function capacity:
2288 _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;}
2289
2290 template<class _R2, class _B0, class _B1>
2291 bool operator==(const function<_R2(_B0, _B1)>&) const = delete;
2292 template<class _R2, class _B0, class _B1>
2293 bool operator!=(const function<_R2(_B0, _B1)>&) const = delete;
2294
2295 // 20.7.16.2.4, function invocation:
2296 _Rp operator()(_A0, _A1) const;
2297
2298#ifndef _LIBCPP_NO_RTTI
2299 // 20.7.16.2.5, function target access:
2300 const std::type_info& target_type() const;
2301 template <typename _Tp> _Tp* target();
2302 template <typename _Tp> const _Tp* target() const;
2303#endif // _LIBCPP_NO_RTTI
2304};
2305
2306template<class _Rp, class _A0, class _A1>
2307function<_Rp(_A0, _A1)>::function(const function& __f)
2308{
2309 if (__f.__f_ == 0)
2310 __f_ = 0;
2311 else if (__f.__f_ == (const __base*)&__f.__buf_)
2312 {
2313 __f_ = (__base*)&__buf_;
2314 __f.__f_->__clone(__f_);
2315 }
2316 else
2317 __f_ = __f.__f_->__clone();
2318}
2319
2320template<class _Rp, class _A0, class _A1>
2321template<class _Alloc>
2322function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc&, const function& __f)
2323{
2324 if (__f.__f_ == 0)
2325 __f_ = 0;
2326 else if (__f.__f_ == (const __base*)&__f.__buf_)
2327 {
2328 __f_ = (__base*)&__buf_;
2329 __f.__f_->__clone(__f_);
2330 }
2331 else
2332 __f_ = __f.__f_->__clone();
2333}
2334
2335template<class _Rp, class _A0, class _A1>
2336template <class _Fp>
2337function<_Rp(_A0, _A1)>::function(_Fp __f,
2338 typename enable_if<!is_integral<_Fp>::value>::type*)
2339 : __f_(0)
2340{
2341 if (__function::__not_null(__f))
2342 {
2343 typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0, _A1)> _FF;
2344 if (sizeof(_FF) <= sizeof(__buf_))
2345 {
2346 __f_ = (__base*)&__buf_;
2347 ::new ((void*)__f_) _FF(__f);
2348 }
2349 else
2350 {
2351 typedef allocator<_FF> _Ap;
2352 _Ap __a;
2353 typedef __allocator_destructor<_Ap> _Dp;
2354 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
2355 ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a));
2356 __f_ = __hold.release();
2357 }
2358 }
2359}
2360
2361template<class _Rp, class _A0, class _A1>
2362template <class _Fp, class _Alloc>
2363function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
2364 typename enable_if<!is_integral<_Fp>::value>::type*)
2365 : __f_(0)
2366{
2367 typedef allocator_traits<_Alloc> __alloc_traits;
2368 if (__function::__not_null(__f))
2369 {
2370 typedef __function::__func<_Fp, _Alloc, _Rp(_A0, _A1)> _FF;
2371 if (sizeof(_FF) <= sizeof(__buf_))
2372 {
2373 __f_ = (__base*)&__buf_;
2374 ::new ((void*)__f_) _FF(__f, __a0);
2375 }
2376 else
2377 {
2378 typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
2379 _Ap __a(__a0);
2380 typedef __allocator_destructor<_Ap> _Dp;
2381 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
2382 ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a));
2383 __f_ = __hold.release();
2384 }
2385 }
2386}
2387
2388template<class _Rp, class _A0, class _A1>
2389function<_Rp(_A0, _A1)>&
2390function<_Rp(_A0, _A1)>::operator=(const function& __f)
2391{
2392 if (__f)
2393 function(__f).swap(*this);
2394 else
2395 *this = nullptr;
2396 return *this;
2397}
2398
2399template<class _Rp, class _A0, class _A1>
2400function<_Rp(_A0, _A1)>&
2401function<_Rp(_A0, _A1)>::operator=(nullptr_t)
2402{
2403 __base* __t = __f_;
2404 __f_ = 0;
2405 if (__t == (__base*)&__buf_)
2406 __t->destroy();
2407 else if (__t)
2408 __t->destroy_deallocate();
2409 return *this;
2410}
2411
2412template<class _Rp, class _A0, class _A1>
2413template <class _Fp>
2414typename enable_if
2415<
2416 !is_integral<_Fp>::value,
2417 function<_Rp(_A0, _A1)>&
2418>::type
2419function<_Rp(_A0, _A1)>::operator=(_Fp __f)
2420{
2421 function(_VSTD::move(__f)).swap(*this);
2422 return *this;
2423}
2424
2425template<class _Rp, class _A0, class _A1>
2426function<_Rp(_A0, _A1)>::~function()
2427{
2428 if (__f_ == (__base*)&__buf_)
2429 __f_->destroy();
2430 else if (__f_)
2431 __f_->destroy_deallocate();
2432}
2433
2434template<class _Rp, class _A0, class _A1>
2435void
2436function<_Rp(_A0, _A1)>::swap(function& __f)
2437{
2438 if (_VSTD::addressof(__f) == this)
2439 return;
2440 if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
2441 {
2442 typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
2443 __base* __t = (__base*)&__tempbuf;
2444 __f_->__clone(__t);
2445 __f_->destroy();
2446 __f_ = 0;
2447 __f.__f_->__clone((__base*)&__buf_);
2448 __f.__f_->destroy();
2449 __f.__f_ = 0;
2450 __f_ = (__base*)&__buf_;
2451 __t->__clone((__base*)&__f.__buf_);
2452 __t->destroy();
2453 __f.__f_ = (__base*)&__f.__buf_;
2454 }
2455 else if (__f_ == (__base*)&__buf_)
2456 {
2457 __f_->__clone((__base*)&__f.__buf_);
2458 __f_->destroy();
2459 __f_ = __f.__f_;
2460 __f.__f_ = (__base*)&__f.__buf_;
2461 }
2462 else if (__f.__f_ == (__base*)&__f.__buf_)
2463 {
2464 __f.__f_->__clone((__base*)&__buf_);
2465 __f.__f_->destroy();
2466 __f.__f_ = __f_;
2467 __f_ = (__base*)&__buf_;
2468 }
2469 else
2470 _VSTD::swap(__f_, __f.__f_);
2471}
2472
2473template<class _Rp, class _A0, class _A1>
2474_Rp
2475function<_Rp(_A0, _A1)>::operator()(_A0 __a0, _A1 __a1) const
2476{
2477 if (__f_ == 0)
2478 __throw_bad_function_call();
2479 return (*__f_)(__a0, __a1);
2480}
2481
2482#ifndef _LIBCPP_NO_RTTI
2483
2484template<class _Rp, class _A0, class _A1>
2485const std::type_info&
2486function<_Rp(_A0, _A1)>::target_type() const
2487{
2488 if (__f_ == 0)
2489 return typeid(void);
2490 return __f_->target_type();
2491}
2492
2493template<class _Rp, class _A0, class _A1>
2494template <typename _Tp>
2495_Tp*
2496function<_Rp(_A0, _A1)>::target()
2497{
2498 if (__f_ == 0)
2499 return (_Tp*)0;
2500 return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
2501}
2502
2503template<class _Rp, class _A0, class _A1>
2504template <typename _Tp>
2505const _Tp*
2506function<_Rp(_A0, _A1)>::target() const
2507{
2508 if (__f_ == 0)
2509 return (const _Tp*)0;
2510 return (const _Tp*)__f_->target(typeid(_Tp));
2511}
2512
2513#endif // _LIBCPP_NO_RTTI
2514
2515template<class _Rp, class _A0, class _A1, class _A2>
2516class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0, _A1, _A2)>
2517{
2518 typedef __function::__base<_Rp(_A0, _A1, _A2)> __base;
2519 aligned_storage<3*sizeof(void*)>::type __buf_;
2520 __base* __f_;
2521
2522public:
2523 typedef _Rp result_type;
2524
2525 // 20.7.16.2.1, construct/copy/destroy:
2526 _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {}
2527 _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {}
2528 function(const function&);
2529 template<class _Fp>
2530 function(_Fp,
2531 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
2532
2533 template<class _Alloc>
2534 _LIBCPP_INLINE_VISIBILITY
2535 function(allocator_arg_t, const _Alloc&) : __f_(0) {}
2536 template<class _Alloc>
2537 _LIBCPP_INLINE_VISIBILITY
2538 function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {}
2539 template<class _Alloc>
2540 function(allocator_arg_t, const _Alloc&, const function&);
2541 template<class _Fp, class _Alloc>
2542 function(allocator_arg_t, const _Alloc& __a, _Fp __f,
2543 typename enable_if<!is_integral<_Fp>::value>::type* = 0);
2544
2545 function& operator=(const function&);
2546 function& operator=(nullptr_t);
2547 template<class _Fp>
2548 typename enable_if
2549 <
2550 !is_integral<_Fp>::value,
2551 function&
2552 >::type
2553 operator=(_Fp);
2554
2555 ~function();
2556
2557 // 20.7.16.2.2, function modifiers:
2558 void swap(function&);
2559 template<class _Fp, class _Alloc>
2560 _LIBCPP_INLINE_VISIBILITY
2561 void assign(_Fp __f, const _Alloc& __a)
2562 {function(allocator_arg, __a, __f).swap(*this);}
2563
2564 // 20.7.16.2.3, function capacity:
2565 _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;}
2566
2567 template<class _R2, class _B0, class _B1, class _B2>
2568 bool operator==(const function<_R2(_B0, _B1, _B2)>&) const = delete;
2569 template<class _R2, class _B0, class _B1, class _B2>
2570 bool operator!=(const function<_R2(_B0, _B1, _B2)>&) const = delete;
2571
2572 // 20.7.16.2.4, function invocation:
2573 _Rp operator()(_A0, _A1, _A2) const;
2574
2575#ifndef _LIBCPP_NO_RTTI
2576 // 20.7.16.2.5, function target access:
2577 const std::type_info& target_type() const;
2578 template <typename _Tp> _Tp* target();
2579 template <typename _Tp> const _Tp* target() const;
2580#endif // _LIBCPP_NO_RTTI
2581};
2582
2583template<class _Rp, class _A0, class _A1, class _A2>
2584function<_Rp(_A0, _A1, _A2)>::function(const function& __f)
2585{
2586 if (__f.__f_ == 0)
2587 __f_ = 0;
2588 else if (__f.__f_ == (const __base*)&__f.__buf_)
2589 {
2590 __f_ = (__base*)&__buf_;
2591 __f.__f_->__clone(__f_);
2592 }
2593 else
2594 __f_ = __f.__f_->__clone();
2595}
2596
2597template<class _Rp, class _A0, class _A1, class _A2>
2598template<class _Alloc>
2599function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc&,
2600 const function& __f)
2601{
2602 if (__f.__f_ == 0)
2603 __f_ = 0;
2604 else if (__f.__f_ == (const __base*)&__f.__buf_)
2605 {
2606 __f_ = (__base*)&__buf_;
2607 __f.__f_->__clone(__f_);
2608 }
2609 else
2610 __f_ = __f.__f_->__clone();
2611}
2612
2613template<class _Rp, class _A0, class _A1, class _A2>
2614template <class _Fp>
2615function<_Rp(_A0, _A1, _A2)>::function(_Fp __f,
2616 typename enable_if<!is_integral<_Fp>::value>::type*)
2617 : __f_(0)
2618{
2619 if (__function::__not_null(__f))
2620 {
2621 typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0, _A1, _A2)> _FF;
2622 if (sizeof(_FF) <= sizeof(__buf_))
2623 {
2624 __f_ = (__base*)&__buf_;
2625 ::new ((void*)__f_) _FF(__f);
2626 }
2627 else
2628 {
2629 typedef allocator<_FF> _Ap;
2630 _Ap __a;
2631 typedef __allocator_destructor<_Ap> _Dp;
2632 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
2633 ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a));
2634 __f_ = __hold.release();
2635 }
2636 }
2637}
2638
2639template<class _Rp, class _A0, class _A1, class _A2>
2640template <class _Fp, class _Alloc>
2641function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
2642 typename enable_if<!is_integral<_Fp>::value>::type*)
2643 : __f_(0)
2644{
2645 typedef allocator_traits<_Alloc> __alloc_traits;
2646 if (__function::__not_null(__f))
2647 {
2648 typedef __function::__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)> _FF;
2649 if (sizeof(_FF) <= sizeof(__buf_))
2650 {
2651 __f_ = (__base*)&__buf_;
2652 ::new ((void*)__f_) _FF(__f, __a0);
2653 }
2654 else
2655 {
2656 typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
2657 _Ap __a(__a0);
2658 typedef __allocator_destructor<_Ap> _Dp;
2659 unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
2660 ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a));
2661 __f_ = __hold.release();
2662 }
2663 }
2664}
2665
2666template<class _Rp, class _A0, class _A1, class _A2>
2667function<_Rp(_A0, _A1, _A2)>&
2668function<_Rp(_A0, _A1, _A2)>::operator=(const function& __f)
2669{
2670 if (__f)
2671 function(__f).swap(*this);
2672 else
2673 *this = nullptr;
2674 return *this;
2675}
2676
2677template<class _Rp, class _A0, class _A1, class _A2>
2678function<_Rp(_A0, _A1, _A2)>&
2679function<_Rp(_A0, _A1, _A2)>::operator=(nullptr_t)
2680{
2681 __base* __t = __f_;
2682 __f_ = 0;
2683 if (__t == (__base*)&__buf_)
2684 __t->destroy();
2685 else if (__t)
2686 __t->destroy_deallocate();
2687 return *this;
2688}
2689
2690template<class _Rp, class _A0, class _A1, class _A2>
2691template <class _Fp>
2692typename enable_if
2693<
2694 !is_integral<_Fp>::value,
2695 function<_Rp(_A0, _A1, _A2)>&
2696>::type
2697function<_Rp(_A0, _A1, _A2)>::operator=(_Fp __f)
2698{
2699 function(_VSTD::move(__f)).swap(*this);
2700 return *this;
2701}
2702
2703template<class _Rp, class _A0, class _A1, class _A2>
2704function<_Rp(_A0, _A1, _A2)>::~function()
2705{
2706 if (__f_ == (__base*)&__buf_)
2707 __f_->destroy();
2708 else if (__f_)
2709 __f_->destroy_deallocate();
2710}
2711
2712template<class _Rp, class _A0, class _A1, class _A2>
2713void
2714function<_Rp(_A0, _A1, _A2)>::swap(function& __f)
2715{
2716 if (_VSTD::addressof(__f) == this)
2717 return;
2718 if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
2719 {
2720 typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
2721 __base* __t = (__base*)&__tempbuf;
2722 __f_->__clone(__t);
2723 __f_->destroy();
2724 __f_ = 0;
2725 __f.__f_->__clone((__base*)&__buf_);
2726 __f.__f_->destroy();
2727 __f.__f_ = 0;
2728 __f_ = (__base*)&__buf_;
2729 __t->__clone((__base*)&__f.__buf_);
2730 __t->destroy();
2731 __f.__f_ = (__base*)&__f.__buf_;
2732 }
2733 else if (__f_ == (__base*)&__buf_)
2734 {
2735 __f_->__clone((__base*)&__f.__buf_);
2736 __f_->destroy();
2737 __f_ = __f.__f_;
2738 __f.__f_ = (__base*)&__f.__buf_;
2739 }
2740 else if (__f.__f_ == (__base*)&__f.__buf_)
2741 {
2742 __f.__f_->__clone((__base*)&__buf_);
2743 __f.__f_->destroy();
2744 __f.__f_ = __f_;
2745 __f_ = (__base*)&__buf_;
2746 }
2747 else
2748 _VSTD::swap(__f_, __f.__f_);
2749}
2750
2751template<class _Rp, class _A0, class _A1, class _A2>
2752_Rp
2753function<_Rp(_A0, _A1, _A2)>::operator()(_A0 __a0, _A1 __a1, _A2 __a2) const
2754{
2755 if (__f_ == 0)
2756 __throw_bad_function_call();
2757 return (*__f_)(__a0, __a1, __a2);
2758}
2759
2760#ifndef _LIBCPP_NO_RTTI
2761
2762template<class _Rp, class _A0, class _A1, class _A2>
2763const std::type_info&
2764function<_Rp(_A0, _A1, _A2)>::target_type() const
2765{
2766 if (__f_ == 0)
2767 return typeid(void);
2768 return __f_->target_type();
2769}
2770
2771template<class _Rp, class _A0, class _A1, class _A2>
2772template <typename _Tp>
2773_Tp*
2774function<_Rp(_A0, _A1, _A2)>::target()
2775{
2776 if (__f_ == 0)
2777 return (_Tp*)0;
2778 return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
2779}
2780
2781template<class _Rp, class _A0, class _A1, class _A2>
2782template <typename _Tp>
2783const _Tp*
2784function<_Rp(_A0, _A1, _A2)>::target() const
2785{
2786 if (__f_ == 0)
2787 return (const _Tp*)0;
2788 return (const _Tp*)__f_->target(typeid(_Tp));
2789}
2790
2791#endif // _LIBCPP_NO_RTTI
2792
2793template <class _Fp>
2794inline _LIBCPP_INLINE_VISIBILITY
2795bool
2796operator==(const function<_Fp>& __f, nullptr_t) {return !__f;}
2797
2798template <class _Fp>
2799inline _LIBCPP_INLINE_VISIBILITY
2800bool
2801operator==(nullptr_t, const function<_Fp>& __f) {return !__f;}
2802
2803template <class _Fp>
2804inline _LIBCPP_INLINE_VISIBILITY
2805bool
2806operator!=(const function<_Fp>& __f, nullptr_t) {return (bool)__f;}
2807
2808template <class _Fp>
2809inline _LIBCPP_INLINE_VISIBILITY
2810bool
2811operator!=(nullptr_t, const function<_Fp>& __f) {return (bool)__f;}
2812
2813template <class _Fp>
2814inline _LIBCPP_INLINE_VISIBILITY
2815void
2816swap(function<_Fp>& __x, function<_Fp>& __y)
2817{return __x.swap(__y);}
1212_LIBCPP_END_NAMESPACE_STD
28181213
28191214#endif // _LIBCPP_CXX03_LANG
28201215
2821_LIBCPP_END_NAMESPACE_STD
2822
28231216#endif // _LIBCPP___FUNCTIONAL_FUNCTION_H
lib/libcxx/include/__functional/hash.h+41-35
......@@ -10,8 +10,15 @@
1010#define _LIBCPP___FUNCTIONAL_HASH_H
1111
1212#include <__config>
13#include <__functional/invoke.h>
1314#include <__functional/unary_function.h>
14#include <__tuple>
15#include <__fwd/hash.h>
16#include <__tuple_dir/sfinae_helpers.h>
17#include <__type_traits/is_copy_constructible.h>
18#include <__type_traits/is_default_constructible.h>
19#include <__type_traits/is_enum.h>
20#include <__type_traits/is_move_constructible.h>
21#include <__type_traits/underlying_type.h>
1522#include <__utility/forward.h>
1623#include <__utility/move.h>
1724#include <__utility/pair.h>
......@@ -20,7 +27,6 @@
2027#include <cstdint>
2128#include <cstring>
2229#include <limits>
23#include <type_traits>
2430
2531#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2632# pragma GCC system_header
......@@ -62,7 +68,7 @@ __murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len)
6268 const unsigned char* __data = static_cast<const unsigned char*>(__key);
6369 for (; __len >= 4; __data += 4, __len -= 4)
6470 {
65 _Size __k = __loadword<_Size>(__data);
71 _Size __k = std::__loadword<_Size>(__data);
6672 __k *= __m;
6773 __k ^= __k >> __r;
6874 __k *= __m;
......@@ -127,14 +133,14 @@ struct __murmur2_or_cityhash<_Size, 64>
127133 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
128134 {
129135 if (__len > 8) {
130 const _Size __a = __loadword<_Size>(__s);
131 const _Size __b = __loadword<_Size>(__s + __len - 8);
136 const _Size __a = std::__loadword<_Size>(__s);
137 const _Size __b = std::__loadword<_Size>(__s + __len - 8);
132138 return __hash_len_16(__a, __rotate_by_at_least_1(__b + __len, __len)) ^ __b;
133139 }
134140 if (__len >= 4) {
135 const uint32_t __a = __loadword<uint32_t>(__s);
136 const uint32_t __b = __loadword<uint32_t>(__s + __len - 4);
137 return __hash_len_16(__len + (__a << 3), __b);
141 const uint32_t __a = std::__loadword<uint32_t>(__s);
142 const uint32_t __b = std::__loadword<uint32_t>(__s + __len - 4);
143 return __hash_len_16(__len + (static_cast<_Size>(__a) << 3), __b);
138144 }
139145 if (__len > 0) {
140146 const unsigned char __a = static_cast<unsigned char>(__s[0]);
......@@ -151,10 +157,10 @@ struct __murmur2_or_cityhash<_Size, 64>
151157 static _Size __hash_len_17_to_32(const char *__s, _Size __len)
152158 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
153159 {
154 const _Size __a = __loadword<_Size>(__s) * __k1;
155 const _Size __b = __loadword<_Size>(__s + 8);
156 const _Size __c = __loadword<_Size>(__s + __len - 8) * __k2;
157 const _Size __d = __loadword<_Size>(__s + __len - 16) * __k0;
160 const _Size __a = std::__loadword<_Size>(__s) * __k1;
161 const _Size __b = std::__loadword<_Size>(__s + 8);
162 const _Size __c = std::__loadword<_Size>(__s + __len - 8) * __k2;
163 const _Size __d = std::__loadword<_Size>(__s + __len - 16) * __k0;
158164 return __hash_len_16(__rotate(__a - __b, 43) + __rotate(__c, 30) + __d,
159165 __a + __rotate(__b ^ __k3, 20) - __c + __len);
160166 }
......@@ -179,10 +185,10 @@ struct __murmur2_or_cityhash<_Size, 64>
179185 const char* __s, _Size __a, _Size __b)
180186 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
181187 {
182 return __weak_hash_len_32_with_seeds(__loadword<_Size>(__s),
183 __loadword<_Size>(__s + 8),
184 __loadword<_Size>(__s + 16),
185 __loadword<_Size>(__s + 24),
188 return __weak_hash_len_32_with_seeds(std::__loadword<_Size>(__s),
189 std::__loadword<_Size>(__s + 8),
190 std::__loadword<_Size>(__s + 16),
191 std::__loadword<_Size>(__s + 24),
186192 __a,
187193 __b);
188194 }
......@@ -191,23 +197,23 @@ struct __murmur2_or_cityhash<_Size, 64>
191197 static _Size __hash_len_33_to_64(const char *__s, size_t __len)
192198 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
193199 {
194 _Size __z = __loadword<_Size>(__s + 24);
195 _Size __a = __loadword<_Size>(__s) +
196 (__len + __loadword<_Size>(__s + __len - 16)) * __k0;
200 _Size __z = std::__loadword<_Size>(__s + 24);
201 _Size __a = std::__loadword<_Size>(__s) +
202 (__len + std::__loadword<_Size>(__s + __len - 16)) * __k0;
197203 _Size __b = __rotate(__a + __z, 52);
198204 _Size __c = __rotate(__a, 37);
199 __a += __loadword<_Size>(__s + 8);
205 __a += std::__loadword<_Size>(__s + 8);
200206 __c += __rotate(__a, 7);
201 __a += __loadword<_Size>(__s + 16);
207 __a += std::__loadword<_Size>(__s + 16);
202208 _Size __vf = __a + __z;
203209 _Size __vs = __b + __rotate(__a, 31) + __c;
204 __a = __loadword<_Size>(__s + 16) + __loadword<_Size>(__s + __len - 32);
205 __z += __loadword<_Size>(__s + __len - 8);
210 __a = std::__loadword<_Size>(__s + 16) + std::__loadword<_Size>(__s + __len - 32);
211 __z += std::__loadword<_Size>(__s + __len - 8);
206212 __b = __rotate(__a + __z, 52);
207213 __c = __rotate(__a, 37);
208 __a += __loadword<_Size>(__s + __len - 24);
214 __a += std::__loadword<_Size>(__s + __len - 24);
209215 __c += __rotate(__a, 7);
210 __a += __loadword<_Size>(__s + __len - 16);
216 __a += std::__loadword<_Size>(__s + __len - 16);
211217 _Size __wf = __a + __z;
212218 _Size __ws = __b + __rotate(__a, 31) + __c;
213219 _Size __r = __shift_mix((__vf + __ws) * __k2 + (__wf + __vs) * __k0);
......@@ -233,26 +239,26 @@ __murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len)
233239
234240 // For strings over 64 bytes we hash the end first, and then as we
235241 // loop we keep 56 bytes of state: v, w, x, y, and z.
236 _Size __x = __loadword<_Size>(__s + __len - 40);
237 _Size __y = __loadword<_Size>(__s + __len - 16) +
238 __loadword<_Size>(__s + __len - 56);
239 _Size __z = __hash_len_16(__loadword<_Size>(__s + __len - 48) + __len,
240 __loadword<_Size>(__s + __len - 24));
242 _Size __x = std::__loadword<_Size>(__s + __len - 40);
243 _Size __y = std::__loadword<_Size>(__s + __len - 16) +
244 std::__loadword<_Size>(__s + __len - 56);
245 _Size __z = __hash_len_16(std::__loadword<_Size>(__s + __len - 48) + __len,
246 std::__loadword<_Size>(__s + __len - 24));
241247 pair<_Size, _Size> __v = __weak_hash_len_32_with_seeds(__s + __len - 64, __len, __z);
242248 pair<_Size, _Size> __w = __weak_hash_len_32_with_seeds(__s + __len - 32, __y + __k1, __x);
243 __x = __x * __k1 + __loadword<_Size>(__s);
249 __x = __x * __k1 + std::__loadword<_Size>(__s);
244250
245251 // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks.
246252 __len = (__len - 1) & ~static_cast<_Size>(63);
247253 do {
248 __x = __rotate(__x + __y + __v.first + __loadword<_Size>(__s + 8), 37) * __k1;
249 __y = __rotate(__y + __v.second + __loadword<_Size>(__s + 48), 42) * __k1;
254 __x = __rotate(__x + __y + __v.first + std::__loadword<_Size>(__s + 8), 37) * __k1;
255 __y = __rotate(__y + __v.second + std::__loadword<_Size>(__s + 48), 42) * __k1;
250256 __x ^= __w.second;
251 __y += __v.first + __loadword<_Size>(__s + 40);
257 __y += __v.first + std::__loadword<_Size>(__s + 40);
252258 __z = __rotate(__z + __w.first, 33) * __k1;
253259 __v = __weak_hash_len_32_with_seeds(__s, __v.second * __k1, __x + __w.first);
254260 __w = __weak_hash_len_32_with_seeds(__s + 32, __z + __w.second,
255 __y + __loadword<_Size>(__s + 16));
261 __y + std::__loadword<_Size>(__s + 16));
256262 _VSTD::swap(__z, __x);
257263 __s += 64;
258264 __len -= 64;
lib/libcxx/include/__functional/invoke.h+16-8
......@@ -248,7 +248,7 @@ struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
248248
249249template <class _MP>
250250struct __member_pointer_traits
251 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
251 : public __member_pointer_traits_imp<__remove_cv_t<_MP>,
252252 is_member_function_pointer<_MP>::value,
253253 is_member_object_pointer<_MP>::value>
254254{
......@@ -398,7 +398,7 @@ template <class _Ret, class _Fp, class ..._Args>
398398struct __invokable_r
399399{
400400 template <class _XFp, class ..._XArgs>
401 static decltype(std::__invoke(declval<_XFp>(), declval<_XArgs>()...)) __try_call(int);
401 static decltype(std::__invoke(std::declval<_XFp>(), std::declval<_XArgs>()...)) __try_call(int);
402402 template <class _XFp, class ..._XArgs>
403403 static __nat __try_call(...);
404404
......@@ -406,10 +406,10 @@ struct __invokable_r
406406 // or incomplete array types as required by the standard.
407407 using _Result = decltype(__try_call<_Fp, _Args...>(0));
408408
409 using type = typename conditional<
409 using type = __conditional_t<
410410 _IsNotSame<_Result, __nat>::value,
411 typename conditional< is_void<_Ret>::value, true_type, __is_core_convertible<_Result, _Ret> >::type,
412 false_type >::type;
411 __conditional_t<is_void<_Ret>::value, true_type, __is_core_convertible<_Result, _Ret> >,
412 false_type>;
413413 static const bool value = type::value;
414414};
415415template <class _Fp, class ..._Args>
......@@ -428,15 +428,23 @@ struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
428428 template <class _Tp>
429429 static void __test_noexcept(_Tp) _NOEXCEPT;
430430
431#ifdef _LIBCPP_CXX03_LANG
432 static const bool value = false;
433#else
431434 static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
432 _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...)));
435 _VSTD::__invoke(std::declval<_Fp>(), std::declval<_Args>()...)));
436#endif
433437};
434438
435439template <class _Ret, class _Fp, class ..._Args>
436440struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
437441{
442#ifdef _LIBCPP_CXX03_LANG
443 static const bool value = false;
444#else
438445 static const bool value = noexcept(
439 _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...));
446 _VSTD::__invoke(std::declval<_Fp>(), std::declval<_Args>()...));
447#endif
440448};
441449
442450template <class _Ret, class _Fp, class ..._Args>
......@@ -524,7 +532,7 @@ template <class _Fn, class... _Args>
524532using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
525533
526534template <class _Fn, class ..._Args>
527_LIBCPP_CONSTEXPR_AFTER_CXX17 invoke_result_t<_Fn, _Args...>
535_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 invoke_result_t<_Fn, _Args...>
528536invoke(_Fn&& __f, _Args&&... __args)
529537 noexcept(is_nothrow_invocable_v<_Fn, _Args...>)
530538{
lib/libcxx/include/__functional/is_transparent.h+1-2
......@@ -25,8 +25,7 @@ template <class _Tp, class, class = void>
2525struct __is_transparent : false_type {};
2626
2727template <class _Tp, class _Up>
28struct __is_transparent<_Tp, _Up,
29 typename __void_t<typename _Tp::is_transparent>::type>
28struct __is_transparent<_Tp, _Up, __void_t<typename _Tp::is_transparent> >
3029 : true_type {};
3130
3231#endif
lib/libcxx/include/__functional/mem_fn.h+3-3
......@@ -33,12 +33,12 @@ private:
3333 type __f_;
3434
3535public:
36 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
36 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
3737 __mem_fn(type __f) _NOEXCEPT : __f_(__f) {}
3838
3939 // invoke
4040 template <class... _ArgTypes>
41 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
41 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
4242
4343 typename __invoke_return<type, _ArgTypes...>::type
4444 operator() (_ArgTypes&&... __args) const {
......@@ -47,7 +47,7 @@ public:
4747};
4848
4949template<class _Rp, class _Tp>
50inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
50inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
5151__mem_fn<_Rp _Tp::*>
5252mem_fn(_Rp _Tp::* __pm) _NOEXCEPT
5353{
lib/libcxx/include/__functional/not_fn.h+2-2
......@@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2727struct __not_fn_op {
2828 template <class... _Args>
2929 _LIBCPP_HIDE_FROM_ABI
30 _LIBCPP_CONSTEXPR_AFTER_CXX17 auto operator()(_Args&&... __args) const
30 _LIBCPP_CONSTEXPR_SINCE_CXX20 auto operator()(_Args&&... __args) const
3131 noexcept(noexcept(!_VSTD::invoke(_VSTD::forward<_Args>(__args)...)))
3232 -> decltype( !_VSTD::invoke(_VSTD::forward<_Args>(__args)...))
3333 { return !_VSTD::invoke(_VSTD::forward<_Args>(__args)...); }
......@@ -43,7 +43,7 @@ template <class _Fn, class = enable_if_t<
4343 is_move_constructible_v<decay_t<_Fn>>
4444>>
4545_LIBCPP_HIDE_FROM_ABI
46_LIBCPP_CONSTEXPR_AFTER_CXX17 auto not_fn(_Fn&& __f) {
46_LIBCPP_CONSTEXPR_SINCE_CXX20 auto not_fn(_Fn&& __f) {
4747 return __not_fn_t<decay_t<_Fn>>(_VSTD::forward<_Fn>(__f));
4848}
4949
lib/libcxx/include/__functional/operations.h+57-38
......@@ -32,17 +32,18 @@ struct _LIBCPP_TEMPLATE_VIS plus
3232 : __binary_function<_Tp, _Tp, _Tp>
3333{
3434 typedef _Tp __result_type; // used by valarray
35 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
35 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
3636 _Tp operator()(const _Tp& __x, const _Tp& __y) const
3737 {return __x + __y;}
3838};
39_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(plus);
3940
4041#if _LIBCPP_STD_VER > 11
4142template <>
4243struct _LIBCPP_TEMPLATE_VIS plus<void>
4344{
4445 template <class _T1, class _T2>
45 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
46 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
4647 auto operator()(_T1&& __t, _T2&& __u) const
4748 noexcept(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
4849 -> decltype( _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
......@@ -60,17 +61,18 @@ struct _LIBCPP_TEMPLATE_VIS minus
6061 : __binary_function<_Tp, _Tp, _Tp>
6162{
6263 typedef _Tp __result_type; // used by valarray
63 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
64 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
6465 _Tp operator()(const _Tp& __x, const _Tp& __y) const
6566 {return __x - __y;}
6667};
68_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(minus);
6769
6870#if _LIBCPP_STD_VER > 11
6971template <>
7072struct _LIBCPP_TEMPLATE_VIS minus<void>
7173{
7274 template <class _T1, class _T2>
73 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
75 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
7476 auto operator()(_T1&& __t, _T2&& __u) const
7577 noexcept(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)))
7678 -> decltype( _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))
......@@ -88,17 +90,18 @@ struct _LIBCPP_TEMPLATE_VIS multiplies
8890 : __binary_function<_Tp, _Tp, _Tp>
8991{
9092 typedef _Tp __result_type; // used by valarray
91 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
93 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
9294 _Tp operator()(const _Tp& __x, const _Tp& __y) const
9395 {return __x * __y;}
9496};
97_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(multiplies);
9598
9699#if _LIBCPP_STD_VER > 11
97100template <>
98101struct _LIBCPP_TEMPLATE_VIS multiplies<void>
99102{
100103 template <class _T1, class _T2>
101 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
104 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
102105 auto operator()(_T1&& __t, _T2&& __u) const
103106 noexcept(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)))
104107 -> decltype( _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))
......@@ -116,17 +119,18 @@ struct _LIBCPP_TEMPLATE_VIS divides
116119 : __binary_function<_Tp, _Tp, _Tp>
117120{
118121 typedef _Tp __result_type; // used by valarray
119 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
122 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
120123 _Tp operator()(const _Tp& __x, const _Tp& __y) const
121124 {return __x / __y;}
122125};
126_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(divides);
123127
124128#if _LIBCPP_STD_VER > 11
125129template <>
126130struct _LIBCPP_TEMPLATE_VIS divides<void>
127131{
128132 template <class _T1, class _T2>
129 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
133 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
130134 auto operator()(_T1&& __t, _T2&& __u) const
131135 noexcept(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)))
132136 -> decltype( _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))
......@@ -144,17 +148,18 @@ struct _LIBCPP_TEMPLATE_VIS modulus
144148 : __binary_function<_Tp, _Tp, _Tp>
145149{
146150 typedef _Tp __result_type; // used by valarray
147 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
151 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
148152 _Tp operator()(const _Tp& __x, const _Tp& __y) const
149153 {return __x % __y;}
150154};
155_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(modulus);
151156
152157#if _LIBCPP_STD_VER > 11
153158template <>
154159struct _LIBCPP_TEMPLATE_VIS modulus<void>
155160{
156161 template <class _T1, class _T2>
157 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
162 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
158163 auto operator()(_T1&& __t, _T2&& __u) const
159164 noexcept(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)))
160165 -> decltype( _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))
......@@ -172,17 +177,18 @@ struct _LIBCPP_TEMPLATE_VIS negate
172177 : __unary_function<_Tp, _Tp>
173178{
174179 typedef _Tp __result_type; // used by valarray
175 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
180 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
176181 _Tp operator()(const _Tp& __x) const
177182 {return -__x;}
178183};
184_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(negate);
179185
180186#if _LIBCPP_STD_VER > 11
181187template <>
182188struct _LIBCPP_TEMPLATE_VIS negate<void>
183189{
184190 template <class _Tp>
185 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
191 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
186192 auto operator()(_Tp&& __x) const
187193 noexcept(noexcept(- _VSTD::forward<_Tp>(__x)))
188194 -> decltype( - _VSTD::forward<_Tp>(__x))
......@@ -202,17 +208,18 @@ struct _LIBCPP_TEMPLATE_VIS bit_and
202208 : __binary_function<_Tp, _Tp, _Tp>
203209{
204210 typedef _Tp __result_type; // used by valarray
205 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
211 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
206212 _Tp operator()(const _Tp& __x, const _Tp& __y) const
207213 {return __x & __y;}
208214};
215_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_and);
209216
210217#if _LIBCPP_STD_VER > 11
211218template <>
212219struct _LIBCPP_TEMPLATE_VIS bit_and<void>
213220{
214221 template <class _T1, class _T2>
215 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
222 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
216223 auto operator()(_T1&& __t, _T2&& __u) const
217224 noexcept(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)))
218225 -> decltype( _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))
......@@ -226,16 +233,17 @@ template <class _Tp = void>
226233struct _LIBCPP_TEMPLATE_VIS bit_not
227234 : __unary_function<_Tp, _Tp>
228235{
229 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
236 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
230237 _Tp operator()(const _Tp& __x) const
231238 {return ~__x;}
232239};
240_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_not);
233241
234242template <>
235243struct _LIBCPP_TEMPLATE_VIS bit_not<void>
236244{
237245 template <class _Tp>
238 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
246 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
239247 auto operator()(_Tp&& __x) const
240248 noexcept(noexcept(~_VSTD::forward<_Tp>(__x)))
241249 -> decltype( ~_VSTD::forward<_Tp>(__x))
......@@ -253,17 +261,18 @@ struct _LIBCPP_TEMPLATE_VIS bit_or
253261 : __binary_function<_Tp, _Tp, _Tp>
254262{
255263 typedef _Tp __result_type; // used by valarray
256 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
264 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
257265 _Tp operator()(const _Tp& __x, const _Tp& __y) const
258266 {return __x | __y;}
259267};
268_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_or);
260269
261270#if _LIBCPP_STD_VER > 11
262271template <>
263272struct _LIBCPP_TEMPLATE_VIS bit_or<void>
264273{
265274 template <class _T1, class _T2>
266 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
275 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
267276 auto operator()(_T1&& __t, _T2&& __u) const
268277 noexcept(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)))
269278 -> decltype( _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))
......@@ -281,17 +290,18 @@ struct _LIBCPP_TEMPLATE_VIS bit_xor
281290 : __binary_function<_Tp, _Tp, _Tp>
282291{
283292 typedef _Tp __result_type; // used by valarray
284 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
293 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
285294 _Tp operator()(const _Tp& __x, const _Tp& __y) const
286295 {return __x ^ __y;}
287296};
297_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_xor);
288298
289299#if _LIBCPP_STD_VER > 11
290300template <>
291301struct _LIBCPP_TEMPLATE_VIS bit_xor<void>
292302{
293303 template <class _T1, class _T2>
294 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
304 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
295305 auto operator()(_T1&& __t, _T2&& __u) const
296306 noexcept(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)))
297307 -> decltype( _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))
......@@ -311,17 +321,18 @@ struct _LIBCPP_TEMPLATE_VIS equal_to
311321 : __binary_function<_Tp, _Tp, bool>
312322{
313323 typedef bool __result_type; // used by valarray
314 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
324 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
315325 bool operator()(const _Tp& __x, const _Tp& __y) const
316326 {return __x == __y;}
317327};
328_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(equal_to);
318329
319330#if _LIBCPP_STD_VER > 11
320331template <>
321332struct _LIBCPP_TEMPLATE_VIS equal_to<void>
322333{
323334 template <class _T1, class _T2>
324 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
335 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
325336 auto operator()(_T1&& __t, _T2&& __u) const
326337 noexcept(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)))
327338 -> decltype( _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))
......@@ -339,17 +350,18 @@ struct _LIBCPP_TEMPLATE_VIS not_equal_to
339350 : __binary_function<_Tp, _Tp, bool>
340351{
341352 typedef bool __result_type; // used by valarray
342 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
353 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
343354 bool operator()(const _Tp& __x, const _Tp& __y) const
344355 {return __x != __y;}
345356};
357_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(not_equal_to);
346358
347359#if _LIBCPP_STD_VER > 11
348360template <>
349361struct _LIBCPP_TEMPLATE_VIS not_equal_to<void>
350362{
351363 template <class _T1, class _T2>
352 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
364 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
353365 auto operator()(_T1&& __t, _T2&& __u) const
354366 noexcept(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)))
355367 -> decltype( _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))
......@@ -367,17 +379,18 @@ struct _LIBCPP_TEMPLATE_VIS less
367379 : __binary_function<_Tp, _Tp, bool>
368380{
369381 typedef bool __result_type; // used by valarray
370 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
382 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
371383 bool operator()(const _Tp& __x, const _Tp& __y) const
372384 {return __x < __y;}
373385};
386_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less);
374387
375388#if _LIBCPP_STD_VER > 11
376389template <>
377390struct _LIBCPP_TEMPLATE_VIS less<void>
378391{
379392 template <class _T1, class _T2>
380 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
393 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
381394 auto operator()(_T1&& __t, _T2&& __u) const
382395 noexcept(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)))
383396 -> decltype( _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))
......@@ -395,17 +408,18 @@ struct _LIBCPP_TEMPLATE_VIS less_equal
395408 : __binary_function<_Tp, _Tp, bool>
396409{
397410 typedef bool __result_type; // used by valarray
398 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
411 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
399412 bool operator()(const _Tp& __x, const _Tp& __y) const
400413 {return __x <= __y;}
401414};
415_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less_equal);
402416
403417#if _LIBCPP_STD_VER > 11
404418template <>
405419struct _LIBCPP_TEMPLATE_VIS less_equal<void>
406420{
407421 template <class _T1, class _T2>
408 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
422 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
409423 auto operator()(_T1&& __t, _T2&& __u) const
410424 noexcept(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)))
411425 -> decltype( _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))
......@@ -423,17 +437,18 @@ struct _LIBCPP_TEMPLATE_VIS greater_equal
423437 : __binary_function<_Tp, _Tp, bool>
424438{
425439 typedef bool __result_type; // used by valarray
426 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
440 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
427441 bool operator()(const _Tp& __x, const _Tp& __y) const
428442 {return __x >= __y;}
429443};
444_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater_equal);
430445
431446#if _LIBCPP_STD_VER > 11
432447template <>
433448struct _LIBCPP_TEMPLATE_VIS greater_equal<void>
434449{
435450 template <class _T1, class _T2>
436 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
451 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
437452 auto operator()(_T1&& __t, _T2&& __u) const
438453 noexcept(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)))
439454 -> decltype( _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))
......@@ -451,17 +466,18 @@ struct _LIBCPP_TEMPLATE_VIS greater
451466 : __binary_function<_Tp, _Tp, bool>
452467{
453468 typedef bool __result_type; // used by valarray
454 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
469 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
455470 bool operator()(const _Tp& __x, const _Tp& __y) const
456471 {return __x > __y;}
457472};
473_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater);
458474
459475#if _LIBCPP_STD_VER > 11
460476template <>
461477struct _LIBCPP_TEMPLATE_VIS greater<void>
462478{
463479 template <class _T1, class _T2>
464 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
480 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
465481 auto operator()(_T1&& __t, _T2&& __u) const
466482 noexcept(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)))
467483 -> decltype( _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))
......@@ -481,17 +497,18 @@ struct _LIBCPP_TEMPLATE_VIS logical_and
481497 : __binary_function<_Tp, _Tp, bool>
482498{
483499 typedef bool __result_type; // used by valarray
484 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
500 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
485501 bool operator()(const _Tp& __x, const _Tp& __y) const
486502 {return __x && __y;}
487503};
504_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_and);
488505
489506#if _LIBCPP_STD_VER > 11
490507template <>
491508struct _LIBCPP_TEMPLATE_VIS logical_and<void>
492509{
493510 template <class _T1, class _T2>
494 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
511 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
495512 auto operator()(_T1&& __t, _T2&& __u) const
496513 noexcept(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)))
497514 -> decltype( _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))
......@@ -509,17 +526,18 @@ struct _LIBCPP_TEMPLATE_VIS logical_not
509526 : __unary_function<_Tp, bool>
510527{
511528 typedef bool __result_type; // used by valarray
512 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
529 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
513530 bool operator()(const _Tp& __x) const
514531 {return !__x;}
515532};
533_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_not);
516534
517535#if _LIBCPP_STD_VER > 11
518536template <>
519537struct _LIBCPP_TEMPLATE_VIS logical_not<void>
520538{
521539 template <class _Tp>
522 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
540 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
523541 auto operator()(_Tp&& __x) const
524542 noexcept(noexcept(!_VSTD::forward<_Tp>(__x)))
525543 -> decltype( !_VSTD::forward<_Tp>(__x))
......@@ -537,17 +555,18 @@ struct _LIBCPP_TEMPLATE_VIS logical_or
537555 : __binary_function<_Tp, _Tp, bool>
538556{
539557 typedef bool __result_type; // used by valarray
540 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
558 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
541559 bool operator()(const _Tp& __x, const _Tp& __y) const
542560 {return __x || __y;}
543561};
562_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_or);
544563
545564#if _LIBCPP_STD_VER > 11
546565template <>
547566struct _LIBCPP_TEMPLATE_VIS logical_or<void>
548567{
549568 template <class _T1, class _T2>
550 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
569 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
551570 auto operator()(_T1&& __t, _T2&& __u) const
552571 noexcept(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)))
553572 -> decltype( _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))
lib/libcxx/include/__functional/ranges_operations.h+2-1
......@@ -10,9 +10,10 @@
1010#ifndef _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
1111#define _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
1212
13#include <__concepts/equality_comparable.h>
14#include <__concepts/totally_ordered.h>
1315#include <__config>
1416#include <__utility/forward.h>
15#include <concepts>
1617
1718#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1819# pragma GCC system_header
lib/libcxx/include/__functional/reference_wrapper.h+14-11
......@@ -11,10 +11,13 @@
1111#define _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H
1212
1313#include <__config>
14#include <__functional/invoke.h>
1415#include <__functional/weak_result_type.h>
1516#include <__memory/addressof.h>
17#include <__type_traits/enable_if.h>
18#include <__type_traits/remove_cvref.h>
19#include <__utility/declval.h>
1620#include <__utility/forward.h>
17#include <type_traits>
1821
1922#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2023# pragma GCC system_header
......@@ -35,22 +38,22 @@ private:
3538 static void __fun(_Tp&&) = delete;
3639
3740public:
38 template <class _Up, class = __enable_if_t<!__is_same_uncvref<_Up, reference_wrapper>::value, decltype(__fun(declval<_Up>())) > >
39 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
40 reference_wrapper(_Up&& __u) _NOEXCEPT_(noexcept(__fun(declval<_Up>()))) {
41 template <class _Up, class = __enable_if_t<!__is_same_uncvref<_Up, reference_wrapper>::value, decltype(__fun(std::declval<_Up>())) > >
42 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
43 reference_wrapper(_Up&& __u) _NOEXCEPT_(noexcept(__fun(std::declval<_Up>()))) {
4144 type& __f = static_cast<_Up&&>(__u);
4245 __f_ = _VSTD::addressof(__f);
4346 }
4447
4548 // access
46 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
49 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
4750 operator type&() const _NOEXCEPT {return *__f_;}
48 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
51 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
4952 type& get() const _NOEXCEPT {return *__f_;}
5053
5154 // invoke
5255 template <class... _ArgTypes>
53 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
56 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
5457 typename __invoke_of<type&, _ArgTypes...>::type
5558 operator() (_ArgTypes&&... __args) const {
5659 return std::__invoke(get(), std::forward<_ArgTypes>(__args)...);
......@@ -63,7 +66,7 @@ reference_wrapper(_Tp&) -> reference_wrapper<_Tp>;
6366#endif
6467
6568template <class _Tp>
66inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
69inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
6770reference_wrapper<_Tp>
6871ref(_Tp& __t) _NOEXCEPT
6972{
......@@ -71,7 +74,7 @@ ref(_Tp& __t) _NOEXCEPT
7174}
7275
7376template <class _Tp>
74inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
77inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
7578reference_wrapper<_Tp>
7679ref(reference_wrapper<_Tp> __t) _NOEXCEPT
7780{
......@@ -79,7 +82,7 @@ ref(reference_wrapper<_Tp> __t) _NOEXCEPT
7982}
8083
8184template <class _Tp>
82inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
85inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
8386reference_wrapper<const _Tp>
8487cref(const _Tp& __t) _NOEXCEPT
8588{
......@@ -87,7 +90,7 @@ cref(const _Tp& __t) _NOEXCEPT
8790}
8891
8992template <class _Tp>
90inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
93inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
9194reference_wrapper<const _Tp>
9295cref(reference_wrapper<_Tp> __t) _NOEXCEPT
9396{
lib/libcxx/include/__functional/unary_negate.h+3-3
......@@ -27,16 +27,16 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 unary_negate
2727{
2828 _Predicate __pred_;
2929public:
30 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
30 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
3131 explicit unary_negate(const _Predicate& __pred)
3232 : __pred_(__pred) {}
33 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
33 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
3434 bool operator()(const typename _Predicate::argument_type& __x) const
3535 {return !__pred_(__x);}
3636};
3737
3838template <class _Predicate>
39_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
39_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
4040unary_negate<_Predicate>
4141not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);}
4242
lib/libcxx/include/__functional/unwrap_ref.h+1
......@@ -10,6 +10,7 @@
1010#define _LIBCPP___FUNCTIONAL_UNWRAP_REF_H
1111
1212#include <__config>
13#include <__type_traits/decay.h>
1314
1415#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1516# pragma GCC system_header
lib/libcxx/include/__functional/weak_result_type.h+5-2
......@@ -12,8 +12,11 @@
1212
1313#include <__config>
1414#include <__functional/binary_function.h>
15#include <__functional/invoke.h>
1516#include <__functional/unary_function.h>
16#include <type_traits>
17#include <__type_traits/integral_constant.h>
18#include <__type_traits/is_same.h>
19#include <__utility/declval.h>
1720
1821#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1922# pragma GCC system_header
......@@ -283,7 +286,7 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>
283286template <class _Tp, class ..._Args>
284287struct __invoke_return
285288{
286 typedef decltype(_VSTD::__invoke(declval<_Tp>(), declval<_Args>()...)) type;
289 typedef decltype(_VSTD::__invoke(std::declval<_Tp>(), std::declval<_Args>()...)) type;
287290};
288291
289292_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__fwd/array.h created+26
......@@ -0,0 +1,26 @@
1//===---------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===---------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___FWD_ARRAY_H
10#define _LIBCPP___FWD_ARRAY_H
11
12#include <__config>
13#include <cstddef>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20
21template <class _Tp, size_t _Size>
22struct _LIBCPP_TEMPLATE_VIS array;
23
24_LIBCPP_END_NAMESPACE_STD
25
26#endif // _LIBCPP___FWD_ARRAY_H
lib/libcxx/include/__fwd/get.h created+115
......@@ -0,0 +1,115 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___FWD_GET_H
10#define _LIBCPP___FWD_GET_H
11
12#include <__concepts/copyable.h>
13#include <__config>
14#include <__fwd/array.h>
15#include <__fwd/pair.h>
16#include <__fwd/subrange.h>
17#include <__fwd/tuple.h>
18#include <__tuple_dir/tuple_element.h>
19#include <cstddef>
20
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header
23#endif
24
25_LIBCPP_BEGIN_NAMESPACE_STD
26
27#ifndef _LIBCPP_CXX03_LANG
28
29template <size_t _Ip, class ..._Tp>
30_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
31typename tuple_element<_Ip, tuple<_Tp...> >::type&
32get(tuple<_Tp...>&) _NOEXCEPT;
33
34template <size_t _Ip, class ..._Tp>
35_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
36const typename tuple_element<_Ip, tuple<_Tp...> >::type&
37get(const tuple<_Tp...>&) _NOEXCEPT;
38
39template <size_t _Ip, class ..._Tp>
40_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
41typename tuple_element<_Ip, tuple<_Tp...> >::type&&
42get(tuple<_Tp...>&&) _NOEXCEPT;
43
44template <size_t _Ip, class ..._Tp>
45_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
46const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
47get(const tuple<_Tp...>&&) _NOEXCEPT;
48
49#endif //_LIBCPP_CXX03_LANG
50
51template <size_t _Ip, class _T1, class _T2>
52_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
53typename tuple_element<_Ip, pair<_T1, _T2> >::type&
54get(pair<_T1, _T2>&) _NOEXCEPT;
55
56template <size_t _Ip, class _T1, class _T2>
57_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
58const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
59get(const pair<_T1, _T2>&) _NOEXCEPT;
60
61#ifndef _LIBCPP_CXX03_LANG
62template <size_t _Ip, class _T1, class _T2>
63_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
64typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
65get(pair<_T1, _T2>&&) _NOEXCEPT;
66
67template <size_t _Ip, class _T1, class _T2>
68_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
69const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
70get(const pair<_T1, _T2>&&) _NOEXCEPT;
71#endif
72
73template <size_t _Ip, class _Tp, size_t _Size>
74_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
75_Tp&
76get(array<_Tp, _Size>&) _NOEXCEPT;
77
78template <size_t _Ip, class _Tp, size_t _Size>
79_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
80const _Tp&
81get(const array<_Tp, _Size>&) _NOEXCEPT;
82
83#ifndef _LIBCPP_CXX03_LANG
84template <size_t _Ip, class _Tp, size_t _Size>
85_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
86_Tp&&
87get(array<_Tp, _Size>&&) _NOEXCEPT;
88
89template <size_t _Ip, class _Tp, size_t _Size>
90_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
91const _Tp&&
92get(const array<_Tp, _Size>&&) _NOEXCEPT;
93#endif
94
95#if _LIBCPP_STD_VER >= 20
96
97namespace ranges {
98
99template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind>
100 requires((_Index == 0 && copyable<_Iter>) || _Index == 1)
101_LIBCPP_HIDE_FROM_ABI constexpr auto get(const subrange<_Iter, _Sent, _Kind>& __subrange);
102
103template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind>
104 requires(_Index < 2)
105_LIBCPP_HIDE_FROM_ABI constexpr auto get(subrange<_Iter, _Sent, _Kind>&& __subrange);
106
107} // namespace ranges
108
109using ranges::get;
110
111#endif // _LIBCPP_STD_VER >= 20
112
113_LIBCPP_END_NAMESPACE_STD
114
115#endif // _LIBCPP___FWD_GET_H
lib/libcxx/include/__fwd/hash.h created+25
......@@ -0,0 +1,25 @@
1//===---------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===---------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___FWD_HASH_H
10#define _LIBCPP___FWD_HASH_H
11
12#include <__config>
13
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# pragma GCC system_header
16#endif
17
18_LIBCPP_BEGIN_NAMESPACE_STD
19
20template <class>
21struct _LIBCPP_TEMPLATE_VIS hash;
22
23_LIBCPP_END_NAMESPACE_STD
24
25#endif // _LIBCPP___FWD_HASH_H
lib/libcxx/include/__fwd/memory_resource.h created+27
......@@ -0,0 +1,27 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___FWD_MEMORY_RESOURCE_H
10#define _LIBCPP___FWD_MEMORY_RESOURCE_H
11
12#include <__config>
13
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# pragma GCC system_header
16#endif
17
18_LIBCPP_BEGIN_NAMESPACE_STD
19
20namespace pmr {
21template <class _ValueType>
22class _LIBCPP_TEMPLATE_VIS polymorphic_allocator;
23} // namespace pmr
24
25_LIBCPP_END_NAMESPACE_STD
26
27#endif // _LIBCPP___FWD_MEMORY_RESOURCE_H
lib/libcxx/include/__fwd/pair.h created+25
......@@ -0,0 +1,25 @@
1//===---------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===---------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___FWD_PAIR_H
10#define _LIBCPP___FWD_PAIR_H
11
12#include <__config>
13
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# pragma GCC system_header
16#endif
17
18_LIBCPP_BEGIN_NAMESPACE_STD
19
20template <class, class>
21struct _LIBCPP_TEMPLATE_VIS pair;
22
23_LIBCPP_END_NAMESPACE_STD
24
25#endif // _LIBCPP___FWD_PAIR_H
lib/libcxx/include/__fwd/span.h+3-3
......@@ -7,8 +7,8 @@
77//
88//===---------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_FWD_SPAN_H
11#define _LIBCPP_FWD_SPAN_H
10#ifndef _LIBCPP___FWD_SPAN_H
11#define _LIBCPP___FWD_SPAN_H
1212
1313#include <__config>
1414#include <cstddef>
......@@ -34,4 +34,4 @@ _LIBCPP_END_NAMESPACE_STD
3434
3535_LIBCPP_POP_MACROS
3636
37#endif // _LIBCPP_FWD_SPAN_H
37#endif // _LIBCPP___FWD_SPAN_H
lib/libcxx/include/__fwd/string.h created+110
......@@ -0,0 +1,110 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___FWD_STRING_H
10#define _LIBCPP___FWD_STRING_H
11
12#include <__config>
13#include <__fwd/memory_resource.h>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20
21template <class _CharT>
22struct _LIBCPP_TEMPLATE_VIS char_traits;
23template <>
24struct char_traits<char>;
25
26#ifndef _LIBCPP_HAS_NO_CHAR8_T
27template <>
28struct char_traits<char8_t>;
29#endif
30
31template <>
32struct char_traits<char16_t>;
33template <>
34struct char_traits<char32_t>;
35
36#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
37template <>
38struct char_traits<wchar_t>;
39#endif
40
41template <class _Tp>
42class _LIBCPP_TEMPLATE_VIS allocator;
43
44template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> >
45class _LIBCPP_TEMPLATE_VIS basic_string;
46
47using string = basic_string<char>;
48
49#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
50using wstring = basic_string<wchar_t>;
51#endif
52
53#ifndef _LIBCPP_HAS_NO_CHAR8_T
54using u8string = basic_string<char8_t>;
55#endif
56
57using u16string = basic_string<char16_t>;
58using u32string = basic_string<char32_t>;
59
60#if _LIBCPP_STD_VER >= 17
61
62namespace pmr {
63template <class _CharT, class _Traits = char_traits<_CharT>>
64using basic_string = std::basic_string<_CharT, _Traits, polymorphic_allocator<_CharT>>;
65
66using string = basic_string<char>;
67
68# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
69using wstring = basic_string<wchar_t>;
70# endif
71
72# ifndef _LIBCPP_HAS_NO_CHAR8_T
73using u8string = basic_string<char8_t>;
74# endif
75
76using u16string = basic_string<char16_t>;
77using u32string = basic_string<char32_t>;
78
79} // namespace pmr
80
81#endif // _LIBCPP_STD_VER >= 17
82
83// clang-format off
84template <class _CharT, class _Traits, class _Allocator>
85class _LIBCPP_PREFERRED_NAME(string)
86#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
87 _LIBCPP_PREFERRED_NAME(wstring)
88#endif
89#ifndef _LIBCPP_HAS_NO_CHAR8_T
90 _LIBCPP_PREFERRED_NAME(u8string)
91#endif
92 _LIBCPP_PREFERRED_NAME(u16string)
93 _LIBCPP_PREFERRED_NAME(u32string)
94#if _LIBCPP_STD_VER >= 17
95 _LIBCPP_PREFERRED_NAME(pmr::string)
96# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
97 _LIBCPP_PREFERRED_NAME(pmr::wstring)
98# endif
99# ifndef _LIBCPP_HAS_NO_CHAR8_T
100 _LIBCPP_PREFERRED_NAME(pmr::u8string)
101# endif
102 _LIBCPP_PREFERRED_NAME(pmr::u16string)
103 _LIBCPP_PREFERRED_NAME(pmr::u32string)
104#endif
105 basic_string;
106// clang-format on
107
108_LIBCPP_END_NAMESPACE_STD
109
110#endif // _LIBCPP___FWD_STRING_H
lib/libcxx/include/__fwd/string_view.h+16-3
......@@ -7,8 +7,8 @@
77//
88//===---------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_FWD_STRING_VIEW_H
11#define _LIBCPP_FWD_STRING_VIEW_H
10#ifndef _LIBCPP___FWD_STRING_VIEW_H
11#define _LIBCPP___FWD_STRING_VIEW_H
1212
1313#include <__config>
1414#include <iosfwd> // char_traits
......@@ -32,6 +32,19 @@ typedef basic_string_view<char32_t> u32string_view;
3232typedef basic_string_view<wchar_t> wstring_view;
3333#endif
3434
35// clang-format off
36template <class _CharT, class _Traits>
37class _LIBCPP_PREFERRED_NAME(string_view)
38#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
39 _LIBCPP_PREFERRED_NAME(wstring_view)
40#endif
41#ifndef _LIBCPP_HAS_NO_CHAR8_T
42 _LIBCPP_PREFERRED_NAME(u8string_view)
43#endif
44 _LIBCPP_PREFERRED_NAME(u16string_view)
45 _LIBCPP_PREFERRED_NAME(u32string_view)
46 basic_string_view;
47// clang-format on
3548_LIBCPP_END_NAMESPACE_STD
3649
37#endif // _LIBCPP_FWD_STRING_VIEW_H
50#endif // _LIBCPP___FWD_STRING_VIEW_H
lib/libcxx/include/__fwd/subrange.h created+38
......@@ -0,0 +1,38 @@
1//===---------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===---------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___FWD_SUBRANGE_H
10#define _LIBCPP___FWD_SUBRANGE_H
11
12#include <__config>
13
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# pragma GCC system_header
16#endif
17
18#if _LIBCPP_STD_VER >= 20
19
20#include <__iterator/concepts.h>
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24namespace ranges {
25
26enum class _LIBCPP_ENUM_VIS subrange_kind : bool { unsized, sized };
27
28template <input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent, subrange_kind _Kind>
29 requires(_Kind == subrange_kind::sized || !sized_sentinel_for<_Sent, _Iter>)
30class _LIBCPP_TEMPLATE_VIS subrange;
31
32} // namespace ranges
33
34_LIBCPP_END_NAMESPACE_STD
35
36#endif // _LIBCPP_STD_VER >= 20
37
38#endif // _LIBCPP___FWD_SUBRANGE_H
lib/libcxx/include/__fwd/tuple.h created+29
......@@ -0,0 +1,29 @@
1//===---------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===---------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___FWD_TUPLE_H
10#define _LIBCPP___FWD_TUPLE_H
11
12#include <__config>
13
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# pragma GCC system_header
16#endif
17
18_LIBCPP_BEGIN_NAMESPACE_STD
19
20#ifndef _LIBCPP_CXX03_LANG
21
22template <class...>
23class _LIBCPP_TEMPLATE_VIS tuple;
24
25#endif // _LIBCPP_CXX03_LANG
26
27_LIBCPP_END_NAMESPACE_STD
28
29#endif // _LIBCPP___FWD_TUPLE_H
lib/libcxx/include/__hash_table+76-71
......@@ -13,16 +13,25 @@
1313#include <__algorithm/max.h>
1414#include <__algorithm/min.h>
1515#include <__assert>
16#include <__bits> // __libcpp_clz
16#include <__bit/countl.h>
1717#include <__config>
1818#include <__debug>
1919#include <__functional/hash.h>
2020#include <__iterator/iterator_traits.h>
21#include <__memory/addressof.h>
22#include <__memory/allocator_traits.h>
23#include <__memory/compressed_pair.h>
24#include <__memory/pointer_traits.h>
2125#include <__memory/swap_allocator.h>
26#include <__memory/unique_ptr.h>
27#include <__type_traits/can_extract_key.h>
28#include <__utility/forward.h>
29#include <__utility/move.h>
30#include <__utility/pair.h>
2231#include <__utility/swap.h>
2332#include <cmath>
33#include <cstring>
2434#include <initializer_list>
25#include <memory>
2635#include <type_traits>
2736
2837#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -48,7 +57,7 @@ template <class ..._Args>
4857struct __is_hash_value_type : false_type {};
4958
5059template <class _One>
51struct __is_hash_value_type<_One> : __is_hash_value_type_imp<__uncvref_t<_One> > {};
60struct __is_hash_value_type<_One> : __is_hash_value_type_imp<__remove_cvref_t<_One> > {};
5261
5362_LIBCPP_FUNC_VIS
5463size_t __next_prime(size_t __n);
......@@ -58,16 +67,13 @@ struct __hash_node_base
5867{
5968 typedef typename pointer_traits<_NodePtr>::element_type __node_type;
6069 typedef __hash_node_base __first_node;
61 typedef typename __rebind_pointer<_NodePtr, __first_node>::type __node_base_pointer;
70 typedef __rebind_pointer_t<_NodePtr, __first_node> __node_base_pointer;
6271 typedef _NodePtr __node_pointer;
6372
6473#if defined(_LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB)
6574 typedef __node_base_pointer __next_pointer;
6675#else
67 typedef typename conditional<
68 is_pointer<__node_pointer>::value,
69 __node_base_pointer,
70 __node_pointer>::type __next_pointer;
76 typedef __conditional_t<is_pointer<__node_pointer>::value, __node_base_pointer, __node_pointer> __next_pointer;
7177#endif
7278
7379 __next_pointer __next_;
......@@ -96,7 +102,7 @@ template <class _Tp, class _VoidPtr>
96102struct _LIBCPP_STANDALONE_DEBUG __hash_node
97103 : public __hash_node_base
98104 <
99 typename __rebind_pointer<_VoidPtr, __hash_node<_Tp, _VoidPtr> >::type
105 __rebind_pointer_t<_VoidPtr, __hash_node<_Tp, _VoidPtr> >
100106 >
101107{
102108 typedef _Tp __node_value_type;
......@@ -208,9 +214,9 @@ struct __hash_map_pointer_types {};
208214template <class _Tp, class _AllocPtr, class _KVTypes>
209215struct __hash_map_pointer_types<_Tp, _AllocPtr, _KVTypes, true> {
210216 typedef typename _KVTypes::__map_value_type _Mv;
211 typedef typename __rebind_pointer<_AllocPtr, _Mv>::type
217 typedef __rebind_pointer_t<_AllocPtr, _Mv>
212218 __map_value_type_pointer;
213 typedef typename __rebind_pointer<_AllocPtr, const _Mv>::type
219 typedef __rebind_pointer_t<_AllocPtr, const _Mv>
214220 __const_map_value_type_pointer;
215221};
216222
......@@ -228,21 +234,21 @@ public:
228234 typedef ptrdiff_t difference_type;
229235 typedef size_t size_type;
230236
231 typedef typename __rebind_pointer<_NodePtr, void>::type __void_pointer;
237 typedef __rebind_pointer_t<_NodePtr, void> __void_pointer;
232238
233239 typedef typename pointer_traits<_NodePtr>::element_type __node_type;
234240 typedef _NodePtr __node_pointer;
235241
236242 typedef __hash_node_base<__node_pointer> __node_base_type;
237 typedef typename __rebind_pointer<_NodePtr, __node_base_type>::type
243 typedef __rebind_pointer_t<_NodePtr, __node_base_type>
238244 __node_base_pointer;
239245
240246 typedef typename __node_base_type::__next_pointer __next_pointer;
241247
242248 typedef _Tp __node_value_type;
243 typedef typename __rebind_pointer<_VoidPtr, __node_value_type>::type
249 typedef __rebind_pointer_t<_VoidPtr, __node_value_type>
244250 __node_value_type_pointer;
245 typedef typename __rebind_pointer<_VoidPtr, const __node_value_type>::type
251 typedef __rebind_pointer_t<_VoidPtr, const __node_value_type>
246252 __const_node_value_type_pointer;
247253
248254private:
......@@ -250,7 +256,7 @@ private:
250256 "_NodePtr should never be a pointer to const");
251257 static_assert((is_same<typename pointer_traits<_VoidPtr>::element_type, void>::value),
252258 "_VoidPtr does not point to unqualified void type");
253 static_assert((is_same<typename __rebind_pointer<_VoidPtr, __node_type>::type,
259 static_assert((is_same<__rebind_pointer_t<_VoidPtr, __node_type>,
254260 _NodePtr>::value), "_VoidPtr does not rebind to _NodePtr.");
255261};
256262
......@@ -269,7 +275,7 @@ struct __hash_node_types_from_iterator<__hash_const_local_iterator<_NodePtr> > :
269275template <class _NodeValueTp, class _VoidPtr>
270276struct __make_hash_node_types {
271277 typedef __hash_node<_NodeValueTp, _VoidPtr> _NodeTp;
272 typedef typename __rebind_pointer<_VoidPtr, _NodeTp>::type _NodePtr;
278 typedef __rebind_pointer_t<_VoidPtr, _NodeTp> _NodePtr;
273279 typedef __hash_node_types<_NodePtr> type;
274280};
275281
......@@ -559,7 +565,7 @@ public:
559565 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
560566 "Attempted to increment a non-incrementable unordered container local_iterator");
561567 __node_ = __node_->__next_;
562 if (__node_ != nullptr && __constrain_hash(__node_->__hash(), __bucket_count_) != __bucket_)
568 if (__node_ != nullptr && std::__constrain_hash(__node_->__hash(), __bucket_count_) != __bucket_)
563569 __node_ = nullptr;
564570 return *this;
565571 }
......@@ -614,8 +620,8 @@ class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator
614620
615621 typedef pointer_traits<__node_pointer> __pointer_traits;
616622 typedef typename __pointer_traits::element_type __node;
617 typedef typename remove_const<__node>::type __non_const_node;
618 typedef typename __rebind_pointer<__node_pointer, __non_const_node>::type
623 typedef __remove_const_t<__node> __non_const_node;
624 typedef __rebind_pointer_t<__node_pointer, __non_const_node>
619625 __non_const_node_pointer;
620626public:
621627 typedef __hash_local_iterator<__non_const_node_pointer>
......@@ -692,7 +698,7 @@ public:
692698 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
693699 "Attempted to increment a non-incrementable unordered container const_local_iterator");
694700 __node_ = __node_->__next_;
695 if (__node_ != nullptr && __constrain_hash(__node_->__hash(), __bucket_count_) != __bucket_)
701 if (__node_ != nullptr && std::__constrain_hash(__node_->__hash(), __bucket_count_) != __bucket_)
696702 __node_ = nullptr;
697703 return *this;
698704 }
......@@ -892,7 +898,7 @@ public:
892898 // Create __node
893899
894900 typedef typename _NodeTypes::__node_type __node;
895 typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator;
901 typedef __rebind_alloc<__alloc_traits, __node> __node_allocator;
896902 typedef allocator_traits<__node_allocator> __node_traits;
897903 typedef typename _NodeTypes::__void_pointer __void_pointer;
898904 typedef typename _NodeTypes::__node_pointer __node_pointer;
......@@ -907,15 +913,14 @@ private:
907913 // the pointer using 'pointer_traits'.
908914 static_assert((is_same<__node_pointer, typename __node_traits::pointer>::value),
909915 "Allocator does not rebind pointers in a sane manner.");
910 typedef typename __rebind_alloc_helper<__node_traits, __first_node>::type
911 __node_base_allocator;
916 typedef __rebind_alloc<__node_traits, __first_node> __node_base_allocator;
912917 typedef allocator_traits<__node_base_allocator> __node_base_traits;
913918 static_assert((is_same<__node_base_pointer, typename __node_base_traits::pointer>::value),
914919 "Allocator does not rebind pointers in a sane manner.");
915920
916921private:
917922
918 typedef typename __rebind_alloc_helper<__node_traits, __next_pointer>::type __pointer_allocator;
923 typedef __rebind_alloc<__node_traits, __next_pointer> __pointer_allocator;
919924 typedef __bucket_list_deallocator<__pointer_allocator> __bucket_list_deleter;
920925 typedef unique_ptr<__next_pointer[], __bucket_list_deleter> __bucket_list;
921926 typedef allocator_traits<__pointer_allocator> __pointer_alloc_traits;
......@@ -1151,11 +1156,11 @@ public:
11511156 _LIBCPP_INLINE_VISIBILITY void __rehash_multi(size_type __n) { __rehash<false>(__n); }
11521157 _LIBCPP_INLINE_VISIBILITY void __reserve_unique(size_type __n)
11531158 {
1154 __rehash_unique(static_cast<size_type>(ceil(__n / max_load_factor())));
1159 __rehash_unique(static_cast<size_type>(std::ceil(__n / max_load_factor())));
11551160 }
11561161 _LIBCPP_INLINE_VISIBILITY void __reserve_multi(size_type __n)
11571162 {
1158 __rehash_multi(static_cast<size_type>(ceil(__n / max_load_factor())));
1163 __rehash_multi(static_cast<size_type>(std::ceil(__n / max_load_factor())));
11591164 }
11601165
11611166 _LIBCPP_INLINE_VISIBILITY
......@@ -1179,7 +1184,7 @@ public:
11791184 {
11801185 _LIBCPP_ASSERT(bucket_count() > 0,
11811186 "unordered container::bucket(key) called when bucket_count() == 0");
1182 return __constrain_hash(hash_function()(__k), bucket_count());
1187 return std::__constrain_hash(hash_function()(__k), bucket_count());
11831188 }
11841189
11851190 template <class _Key>
......@@ -1428,7 +1433,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u)
14281433{
14291434 if (size() > 0)
14301435 {
1431 __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
1436 __bucket_list_[std::__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
14321437 __p1_.first().__ptr();
14331438 __u.__p1_.first().__next_ = nullptr;
14341439 __u.size() = 0;
......@@ -1452,7 +1457,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u,
14521457 {
14531458 __p1_.first().__next_ = __u.__p1_.first().__next_;
14541459 __u.__p1_.first().__next_ = nullptr;
1455 __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
1460 __bucket_list_[std::__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
14561461 __p1_.first().__ptr();
14571462 size() = __u.size();
14581463 __u.size() = 0;
......@@ -1569,7 +1574,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
15691574 __p1_.first().__next_ = __u.__p1_.first().__next_;
15701575 if (size() > 0)
15711576 {
1572 __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
1577 __bucket_list_[std::__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
15731578 __p1_.first().__ptr();
15741579 __u.__p1_.first().__next_ = nullptr;
15751580 __u.size() = 0;
......@@ -1784,12 +1789,12 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare(
17841789
17851790 if (__bc != 0)
17861791 {
1787 size_t __chash = __constrain_hash(__hash, __bc);
1792 size_t __chash = std::__constrain_hash(__hash, __bc);
17881793 __next_pointer __ndptr = __bucket_list_[__chash];
17891794 if (__ndptr != nullptr)
17901795 {
17911796 for (__ndptr = __ndptr->__next_; __ndptr != nullptr &&
1792 __constrain_hash(__ndptr->__hash(), __bc) == __chash;
1797 std::__constrain_hash(__ndptr->__hash(), __bc) == __chash;
17931798 __ndptr = __ndptr->__next_)
17941799 {
17951800 if (key_eq()(__ndptr->__upcast()->__value_, __value))
......@@ -1799,8 +1804,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare(
17991804 }
18001805 if (size()+1 > __bc * max_load_factor() || __bc == 0)
18011806 {
1802 __rehash_unique(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
1803 size_type(ceil(float(size() + 1) / max_load_factor()))));
1807 __rehash_unique(_VSTD::max<size_type>(2 * __bc + !std::__is_hash_power2(__bc),
1808 size_type(std::ceil(float(size() + 1) / max_load_factor()))));
18041809 }
18051810 return nullptr;
18061811}
......@@ -1816,7 +1821,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_perform(
18161821 __node_pointer __nd) _NOEXCEPT
18171822{
18181823 size_type __bc = bucket_count();
1819 size_t __chash = __constrain_hash(__nd->__hash(), __bc);
1824 size_t __chash = std::__constrain_hash(__nd->__hash(), __bc);
18201825 // insert_after __bucket_list_[__chash], or __first_node if bucket is null
18211826 __next_pointer __pn = __bucket_list_[__chash];
18221827 if (__pn == nullptr)
......@@ -1827,7 +1832,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_perform(
18271832 // fix up __bucket_list_
18281833 __bucket_list_[__chash] = __pn;
18291834 if (__nd->__next_ != nullptr)
1830 __bucket_list_[__constrain_hash(__nd->__next_->__hash(), __bc)] = __nd->__ptr();
1835 __bucket_list_[std::__constrain_hash(__nd->__next_->__hash(), __bc)] = __nd->__ptr();
18311836 }
18321837 else
18331838 {
......@@ -1871,16 +1876,16 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_prepare(
18711876 size_type __bc = bucket_count();
18721877 if (size()+1 > __bc * max_load_factor() || __bc == 0)
18731878 {
1874 __rehash_multi(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
1875 size_type(ceil(float(size() + 1) / max_load_factor()))));
1879 __rehash_multi(_VSTD::max<size_type>(2 * __bc + !std::__is_hash_power2(__bc),
1880 size_type(std::ceil(float(size() + 1) / max_load_factor()))));
18761881 __bc = bucket_count();
18771882 }
1878 size_t __chash = __constrain_hash(__cp_hash, __bc);
1883 size_t __chash = std::__constrain_hash(__cp_hash, __bc);
18791884 __next_pointer __pn = __bucket_list_[__chash];
18801885 if (__pn != nullptr)
18811886 {
18821887 for (bool __found = false; __pn->__next_ != nullptr &&
1883 __constrain_hash(__pn->__next_->__hash(), __bc) == __chash;
1888 std::__constrain_hash(__pn->__next_->__hash(), __bc) == __chash;
18841889 __pn = __pn->__next_)
18851890 {
18861891 // __found key_eq() action
......@@ -1912,7 +1917,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_perform(
19121917 __node_pointer __cp, __next_pointer __pn) _NOEXCEPT
19131918{
19141919 size_type __bc = bucket_count();
1915 size_t __chash = __constrain_hash(__cp->__hash_, __bc);
1920 size_t __chash = std::__constrain_hash(__cp->__hash_, __bc);
19161921 if (__pn == nullptr)
19171922 {
19181923 __pn =__p1_.first().__ptr();
......@@ -1921,7 +1926,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_perform(
19211926 // fix up __bucket_list_
19221927 __bucket_list_[__chash] = __pn;
19231928 if (__cp->__next_ != nullptr)
1924 __bucket_list_[__constrain_hash(__cp->__next_->__hash(), __bc)]
1929 __bucket_list_[std::__constrain_hash(__cp->__next_->__hash(), __bc)]
19251930 = __cp->__ptr();
19261931 }
19271932 else
......@@ -1930,7 +1935,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_perform(
19301935 __pn->__next_ = __cp->__ptr();
19311936 if (__cp->__next_ != nullptr)
19321937 {
1933 size_t __nhash = __constrain_hash(__cp->__next_->__hash(), __bc);
1938 size_t __nhash = std::__constrain_hash(__cp->__next_->__hash(), __bc);
19341939 if (__nhash != __chash)
19351940 __bucket_list_[__nhash] = __cp->__ptr();
19361941 }
......@@ -1965,11 +1970,11 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(
19651970 size_type __bc = bucket_count();
19661971 if (size()+1 > __bc * max_load_factor() || __bc == 0)
19671972 {
1968 __rehash_multi(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
1969 size_type(ceil(float(size() + 1) / max_load_factor()))));
1973 __rehash_multi(_VSTD::max<size_type>(2 * __bc + !std::__is_hash_power2(__bc),
1974 size_type(std::ceil(float(size() + 1) / max_load_factor()))));
19701975 __bc = bucket_count();
19711976 }
1972 size_t __chash = __constrain_hash(__cp->__hash_, __bc);
1977 size_t __chash = std::__constrain_hash(__cp->__hash_, __bc);
19731978 __next_pointer __pp = __bucket_list_[__chash];
19741979 while (__pp->__next_ != __np)
19751980 __pp = __pp->__next_;
......@@ -1996,12 +2001,12 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&
19962001 size_t __chash;
19972002 if (__bc != 0)
19982003 {
1999 __chash = __constrain_hash(__hash, __bc);
2004 __chash = std::__constrain_hash(__hash, __bc);
20002005 __nd = __bucket_list_[__chash];
20012006 if (__nd != nullptr)
20022007 {
20032008 for (__nd = __nd->__next_; __nd != nullptr &&
2004 (__nd->__hash() == __hash || __constrain_hash(__nd->__hash(), __bc) == __chash);
2009 (__nd->__hash() == __hash || std::__constrain_hash(__nd->__hash(), __bc) == __chash);
20052010 __nd = __nd->__next_)
20062011 {
20072012 if (key_eq()(__nd->__upcast()->__value_, __k))
......@@ -2013,10 +2018,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&
20132018 __node_holder __h = __construct_node_hash(__hash, _VSTD::forward<_Args>(__args)...);
20142019 if (size()+1 > __bc * max_load_factor() || __bc == 0)
20152020 {
2016 __rehash_unique(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
2017 size_type(ceil(float(size() + 1) / max_load_factor()))));
2021 __rehash_unique(_VSTD::max<size_type>(2 * __bc + !std::__is_hash_power2(__bc),
2022 size_type(std::ceil(float(size() + 1) / max_load_factor()))));
20182023 __bc = bucket_count();
2019 __chash = __constrain_hash(__hash, __bc);
2024 __chash = std::__constrain_hash(__hash, __bc);
20202025 }
20212026 // insert_after __bucket_list_[__chash], or __first_node if bucket is null
20222027 __next_pointer __pn = __bucket_list_[__chash];
......@@ -2028,7 +2033,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&
20282033 // fix up __bucket_list_
20292034 __bucket_list_[__chash] = __pn;
20302035 if (__h->__next_ != nullptr)
2031 __bucket_list_[__constrain_hash(__h->__next_->__hash(), __bc)]
2036 __bucket_list_[std::__constrain_hash(__h->__next_->__hash(), __bc)]
20322037 = __h.get()->__ptr();
20332038 }
20342039 else
......@@ -2224,7 +2229,7 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
22242229 if (__n == 1)
22252230 __n = 2;
22262231 else if (__n & (__n - 1))
2227 __n = __next_prime(__n);
2232 __n = std::__next_prime(__n);
22282233 size_type __bc = bucket_count();
22292234 if (__n > __bc)
22302235 __do_rehash<_UniqueKeys>(__n);
......@@ -2233,8 +2238,8 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
22332238 __n = _VSTD::max<size_type>
22342239 (
22352240 __n,
2236 __is_hash_power2(__bc) ? __next_hash_pow2(size_t(ceil(float(size()) / max_load_factor()))) :
2237 __next_prime(size_t(ceil(float(size()) / max_load_factor())))
2241 std::__is_hash_power2(__bc) ? std::__next_hash_pow2(size_t(std::ceil(float(size()) / max_load_factor()))) :
2242 std::__next_prime(size_t(std::ceil(float(size()) / max_load_factor())))
22382243 );
22392244 if (__n < __bc)
22402245 __do_rehash<_UniqueKeys>(__n);
......@@ -2259,13 +2264,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__do_rehash(size_type __nbc)
22592264 __next_pointer __cp = __pp->__next_;
22602265 if (__cp != nullptr)
22612266 {
2262 size_type __chash = __constrain_hash(__cp->__hash(), __nbc);
2267 size_type __chash = std::__constrain_hash(__cp->__hash(), __nbc);
22632268 __bucket_list_[__chash] = __pp;
22642269 size_type __phash = __chash;
22652270 for (__pp = __cp, void(), __cp = __cp->__next_; __cp != nullptr;
22662271 __cp = __pp->__next_)
22672272 {
2268 __chash = __constrain_hash(__cp->__hash(), __nbc);
2273 __chash = std::__constrain_hash(__cp->__hash(), __nbc);
22692274 if (__chash == __phash)
22702275 __pp = __cp;
22712276 else
......@@ -2279,7 +2284,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__do_rehash(size_type __nbc)
22792284 else
22802285 {
22812286 __next_pointer __np = __cp;
2282 if _LIBCPP_CONSTEXPR_AFTER_CXX14 (!_UniqueKeys)
2287 if _LIBCPP_CONSTEXPR_SINCE_CXX17 (!_UniqueKeys)
22832288 {
22842289 for (; __np->__next_ != nullptr &&
22852290 key_eq()(__cp->__upcast()->__value_,
......@@ -2307,13 +2312,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k)
23072312 size_type __bc = bucket_count();
23082313 if (__bc != 0)
23092314 {
2310 size_t __chash = __constrain_hash(__hash, __bc);
2315 size_t __chash = std::__constrain_hash(__hash, __bc);
23112316 __next_pointer __nd = __bucket_list_[__chash];
23122317 if (__nd != nullptr)
23132318 {
23142319 for (__nd = __nd->__next_; __nd != nullptr &&
23152320 (__nd->__hash() == __hash
2316 || __constrain_hash(__nd->__hash(), __bc) == __chash);
2321 || std::__constrain_hash(__nd->__hash(), __bc) == __chash);
23172322 __nd = __nd->__next_)
23182323 {
23192324 if ((__nd->__hash() == __hash)
......@@ -2334,13 +2339,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const
23342339 size_type __bc = bucket_count();
23352340 if (__bc != 0)
23362341 {
2337 size_t __chash = __constrain_hash(__hash, __bc);
2342 size_t __chash = std::__constrain_hash(__hash, __bc);
23382343 __next_pointer __nd = __bucket_list_[__chash];
23392344 if (__nd != nullptr)
23402345 {
23412346 for (__nd = __nd->__next_; __nd != nullptr &&
23422347 (__hash == __nd->__hash()
2343 || __constrain_hash(__nd->__hash(), __bc) == __chash);
2348 || std::__constrain_hash(__nd->__hash(), __bc) == __chash);
23442349 __nd = __nd->__next_)
23452350 {
23462351 if ((__nd->__hash() == __hash)
......@@ -2462,7 +2467,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT
24622467 // current node
24632468 __next_pointer __cn = __p.__node_;
24642469 size_type __bc = bucket_count();
2465 size_t __chash = __constrain_hash(__cn->__hash(), __bc);
2470 size_t __chash = std::__constrain_hash(__cn->__hash(), __bc);
24662471 // find previous node
24672472 __next_pointer __pn = __bucket_list_[__chash];
24682473 for (; __pn->__next_ != __cn; __pn = __pn->__next_)
......@@ -2471,16 +2476,16 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT
24712476 // if __pn is not in same bucket (before begin is not in same bucket) &&
24722477 // if __cn->__next_ is not in same bucket (nullptr is not in same bucket)
24732478 if (__pn == __p1_.first().__ptr()
2474 || __constrain_hash(__pn->__hash(), __bc) != __chash)
2479 || std::__constrain_hash(__pn->__hash(), __bc) != __chash)
24752480 {
24762481 if (__cn->__next_ == nullptr
2477 || __constrain_hash(__cn->__next_->__hash(), __bc) != __chash)
2482 || std::__constrain_hash(__cn->__next_->__hash(), __bc) != __chash)
24782483 __bucket_list_[__chash] = nullptr;
24792484 }
24802485 // if __cn->__next_ is not in same bucket (nullptr is in same bucket)
24812486 if (__cn->__next_ != nullptr)
24822487 {
2483 size_t __nhash = __constrain_hash(__cn->__next_->__hash(), __bc);
2488 size_t __nhash = std::__constrain_hash(__cn->__next_->__hash(), __bc);
24842489 if (__nhash != __chash)
24852490 __bucket_list_[__nhash] = __pn;
24862491 }
......@@ -2634,10 +2639,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
26342639 __p2_.swap(__u.__p2_);
26352640 __p3_.swap(__u.__p3_);
26362641 if (size() > 0)
2637 __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
2642 __bucket_list_[std::__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
26382643 __p1_.first().__ptr();
26392644 if (__u.size() > 0)
2640 __u.__bucket_list_[__constrain_hash(__u.__p1_.first().__next_->__hash(), __u.bucket_count())] =
2645 __u.__bucket_list_[std::__constrain_hash(__u.__p1_.first().__next_->__hash(), __u.bucket_count())] =
26412646 __u.__p1_.first().__ptr();
26422647 std::__debug_db_swap(this, std::addressof(__u));
26432648}
......@@ -2654,8 +2659,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::bucket_size(size_type __n) const
26542659 if (__np != nullptr)
26552660 {
26562661 for (__np = __np->__next_; __np != nullptr &&
2657 __constrain_hash(__np->__hash(), __bc) == __n;
2658 __np = __np->__next_, (void) ++__r)
2662 std::__constrain_hash(__np->__hash(), __bc) == __n;
2663 __np = __np->__next_, (void) ++__r)
26592664 ;
26602665 }
26612666 return __r;
lib/libcxx/include/__iterator/access.h+8-8
......@@ -20,7 +20,7 @@
2020_LIBCPP_BEGIN_NAMESPACE_STD
2121
2222template <class _Tp, size_t _Np>
23_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
23_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
2424_Tp*
2525begin(_Tp (&__array)[_Np])
2626{
......@@ -28,7 +28,7 @@ begin(_Tp (&__array)[_Np])
2828}
2929
3030template <class _Tp, size_t _Np>
31_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
31_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
3232_Tp*
3333end(_Tp (&__array)[_Np])
3434{
......@@ -38,7 +38,7 @@ end(_Tp (&__array)[_Np])
3838#if !defined(_LIBCPP_CXX03_LANG)
3939
4040template <class _Cp>
41_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
41_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
4242auto
4343begin(_Cp& __c) -> decltype(__c.begin())
4444{
......@@ -46,7 +46,7 @@ begin(_Cp& __c) -> decltype(__c.begin())
4646}
4747
4848template <class _Cp>
49_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
49_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
5050auto
5151begin(const _Cp& __c) -> decltype(__c.begin())
5252{
......@@ -54,7 +54,7 @@ begin(const _Cp& __c) -> decltype(__c.begin())
5454}
5555
5656template <class _Cp>
57_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
57_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
5858auto
5959end(_Cp& __c) -> decltype(__c.end())
6060{
......@@ -62,7 +62,7 @@ end(_Cp& __c) -> decltype(__c.end())
6262}
6363
6464template <class _Cp>
65_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
65_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
6666auto
6767end(const _Cp& __c) -> decltype(__c.end())
6868{
......@@ -72,14 +72,14 @@ end(const _Cp& __c) -> decltype(__c.end())
7272#if _LIBCPP_STD_VER > 11
7373
7474template <class _Cp>
75_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
75_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
7676auto cbegin(const _Cp& __c) -> decltype(_VSTD::begin(__c))
7777{
7878 return _VSTD::begin(__c);
7979}
8080
8181template <class _Cp>
82_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
82_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
8383auto cend(const _Cp& __c) -> decltype(_VSTD::end(__c))
8484{
8585 return _VSTD::end(__c);
lib/libcxx/include/__iterator/advance.h+13-9
......@@ -11,16 +11,20 @@
1111#define _LIBCPP___ITERATOR_ADVANCE_H
1212
1313#include <__assert>
14#include <__concepts/assignable.h>
15#include <__concepts/same_as.h>
1416#include <__config>
1517#include <__iterator/concepts.h>
1618#include <__iterator/incrementable_traits.h>
1719#include <__iterator/iterator_traits.h>
20#include <__type_traits/enable_if.h>
21#include <__type_traits/is_integral.h>
22#include <__utility/convert_to_integral.h>
23#include <__utility/declval.h>
1824#include <__utility/move.h>
1925#include <__utility/unreachable.h>
20#include <concepts>
2126#include <cstdlib>
2227#include <limits>
23#include <type_traits>
2428
2529#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2630# pragma GCC system_header
......@@ -29,14 +33,14 @@
2933_LIBCPP_BEGIN_NAMESPACE_STD
3034
3135template <class _InputIter>
32_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
36_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
3337void __advance(_InputIter& __i, typename iterator_traits<_InputIter>::difference_type __n, input_iterator_tag) {
3438 for (; __n > 0; --__n)
3539 ++__i;
3640}
3741
3842template <class _BiDirIter>
39_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
43_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
4044void __advance(_BiDirIter& __i, typename iterator_traits<_BiDirIter>::difference_type __n, bidirectional_iterator_tag) {
4145 if (__n >= 0)
4246 for (; __n > 0; --__n)
......@@ -47,16 +51,16 @@ void __advance(_BiDirIter& __i, typename iterator_traits<_BiDirIter>::difference
4751}
4852
4953template <class _RandIter>
50_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
54_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
5155void __advance(_RandIter& __i, typename iterator_traits<_RandIter>::difference_type __n, random_access_iterator_tag) {
5256 __i += __n;
5357}
5458
5559template <
5660 class _InputIter, class _Distance,
57 class _IntegralDistance = decltype(_VSTD::__convert_to_integral(declval<_Distance>())),
61 class _IntegralDistance = decltype(_VSTD::__convert_to_integral(std::declval<_Distance>())),
5862 class = __enable_if_t<is_integral<_IntegralDistance>::value> >
59_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
63_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
6064void advance(_InputIter& __i, _Distance __orig_n) {
6165 typedef typename iterator_traits<_InputIter>::difference_type _Difference;
6266 _Difference __n = static_cast<_Difference>(_VSTD::__convert_to_integral(__orig_n));
......@@ -65,7 +69,7 @@ void advance(_InputIter& __i, _Distance __orig_n) {
6569 _VSTD::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());
6670}
6771
68#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
72#if _LIBCPP_STD_VER > 17
6973
7074// [range.iter.op.advance]
7175
......@@ -192,7 +196,7 @@ inline namespace __cpo {
192196} // namespace __cpo
193197} // namespace ranges
194198
195#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
199#endif // _LIBCPP_STD_VER > 17
196200
197201_LIBCPP_END_NAMESPACE_STD
198202
lib/libcxx/include/__iterator/back_insert_iterator.h+9-8
......@@ -45,22 +45,23 @@ public:
4545 typedef void reference;
4646 typedef _Container container_type;
4747
48 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
49 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(const typename _Container::value_type& __value)
48 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
49 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator& operator=(const typename _Container::value_type& __value)
5050 {container->push_back(__value); return *this;}
5151#ifndef _LIBCPP_CXX03_LANG
52 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(typename _Container::value_type&& __value)
52 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator& operator=(typename _Container::value_type&& __value)
5353 {container->push_back(_VSTD::move(__value)); return *this;}
5454#endif // _LIBCPP_CXX03_LANG
55 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator*() {return *this;}
56 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator++() {return *this;}
57 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator operator++(int) {return *this;}
55 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator& operator*() {return *this;}
56 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator& operator++() {return *this;}
57 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator operator++(int) {return *this;}
5858
59 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Container* __get_container() const { return container; }
59 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Container* __get_container() const { return container; }
6060};
61_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(back_insert_iterator);
6162
6263template <class _Container>
63inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
64inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
6465back_insert_iterator<_Container>
6566back_inserter(_Container& __x)
6667{
lib/libcxx/include/__iterator/bounded_iter.h+17-15
......@@ -14,8 +14,10 @@
1414#include <__config>
1515#include <__iterator/iterator_traits.h>
1616#include <__memory/pointer_traits.h>
17#include <__type_traits/enable_if.h>
18#include <__type_traits/integral_constant.h>
19#include <__type_traits/is_convertible.h>
1720#include <__utility/move.h>
18#include <type_traits>
1921
2022#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2123# pragma GCC system_header
......@@ -73,7 +75,7 @@ private:
7375 //
7476 // Since it is non-standard for iterators to have this constructor, __bounded_iter must
7577 // be created via `std::__make_bounded_iter`.
76 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit __bounded_iter(
78 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __bounded_iter(
7779 _Iterator __current, _Iterator __begin, _Iterator __end)
7880 : __current_(__current), __begin_(__begin), __end_(__end) {
7981 _LIBCPP_ASSERT(__begin <= __end, "__bounded_iter(current, begin, end): [begin, end) is not a valid range");
......@@ -86,19 +88,19 @@ public:
8688 // Dereference and indexing operations.
8789 //
8890 // These operations check that the iterator is dereferenceable, that is within [begin, end).
89 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference operator*() const _NOEXCEPT {
91 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT {
9092 _LIBCPP_ASSERT(
9193 __in_bounds(__current_), "__bounded_iter::operator*: Attempt to dereference an out-of-range iterator");
9294 return *__current_;
9395 }
9496
95 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 pointer operator->() const _NOEXCEPT {
97 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pointer operator->() const _NOEXCEPT {
9698 _LIBCPP_ASSERT(
9799 __in_bounds(__current_), "__bounded_iter::operator->: Attempt to dereference an out-of-range iterator");
98100 return std::__to_address(__current_);
99101 }
100102
101 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference operator[](difference_type __n) const _NOEXCEPT {
103 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator[](difference_type __n) const _NOEXCEPT {
102104 _LIBCPP_ASSERT(
103105 __in_bounds(__current_ + __n), "__bounded_iter::operator[]: Attempt to index an iterator out-of-range");
104106 return __current_[__n];
......@@ -108,54 +110,54 @@ public:
108110 //
109111 // These operations do not check that the resulting iterator is within the bounds, since that
110112 // would make it impossible to create a past-the-end iterator.
111 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter& operator++() _NOEXCEPT {
113 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter& operator++() _NOEXCEPT {
112114 ++__current_;
113115 return *this;
114116 }
115 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter operator++(int) _NOEXCEPT {
117 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter operator++(int) _NOEXCEPT {
116118 __bounded_iter __tmp(*this);
117119 ++*this;
118120 return __tmp;
119121 }
120122
121 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter& operator--() _NOEXCEPT {
123 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter& operator--() _NOEXCEPT {
122124 --__current_;
123125 return *this;
124126 }
125 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter operator--(int) _NOEXCEPT {
127 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter operator--(int) _NOEXCEPT {
126128 __bounded_iter __tmp(*this);
127129 --*this;
128130 return __tmp;
129131 }
130132
131 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter& operator+=(difference_type __n) _NOEXCEPT {
133 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter& operator+=(difference_type __n) _NOEXCEPT {
132134 __current_ += __n;
133135 return *this;
134136 }
135 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend __bounded_iter
137 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __bounded_iter
136138 operator+(__bounded_iter const& __self, difference_type __n) _NOEXCEPT {
137139 __bounded_iter __tmp(__self);
138140 __tmp += __n;
139141 return __tmp;
140142 }
141 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend __bounded_iter
143 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __bounded_iter
142144 operator+(difference_type __n, __bounded_iter const& __self) _NOEXCEPT {
143145 __bounded_iter __tmp(__self);
144146 __tmp += __n;
145147 return __tmp;
146148 }
147149
148 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter& operator-=(difference_type __n) _NOEXCEPT {
150 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter& operator-=(difference_type __n) _NOEXCEPT {
149151 __current_ -= __n;
150152 return *this;
151153 }
152 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend __bounded_iter
154 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __bounded_iter
153155 operator-(__bounded_iter const& __self, difference_type __n) _NOEXCEPT {
154156 __bounded_iter __tmp(__self);
155157 __tmp -= __n;
156158 return __tmp;
157159 }
158 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend difference_type
160 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend difference_type
159161 operator-(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
160162 return __x.__current_ - __y.__current_;
161163 }
lib/libcxx/include/__iterator/common_iterator.h+25-14
......@@ -11,6 +11,13 @@
1111#define _LIBCPP___ITERATOR_COMMON_ITERATOR_H
1212
1313#include <__assert>
14#include <__concepts/assignable.h>
15#include <__concepts/constructible.h>
16#include <__concepts/convertible_to.h>
17#include <__concepts/copyable.h>
18#include <__concepts/derived_from.h>
19#include <__concepts/equality_comparable.h>
20#include <__concepts/same_as.h>
1421#include <__config>
1522#include <__iterator/concepts.h>
1623#include <__iterator/incrementable_traits.h>
......@@ -18,7 +25,8 @@
1825#include <__iterator/iter_swap.h>
1926#include <__iterator/iterator_traits.h>
2027#include <__iterator/readable_traits.h>
21#include <concepts>
28#include <__type_traits/is_pointer.h>
29#include <__utility/declval.h>
2230#include <variant>
2331
2432#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -95,14 +103,14 @@ public:
95103
96104 constexpr decltype(auto) operator*()
97105 {
98 _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), "Attempted to dereference a non-dereferenceable common_iterator");
106 _LIBCPP_ASSERT(std::holds_alternative<_Iter>(__hold_), "Attempted to dereference a non-dereferenceable common_iterator");
99107 return *_VSTD::__unchecked_get<_Iter>(__hold_);
100108 }
101109
102110 constexpr decltype(auto) operator*() const
103111 requires __dereferenceable<const _Iter>
104112 {
105 _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), "Attempted to dereference a non-dereferenceable common_iterator");
113 _LIBCPP_ASSERT(std::holds_alternative<_Iter>(__hold_), "Attempted to dereference a non-dereferenceable common_iterator");
106114 return *_VSTD::__unchecked_get<_Iter>(__hold_);
107115 }
108116
......@@ -113,7 +121,7 @@ public:
113121 is_reference_v<iter_reference_t<_I2>> ||
114122 constructible_from<iter_value_t<_I2>, iter_reference_t<_I2>>)
115123 {
116 _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), "Attempted to dereference a non-dereferenceable common_iterator");
124 _LIBCPP_ASSERT(std::holds_alternative<_Iter>(__hold_), "Attempted to dereference a non-dereferenceable common_iterator");
117125 if constexpr (is_pointer_v<_Iter> || requires(const _Iter& __i) { __i.operator->(); }) {
118126 return _VSTD::__unchecked_get<_Iter>(__hold_);
119127 } else if constexpr (is_reference_v<iter_reference_t<_Iter>>) {
......@@ -125,12 +133,12 @@ public:
125133 }
126134
127135 common_iterator& operator++() {
128 _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), "Attempted to increment a non-dereferenceable common_iterator");
136 _LIBCPP_ASSERT(std::holds_alternative<_Iter>(__hold_), "Attempted to increment a non-dereferenceable common_iterator");
129137 ++_VSTD::__unchecked_get<_Iter>(__hold_); return *this;
130138 }
131139
132140 decltype(auto) operator++(int) {
133 _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), "Attempted to increment a non-dereferenceable common_iterator");
141 _LIBCPP_ASSERT(std::holds_alternative<_Iter>(__hold_), "Attempted to increment a non-dereferenceable common_iterator");
134142 if constexpr (forward_iterator<_Iter>) {
135143 auto __tmp = *this;
136144 ++*this;
......@@ -147,6 +155,7 @@ public:
147155
148156 template<class _I2, sentinel_for<_Iter> _S2>
149157 requires sentinel_for<_Sent, _I2>
158 _LIBCPP_HIDE_FROM_ABI
150159 friend constexpr bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) {
151160 _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");
152161 _LIBCPP_ASSERT(!__y.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");
......@@ -165,6 +174,7 @@ public:
165174
166175 template<class _I2, sentinel_for<_Iter> _S2>
167176 requires sentinel_for<_Sent, _I2> && equality_comparable_with<_Iter, _I2>
177 _LIBCPP_HIDE_FROM_ABI
168178 friend constexpr bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) {
169179 _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");
170180 _LIBCPP_ASSERT(!__y.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");
......@@ -186,6 +196,7 @@ public:
186196
187197 template<sized_sentinel_for<_Iter> _I2, sized_sentinel_for<_Iter> _S2>
188198 requires sized_sentinel_for<_Sent, _I2>
199 _LIBCPP_HIDE_FROM_ABI
189200 friend constexpr iter_difference_t<_I2> operator-(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) {
190201 _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception(), "Attempted to subtract from a valueless common_iterator");
191202 _LIBCPP_ASSERT(!__y.__hold_.valueless_by_exception(), "Attempted to subtract a valueless common_iterator");
......@@ -205,20 +216,20 @@ public:
205216 return _VSTD::__unchecked_get<_Sent>(__x.__hold_) - _VSTD::__unchecked_get<_I2>(__y.__hold_);
206217 }
207218
208 friend constexpr iter_rvalue_reference_t<_Iter> iter_move(const common_iterator& __i)
209 noexcept(noexcept(ranges::iter_move(declval<const _Iter&>())))
219 _LIBCPP_HIDE_FROM_ABI friend constexpr iter_rvalue_reference_t<_Iter> iter_move(const common_iterator& __i)
220 noexcept(noexcept(ranges::iter_move(std::declval<const _Iter&>())))
210221 requires input_iterator<_Iter>
211222 {
212 _LIBCPP_ASSERT(holds_alternative<_Iter>(__i.__hold_), "Attempted to iter_move a non-dereferenceable common_iterator");
223 _LIBCPP_ASSERT(std::holds_alternative<_Iter>(__i.__hold_), "Attempted to iter_move a non-dereferenceable common_iterator");
213224 return ranges::iter_move( _VSTD::__unchecked_get<_Iter>(__i.__hold_));
214225 }
215226
216227 template<indirectly_swappable<_Iter> _I2, class _S2>
217 friend constexpr void iter_swap(const common_iterator& __x, const common_iterator<_I2, _S2>& __y)
218 noexcept(noexcept(ranges::iter_swap(declval<const _Iter&>(), declval<const _I2&>())))
228 _LIBCPP_HIDE_FROM_ABI friend constexpr void iter_swap(const common_iterator& __x, const common_iterator<_I2, _S2>& __y)
229 noexcept(noexcept(ranges::iter_swap(std::declval<const _Iter&>(), std::declval<const _I2&>())))
219230 {
220 _LIBCPP_ASSERT(holds_alternative<_Iter>(__x.__hold_), "Attempted to iter_swap a non-dereferenceable common_iterator");
221 _LIBCPP_ASSERT(holds_alternative<_I2>(__y.__hold_), "Attempted to iter_swap a non-dereferenceable common_iterator");
231 _LIBCPP_ASSERT(std::holds_alternative<_Iter>(__x.__hold_), "Attempted to iter_swap a non-dereferenceable common_iterator");
232 _LIBCPP_ASSERT(std::holds_alternative<_I2>(__y.__hold_), "Attempted to iter_swap a non-dereferenceable common_iterator");
222233 return ranges::iter_swap(_VSTD::__unchecked_get<_Iter>(__x.__hold_), _VSTD::__unchecked_get<_I2>(__y.__hold_));
223234 }
224235};
......@@ -246,7 +257,7 @@ struct __arrow_type_or_void {
246257template<class _Iter, class _Sent>
247258 requires __common_iter_has_ptr_op<_Iter, _Sent>
248259struct __arrow_type_or_void<_Iter, _Sent> {
249 using type = decltype(declval<const common_iterator<_Iter, _Sent>&>().operator->());
260 using type = decltype(std::declval<const common_iterator<_Iter, _Sent>&>().operator->());
250261};
251262
252263template<input_iterator _Iter, class _Sent>
lib/libcxx/include/__iterator/concepts.h+22-2
......@@ -10,15 +10,35 @@
1010#ifndef _LIBCPP___ITERATOR_CONCEPTS_H
1111#define _LIBCPP___ITERATOR_CONCEPTS_H
1212
13#include <__concepts/arithmetic.h>
14#include <__concepts/assignable.h>
15#include <__concepts/common_reference_with.h>
16#include <__concepts/constructible.h>
17#include <__concepts/copyable.h>
18#include <__concepts/derived_from.h>
19#include <__concepts/equality_comparable.h>
20#include <__concepts/invocable.h>
21#include <__concepts/movable.h>
22#include <__concepts/predicate.h>
23#include <__concepts/regular.h>
24#include <__concepts/relation.h>
25#include <__concepts/same_as.h>
26#include <__concepts/semiregular.h>
27#include <__concepts/totally_ordered.h>
1328#include <__config>
29#include <__functional/invoke.h>
1430#include <__iterator/incrementable_traits.h>
1531#include <__iterator/iter_move.h>
1632#include <__iterator/iterator_traits.h>
1733#include <__iterator/readable_traits.h>
1834#include <__memory/pointer_traits.h>
35#include <__type_traits/add_pointer.h>
36#include <__type_traits/common_reference.h>
37#include <__type_traits/is_pointer.h>
38#include <__type_traits/is_reference.h>
39#include <__type_traits/remove_cv.h>
40#include <__type_traits/remove_cvref.h>
1941#include <__utility/forward.h>
20#include <concepts>
21#include <type_traits>
2242
2343#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2444# pragma GCC system_header
lib/libcxx/include/__iterator/counted_iterator.h+10-3
......@@ -6,10 +6,16 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___ITERATOR_COUNTED_ITERATOR_H
1011#define _LIBCPP___ITERATOR_COUNTED_ITERATOR_H
1112
1213#include <__assert>
14#include <__concepts/assignable.h>
15#include <__concepts/common_with.h>
16#include <__concepts/constructible.h>
17#include <__concepts/convertible_to.h>
18#include <__concepts/same_as.h>
1319#include <__config>
1420#include <__iterator/concepts.h>
1521#include <__iterator/default_sentinel.h>
......@@ -19,10 +25,10 @@
1925#include <__iterator/iterator_traits.h>
2026#include <__iterator/readable_traits.h>
2127#include <__memory/pointer_traits.h>
28#include <__type_traits/add_pointer.h>
29#include <__type_traits/conditional.h>
2230#include <__utility/move.h>
2331#include <compare>
24#include <concepts>
25#include <type_traits>
2632
2733#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2834# pragma GCC system_header
......@@ -263,7 +269,7 @@ public:
263269 }
264270
265271 template<common_with<_Iter> _I2>
266 friend constexpr strong_ordering operator<=>(
272 _LIBCPP_HIDE_FROM_ABI friend constexpr strong_ordering operator<=>(
267273 const counted_iterator& __lhs, const counted_iterator<_I2>& __rhs)
268274 {
269275 return __rhs.__count_ <=> __lhs.__count_;
......@@ -288,6 +294,7 @@ public:
288294 return ranges::iter_swap(__x.__current_, __y.__current_);
289295 }
290296};
297_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(counted_iterator);
291298
292299template<input_iterator _Iter>
293300 requires same_as<_ITER_TRAITS<_Iter>, iterator_traits<_Iter>>
lib/libcxx/include/__iterator/distance.h+8-7
......@@ -17,7 +17,8 @@
1717#include <__ranges/access.h>
1818#include <__ranges/concepts.h>
1919#include <__ranges/size.h>
20#include <type_traits>
20#include <__type_traits/decay.h>
21#include <__type_traits/remove_cvref.h>
2122
2223#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2324# pragma GCC system_header
......@@ -26,7 +27,7 @@
2627_LIBCPP_BEGIN_NAMESPACE_STD
2728
2829template <class _InputIter>
29inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
30inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
3031typename iterator_traits<_InputIter>::difference_type
3132__distance(_InputIter __first, _InputIter __last, input_iterator_tag)
3233{
......@@ -37,7 +38,7 @@ __distance(_InputIter __first, _InputIter __last, input_iterator_tag)
3738}
3839
3940template <class _RandIter>
40inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
41inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
4142typename iterator_traits<_RandIter>::difference_type
4243__distance(_RandIter __first, _RandIter __last, random_access_iterator_tag)
4344{
......@@ -45,14 +46,14 @@ __distance(_RandIter __first, _RandIter __last, random_access_iterator_tag)
4546}
4647
4748template <class _InputIter>
48inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
49inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
4950typename iterator_traits<_InputIter>::difference_type
5051distance(_InputIter __first, _InputIter __last)
5152{
5253 return _VSTD::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());
5354}
5455
55#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
56#if _LIBCPP_STD_VER > 17
5657
5758// [range.iter.op.distance]
5859
......@@ -75,7 +76,7 @@ struct __fn {
7576 template<class _Ip, sized_sentinel_for<decay_t<_Ip>> _Sp>
7677 _LIBCPP_HIDE_FROM_ABI
7778 constexpr iter_difference_t<_Ip> operator()(_Ip&& __first, _Sp __last) const {
78 if constexpr (sized_sentinel_for<_Sp, __uncvref_t<_Ip>>) {
79 if constexpr (sized_sentinel_for<_Sp, __remove_cvref_t<_Ip>>) {
7980 return __last - __first;
8081 } else {
8182 return __last - decay_t<_Ip>(__first);
......@@ -100,7 +101,7 @@ inline namespace __cpo {
100101} // namespace __cpo
101102} // namespace ranges
102103
103#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
104#endif // _LIBCPP_STD_VER > 17
104105
105106_LIBCPP_END_NAMESPACE_STD
106107
lib/libcxx/include/__iterator/front_insert_iterator.h+8-7
......@@ -45,20 +45,21 @@ public:
4545 typedef void reference;
4646 typedef _Container container_type;
4747
48 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit front_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
49 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(const typename _Container::value_type& __value)
48 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit front_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
49 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 front_insert_iterator& operator=(const typename _Container::value_type& __value)
5050 {container->push_front(__value); return *this;}
5151#ifndef _LIBCPP_CXX03_LANG
52 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(typename _Container::value_type&& __value)
52 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 front_insert_iterator& operator=(typename _Container::value_type&& __value)
5353 {container->push_front(_VSTD::move(__value)); return *this;}
5454#endif // _LIBCPP_CXX03_LANG
55 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator*() {return *this;}
56 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator++() {return *this;}
57 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator operator++(int) {return *this;}
55 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 front_insert_iterator& operator*() {return *this;}
56 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 front_insert_iterator& operator++() {return *this;}
57 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 front_insert_iterator operator++(int) {return *this;}
5858};
59_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(front_insert_iterator);
5960
6061template <class _Container>
61inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
62inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
6263front_insert_iterator<_Container>
6364front_inserter(_Container& __x)
6465{
lib/libcxx/include/__iterator/incrementable_traits.h+7-3
......@@ -10,11 +10,15 @@
1010#ifndef _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H
1111#define _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H
1212
13#include <__concepts/arithmetic.h>
1314#include <__config>
15#include <__type_traits/conditional.h>
16#include <__type_traits/is_object.h>
1417#include <__type_traits/is_primary_template.h>
15#include <concepts>
18#include <__type_traits/make_signed.h>
19#include <__type_traits/remove_cvref.h>
20#include <__utility/declval.h>
1621#include <cstddef>
17#include <type_traits>
1822
1923#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2024# pragma GCC system_header
......@@ -53,7 +57,7 @@ concept __has_integral_minus =
5357template<__has_integral_minus _Tp>
5458requires (!__has_member_difference_type<_Tp>)
5559struct incrementable_traits<_Tp> {
56 using difference_type = make_signed_t<decltype(declval<_Tp>() - declval<_Tp>())>;
60 using difference_type = make_signed_t<decltype(std::declval<_Tp>() - std::declval<_Tp>())>;
5761};
5862
5963template <class>
lib/libcxx/include/__iterator/insert_iterator.h+8-8
......@@ -24,7 +24,7 @@
2424
2525_LIBCPP_BEGIN_NAMESPACE_STD
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27#if _LIBCPP_STD_VER > 17
2828template <class _Container>
2929using __insert_iterator_iter_t = ranges::iterator_t<_Container>;
3030#else
......@@ -55,21 +55,21 @@ public:
5555 typedef void reference;
5656 typedef _Container container_type;
5757
58 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator(_Container& __x, __insert_iterator_iter_t<_Container> __i)
58 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 insert_iterator(_Container& __x, __insert_iterator_iter_t<_Container> __i)
5959 : container(_VSTD::addressof(__x)), iter(__i) {}
60 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(const typename _Container::value_type& __value)
60 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 insert_iterator& operator=(const typename _Container::value_type& __value)
6161 {iter = container->insert(iter, __value); ++iter; return *this;}
6262#ifndef _LIBCPP_CXX03_LANG
63 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(typename _Container::value_type&& __value)
63 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 insert_iterator& operator=(typename _Container::value_type&& __value)
6464 {iter = container->insert(iter, _VSTD::move(__value)); ++iter; return *this;}
6565#endif // _LIBCPP_CXX03_LANG
66 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator*() {return *this;}
67 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator++() {return *this;}
68 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator++(int) {return *this;}
66 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 insert_iterator& operator*() {return *this;}
67 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 insert_iterator& operator++() {return *this;}
68 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 insert_iterator& operator++(int) {return *this;}
6969};
7070
7171template <class _Container>
72inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
72inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
7373insert_iterator<_Container>
7474inserter(_Container& __x, __insert_iterator_iter_t<_Container> __i)
7575{
lib/libcxx/include/__iterator/iter_move.h+7-2
......@@ -13,9 +13,11 @@
1313#include <__concepts/class_or_enum.h>
1414#include <__config>
1515#include <__iterator/iterator_traits.h>
16#include <__type_traits/is_reference.h>
17#include <__type_traits/remove_cvref.h>
18#include <__utility/declval.h>
1619#include <__utility/forward.h>
1720#include <__utility/move.h>
18#include <type_traits>
1921
2022#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2123# pragma GCC system_header
......@@ -36,6 +38,7 @@ template <class _Tp>
3638concept __unqualified_iter_move =
3739 __class_or_enum<remove_cvref_t<_Tp>> &&
3840 requires (_Tp&& __t) {
41 // NOLINTNEXTLINE(libcpp-robust-against-adl) iter_swap ADL calls should only be made through ranges::iter_swap
3942 iter_move(std::forward<_Tp>(__t));
4043 };
4144
......@@ -59,6 +62,7 @@ concept __just_deref =
5962// [iterator.cust.move]
6063
6164struct __fn {
65 // NOLINTBEGIN(libcpp-robust-against-adl) iter_move ADL calls should only be made through ranges::iter_move
6266 template<class _Ip>
6367 requires __unqualified_iter_move<_Ip>
6468 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Ip&& __i) const
......@@ -66,6 +70,7 @@ struct __fn {
6670 {
6771 return iter_move(std::forward<_Ip>(__i));
6872 }
73 // NOLINTEND(libcpp-robust-against-adl)
6974
7075 template<class _Ip>
7176 requires __move_deref<_Ip>
......@@ -90,7 +95,7 @@ inline namespace __cpo {
9095
9196template<__dereferenceable _Tp>
9297 requires requires(_Tp& __t) { { ranges::iter_move(__t) } -> __can_reference; }
93using iter_rvalue_reference_t = decltype(ranges::iter_move(declval<_Tp&>()));
98using iter_rvalue_reference_t = decltype(ranges::iter_move(std::declval<_Tp&>()));
9499
95100#endif // _LIBCPP_STD_VER > 17
96101
lib/libcxx/include/__iterator/iter_swap.h+10-3
......@@ -6,18 +6,21 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___ITERATOR_ITER_SWAP_H
1011#define _LIBCPP___ITERATOR_ITER_SWAP_H
1112
13#include <__concepts/class_or_enum.h>
14#include <__concepts/swappable.h>
1215#include <__config>
1316#include <__iterator/concepts.h>
1417#include <__iterator/iter_move.h>
1518#include <__iterator/iterator_traits.h>
1619#include <__iterator/readable_traits.h>
20#include <__type_traits/remove_cvref.h>
21#include <__utility/declval.h>
1722#include <__utility/forward.h>
1823#include <__utility/move.h>
19#include <concepts>
20#include <type_traits>
2124
2225#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2326# pragma GCC system_header
......@@ -38,6 +41,7 @@ namespace __iter_swap {
3841 concept __unqualified_iter_swap =
3942 (__class_or_enum<remove_cvref_t<_T1>> || __class_or_enum<remove_cvref_t<_T2>>) &&
4043 requires (_T1&& __x, _T2&& __y) {
44 // NOLINTNEXTLINE(libcpp-robust-against-adl) iter_swap ADL calls should only be made through ranges::iter_swap
4145 iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y));
4246 };
4347
......@@ -46,7 +50,9 @@ namespace __iter_swap {
4650 indirectly_readable<_T1> && indirectly_readable<_T2> &&
4751 swappable_with<iter_reference_t<_T1>, iter_reference_t<_T2>>;
4852
53
4954 struct __fn {
55 // NOLINTBEGIN(libcpp-robust-against-adl) iter_swap ADL calls should only be made through ranges::iter_swap
5056 template <class _T1, class _T2>
5157 requires __unqualified_iter_swap<_T1, _T2>
5258 _LIBCPP_HIDE_FROM_ABI
......@@ -55,6 +61,7 @@ namespace __iter_swap {
5561 {
5662 (void)iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y));
5763 }
64 // NOLINTEND(libcpp-robust-against-adl)
5865
5966 template <class _T1, class _T2>
6067 requires (!__unqualified_iter_swap<_T1, _T2>) &&
......@@ -75,7 +82,7 @@ namespace __iter_swap {
7582 constexpr void operator()(_T1&& __x, _T2&& __y) const
7683 noexcept(noexcept(iter_value_t<_T2>(ranges::iter_move(__y))) &&
7784 noexcept(*__y = ranges::iter_move(__x)) &&
78 noexcept(*_VSTD::forward<_T1>(__x) = declval<iter_value_t<_T2>>()))
85 noexcept(*_VSTD::forward<_T1>(__x) = std::declval<iter_value_t<_T2>>()))
7986 {
8087 iter_value_t<_T2> __old(ranges::iter_move(__y));
8188 *__y = ranges::iter_move(__x);
lib/libcxx/include/__iterator/iterator_traits.h+31-11
......@@ -10,12 +10,32 @@
1010#ifndef _LIBCPP___ITERATOR_ITERATOR_TRAITS_H
1111#define _LIBCPP___ITERATOR_ITERATOR_TRAITS_H
1212
13#include <__concepts/arithmetic.h>
14#include <__concepts/constructible.h>
15#include <__concepts/convertible_to.h>
16#include <__concepts/copyable.h>
17#include <__concepts/equality_comparable.h>
18#include <__concepts/same_as.h>
19#include <__concepts/totally_ordered.h>
1320#include <__config>
21#include <__fwd/pair.h>
1422#include <__iterator/incrementable_traits.h>
1523#include <__iterator/readable_traits.h>
16#include <concepts>
24#include <__type_traits/add_const.h>
25#include <__type_traits/common_reference.h>
26#include <__type_traits/conditional.h>
27#include <__type_traits/disjunction.h>
28#include <__type_traits/is_convertible.h>
29#include <__type_traits/is_object.h>
30#include <__type_traits/is_primary_template.h>
31#include <__type_traits/is_reference.h>
32#include <__type_traits/is_valid_expansion.h>
33#include <__type_traits/remove_const.h>
34#include <__type_traits/remove_cv.h>
35#include <__type_traits/remove_cvref.h>
36#include <__type_traits/void_t.h>
37#include <__utility/declval.h>
1738#include <cstddef>
18#include <type_traits>
1939
2040#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2141# pragma GCC system_header
......@@ -40,7 +60,7 @@ concept __dereferenceable = requires(_Tp& __t) {
4060
4161// [iterator.traits]
4262template<__dereferenceable _Tp>
43using iter_reference_t = decltype(*declval<_Tp&>());
63using iter_reference_t = decltype(*std::declval<_Tp&>());
4464
4565#endif // _LIBCPP_STD_VER > 17
4666
......@@ -107,11 +127,11 @@ struct __has_iterator_typedefs
107127{
108128private:
109129 template <class _Up> static false_type __test(...);
110 template <class _Up> static true_type __test(typename __void_t<typename _Up::iterator_category>::type* = 0,
111 typename __void_t<typename _Up::difference_type>::type* = 0,
112 typename __void_t<typename _Up::value_type>::type* = 0,
113 typename __void_t<typename _Up::reference>::type* = 0,
114 typename __void_t<typename _Up::pointer>::type* = 0);
130 template <class _Up> static true_type __test(__void_t<typename _Up::iterator_category>* = nullptr,
131 __void_t<typename _Up::difference_type>* = nullptr,
132 __void_t<typename _Up::value_type>* = nullptr,
133 __void_t<typename _Up::reference>* = nullptr,
134 __void_t<typename _Up::pointer>* = nullptr);
115135public:
116136 static const bool value = decltype(__test<_Tp>(0,0,0,0,0))::value;
117137};
......@@ -253,7 +273,7 @@ struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> { using type = typ
253273template<class _Ip>
254274 requires requires(_Ip& __i) { __i.operator->(); } && (!__has_member_pointer<_Ip>)
255275struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> {
256 using type = decltype(declval<_Ip&>().operator->());
276 using type = decltype(std::declval<_Ip&>().operator->());
257277};
258278
259279// Otherwise, `reference` names `iter-reference-t<I>`.
......@@ -407,7 +427,7 @@ requires is_object_v<_Tp>
407427struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*>
408428{
409429 typedef ptrdiff_t difference_type;
410 typedef typename remove_cv<_Tp>::type value_type;
430 typedef __remove_cv_t<_Tp> value_type;
411431 typedef _Tp* pointer;
412432 typedef _Tp& reference;
413433 typedef random_access_iterator_tag iterator_category;
......@@ -492,7 +512,7 @@ template<class _InputIterator>
492512using __iter_value_type = typename iterator_traits<_InputIterator>::value_type;
493513
494514template<class _InputIterator>
495using __iter_key_type = typename remove_const<typename iterator_traits<_InputIterator>::value_type::first_type>::type;
515using __iter_key_type = __remove_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>;
496516
497517template<class _InputIterator>
498518using __iter_mapped_type = typename iterator_traits<_InputIterator>::value_type::second_type;
lib/libcxx/include/__iterator/iterator_with_data.h created+100
......@@ -0,0 +1,100 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ITERATOR_ITERATOR_WITH_DATA_H
10#define _LIBCPP___ITERATOR_ITERATOR_WITH_DATA_H
11
12#include <__compare/compare_three_way_result.h>
13#include <__compare/three_way_comparable.h>
14#include <__config>
15#include <__iterator/concepts.h>
16#include <__iterator/incrementable_traits.h>
17#include <__iterator/iter_move.h>
18#include <__iterator/iter_swap.h>
19#include <__iterator/iterator_traits.h>
20#include <__iterator/readable_traits.h>
21#include <__utility/move.h>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27#if _LIBCPP_STD_VER >= 20
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30
31template <forward_iterator _Iterator, class _Data>
32class __iterator_with_data {
33 _Iterator __iter_{};
34 _Data __data_{};
35
36public:
37 using value_type = iter_value_t<_Iterator>;
38 using difference_type = iter_difference_t<_Iterator>;
39
40 _LIBCPP_HIDE_FROM_ABI __iterator_with_data() = default;
41
42 constexpr _LIBCPP_HIDE_FROM_ABI __iterator_with_data(_Iterator __iter, _Data __data)
43 : __iter_(std::move(__iter)), __data_(std::move(__data)) {}
44
45 constexpr _LIBCPP_HIDE_FROM_ABI _Iterator __get_iter() const { return __iter_; }
46
47 constexpr _LIBCPP_HIDE_FROM_ABI _Data __get_data() && { return std::move(__data_); }
48
49 friend constexpr _LIBCPP_HIDE_FROM_ABI bool
50 operator==(const __iterator_with_data& __lhs, const __iterator_with_data& __rhs) {
51 return __lhs.__iter_ == __rhs.__iter_;
52 }
53
54 constexpr _LIBCPP_HIDE_FROM_ABI __iterator_with_data& operator++() {
55 ++__iter_;
56 return *this;
57 }
58
59 constexpr _LIBCPP_HIDE_FROM_ABI __iterator_with_data operator++(int) {
60 auto __tmp = *this;
61 __iter_++;
62 return __tmp;
63 }
64
65 constexpr _LIBCPP_HIDE_FROM_ABI __iterator_with_data& operator--()
66 requires bidirectional_iterator<_Iterator>
67 {
68 --__iter_;
69 return *this;
70 }
71
72 constexpr _LIBCPP_HIDE_FROM_ABI __iterator_with_data operator--(int)
73 requires bidirectional_iterator<_Iterator>
74 {
75 auto __tmp = *this;
76 --__iter_;
77 return __tmp;
78 }
79
80 constexpr _LIBCPP_HIDE_FROM_ABI iter_reference_t<_Iterator> operator*() const { return *__iter_; }
81
82 _LIBCPP_HIDE_FROM_ABI friend constexpr iter_rvalue_reference_t<_Iterator>
83 iter_move(const __iterator_with_data& __iter) noexcept(noexcept(ranges::iter_move(__iter.__iter_))) {
84 return ranges::iter_move(__iter.__iter_);
85 }
86
87 _LIBCPP_HIDE_FROM_ABI friend constexpr void
88 iter_swap(const __iterator_with_data& __lhs,
89 const __iterator_with_data& __rhs) noexcept(noexcept(ranges::iter_swap(__lhs.__iter_, __rhs.__iter_)))
90 requires indirectly_swappable<_Iterator>
91 {
92 return ranges::iter_swap(__lhs.__data_, __rhs.__iter_);
93 }
94};
95
96_LIBCPP_END_NAMESPACE_STD
97
98#endif // _LIBCPP_STD_VER >= 20
99
100#endif // _LIBCPP___ITERATOR_ITERATOR_WITH_DATA_H
lib/libcxx/include/__iterator/move_iterator.h+37-28
......@@ -24,8 +24,16 @@
2424#include <__iterator/iterator_traits.h>
2525#include <__iterator/move_sentinel.h>
2626#include <__iterator/readable_traits.h>
27#include <__type_traits/conditional.h>
28#include <__type_traits/enable_if.h>
29#include <__type_traits/is_assignable.h>
30#include <__type_traits/is_constructible.h>
31#include <__type_traits/is_convertible.h>
32#include <__type_traits/is_reference.h>
33#include <__type_traits/is_same.h>
34#include <__type_traits/remove_reference.h>
35#include <__utility/declval.h>
2736#include <__utility/move.h>
28#include <type_traits>
2937
3038#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3139# pragma GCC system_header
......@@ -49,7 +57,7 @@ struct __move_iter_category_base<_Iter> {
4957
5058template<class _Iter, class _Sent>
5159concept __move_iter_comparable = requires {
52 { declval<const _Iter&>() == declval<_Sent>() } -> convertible_to<bool>;
60 { std::declval<const _Iter&>() == std::declval<_Sent>() } -> convertible_to<bool>;
5361};
5462#endif // _LIBCPP_STD_VER > 17
5563
......@@ -82,18 +90,18 @@ public:
8290 typedef typename iterator_traits<iterator_type>::reference __reference;
8391 typedef typename conditional<
8492 is_reference<__reference>::value,
85 typename remove_reference<__reference>::type&&,
93 __libcpp_remove_reference_t<__reference>&&,
8694 __reference
8795 >::type reference;
8896#endif // _LIBCPP_STD_VER > 17
8997
90 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
98 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
9199 explicit move_iterator(_Iter __i) : __current_(std::move(__i)) {}
92100
93 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
101 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
94102 move_iterator& operator++() { ++__current_; return *this; }
95103
96 _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
104 _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
97105 pointer operator->() const { return __current_; }
98106
99107#if _LIBCPP_STD_VER > 17
......@@ -133,13 +141,13 @@ public:
133141 _LIBCPP_HIDE_FROM_ABI constexpr
134142 void operator++(int) { ++__current_; }
135143#else
136 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
144 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
137145 move_iterator() : __current_() {}
138146
139147 template <class _Up, class = __enable_if_t<
140148 !is_same<_Up, _Iter>::value && is_convertible<const _Up&, _Iter>::value
141149 > >
142 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
150 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
143151 move_iterator(const move_iterator<_Up>& __u) : __current_(__u.base()) {}
144152
145153 template <class _Up, class = __enable_if_t<
......@@ -147,35 +155,35 @@ public:
147155 is_convertible<const _Up&, _Iter>::value &&
148156 is_assignable<_Iter&, const _Up&>::value
149157 > >
150 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
158 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
151159 move_iterator& operator=(const move_iterator<_Up>& __u) {
152160 __current_ = __u.base();
153161 return *this;
154162 }
155163
156 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
164 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
157165 _Iter base() const { return __current_; }
158166
159 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
167 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
160168 reference operator*() const { return static_cast<reference>(*__current_); }
161 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
169 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
162170 reference operator[](difference_type __n) const { return static_cast<reference>(__current_[__n]); }
163171
164 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
172 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
165173 move_iterator operator++(int) { move_iterator __tmp(*this); ++__current_; return __tmp; }
166174#endif // _LIBCPP_STD_VER > 17
167175
168 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
176 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
169177 move_iterator& operator--() { --__current_; return *this; }
170 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
178 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
171179 move_iterator operator--(int) { move_iterator __tmp(*this); --__current_; return __tmp; }
172 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
180 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
173181 move_iterator operator+(difference_type __n) const { return move_iterator(__current_ + __n); }
174 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
182 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
175183 move_iterator& operator+=(difference_type __n) { __current_ += __n; return *this; }
176 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
184 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
177185 move_iterator operator-(difference_type __n) const { return move_iterator(__current_ - __n); }
178 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
186 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
179187 move_iterator& operator-=(difference_type __n) { __current_ -= __n; return *this; }
180188
181189#if _LIBCPP_STD_VER > 17
......@@ -222,9 +230,10 @@ private:
222230
223231 _Iter __current_;
224232};
233_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(move_iterator);
225234
226235template <class _Iter1, class _Iter2>
227inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
236inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
228237bool operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
229238{
230239 return __x.base() == __y.base();
......@@ -232,7 +241,7 @@ bool operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& _
232241
233242#if _LIBCPP_STD_VER <= 17
234243template <class _Iter1, class _Iter2>
235inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
244inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
236245bool operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
237246{
238247 return __x.base() != __y.base();
......@@ -240,28 +249,28 @@ bool operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& _
240249#endif // _LIBCPP_STD_VER <= 17
241250
242251template <class _Iter1, class _Iter2>
243inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
252inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
244253bool operator<(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
245254{
246255 return __x.base() < __y.base();
247256}
248257
249258template <class _Iter1, class _Iter2>
250inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
259inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
251260bool operator>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
252261{
253262 return __x.base() > __y.base();
254263}
255264
256265template <class _Iter1, class _Iter2>
257inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
266inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
258267bool operator<=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
259268{
260269 return __x.base() <= __y.base();
261270}
262271
263272template <class _Iter1, class _Iter2>
264inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
273inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
265274bool operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
266275{
267276 return __x.base() >= __y.base();
......@@ -279,7 +288,7 @@ auto operator<=>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>&
279288
280289#ifndef _LIBCPP_CXX03_LANG
281290template <class _Iter1, class _Iter2>
282inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
291inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
283292auto operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
284293 -> decltype(__x.base() - __y.base())
285294{
......@@ -305,7 +314,7 @@ move_iterator<_Iter> operator+(iter_difference_t<_Iter> __n, const move_iterator
305314}
306315#else
307316template <class _Iter>
308inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
317inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
309318move_iterator<_Iter>
310319operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterator<_Iter>& __x)
311320{
......@@ -314,7 +323,7 @@ operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterato
314323#endif // _LIBCPP_STD_VER > 17
315324
316325template <class _Iter>
317inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
326inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
318327move_iterator<_Iter>
319328make_move_iterator(_Iter __i)
320329{
lib/libcxx/include/__iterator/move_sentinel.h+2
......@@ -50,6 +50,8 @@ private:
5050 _Sent __last_ = _Sent();
5151};
5252
53_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(move_sentinel);
54
5355#endif // _LIBCPP_STD_VER > 17
5456
5557_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/next.h+4-4
......@@ -16,7 +16,7 @@
1616#include <__iterator/concepts.h>
1717#include <__iterator/incrementable_traits.h>
1818#include <__iterator/iterator_traits.h>
19#include <type_traits>
19#include <__type_traits/enable_if.h>
2020
2121#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2222# pragma GCC system_header
......@@ -25,7 +25,7 @@
2525_LIBCPP_BEGIN_NAMESPACE_STD
2626
2727template <class _InputIter>
28inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
28inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
2929 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value, _InputIter>::type
3030 next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) {
3131 _LIBCPP_ASSERT(__n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value,
......@@ -35,7 +35,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
3535 return __x;
3636}
3737
38#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
38#if _LIBCPP_STD_VER > 17
3939
4040// [range.iter.op.next]
4141
......@@ -77,7 +77,7 @@ inline namespace __cpo {
7777} // namespace __cpo
7878} // namespace ranges
7979
80#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
80#endif // _LIBCPP_STD_VER > 17
8181
8282_LIBCPP_END_NAMESPACE_STD
8383
lib/libcxx/include/__iterator/ostreambuf_iterator.h+1-1
......@@ -65,7 +65,7 @@ public:
6565
6666 template <class _Ch, class _Tr>
6767 friend
68 _LIBCPP_HIDDEN
68 _LIBCPP_HIDE_FROM_ABI
6969 ostreambuf_iterator<_Ch, _Tr>
7070 __pad_and_output(ostreambuf_iterator<_Ch, _Tr> __s,
7171 const _Ch* __ob, const _Ch* __op, const _Ch* __oe,
lib/libcxx/include/__iterator/prev.h+4-4
......@@ -16,7 +16,7 @@
1616#include <__iterator/concepts.h>
1717#include <__iterator/incrementable_traits.h>
1818#include <__iterator/iterator_traits.h>
19#include <type_traits>
19#include <__type_traits/enable_if.h>
2020
2121#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2222# pragma GCC system_header
......@@ -25,7 +25,7 @@
2525_LIBCPP_BEGIN_NAMESPACE_STD
2626
2727template <class _InputIter>
28inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
28inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
2929 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value, _InputIter>::type
3030 prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) {
3131 _LIBCPP_ASSERT(__n <= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value,
......@@ -34,7 +34,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
3434 return __x;
3535}
3636
37#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
37#if _LIBCPP_STD_VER > 17
3838
3939// [range.iter.op.prev]
4040
......@@ -70,7 +70,7 @@ inline namespace __cpo {
7070} // namespace __cpo
7171} // namespace ranges
7272
73#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
73#endif // _LIBCPP_STD_VER > 17
7474
7575_LIBCPP_END_NAMESPACE_STD
7676
lib/libcxx/include/__iterator/projected.h+2-1
......@@ -6,13 +6,14 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___ITERATOR_PROJECTED_H
1011#define _LIBCPP___ITERATOR_PROJECTED_H
1112
1213#include <__config>
1314#include <__iterator/concepts.h>
1415#include <__iterator/incrementable_traits.h>
15#include <type_traits>
16#include <__type_traits/remove_cvref.h>
1617
1718#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1819# pragma GCC system_header
lib/libcxx/include/__iterator/readable_traits.h+8-2
......@@ -10,9 +10,15 @@
1010#ifndef _LIBCPP___ITERATOR_READABLE_TRAITS_H
1111#define _LIBCPP___ITERATOR_READABLE_TRAITS_H
1212
13#include <__concepts/same_as.h>
1314#include <__config>
14#include <concepts>
15#include <type_traits>
15#include <__type_traits/conditional.h>
16#include <__type_traits/is_array.h>
17#include <__type_traits/is_object.h>
18#include <__type_traits/is_primary_template.h>
19#include <__type_traits/remove_cv.h>
20#include <__type_traits/remove_cvref.h>
21#include <__type_traits/remove_extent.h>
1622
1723#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1824# pragma GCC system_header
lib/libcxx/include/__iterator/reverse_access.h+10-10
......@@ -24,70 +24,70 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2424#if _LIBCPP_STD_VER > 11
2525
2626template <class _Tp, size_t _Np>
27_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
27_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
2828reverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np])
2929{
3030 return reverse_iterator<_Tp*>(__array + _Np);
3131}
3232
3333template <class _Tp, size_t _Np>
34_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
34_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
3535reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np])
3636{
3737 return reverse_iterator<_Tp*>(__array);
3838}
3939
4040template <class _Ep>
41_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
41_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
4242reverse_iterator<const _Ep*> rbegin(initializer_list<_Ep> __il)
4343{
4444 return reverse_iterator<const _Ep*>(__il.end());
4545}
4646
4747template <class _Ep>
48_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
48_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
4949reverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il)
5050{
5151 return reverse_iterator<const _Ep*>(__il.begin());
5252}
5353
5454template <class _Cp>
55_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
55_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
5656auto rbegin(_Cp& __c) -> decltype(__c.rbegin())
5757{
5858 return __c.rbegin();
5959}
6060
6161template <class _Cp>
62_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
62_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
6363auto rbegin(const _Cp& __c) -> decltype(__c.rbegin())
6464{
6565 return __c.rbegin();
6666}
6767
6868template <class _Cp>
69_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
69_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
7070auto rend(_Cp& __c) -> decltype(__c.rend())
7171{
7272 return __c.rend();
7373}
7474
7575template <class _Cp>
76_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
76_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
7777auto rend(const _Cp& __c) -> decltype(__c.rend())
7878{
7979 return __c.rend();
8080}
8181
8282template <class _Cp>
83_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
83_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
8484auto crbegin(const _Cp& __c) -> decltype(_VSTD::rbegin(__c))
8585{
8686 return _VSTD::rbegin(__c);
8787}
8888
8989template <class _Cp>
90_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
90_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
9191auto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c))
9292{
9393 return _VSTD::rend(__c);
lib/libcxx/include/__iterator/reverse_iterator.h+47-48
......@@ -25,12 +25,20 @@
2525#include <__iterator/next.h>
2626#include <__iterator/prev.h>
2727#include <__iterator/readable_traits.h>
28#include <__iterator/segmented_iterator.h>
2829#include <__memory/addressof.h>
2930#include <__ranges/access.h>
3031#include <__ranges/concepts.h>
3132#include <__ranges/subrange.h>
33#include <__type_traits/conditional.h>
34#include <__type_traits/enable_if.h>
35#include <__type_traits/is_assignable.h>
36#include <__type_traits/is_convertible.h>
37#include <__type_traits/is_nothrow_copy_constructible.h>
38#include <__type_traits/is_pointer.h>
39#include <__type_traits/is_same.h>
40#include <__utility/declval.h>
3241#include <__utility/move.h>
33#include <type_traits>
3442
3543#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3644# pragma GCC system_header
......@@ -52,7 +60,7 @@ class _LIBCPP_TEMPLATE_VIS reverse_iterator
5260_LIBCPP_SUPPRESS_DEPRECATED_POP
5361private:
5462#ifndef _LIBCPP_ABI_NO_ITERATOR_BASES
55 _Iter __t; // no longer used as of LWG #2360, not removed due to ABI break
63 _Iter __t_; // no longer used as of LWG #2360, not removed due to ABI break
5664#endif
5765
5866#if _LIBCPP_STD_VER > 17
......@@ -81,18 +89,18 @@ public:
8189#endif
8290
8391#ifndef _LIBCPP_ABI_NO_ITERATOR_BASES
84 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
85 reverse_iterator() : __t(), current() {}
92 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
93 reverse_iterator() : __t_(), current() {}
8694
87 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
88 explicit reverse_iterator(_Iter __x) : __t(__x), current(__x) {}
95 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
96 explicit reverse_iterator(_Iter __x) : __t_(__x), current(__x) {}
8997
9098 template <class _Up, class = __enable_if_t<
9199 !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value
92100 > >
93 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
101 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
94102 reverse_iterator(const reverse_iterator<_Up>& __u)
95 : __t(__u.base()), current(__u.base())
103 : __t_(__u.base()), current(__u.base())
96104 { }
97105
98106 template <class _Up, class = __enable_if_t<
......@@ -100,22 +108,22 @@ public:
100108 is_convertible<_Up const&, _Iter>::value &&
101109 is_assignable<_Iter&, _Up const&>::value
102110 > >
103 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
111 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
104112 reverse_iterator& operator=(const reverse_iterator<_Up>& __u) {
105 __t = current = __u.base();
113 __t_ = current = __u.base();
106114 return *this;
107115 }
108116#else
109 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
117 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
110118 reverse_iterator() : current() {}
111119
112 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
120 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
113121 explicit reverse_iterator(_Iter __x) : current(__x) {}
114122
115123 template <class _Up, class = __enable_if_t<
116124 !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value
117125 > >
118 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
126 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
119127 reverse_iterator(const reverse_iterator<_Up>& __u)
120128 : current(__u.base())
121129 { }
......@@ -125,15 +133,15 @@ public:
125133 is_convertible<_Up const&, _Iter>::value &&
126134 is_assignable<_Iter&, _Up const&>::value
127135 > >
128 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
136 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
129137 reverse_iterator& operator=(const reverse_iterator<_Up>& __u) {
130138 current = __u.base();
131139 return *this;
132140 }
133141#endif
134 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
142 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
135143 _Iter base() const {return current;}
136 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
144 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
137145 reference operator*() const {_Iter __tmp = current; return *--__tmp;}
138146
139147#if _LIBCPP_STD_VER > 17
......@@ -148,36 +156,36 @@ public:
148156 }
149157 }
150158#else
151 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
159 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
152160 pointer operator->() const {
153161 return std::addressof(operator*());
154162 }
155163#endif // _LIBCPP_STD_VER > 17
156164
157 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
165 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
158166 reverse_iterator& operator++() {--current; return *this;}
159 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
167 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
160168 reverse_iterator operator++(int) {reverse_iterator __tmp(*this); --current; return __tmp;}
161 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
169 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
162170 reverse_iterator& operator--() {++current; return *this;}
163 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
171 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
164172 reverse_iterator operator--(int) {reverse_iterator __tmp(*this); ++current; return __tmp;}
165 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
173 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
166174 reverse_iterator operator+(difference_type __n) const {return reverse_iterator(current - __n);}
167 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
175 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
168176 reverse_iterator& operator+=(difference_type __n) {current -= __n; return *this;}
169 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
177 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
170178 reverse_iterator operator-(difference_type __n) const {return reverse_iterator(current + __n);}
171 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
179 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
172180 reverse_iterator& operator-=(difference_type __n) {current += __n; return *this;}
173 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
181 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
174182 reference operator[](difference_type __n) const {return *(*this + __n);}
175183
176184#if _LIBCPP_STD_VER > 17
177185 _LIBCPP_HIDE_FROM_ABI friend constexpr
178186 iter_rvalue_reference_t<_Iter> iter_move(const reverse_iterator& __i)
179187 noexcept(is_nothrow_copy_constructible_v<_Iter> &&
180 noexcept(ranges::iter_move(--declval<_Iter&>()))) {
188 noexcept(ranges::iter_move(--std::declval<_Iter&>()))) {
181189 auto __tmp = __i.base();
182190 return ranges::iter_move(--__tmp);
183191 }
......@@ -187,7 +195,7 @@ public:
187195 void iter_swap(const reverse_iterator& __x, const reverse_iterator<_Iter2>& __y)
188196 noexcept(is_nothrow_copy_constructible_v<_Iter> &&
189197 is_nothrow_copy_constructible_v<_Iter2> &&
190 noexcept(ranges::iter_swap(--declval<_Iter&>(), --declval<_Iter2&>()))) {
198 noexcept(ranges::iter_swap(--std::declval<_Iter&>(), --std::declval<_Iter2&>()))) {
191199 auto __xtmp = __x.base();
192200 auto __ytmp = __y.base();
193201 ranges::iter_swap(--__xtmp, --__ytmp);
......@@ -195,14 +203,8 @@ public:
195203#endif // _LIBCPP_STD_VER > 17
196204};
197205
198template <class _Iter>
199struct __is_reverse_iterator : false_type {};
200
201template <class _Iter>
202struct __is_reverse_iterator<reverse_iterator<_Iter> > : true_type {};
203
204206template <class _Iter1, class _Iter2>
205inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
207inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
206208bool
207209operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
208210#if _LIBCPP_STD_VER > 17
......@@ -215,7 +217,7 @@ operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>&
215217}
216218
217219template <class _Iter1, class _Iter2>
218inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
220inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
219221bool
220222operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
221223#if _LIBCPP_STD_VER > 17
......@@ -228,7 +230,7 @@ operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& _
228230}
229231
230232template <class _Iter1, class _Iter2>
231inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
233inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
232234bool
233235operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
234236#if _LIBCPP_STD_VER > 17
......@@ -241,7 +243,7 @@ operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>&
241243}
242244
243245template <class _Iter1, class _Iter2>
244inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
246inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
245247bool
246248operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
247249#if _LIBCPP_STD_VER > 17
......@@ -254,7 +256,7 @@ operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& _
254256}
255257
256258template <class _Iter1, class _Iter2>
257inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
259inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
258260bool
259261operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
260262#if _LIBCPP_STD_VER > 17
......@@ -267,7 +269,7 @@ operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>&
267269}
268270
269271template <class _Iter1, class _Iter2>
270inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
272inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
271273bool
272274operator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
273275#if _LIBCPP_STD_VER > 17
......@@ -291,7 +293,7 @@ operator<=>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>&
291293
292294#ifndef _LIBCPP_CXX03_LANG
293295template <class _Iter1, class _Iter2>
294inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
296inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
295297auto
296298operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
297299-> decltype(__y.base() - __x.base())
......@@ -309,7 +311,7 @@ operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& _
309311#endif
310312
311313template <class _Iter>
312inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
314inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
313315reverse_iterator<_Iter>
314316operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_iterator<_Iter>& __x)
315317{
......@@ -324,7 +326,7 @@ inline constexpr bool disable_sized_sentinel_for<reverse_iterator<_Iter1>, rever
324326
325327#if _LIBCPP_STD_VER > 11
326328template <class _Iter>
327inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
329inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
328330reverse_iterator<_Iter> make_reverse_iterator(_Iter __i)
329331{
330332 return reverse_iterator<_Iter>(__i);
......@@ -394,7 +396,7 @@ public:
394396 _LIBCPP_HIDE_FROM_ABI friend constexpr
395397 iter_rvalue_reference_t<_Iter> iter_move(const __unconstrained_reverse_iterator& __i)
396398 noexcept(is_nothrow_copy_constructible_v<_Iter> &&
397 noexcept(ranges::iter_move(--declval<_Iter&>()))) {
399 noexcept(ranges::iter_move(--std::declval<_Iter&>()))) {
398400 auto __tmp = __i.base();
399401 return ranges::iter_move(--__tmp);
400402 }
......@@ -478,9 +480,6 @@ public:
478480 }
479481};
480482
481template <class _Iter>
482struct __is_reverse_iterator<__unconstrained_reverse_iterator<_Iter>> : true_type {};
483
484483#endif // _LIBCPP_STD_VER <= 17
485484
486485template <template <class> class _RevIter1, template <class> class _RevIter2, class _Iter>
......@@ -499,7 +498,7 @@ struct __unwrap_reverse_iter_impl {
499498 }
500499};
501500
502#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
501#if _LIBCPP_STD_VER > 17
503502template <ranges::bidirectional_range _Range>
504503_LIBCPP_HIDE_FROM_ABI constexpr ranges::
505504 subrange<reverse_iterator<ranges::iterator_t<_Range>>, reverse_iterator<ranges::iterator_t<_Range>>>
lib/libcxx/include/__iterator/segmented_iterator.h created+79
......@@ -0,0 +1,79 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___SEGMENTED_ITERATOR_H
10#define _LIBCPP___SEGMENTED_ITERATOR_H
11
12// Segmented iterators are iterators over (not necessarily contiguous) sub-ranges.
13//
14// For example, std::deque stores its data into multiple blocks of contiguous memory,
15// which are not stored contiguously themselves. The concept of segmented iterators
16// allows algorithms to operate over these multi-level iterators natively, opening the
17// door to various optimizations. See http://lafstern.org/matt/segmented.pdf for details.
18//
19// If __segmented_iterator_traits can be instantiated, the following functions and associated types must be provided:
20// - Traits::__local_iterator
21// The type of iterators used to iterate inside a segment.
22//
23// - Traits::__segment_iterator
24// The type of iterators used to iterate over segments.
25// Segment iterators can be forward iterators or bidirectional iterators, depending on the
26// underlying data structure.
27//
28// - static __segment_iterator Traits::__segment(It __it)
29// Returns an iterator to the segment that the provided iterator is in.
30//
31// - static __local_iterator Traits::__local(It __it)
32// Returns the local iterator pointing to the element that the provided iterator points to.
33//
34// - static __local_iterator Traits::__begin(__segment_iterator __it)
35// Returns the local iterator to the beginning of the segment that the provided iterator is pointing into.
36//
37// - static __local_iterator Traits::__end(__segment_iterator __it)
38// Returns the one-past-the-end local iterator to the segment that the provided iterator is pointing into.
39//
40// - static It Traits::__compose(__segment_iterator, __local_iterator)
41// Returns the iterator composed of the segment iterator and local iterator.
42
43#include <__config>
44#include <__type_traits/integral_constant.h>
45#include <cstddef>
46
47#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
48# pragma GCC system_header
49#endif
50
51_LIBCPP_BEGIN_NAMESPACE_STD
52
53template <class _Iterator>
54struct __segmented_iterator_traits;
55/* exposition-only:
56{
57 using __segment_iterator = ...;
58 using __local_iterator = ...;
59
60 static __segment_iterator __segment(_Iterator);
61 static __local_iterator __local(_Iterator);
62 static __local_iterator __begin(__segment_iterator);
63 static __local_iterator __end(__segment_iterator);
64 static _Iterator __compose(__segment_iterator, __local_iterator);
65};
66*/
67
68template <class _Tp, size_t = 0>
69struct __has_specialization : false_type {};
70
71template <class _Tp>
72struct __has_specialization<_Tp, sizeof(_Tp) * 0> : true_type {};
73
74template <class _Iterator>
75using __is_segmented_iterator = __has_specialization<__segmented_iterator_traits<_Iterator> >;
76
77_LIBCPP_END_NAMESPACE_STD
78
79#endif // _LIBCPP___SEGMENTED_ITERATOR_H
lib/libcxx/include/__iterator/size.h+2-1
......@@ -11,8 +11,9 @@
1111#define _LIBCPP___ITERATOR_SIZE_H
1212
1313#include <__config>
14#include <__type_traits/common_type.h>
15#include <__type_traits/make_signed.h>
1416#include <cstddef>
15#include <type_traits>
1617
1718#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1819# pragma GCC system_header
lib/libcxx/include/__iterator/wrap_iter.h+36-35
......@@ -15,7 +15,8 @@
1515#include <__iterator/iterator_traits.h>
1616#include <__memory/addressof.h>
1717#include <__memory/pointer_traits.h>
18#include <type_traits>
18#include <__type_traits/enable_if.h>
19#include <__type_traits/is_convertible.h>
1920
2021#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2122# pragma GCC system_header
......@@ -38,17 +39,17 @@ public:
3839#endif
3940
4041private:
41 iterator_type __i;
42 iterator_type __i_;
4243public:
43 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter() _NOEXCEPT
44 : __i()
44 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter() _NOEXCEPT
45 : __i_()
4546 {
4647 _VSTD::__debug_db_insert_i(this);
4748 }
48 template <class _Up> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
49 template <class _Up> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
4950 __wrap_iter(const __wrap_iter<_Up>& __u,
5051 typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = nullptr) _NOEXCEPT
51 : __i(__u.base())
52 : __i_(__u.base())
5253 {
5354#ifdef _LIBCPP_ENABLE_DEBUG_MODE
5455 if (!__libcpp_is_constant_evaluated())
......@@ -56,87 +57,87 @@ public:
5657#endif
5758 }
5859#ifdef _LIBCPP_ENABLE_DEBUG_MODE
59 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
60 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
6061 __wrap_iter(const __wrap_iter& __x)
61 : __i(__x.base())
62 : __i_(__x.base())
6263 {
6364 if (!__libcpp_is_constant_evaluated())
6465 __get_db()->__iterator_copy(this, _VSTD::addressof(__x));
6566 }
66 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
67 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
6768 __wrap_iter& operator=(const __wrap_iter& __x)
6869 {
6970 if (this != _VSTD::addressof(__x))
7071 {
7172 if (!__libcpp_is_constant_evaluated())
7273 __get_db()->__iterator_copy(this, _VSTD::addressof(__x));
73 __i = __x.__i;
74 __i_ = __x.__i_;
7475 }
7576 return *this;
7677 }
77 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
78 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
7879 ~__wrap_iter()
7980 {
8081 if (!__libcpp_is_constant_evaluated())
8182 __get_db()->__erase_i(this);
8283 }
8384#endif
84 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference operator*() const _NOEXCEPT
85 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT
8586 {
8687 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
8788 "Attempted to dereference a non-dereferenceable iterator");
88 return *__i;
89 return *__i_;
8990 }
90 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 pointer operator->() const _NOEXCEPT
91 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pointer operator->() const _NOEXCEPT
9192 {
9293 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
9394 "Attempted to dereference a non-dereferenceable iterator");
94 return _VSTD::__to_address(__i);
95 return _VSTD::__to_address(__i_);
9596 }
96 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter& operator++() _NOEXCEPT
97 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter& operator++() _NOEXCEPT
9798 {
9899 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
99100 "Attempted to increment a non-incrementable iterator");
100 ++__i;
101 ++__i_;
101102 return *this;
102103 }
103 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter operator++(int) _NOEXCEPT
104 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter operator++(int) _NOEXCEPT
104105 {__wrap_iter __tmp(*this); ++(*this); return __tmp;}
105106
106 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter& operator--() _NOEXCEPT
107 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter& operator--() _NOEXCEPT
107108 {
108109 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__decrementable(this),
109110 "Attempted to decrement a non-decrementable iterator");
110 --__i;
111 --__i_;
111112 return *this;
112113 }
113 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter operator--(int) _NOEXCEPT
114 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter operator--(int) _NOEXCEPT
114115 {__wrap_iter __tmp(*this); --(*this); return __tmp;}
115 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter operator+ (difference_type __n) const _NOEXCEPT
116 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter operator+ (difference_type __n) const _NOEXCEPT
116117 {__wrap_iter __w(*this); __w += __n; return __w;}
117 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter& operator+=(difference_type __n) _NOEXCEPT
118 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter& operator+=(difference_type __n) _NOEXCEPT
118119 {
119120 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__addable(this, __n),
120121 "Attempted to add/subtract an iterator outside its valid range");
121 __i += __n;
122 __i_ += __n;
122123 return *this;
123124 }
124 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter operator- (difference_type __n) const _NOEXCEPT
125 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter operator- (difference_type __n) const _NOEXCEPT
125126 {return *this + (-__n);}
126 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter& operator-=(difference_type __n) _NOEXCEPT
127 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter& operator-=(difference_type __n) _NOEXCEPT
127128 {*this += -__n; return *this;}
128 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference operator[](difference_type __n) const _NOEXCEPT
129 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator[](difference_type __n) const _NOEXCEPT
129130 {
130131 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__subscriptable(this, __n),
131132 "Attempted to subscript an iterator outside its valid range");
132 return __i[__n];
133 return __i_[__n];
133134 }
134135
135 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 iterator_type base() const _NOEXCEPT {return __i;}
136 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 iterator_type base() const _NOEXCEPT {return __i_;}
136137
137138private:
138 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
139 explicit __wrap_iter(const void* __p, iterator_type __x) _NOEXCEPT : __i(__x)
139 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
140 explicit __wrap_iter(const void* __p, iterator_type __x) _NOEXCEPT : __i_(__x)
140141 {
141142 (void)__p;
142143#ifdef _LIBCPP_ENABLE_DEBUG_MODE
......@@ -166,7 +167,7 @@ bool operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y)
166167}
167168
168169template <class _Iter1>
169_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
170_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
170171bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
171172{
172173 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__less_than_comparable(_VSTD::addressof(__x), _VSTD::addressof(__y)),
......@@ -175,7 +176,7 @@ bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _
175176}
176177
177178template <class _Iter1, class _Iter2>
178_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
179_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
179180bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
180181{
181182 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
......@@ -240,7 +241,7 @@ bool operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y)
240241}
241242
242243template <class _Iter1, class _Iter2>
243_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
244_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
244245#ifndef _LIBCPP_CXX03_LANG
245246auto operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
246247 -> decltype(__x.base() - __y.base())
......@@ -255,7 +256,7 @@ operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXC
255256}
256257
257258template <class _Iter1>
258_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
259_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
259260__wrap_iter<_Iter1> operator+(typename __wrap_iter<_Iter1>::difference_type __n, __wrap_iter<_Iter1> __x) _NOEXCEPT
260261{
261262 __x += __n;
lib/libcxx/include/__locale+76-72
......@@ -15,13 +15,15 @@
1515#include <cctype>
1616#include <cstdint>
1717#include <locale.h>
18#include <memory>
1918#include <mutex>
2019#include <string>
2120
21// Some platforms require more includes than others. Keep the includes on all plaforms for now.
22#include <cstddef>
23#include <cstring>
24
2225#if defined(_LIBCPP_MSVCRT_LIKE)
2326# include <__support/win32/locale_win32.h>
24# include <cstring>
2527#elif defined(_AIX) || defined(__MVS__)
2628# include <__support/ibm/xlocale.h>
2729#elif defined(__ANDROID__)
......@@ -33,7 +35,7 @@
3335# include <__support/newlib/xlocale.h>
3436#elif defined(__OpenBSD__)
3537# include <__support/openbsd/xlocale.h>
36#elif (defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__))
38#elif (defined(__APPLE__) || defined(__FreeBSD__))
3739# include <xlocale.h>
3840#elif defined(__Fuchsia__)
3941# include <__support/fuchsia/xlocale.h>
......@@ -191,12 +193,12 @@ protected:
191193 explicit facet(size_t __refs = 0)
192194 : __shared_count(static_cast<long>(__refs)-1) {}
193195
194 virtual ~facet();
196 ~facet() override;
195197
196198// facet(const facet&) = delete; // effectively done in __shared_count
197199// void operator=(const facet&) = delete;
198200private:
199 virtual void __on_zero_shared() _NOEXCEPT;
201 void __on_zero_shared() _NOEXCEPT override;
200202};
201203
202204class _LIBCPP_TYPE_VIS locale::id
......@@ -291,7 +293,7 @@ public:
291293 static locale::id id;
292294
293295protected:
294 ~collate();
296 ~collate() override;
295297 virtual int do_compare(const char_type* __lo1, const char_type* __hi1,
296298 const char_type* __lo2, const char_type* __hi2) const;
297299 virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const
......@@ -350,7 +352,7 @@ template <>
350352class _LIBCPP_TYPE_VIS collate_byname<char>
351353 : public collate<char>
352354{
353 locale_t __l;
355 locale_t __l_;
354356public:
355357 typedef char char_type;
356358 typedef basic_string<char_type> string_type;
......@@ -359,10 +361,10 @@ public:
359361 explicit collate_byname(const string& __n, size_t __refs = 0);
360362
361363protected:
362 ~collate_byname();
363 virtual int do_compare(const char_type* __lo1, const char_type* __hi1,
364 const char_type* __lo2, const char_type* __hi2) const;
365 virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const;
364 ~collate_byname() override;
365 int do_compare(const char_type* __lo1, const char_type* __hi1,
366 const char_type* __lo2, const char_type* __hi2) const override;
367 string_type do_transform(const char_type* __lo, const char_type* __hi) const override;
366368};
367369
368370#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
......@@ -370,7 +372,7 @@ template <>
370372class _LIBCPP_TYPE_VIS collate_byname<wchar_t>
371373 : public collate<wchar_t>
372374{
373 locale_t __l;
375 locale_t __l_;
374376public:
375377 typedef wchar_t char_type;
376378 typedef basic_string<char_type> string_type;
......@@ -379,11 +381,11 @@ public:
379381 explicit collate_byname(const string& __n, size_t __refs = 0);
380382
381383protected:
382 ~collate_byname();
384 ~collate_byname() override;
383385
384 virtual int do_compare(const char_type* __lo1, const char_type* __hi1,
385 const char_type* __lo2, const char_type* __hi2) const;
386 virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const;
386 int do_compare(const char_type* __lo1, const char_type* __hi1,
387 const char_type* __lo2, const char_type* __hi2) const override;
388 string_type do_transform(const char_type* __lo, const char_type* __hi) const override;
387389};
388390#endif
389391
......@@ -453,10 +455,10 @@ public:
453455 static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used
454456# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
455457# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
456#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__DragonFly__)
458#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
457459# ifdef __APPLE__
458460 typedef __uint32_t mask;
459# elif defined(__FreeBSD__) || defined(__DragonFly__)
461# elif defined(__FreeBSD__)
460462 typedef unsigned long mask;
461463# elif defined(__EMSCRIPTEN__) || defined(__NetBSD__)
462464 typedef unsigned short mask;
......@@ -510,7 +512,8 @@ public:
510512 static const mask punct = _P;
511513 static const mask xdigit = _X | _N;
512514 static const mask blank = _B;
513 static const mask __regex_word = 0x80;
515 // mask is already fully saturated, use a different type in regex_type_traits.
516 static const unsigned short __regex_word = 0x100;
514517# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
515518# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
516519# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT
......@@ -549,7 +552,8 @@ public:
549552
550553 _LIBCPP_INLINE_VISIBILITY ctype_base() {}
551554
552 static_assert((__regex_word & ~(space | print | cntrl | upper | lower | alpha | digit | punct | xdigit | blank)) == __regex_word,
555 static_assert((__regex_word & ~(std::make_unsigned<mask>::type)(space | print | cntrl | upper | lower | alpha |
556 digit | punct | xdigit | blank)) == __regex_word,
553557 "__regex_word can't overlap other bits");
554558};
555559
......@@ -643,7 +647,7 @@ public:
643647 static locale::id id;
644648
645649protected:
646 ~ctype();
650 ~ctype() override;
647651 virtual bool do_is(mask __m, char_type __c) const;
648652 virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const;
649653 virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const;
......@@ -697,7 +701,7 @@ public:
697701 const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const
698702 {
699703 for (; __low != __high; ++__low)
700 if (!(isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m)))
704 if (!isascii(*__low) || !(__tab_[static_cast<int>(*__low)] & __m))
701705 break;
702706 return __low;
703707 }
......@@ -773,7 +777,7 @@ public:
773777#endif
774778
775779protected:
776 ~ctype();
780 ~ctype() override;
777781 virtual char_type do_toupper(char_type __c) const;
778782 virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
779783 virtual char_type do_tolower(char_type __c) const;
......@@ -792,18 +796,18 @@ template <>
792796class _LIBCPP_TYPE_VIS ctype_byname<char>
793797 : public ctype<char>
794798{
795 locale_t __l;
799 locale_t __l_;
796800
797801public:
798802 explicit ctype_byname(const char*, size_t = 0);
799803 explicit ctype_byname(const string&, size_t = 0);
800804
801805protected:
802 ~ctype_byname();
803 virtual char_type do_toupper(char_type) const;
804 virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
805 virtual char_type do_tolower(char_type) const;
806 virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
806 ~ctype_byname() override;
807 char_type do_toupper(char_type) const override;
808 const char_type* do_toupper(char_type* __low, const char_type* __high) const override;
809 char_type do_tolower(char_type) const override;
810 const char_type* do_tolower(char_type* __low, const char_type* __high) const override;
807811};
808812
809813#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
......@@ -811,26 +815,26 @@ template <>
811815class _LIBCPP_TYPE_VIS ctype_byname<wchar_t>
812816 : public ctype<wchar_t>
813817{
814 locale_t __l;
818 locale_t __l_;
815819
816820public:
817821 explicit ctype_byname(const char*, size_t = 0);
818822 explicit ctype_byname(const string&, size_t = 0);
819823
820824protected:
821 ~ctype_byname();
822 virtual bool do_is(mask __m, char_type __c) const;
823 virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const;
824 virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const;
825 virtual const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const;
826 virtual char_type do_toupper(char_type) const;
827 virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
828 virtual char_type do_tolower(char_type) const;
829 virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
830 virtual char_type do_widen(char) const;
831 virtual const char* do_widen(const char* __low, const char* __high, char_type* __dest) const;
832 virtual char do_narrow(char_type, char __dfault) const;
833 virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const;
825 ~ctype_byname() override;
826 bool do_is(mask __m, char_type __c) const override;
827 const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const override;
828 const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const override;
829 const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const override;
830 char_type do_toupper(char_type) const override;
831 const char_type* do_toupper(char_type* __low, const char_type* __high) const override;
832 char_type do_tolower(char_type) const override;
833 const char_type* do_tolower(char_type* __low, const char_type* __high) const override;
834 char_type do_widen(char) const override;
835 const char* do_widen(const char* __low, const char* __high, char_type* __dest) const override;
836 char do_narrow(char_type, char __dfault) const override;
837 const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const override;
834838};
835839#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
836840
......@@ -839,7 +843,7 @@ inline _LIBCPP_INLINE_VISIBILITY
839843bool
840844isspace(_CharT __c, const locale& __loc)
841845{
842 return use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c);
846 return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c);
843847}
844848
845849template <class _CharT>
......@@ -847,7 +851,7 @@ inline _LIBCPP_INLINE_VISIBILITY
847851bool
848852isprint(_CharT __c, const locale& __loc)
849853{
850 return use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c);
854 return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c);
851855}
852856
853857template <class _CharT>
......@@ -855,7 +859,7 @@ inline _LIBCPP_INLINE_VISIBILITY
855859bool
856860iscntrl(_CharT __c, const locale& __loc)
857861{
858 return use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c);
862 return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c);
859863}
860864
861865template <class _CharT>
......@@ -863,7 +867,7 @@ inline _LIBCPP_INLINE_VISIBILITY
863867bool
864868isupper(_CharT __c, const locale& __loc)
865869{
866 return use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c);
870 return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c);
867871}
868872
869873template <class _CharT>
......@@ -871,7 +875,7 @@ inline _LIBCPP_INLINE_VISIBILITY
871875bool
872876islower(_CharT __c, const locale& __loc)
873877{
874 return use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c);
878 return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c);
875879}
876880
877881template <class _CharT>
......@@ -879,7 +883,7 @@ inline _LIBCPP_INLINE_VISIBILITY
879883bool
880884isalpha(_CharT __c, const locale& __loc)
881885{
882 return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c);
886 return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c);
883887}
884888
885889template <class _CharT>
......@@ -887,7 +891,7 @@ inline _LIBCPP_INLINE_VISIBILITY
887891bool
888892isdigit(_CharT __c, const locale& __loc)
889893{
890 return use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c);
894 return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c);
891895}
892896
893897template <class _CharT>
......@@ -895,7 +899,7 @@ inline _LIBCPP_INLINE_VISIBILITY
895899bool
896900ispunct(_CharT __c, const locale& __loc)
897901{
898 return use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c);
902 return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c);
899903}
900904
901905template <class _CharT>
......@@ -903,7 +907,7 @@ inline _LIBCPP_INLINE_VISIBILITY
903907bool
904908isxdigit(_CharT __c, const locale& __loc)
905909{
906 return use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c);
910 return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c);
907911}
908912
909913template <class _CharT>
......@@ -911,7 +915,7 @@ inline _LIBCPP_INLINE_VISIBILITY
911915bool
912916isalnum(_CharT __c, const locale& __loc)
913917{
914 return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c);
918 return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c);
915919}
916920
917921template <class _CharT>
......@@ -919,7 +923,7 @@ inline _LIBCPP_INLINE_VISIBILITY
919923bool
920924isgraph(_CharT __c, const locale& __loc)
921925{
922 return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c);
926 return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c);
923927}
924928
925929template <class _CharT>
......@@ -927,7 +931,7 @@ inline _LIBCPP_INLINE_VISIBILITY
927931_CharT
928932toupper(_CharT __c, const locale& __loc)
929933{
930 return use_facet<ctype<_CharT> >(__loc).toupper(__c);
934 return std::use_facet<ctype<_CharT> >(__loc).toupper(__c);
931935}
932936
933937template <class _CharT>
......@@ -935,7 +939,7 @@ inline _LIBCPP_INLINE_VISIBILITY
935939_CharT
936940tolower(_CharT __c, const locale& __loc)
937941{
938 return use_facet<ctype<_CharT> >(__loc).tolower(__c);
942 return std::use_facet<ctype<_CharT> >(__loc).tolower(__c);
939943}
940944
941945// codecvt_base
......@@ -1021,7 +1025,7 @@ protected:
10211025 explicit codecvt(const char*, size_t __refs = 0)
10221026 : locale::facet(__refs) {}
10231027
1024 ~codecvt();
1028 ~codecvt() override;
10251029
10261030 virtual result do_out(state_type& __st,
10271031 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
......@@ -1045,7 +1049,7 @@ class _LIBCPP_TYPE_VIS codecvt<wchar_t, char, mbstate_t>
10451049 : public locale::facet,
10461050 public codecvt_base
10471051{
1048 locale_t __l;
1052 locale_t __l_;
10491053public:
10501054 typedef wchar_t intern_type;
10511055 typedef char extern_type;
......@@ -1105,7 +1109,7 @@ public:
11051109protected:
11061110 explicit codecvt(const char*, size_t __refs = 0);
11071111
1108 ~codecvt();
1112 ~codecvt() override;
11091113
11101114 virtual result do_out(state_type& __st,
11111115 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
......@@ -1192,7 +1196,7 @@ protected:
11921196 explicit codecvt(const char*, size_t __refs = 0)
11931197 : locale::facet(__refs) {}
11941198
1195 ~codecvt();
1199 ~codecvt() override;
11961200
11971201 virtual result do_out(state_type& __st,
11981202 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
......@@ -1280,7 +1284,7 @@ protected:
12801284 explicit codecvt(const char*, size_t __refs = 0)
12811285 : locale::facet(__refs) {}
12821286
1283 ~codecvt();
1287 ~codecvt() override;
12841288
12851289 virtual result do_out(state_type& __st,
12861290 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
......@@ -1368,7 +1372,7 @@ protected:
13681372 explicit codecvt(const char*, size_t __refs = 0)
13691373 : locale::facet(__refs) {}
13701374
1371 ~codecvt();
1375 ~codecvt() override;
13721376
13731377 virtual result do_out(state_type& __st,
13741378 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
......@@ -1456,7 +1460,7 @@ protected:
14561460 explicit codecvt(const char*, size_t __refs = 0)
14571461 : locale::facet(__refs) {}
14581462
1459 ~codecvt();
1463 ~codecvt() override;
14601464
14611465 virtual result do_out(state_type& __st,
14621466 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
......@@ -1488,7 +1492,7 @@ public:
14881492 explicit codecvt_byname(const string& __nm, size_t __refs = 0)
14891493 : codecvt<_InternT, _ExternT, _StateT>(__nm.c_str(), __refs) {}
14901494protected:
1491 ~codecvt_byname();
1495 ~codecvt_byname() override;
14921496};
14931497
14941498_LIBCPP_SUPPRESS_DEPRECATED_PUSH
......@@ -1540,7 +1544,7 @@ struct _LIBCPP_TYPE_VIS __narrow_to_utf8<16>
15401544 __narrow_to_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
15411545_LIBCPP_SUPPRESS_DEPRECATED_POP
15421546
1543 ~__narrow_to_utf8();
1547 ~__narrow_to_utf8() override;
15441548
15451549 template <class _OutputIterator, class _CharT>
15461550 _LIBCPP_INLINE_VISIBILITY
......@@ -1576,7 +1580,7 @@ struct _LIBCPP_TYPE_VIS __narrow_to_utf8<32>
15761580 __narrow_to_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
15771581_LIBCPP_SUPPRESS_DEPRECATED_POP
15781582
1579 ~__narrow_to_utf8();
1583 ~__narrow_to_utf8() override;
15801584
15811585 template <class _OutputIterator, class _CharT>
15821586 _LIBCPP_INLINE_VISIBILITY
......@@ -1634,7 +1638,7 @@ struct _LIBCPP_TYPE_VIS __widen_from_utf8<16>
16341638 __widen_from_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
16351639_LIBCPP_SUPPRESS_DEPRECATED_POP
16361640
1637 ~__widen_from_utf8();
1641 ~__widen_from_utf8() override;
16381642
16391643 template <class _OutputIterator>
16401644 _LIBCPP_INLINE_VISIBILITY
......@@ -1670,7 +1674,7 @@ struct _LIBCPP_TYPE_VIS __widen_from_utf8<32>
16701674 __widen_from_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
16711675_LIBCPP_SUPPRESS_DEPRECATED_POP
16721676
1673 ~__widen_from_utf8();
1677 ~__widen_from_utf8() override;
16741678
16751679 template <class _OutputIterator>
16761680 _LIBCPP_INLINE_VISIBILITY
......@@ -1720,7 +1724,7 @@ public:
17201724 static locale::id id;
17211725
17221726protected:
1723 ~numpunct();
1727 ~numpunct() override;
17241728 virtual char_type do_decimal_point() const;
17251729 virtual char_type do_thousands_sep() const;
17261730 virtual string do_grouping() const;
......@@ -1752,7 +1756,7 @@ public:
17521756 static locale::id id;
17531757
17541758protected:
1755 ~numpunct();
1759 ~numpunct() override;
17561760 virtual char_type do_decimal_point() const;
17571761 virtual char_type do_thousands_sep() const;
17581762 virtual string do_grouping() const;
......@@ -1781,7 +1785,7 @@ public:
17811785 explicit numpunct_byname(const string& __nm, size_t __refs = 0);
17821786
17831787protected:
1784 ~numpunct_byname();
1788 ~numpunct_byname() override;
17851789
17861790private:
17871791 void __init(const char*);
......@@ -1800,7 +1804,7 @@ public:
18001804 explicit numpunct_byname(const string& __nm, size_t __refs = 0);
18011805
18021806protected:
1803 ~numpunct_byname();
1807 ~numpunct_byname() override;
18041808
18051809private:
18061810 void __init(const char*);
lib/libcxx/include/__memory/addressof.h+1-1
......@@ -19,7 +19,7 @@
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
2121template <class _Tp>
22inline _LIBCPP_CONSTEXPR_AFTER_CXX14
22inline _LIBCPP_CONSTEXPR_SINCE_CXX17
2323_LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
2424_Tp*
2525addressof(_Tp& __x) _NOEXCEPT
lib/libcxx/include/__memory/align.h created+25
......@@ -0,0 +1,25 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___MEMORY_ALIGN_H
10#define _LIBCPP___MEMORY_ALIGN_H
11
12#include <__config>
13#include <cstddef>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20
21_LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space);
22
23_LIBCPP_END_NAMESPACE_STD
24
25#endif // _LIBCPP___MEMORY_ALIGN_H
lib/libcxx/include/__memory/allocate_at_least.h+1
......@@ -25,6 +25,7 @@ struct allocation_result {
2525 _Pointer ptr;
2626 size_t count;
2727};
28_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result);
2829
2930template <class _Alloc>
3031[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr
lib/libcxx/include/__memory/allocator.h+14-11
......@@ -13,11 +13,14 @@
1313#include <__config>
1414#include <__memory/allocate_at_least.h>
1515#include <__memory/allocator_traits.h>
16#include <__type_traits/is_constant_evaluated.h>
17#include <__type_traits/is_same.h>
18#include <__type_traits/is_void.h>
19#include <__type_traits/is_volatile.h>
1620#include <__utility/forward.h>
1721#include <cstddef>
1822#include <new>
1923#include <stdexcept>
20#include <type_traits>
2124
2225#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2326# pragma GCC system_header
......@@ -95,14 +98,14 @@ public:
9598 typedef true_type propagate_on_container_move_assignment;
9699 typedef true_type is_always_equal;
97100
98 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
101 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
99102 allocator() _NOEXCEPT = default;
100103
101104 template <class _Up>
102 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
105 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
103106 allocator(const allocator<_Up>&) _NOEXCEPT { }
104107
105 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
108 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
106109 _Tp* allocate(size_t __n) {
107110 if (__n > allocator_traits<allocator>::max_size(*this))
108111 __throw_bad_array_new_length();
......@@ -120,7 +123,7 @@ public:
120123 }
121124#endif
122125
123 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
126 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
124127 void deallocate(_Tp* __p, size_t __n) _NOEXCEPT {
125128 if (__libcpp_is_constant_evaluated()) {
126129 ::operator delete(__p);
......@@ -184,14 +187,14 @@ public:
184187 typedef true_type propagate_on_container_move_assignment;
185188 typedef true_type is_always_equal;
186189
187 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
190 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
188191 allocator() _NOEXCEPT = default;
189192
190193 template <class _Up>
191 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
194 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
192195 allocator(const allocator<_Up>&) _NOEXCEPT { }
193196
194 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
197 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
195198 const _Tp* allocate(size_t __n) {
196199 if (__n > allocator_traits<allocator>::max_size(*this))
197200 __throw_bad_array_new_length();
......@@ -209,7 +212,7 @@ public:
209212 }
210213#endif
211214
212 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
215 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
213216 void deallocate(const _Tp* __p, size_t __n) {
214217 if (__libcpp_is_constant_evaluated()) {
215218 ::operator delete(const_cast<_Tp*>(__p));
......@@ -258,11 +261,11 @@ public:
258261};
259262
260263template <class _Tp, class _Up>
261inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
264inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
262265bool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return true;}
263266
264267template <class _Tp, class _Up>
265inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
268inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
266269bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;}
267270
268271_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__memory/allocator_arg_t.h+4-2
......@@ -12,8 +12,10 @@
1212
1313#include <__config>
1414#include <__memory/uses_allocator.h>
15#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_constructible.h>
17#include <__type_traits/remove_cvref.h>
1518#include <__utility/forward.h>
16#include <type_traits>
1719
1820#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1921# pragma GCC system_header
......@@ -36,7 +38,7 @@ extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg;
3638template <class _Tp, class _Alloc, class ..._Args>
3739struct __uses_alloc_ctor_imp
3840{
39 typedef _LIBCPP_NODEBUG __uncvref_t<_Alloc> _RawAlloc;
41 typedef _LIBCPP_NODEBUG __remove_cvref_t<_Alloc> _RawAlloc;
4042 static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;
4143 static const bool __ic =
4244 is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
lib/libcxx/include/__memory/allocator_destructor.h created+42
......@@ -0,0 +1,42 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___MEMORY_ALLOCATOR_DESTRUCTOR_H
10#define _LIBCPP___MEMORY_ALLOCATOR_DESTRUCTOR_H
11
12#include <__config>
13#include <__memory/allocator_traits.h>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20
21template <class _Alloc>
22class __allocator_destructor
23{
24 typedef _LIBCPP_NODEBUG allocator_traits<_Alloc> __alloc_traits;
25public:
26 typedef _LIBCPP_NODEBUG typename __alloc_traits::pointer pointer;
27 typedef _LIBCPP_NODEBUG typename __alloc_traits::size_type size_type;
28private:
29 _Alloc& __alloc_;
30 size_type __s_;
31public:
32 _LIBCPP_INLINE_VISIBILITY __allocator_destructor(_Alloc& __a, size_type __s)
33 _NOEXCEPT
34 : __alloc_(__a), __s_(__s) {}
35 _LIBCPP_INLINE_VISIBILITY
36 void operator()(pointer __p) _NOEXCEPT
37 {__alloc_traits::deallocate(__alloc_, __p, __s_);}
38};
39
40_LIBCPP_END_NAMESPACE_STD
41
42#endif // _LIBCPP___MEMORY_ALLOCATOR_DESTRUCTOR_H
lib/libcxx/include/__memory/allocator_traits.h+34-29
......@@ -13,9 +13,16 @@
1313#include <__config>
1414#include <__memory/construct_at.h>
1515#include <__memory/pointer_traits.h>
16#include <__type_traits/enable_if.h>
17#include <__type_traits/is_copy_constructible.h>
18#include <__type_traits/is_empty.h>
19#include <__type_traits/is_move_constructible.h>
20#include <__type_traits/make_unsigned.h>
21#include <__type_traits/remove_reference.h>
22#include <__type_traits/void_t.h>
23#include <__utility/declval.h>
1624#include <__utility/forward.h>
1725#include <limits>
18#include <type_traits>
1926
2027#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2128# pragma GCC system_header
......@@ -28,12 +35,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2835
2936#define _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(NAME, PROPERTY) \
3037 template <class _Tp, class = void> struct NAME : false_type { }; \
31 template <class _Tp> struct NAME<_Tp, typename __void_t<typename _Tp:: PROPERTY >::type> : true_type { }
38 template <class _Tp> struct NAME<_Tp, __void_t<typename _Tp:: PROPERTY > > : true_type { }
3239
3340// __pointer
3441_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_pointer, pointer);
3542template <class _Tp, class _Alloc,
36 class _RawAlloc = typename remove_reference<_Alloc>::type,
43 class _RawAlloc = __libcpp_remove_reference_t<_Alloc>,
3744 bool = __has_pointer<_RawAlloc>::value>
3845struct __pointer {
3946 using type _LIBCPP_NODEBUG = typename _RawAlloc::pointer;
......@@ -152,13 +159,12 @@ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
152159template <class _Tp, class _Up, class = void>
153160struct __has_rebind_other : false_type { };
154161template <class _Tp, class _Up>
155struct __has_rebind_other<_Tp, _Up, typename __void_t<
156 typename _Tp::template rebind<_Up>::other
157>::type> : true_type { };
162struct __has_rebind_other<_Tp, _Up, __void_t<typename _Tp::template rebind<_Up>::other> > : true_type { };
158163
159164template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value>
160165struct __allocator_traits_rebind {
161 using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>::other;
166 static_assert(__has_rebind_other<_Tp, _Up>::value, "This allocator has to implement rebind");
167 using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>::other;
162168};
163169template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
164170struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true> {
......@@ -181,7 +187,7 @@ struct __has_allocate_hint : false_type { };
181187
182188template <class _Alloc, class _SizeType, class _ConstVoidPtr>
183189struct __has_allocate_hint<_Alloc, _SizeType, _ConstVoidPtr, decltype(
184 (void)declval<_Alloc>().allocate(declval<_SizeType>(), declval<_ConstVoidPtr>())
190 (void)std::declval<_Alloc>().allocate(std::declval<_SizeType>(), std::declval<_ConstVoidPtr>())
185191)> : true_type { };
186192
187193// __has_construct
......@@ -190,7 +196,7 @@ struct __has_construct_impl : false_type { };
190196
191197template <class _Alloc, class ..._Args>
192198struct __has_construct_impl<decltype(
193 (void)declval<_Alloc>().construct(declval<_Args>()...)
199 (void)std::declval<_Alloc>().construct(std::declval<_Args>()...)
194200), _Alloc, _Args...> : true_type { };
195201
196202template <class _Alloc, class ..._Args>
......@@ -202,7 +208,7 @@ struct __has_destroy : false_type { };
202208
203209template <class _Alloc, class _Pointer>
204210struct __has_destroy<_Alloc, _Pointer, decltype(
205 (void)declval<_Alloc>().destroy(declval<_Pointer>())
211 (void)std::declval<_Alloc>().destroy(std::declval<_Pointer>())
206212)> : true_type { };
207213
208214// __has_max_size
......@@ -211,7 +217,7 @@ struct __has_max_size : false_type { };
211217
212218template <class _Alloc>
213219struct __has_max_size<_Alloc, decltype(
214 (void)declval<_Alloc&>().max_size()
220 (void)std::declval<_Alloc&>().max_size()
215221)> : true_type { };
216222
217223// __has_select_on_container_copy_construction
......@@ -220,7 +226,7 @@ struct __has_select_on_container_copy_construction : false_type { };
220226
221227template <class _Alloc>
222228struct __has_select_on_container_copy_construction<_Alloc, decltype(
223 (void)declval<_Alloc>().select_on_container_copy_construction()
229 (void)std::declval<_Alloc>().select_on_container_copy_construction()
224230)> : true_type { };
225231
226232_LIBCPP_SUPPRESS_DEPRECATED_POP
......@@ -257,14 +263,14 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
257263 };
258264#endif // _LIBCPP_CXX03_LANG
259265
260 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
266 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
261267 static pointer allocate(allocator_type& __a, size_type __n) {
262268 return __a.allocate(__n);
263269 }
264270
265271 template <class _Ap = _Alloc, class =
266272 __enable_if_t<__has_allocate_hint<_Ap, size_type, const_void_pointer>::value> >
267 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
273 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
268274 static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) {
269275 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
270276 return __a.allocate(__n, __hint);
......@@ -272,19 +278,19 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
272278 }
273279 template <class _Ap = _Alloc, class = void, class =
274280 __enable_if_t<!__has_allocate_hint<_Ap, size_type, const_void_pointer>::value> >
275 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
281 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
276282 static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer) {
277283 return __a.allocate(__n);
278284 }
279285
280 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
286 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
281287 static void deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT {
282288 __a.deallocate(__p, __n);
283289 }
284290
285291 template <class _Tp, class... _Args, class =
286292 __enable_if_t<__has_construct<allocator_type, _Tp*, _Args...>::value> >
287 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
293 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
288294 static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args) {
289295 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
290296 __a.construct(__p, _VSTD::forward<_Args>(__args)...);
......@@ -292,7 +298,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
292298 }
293299 template <class _Tp, class... _Args, class = void, class =
294300 __enable_if_t<!__has_construct<allocator_type, _Tp*, _Args...>::value> >
295 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
301 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
296302 static void construct(allocator_type&, _Tp* __p, _Args&&... __args) {
297303#if _LIBCPP_STD_VER > 17
298304 _VSTD::construct_at(__p, _VSTD::forward<_Args>(__args)...);
......@@ -303,7 +309,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
303309
304310 template <class _Tp, class =
305311 __enable_if_t<__has_destroy<allocator_type, _Tp*>::value> >
306 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
312 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
307313 static void destroy(allocator_type& __a, _Tp* __p) {
308314 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
309315 __a.destroy(__p);
......@@ -311,7 +317,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
311317 }
312318 template <class _Tp, class = void, class =
313319 __enable_if_t<!__has_destroy<allocator_type, _Tp*>::value> >
314 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
320 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
315321 static void destroy(allocator_type&, _Tp* __p) {
316322#if _LIBCPP_STD_VER > 17
317323 _VSTD::destroy_at(__p);
......@@ -322,7 +328,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
322328
323329 template <class _Ap = _Alloc, class =
324330 __enable_if_t<__has_max_size<const _Ap>::value> >
325 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
331 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
326332 static size_type max_size(const allocator_type& __a) _NOEXCEPT {
327333 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
328334 return __a.max_size();
......@@ -330,33 +336,32 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
330336 }
331337 template <class _Ap = _Alloc, class = void, class =
332338 __enable_if_t<!__has_max_size<const _Ap>::value> >
333 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
339 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
334340 static size_type max_size(const allocator_type&) _NOEXCEPT {
335341 return numeric_limits<size_type>::max() / sizeof(value_type);
336342 }
337343
338344 template <class _Ap = _Alloc, class =
339345 __enable_if_t<__has_select_on_container_copy_construction<const _Ap>::value> >
340 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
346 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
341347 static allocator_type select_on_container_copy_construction(const allocator_type& __a) {
342348 return __a.select_on_container_copy_construction();
343349 }
344350 template <class _Ap = _Alloc, class = void, class =
345351 __enable_if_t<!__has_select_on_container_copy_construction<const _Ap>::value> >
346 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
352 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
347353 static allocator_type select_on_container_copy_construction(const allocator_type& __a) {
348354 return __a;
349355 }
350356};
351357
352template <class _Traits, class _Tp>
353struct __rebind_alloc_helper {
354358#ifndef _LIBCPP_CXX03_LANG
355 using type _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>;
359template <class _Traits, class _Tp>
360using __rebind_alloc _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>;
356361#else
357 using type = typename _Traits::template rebind_alloc<_Tp>::other;
362template <class _Traits, class _Tp>
363using __rebind_alloc = typename _Traits::template rebind_alloc<_Tp>::other;
358364#endif
359};
360365
361366// __is_default_allocator
362367template <class _Tp>
lib/libcxx/include/__memory/assume_aligned.h+1-1
......@@ -12,9 +12,9 @@
1212
1313#include <__assert>
1414#include <__config>
15#include <__type_traits/is_constant_evaluated.h>
1516#include <cstddef>
1617#include <cstdint>
17#include <type_traits> // for is_constant_evaluated()
1818
1919#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2020# pragma GCC system_header
lib/libcxx/include/__memory/builtin_new_allocator.h created+70
......@@ -0,0 +1,70 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___MEMORY_BUILTIN_NEW_ALLOCATOR_H
10#define _LIBCPP___MEMORY_BUILTIN_NEW_ALLOCATOR_H
11
12#include <__config>
13#include <__memory/unique_ptr.h>
14#include <cstddef>
15#include <new>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23// __builtin_new_allocator -- A non-templated helper for allocating and
24// deallocating memory using __builtin_operator_new and
25// __builtin_operator_delete. It should be used in preference to
26// `std::allocator<T>` to avoid additional instantiations.
27struct __builtin_new_allocator {
28 struct __builtin_new_deleter {
29 typedef void* pointer_type;
30
31 _LIBCPP_CONSTEXPR explicit __builtin_new_deleter(size_t __size, size_t __align)
32 : __size_(__size), __align_(__align) {}
33
34 void operator()(void* __p) const _NOEXCEPT {
35 _VSTD::__libcpp_deallocate(__p, __size_, __align_);
36 }
37
38 private:
39 size_t __size_;
40 size_t __align_;
41 };
42
43 typedef unique_ptr<void, __builtin_new_deleter> __holder_t;
44
45 static __holder_t __allocate_bytes(size_t __s, size_t __align) {
46 return __holder_t(_VSTD::__libcpp_allocate(__s, __align),
47 __builtin_new_deleter(__s, __align));
48 }
49
50 static void __deallocate_bytes(void* __p, size_t __s,
51 size_t __align) _NOEXCEPT {
52 _VSTD::__libcpp_deallocate(__p, __s, __align);
53 }
54
55 template <class _Tp>
56 _LIBCPP_NODEBUG _LIBCPP_ALWAYS_INLINE
57 static __holder_t __allocate_type(size_t __n) {
58 return __allocate_bytes(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
59 }
60
61 template <class _Tp>
62 _LIBCPP_NODEBUG _LIBCPP_ALWAYS_INLINE
63 static void __deallocate_type(void* __p, size_t __n) _NOEXCEPT {
64 __deallocate_bytes(__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
65 }
66};
67
68_LIBCPP_END_NAMESPACE_STD
69
70#endif // _LIBCPP___MEMORY_BUILTIN_NEW_ALLOCATOR_H
lib/libcxx/include/__memory/compressed_pair.h+22-11
......@@ -11,10 +11,21 @@
1111#define _LIBCPP___MEMORY_COMPRESSED_PAIR_H
1212
1313#include <__config>
14#include <__fwd/get.h>
15#include <__fwd/tuple.h>
16#include <__tuple_dir/tuple_indices.h>
17#include <__type_traits/decay.h>
18#include <__type_traits/dependent_type.h>
19#include <__type_traits/enable_if.h>
20#include <__type_traits/is_default_constructible.h>
21#include <__type_traits/is_empty.h>
22#include <__type_traits/is_final.h>
23#include <__type_traits/is_same.h>
24#include <__type_traits/is_swappable.h>
1425#include <__utility/forward.h>
1526#include <__utility/move.h>
16#include <tuple> // needed in c++03 for some constructors
17#include <type_traits>
27#include <__utility/piecewise_construct.h>
28#include <cstddef>
1829
1930#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2031# pragma GCC system_header
......@@ -41,12 +52,12 @@ struct __compressed_pair_elem {
4152
4253#ifndef _LIBCPP_CXX03_LANG
4354 template <class... _Args, size_t... _Indices>
44 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
55 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
4556 explicit __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indices...>)
4657 : __value_(std::forward<_Args>(std::get<_Indices>(__args))...) {}
4758#endif
4859
49 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference __get() _NOEXCEPT { return __value_; }
60 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference __get() _NOEXCEPT { return __value_; }
5061 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return __value_; }
5162
5263private:
......@@ -70,12 +81,12 @@ struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp {
7081
7182#ifndef _LIBCPP_CXX03_LANG
7283 template <class... _Args, size_t... _Indices>
73 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
84 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
7485 __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indices...>)
7586 : __value_type(std::forward<_Args>(std::get<_Indices>(__args))...) {}
7687#endif
7788
78 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference __get() _NOEXCEPT { return *this; }
89 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference __get() _NOEXCEPT { return *this; }
7990 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return *this; }
8091};
8192
......@@ -109,14 +120,14 @@ public:
109120
110121#ifndef _LIBCPP_CXX03_LANG
111122 template <class... _Args1, class... _Args2>
112 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14
123 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
113124 explicit __compressed_pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args,
114125 tuple<_Args2...> __second_args)
115126 : _Base1(__pc, std::move(__first_args), typename __make_tuple_indices<sizeof...(_Args1)>::type()),
116127 _Base2(__pc, std::move(__second_args), typename __make_tuple_indices<sizeof...(_Args2)>::type()) {}
117128#endif
118129
119 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
130 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
120131 typename _Base1::reference first() _NOEXCEPT {
121132 return static_cast<_Base1&>(*this).__get();
122133 }
......@@ -126,7 +137,7 @@ public:
126137 return static_cast<_Base1 const&>(*this).__get();
127138 }
128139
129 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
140 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
130141 typename _Base2::reference second() _NOEXCEPT {
131142 return static_cast<_Base2&>(*this).__get();
132143 }
......@@ -145,7 +156,7 @@ public:
145156 return static_cast<_Base2*>(__pair);
146157 }
147158
148 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
159 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
149160 void swap(__compressed_pair& __x)
150161 _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value) {
151162 using std::swap;
......@@ -155,7 +166,7 @@ public:
155166};
156167
157168template <class _T1, class _T2>
158inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
169inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
159170void swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y)
160171 _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value) {
161172 __x.swap(__y);
lib/libcxx/include/__memory/concepts.h+5-4
......@@ -10,14 +10,15 @@
1010#ifndef _LIBCPP___MEMORY_CONCEPTS_H
1111#define _LIBCPP___MEMORY_CONCEPTS_H
1212
13#include <__concepts/same_as.h>
1314#include <__config>
1415#include <__iterator/concepts.h>
1516#include <__iterator/iterator_traits.h>
1617#include <__iterator/readable_traits.h>
1718#include <__ranges/access.h>
1819#include <__ranges/concepts.h>
19#include <concepts>
20#include <type_traits>
20#include <__type_traits/is_reference.h>
21#include <__type_traits/remove_cvref.h>
2122
2223#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2324# pragma GCC system_header
......@@ -25,7 +26,7 @@
2526
2627_LIBCPP_BEGIN_NAMESPACE_STD
2728
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
29#if _LIBCPP_STD_VER > 17
2930
3031namespace ranges {
3132
......@@ -61,7 +62,7 @@ concept __nothrow_forward_range =
6162
6263} // namespace ranges
6364
64#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
65#endif // _LIBCPP_STD_VER > 17
6566
6667_LIBCPP_END_NAMESPACE_STD
6768
lib/libcxx/include/__memory/construct_at.h+14-11
......@@ -15,9 +15,12 @@
1515#include <__iterator/access.h>
1616#include <__memory/addressof.h>
1717#include <__memory/voidify.h>
18#include <__type_traits/enable_if.h>
19#include <__type_traits/is_array.h>
20#include <__utility/declval.h>
1821#include <__utility/forward.h>
1922#include <__utility/move.h>
20#include <type_traits>
23#include <new>
2124
2225#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2326# pragma GCC system_header
......@@ -29,7 +32,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2932
3033#if _LIBCPP_STD_VER > 17
3134
32template <class _Tp, class... _Args, class = decltype(::new(declval<void*>()) _Tp(declval<_Args>()...))>
35template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))>
3336_LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __args) {
3437 _LIBCPP_ASSERT(__location != nullptr, "null pointer given to construct_at");
3538 return ::new (_VSTD::__voidify(*__location)) _Tp(_VSTD::forward<_Args>(__args)...);
......@@ -37,7 +40,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __
3740
3841#endif
3942
40template <class _Tp, class... _Args, class = decltype(::new(declval<void*>()) _Tp(declval<_Args>()...))>
43template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))>
4144_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __construct_at(_Tp* __location, _Args&&... __args) {
4245#if _LIBCPP_STD_VER > 17
4346 return std::construct_at(__location, std::forward<_Args>(__args)...);
......@@ -53,11 +56,11 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __construct_at(_Tp* __location, _Ar
5356// taking an array).
5457
5558template <class _ForwardIterator>
56_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
59_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
5760_ForwardIterator __destroy(_ForwardIterator, _ForwardIterator);
5861
5962template <class _Tp, typename enable_if<!is_array<_Tp>::value, int>::type = 0>
60_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
63_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
6164void __destroy_at(_Tp* __loc) {
6265 _LIBCPP_ASSERT(__loc != nullptr, "null pointer given to destroy_at");
6366 __loc->~_Tp();
......@@ -65,7 +68,7 @@ void __destroy_at(_Tp* __loc) {
6568
6669#if _LIBCPP_STD_VER > 17
6770template <class _Tp, typename enable_if<is_array<_Tp>::value, int>::type = 0>
68_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
71_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
6972void __destroy_at(_Tp* __loc) {
7073 _LIBCPP_ASSERT(__loc != nullptr, "null pointer given to destroy_at");
7174 _VSTD::__destroy(_VSTD::begin(*__loc), _VSTD::end(*__loc));
......@@ -73,7 +76,7 @@ void __destroy_at(_Tp* __loc) {
7376#endif
7477
7578template <class _ForwardIterator>
76_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
79_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
7780_ForwardIterator __destroy(_ForwardIterator __first, _ForwardIterator __last) {
7881 for (; __first != __last; ++__first)
7982 _VSTD::__destroy_at(_VSTD::addressof(*__first));
......@@ -83,27 +86,27 @@ _ForwardIterator __destroy(_ForwardIterator __first, _ForwardIterator __last) {
8386#if _LIBCPP_STD_VER > 14
8487
8588template <class _Tp, enable_if_t<!is_array_v<_Tp>, int> = 0>
86_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
89_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
8790void destroy_at(_Tp* __loc) {
8891 _VSTD::__destroy_at(__loc);
8992}
9093
9194#if _LIBCPP_STD_VER > 17
9295template <class _Tp, enable_if_t<is_array_v<_Tp>, int> = 0>
93_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
96_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
9497void destroy_at(_Tp* __loc) {
9598 _VSTD::__destroy_at(__loc);
9699}
97100#endif
98101
99102template <class _ForwardIterator>
100_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
103_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
101104void destroy(_ForwardIterator __first, _ForwardIterator __last) {
102105 (void)_VSTD::__destroy(_VSTD::move(__first), _VSTD::move(__last));
103106}
104107
105108template <class _ForwardIterator, class _Size>
106_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
109_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
107110_ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) {
108111 for (; __n > 0; (void)++__first, --__n)
109112 _VSTD::__destroy_at(_VSTD::addressof(*__first));
lib/libcxx/include/__memory/destruct_n.h created+64
......@@ -0,0 +1,64 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___MEMORY_DESTRUCT_N_H
10#define _LIBCPP___MEMORY_DESTRUCT_N_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_trivially_destructible.h>
15#include <cstddef>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23struct __destruct_n
24{
25private:
26 size_t __size_;
27
28 template <class _Tp>
29 _LIBCPP_INLINE_VISIBILITY void __process(_Tp* __p, false_type) _NOEXCEPT
30 {for (size_t __i = 0; __i < __size_; ++__i, ++__p) __p->~_Tp();}
31
32 template <class _Tp>
33 _LIBCPP_INLINE_VISIBILITY void __process(_Tp*, true_type) _NOEXCEPT
34 {}
35
36 _LIBCPP_INLINE_VISIBILITY void __incr(false_type) _NOEXCEPT
37 {++__size_;}
38 _LIBCPP_INLINE_VISIBILITY void __incr(true_type) _NOEXCEPT
39 {}
40
41 _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, false_type) _NOEXCEPT
42 {__size_ = __s;}
43 _LIBCPP_INLINE_VISIBILITY void __set(size_t, true_type) _NOEXCEPT
44 {}
45public:
46 _LIBCPP_INLINE_VISIBILITY explicit __destruct_n(size_t __s) _NOEXCEPT
47 : __size_(__s) {}
48
49 template <class _Tp>
50 _LIBCPP_INLINE_VISIBILITY void __incr() _NOEXCEPT
51 {__incr(integral_constant<bool, is_trivially_destructible<_Tp>::value>());}
52
53 template <class _Tp>
54 _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, _Tp*) _NOEXCEPT
55 {__set(__s, integral_constant<bool, is_trivially_destructible<_Tp>::value>());}
56
57 template <class _Tp>
58 _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __p) _NOEXCEPT
59 {__process(__p, integral_constant<bool, is_trivially_destructible<_Tp>::value>());}
60};
61
62_LIBCPP_END_NAMESPACE_STD
63
64#endif // _LIBCPP___MEMORY_DESTRUCT_N_H
lib/libcxx/include/__memory/pointer_traits.h+24-22
......@@ -12,8 +12,15 @@
1212
1313#include <__config>
1414#include <__memory/addressof.h>
15#include <__type_traits/conditional.h>
16#include <__type_traits/conjunction.h>
17#include <__type_traits/decay.h>
18#include <__type_traits/is_class.h>
19#include <__type_traits/is_function.h>
20#include <__type_traits/is_void.h>
21#include <__type_traits/void_t.h>
22#include <__utility/declval.h>
1523#include <cstddef>
16#include <type_traits>
1724
1825#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1926# pragma GCC system_header
......@@ -25,8 +32,7 @@ template <class _Tp, class = void>
2532struct __has_element_type : false_type {};
2633
2734template <class _Tp>
28struct __has_element_type<_Tp,
29 typename __void_t<typename _Tp::element_type>::type> : true_type {};
35struct __has_element_type<_Tp, __void_t<typename _Tp::element_type> > : true_type {};
3036
3137template <class _Ptr, bool = __has_element_type<_Ptr>::value>
3238struct __pointer_traits_element_type;
......@@ -53,8 +59,7 @@ template <class _Tp, class = void>
5359struct __has_difference_type : false_type {};
5460
5561template <class _Tp>
56struct __has_difference_type<_Tp,
57 typename __void_t<typename _Tp::difference_type>::type> : true_type {};
62struct __has_difference_type<_Tp, __void_t<typename _Tp::difference_type> > : true_type {};
5863
5964template <class _Ptr, bool = __has_difference_type<_Ptr>::value>
6065struct __pointer_traits_difference_type
......@@ -123,9 +128,8 @@ struct _LIBCPP_TEMPLATE_VIS pointer_traits
123128private:
124129 struct __nat {};
125130public:
126 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
127 static pointer pointer_to(typename conditional<is_void<element_type>::value,
128 __nat, element_type>::type& __r)
131 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
132 static pointer pointer_to(__conditional_t<is_void<element_type>::value, __nat, element_type>& __r)
129133 {return pointer::pointer_to(__r);}
130134};
131135
......@@ -145,20 +149,18 @@ struct _LIBCPP_TEMPLATE_VIS pointer_traits<_Tp*>
145149private:
146150 struct __nat {};
147151public:
148 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
149 static pointer pointer_to(typename conditional<is_void<element_type>::value,
150 __nat, element_type>::type& __r) _NOEXCEPT
152 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
153 static pointer pointer_to(__conditional_t<is_void<element_type>::value, __nat, element_type>& __r) _NOEXCEPT
151154 {return _VSTD::addressof(__r);}
152155};
153156
154template <class _From, class _To>
155struct __rebind_pointer {
156157#ifndef _LIBCPP_CXX03_LANG
157 typedef typename pointer_traits<_From>::template rebind<_To> type;
158template <class _From, class _To>
159using __rebind_pointer_t = typename pointer_traits<_From>::template rebind<_To>;
158160#else
159 typedef typename pointer_traits<_From>::template rebind<_To>::other type;
161template <class _From, class _To>
162using __rebind_pointer_t = typename pointer_traits<_From>::template rebind<_To>::other;
160163#endif
161};
162164
163165// to_address
164166
......@@ -177,7 +179,7 @@ struct _HasToAddress : false_type {};
177179
178180template <class _Pointer>
179181struct _HasToAddress<_Pointer,
180 decltype((void)pointer_traits<_Pointer>::to_address(declval<const _Pointer&>()))
182 decltype((void)pointer_traits<_Pointer>::to_address(std::declval<const _Pointer&>()))
181183> : true_type {};
182184
183185template <class _Pointer, class = void>
......@@ -185,7 +187,7 @@ struct _HasArrow : false_type {};
185187
186188template <class _Pointer>
187189struct _HasArrow<_Pointer,
188 decltype((void)declval<const _Pointer&>().operator->())
190 decltype((void)std::declval<const _Pointer&>().operator->())
189191> : true_type {};
190192
191193template <class _Pointer>
......@@ -198,7 +200,7 @@ template <class _Pointer, class = __enable_if_t<
198200 _And<is_class<_Pointer>, _IsFancyPointer<_Pointer> >::value
199201> >
200202_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
201typename decay<decltype(__to_address_helper<_Pointer>::__call(declval<const _Pointer&>()))>::type
203typename decay<decltype(__to_address_helper<_Pointer>::__call(std::declval<const _Pointer&>()))>::type
202204__to_address(const _Pointer& __p) _NOEXCEPT {
203205 return __to_address_helper<_Pointer>::__call(__p);
204206}
......@@ -206,16 +208,16 @@ __to_address(const _Pointer& __p) _NOEXCEPT {
206208template <class _Pointer, class>
207209struct __to_address_helper {
208210 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
209 static decltype(_VSTD::__to_address(declval<const _Pointer&>().operator->()))
211 static decltype(_VSTD::__to_address(std::declval<const _Pointer&>().operator->()))
210212 __call(const _Pointer& __p) _NOEXCEPT {
211213 return _VSTD::__to_address(__p.operator->());
212214 }
213215};
214216
215217template <class _Pointer>
216struct __to_address_helper<_Pointer, decltype((void)pointer_traits<_Pointer>::to_address(declval<const _Pointer&>()))> {
218struct __to_address_helper<_Pointer, decltype((void)pointer_traits<_Pointer>::to_address(std::declval<const _Pointer&>()))> {
217219 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
218 static decltype(pointer_traits<_Pointer>::to_address(declval<const _Pointer&>()))
220 static decltype(pointer_traits<_Pointer>::to_address(std::declval<const _Pointer&>()))
219221 __call(const _Pointer& __p) _NOEXCEPT {
220222 return pointer_traits<_Pointer>::to_address(__p);
221223 }
lib/libcxx/include/__memory/ranges_construct_at.h+4-3
......@@ -22,6 +22,7 @@
2222#include <__utility/declval.h>
2323#include <__utility/forward.h>
2424#include <__utility/move.h>
25#include <new>
2526
2627#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2728# pragma GCC system_header
......@@ -29,7 +30,7 @@
2930
3031_LIBCPP_BEGIN_NAMESPACE_STD
3132
32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
33#if _LIBCPP_STD_VER > 17
3334namespace ranges {
3435
3536// construct_at
......@@ -38,7 +39,7 @@ namespace __construct_at {
3839
3940struct __fn {
4041 template<class _Tp, class... _Args, class = decltype(
41 ::new (declval<void*>()) _Tp(declval<_Args>()...)
42 ::new (std::declval<void*>()) _Tp(std::declval<_Args>()...)
4243 )>
4344 _LIBCPP_HIDE_FROM_ABI
4445 constexpr _Tp* operator()(_Tp* __location, _Args&& ...__args) const {
......@@ -117,7 +118,7 @@ inline namespace __cpo {
117118
118119} // namespace ranges
119120
120#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
121#endif // _LIBCPP_STD_VER > 17
121122
122123_LIBCPP_END_NAMESPACE_STD
123124
lib/libcxx/include/__memory/ranges_uninitialized_algorithms.h+7-6
......@@ -23,8 +23,9 @@
2323#include <__ranges/access.h>
2424#include <__ranges/concepts.h>
2525#include <__ranges/dangling.h>
26#include <__type_traits/remove_reference.h>
2627#include <__utility/move.h>
27#include <type_traits>
28#include <new>
2829
2930#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3031# pragma GCC system_header
......@@ -32,7 +33,7 @@
3233
3334_LIBCPP_BEGIN_NAMESPACE_STD
3435
35#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
36#if _LIBCPP_STD_VER > 17
3637
3738namespace ranges {
3839
......@@ -255,7 +256,7 @@ struct __fn {
255256 sentinel_for<_InputIterator> _Sentinel1,
256257 __nothrow_forward_iterator _OutputIterator,
257258 __nothrow_sentinel_for<_OutputIterator> _Sentinel2>
258 requires constructible_from<iter_value_t<_OutputIterator>, iter_reference_t<_InputIterator>>
259 requires constructible_from<iter_value_t<_OutputIterator>, iter_rvalue_reference_t<_InputIterator>>
259260 uninitialized_move_result<_InputIterator, _OutputIterator>
260261 operator()(_InputIterator __ifirst, _Sentinel1 __ilast, _OutputIterator __ofirst, _Sentinel2 __olast) const {
261262 using _ValueType = remove_reference_t<iter_reference_t<_OutputIterator>>;
......@@ -266,7 +267,7 @@ struct __fn {
266267 }
267268
268269 template <input_range _InputRange, __nothrow_forward_range _OutputRange>
269 requires constructible_from<range_value_t<_OutputRange>, range_reference_t<_InputRange>>
270 requires constructible_from<range_value_t<_OutputRange>, range_rvalue_reference_t<_InputRange>>
270271 uninitialized_move_result<borrowed_iterator_t<_InputRange>, borrowed_iterator_t<_OutputRange>>
271272 operator()(_InputRange&& __in_range, _OutputRange&& __out_range) const {
272273 return (*this)(ranges::begin(__in_range), ranges::end(__in_range),
......@@ -291,7 +292,7 @@ struct __fn {
291292 template <input_iterator _InputIterator,
292293 __nothrow_forward_iterator _OutputIterator,
293294 __nothrow_sentinel_for<_OutputIterator> _Sentinel>
294 requires constructible_from<iter_value_t<_OutputIterator>, iter_reference_t<_InputIterator>>
295 requires constructible_from<iter_value_t<_OutputIterator>, iter_rvalue_reference_t<_InputIterator>>
295296 uninitialized_move_n_result<_InputIterator, _OutputIterator>
296297 operator()(_InputIterator __ifirst, iter_difference_t<_InputIterator> __n,
297298 _OutputIterator __ofirst, _Sentinel __olast) const {
......@@ -311,7 +312,7 @@ inline namespace __cpo {
311312
312313} // namespace ranges
313314
314#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
315#endif // _LIBCPP_STD_VER > 17
315316
316317_LIBCPP_END_NAMESPACE_STD
317318
lib/libcxx/include/__memory/raw_storage_iterator.h+1
......@@ -16,6 +16,7 @@
1616#include <__memory/addressof.h>
1717#include <__utility/move.h>
1818#include <cstddef>
19#include <new>
1920
2021#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2122# pragma GCC system_header
lib/libcxx/include/__memory/shared_ptr.h+159-65
......@@ -11,6 +11,8 @@
1111#define _LIBCPP___MEMORY_SHARED_PTR_H
1212
1313#include <__availability>
14#include <__compare/compare_three_way.h>
15#include <__compare/ordering.h>
1416#include <__config>
1517#include <__functional/binary_function.h>
1618#include <__functional/operations.h>
......@@ -19,6 +21,7 @@
1921#include <__memory/addressof.h>
2022#include <__memory/allocation_guard.h>
2123#include <__memory/allocator.h>
24#include <__memory/allocator_destructor.h>
2225#include <__memory/allocator_traits.h>
2326#include <__memory/auto_ptr.h>
2427#include <__memory/compressed_pair.h>
......@@ -32,39 +35,19 @@
3235#include <cstddef>
3336#include <cstdlib> // abort
3437#include <iosfwd>
38#include <new>
3539#include <stdexcept>
36#include <type_traits>
3740#include <typeinfo>
3841#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
3942# include <atomic>
4043#endif
4144
42
4345#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
4446# pragma GCC system_header
4547#endif
4648
4749_LIBCPP_BEGIN_NAMESPACE_STD
4850
49template <class _Alloc>
50class __allocator_destructor
51{
52 typedef _LIBCPP_NODEBUG allocator_traits<_Alloc> __alloc_traits;
53public:
54 typedef _LIBCPP_NODEBUG typename __alloc_traits::pointer pointer;
55 typedef _LIBCPP_NODEBUG typename __alloc_traits::size_type size_type;
56private:
57 _Alloc& __alloc_;
58 size_type __s_;
59public:
60 _LIBCPP_INLINE_VISIBILITY __allocator_destructor(_Alloc& __a, size_type __s)
61 _NOEXCEPT
62 : __alloc_(__a), __s_(__s) {}
63 _LIBCPP_INLINE_VISIBILITY
64 void operator()(pointer __p) _NOEXCEPT
65 {__alloc_traits::deallocate(__alloc_, __p, __s_);}
66};
67
6851// NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively)
6952// should be sufficient for thread safety.
7053// See https://llvm.org/PR22803
......@@ -128,8 +111,8 @@ class _LIBCPP_EXCEPTION_ABI bad_weak_ptr
128111public:
129112 bad_weak_ptr() _NOEXCEPT = default;
130113 bad_weak_ptr(const bad_weak_ptr&) _NOEXCEPT = default;
131 virtual ~bad_weak_ptr() _NOEXCEPT;
132 virtual const char* what() const _NOEXCEPT;
114 ~bad_weak_ptr() _NOEXCEPT override;
115 const char* what() const _NOEXCEPT override;
133116};
134117
135118_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
......@@ -194,7 +177,7 @@ public:
194177 : __shared_count(__refs),
195178 __shared_weak_owners_(__refs) {}
196179protected:
197 virtual ~__shared_weak_count();
180 ~__shared_weak_count() override;
198181
199182public:
200183#if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS)
......@@ -237,12 +220,12 @@ public:
237220 : __data_(__compressed_pair<_Tp, _Dp>(__p, _VSTD::move(__d)), _VSTD::move(__a)) {}
238221
239222#ifndef _LIBCPP_NO_RTTI
240 virtual const void* __get_deleter(const type_info&) const _NOEXCEPT;
223 const void* __get_deleter(const type_info&) const _NOEXCEPT override;
241224#endif
242225
243226private:
244 virtual void __on_zero_shared() _NOEXCEPT;
245 virtual void __on_zero_shared_weak() _NOEXCEPT;
227 void __on_zero_shared() _NOEXCEPT override;
228 void __on_zero_shared_weak() _NOEXCEPT override;
246229};
247230
248231#ifndef _LIBCPP_NO_RTTI
......@@ -277,6 +260,8 @@ __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT
277260 __a.deallocate(_PTraits::pointer_to(*this), 1);
278261}
279262
263struct __default_initialize_tag {};
264
280265template <class _Tp, class _Alloc>
281266struct __shared_ptr_emplace
282267 : __shared_weak_count
......@@ -295,6 +280,16 @@ struct __shared_ptr_emplace
295280#endif
296281 }
297282
283
284#if _LIBCPP_STD_VER >= 20
285 _LIBCPP_HIDE_FROM_ABI
286 explicit __shared_ptr_emplace(__default_initialize_tag, _Alloc __a)
287 : __storage_(std::move(__a))
288 {
289 ::new ((void*)__get_elem()) _Tp;
290 }
291#endif
292
298293 _LIBCPP_HIDE_FROM_ABI
299294 _Alloc* __get_alloc() _NOEXCEPT { return __storage_.__get_alloc(); }
300295
......@@ -302,7 +297,7 @@ struct __shared_ptr_emplace
302297 _Tp* __get_elem() _NOEXCEPT { return __storage_.__get_elem(); }
303298
304299private:
305 virtual void __on_zero_shared() _NOEXCEPT {
300 void __on_zero_shared() _NOEXCEPT override {
306301#if _LIBCPP_STD_VER > 17
307302 using _TpAlloc = typename __allocator_traits_rebind<_Alloc, _Tp>::type;
308303 _TpAlloc __tmp(*__get_alloc());
......@@ -312,7 +307,7 @@ private:
312307#endif
313308 }
314309
315 virtual void __on_zero_shared_weak() _NOEXCEPT {
310 void __on_zero_shared_weak() _NOEXCEPT override {
316311 using _ControlBlockAlloc = typename __allocator_traits_rebind<_Alloc, __shared_ptr_emplace>::type;
317312 using _ControlBlockPointer = typename allocator_traits<_ControlBlockAlloc>::pointer;
318313 _ControlBlockAlloc __tmp(*__get_alloc());
......@@ -383,22 +378,22 @@ struct __compatible_with
383378template <class _Ptr, class = void>
384379struct __is_deletable : false_type { };
385380template <class _Ptr>
386struct __is_deletable<_Ptr, decltype(delete declval<_Ptr>())> : true_type { };
381struct __is_deletable<_Ptr, decltype(delete std::declval<_Ptr>())> : true_type { };
387382
388383template <class _Ptr, class = void>
389384struct __is_array_deletable : false_type { };
390385template <class _Ptr>
391struct __is_array_deletable<_Ptr, decltype(delete[] declval<_Ptr>())> : true_type { };
386struct __is_array_deletable<_Ptr, decltype(delete[] std::declval<_Ptr>())> : true_type { };
392387
393388template <class _Dp, class _Pt,
394 class = decltype(declval<_Dp>()(declval<_Pt>()))>
389 class = decltype(std::declval<_Dp>()(std::declval<_Pt>()))>
395390static true_type __well_formed_deleter_test(int);
396391
397392template <class, class>
398393static false_type __well_formed_deleter_test(...);
399394
400395template <class _Dp, class _Pt>
401struct __well_formed_deleter : decltype(__well_formed_deleter_test<_Dp, _Pt>(0)) {};
396struct __well_formed_deleter : decltype(std::__well_formed_deleter_test<_Dp, _Pt>(0)) {};
402397
403398template<class _Dp, class _Tp, class _Yp>
404399struct __shared_ptr_deleter_ctor_reqs
......@@ -687,7 +682,7 @@ public:
687682 {
688683 typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
689684 typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer,
690 reference_wrapper<typename remove_reference<_Dp>::type>,
685 reference_wrapper<__libcpp_remove_reference_t<_Dp> >,
691686 _AllocT> _CntrlBlk;
692687 __cntrl_ = new _CntrlBlk(__r.get(), _VSTD::ref(__r.get_deleter()), _AllocT());
693688 __enable_weak_this(__r.get(), __r.get());
......@@ -802,7 +797,7 @@ public:
802797 }
803798
804799 _LIBCPP_HIDE_FROM_ABI
805 typename add_lvalue_reference<element_type>::type operator*() const _NOEXCEPT
800 __add_lvalue_reference_t<element_type> operator*() const _NOEXCEPT
806801 {
807802 return *__ptr_;
808803 }
......@@ -855,7 +850,7 @@ public:
855850
856851#if _LIBCPP_STD_VER > 14
857852 _LIBCPP_HIDE_FROM_ABI
858 typename add_lvalue_reference<element_type>::type operator[](ptrdiff_t __i) const
853 __add_lvalue_reference_t<element_type> operator[](ptrdiff_t __i) const
859854 {
860855 static_assert(is_array<_Tp>::value,
861856 "std::shared_ptr<T>::operator[] is only valid when T is an array type.");
......@@ -904,7 +899,7 @@ private:
904899 _LIBCPP_HIDE_FROM_ABI
905900 void __enable_weak_this(const enable_shared_from_this<_Yp>* __e, _OrigPtr* __ptr) _NOEXCEPT
906901 {
907 typedef typename remove_cv<_Yp>::type _RawYp;
902 typedef __remove_cv_t<_Yp> _RawYp;
908903 if (__e && __e->__weak_this_.expired())
909904 {
910905 __e->__weak_this_ = shared_ptr<_RawYp>(*this,
......@@ -962,6 +957,29 @@ shared_ptr<_Tp> make_shared(_Args&& ...__args)
962957 return _VSTD::allocate_shared<_Tp>(allocator<_Tp>(), _VSTD::forward<_Args>(__args)...);
963958}
964959
960#if _LIBCPP_STD_VER >= 20
961
962template<class _Tp, class _Alloc, __enable_if_t<!is_array<_Tp>::value, int> = 0>
963_LIBCPP_HIDE_FROM_ABI
964shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc& __a)
965{
966 using _ControlBlock = __shared_ptr_emplace<_Tp, _Alloc>;
967 using _ControlBlockAllocator = typename __allocator_traits_rebind<_Alloc, _ControlBlock>::type;
968 __allocation_guard<_ControlBlockAllocator> __guard(__a, 1);
969 ::new ((void*)_VSTD::addressof(*__guard.__get())) _ControlBlock(__default_initialize_tag{}, __a);
970 auto __control_block = __guard.__release_ptr();
971 return shared_ptr<_Tp>::__create_with_control_block((*__control_block).__get_elem(), _VSTD::addressof(*__control_block));
972}
973
974template<class _Tp, __enable_if_t<!is_array<_Tp>::value, int> = 0>
975_LIBCPP_HIDE_FROM_ABI
976shared_ptr<_Tp> make_shared_for_overwrite()
977{
978 return std::allocate_shared_for_overwrite<_Tp>(allocator<_Tp>());
979}
980
981#endif // _LIBCPP_STD_VER >= 20
982
965983#if _LIBCPP_STD_VER > 14
966984
967985template <size_t _Alignment>
......@@ -992,6 +1010,17 @@ struct __unbounded_array_control_block<_Tp[], _Alloc> : __shared_weak_count
9921010 std::__uninitialized_allocator_value_construct_n(__alloc_, std::begin(__data_), __count_);
9931011 }
9941012
1013#if _LIBCPP_STD_VER >= 20
1014 _LIBCPP_HIDE_FROM_ABI
1015 explicit __unbounded_array_control_block(_Alloc const& __alloc, size_t __count, __default_initialize_tag)
1016 : __alloc_(__alloc), __count_(__count)
1017 {
1018 // We are purposefully not using an allocator-aware default construction because the spec says so.
1019 // There's currently no way of expressing default initialization in an allocator-aware manner anyway.
1020 std::uninitialized_default_construct_n(std::begin(__data_), __count_);
1021 }
1022#endif
1023
9951024 // Returns the number of bytes required to store a control block followed by the given number
9961025 // of elements of _Tp, with the whole storage being aligned to a multiple of _Tp's alignment.
9971026 _LIBCPP_HIDE_FROM_ABI
......@@ -1008,7 +1037,7 @@ struct __unbounded_array_control_block<_Tp[], _Alloc> : __shared_weak_count
10081037 return (__bytes + __align - 1) & ~(__align - 1);
10091038 }
10101039
1011 _LIBCPP_HIDE_FROM_ABI
1040 _LIBCPP_HIDE_FROM_ABI_VIRTUAL
10121041 ~__unbounded_array_control_block() override { } // can't be `= default` because of the sometimes-non-trivial union member __data_
10131042
10141043private:
......@@ -1075,7 +1104,16 @@ struct __bounded_array_control_block<_Tp[_Count], _Alloc>
10751104 std::__uninitialized_allocator_value_construct_n(__alloc_, std::addressof(__data_[0]), _Count);
10761105 }
10771106
1107#if _LIBCPP_STD_VER >= 20
10781108 _LIBCPP_HIDE_FROM_ABI
1109 explicit __bounded_array_control_block(_Alloc const& __alloc, __default_initialize_tag) : __alloc_(__alloc) {
1110 // We are purposefully not using an allocator-aware default construction because the spec says so.
1111 // There's currently no way of expressing default initialization in an allocator-aware manner anyway.
1112 std::uninitialized_default_construct_n(std::addressof(__data_[0]), _Count);
1113 }
1114#endif
1115
1116 _LIBCPP_HIDE_FROM_ABI_VIRTUAL
10791117 ~__bounded_array_control_block() override { } // can't be `= default` because of the sometimes-non-trivial union member __data_
10801118
10811119private:
......@@ -1118,6 +1156,7 @@ shared_ptr<_Array> __allocate_shared_bounded_array(const _Alloc& __a, _Arg&& ...
11181156
11191157#if _LIBCPP_STD_VER > 17
11201158
1159// bounded array variants
11211160template<class _Tp, class _Alloc, class = __enable_if_t<is_bounded_array<_Tp>::value>>
11221161_LIBCPP_HIDE_FROM_ABI
11231162shared_ptr<_Tp> allocate_shared(const _Alloc& __a)
......@@ -1132,18 +1171,11 @@ shared_ptr<_Tp> allocate_shared(const _Alloc& __a, const remove_extent_t<_Tp>& _
11321171 return std::__allocate_shared_bounded_array<_Tp>(__a, __u);
11331172}
11341173
1135template<class _Tp, class _Alloc, class = __enable_if_t<is_unbounded_array<_Tp>::value>>
1174template<class _Tp, class _Alloc, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0>
11361175_LIBCPP_HIDE_FROM_ABI
1137shared_ptr<_Tp> allocate_shared(const _Alloc& __a, size_t __n)
1176shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc& __a)
11381177{
1139 return std::__allocate_shared_unbounded_array<_Tp>(__a, __n);
1140}
1141
1142template<class _Tp, class _Alloc, class = __enable_if_t<is_unbounded_array<_Tp>::value>>
1143_LIBCPP_HIDE_FROM_ABI
1144shared_ptr<_Tp> allocate_shared(const _Alloc& __a, size_t __n, const remove_extent_t<_Tp>& __u)
1145{
1146 return std::__allocate_shared_unbounded_array<_Tp>(__a, __n, __u);
1178 return std::__allocate_shared_bounded_array<_Tp>(__a, __default_initialize_tag{});
11471179}
11481180
11491181template<class _Tp, class = __enable_if_t<is_bounded_array<_Tp>::value>>
......@@ -1160,6 +1192,35 @@ shared_ptr<_Tp> make_shared(const remove_extent_t<_Tp>& __u)
11601192 return std::__allocate_shared_bounded_array<_Tp>(allocator<_Tp>(), __u);
11611193}
11621194
1195template<class _Tp, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0>
1196_LIBCPP_HIDE_FROM_ABI
1197shared_ptr<_Tp> make_shared_for_overwrite()
1198{
1199 return std::__allocate_shared_bounded_array<_Tp>(allocator<_Tp>(), __default_initialize_tag{});
1200}
1201
1202// unbounded array variants
1203template<class _Tp, class _Alloc, class = __enable_if_t<is_unbounded_array<_Tp>::value>>
1204_LIBCPP_HIDE_FROM_ABI
1205shared_ptr<_Tp> allocate_shared(const _Alloc& __a, size_t __n)
1206{
1207 return std::__allocate_shared_unbounded_array<_Tp>(__a, __n);
1208}
1209
1210template<class _Tp, class _Alloc, class = __enable_if_t<is_unbounded_array<_Tp>::value>>
1211_LIBCPP_HIDE_FROM_ABI
1212shared_ptr<_Tp> allocate_shared(const _Alloc& __a, size_t __n, const remove_extent_t<_Tp>& __u)
1213{
1214 return std::__allocate_shared_unbounded_array<_Tp>(__a, __n, __u);
1215}
1216
1217template<class _Tp, class _Alloc, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0>
1218_LIBCPP_HIDE_FROM_ABI
1219shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc& __a, size_t __n)
1220{
1221 return std::__allocate_shared_unbounded_array<_Tp>(__a, __n, __default_initialize_tag{});
1222}
1223
11631224template<class _Tp, class = __enable_if_t<is_unbounded_array<_Tp>::value>>
11641225_LIBCPP_HIDE_FROM_ABI
11651226shared_ptr<_Tp> make_shared(size_t __n)
......@@ -1174,6 +1235,13 @@ shared_ptr<_Tp> make_shared(size_t __n, const remove_extent_t<_Tp>& __u)
11741235 return std::__allocate_shared_unbounded_array<_Tp>(allocator<_Tp>(), __n, __u);
11751236}
11761237
1238template<class _Tp, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0>
1239_LIBCPP_HIDE_FROM_ABI
1240shared_ptr<_Tp> make_shared_for_overwrite(size_t __n)
1241{
1242 return std::__allocate_shared_unbounded_array<_Tp>(allocator<_Tp>(), __n, __default_initialize_tag{});
1243}
1244
11771245#endif // _LIBCPP_STD_VER > 17
11781246
11791247template<class _Tp, class _Up>
......@@ -1184,6 +1252,8 @@ operator==(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
11841252 return __x.get() == __y.get();
11851253}
11861254
1255#if _LIBCPP_STD_VER <= 17
1256
11871257template<class _Tp, class _Up>
11881258inline _LIBCPP_INLINE_VISIBILITY
11891259bool
......@@ -1230,6 +1300,17 @@ operator>=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
12301300 return !(__x < __y);
12311301}
12321302
1303#endif // _LIBCPP_STD_VER <= 17
1304
1305#if _LIBCPP_STD_VER > 17
1306template<class _Tp, class _Up>
1307_LIBCPP_HIDE_FROM_ABI strong_ordering
1308operator<=>(shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) noexcept
1309{
1310 return compare_three_way()(__x.get(), __y.get());
1311}
1312#endif
1313
12331314template<class _Tp>
12341315inline _LIBCPP_INLINE_VISIBILITY
12351316bool
......@@ -1238,6 +1319,8 @@ operator==(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
12381319 return !__x;
12391320}
12401321
1322#if _LIBCPP_STD_VER <= 17
1323
12411324template<class _Tp>
12421325inline _LIBCPP_INLINE_VISIBILITY
12431326bool
......@@ -1326,6 +1409,17 @@ operator>=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
13261409 return !(nullptr < __x);
13271410}
13281411
1412#endif // _LIBCPP_STD_VER <= 17
1413
1414#if _LIBCPP_STD_VER > 17
1415template<class _Tp>
1416_LIBCPP_HIDE_FROM_ABI strong_ordering
1417operator<=>(shared_ptr<_Tp> const& __x, nullptr_t) noexcept
1418{
1419 return compare_three_way()(__x.get(), static_cast<typename shared_ptr<_Tp>::element_type*>(nullptr));
1420}
1421#endif
1422
13291423template<class _Tp>
13301424inline _LIBCPP_INLINE_VISIBILITY
13311425void
......@@ -1355,7 +1449,7 @@ dynamic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
13551449}
13561450
13571451template<class _Tp, class _Up>
1358shared_ptr<_Tp>
1452_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>
13591453const_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
13601454{
13611455 typedef typename shared_ptr<_Tp>::element_type _RTp;
......@@ -1363,7 +1457,7 @@ const_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
13631457}
13641458
13651459template<class _Tp, class _Up>
1366shared_ptr<_Tp>
1460_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>
13671461reinterpret_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
13681462{
13691463 return shared_ptr<_Tp>(__r,
......@@ -1771,7 +1865,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p);
17711865
17721866class _LIBCPP_TYPE_VIS __sp_mut
17731867{
1774 void* __lx;
1868 void* __lx_;
17751869public:
17761870 void lock() _NOEXCEPT;
17771871 void unlock() _NOEXCEPT;
......@@ -1797,10 +1891,10 @@ atomic_is_lock_free(const shared_ptr<_Tp>*)
17971891
17981892template <class _Tp>
17991893_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
1800shared_ptr<_Tp>
1894_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>
18011895atomic_load(const shared_ptr<_Tp>* __p)
18021896{
1803 __sp_mut& __m = __get_sp_mut(__p);
1897 __sp_mut& __m = std::__get_sp_mut(__p);
18041898 __m.lock();
18051899 shared_ptr<_Tp> __q = *__p;
18061900 __m.unlock();
......@@ -1813,15 +1907,15 @@ _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
18131907shared_ptr<_Tp>
18141908atomic_load_explicit(const shared_ptr<_Tp>* __p, memory_order)
18151909{
1816 return atomic_load(__p);
1910 return std::atomic_load(__p);
18171911}
18181912
18191913template <class _Tp>
18201914_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
1821void
1915_LIBCPP_HIDE_FROM_ABI void
18221916atomic_store(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r)
18231917{
1824 __sp_mut& __m = __get_sp_mut(__p);
1918 __sp_mut& __m = std::__get_sp_mut(__p);
18251919 __m.lock();
18261920 __p->swap(__r);
18271921 __m.unlock();
......@@ -1833,15 +1927,15 @@ _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
18331927void
18341928atomic_store_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order)
18351929{
1836 atomic_store(__p, __r);
1930 std::atomic_store(__p, __r);
18371931}
18381932
18391933template <class _Tp>
18401934_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
1841shared_ptr<_Tp>
1935_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>
18421936atomic_exchange(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r)
18431937{
1844 __sp_mut& __m = __get_sp_mut(__p);
1938 __sp_mut& __m = std::__get_sp_mut(__p);
18451939 __m.lock();
18461940 __p->swap(__r);
18471941 __m.unlock();
......@@ -1854,16 +1948,16 @@ _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
18541948shared_ptr<_Tp>
18551949atomic_exchange_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order)
18561950{
1857 return atomic_exchange(__p, __r);
1951 return std::atomic_exchange(__p, __r);
18581952}
18591953
18601954template <class _Tp>
18611955_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
1862bool
1956_LIBCPP_HIDE_FROM_ABI bool
18631957atomic_compare_exchange_strong(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w)
18641958{
18651959 shared_ptr<_Tp> __temp;
1866 __sp_mut& __m = __get_sp_mut(__p);
1960 __sp_mut& __m = std::__get_sp_mut(__p);
18671961 __m.lock();
18681962 if (__p->__owner_equivalent(*__v))
18691963 {
......@@ -1884,7 +1978,7 @@ _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
18841978bool
18851979atomic_compare_exchange_weak(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w)
18861980{
1887 return atomic_compare_exchange_strong(__p, __v, __w);
1981 return std::atomic_compare_exchange_strong(__p, __v, __w);
18881982}
18891983
18901984template <class _Tp>
......@@ -1894,7 +1988,7 @@ bool
18941988atomic_compare_exchange_strong_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v,
18951989 shared_ptr<_Tp> __w, memory_order, memory_order)
18961990{
1897 return atomic_compare_exchange_strong(__p, __v, __w);
1991 return std::atomic_compare_exchange_strong(__p, __v, __w);
18981992}
18991993
19001994template <class _Tp>
......@@ -1904,7 +1998,7 @@ bool
19041998atomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v,
19051999 shared_ptr<_Tp> __w, memory_order, memory_order)
19062000{
1907 return atomic_compare_exchange_weak(__p, __v, __w);
2001 return std::atomic_compare_exchange_weak(__p, __v, __w);
19082002}
19092003
19102004#endif // !defined(_LIBCPP_HAS_NO_THREADS)
lib/libcxx/include/__memory/swap_allocator.h+4-3
......@@ -12,6 +12,7 @@
1212#include <__config>
1313#include <__memory/allocator_traits.h>
1414#include <__type_traits/integral_constant.h>
15#include <__type_traits/is_swappable.h>
1516#include <__utility/swap.h>
1617
1718#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -21,7 +22,7 @@
2122_LIBCPP_BEGIN_NAMESPACE_STD
2223
2324template <typename _Alloc>
24_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void __swap_allocator(_Alloc& __a1, _Alloc& __a2, true_type)
25_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __swap_allocator(_Alloc& __a1, _Alloc& __a2, true_type)
2526#if _LIBCPP_STD_VER > 11
2627 _NOEXCEPT
2728#else
......@@ -33,11 +34,11 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void __swap_allocator(_Alloc
3334}
3435
3536template <typename _Alloc>
36inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void
37inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
3738__swap_allocator(_Alloc&, _Alloc&, false_type) _NOEXCEPT {}
3839
3940template <typename _Alloc>
40inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void __swap_allocator(_Alloc& __a1, _Alloc& __a2)
41inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __swap_allocator(_Alloc& __a1, _Alloc& __a2)
4142#if _LIBCPP_STD_VER > 11
4243 _NOEXCEPT
4344#else
lib/libcxx/include/__memory/temp_value.h created+56
......@@ -0,0 +1,56 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___MEMORY_TEMP_VALUE_H
10#define _LIBCPP___MEMORY_TEMP_VALUE_H
11
12#include <__config>
13#include <__memory/addressof.h>
14#include <__memory/allocator_traits.h>
15#include <__type_traits/aligned_storage.h>
16#include <__utility/forward.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24template <class _Tp, class _Alloc>
25struct __temp_value {
26 typedef allocator_traits<_Alloc> _Traits;
27
28#ifdef _LIBCPP_CXX03_LANG
29 typename aligned_storage<sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)>::type __v;
30#else
31 union { _Tp __v; };
32#endif
33 _Alloc &__a;
34
35 _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp *__addr() {
36#ifdef _LIBCPP_CXX03_LANG
37 return reinterpret_cast<_Tp*>(std::addressof(__v));
38#else
39 return std::addressof(__v);
40#endif
41 }
42
43 _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp & get() { return *__addr(); }
44
45 template<class... _Args>
46 _LIBCPP_NO_CFI
47 _LIBCPP_CONSTEXPR_SINCE_CXX20 __temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) {
48 _Traits::construct(__a, __addr(), std::forward<_Args>(__args)...);
49 }
50
51 _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__temp_value() { _Traits::destroy(__a, __addr()); }
52};
53
54_LIBCPP_END_NAMESPACE_STD
55
56#endif // _LIBCPP___MEMORY_TEMP_VALUE_H
lib/libcxx/include/__memory/temporary_buffer.h+1-1
......@@ -23,7 +23,7 @@
2323_LIBCPP_BEGIN_NAMESPACE_STD
2424
2525template <class _Tp>
26_LIBCPP_NODISCARD_EXT _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX17
26_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX17
2727pair<_Tp*, ptrdiff_t>
2828get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT
2929{
lib/libcxx/include/__memory/uninitialized_algorithms.h+37-33
......@@ -20,11 +20,21 @@
2020#include <__memory/construct_at.h>
2121#include <__memory/pointer_traits.h>
2222#include <__memory/voidify.h>
23#include <__type_traits/extent.h>
24#include <__type_traits/is_array.h>
2325#include <__type_traits/is_constant_evaluated.h>
26#include <__type_traits/is_trivially_copy_assignable.h>
27#include <__type_traits/is_trivially_copy_constructible.h>
28#include <__type_traits/is_trivially_move_assignable.h>
29#include <__type_traits/is_trivially_move_constructible.h>
30#include <__type_traits/is_unbounded_array.h>
31#include <__type_traits/negation.h>
32#include <__type_traits/remove_const.h>
33#include <__type_traits/remove_extent.h>
34#include <__utility/exception_guard.h>
2435#include <__utility/move.h>
2536#include <__utility/pair.h>
26#include <__utility/transaction.h>
27#include <type_traits>
37#include <new>
2838
2939#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3040# pragma GCC system_header
......@@ -64,6 +74,7 @@ __uninitialized_copy(_InputIterator __ifirst, _Sentinel1 __ilast,
6474}
6575
6676template <class _InputIterator, class _ForwardIterator>
77_LIBCPP_HIDE_FROM_ABI
6778_ForwardIterator uninitialized_copy(_InputIterator __ifirst, _InputIterator __ilast,
6879 _ForwardIterator __ofirst) {
6980 typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType;
......@@ -282,7 +293,7 @@ template <class _ForwardIterator, class _Size>
282293inline _LIBCPP_HIDE_FROM_ABI
283294_ForwardIterator uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) {
284295 using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;
285 return __uninitialized_value_construct_n<_ValueType>(_VSTD::move(__first), __n);
296 return std::__uninitialized_value_construct_n<_ValueType>(_VSTD::move(__first), __n);
286297}
287298
288299// uninitialized_move
......@@ -410,7 +421,10 @@ constexpr void __allocator_construct_at(_Alloc& __alloc, _Tp* __loc) {
410421 _Tp& __array = *__loc;
411422
412423 // If an exception is thrown, destroy what we have constructed so far in reverse order.
413 __transaction __guard([&]() { std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + __i); });
424 __exception_guard __guard([&]() {
425 std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + __i);
426 });
427
414428 for (; __i != extent_v<_Tp>; ++__i) {
415429 std::__allocator_construct_at(__elem_alloc, std::addressof(__array[__i]));
416430 }
......@@ -447,7 +461,9 @@ constexpr void __allocator_construct_at(_Alloc& __alloc, _Tp* __loc, _Arg const&
447461 _Tp& __array = *__loc;
448462
449463 // If an exception is thrown, destroy what we have constructed so far in reverse order.
450 __transaction __guard([&]() { std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + __i); });
464 __exception_guard __guard([&]() {
465 std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + __i);
466 });
451467 for (; __i != extent_v<_Tp>; ++__i) {
452468 std::__allocator_construct_at(__elem_alloc, std::addressof(__array[__i]), __arg[__i]);
453469 }
......@@ -472,7 +488,7 @@ constexpr void __uninitialized_allocator_fill_n(_Alloc& __alloc, _BidirIter __it
472488 _BidirIter __begin = __it;
473489
474490 // If an exception is thrown, destroy what we have constructed so far in reverse order.
475 __transaction __guard([&]() { std::__allocator_destroy_multidimensional(__value_alloc, __begin, __it); });
491 __exception_guard __guard([&]() { std::__allocator_destroy_multidimensional(__value_alloc, __begin, __it); });
476492 for (; __n != 0; --__n, ++__it) {
477493 std::__allocator_construct_at(__value_alloc, std::addressof(*__it), __value);
478494 }
......@@ -489,7 +505,7 @@ constexpr void __uninitialized_allocator_value_construct_n(_Alloc& __alloc, _Bid
489505 _BidirIter __begin = __it;
490506
491507 // If an exception is thrown, destroy what we have constructed so far in reverse order.
492 __transaction __guard([&]() { std::__allocator_destroy_multidimensional(__value_alloc, __begin, __it); });
508 __exception_guard __guard([&]() { std::__allocator_destroy_multidimensional(__value_alloc, __begin, __it); });
493509 for (; __n != 0; --__n, ++__it) {
494510 std::__allocator_construct_at(__value_alloc, std::addressof(*__it));
495511 }
......@@ -500,7 +516,7 @@ constexpr void __uninitialized_allocator_value_construct_n(_Alloc& __alloc, _Bid
500516
501517// Destroy all elements in [__first, __last) from left to right using allocator destruction.
502518template <class _Alloc, class _Iter, class _Sent>
503_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void
519_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
504520__allocator_destroy(_Alloc& __alloc, _Iter __first, _Sent __last) {
505521 for (; __first != __last; ++__first)
506522 allocator_traits<_Alloc>::destroy(__alloc, std::__to_address(__first));
......@@ -509,11 +525,11 @@ __allocator_destroy(_Alloc& __alloc, _Iter __first, _Sent __last) {
509525template <class _Alloc, class _Iter>
510526class _AllocatorDestroyRangeReverse {
511527public:
512 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
528 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
513529 _AllocatorDestroyRangeReverse(_Alloc& __alloc, _Iter& __first, _Iter& __last)
514530 : __alloc_(__alloc), __first_(__first), __last_(__last) {}
515531
516 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void operator()() const {
532 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void operator()() const {
517533 std::__allocator_destroy(__alloc_, std::reverse_iterator<_Iter>(__last_), std::reverse_iterator<_Iter>(__first_));
518534 }
519535
......@@ -528,23 +544,17 @@ private:
528544// The caller has to ensure that __first2 can hold at least N uninitialized elements. If an exception is thrown the
529545// already copied elements are destroyed in reverse order of their construction.
530546template <class _Alloc, class _Iter1, class _Sent1, class _Iter2>
531_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2
547_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter2
532548__uninitialized_allocator_copy(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) {
533#ifndef _LIBCPP_NO_EXCEPTIONS
534549 auto __destruct_first = __first2;
535 try {
536#endif
550 auto __guard =
551 std::__make_exception_guard(_AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2));
537552 while (__first1 != __last1) {
538553 allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), *__first1);
539554 ++__first1;
540555 ++__first2;
541556 }
542#ifndef _LIBCPP_NO_EXCEPTIONS
543 } catch (...) {
544 _AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2)();
545 throw;
546 }
547#endif
557 __guard.__complete();
548558 return __first2;
549559}
550560
......@@ -556,12 +566,12 @@ struct __allocator_has_trivial_copy_construct<allocator<_Type>, _Type> : true_ty
556566
557567template <class _Alloc,
558568 class _Type,
559 class _RawType = typename remove_const<_Type>::type,
569 class _RawType = __remove_const_t<_Type>,
560570 __enable_if_t<
561571 // using _RawType because of the allocator<T const> extension
562572 is_trivially_copy_constructible<_RawType>::value && is_trivially_copy_assignable<_RawType>::value &&
563573 __allocator_has_trivial_copy_construct<_Alloc, _RawType>::value>* = nullptr>
564_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Type*
574_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Type*
565575__uninitialized_allocator_copy(_Alloc&, const _Type* __first1, const _Type* __last1, _Type* __first2) {
566576 // TODO: Remove the const_cast once we drop support for std::allocator<T const>
567577 if (__libcpp_is_constant_evaluated()) {
......@@ -582,14 +592,13 @@ __uninitialized_allocator_copy(_Alloc&, const _Type* __first1, const _Type* __la
582592// Otherwise try to copy all elements. If an exception is thrown the already copied
583593// elements are destroyed in reverse order of their construction.
584594template <class _Alloc, class _Iter1, class _Sent1, class _Iter2>
585_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2 __uninitialized_allocator_move_if_noexcept(
595_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter2 __uninitialized_allocator_move_if_noexcept(
586596 _Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) {
587597 static_assert(__is_cpp17_move_insertable<_Alloc>::value,
588598 "The specified type does not meet the requirements of Cpp17MoveInsertable");
589#ifndef _LIBCPP_NO_EXCEPTIONS
590599 auto __destruct_first = __first2;
591 try {
592#endif
600 auto __guard =
601 std::__make_exception_guard(_AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2));
593602 while (__first1 != __last1) {
594603#ifndef _LIBCPP_NO_EXCEPTIONS
595604 allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), std::move_if_noexcept(*__first1));
......@@ -599,12 +608,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2 __uninitialized_alloc
599608 ++__first1;
600609 ++__first2;
601610 }
602#ifndef _LIBCPP_NO_EXCEPTIONS
603 } catch (...) {
604 _AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2)();
605 throw;
606 }
607#endif
611 __guard.__complete();
608612 return __first2;
609613}
610614
......@@ -622,7 +626,7 @@ template <
622626 class _Type = typename iterator_traits<_Iter1>::value_type,
623627 class = __enable_if_t<is_trivially_move_constructible<_Type>::value && is_trivially_move_assignable<_Type>::value &&
624628 __allocator_has_trivial_move_construct<_Alloc, _Type>::value> >
625_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2
629_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter2
626630__uninitialized_allocator_move_if_noexcept(_Alloc&, _Iter1 __first1, _Iter1 __last1, _Iter2 __first2) {
627631 if (__libcpp_is_constant_evaluated()) {
628632 while (__first1 != __last1) {
lib/libcxx/include/__memory/unique_ptr.h+197-208
......@@ -10,16 +10,35 @@
1010#ifndef _LIBCPP___MEMORY_UNIQUE_PTR_H
1111#define _LIBCPP___MEMORY_UNIQUE_PTR_H
1212
13#include <__compare/compare_three_way.h>
14#include <__compare/compare_three_way_result.h>
15#include <__compare/three_way_comparable.h>
1316#include <__config>
1417#include <__functional/hash.h>
1518#include <__functional/operations.h>
1619#include <__memory/allocator_traits.h> // __pointer
1720#include <__memory/auto_ptr.h>
1821#include <__memory/compressed_pair.h>
22#include <__type_traits/add_lvalue_reference.h>
23#include <__type_traits/common_type.h>
24#include <__type_traits/dependent_type.h>
25#include <__type_traits/integral_constant.h>
26#include <__type_traits/is_array.h>
27#include <__type_traits/is_assignable.h>
28#include <__type_traits/is_constructible.h>
29#include <__type_traits/is_convertible.h>
30#include <__type_traits/is_default_constructible.h>
31#include <__type_traits/is_function.h>
32#include <__type_traits/is_pointer.h>
33#include <__type_traits/is_reference.h>
34#include <__type_traits/is_same.h>
35#include <__type_traits/is_swappable.h>
36#include <__type_traits/is_void.h>
37#include <__type_traits/remove_extent.h>
38#include <__type_traits/type_identity.h>
1939#include <__utility/forward.h>
2040#include <__utility/move.h>
2141#include <cstddef>
22#include <type_traits>
2342
2443#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2544# pragma GCC system_header
......@@ -37,12 +56,10 @@ struct _LIBCPP_TEMPLATE_VIS default_delete {
3756 _LIBCPP_INLINE_VISIBILITY default_delete() {}
3857#endif
3958 template <class _Up>
40 _LIBCPP_INLINE_VISIBILITY
41 default_delete(const default_delete<_Up>&,
42 typename enable_if<is_convertible<_Up*, _Tp*>::value>::type* =
43 0) _NOEXCEPT {}
59 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 default_delete(
60 const default_delete<_Up>&, typename enable_if<is_convertible<_Up*, _Tp*>::value>::type* = 0) _NOEXCEPT {}
4461
45 _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __ptr) const _NOEXCEPT {
62 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator()(_Tp* __ptr) const _NOEXCEPT {
4663 static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type");
4764 static_assert(!is_void<_Tp>::value, "cannot delete an incomplete type");
4865 delete __ptr;
......@@ -64,13 +81,11 @@ public:
6481#endif
6582
6683 template <class _Up>
67 _LIBCPP_INLINE_VISIBILITY
68 default_delete(const default_delete<_Up[]>&,
69 typename _EnableIfConvertible<_Up>::type* = 0) _NOEXCEPT {}
84 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
85 default_delete(const default_delete<_Up[]>&, typename _EnableIfConvertible<_Up>::type* = 0) _NOEXCEPT {}
7086
7187 template <class _Up>
72 _LIBCPP_INLINE_VISIBILITY
73 typename _EnableIfConvertible<_Up>::type
88 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 typename _EnableIfConvertible<_Up>::type
7489 operator()(_Up* __ptr) const _NOEXCEPT {
7590 static_assert(sizeof(_Up) >= 0, "cannot delete an incomplete type");
7691 delete[] __ptr;
......@@ -172,22 +187,17 @@ public:
172187 _LIBCPP_INLINE_VISIBILITY
173188 _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {}
174189
175 template <bool _Dummy = true,
176 class = _EnableIfDeleterDefaultConstructible<_Dummy> >
177 _LIBCPP_INLINE_VISIBILITY
178 explicit unique_ptr(pointer __p) _NOEXCEPT : __ptr_(__p, __value_init_tag()) {}
190 template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >
191 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(pointer __p) _NOEXCEPT
192 : __ptr_(__p, __value_init_tag()) {}
179193
180 template <bool _Dummy = true,
181 class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >
182 _LIBCPP_INLINE_VISIBILITY
183 unique_ptr(pointer __p, _LValRefType<_Dummy> __d) _NOEXCEPT
194 template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >
195 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, _LValRefType<_Dummy> __d) _NOEXCEPT
184196 : __ptr_(__p, __d) {}
185197
186 template <bool _Dummy = true,
187 class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >
188 _LIBCPP_INLINE_VISIBILITY
189 unique_ptr(pointer __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
190 : __ptr_(__p, _VSTD::move(__d)) {
198 template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >
199 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
200 unique_ptr(pointer __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT : __ptr_(__p, _VSTD::move(__d)) {
191201 static_assert(!is_reference<deleter_type>::value,
192202 "rvalue deleter bound to reference");
193203 }
......@@ -197,17 +207,14 @@ public:
197207 _LIBCPP_INLINE_VISIBILITY
198208 unique_ptr(pointer __p, _BadRValRefType<_Dummy> __d) = delete;
199209
200 _LIBCPP_INLINE_VISIBILITY
201 unique_ptr(unique_ptr&& __u) _NOEXCEPT
202 : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {
203 }
210 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) _NOEXCEPT
211 : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {}
204212
205 template <class _Up, class _Ep,
206 class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
207 class = _EnableIfDeleterConvertible<_Ep>
208 >
209 _LIBCPP_INLINE_VISIBILITY
210 unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT
213 template <class _Up,
214 class _Ep,
215 class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
216 class = _EnableIfDeleterConvertible<_Ep> >
217 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT
211218 : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {}
212219
213220#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
......@@ -220,19 +227,17 @@ public:
220227 : __ptr_(__p.release(), __value_init_tag()) {}
221228#endif
222229
223 _LIBCPP_INLINE_VISIBILITY
224 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {
230 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {
225231 reset(__u.release());
226232 __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter());
227233 return *this;
228234 }
229235
230 template <class _Up, class _Ep,
231 class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
232 class = _EnableIfDeleterAssignable<_Ep>
233 >
234 _LIBCPP_INLINE_VISIBILITY
235 unique_ptr& operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT {
236 template <class _Up,
237 class _Ep,
238 class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
239 class = _EnableIfDeleterAssignable<_Ep> >
240 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT {
236241 reset(__u.release());
237242 __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter());
238243 return *this;
......@@ -255,58 +260,44 @@ public:
255260 unique_ptr& operator=(unique_ptr const&) = delete;
256261#endif
257262
258 _LIBCPP_INLINE_VISIBILITY
259 ~unique_ptr() { reset(); }
263 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }
260264
261 _LIBCPP_INLINE_VISIBILITY
262 unique_ptr& operator=(nullptr_t) _NOEXCEPT {
265 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(nullptr_t) _NOEXCEPT {
263266 reset();
264267 return *this;
265268 }
266269
267 _LIBCPP_INLINE_VISIBILITY
268 typename add_lvalue_reference<_Tp>::type
269 operator*() const {
270 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator*() const {
270271 return *__ptr_.first();
271272 }
272 _LIBCPP_INLINE_VISIBILITY
273 pointer operator->() const _NOEXCEPT {
274 return __ptr_.first();
275 }
276 _LIBCPP_INLINE_VISIBILITY
277 pointer get() const _NOEXCEPT {
273 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer operator->() const _NOEXCEPT {
278274 return __ptr_.first();
279275 }
280 _LIBCPP_INLINE_VISIBILITY
281 deleter_type& get_deleter() _NOEXCEPT {
276 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_.first(); }
277 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT {
282278 return __ptr_.second();
283279 }
284 _LIBCPP_INLINE_VISIBILITY
285 const deleter_type& get_deleter() const _NOEXCEPT {
280 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 const deleter_type& get_deleter() const _NOEXCEPT {
286281 return __ptr_.second();
287282 }
288 _LIBCPP_INLINE_VISIBILITY
289 explicit operator bool() const _NOEXCEPT {
283 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit operator bool() const _NOEXCEPT {
290284 return __ptr_.first() != nullptr;
291285 }
292286
293 _LIBCPP_INLINE_VISIBILITY
294 pointer release() _NOEXCEPT {
287 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer release() _NOEXCEPT {
295288 pointer __t = __ptr_.first();
296289 __ptr_.first() = pointer();
297290 return __t;
298291 }
299292
300 _LIBCPP_INLINE_VISIBILITY
301 void reset(pointer __p = pointer()) _NOEXCEPT {
293 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(pointer __p = pointer()) _NOEXCEPT {
302294 pointer __tmp = __ptr_.first();
303295 __ptr_.first() = __p;
304296 if (__tmp)
305297 __ptr_.second()(__tmp);
306298 }
307299
308 _LIBCPP_INLINE_VISIBILITY
309 void swap(unique_ptr& __u) _NOEXCEPT {
300 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT {
310301 __ptr_.swap(__u.__ptr_);
311302 }
312303};
......@@ -394,40 +385,36 @@ public:
394385 _LIBCPP_INLINE_VISIBILITY
395386 _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {}
396387
397 template <class _Pp, bool _Dummy = true,
398 class = _EnableIfDeleterDefaultConstructible<_Dummy>,
399 class = _EnableIfPointerConvertible<_Pp> >
400 _LIBCPP_INLINE_VISIBILITY
401 explicit unique_ptr(_Pp __p) _NOEXCEPT
388 template <class _Pp,
389 bool _Dummy = true,
390 class = _EnableIfDeleterDefaultConstructible<_Dummy>,
391 class = _EnableIfPointerConvertible<_Pp> >
392 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(_Pp __p) _NOEXCEPT
402393 : __ptr_(__p, __value_init_tag()) {}
403394
404 template <class _Pp, bool _Dummy = true,
405 class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> >,
406 class = _EnableIfPointerConvertible<_Pp> >
407 _LIBCPP_INLINE_VISIBILITY
408 unique_ptr(_Pp __p, _LValRefType<_Dummy> __d) _NOEXCEPT
395 template <class _Pp,
396 bool _Dummy = true,
397 class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> >,
398 class = _EnableIfPointerConvertible<_Pp> >
399 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(_Pp __p, _LValRefType<_Dummy> __d) _NOEXCEPT
409400 : __ptr_(__p, __d) {}
410401
411 template <bool _Dummy = true,
412 class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >
413 _LIBCPP_INLINE_VISIBILITY
414 unique_ptr(nullptr_t, _LValRefType<_Dummy> __d) _NOEXCEPT
402 template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >
403 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(nullptr_t, _LValRefType<_Dummy> __d) _NOEXCEPT
415404 : __ptr_(nullptr, __d) {}
416405
417 template <class _Pp, bool _Dummy = true,
418 class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> >,
419 class = _EnableIfPointerConvertible<_Pp> >
420 _LIBCPP_INLINE_VISIBILITY
421 unique_ptr(_Pp __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
406 template <class _Pp,
407 bool _Dummy = true,
408 class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> >,
409 class = _EnableIfPointerConvertible<_Pp> >
410 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(_Pp __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
422411 : __ptr_(__p, _VSTD::move(__d)) {
423412 static_assert(!is_reference<deleter_type>::value,
424413 "rvalue deleter bound to reference");
425414 }
426415
427 template <bool _Dummy = true,
428 class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >
429 _LIBCPP_INLINE_VISIBILITY
430 unique_ptr(nullptr_t, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
416 template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >
417 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(nullptr_t, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
431418 : __ptr_(nullptr, _VSTD::move(__d)) {
432419 static_assert(!is_reference<deleter_type>::value,
433420 "rvalue deleter bound to reference");
......@@ -439,34 +426,27 @@ public:
439426 _LIBCPP_INLINE_VISIBILITY
440427 unique_ptr(_Pp __p, _BadRValRefType<_Dummy> __d) = delete;
441428
442 _LIBCPP_INLINE_VISIBILITY
443 unique_ptr(unique_ptr&& __u) _NOEXCEPT
444 : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {
445 }
429 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) _NOEXCEPT
430 : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {}
446431
447 _LIBCPP_INLINE_VISIBILITY
448 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {
432 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {
449433 reset(__u.release());
450434 __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter());
451435 return *this;
452436 }
453437
454 template <class _Up, class _Ep,
455 class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
456 class = _EnableIfDeleterConvertible<_Ep>
457 >
458 _LIBCPP_INLINE_VISIBILITY
459 unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT
460 : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {
461 }
438 template <class _Up,
439 class _Ep,
440 class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
441 class = _EnableIfDeleterConvertible<_Ep> >
442 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT
443 : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {}
462444
463 template <class _Up, class _Ep,
464 class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
465 class = _EnableIfDeleterAssignable<_Ep>
466 >
467 _LIBCPP_INLINE_VISIBILITY
468 unique_ptr&
469 operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT {
445 template <class _Up,
446 class _Ep,
447 class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
448 class = _EnableIfDeleterAssignable<_Ep> >
449 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT {
470450 reset(__u.release());
471451 __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter());
472452 return *this;
......@@ -477,90 +457,77 @@ public:
477457 unique_ptr& operator=(unique_ptr const&) = delete;
478458#endif
479459public:
480 _LIBCPP_INLINE_VISIBILITY
481 ~unique_ptr() { reset(); }
460 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }
482461
483 _LIBCPP_INLINE_VISIBILITY
484 unique_ptr& operator=(nullptr_t) _NOEXCEPT {
462 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(nullptr_t) _NOEXCEPT {
485463 reset();
486464 return *this;
487465 }
488466
489 _LIBCPP_INLINE_VISIBILITY
490 typename add_lvalue_reference<_Tp>::type
467 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp>
491468 operator[](size_t __i) const {
492469 return __ptr_.first()[__i];
493470 }
494 _LIBCPP_INLINE_VISIBILITY
495 pointer get() const _NOEXCEPT {
496 return __ptr_.first();
497 }
471 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_.first(); }
498472
499 _LIBCPP_INLINE_VISIBILITY
500 deleter_type& get_deleter() _NOEXCEPT {
473 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT {
501474 return __ptr_.second();
502475 }
503476
504 _LIBCPP_INLINE_VISIBILITY
505 const deleter_type& get_deleter() const _NOEXCEPT {
477 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 const deleter_type& get_deleter() const _NOEXCEPT {
506478 return __ptr_.second();
507479 }
508 _LIBCPP_INLINE_VISIBILITY
509 explicit operator bool() const _NOEXCEPT {
480 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit operator bool() const _NOEXCEPT {
510481 return __ptr_.first() != nullptr;
511482 }
512483
513 _LIBCPP_INLINE_VISIBILITY
514 pointer release() _NOEXCEPT {
484 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer release() _NOEXCEPT {
515485 pointer __t = __ptr_.first();
516486 __ptr_.first() = pointer();
517487 return __t;
518488 }
519489
520490 template <class _Pp>
521 _LIBCPP_INLINE_VISIBILITY
522 typename enable_if<
523 _CheckArrayPointerConversion<_Pp>::value
524 >::type
525 reset(_Pp __p) _NOEXCEPT {
491 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
492 typename enable_if< _CheckArrayPointerConversion<_Pp>::value >::type
493 reset(_Pp __p) _NOEXCEPT {
526494 pointer __tmp = __ptr_.first();
527495 __ptr_.first() = __p;
528496 if (__tmp)
529497 __ptr_.second()(__tmp);
530498 }
531499
532 _LIBCPP_INLINE_VISIBILITY
533 void reset(nullptr_t = nullptr) _NOEXCEPT {
500 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(nullptr_t = nullptr) _NOEXCEPT {
534501 pointer __tmp = __ptr_.first();
535502 __ptr_.first() = nullptr;
536503 if (__tmp)
537504 __ptr_.second()(__tmp);
538505 }
539506
540 _LIBCPP_INLINE_VISIBILITY
541 void swap(unique_ptr& __u) _NOEXCEPT {
507 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT {
542508 __ptr_.swap(__u.__ptr_);
543509 }
544
545510};
546511
547512template <class _Tp, class _Dp>
548inline _LIBCPP_INLINE_VISIBILITY
549typename enable_if<
550 __is_swappable<_Dp>::value,
551 void
552>::type
553swap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT {__x.swap(__y);}
513inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
514 typename enable_if< __is_swappable<_Dp>::value, void >::type
515 swap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT {
516 __x.swap(__y);
517}
554518
555519template <class _T1, class _D1, class _T2, class _D2>
556inline _LIBCPP_INLINE_VISIBILITY
557bool
558operator==(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __x.get() == __y.get();}
520inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
521operator==(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {
522 return __x.get() == __y.get();
523}
559524
525#if _LIBCPP_STD_VER <= 17
560526template <class _T1, class _D1, class _T2, class _D2>
561527inline _LIBCPP_INLINE_VISIBILITY
562528bool
563529operator!=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x == __y);}
530#endif
564531
565532template <class _T1, class _D1, class _T2, class _D2>
566533inline _LIBCPP_INLINE_VISIBILITY
......@@ -588,14 +555,26 @@ inline _LIBCPP_INLINE_VISIBILITY
588555bool
589556operator>=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x < __y);}
590557
558
559#if _LIBCPP_STD_VER > 17
560template <class _T1, class _D1, class _T2, class _D2>
561requires three_way_comparable_with<typename unique_ptr<_T1, _D1>::pointer,
562 typename unique_ptr<_T2, _D2>::pointer>
563_LIBCPP_HIDE_FROM_ABI
564compare_three_way_result_t<typename unique_ptr<_T1, _D1>::pointer,
565 typename unique_ptr<_T2, _D2>::pointer>
566operator<=>(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {
567 return compare_three_way()(__x.get(), __y.get());
568}
569#endif
570
591571template <class _T1, class _D1>
592inline _LIBCPP_INLINE_VISIBILITY
593bool
594operator==(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT
595{
596 return !__x;
572inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
573operator==(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT {
574 return !__x;
597575}
598576
577#if _LIBCPP_STD_VER <= 17
599578template <class _T1, class _D1>
600579inline _LIBCPP_INLINE_VISIBILITY
601580bool
......@@ -619,72 +598,67 @@ operator!=(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT
619598{
620599 return static_cast<bool>(__x);
621600}
601#endif // _LIBCPP_STD_VER <= 17
622602
623603template <class _T1, class _D1>
624inline _LIBCPP_INLINE_VISIBILITY
625bool
626operator<(const unique_ptr<_T1, _D1>& __x, nullptr_t)
627{
628 typedef typename unique_ptr<_T1, _D1>::pointer _P1;
629 return less<_P1>()(__x.get(), nullptr);
604inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
605operator<(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
606 typedef typename unique_ptr<_T1, _D1>::pointer _P1;
607 return less<_P1>()(__x.get(), nullptr);
630608}
631609
632610template <class _T1, class _D1>
633inline _LIBCPP_INLINE_VISIBILITY
634bool
635operator<(nullptr_t, const unique_ptr<_T1, _D1>& __x)
636{
637 typedef typename unique_ptr<_T1, _D1>::pointer _P1;
638 return less<_P1>()(nullptr, __x.get());
611inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
612operator<(nullptr_t, const unique_ptr<_T1, _D1>& __x) {
613 typedef typename unique_ptr<_T1, _D1>::pointer _P1;
614 return less<_P1>()(nullptr, __x.get());
639615}
640616
641617template <class _T1, class _D1>
642inline _LIBCPP_INLINE_VISIBILITY
643bool
644operator>(const unique_ptr<_T1, _D1>& __x, nullptr_t)
645{
646 return nullptr < __x;
618inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
619operator>(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
620 return nullptr < __x;
647621}
648622
649623template <class _T1, class _D1>
650inline _LIBCPP_INLINE_VISIBILITY
651bool
652operator>(nullptr_t, const unique_ptr<_T1, _D1>& __x)
653{
654 return __x < nullptr;
624inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
625operator>(nullptr_t, const unique_ptr<_T1, _D1>& __x) {
626 return __x < nullptr;
655627}
656628
657629template <class _T1, class _D1>
658inline _LIBCPP_INLINE_VISIBILITY
659bool
660operator<=(const unique_ptr<_T1, _D1>& __x, nullptr_t)
661{
662 return !(nullptr < __x);
630inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
631operator<=(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
632 return !(nullptr < __x);
663633}
664634
665635template <class _T1, class _D1>
666inline _LIBCPP_INLINE_VISIBILITY
667bool
668operator<=(nullptr_t, const unique_ptr<_T1, _D1>& __x)
669{
670 return !(__x < nullptr);
636inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
637operator<=(nullptr_t, const unique_ptr<_T1, _D1>& __x) {
638 return !(__x < nullptr);
671639}
672640
673641template <class _T1, class _D1>
674inline _LIBCPP_INLINE_VISIBILITY
675bool
676operator>=(const unique_ptr<_T1, _D1>& __x, nullptr_t)
677{
678 return !(__x < nullptr);
642inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
643operator>=(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
644 return !(__x < nullptr);
679645}
680646
681647template <class _T1, class _D1>
682inline _LIBCPP_INLINE_VISIBILITY
683bool
684operator>=(nullptr_t, const unique_ptr<_T1, _D1>& __x)
685{
686 return !(nullptr < __x);
648inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
649operator>=(nullptr_t, const unique_ptr<_T1, _D1>& __x) {
650 return !(nullptr < __x);
651}
652
653#if _LIBCPP_STD_VER > 17
654template <class _T1, class _D1>
655 requires three_way_comparable<
656 typename unique_ptr<_T1, _D1>::pointer> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
657 compare_three_way_result_t<typename unique_ptr<_T1, _D1>::pointer>
658operator<=>(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
659 return compare_three_way()(__x.get(), static_cast<typename unique_ptr<_T1, _D1>::pointer>(nullptr));
687660}
661#endif
688662
689663#if _LIBCPP_STD_VER > 11
690664
......@@ -706,21 +680,17 @@ struct __unique_if<_Tp[_Np]>
706680 typedef void __unique_array_known_bound;
707681};
708682
709template<class _Tp, class... _Args>
710inline _LIBCPP_INLINE_VISIBILITY
711typename __unique_if<_Tp>::__unique_single
712make_unique(_Args&&... __args)
713{
714 return unique_ptr<_Tp>(new _Tp(_VSTD::forward<_Args>(__args)...));
683template <class _Tp, class... _Args>
684inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_single
685make_unique(_Args&&... __args) {
686 return unique_ptr<_Tp>(new _Tp(_VSTD::forward<_Args>(__args)...));
715687}
716688
717template<class _Tp>
718inline _LIBCPP_INLINE_VISIBILITY
719typename __unique_if<_Tp>::__unique_array_unknown_bound
720make_unique(size_t __n)
721{
722 typedef typename remove_extent<_Tp>::type _Up;
723 return unique_ptr<_Tp>(new _Up[__n]());
689template <class _Tp>
690inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_array_unknown_bound
691make_unique(size_t __n) {
692 typedef __remove_extent_t<_Tp> _Up;
693 return unique_ptr<_Tp>(new _Up[__n]());
724694}
725695
726696template<class _Tp, class... _Args>
......@@ -729,6 +699,25 @@ template<class _Tp, class... _Args>
729699
730700#endif // _LIBCPP_STD_VER > 11
731701
702#if _LIBCPP_STD_VER >= 20
703
704template <class _Tp>
705_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_single
706make_unique_for_overwrite() {
707 return unique_ptr<_Tp>(new _Tp);
708}
709
710template <class _Tp>
711_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_array_unknown_bound
712make_unique_for_overwrite(size_t __n) {
713 return unique_ptr<_Tp>(new __remove_extent_t<_Tp>[__n]);
714}
715
716template<class _Tp, class... _Args>
717typename __unique_if<_Tp>::__unique_array_known_bound make_unique_for_overwrite(_Args&&...) = delete;
718
719#endif // _LIBCPP_STD_VER >= 20
720
732721template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
733722
734723template <class _Tp, class _Dp>
lib/libcxx/include/__memory/uses_allocator.h+1-1
......@@ -11,8 +11,8 @@
1111#define _LIBCPP___MEMORY_USES_ALLOCATOR_H
1212
1313#include <__config>
14#include <__type_traits/is_convertible.h>
1415#include <cstddef>
15#include <type_traits>
1616
1717#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1818# pragma GCC system_header
lib/libcxx/include/__memory/uses_allocator_construction.h created+221
......@@ -0,0 +1,221 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___MEMORY_USES_ALLOCATOR_CONSTRUCTION_H
10#define _LIBCPP___MEMORY_USES_ALLOCATOR_CONSTRUCTION_H
11
12#include <__config>
13#include <__memory/construct_at.h>
14#include <__memory/uses_allocator.h>
15#include <__type_traits/enable_if.h>
16#include <__type_traits/is_same.h>
17#include <__type_traits/remove_cv.h>
18#include <__utility/declval.h>
19#include <__utility/pair.h>
20#include <tuple>
21
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
26_LIBCPP_BEGIN_NAMESPACE_STD
27
28#if _LIBCPP_STD_VER >= 17
29
30template <class _Type>
31inline constexpr bool __is_std_pair = false;
32
33template <class _Type1, class _Type2>
34inline constexpr bool __is_std_pair<pair<_Type1, _Type2>> = true;
35
36template <class _Type, class _Alloc, class... _Args, __enable_if_t<!__is_std_pair<_Type>, int> = 0>
37_LIBCPP_HIDE_FROM_ABI constexpr auto
38__uses_allocator_construction_args(const _Alloc& __alloc, _Args&&... __args) noexcept {
39 if constexpr (!uses_allocator_v<_Type, _Alloc> && is_constructible_v<_Type, _Args...>) {
40 return std::forward_as_tuple(std::forward<_Args>(__args)...);
41 } else if constexpr (uses_allocator_v<_Type, _Alloc> &&
42 is_constructible_v<_Type, allocator_arg_t, const _Alloc&, _Args...>) {
43 return tuple<allocator_arg_t, const _Alloc&, _Args&&...>(allocator_arg, __alloc, std::forward<_Args>(__args)...);
44 } else if constexpr (uses_allocator_v<_Type, _Alloc> && is_constructible_v<_Type, _Args..., const _Alloc&>) {
45 return std::forward_as_tuple(std::forward<_Args>(__args)..., __alloc);
46 } else {
47 static_assert(
48 sizeof(_Type) + 1 == 0, "If uses_allocator_v<Type> is true, the type has to be allocator-constructible");
49 }
50}
51
52template <class _Pair, class _Alloc, class _Tuple1, class _Tuple2, __enable_if_t<__is_std_pair<_Pair>, int> = 0>
53_LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(
54 const _Alloc& __alloc, piecewise_construct_t, _Tuple1&& __x, _Tuple2&& __y) noexcept {
55 return std::make_tuple(
56 piecewise_construct,
57 std::apply(
58 [&__alloc](auto&&... __args1) {
59 return std::__uses_allocator_construction_args<typename _Pair::first_type>(
60 __alloc, std::forward<decltype(__args1)>(__args1)...);
61 },
62 std::forward<_Tuple1>(__x)),
63 std::apply(
64 [&__alloc](auto&&... __args2) {
65 return std::__uses_allocator_construction_args<typename _Pair::second_type>(
66 __alloc, std::forward<decltype(__args2)>(__args2)...);
67 },
68 std::forward<_Tuple2>(__y)));
69}
70
71template <class _Pair, class _Alloc, __enable_if_t<__is_std_pair<_Pair>, int> = 0>
72_LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(const _Alloc& __alloc) noexcept {
73 return std::__uses_allocator_construction_args<_Pair>(__alloc, piecewise_construct, tuple<>{}, tuple<>{});
74}
75
76template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_std_pair<_Pair>, int> = 0>
77_LIBCPP_HIDE_FROM_ABI constexpr auto
78__uses_allocator_construction_args(const _Alloc& __alloc, _Up&& __u, _Vp&& __v) noexcept {
79 return std::__uses_allocator_construction_args<_Pair>(
80 __alloc,
81 piecewise_construct,
82 std::forward_as_tuple(std::forward<_Up>(__u)),
83 std::forward_as_tuple(std::forward<_Vp>(__v)));
84}
85
86# if _LIBCPP_STD_VER > 20
87template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_std_pair<_Pair>, int> = 0>
88_LIBCPP_HIDE_FROM_ABI constexpr auto
89__uses_allocator_construction_args(const _Alloc& __alloc, pair<_Up, _Vp>& __pair) noexcept {
90 return std::__uses_allocator_construction_args<_Pair>(
91 __alloc, piecewise_construct, std::forward_as_tuple(__pair.first), std::forward_as_tuple(__pair.second));
92}
93# endif
94
95template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_std_pair<_Pair>, int> = 0>
96_LIBCPP_HIDE_FROM_ABI constexpr auto
97__uses_allocator_construction_args(const _Alloc& __alloc, const pair<_Up, _Vp>& __pair) noexcept {
98 return std::__uses_allocator_construction_args<_Pair>(
99 __alloc, piecewise_construct, std::forward_as_tuple(__pair.first), std::forward_as_tuple(__pair.second));
100}
101
102template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_std_pair<_Pair>, int> = 0>
103_LIBCPP_HIDE_FROM_ABI constexpr auto
104__uses_allocator_construction_args(const _Alloc& __alloc, pair<_Up, _Vp>&& __pair) noexcept {
105 return std::__uses_allocator_construction_args<_Pair>(
106 __alloc,
107 piecewise_construct,
108 std::forward_as_tuple(std::get<0>(std::move(__pair))),
109 std::forward_as_tuple(std::get<1>(std::move(__pair))));
110}
111
112# if _LIBCPP_STD_VER > 20
113template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_std_pair<_Pair>, int> = 0>
114_LIBCPP_HIDE_FROM_ABI constexpr auto
115__uses_allocator_construction_args(const _Alloc& __alloc, const pair<_Up, _Vp>&& __pair) noexcept {
116 return std::__uses_allocator_construction_args<_Pair>(
117 __alloc,
118 piecewise_construct,
119 std::forward_as_tuple(std::get<0>(std::move(__pair))),
120 std::forward_as_tuple(std::get<1>(std::move(__pair))));
121}
122# endif
123
124namespace __uses_allocator_detail {
125
126template <class _Ap, class _Bp>
127void __fun(const pair<_Ap, _Bp>&);
128
129template <class _Tp>
130decltype(__uses_allocator_detail::__fun(std::declval<_Tp>()), true_type()) __convertible_to_const_pair_ref_impl(int);
131
132template <class>
133false_type __convertible_to_const_pair_ref_impl(...);
134
135template <class _Tp>
136inline constexpr bool __convertible_to_const_pair_ref =
137 decltype(__uses_allocator_detail::__convertible_to_const_pair_ref_impl<_Tp>(0))::value;
138
139} // namespace __uses_allocator_detail
140
141template <
142 class _Pair,
143 class _Alloc,
144 class _Type,
145 __enable_if_t<__is_std_pair<_Pair> && !__uses_allocator_detail::__convertible_to_const_pair_ref<_Type>, int> = 0>
146_LIBCPP_HIDE_FROM_ABI constexpr auto
147__uses_allocator_construction_args(const _Alloc& __alloc, _Type&& __value) noexcept;
148
149template <class _Type, class _Alloc, class... _Args>
150_LIBCPP_HIDE_FROM_ABI constexpr _Type __make_obj_using_allocator(const _Alloc& __alloc, _Args&&... __args);
151
152template <class _Pair,
153 class _Alloc,
154 class _Type,
155 __enable_if_t<__is_std_pair<_Pair> && !__uses_allocator_detail::__convertible_to_const_pair_ref<_Type>, int>>
156_LIBCPP_HIDE_FROM_ABI constexpr auto
157__uses_allocator_construction_args(const _Alloc& __alloc, _Type&& __value) noexcept {
158 struct __pair_constructor {
159 using _PairMutable = remove_cv_t<_Pair>;
160
161 _LIBCPP_HIDE_FROM_ABI constexpr auto __do_construct(const _PairMutable& __pair) const {
162 return std::__make_obj_using_allocator<_PairMutable>(__alloc_, __pair);
163 }
164
165 _LIBCPP_HIDE_FROM_ABI constexpr auto __do_construct(_PairMutable&& __pair) const {
166 return std::__make_obj_using_allocator<_PairMutable>(__alloc_, std::move(__pair));
167 }
168
169 const _Alloc& __alloc_;
170 _Type& __value_;
171
172 _LIBCPP_HIDE_FROM_ABI constexpr operator _PairMutable() const {
173 return __do_construct(std::forward<_Type>(this->__value_));
174 }
175 };
176
177 return std::make_tuple(__pair_constructor{__alloc, __value});
178}
179
180template <class _Type, class _Alloc, class... _Args>
181_LIBCPP_HIDE_FROM_ABI constexpr _Type __make_obj_using_allocator(const _Alloc& __alloc, _Args&&... __args) {
182 return std::make_from_tuple<_Type>(
183 std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...));
184}
185
186template <class _Type, class _Alloc, class... _Args>
187_LIBCPP_HIDE_FROM_ABI constexpr _Type*
188__uninitialized_construct_using_allocator(_Type* __ptr, const _Alloc& __alloc, _Args&&... __args) {
189 return std::apply(
190 [&__ptr](auto&&... __xs) { return std::__construct_at(__ptr, std::forward<decltype(__xs)>(__xs)...); },
191 std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...));
192}
193
194#endif // _LIBCPP_STD_VER >= 17
195
196#if _LIBCPP_STD_VER >= 20
197
198template <class _Type, class _Alloc, class... _Args>
199_LIBCPP_HIDE_FROM_ABI constexpr auto uses_allocator_construction_args(const _Alloc& __alloc, _Args&&... __args) noexcept
200 -> decltype(std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...)) {
201 return /*--*/ std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...);
202}
203
204template <class _Type, class _Alloc, class... _Args>
205_LIBCPP_HIDE_FROM_ABI constexpr auto make_obj_using_allocator(const _Alloc& __alloc, _Args&&... __args)
206 -> decltype(std::__make_obj_using_allocator<_Type>(__alloc, std::forward<_Args>(__args)...)) {
207 return /*--*/ std::__make_obj_using_allocator<_Type>(__alloc, std::forward<_Args>(__args)...);
208}
209
210template <class _Type, class _Alloc, class... _Args>
211_LIBCPP_HIDE_FROM_ABI constexpr auto
212uninitialized_construct_using_allocator(_Type* __ptr, const _Alloc& __alloc, _Args&&... __args)
213 -> decltype(std::__uninitialized_construct_using_allocator(__ptr, __alloc, std::forward<_Args>(__args)...)) {
214 return /*--*/ std::__uninitialized_construct_using_allocator(__ptr, __alloc, std::forward<_Args>(__args)...);
215}
216
217#endif // _LIBCPP_STD_VER >= 20
218
219_LIBCPP_END_NAMESPACE_STD
220
221#endif // _LIBCPP___MEMORY_USES_ALLOCATOR_CONSTRUCTION_H
lib/libcxx/include/__memory/voidify.h+1-1
......@@ -20,7 +20,7 @@
2020_LIBCPP_BEGIN_NAMESPACE_STD
2121
2222template <typename _Tp>
23_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void* __voidify(_Tp& __from) {
23_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void* __voidify(_Tp& __from) {
2424 // Cast away cv-qualifiers to allow modifying elements of a range through const iterators.
2525 return const_cast<void*>(static_cast<const volatile void*>(_VSTD::addressof(__from)));
2626}
lib/libcxx/include/__memory_resource/memory_resource.h created+75
......@@ -0,0 +1,75 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___MEMORY_RESOURCE_MEMORY_RESOURCE_H
10#define _LIBCPP___MEMORY_RESOURCE_MEMORY_RESOURCE_H
11
12#include <__config>
13#include <cstddef>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19#if _LIBCPP_STD_VER > 14
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23namespace pmr {
24
25// [mem.res.class]
26
27class _LIBCPP_TYPE_VIS memory_resource {
28 static const size_t __max_align = alignof(max_align_t);
29
30public:
31 virtual ~memory_resource();
32
33 _LIBCPP_NODISCARD_AFTER_CXX17
34 [[using __gnu__: __returns_nonnull__, __alloc_size__(2), __alloc_align__(3)]] _LIBCPP_HIDE_FROM_ABI void*
35 allocate(size_t __bytes, size_t __align = __max_align) {
36 return do_allocate(__bytes, __align);
37 }
38
39 [[__gnu__::__nonnull__]] _LIBCPP_HIDE_FROM_ABI void
40 deallocate(void* __p, size_t __bytes, size_t __align = __max_align) {
41 do_deallocate(__p, __bytes, __align);
42 }
43
44 _LIBCPP_HIDE_FROM_ABI bool is_equal(const memory_resource& __other) const noexcept { return do_is_equal(__other); }
45
46private:
47 virtual void* do_allocate(size_t, size_t) = 0;
48 virtual void do_deallocate(void*, size_t, size_t) = 0;
49 virtual bool do_is_equal(memory_resource const&) const noexcept = 0;
50};
51
52// [mem.res.eq]
53
54inline _LIBCPP_HIDE_FROM_ABI bool operator==(const memory_resource& __lhs, const memory_resource& __rhs) noexcept {
55 return &__lhs == &__rhs || __lhs.is_equal(__rhs);
56}
57
58inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const memory_resource& __lhs, const memory_resource& __rhs) noexcept {
59 return !(__lhs == __rhs);
60}
61
62// [mem.res.global]
63
64[[__gnu__::__returns_nonnull__]] _LIBCPP_FUNC_VIS memory_resource* get_default_resource() noexcept;
65[[__gnu__::__returns_nonnull__]] _LIBCPP_FUNC_VIS memory_resource* set_default_resource(memory_resource*) noexcept;
66[[using __gnu__: __returns_nonnull__, __const__]] _LIBCPP_FUNC_VIS memory_resource* new_delete_resource() noexcept;
67[[using __gnu__: __returns_nonnull__, __const__]] _LIBCPP_FUNC_VIS memory_resource* null_memory_resource() noexcept;
68
69} // namespace pmr
70
71_LIBCPP_END_NAMESPACE_STD
72
73#endif // _LIBCPP_STD_VER > 14
74
75#endif // _LIBCPP___MEMORY_RESOURCE_MEMORY_RESOURCE_H
lib/libcxx/include/__memory_resource/monotonic_buffer_resource.h created+120
......@@ -0,0 +1,120 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___MEMORY_RESOURCE_MONOTONIC_BUFFER_RESOURCE_H
10#define _LIBCPP___MEMORY_RESOURCE_MONOTONIC_BUFFER_RESOURCE_H
11
12#include <__config>
13#include <__memory/addressof.h>
14#include <__memory_resource/memory_resource.h>
15#include <cstddef>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21#if _LIBCPP_STD_VER > 14
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25namespace pmr {
26
27// [mem.res.monotonic.buffer]
28
29class _LIBCPP_TYPE_VIS monotonic_buffer_resource : public memory_resource {
30 static const size_t __default_buffer_capacity = 1024;
31 static const size_t __default_buffer_alignment = 16;
32
33 struct __chunk_footer {
34 __chunk_footer* __next_;
35 char* __start_;
36 char* __cur_;
37 size_t __align_;
38 size_t __allocation_size() { return (reinterpret_cast<char*>(this) - __start_) + sizeof(*this); }
39 void* __try_allocate_from_chunk(size_t, size_t);
40 };
41
42 struct __initial_descriptor {
43 char* __start_;
44 char* __cur_;
45 union {
46 char* __end_;
47 size_t __size_;
48 };
49 void* __try_allocate_from_chunk(size_t, size_t);
50 };
51
52public:
53 _LIBCPP_HIDE_FROM_ABI monotonic_buffer_resource()
54 : monotonic_buffer_resource(nullptr, __default_buffer_capacity, get_default_resource()) {}
55
56 _LIBCPP_HIDE_FROM_ABI explicit monotonic_buffer_resource(size_t __initial_size)
57 : monotonic_buffer_resource(nullptr, __initial_size, get_default_resource()) {}
58
59 _LIBCPP_HIDE_FROM_ABI monotonic_buffer_resource(void* __buffer, size_t __buffer_size)
60 : monotonic_buffer_resource(__buffer, __buffer_size, get_default_resource()) {}
61
62 _LIBCPP_HIDE_FROM_ABI explicit monotonic_buffer_resource(memory_resource* __upstream)
63 : monotonic_buffer_resource(nullptr, __default_buffer_capacity, __upstream) {}
64
65 _LIBCPP_HIDE_FROM_ABI monotonic_buffer_resource(size_t __initial_size, memory_resource* __upstream)
66 : monotonic_buffer_resource(nullptr, __initial_size, __upstream) {}
67
68 _LIBCPP_HIDE_FROM_ABI monotonic_buffer_resource(void* __buffer, size_t __buffer_size, memory_resource* __upstream)
69 : __res_(__upstream) {
70 __initial_.__start_ = static_cast<char*>(__buffer);
71 if (__buffer != nullptr) {
72 __initial_.__cur_ = static_cast<char*>(__buffer) + __buffer_size;
73 __initial_.__end_ = static_cast<char*>(__buffer) + __buffer_size;
74 } else {
75 __initial_.__cur_ = nullptr;
76 __initial_.__size_ = __buffer_size;
77 }
78 __chunks_ = nullptr;
79 }
80
81 monotonic_buffer_resource(const monotonic_buffer_resource&) = delete;
82
83 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~monotonic_buffer_resource() override { release(); }
84
85 monotonic_buffer_resource& operator=(const monotonic_buffer_resource&) = delete;
86
87 _LIBCPP_HIDE_FROM_ABI void release() {
88 if (__initial_.__start_ != nullptr)
89 __initial_.__cur_ = __initial_.__end_;
90 while (__chunks_ != nullptr) {
91 __chunk_footer* __next = __chunks_->__next_;
92 __res_->deallocate(__chunks_->__start_, __chunks_->__allocation_size(), __chunks_->__align_);
93 __chunks_ = __next;
94 }
95 }
96
97 _LIBCPP_HIDE_FROM_ABI memory_resource* upstream_resource() const { return __res_; }
98
99protected:
100 void* do_allocate(size_t __bytes, size_t __alignment) override; // key function
101
102 _LIBCPP_HIDE_FROM_ABI_VIRTUAL void do_deallocate(void*, size_t, size_t) override {}
103
104 _LIBCPP_HIDE_FROM_ABI_VIRTUAL bool do_is_equal(const memory_resource& __other) const _NOEXCEPT override {
105 return this == std::addressof(__other);
106 }
107
108private:
109 __initial_descriptor __initial_;
110 __chunk_footer* __chunks_;
111 memory_resource* __res_;
112};
113
114} // namespace pmr
115
116_LIBCPP_END_NAMESPACE_STD
117
118#endif // _LIBCPP_STD_VER > 14
119
120#endif // _LIBCPP___MEMORY_RESOURCE_MONOTONIC_BUFFER_RESOURCE_H
lib/libcxx/include/__memory_resource/polymorphic_allocator.h created+224
......@@ -0,0 +1,224 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___MEMORY_RESOURCE_POLYMORPHIC_ALLOCATOR_H
10#define _LIBCPP___MEMORY_RESOURCE_POLYMORPHIC_ALLOCATOR_H
11
12#include <__assert>
13#include <__config>
14#include <__memory_resource/memory_resource.h>
15#include <__utility/exception_guard.h>
16#include <cstddef>
17#include <limits>
18#include <new>
19#include <stdexcept>
20#include <tuple>
21
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
26_LIBCPP_PUSH_MACROS
27#include <__undef_macros>
28
29#if _LIBCPP_STD_VER > 14
30
31_LIBCPP_BEGIN_NAMESPACE_STD
32
33namespace pmr {
34
35// [mem.poly.allocator.class]
36
37template <class _ValueType
38# if _LIBCPP_STD_VER >= 20
39 = byte
40# endif
41 >
42class _LIBCPP_TEMPLATE_VIS polymorphic_allocator {
43
44public:
45 using value_type = _ValueType;
46
47 // [mem.poly.allocator.ctor]
48
49 _LIBCPP_HIDE_FROM_ABI polymorphic_allocator() noexcept : __res_(std::pmr::get_default_resource()) {}
50
51 _LIBCPP_HIDE_FROM_ABI polymorphic_allocator(memory_resource* __r) noexcept : __res_(__r) {}
52
53 polymorphic_allocator(const polymorphic_allocator&) = default;
54
55 template <class _Tp>
56 _LIBCPP_HIDE_FROM_ABI polymorphic_allocator(const polymorphic_allocator<_Tp>& __other) noexcept
57 : __res_(__other.resource()) {}
58
59 polymorphic_allocator& operator=(const polymorphic_allocator&) = delete;
60
61 // [mem.poly.allocator.mem]
62
63 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _ValueType* allocate(size_t __n) {
64 if (__n > __max_size()) {
65 __throw_bad_array_new_length();
66 }
67 return static_cast<_ValueType*>(__res_->allocate(__n * sizeof(_ValueType), alignof(_ValueType)));
68 }
69
70 _LIBCPP_HIDE_FROM_ABI void deallocate(_ValueType* __p, size_t __n) {
71 _LIBCPP_ASSERT(__n <= __max_size(), "deallocate called for size which exceeds max_size()");
72 __res_->deallocate(__p, __n * sizeof(_ValueType), alignof(_ValueType));
73 }
74
75# if _LIBCPP_STD_VER >= 20
76
77 [[nodiscard]] [[using __gnu__: __alloc_size__(2), __alloc_align__(3)]] void*
78 allocate_bytes(size_t __nbytes, size_t __alignment = alignof(max_align_t)) {
79 return __res_->allocate(__nbytes, __alignment);
80 }
81
82 void deallocate_bytes(void* __ptr, size_t __nbytes, size_t __alignment = alignof(max_align_t)) {
83 __res_->deallocate(__ptr, __nbytes, __alignment);
84 }
85
86 template <class _Type>
87 [[nodiscard]] _Type* allocate_object(size_t __n = 1) {
88 if (numeric_limits<size_t>::max() / sizeof(_Type) < __n)
89 std::__throw_bad_array_new_length();
90 return static_cast<_Type*>(allocate_bytes(__n * sizeof(_Type), alignof(_Type)));
91 }
92
93 template <class _Type>
94 void deallocate_object(_Type* __ptr, size_t __n = 1) {
95 deallocate_bytes(__ptr, __n * sizeof(_Type), alignof(_Type));
96 }
97
98 template <class _Type, class... _CtorArgs>
99 [[nodiscard]] _Type* new_object(_CtorArgs&&... __ctor_args) {
100 _Type* __ptr = allocate_object<_Type>();
101 __exception_guard __guard([&] { deallocate_object(__ptr); });
102 construct(__ptr, std::forward<_CtorArgs>(__ctor_args)...);
103 __guard.__complete();
104 return __ptr;
105 }
106
107 template <class _Type>
108 void delete_object(_Type* __ptr) {
109 destroy(__ptr);
110 deallocate_object(__ptr);
111 }
112
113# endif // _LIBCPP_STD_VER >= 20
114
115 template <class _Tp, class... _Ts>
116 _LIBCPP_HIDE_FROM_ABI void construct(_Tp* __p, _Ts&&... __args) {
117 std::__user_alloc_construct_impl(
118 typename __uses_alloc_ctor<_Tp, polymorphic_allocator&, _Ts...>::type(),
119 __p,
120 *this,
121 std::forward<_Ts>(__args)...);
122 }
123
124 template <class _T1, class _T2, class... _Args1, class... _Args2>
125 _LIBCPP_HIDE_FROM_ABI void
126 construct(pair<_T1, _T2>* __p, piecewise_construct_t, tuple<_Args1...> __x, tuple<_Args2...> __y) {
127 ::new ((void*)__p) pair<_T1, _T2>(
128 piecewise_construct,
129 __transform_tuple(typename __uses_alloc_ctor< _T1, polymorphic_allocator&, _Args1... >::type(),
130 std::move(__x),
131 typename __make_tuple_indices<sizeof...(_Args1)>::type{}),
132 __transform_tuple(typename __uses_alloc_ctor< _T2, polymorphic_allocator&, _Args2... >::type(),
133 std::move(__y),
134 typename __make_tuple_indices<sizeof...(_Args2)>::type{}));
135 }
136
137 template <class _T1, class _T2>
138 _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p) {
139 construct(__p, piecewise_construct, tuple<>(), tuple<>());
140 }
141
142 template <class _T1, class _T2, class _Up, class _Vp>
143 _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, _Up&& __u, _Vp&& __v) {
144 construct(__p,
145 piecewise_construct,
146 std::forward_as_tuple(std::forward<_Up>(__u)),
147 std::forward_as_tuple(std::forward<_Vp>(__v)));
148 }
149
150 template <class _T1, class _T2, class _U1, class _U2>
151 _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, const pair<_U1, _U2>& __pr) {
152 construct(__p, piecewise_construct, std::forward_as_tuple(__pr.first), std::forward_as_tuple(__pr.second));
153 }
154
155 template <class _T1, class _T2, class _U1, class _U2>
156 _LIBCPP_HIDE_FROM_ABI void construct(pair<_T1, _T2>* __p, pair<_U1, _U2>&& __pr) {
157 construct(__p,
158 piecewise_construct,
159 std::forward_as_tuple(std::forward<_U1>(__pr.first)),
160 std::forward_as_tuple(std::forward<_U2>(__pr.second)));
161 }
162
163 template <class _Tp>
164 _LIBCPP_HIDE_FROM_ABI void destroy(_Tp* __p) {
165 __p->~_Tp();
166 }
167
168 _LIBCPP_HIDE_FROM_ABI polymorphic_allocator select_on_container_copy_construction() const noexcept {
169 return polymorphic_allocator();
170 }
171
172 _LIBCPP_HIDE_FROM_ABI memory_resource* resource() const noexcept { return __res_; }
173
174private:
175 template <class... _Args, size_t... _Is>
176 _LIBCPP_HIDE_FROM_ABI tuple<_Args&&...>
177 __transform_tuple(integral_constant<int, 0>, tuple<_Args...>&& __t, __tuple_indices<_Is...>) {
178 return std::forward_as_tuple(std::get<_Is>(std::move(__t))...);
179 }
180
181 template <class... _Args, size_t... _Is>
182 _LIBCPP_HIDE_FROM_ABI tuple<allocator_arg_t const&, polymorphic_allocator&, _Args&&...>
183 __transform_tuple(integral_constant<int, 1>, tuple<_Args...>&& __t, __tuple_indices<_Is...>) {
184 using _Tup = tuple<allocator_arg_t const&, polymorphic_allocator&, _Args&&...>;
185 return _Tup(allocator_arg, *this, std::get<_Is>(std::move(__t))...);
186 }
187
188 template <class... _Args, size_t... _Is>
189 _LIBCPP_HIDE_FROM_ABI tuple<_Args&&..., polymorphic_allocator&>
190 __transform_tuple(integral_constant<int, 2>, tuple<_Args...>&& __t, __tuple_indices<_Is...>) {
191 using _Tup = tuple<_Args&&..., polymorphic_allocator&>;
192 return _Tup(std::get<_Is>(std::move(__t))..., *this);
193 }
194
195 _LIBCPP_HIDE_FROM_ABI size_t __max_size() const noexcept {
196 return numeric_limits<size_t>::max() / sizeof(value_type);
197 }
198
199 memory_resource* __res_;
200};
201
202// [mem.poly.allocator.eq]
203
204template <class _Tp, class _Up>
205inline _LIBCPP_HIDE_FROM_ABI bool
206operator==(const polymorphic_allocator<_Tp>& __lhs, const polymorphic_allocator<_Up>& __rhs) noexcept {
207 return *__lhs.resource() == *__rhs.resource();
208}
209
210template <class _Tp, class _Up>
211inline _LIBCPP_HIDE_FROM_ABI bool
212operator!=(const polymorphic_allocator<_Tp>& __lhs, const polymorphic_allocator<_Up>& __rhs) noexcept {
213 return !(__lhs == __rhs);
214}
215
216} // namespace pmr
217
218_LIBCPP_END_NAMESPACE_STD
219
220#endif // _LIBCPP_STD_VER > 14
221
222_LIBCPP_POP_MACROS
223
224#endif // _LIBCPP___MEMORY_RESOURCE_POLYMORPHIC_ALLOCATOR_H
lib/libcxx/include/__memory_resource/pool_options.h created+38
......@@ -0,0 +1,38 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___MEMORY_RESOURCE_POOL_OPTIONS_H
10#define _LIBCPP___MEMORY_RESOURCE_POOL_OPTIONS_H
11
12#include <__config>
13#include <cstddef>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19#if _LIBCPP_STD_VER > 14
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23namespace pmr {
24
25// [mem.res.pool.options]
26
27struct _LIBCPP_TYPE_VIS pool_options {
28 size_t max_blocks_per_chunk = 0;
29 size_t largest_required_pool_block = 0;
30};
31
32} // namespace pmr
33
34_LIBCPP_END_NAMESPACE_STD
35
36#endif // _LIBCPP_STD_VER > 14
37
38#endif // _LIBCPP___MEMORY_RESOURCE_POOL_OPTIONS_H
lib/libcxx/include/__memory_resource/synchronized_pool_resource.h created+94
......@@ -0,0 +1,94 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___MEMORY_RESOURCE_SYNCHRONIZED_POOL_RESOURCE_H
10#define _LIBCPP___MEMORY_RESOURCE_SYNCHRONIZED_POOL_RESOURCE_H
11
12#include <__config>
13#include <__memory_resource/memory_resource.h>
14#include <__memory_resource/pool_options.h>
15#include <__memory_resource/unsynchronized_pool_resource.h>
16#include <cstddef>
17#if !defined(_LIBCPP_HAS_NO_THREADS)
18# include <mutex>
19#endif
20
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header
23#endif
24
25#if _LIBCPP_STD_VER > 14
26
27_LIBCPP_BEGIN_NAMESPACE_STD
28
29namespace pmr {
30
31// [mem.res.pool.overview]
32
33class _LIBCPP_TYPE_VIS synchronized_pool_resource : public memory_resource {
34public:
35 _LIBCPP_HIDE_FROM_ABI synchronized_pool_resource(const pool_options& __opts, memory_resource* __upstream)
36 : __unsync_(__opts, __upstream) {}
37
38 _LIBCPP_HIDE_FROM_ABI synchronized_pool_resource()
39 : synchronized_pool_resource(pool_options(), get_default_resource()) {}
40
41 _LIBCPP_HIDE_FROM_ABI explicit synchronized_pool_resource(memory_resource* __upstream)
42 : synchronized_pool_resource(pool_options(), __upstream) {}
43
44 _LIBCPP_HIDE_FROM_ABI explicit synchronized_pool_resource(const pool_options& __opts)
45 : synchronized_pool_resource(__opts, get_default_resource()) {}
46
47 synchronized_pool_resource(const synchronized_pool_resource&) = delete;
48
49 ~synchronized_pool_resource() override = default;
50
51 synchronized_pool_resource& operator=(const synchronized_pool_resource&) = delete;
52
53 _LIBCPP_HIDE_FROM_ABI void release() {
54# if !defined(_LIBCPP_HAS_NO_THREADS)
55 unique_lock<mutex> __lk(__mut_);
56# endif
57 __unsync_.release();
58 }
59
60 _LIBCPP_HIDE_FROM_ABI memory_resource* upstream_resource() const { return __unsync_.upstream_resource(); }
61
62 _LIBCPP_HIDE_FROM_ABI pool_options options() const { return __unsync_.options(); }
63
64protected:
65 _LIBCPP_HIDE_FROM_ABI_VIRTUAL void* do_allocate(size_t __bytes, size_t __align) override {
66# if !defined(_LIBCPP_HAS_NO_THREADS)
67 unique_lock<mutex> __lk(__mut_);
68# endif
69 return __unsync_.allocate(__bytes, __align);
70 }
71
72 _LIBCPP_HIDE_FROM_ABI_VIRTUAL void do_deallocate(void* __p, size_t __bytes, size_t __align) override {
73# if !defined(_LIBCPP_HAS_NO_THREADS)
74 unique_lock<mutex> __lk(__mut_);
75# endif
76 return __unsync_.deallocate(__p, __bytes, __align);
77 }
78
79 bool do_is_equal(const memory_resource& __other) const noexcept override; // key function
80
81private:
82# if !defined(_LIBCPP_HAS_NO_THREADS)
83 mutex __mut_;
84# endif
85 unsynchronized_pool_resource __unsync_;
86};
87
88} // namespace pmr
89
90_LIBCPP_END_NAMESPACE_STD
91
92#endif // _LIBCPP_STD_VER > 14
93
94#endif // _LIBCPP___MEMORY_RESOURCE_SYNCHRONIZED_POOL_RESOURCE_H
lib/libcxx/include/__memory_resource/unsynchronized_pool_resource.h created+106
......@@ -0,0 +1,106 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___MEMORY_RESOURCE_UNSYNCHRONIZED_POOL_RESOURCE_H
10#define _LIBCPP___MEMORY_RESOURCE_UNSYNCHRONIZED_POOL_RESOURCE_H
11
12#include <__config>
13#include <__memory_resource/memory_resource.h>
14#include <__memory_resource/pool_options.h>
15#include <cstddef>
16#include <cstdint>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22#if _LIBCPP_STD_VER > 14
23
24_LIBCPP_BEGIN_NAMESPACE_STD
25
26namespace pmr {
27
28// [mem.res.pool.overview]
29
30class _LIBCPP_TYPE_VIS unsynchronized_pool_resource : public memory_resource {
31 class __fixed_pool;
32
33 class __adhoc_pool {
34 struct __chunk_footer;
35 __chunk_footer* __first_;
36
37 public:
38 _LIBCPP_HIDE_FROM_ABI explicit __adhoc_pool() : __first_(nullptr) {}
39
40 void __release_ptr(memory_resource* __upstream);
41 void* __do_allocate(memory_resource* __upstream, size_t __bytes, size_t __align);
42 void __do_deallocate(memory_resource* __upstream, void* __p, size_t __bytes, size_t __align);
43 };
44
45 static const size_t __min_blocks_per_chunk = 16;
46 static const size_t __min_bytes_per_chunk = 1024;
47 static const size_t __max_blocks_per_chunk = (size_t(1) << 20);
48 static const size_t __max_bytes_per_chunk = (size_t(1) << 30);
49
50 static const int __log2_smallest_block_size = 3;
51 static const size_t __smallest_block_size = 8;
52 static const size_t __default_largest_block_size = (size_t(1) << 20);
53 static const size_t __max_largest_block_size = (size_t(1) << 30);
54
55 size_t __pool_block_size(int __i) const;
56 int __log2_pool_block_size(int __i) const;
57 int __pool_index(size_t __bytes, size_t __align) const;
58
59public:
60 unsynchronized_pool_resource(const pool_options& __opts, memory_resource* __upstream);
61
62 _LIBCPP_HIDE_FROM_ABI unsynchronized_pool_resource()
63 : unsynchronized_pool_resource(pool_options(), get_default_resource()) {}
64
65 _LIBCPP_HIDE_FROM_ABI explicit unsynchronized_pool_resource(memory_resource* __upstream)
66 : unsynchronized_pool_resource(pool_options(), __upstream) {}
67
68 _LIBCPP_HIDE_FROM_ABI explicit unsynchronized_pool_resource(const pool_options& __opts)
69 : unsynchronized_pool_resource(__opts, get_default_resource()) {}
70
71 unsynchronized_pool_resource(const unsynchronized_pool_resource&) = delete;
72
73 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~unsynchronized_pool_resource() override { release(); }
74
75 unsynchronized_pool_resource& operator=(const unsynchronized_pool_resource&) = delete;
76
77 void release();
78
79 _LIBCPP_HIDE_FROM_ABI memory_resource* upstream_resource() const { return __res_; }
80
81 [[__gnu__::__pure__]] pool_options options() const;
82
83protected:
84 void* do_allocate(size_t __bytes, size_t __align) override; // key function
85
86 void do_deallocate(void* __p, size_t __bytes, size_t __align) override;
87
88 _LIBCPP_HIDE_FROM_ABI_VIRTUAL bool do_is_equal(const memory_resource& __other) const _NOEXCEPT override {
89 return &__other == this;
90 }
91
92private:
93 memory_resource* __res_;
94 __adhoc_pool __adhoc_pool_;
95 __fixed_pool* __fixed_pools_;
96 int __num_fixed_pools_;
97 uint32_t __options_max_blocks_per_chunk_;
98};
99
100} // namespace pmr
101
102_LIBCPP_END_NAMESPACE_STD
103
104#endif // _LIBCPP_STD_VER > 14
105
106#endif // _LIBCPP___MEMORY_RESOURCE_UNSYNCHRONIZED_POOL_RESOURCE_H
lib/libcxx/include/__mutex_base+2
......@@ -103,6 +103,7 @@ private:
103103 lock_guard(lock_guard const&) = delete;
104104 lock_guard& operator=(lock_guard const&) = delete;
105105};
106_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(lock_guard);
106107
107108template <class _Mutex>
108109class _LIBCPP_TEMPLATE_VIS unique_lock
......@@ -195,6 +196,7 @@ public:
195196 _LIBCPP_INLINE_VISIBILITY
196197 mutex_type* mutex() const _NOEXCEPT {return __m_;}
197198};
199_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(unique_lock);
198200
199201template <class _Mutex>
200202void
lib/libcxx/include/__node_handle+4-3
......@@ -60,7 +60,8 @@ public:
6060
6161#include <__assert>
6262#include <__config>
63#include <memory>
63#include <__memory/allocator_traits.h>
64#include <__memory/pointer_traits.h>
6465#include <optional>
6566
6667#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -90,8 +91,8 @@ class _LIBCPP_TEMPLATE_VIS __basic_node_handle
9091 _NodeType, __basic_node_handle<_NodeType, _Alloc, _MapOrSetSpecifics>>;
9192
9293 typedef allocator_traits<_Alloc> __alloc_traits;
93 typedef typename __rebind_pointer<typename __alloc_traits::void_pointer,
94 _NodeType>::type
94 typedef __rebind_pointer_t<typename __alloc_traits::void_pointer,
95 _NodeType>
9596 __node_pointer_type;
9697
9798public:
lib/libcxx/include/__numeric/accumulate.h+2-2
......@@ -20,7 +20,7 @@
2020_LIBCPP_BEGIN_NAMESPACE_STD
2121
2222template <class _InputIterator, class _Tp>
23_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
23_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2424_Tp
2525accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
2626{
......@@ -34,7 +34,7 @@ accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
3434}
3535
3636template <class _InputIterator, class _Tp, class _BinaryOperation>
37_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
37_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
3838_Tp
3939accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOperation __binary_op)
4040{
lib/libcxx/include/__numeric/adjacent_difference.h+2-2
......@@ -21,7 +21,7 @@
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
2323template <class _InputIterator, class _OutputIterator>
24_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
24_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2525_OutputIterator
2626adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
2727{
......@@ -44,7 +44,7 @@ adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterat
4444}
4545
4646template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
47_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
47_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
4848_OutputIterator
4949adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
5050 _BinaryOperation __binary_op)
lib/libcxx/include/__numeric/exclusive_scan.h+2-2
......@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323#if _LIBCPP_STD_VER > 14
2424
2525template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>
26_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
26_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
2727exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp __init, _BinaryOp __b) {
2828 if (__first != __last) {
2929 _Tp __tmp(__b(__init, *__first));
......@@ -41,7 +41,7 @@ exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __
4141}
4242
4343template <class _InputIterator, class _OutputIterator, class _Tp>
44_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
44_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
4545exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp __init) {
4646 return _VSTD::exclusive_scan(__first, __last, __result, __init, _VSTD::plus<>());
4747}
lib/libcxx/include/__numeric/gcd_lcm.h+9-5
......@@ -12,8 +12,12 @@
1212
1313#include <__assert>
1414#include <__config>
15#include <__type_traits/common_type.h>
16#include <__type_traits/is_integral.h>
17#include <__type_traits/is_same.h>
18#include <__type_traits/is_signed.h>
19#include <__type_traits/make_unsigned.h>
1520#include <limits>
16#include <type_traits>
1721
1822#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1923# pragma GCC system_header
......@@ -60,8 +64,8 @@ common_type_t<_Tp,_Up>
6064gcd(_Tp __m, _Up __n)
6165{
6266 static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to gcd must be integer types");
63 static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to gcd cannot be bool" );
64 static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to gcd cannot be bool" );
67 static_assert((!is_same<__remove_cv_t<_Tp>, bool>::value), "First argument to gcd cannot be bool" );
68 static_assert((!is_same<__remove_cv_t<_Up>, bool>::value), "Second argument to gcd cannot be bool" );
6569 using _Rp = common_type_t<_Tp,_Up>;
6670 using _Wp = make_unsigned_t<_Rp>;
6771 return static_cast<_Rp>(_VSTD::__gcd(
......@@ -75,8 +79,8 @@ common_type_t<_Tp,_Up>
7579lcm(_Tp __m, _Up __n)
7680{
7781 static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to lcm must be integer types");
78 static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to lcm cannot be bool" );
79 static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to lcm cannot be bool" );
82 static_assert((!is_same<__remove_cv_t<_Tp>, bool>::value), "First argument to lcm cannot be bool" );
83 static_assert((!is_same<__remove_cv_t<_Up>, bool>::value), "Second argument to lcm cannot be bool" );
8084 if (__m == 0 || __n == 0)
8185 return 0;
8286
lib/libcxx/include/__numeric/inclusive_scan.h+3-3
......@@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2424#if _LIBCPP_STD_VER > 14
2525
2626template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>
27_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
27_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
2828inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOp __b, _Tp __init) {
2929 for (; __first != __last; ++__first, (void)++__result) {
3030 __init = __b(__init, *__first);
......@@ -34,7 +34,7 @@ inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __
3434}
3535
3636template <class _InputIterator, class _OutputIterator, class _BinaryOp>
37_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
37_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
3838inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOp __b) {
3939 if (__first != __last) {
4040 typename iterator_traits<_InputIterator>::value_type __init = *__first;
......@@ -47,7 +47,7 @@ inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __
4747}
4848
4949template <class _InputIterator, class _OutputIterator>
50_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator inclusive_scan(_InputIterator __first,
50_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator inclusive_scan(_InputIterator __first,
5151 _InputIterator __last,
5252 _OutputIterator __result) {
5353 return _VSTD::inclusive_scan(__first, __last, __result, _VSTD::plus<>());
lib/libcxx/include/__numeric/inner_product.h+2-2
......@@ -20,7 +20,7 @@
2020_LIBCPP_BEGIN_NAMESPACE_STD
2121
2222template <class _InputIterator1, class _InputIterator2, class _Tp>
23_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
23_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2424_Tp
2525inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init)
2626{
......@@ -34,7 +34,7 @@ inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2
3434}
3535
3636template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOperation1, class _BinaryOperation2>
37_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
37_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
3838_Tp
3939inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,
4040 _Tp __init, _BinaryOperation1 __binary_op1, _BinaryOperation2 __binary_op2)
lib/libcxx/include/__numeric/iota.h+1-1
......@@ -19,7 +19,7 @@
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
2121template <class _ForwardIterator, class _Tp>
22_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
22_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2323void
2424iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
2525{
lib/libcxx/include/__numeric/midpoint.h+16-6
......@@ -11,8 +11,18 @@
1111#define _LIBCPP___NUMERIC_MIDPOINT_H
1212
1313#include <__config>
14#include <__type_traits/enable_if.h>
15#include <__type_traits/is_floating_point.h>
16#include <__type_traits/is_integral.h>
17#include <__type_traits/is_null_pointer.h>
18#include <__type_traits/is_object.h>
19#include <__type_traits/is_pointer.h>
20#include <__type_traits/is_same.h>
21#include <__type_traits/is_void.h>
22#include <__type_traits/make_unsigned.h>
23#include <__type_traits/remove_pointer.h>
24#include <cstddef>
1425#include <limits>
15#include <type_traits>
1626
1727#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1828# pragma GCC system_header
......@@ -55,12 +65,12 @@ midpoint(_TPtr __a, _TPtr __b) noexcept
5565
5666
5767template <typename _Tp>
58constexpr int __sign(_Tp __val) {
68_LIBCPP_HIDE_FROM_ABI constexpr int __sign(_Tp __val) {
5969 return (_Tp(0) < __val) - (__val < _Tp(0));
6070}
6171
6272template <typename _Fp>
63constexpr _Fp __fp_abs(_Fp __f) { return __f >= 0 ? __f : -__f; }
73_LIBCPP_HIDE_FROM_ABI constexpr _Fp __fp_abs(_Fp __f) { return __f >= 0 ? __f : -__f; }
6474
6575template <class _Fp>
6676_LIBCPP_INLINE_VISIBILITY constexpr
......@@ -69,10 +79,10 @@ midpoint(_Fp __a, _Fp __b) noexcept
6979{
7080 constexpr _Fp __lo = numeric_limits<_Fp>::min()*2;
7181 constexpr _Fp __hi = numeric_limits<_Fp>::max()/2;
72 return __fp_abs(__a) <= __hi && __fp_abs(__b) <= __hi ? // typical case: overflow is impossible
82 return std::__fp_abs(__a) <= __hi && std::__fp_abs(__b) <= __hi ? // typical case: overflow is impossible
7383 (__a + __b)/2 : // always correctly rounded
74 __fp_abs(__a) < __lo ? __a + __b/2 : // not safe to halve a
75 __fp_abs(__b) < __lo ? __a/2 + __b : // not safe to halve b
84 std::__fp_abs(__a) < __lo ? __a + __b/2 : // not safe to halve a
85 std::__fp_abs(__b) < __lo ? __a/2 + __b : // not safe to halve b
7686 __a/2 + __b/2; // otherwise correctly rounded
7787}
7888
lib/libcxx/include/__numeric/partial_sum.h+2-2
......@@ -21,7 +21,7 @@
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
2323template <class _InputIterator, class _OutputIterator>
24_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
24_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2525_OutputIterator
2626partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
2727{
......@@ -43,7 +43,7 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res
4343}
4444
4545template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
46_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
46_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
4747_OutputIterator
4848partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
4949 _BinaryOperation __binary_op)
lib/libcxx/include/__numeric/reduce.h+3-3
......@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222
2323#if _LIBCPP_STD_VER > 14
2424template <class _InputIterator, class _Tp, class _BinaryOp>
25_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp reduce(_InputIterator __first, _InputIterator __last,
25_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp reduce(_InputIterator __first, _InputIterator __last,
2626 _Tp __init, _BinaryOp __b) {
2727 for (; __first != __last; ++__first)
2828 __init = __b(__init, *__first);
......@@ -30,13 +30,13 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp reduce(_InputIterato
3030}
3131
3232template <class _InputIterator, class _Tp>
33_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp reduce(_InputIterator __first, _InputIterator __last,
33_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp reduce(_InputIterator __first, _InputIterator __last,
3434 _Tp __init) {
3535 return _VSTD::reduce(__first, __last, __init, _VSTD::plus<>());
3636}
3737
3838template <class _InputIterator>
39_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 typename iterator_traits<_InputIterator>::value_type
39_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 typename iterator_traits<_InputIterator>::value_type
4040reduce(_InputIterator __first, _InputIterator __last) {
4141 return _VSTD::reduce(__first, __last, typename iterator_traits<_InputIterator>::value_type{});
4242}
lib/libcxx/include/__numeric/transform_exclusive_scan.h+1-1
......@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222
2323template <class _InputIterator, class _OutputIterator, class _Tp,
2424 class _BinaryOp, class _UnaryOp>
25_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
25_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2626_OutputIterator
2727transform_exclusive_scan(_InputIterator __first, _InputIterator __last,
2828 _OutputIterator __result, _Tp __init,
lib/libcxx/include/__numeric/transform_inclusive_scan.h+2-2
......@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222#if _LIBCPP_STD_VER > 14
2323
2424template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp, class _UnaryOp>
25_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
25_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2626_OutputIterator
2727transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
2828 _OutputIterator __result, _BinaryOp __b, _UnaryOp __u, _Tp __init)
......@@ -36,7 +36,7 @@ transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
3636}
3737
3838template <class _InputIterator, class _OutputIterator, class _BinaryOp, class _UnaryOp>
39_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
39_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
4040_OutputIterator
4141transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
4242 _OutputIterator __result, _BinaryOp __b, _UnaryOp __u)
lib/libcxx/include/__numeric/transform_reduce.h+3-3
......@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222
2323#if _LIBCPP_STD_VER > 14
2424template <class _InputIterator, class _Tp, class _BinaryOp, class _UnaryOp>
25_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp transform_reduce(_InputIterator __first,
25_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp transform_reduce(_InputIterator __first,
2626 _InputIterator __last, _Tp __init,
2727 _BinaryOp __b, _UnaryOp __u) {
2828 for (; __first != __last; ++__first)
......@@ -31,7 +31,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp transform_reduce(_In
3131}
3232
3333template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOp1, class _BinaryOp2>
34_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp transform_reduce(_InputIterator1 __first1,
34_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp transform_reduce(_InputIterator1 __first1,
3535 _InputIterator1 __last1,
3636 _InputIterator2 __first2, _Tp __init,
3737 _BinaryOp1 __b1, _BinaryOp2 __b2) {
......@@ -41,7 +41,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp transform_reduce(_In
4141}
4242
4343template <class _InputIterator1, class _InputIterator2, class _Tp>
44_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp transform_reduce(_InputIterator1 __first1,
44_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp transform_reduce(_InputIterator1 __first1,
4545 _InputIterator1 __last1,
4646 _InputIterator2 __first2, _Tp __init) {
4747 return _VSTD::transform_reduce(__first1, __last1, __first2, _VSTD::move(__init), _VSTD::plus<>(),
lib/libcxx/include/__random/bernoulli_distribution.h+2-2
......@@ -110,7 +110,7 @@ bernoulli_distribution::operator()(_URNG& __g, const param_type& __p)
110110}
111111
112112template <class _CharT, class _Traits>
113basic_ostream<_CharT, _Traits>&
113_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
114114operator<<(basic_ostream<_CharT, _Traits>& __os, const bernoulli_distribution& __x)
115115{
116116 __save_flags<_CharT, _Traits> __lx(__os);
......@@ -123,7 +123,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bernoulli_distribution& _
123123}
124124
125125template <class _CharT, class _Traits>
126basic_istream<_CharT, _Traits>&
126_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
127127operator>>(basic_istream<_CharT, _Traits>& __is, bernoulli_distribution& __x)
128128{
129129 typedef bernoulli_distribution _Eng;
lib/libcxx/include/__random/binomial_distribution.h+5-5
......@@ -133,9 +133,9 @@ binomial_distribution<_IntType>::param_type::param_type(result_type __t, double
133133 if (0 < __p_ && __p_ < 1)
134134 {
135135 __r0_ = static_cast<result_type>((__t_ + 1) * __p_);
136 __pr_ = _VSTD::exp(__libcpp_lgamma(__t_ + 1.) -
137 __libcpp_lgamma(__r0_ + 1.) -
138 __libcpp_lgamma(__t_ - __r0_ + 1.) + __r0_ * _VSTD::log(__p_) +
136 __pr_ = _VSTD::exp(std::__libcpp_lgamma(__t_ + 1.) -
137 std::__libcpp_lgamma(__r0_ + 1.) -
138 std::__libcpp_lgamma(__t_ - __r0_ + 1.) + __r0_ * _VSTD::log(__p_) +
139139 (__t_ - __r0_) * _VSTD::log(1 - __p_));
140140 __odds_ratio_ = __p_ / (1 - __p_);
141141 }
......@@ -189,7 +189,7 @@ binomial_distribution<_IntType>::operator()(_URNG& __g, const param_type& __pr)
189189}
190190
191191template <class _CharT, class _Traits, class _IntType>
192basic_ostream<_CharT, _Traits>&
192_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
193193operator<<(basic_ostream<_CharT, _Traits>& __os,
194194 const binomial_distribution<_IntType>& __x)
195195{
......@@ -203,7 +203,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
203203}
204204
205205template <class _CharT, class _Traits, class _IntType>
206basic_istream<_CharT, _Traits>&
206_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
207207operator>>(basic_istream<_CharT, _Traits>& __is,
208208 binomial_distribution<_IntType>& __x)
209209{
lib/libcxx/include/__random/cauchy_distribution.h+2-2
......@@ -124,7 +124,7 @@ cauchy_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
124124}
125125
126126template <class _CharT, class _Traits, class _RT>
127basic_ostream<_CharT, _Traits>&
127_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
128128operator<<(basic_ostream<_CharT, _Traits>& __os,
129129 const cauchy_distribution<_RT>& __x)
130130{
......@@ -139,7 +139,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
139139}
140140
141141template <class _CharT, class _Traits, class _RT>
142basic_istream<_CharT, _Traits>&
142_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
143143operator>>(basic_istream<_CharT, _Traits>& __is,
144144 cauchy_distribution<_RT>& __x)
145145{
lib/libcxx/include/__random/chi_squared_distribution.h+2-2
......@@ -107,7 +107,7 @@ public:
107107};
108108
109109template <class _CharT, class _Traits, class _RT>
110basic_ostream<_CharT, _Traits>&
110_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
111111operator<<(basic_ostream<_CharT, _Traits>& __os,
112112 const chi_squared_distribution<_RT>& __x)
113113{
......@@ -120,7 +120,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
120120}
121121
122122template <class _CharT, class _Traits, class _RT>
123basic_istream<_CharT, _Traits>&
123_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
124124operator>>(basic_istream<_CharT, _Traits>& __is,
125125 chi_squared_distribution<_RT>& __x)
126126{
lib/libcxx/include/__random/discard_block_engine.h+6-4
......@@ -12,8 +12,8 @@
1212#include <__config>
1313#include <__random/is_seed_sequence.h>
1414#include <__utility/move.h>
15#include <climits>
1615#include <iosfwd>
16#include <limits>
1717#include <type_traits>
1818
1919#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -33,7 +33,9 @@ class _LIBCPP_TEMPLATE_VIS discard_block_engine
3333
3434 static_assert( 0 < __r, "discard_block_engine invalid parameters");
3535 static_assert(__r <= __p, "discard_block_engine invalid parameters");
36 static_assert(__r <= INT_MAX, "discard_block_engine invalid parameters");
36#ifndef _LIBCPP_CXX03_LANG // numeric_limits::max() is not constexpr in C++03
37 static_assert(__r <= numeric_limits<int>::max(), "discard_block_engine invalid parameters");
38#endif
3739public:
3840 // types
3941 typedef typename _Engine::result_type result_type;
......@@ -164,7 +166,7 @@ operator!=(const discard_block_engine<_Eng, _Pp, _Rp>& __x,
164166
165167template <class _CharT, class _Traits,
166168 class _Eng, size_t _Pp, size_t _Rp>
167basic_ostream<_CharT, _Traits>&
169_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
168170operator<<(basic_ostream<_CharT, _Traits>& __os,
169171 const discard_block_engine<_Eng, _Pp, _Rp>& __x)
170172{
......@@ -178,7 +180,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
178180
179181template <class _CharT, class _Traits,
180182 class _Eng, size_t _Pp, size_t _Rp>
181basic_istream<_CharT, _Traits>&
183_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
182184operator>>(basic_istream<_CharT, _Traits>& __is,
183185 discard_block_engine<_Eng, _Pp, _Rp>& __x)
184186{
lib/libcxx/include/__random/discrete_distribution.h+2-2
......@@ -221,7 +221,7 @@ discrete_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p)
221221}
222222
223223template <class _CharT, class _Traits, class _IT>
224basic_ostream<_CharT, _Traits>&
224_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
225225operator<<(basic_ostream<_CharT, _Traits>& __os,
226226 const discrete_distribution<_IT>& __x)
227227{
......@@ -239,7 +239,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
239239}
240240
241241template <class _CharT, class _Traits, class _IT>
242basic_istream<_CharT, _Traits>&
242_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
243243operator>>(basic_istream<_CharT, _Traits>& __is,
244244 discrete_distribution<_IT>& __x)
245245{
lib/libcxx/include/__random/exponential_distribution.h+2-2
......@@ -121,7 +121,7 @@ exponential_distribution<_RealType>::operator()(_URNG& __g, const param_type& __
121121}
122122
123123template <class _CharT, class _Traits, class _RealType>
124basic_ostream<_CharT, _Traits>&
124_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
125125operator<<(basic_ostream<_CharT, _Traits>& __os,
126126 const exponential_distribution<_RealType>& __x)
127127{
......@@ -133,7 +133,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
133133}
134134
135135template <class _CharT, class _Traits, class _RealType>
136basic_istream<_CharT, _Traits>&
136_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
137137operator>>(basic_istream<_CharT, _Traits>& __is,
138138 exponential_distribution<_RealType>& __x)
139139{
lib/libcxx/include/__random/extreme_value_distribution.h+2-2
......@@ -123,7 +123,7 @@ extreme_value_distribution<_RealType>::operator()(_URNG& __g, const param_type&
123123}
124124
125125template <class _CharT, class _Traits, class _RT>
126basic_ostream<_CharT, _Traits>&
126_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
127127operator<<(basic_ostream<_CharT, _Traits>& __os,
128128 const extreme_value_distribution<_RT>& __x)
129129{
......@@ -138,7 +138,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
138138}
139139
140140template <class _CharT, class _Traits, class _RT>
141basic_istream<_CharT, _Traits>&
141_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
142142operator>>(basic_istream<_CharT, _Traits>& __is,
143143 extreme_value_distribution<_RT>& __x)
144144{
lib/libcxx/include/__random/fisher_f_distribution.h+2-2
......@@ -122,7 +122,7 @@ fisher_f_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
122122}
123123
124124template <class _CharT, class _Traits, class _RT>
125basic_ostream<_CharT, _Traits>&
125_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
126126operator<<(basic_ostream<_CharT, _Traits>& __os,
127127 const fisher_f_distribution<_RT>& __x)
128128{
......@@ -137,7 +137,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
137137}
138138
139139template <class _CharT, class _Traits, class _RT>
140basic_istream<_CharT, _Traits>&
140_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
141141operator>>(basic_istream<_CharT, _Traits>& __is,
142142 fisher_f_distribution<_RT>& __x)
143143{
lib/libcxx/include/__random/gamma_distribution.h+2-2
......@@ -175,7 +175,7 @@ gamma_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
175175}
176176
177177template <class _CharT, class _Traits, class _RT>
178basic_ostream<_CharT, _Traits>&
178_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
179179operator<<(basic_ostream<_CharT, _Traits>& __os,
180180 const gamma_distribution<_RT>& __x)
181181{
......@@ -190,7 +190,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
190190}
191191
192192template <class _CharT, class _Traits, class _RT>
193basic_istream<_CharT, _Traits>&
193_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
194194operator>>(basic_istream<_CharT, _Traits>& __is,
195195 gamma_distribution<_RT>& __x)
196196{
lib/libcxx/include/__random/generate_canonical.h+1-1
......@@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2727// generate_canonical
2828
2929template<class _RealType, size_t __bits, class _URNG>
30_RealType
30_LIBCPP_HIDE_FROM_ABI _RealType
3131generate_canonical(_URNG& __g)
3232{
3333 const size_t _Dt = numeric_limits<_RealType>::digits;
lib/libcxx/include/__random/geometric_distribution.h+2-2
......@@ -108,7 +108,7 @@ public:
108108};
109109
110110template <class _CharT, class _Traits, class _IntType>
111basic_ostream<_CharT, _Traits>&
111_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
112112operator<<(basic_ostream<_CharT, _Traits>& __os,
113113 const geometric_distribution<_IntType>& __x)
114114{
......@@ -120,7 +120,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
120120}
121121
122122template <class _CharT, class _Traits, class _IntType>
123basic_istream<_CharT, _Traits>&
123_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
124124operator>>(basic_istream<_CharT, _Traits>& __is,
125125 geometric_distribution<_IntType>& __x)
126126{
lib/libcxx/include/__random/independent_bits_engine.h+4-8
......@@ -51,12 +51,8 @@ private:
5151 static_assert(__w <= _Dt, "independent_bits_engine invalid parameters");
5252
5353 typedef typename _Engine::result_type _Engine_result_type;
54 typedef typename conditional
55 <
56 sizeof(_Engine_result_type) <= sizeof(result_type),
57 result_type,
58 _Engine_result_type
59 >::type _Working_result_type;
54 typedef __conditional_t<sizeof(_Engine_result_type) <= sizeof(result_type), result_type, _Engine_result_type>
55 _Working_result_type;
6056#ifdef _LIBCPP_CXX03_LANG
6157 static const _Working_result_type _Rp = _Engine::_Max - _Engine::_Min
6258 + _Working_result_type(1);
......@@ -244,7 +240,7 @@ operator!=(
244240
245241template <class _CharT, class _Traits,
246242 class _Eng, size_t _Wp, class _UInt>
247basic_ostream<_CharT, _Traits>&
243_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
248244operator<<(basic_ostream<_CharT, _Traits>& __os,
249245 const independent_bits_engine<_Eng, _Wp, _UInt>& __x)
250246{
......@@ -253,7 +249,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
253249
254250template <class _CharT, class _Traits,
255251 class _Eng, size_t _Wp, class _UInt>
256basic_istream<_CharT, _Traits>&
252_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
257253operator>>(basic_istream<_CharT, _Traits>& __is,
258254 independent_bits_engine<_Eng, _Wp, _UInt>& __x)
259255{
lib/libcxx/include/__random/is_seed_sequence.h+1-1
......@@ -23,7 +23,7 @@ struct __is_seed_sequence
2323{
2424 static _LIBCPP_CONSTEXPR const bool value =
2525 !is_convertible<_Sseq, typename _Engine::result_type>::value &&
26 !is_same<typename remove_cv<_Sseq>::type, _Engine>::value;
26 !is_same<__remove_cv_t<_Sseq>, _Engine>::value;
2727};
2828
2929_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__random/is_valid.h+1-1
......@@ -53,7 +53,7 @@ template<> struct __libcpp_random_is_valid_inttype<__uint128_t> : true_type {};
5353template<class, class = void> struct __libcpp_random_is_valid_urng : false_type {};
5454template<class _Gp> struct __libcpp_random_is_valid_urng<_Gp, __enable_if_t<
5555 is_unsigned<typename _Gp::result_type>::value &&
56 _IsSame<decltype(declval<_Gp&>()()), typename _Gp::result_type>::value
56 _IsSame<decltype(std::declval<_Gp&>()()), typename _Gp::result_type>::value
5757> > : true_type {};
5858
5959_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__random/linear_congruential_engine.h+2-2
......@@ -198,7 +198,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
198198
199199template <class _CharT, class _Traits,
200200 class _Up, _Up _Ap, _Up _Cp, _Up _Np>
201basic_istream<_CharT, _Traits>&
201_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
202202operator>>(basic_istream<_CharT, _Traits>& __is,
203203 linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x);
204204
......@@ -372,7 +372,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
372372
373373template <class _CharT, class _Traits,
374374 class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
375basic_istream<_CharT, _Traits>&
375_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
376376operator>>(basic_istream<_CharT, _Traits>& __is,
377377 linear_congruential_engine<_UIntType, __a, __c, __m>& __x)
378378{
lib/libcxx/include/__random/log2.h+3-6
......@@ -58,15 +58,12 @@ struct __log2
5858{
5959 static const size_t value = __log2_imp<
6060#ifndef _LIBCPP_HAS_NO_INT128
61 typename conditional<
62 sizeof(_UIntType) <= sizeof(unsigned long long),
63 unsigned long long,
64 __uint128_t
65 >::type,
61 __conditional_t<sizeof(_UIntType) <= sizeof(unsigned long long), unsigned long long, __uint128_t>,
6662#else
6763 unsigned long long,
6864#endif // _LIBCPP_HAS_NO_INT128
69 _Xp, sizeof(_UIntType) * __CHAR_BIT__ - 1>::value;
65 _Xp,
66 sizeof(_UIntType) * __CHAR_BIT__ - 1>::value;
7067};
7168
7269_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__random/mersenne_twister_engine.h+6-6
......@@ -36,7 +36,7 @@ class _LIBCPP_TEMPLATE_VIS mersenne_twister_engine;
3636template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
3737 _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
3838 _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>
39bool
39_LIBCPP_HIDE_FROM_ABI bool
4040operator==(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
4141 _Bp, _Tp, _Cp, _Lp, _Fp>& __x,
4242 const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
......@@ -56,7 +56,7 @@ template <class _CharT, class _Traits,
5656 class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
5757 _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
5858 _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>
59basic_ostream<_CharT, _Traits>&
59_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
6060operator<<(basic_ostream<_CharT, _Traits>& __os,
6161 const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
6262 _Bp, _Tp, _Cp, _Lp, _Fp>& __x);
......@@ -65,7 +65,7 @@ template <class _CharT, class _Traits,
6565 class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
6666 _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
6767 _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>
68basic_istream<_CharT, _Traits>&
68_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
6969operator>>(basic_istream<_CharT, _Traits>& __is,
7070 mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
7171 _Bp, _Tp, _Cp, _Lp, _Fp>& __x);
......@@ -416,7 +416,7 @@ mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b,
416416template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
417417 _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
418418 _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>
419bool
419_LIBCPP_HIDE_FROM_ABI bool
420420operator==(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
421421 _Bp, _Tp, _Cp, _Lp, _Fp>& __x,
422422 const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
......@@ -474,7 +474,7 @@ template <class _CharT, class _Traits,
474474 class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
475475 _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
476476 _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>
477basic_ostream<_CharT, _Traits>&
477_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
478478operator<<(basic_ostream<_CharT, _Traits>& __os,
479479 const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
480480 _Bp, _Tp, _Cp, _Lp, _Fp>& __x)
......@@ -496,7 +496,7 @@ template <class _CharT, class _Traits,
496496 class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
497497 _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
498498 _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>
499basic_istream<_CharT, _Traits>&
499_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
500500operator>>(basic_istream<_CharT, _Traits>& __is,
501501 mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
502502 _Bp, _Tp, _Cp, _Lp, _Fp>& __x)
lib/libcxx/include/__random/negative_binomial_distribution.h+2-2
......@@ -144,7 +144,7 @@ negative_binomial_distribution<_IntType>::operator()(_URNG& __urng, const param_
144144}
145145
146146template <class _CharT, class _Traits, class _IntType>
147basic_ostream<_CharT, _Traits>&
147_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
148148operator<<(basic_ostream<_CharT, _Traits>& __os,
149149 const negative_binomial_distribution<_IntType>& __x)
150150{
......@@ -158,7 +158,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
158158}
159159
160160template <class _CharT, class _Traits, class _IntType>
161basic_istream<_CharT, _Traits>&
161_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
162162operator>>(basic_istream<_CharT, _Traits>& __is,
163163 negative_binomial_distribution<_IntType>& __x)
164164{
lib/libcxx/include/__random/normal_distribution.h+20-20
......@@ -58,8 +58,8 @@ public:
5858
5959private:
6060 param_type __p_;
61 result_type _V_;
62 bool _V_hot_;
61 result_type __v_;
62 bool __v_hot_;
6363
6464public:
6565 // constructors and reset functions
......@@ -68,18 +68,18 @@ public:
6868 normal_distribution() : normal_distribution(0) {}
6969 _LIBCPP_INLINE_VISIBILITY
7070 explicit normal_distribution(result_type __mean, result_type __stddev = 1)
71 : __p_(param_type(__mean, __stddev)), _V_hot_(false) {}
71 : __p_(param_type(__mean, __stddev)), __v_hot_(false) {}
7272#else
7373 _LIBCPP_INLINE_VISIBILITY
7474 explicit normal_distribution(result_type __mean = 0,
7575 result_type __stddev = 1)
76 : __p_(param_type(__mean, __stddev)), _V_hot_(false) {}
76 : __p_(param_type(__mean, __stddev)), __v_hot_(false) {}
7777#endif
7878 _LIBCPP_INLINE_VISIBILITY
7979 explicit normal_distribution(const param_type& __p)
80 : __p_(__p), _V_hot_(false) {}
80 : __p_(__p), __v_hot_(false) {}
8181 _LIBCPP_INLINE_VISIBILITY
82 void reset() {_V_hot_ = false;}
82 void reset() {__v_hot_ = false;}
8383
8484 // generating functions
8585 template<class _URNG>
......@@ -107,8 +107,8 @@ public:
107107 friend _LIBCPP_INLINE_VISIBILITY
108108 bool operator==(const normal_distribution& __x,
109109 const normal_distribution& __y)
110 {return __x.__p_ == __y.__p_ && __x._V_hot_ == __y._V_hot_ &&
111 (!__x._V_hot_ || __x._V_ == __y._V_);}
110 {return __x.__p_ == __y.__p_ && __x.__v_hot_ == __y.__v_hot_ &&
111 (!__x.__v_hot_ || __x.__v_ == __y.__v_);}
112112 friend _LIBCPP_INLINE_VISIBILITY
113113 bool operator!=(const normal_distribution& __x,
114114 const normal_distribution& __y)
......@@ -134,10 +134,10 @@ normal_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
134134{
135135 static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
136136 result_type _Up;
137 if (_V_hot_)
137 if (__v_hot_)
138138 {
139 _V_hot_ = false;
140 _Up = _V_;
139 __v_hot_ = false;
140 _Up = __v_;
141141 }
142142 else
143143 {
......@@ -152,15 +152,15 @@ normal_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
152152 __s = __u * __u + __v * __v;
153153 } while (__s > 1 || __s == 0);
154154 result_type _Fp = _VSTD::sqrt(-2 * _VSTD::log(__s) / __s);
155 _V_ = __v * _Fp;
156 _V_hot_ = true;
155 __v_ = __v * _Fp;
156 __v_hot_ = true;
157157 _Up = __u * _Fp;
158158 }
159159 return _Up * __p.stddev() + __p.mean();
160160}
161161
162162template <class _CharT, class _Traits, class _RT>
163basic_ostream<_CharT, _Traits>&
163_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
164164operator<<(basic_ostream<_CharT, _Traits>& __os,
165165 const normal_distribution<_RT>& __x)
166166{
......@@ -170,14 +170,14 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
170170 _OStream::scientific);
171171 _CharT __sp = __os.widen(' ');
172172 __os.fill(__sp);
173 __os << __x.mean() << __sp << __x.stddev() << __sp << __x._V_hot_;
174 if (__x._V_hot_)
175 __os << __sp << __x._V_;
173 __os << __x.mean() << __sp << __x.stddev() << __sp << __x.__v_hot_;
174 if (__x.__v_hot_)
175 __os << __sp << __x.__v_;
176176 return __os;
177177}
178178
179179template <class _CharT, class _Traits, class _RT>
180basic_istream<_CharT, _Traits>&
180_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
181181operator>>(basic_istream<_CharT, _Traits>& __is,
182182 normal_distribution<_RT>& __x)
183183{
......@@ -197,8 +197,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
197197 if (!__is.fail())
198198 {
199199 __x.param(param_type(__mean, __stddev));
200 __x._V_hot_ = _V_hot;
201 __x._V_ = _Vp;
200 __x.__v_hot_ = _V_hot;
201 __x.__v_ = _Vp;
202202 }
203203 return __is;
204204}
lib/libcxx/include/__random/piecewise_constant_distribution.h+2-2
......@@ -294,7 +294,7 @@ piecewise_constant_distribution<_RealType>::operator()(_URNG& __g, const param_t
294294}
295295
296296template <class _CharT, class _Traits, class _RT>
297basic_ostream<_CharT, _Traits>&
297_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
298298operator<<(basic_ostream<_CharT, _Traits>& __os,
299299 const piecewise_constant_distribution<_RT>& __x)
300300{
......@@ -320,7 +320,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
320320}
321321
322322template <class _CharT, class _Traits, class _RT>
323basic_istream<_CharT, _Traits>&
323_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
324324operator>>(basic_istream<_CharT, _Traits>& __is,
325325 piecewise_constant_distribution<_RT>& __x)
326326{
lib/libcxx/include/__random/piecewise_linear_distribution.h+2-2
......@@ -310,7 +310,7 @@ piecewise_linear_distribution<_RealType>::operator()(_URNG& __g, const param_typ
310310}
311311
312312template <class _CharT, class _Traits, class _RT>
313basic_ostream<_CharT, _Traits>&
313_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
314314operator<<(basic_ostream<_CharT, _Traits>& __os,
315315 const piecewise_linear_distribution<_RT>& __x)
316316{
......@@ -336,7 +336,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
336336}
337337
338338template <class _CharT, class _Traits, class _RT>
339basic_istream<_CharT, _Traits>&
339_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
340340operator>>(basic_istream<_CharT, _Traits>& __is,
341341 piecewise_linear_distribution<_RT>& __x)
342342{
lib/libcxx/include/__random/poisson_distribution.h+2-2
......@@ -245,7 +245,7 @@ poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr
245245}
246246
247247template <class _CharT, class _Traits, class _IntType>
248basic_ostream<_CharT, _Traits>&
248_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
249249operator<<(basic_ostream<_CharT, _Traits>& __os,
250250 const poisson_distribution<_IntType>& __x)
251251{
......@@ -257,7 +257,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
257257}
258258
259259template <class _CharT, class _Traits, class _IntType>
260basic_istream<_CharT, _Traits>&
260_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
261261operator>>(basic_istream<_CharT, _Traits>& __is,
262262 poisson_distribution<_IntType>& __x)
263263{
lib/libcxx/include/__random/shuffle_order_engine.h+21-21
......@@ -60,8 +60,8 @@ public:
6060
6161private:
6262 _Engine __e_;
63 result_type _V_[__k];
64 result_type _Y_;
63 result_type __v_[__k];
64 result_type __y_;
6565
6666public:
6767 // engine characteristics
......@@ -157,8 +157,8 @@ private:
157157 void __init()
158158 {
159159 for (size_t __i = 0; __i < __k; ++__i)
160 _V_[__i] = __e_();
161 _Y_ = __e_();
160 __v_[__i] = __e_();
161 __y_ = __e_();
162162 }
163163
164164 _LIBCPP_INLINE_VISIBILITY
......@@ -190,11 +190,11 @@ private:
190190 >::type
191191 __eval(__uratio<_Np, _Dp>)
192192 {
193 const size_t __j = static_cast<size_t>(__uratio<_Np, _Dp>::num * (_Y_ - _Min)
193 const size_t __j = static_cast<size_t>(__uratio<_Np, _Dp>::num * (__y_ - _Min)
194194 / __uratio<_Np, _Dp>::den);
195 _Y_ = _V_[__j];
196 _V_[__j] = __e_();
197 return _Y_;
195 __y_ = __v_[__j];
196 __v_[__j] = __e_();
197 return __y_;
198198 }
199199
200200 template <uint64_t __n, uint64_t __d>
......@@ -204,10 +204,10 @@ private:
204204 const double _Fp = __d == 0 ?
205205 __n / (2. * 0x8000000000000000ull) :
206206 __n / (double)__d;
207 const size_t __j = static_cast<size_t>(_Fp * (_Y_ - _Min));
208 _Y_ = _V_[__j];
209 _V_[__j] = __e_();
210 return _Y_;
207 const size_t __j = static_cast<size_t>(_Fp * (__y_ - _Min));
208 __y_ = __v_[__j];
209 __v_[__j] = __e_();
210 return __y_;
211211 }
212212};
213213
......@@ -215,12 +215,12 @@ template<class _Engine, size_t __k>
215215 _LIBCPP_CONSTEXPR const size_t shuffle_order_engine<_Engine, __k>::table_size;
216216
217217template<class _Eng, size_t _Kp>
218bool
218_LIBCPP_HIDE_FROM_ABI bool
219219operator==(
220220 const shuffle_order_engine<_Eng, _Kp>& __x,
221221 const shuffle_order_engine<_Eng, _Kp>& __y)
222222{
223 return __x._Y_ == __y._Y_ && _VSTD::equal(__x._V_, __x._V_ + _Kp, __y._V_) &&
223 return __x.__y_ == __y.__y_ && _VSTD::equal(__x.__v_, __x.__v_ + _Kp, __y.__v_) &&
224224 __x.__e_ == __y.__e_;
225225}
226226
......@@ -236,7 +236,7 @@ operator!=(
236236
237237template <class _CharT, class _Traits,
238238 class _Eng, size_t _Kp>
239basic_ostream<_CharT, _Traits>&
239_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
240240operator<<(basic_ostream<_CharT, _Traits>& __os,
241241 const shuffle_order_engine<_Eng, _Kp>& __x)
242242{
......@@ -245,15 +245,15 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
245245 __os.flags(_Ostream::dec | _Ostream::left);
246246 _CharT __sp = __os.widen(' ');
247247 __os.fill(__sp);
248 __os << __x.__e_ << __sp << __x._V_[0];
248 __os << __x.__e_ << __sp << __x.__v_[0];
249249 for (size_t __i = 1; __i < _Kp; ++__i)
250 __os << __sp << __x._V_[__i];
251 return __os << __sp << __x._Y_;
250 __os << __sp << __x.__v_[__i];
251 return __os << __sp << __x.__y_;
252252}
253253
254254template <class _CharT, class _Traits,
255255 class _Eng, size_t _Kp>
256basic_istream<_CharT, _Traits>&
256_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
257257operator>>(basic_istream<_CharT, _Traits>& __is,
258258 shuffle_order_engine<_Eng, _Kp>& __x)
259259{
......@@ -270,8 +270,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
270270 {
271271 __x.__e_ = __e;
272272 for (size_t __i = 0; __i < _Kp; ++__i)
273 __x._V_[__i] = _Vp[__i];
274 __x._Y_ = _Vp[_Kp];
273 __x.__v_[__i] = _Vp[__i];
274 __x.__y_ = _Vp[_Kp];
275275 }
276276 return __is;
277277}
lib/libcxx/include/__random/student_t_distribution.h+2-2
......@@ -118,7 +118,7 @@ student_t_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
118118}
119119
120120template <class _CharT, class _Traits, class _RT>
121basic_ostream<_CharT, _Traits>&
121_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
122122operator<<(basic_ostream<_CharT, _Traits>& __os,
123123 const student_t_distribution<_RT>& __x)
124124{
......@@ -131,7 +131,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
131131}
132132
133133template <class _CharT, class _Traits, class _RT>
134basic_istream<_CharT, _Traits>&
134_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
135135operator>>(basic_istream<_CharT, _Traits>& __is,
136136 student_t_distribution<_RT>& __x)
137137{
lib/libcxx/include/__random/subtract_with_carry_engine.h+6-6
......@@ -33,7 +33,7 @@ template<class _UIntType, size_t __w, size_t __s, size_t __r>
3333class _LIBCPP_TEMPLATE_VIS subtract_with_carry_engine;
3434
3535template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
36bool
36_LIBCPP_HIDE_FROM_ABI bool
3737operator==(
3838 const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x,
3939 const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y);
......@@ -47,13 +47,13 @@ operator!=(
4747
4848template <class _CharT, class _Traits,
4949 class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
50basic_ostream<_CharT, _Traits>&
50_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
5151operator<<(basic_ostream<_CharT, _Traits>& __os,
5252 const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x);
5353
5454template <class _CharT, class _Traits,
5555 class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
56basic_istream<_CharT, _Traits>&
56_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
5757operator>>(basic_istream<_CharT, _Traits>& __is,
5858 subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x);
5959
......@@ -251,7 +251,7 @@ subtract_with_carry_engine<_UIntType, __w, __s, __r>::operator()()
251251}
252252
253253template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
254bool
254_LIBCPP_HIDE_FROM_ABI bool
255255operator==(
256256 const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x,
257257 const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y)
......@@ -305,7 +305,7 @@ operator!=(
305305
306306template <class _CharT, class _Traits,
307307 class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
308basic_ostream<_CharT, _Traits>&
308_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
309309operator<<(basic_ostream<_CharT, _Traits>& __os,
310310 const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x)
311311{
......@@ -325,7 +325,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
325325
326326template <class _CharT, class _Traits,
327327 class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
328basic_istream<_CharT, _Traits>&
328_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
329329operator>>(basic_istream<_CharT, _Traits>& __is,
330330 subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x)
331331{
lib/libcxx/include/__random/uniform_int_distribution.h+11-12
......@@ -9,7 +9,6 @@
99#ifndef _LIBCPP___RANDOM_UNIFORM_INT_DISTRIBUTION_H
1010#define _LIBCPP___RANDOM_UNIFORM_INT_DISTRIBUTION_H
1111
12#include <__bits>
1312#include <__config>
1413#include <__random/is_valid.h>
1514#include <__random/log2.h>
......@@ -38,12 +37,8 @@ public:
3837
3938private:
4039 typedef typename _Engine::result_type _Engine_result_type;
41 typedef typename conditional
42 <
43 sizeof(_Engine_result_type) <= sizeof(result_type),
44 result_type,
45 _Engine_result_type
46 >::type _Working_result_type;
40 typedef __conditional_t<sizeof(_Engine_result_type) <= sizeof(result_type), result_type, _Engine_result_type>
41 _Working_result_type;
4742
4843 _Engine& __e_;
4944 size_t __w_;
......@@ -178,8 +173,10 @@ public:
178173 result_type a() const {return __a_;}
179174 result_type b() const {return __b_;}
180175
176 _LIBCPP_HIDE_FROM_ABI
181177 friend bool operator==(const param_type& __x, const param_type& __y)
182178 {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;}
179 _LIBCPP_HIDE_FROM_ABI
183180 friend bool operator!=(const param_type& __x, const param_type& __y)
184181 {return !(__x == __y);}
185182 };
......@@ -218,9 +215,11 @@ public:
218215 result_type min() const {return a();}
219216 result_type max() const {return b();}
220217
218 _LIBCPP_HIDE_FROM_ABI
221219 friend bool operator==(const uniform_int_distribution& __x,
222220 const uniform_int_distribution& __y)
223221 {return __x.__p_ == __y.__p_;}
222 _LIBCPP_HIDE_FROM_ABI
224223 friend bool operator!=(const uniform_int_distribution& __x,
225224 const uniform_int_distribution& __y)
226225 {return !(__x == __y);}
......@@ -233,8 +232,8 @@ uniform_int_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p
233232_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
234233{
235234 static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
236 typedef typename conditional<sizeof(result_type) <= sizeof(uint32_t), uint32_t,
237 typename make_unsigned<result_type>::type>::type _UIntType;
235 typedef __conditional_t<sizeof(result_type) <= sizeof(uint32_t), uint32_t, __make_unsigned_t<result_type> >
236 _UIntType;
238237 const _UIntType _Rp = _UIntType(__p.b()) - _UIntType(__p.a()) + _UIntType(1);
239238 if (_Rp == 1)
240239 return __p.a();
......@@ -242,7 +241,7 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
242241 typedef __independent_bits_engine<_URNG, _UIntType> _Eng;
243242 if (_Rp == 0)
244243 return static_cast<result_type>(_Eng(__g, _Dt)());
245 size_t __w = _Dt - __countl_zero(_Rp) - 1;
244 size_t __w = _Dt - std::__countl_zero(_Rp) - 1;
246245 if ((_Rp & (numeric_limits<_UIntType>::max() >> (_Dt - __w))) != 0)
247246 ++__w;
248247 _Eng __e(__g, __w);
......@@ -255,7 +254,7 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
255254}
256255
257256template <class _CharT, class _Traits, class _IT>
258basic_ostream<_CharT, _Traits>&
257_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
259258operator<<(basic_ostream<_CharT, _Traits>& __os,
260259 const uniform_int_distribution<_IT>& __x)
261260{
......@@ -268,7 +267,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
268267}
269268
270269template <class _CharT, class _Traits, class _IT>
271basic_istream<_CharT, _Traits>&
270_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
272271operator>>(basic_istream<_CharT, _Traits>& __is,
273272 uniform_int_distribution<_IT>& __x)
274273{
lib/libcxx/include/__random/uniform_real_distribution.h+2-2
......@@ -123,7 +123,7 @@ uniform_real_distribution<_RealType>::operator()(_URNG& __g, const param_type& _
123123}
124124
125125template <class _CharT, class _Traits, class _RT>
126basic_ostream<_CharT, _Traits>&
126_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
127127operator<<(basic_ostream<_CharT, _Traits>& __os,
128128 const uniform_real_distribution<_RT>& __x)
129129{
......@@ -137,7 +137,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
137137}
138138
139139template <class _CharT, class _Traits, class _RT>
140basic_istream<_CharT, _Traits>&
140_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
141141operator>>(basic_istream<_CharT, _Traits>& __is,
142142 uniform_real_distribution<_RT>& __x)
143143{
lib/libcxx/include/__random/weibull_distribution.h+2-2
......@@ -115,7 +115,7 @@ public:
115115};
116116
117117template <class _CharT, class _Traits, class _RT>
118basic_ostream<_CharT, _Traits>&
118_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
119119operator<<(basic_ostream<_CharT, _Traits>& __os,
120120 const weibull_distribution<_RT>& __x)
121121{
......@@ -130,7 +130,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
130130}
131131
132132template <class _CharT, class _Traits, class _RT>
133basic_istream<_CharT, _Traits>&
133_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
134134operator>>(basic_istream<_CharT, _Traits>& __is,
135135 weibull_distribution<_RT>& __x)
136136{
lib/libcxx/include/__ranges/access.h+8-2
......@@ -6,6 +6,7 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_ACCESS_H
1011#define _LIBCPP___RANGES_ACCESS_H
1112
......@@ -14,8 +15,13 @@
1415#include <__iterator/concepts.h>
1516#include <__iterator/readable_traits.h>
1617#include <__ranges/enable_borrowed_range.h>
18#include <__type_traits/decay.h>
19#include <__type_traits/is_reference.h>
20#include <__type_traits/remove_cvref.h>
21#include <__type_traits/remove_reference.h>
1722#include <__utility/auto_cast.h>
18#include <type_traits>
23#include <__utility/declval.h>
24#include <cstddef>
1925
2026#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2127# pragma GCC system_header
......@@ -99,7 +105,7 @@ inline namespace __cpo {
99105
100106namespace ranges {
101107 template <class _Tp>
102 using iterator_t = decltype(ranges::begin(declval<_Tp&>()));
108 using iterator_t = decltype(ranges::begin(std::declval<_Tp&>()));
103109} // namespace ranges
104110
105111// [range.access.end]
lib/libcxx/include/__ranges/all.h+4-3
......@@ -6,6 +6,7 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_ALL_H
1011#define _LIBCPP___RANGES_ALL_H
1112
......@@ -28,7 +29,7 @@
2829
2930_LIBCPP_BEGIN_NAMESPACE_STD
3031
31#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
32#if _LIBCPP_STD_VER > 17
3233
3334namespace ranges::views {
3435
......@@ -72,11 +73,11 @@ inline namespace __cpo {
7273} // namespace __cpo
7374
7475template<ranges::viewable_range _Range>
75using all_t = decltype(views::all(declval<_Range>()));
76using all_t = decltype(views::all(std::declval<_Range>()));
7677
7778} // namespace ranges::views
7879
79#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
80#endif // _LIBCPP_STD_VER > 17
8081
8182_LIBCPP_END_NAMESPACE_STD
8283
lib/libcxx/include/__ranges/as_rvalue_view.h created+137
......@@ -0,0 +1,137 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___RANGES_AS_RVALUE_H
10#define _LIBCPP___RANGES_AS_RVALUE_H
11
12#include <__concepts/constructible.h>
13#include <__concepts/same_as.h>
14#include <__config>
15#include <__iterator/move_iterator.h>
16#include <__iterator/move_sentinel.h>
17#include <__ranges/access.h>
18#include <__ranges/all.h>
19#include <__ranges/concepts.h>
20#include <__ranges/enable_borrowed_range.h>
21#include <__ranges/range_adaptor.h>
22#include <__ranges/size.h>
23#include <__ranges/view_interface.h>
24#include <__utility/forward.h>
25#include <__utility/move.h>
26
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header
29#endif
30
31#if _LIBCPP_STD_VER >= 23
32
33_LIBCPP_BEGIN_NAMESPACE_STD
34
35namespace ranges {
36template <view _View>
37 requires input_range<_View>
38class as_rvalue_view : public view_interface<as_rvalue_view<_View>> {
39 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
40
41public:
42 _LIBCPP_HIDE_FROM_ABI as_rvalue_view()
43 requires default_initializable<_View>
44 = default;
45
46 _LIBCPP_HIDE_FROM_ABI constexpr explicit as_rvalue_view(_View __base) : __base_(std::move(__base)) {}
47
48 _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
49 requires copy_constructible<_View>
50 {
51 return __base_;
52 }
53
54 _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
55
56 _LIBCPP_HIDE_FROM_ABI constexpr auto begin()
57 requires(!__simple_view<_View>)
58 {
59 return move_iterator(ranges::begin(__base_));
60 }
61
62 _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
63 requires range<const _View>
64 {
65 return move_iterator(ranges::begin(__base_));
66 }
67
68 _LIBCPP_HIDE_FROM_ABI constexpr auto end()
69 requires(!__simple_view<_View>)
70 {
71 if constexpr (common_range<_View>) {
72 return move_iterator(ranges::end(__base_));
73 } else {
74 return move_sentinel(ranges::end(__base_));
75 }
76 }
77
78 _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
79 requires range<const _View>
80 {
81 if constexpr (common_range<const _View>) {
82 return move_iterator(ranges::end(__base_));
83 } else {
84 return move_sentinel(ranges::end(__base_));
85 }
86 }
87
88 _LIBCPP_HIDE_FROM_ABI constexpr auto size()
89 requires sized_range<_View>
90 {
91 return ranges::size(__base_);
92 }
93
94 _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
95 requires sized_range<const _View>
96 {
97 return ranges::size(__base_);
98 }
99};
100
101template <class _Range>
102as_rvalue_view(_Range&&) -> as_rvalue_view<views::all_t<_Range>>;
103
104template <class _View>
105inline constexpr bool enable_borrowed_range<as_rvalue_view<_View>> = enable_borrowed_range<_View>;
106
107namespace views {
108namespace __as_rvalue {
109struct __fn : __range_adaptor_closure<__fn> {
110 template <class _Range>
111 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range) const
112 noexcept(noexcept(/**/ as_rvalue_view(std::forward<_Range>(__range))))
113 -> decltype(/*--*/ as_rvalue_view(std::forward<_Range>(__range))) {
114 return /*-------------*/ as_rvalue_view(std::forward<_Range>(__range));
115 }
116
117 template <class _Range>
118 requires same_as<range_rvalue_reference_t<_Range>, range_reference_t<_Range>>
119 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range) const
120 noexcept(noexcept(/**/ views::all(std::forward<_Range>(__range))))
121 -> decltype(/*--*/ views::all(std::forward<_Range>(__range))) {
122 return /*-------------*/ views::all(std::forward<_Range>(__range));
123 }
124};
125} // namespace __as_rvalue
126
127inline namespace __cpo {
128constexpr auto as_rvalue = __as_rvalue::__fn{};
129} // namespace __cpo
130} // namespace views
131} // namespace ranges
132
133_LIBCPP_END_NAMESPACE_STD
134
135#endif // _LIBCPP_STD_VER >= 23
136
137#endif // _LIBCPP___RANGES_AS_RVALUE_H
lib/libcxx/include/__ranges/common_view.h+5-3
......@@ -6,9 +6,12 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_COMMON_VIEW_H
1011#define _LIBCPP___RANGES_COMMON_VIEW_H
1112
13#include <__concepts/constructible.h>
14#include <__concepts/copyable.h>
1215#include <__config>
1316#include <__iterator/common_iterator.h>
1417#include <__iterator/iterator_traits.h>
......@@ -21,7 +24,6 @@
2124#include <__ranges/view_interface.h>
2225#include <__utility/forward.h>
2326#include <__utility/move.h>
24#include <concepts>
2527#include <type_traits>
2628
2729#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -30,7 +32,7 @@
3032
3133_LIBCPP_BEGIN_NAMESPACE_STD
3234
33#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
35#if _LIBCPP_STD_VER > 17
3436
3537namespace ranges {
3638
......@@ -128,7 +130,7 @@ inline namespace __cpo {
128130} // namespace views
129131} // namespace ranges
130132
131#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
133#endif // _LIBCPP_STD_VER > 17
132134
133135_LIBCPP_END_NAMESPACE_STD
134136
lib/libcxx/include/__ranges/concepts.h+8-3
......@@ -6,6 +6,7 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_CONCEPTS_H
1011#define _LIBCPP___RANGES_CONCEPTS_H
1112
......@@ -23,8 +24,12 @@
2324#include <__ranges/enable_borrowed_range.h>
2425#include <__ranges/enable_view.h>
2526#include <__ranges/size.h>
27#include <__type_traits/add_pointer.h>
28#include <__type_traits/is_reference.h>
29#include <__type_traits/remove_cvref.h>
30#include <__type_traits/remove_reference.h>
31#include <__utility/declval.h>
2632#include <initializer_list>
27#include <type_traits>
2833
2934#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3035# pragma GCC system_header
......@@ -54,7 +59,7 @@ namespace ranges {
5459 // `iterator_t` defined in <__ranges/access.h>
5560
5661 template <range _Rp>
57 using sentinel_t = decltype(ranges::end(declval<_Rp&>()));
62 using sentinel_t = decltype(ranges::end(std::declval<_Rp&>()));
5863
5964 template <range _Rp>
6065 using range_difference_t = iter_difference_t<iterator_t<_Rp>>;
......@@ -73,7 +78,7 @@ namespace ranges {
7378 concept sized_range = range<_Tp> && requires(_Tp& __t) { ranges::size(__t); };
7479
7580 template<sized_range _Rp>
76 using range_size_t = decltype(ranges::size(declval<_Rp&>()));
81 using range_size_t = decltype(ranges::size(std::declval<_Rp&>()));
7782
7883 // `disable_sized_range` defined in `<__ranges/size.h>`
7984
lib/libcxx/include/__ranges/copyable_box.h+5-3
......@@ -10,11 +10,13 @@
1010#ifndef _LIBCPP___RANGES_COPYABLE_BOX_H
1111#define _LIBCPP___RANGES_COPYABLE_BOX_H
1212
13#include <__concepts/constructible.h>
14#include <__concepts/copyable.h>
15#include <__concepts/movable.h>
1316#include <__config>
1417#include <__memory/addressof.h>
1518#include <__memory/construct_at.h>
1619#include <__utility/move.h>
17#include <concepts>
1820#include <optional>
1921#include <type_traits>
2022
......@@ -24,7 +26,7 @@
2426
2527_LIBCPP_BEGIN_NAMESPACE_STD
2628
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
29#if _LIBCPP_STD_VER > 17
2830
2931// __copyable_box allows turning a type that is copy-constructible (but maybe not copy-assignable) into
3032// a type that is both copy-constructible and copy-assignable. It does that by introducing an empty state
......@@ -171,7 +173,7 @@ namespace ranges {
171173 };
172174} // namespace ranges
173175
174#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
176#endif // _LIBCPP_STD_VER > 17
175177
176178_LIBCPP_END_NAMESPACE_STD
177179
lib/libcxx/include/__ranges/counted.h+3-2
......@@ -6,6 +6,7 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_COUNTED_H
1011#define _LIBCPP___RANGES_COUNTED_H
1112
......@@ -29,7 +30,7 @@
2930
3031_LIBCPP_BEGIN_NAMESPACE_STD
3132
32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
33#if _LIBCPP_STD_VER > 17
3334
3435namespace ranges::views {
3536
......@@ -74,7 +75,7 @@ inline namespace __cpo {
7475
7576} // namespace ranges::views
7677
77#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
78#endif // _LIBCPP_STD_VER > 17
7879
7980_LIBCPP_END_NAMESPACE_STD
8081
lib/libcxx/include/__ranges/dangling.h+1-1
......@@ -13,7 +13,7 @@
1313#include <__config>
1414#include <__ranges/access.h>
1515#include <__ranges/concepts.h>
16#include <type_traits>
16#include <__type_traits/conditional.h>
1717
1818#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1919# pragma GCC system_header
lib/libcxx/include/__ranges/data.h+7-1
......@@ -6,6 +6,7 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_DATA_H
1011#define _LIBCPP___RANGES_DATA_H
1112
......@@ -15,8 +16,13 @@
1516#include <__iterator/iterator_traits.h>
1617#include <__memory/pointer_traits.h>
1718#include <__ranges/access.h>
19#include <__type_traits/decay.h>
20#include <__type_traits/is_object.h>
21#include <__type_traits/is_pointer.h>
22#include <__type_traits/is_reference.h>
23#include <__type_traits/remove_pointer.h>
24#include <__type_traits/remove_reference.h>
1825#include <__utility/auto_cast.h>
19#include <type_traits>
2026
2127#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2228# pragma GCC system_header
lib/libcxx/include/__ranges/drop_view.h+5-3
......@@ -6,11 +6,14 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_DROP_VIEW_H
1011#define _LIBCPP___RANGES_DROP_VIEW_H
1112
1213#include <__algorithm/min.h>
1314#include <__assert>
15#include <__concepts/constructible.h>
16#include <__concepts/convertible_to.h>
1417#include <__config>
1518#include <__functional/bind_back.h>
1619#include <__fwd/span.h>
......@@ -33,7 +36,6 @@
3336#include <__utility/auto_cast.h>
3437#include <__utility/forward.h>
3538#include <__utility/move.h>
36#include <concepts>
3739#include <type_traits>
3840
3941#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -45,7 +47,7 @@ _LIBCPP_PUSH_MACROS
4547
4648_LIBCPP_BEGIN_NAMESPACE_STD
4749
48#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
50#if _LIBCPP_STD_VER > 17
4951
5052namespace ranges {
5153 template<view _View>
......@@ -297,7 +299,7 @@ inline namespace __cpo {
297299
298300} // namespace ranges
299301
300#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
302#endif // _LIBCPP_STD_VER > 17
301303
302304_LIBCPP_END_NAMESPACE_STD
303305
lib/libcxx/include/__ranges/drop_while_view.h created+129
......@@ -0,0 +1,129 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___RANGES_DROP_WHILE_VIEW_H
11#define _LIBCPP___RANGES_DROP_WHILE_VIEW_H
12
13#include <__algorithm/ranges_find_if_not.h>
14#include <__assert>
15#include <__concepts/constructible.h>
16#include <__config>
17#include <__functional/bind_back.h>
18#include <__functional/reference_wrapper.h>
19#include <__iterator/concepts.h>
20#include <__ranges/access.h>
21#include <__ranges/all.h>
22#include <__ranges/concepts.h>
23#include <__ranges/copyable_box.h>
24#include <__ranges/enable_borrowed_range.h>
25#include <__ranges/non_propagating_cache.h>
26#include <__ranges/range_adaptor.h>
27#include <__ranges/view_interface.h>
28#include <__type_traits/conditional.h>
29#include <__type_traits/decay.h>
30#include <__type_traits/is_nothrow_constructible.h>
31#include <__type_traits/is_object.h>
32#include <__utility/forward.h>
33#include <__utility/in_place.h>
34#include <__utility/move.h>
35
36#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
37# pragma GCC system_header
38#endif
39
40_LIBCPP_BEGIN_NAMESPACE_STD
41
42#if _LIBCPP_STD_VER >= 20
43
44namespace ranges {
45
46template <view _View, class _Pred>
47 requires input_range<_View> && is_object_v<_Pred> && indirect_unary_predicate<const _Pred, iterator_t<_View>>
48class drop_while_view : public view_interface<drop_while_view<_View, _Pred>> {
49public:
50 _LIBCPP_HIDE_FROM_ABI drop_while_view()
51 requires default_initializable<_View> && default_initializable<_Pred>
52 = default;
53
54 _LIBCPP_HIDE_FROM_ABI constexpr drop_while_view(_View __base, _Pred __pred)
55 : __base_(std::move(__base)), __pred_(std::in_place, std::move(__pred)) {}
56
57 _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
58 requires copy_constructible<_View>
59 {
60 return __base_;
61 }
62
63 _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
64
65 _LIBCPP_HIDE_FROM_ABI constexpr const _Pred& pred() const { return *__pred_; }
66
67 _LIBCPP_HIDE_FROM_ABI constexpr auto begin() {
68 _LIBCPP_ASSERT(__pred_.__has_value(),
69 "drop_while_view needs to have a non-empty predicate before calling begin() -- did a previous "
70 "assignment to this drop_while_view fail?");
71 if constexpr (_UseCache) {
72 if (!__cached_begin_.__has_value()) {
73 __cached_begin_.__emplace(ranges::find_if_not(__base_, std::cref(*__pred_)));
74 }
75 return *__cached_begin_;
76 } else {
77 return ranges::find_if_not(__base_, std::cref(*__pred_));
78 }
79 }
80
81 _LIBCPP_HIDE_FROM_ABI constexpr auto end() { return ranges::end(__base_); }
82
83private:
84 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
85 _LIBCPP_NO_UNIQUE_ADDRESS __copyable_box<_Pred> __pred_;
86
87 static constexpr bool _UseCache = forward_range<_View>;
88 using _Cache = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;
89 _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache();
90};
91
92template <class _View, class _Pred>
93inline constexpr bool enable_borrowed_range<drop_while_view<_View, _Pred>> = enable_borrowed_range<_View>;
94
95template <class _Range, class _Pred>
96drop_while_view(_Range&&, _Pred) -> drop_while_view<views::all_t<_Range>, _Pred>;
97
98namespace views {
99namespace __drop_while {
100
101struct __fn {
102 template <class _Range, class _Pred>
103 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Pred&& __pred) const
104 noexcept(noexcept(/**/ drop_while_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))))
105 -> decltype(/*--*/ drop_while_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))) {
106 return /*-------------*/ drop_while_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred));
107 }
108
109 template <class _Pred>
110 requires constructible_from<decay_t<_Pred>, _Pred>
111 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const
112 noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) {
113 return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pred>(__pred)));
114 }
115};
116
117} // namespace __drop_while
118
119inline namespace __cpo {
120inline constexpr auto drop_while = __drop_while::__fn{};
121} // namespace __cpo
122} // namespace views
123} // namespace ranges
124
125#endif // _LIBCPP_STD_VER >= 20
126
127_LIBCPP_END_NAMESPACE_STD
128
129#endif // _LIBCPP___RANGES_DROP_WHILE_VIEW_H
lib/libcxx/include/__ranges/elements_view.h created+423
......@@ -0,0 +1,423 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___RANGES_ELEMENTS_VIEW_H
11#define _LIBCPP___RANGES_ELEMENTS_VIEW_H
12
13#include <__compare/three_way_comparable.h>
14#include <__concepts/constructible.h>
15#include <__concepts/convertible_to.h>
16#include <__concepts/derived_from.h>
17#include <__concepts/equality_comparable.h>
18#include <__config>
19#include <__fwd/get.h>
20#include <__iterator/concepts.h>
21#include <__iterator/iterator_traits.h>
22#include <__ranges/access.h>
23#include <__ranges/all.h>
24#include <__ranges/concepts.h>
25#include <__ranges/enable_borrowed_range.h>
26#include <__ranges/range_adaptor.h>
27#include <__ranges/size.h>
28#include <__ranges/view_interface.h>
29#include <__tuple_dir/tuple_element.h>
30#include <__tuple_dir/tuple_like.h>
31#include <__tuple_dir/tuple_size.h>
32#include <__type_traits/is_reference.h>
33#include <__type_traits/maybe_const.h>
34#include <__type_traits/remove_cv.h>
35#include <__type_traits/remove_cvref.h>
36#include <__type_traits/remove_reference.h>
37#include <__utility/declval.h>
38#include <__utility/forward.h>
39#include <__utility/move.h>
40#include <cstddef>
41
42#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
43# pragma GCC system_header
44#endif
45
46_LIBCPP_BEGIN_NAMESPACE_STD
47
48#if _LIBCPP_STD_VER >= 20
49
50namespace ranges {
51
52template <class _View, size_t _Np, bool _Const>
53class __elements_view_iterator;
54
55template <class _View, size_t _Np, bool _Const>
56class __elements_view_sentinel;
57
58template <class _Tp, size_t _Np>
59concept __has_tuple_element = __tuple_like<_Tp> && _Np < tuple_size<_Tp>::value;
60
61template <class _Tp, size_t _Np>
62concept __returnable_element = is_reference_v<_Tp> || move_constructible<tuple_element_t<_Np, _Tp>>;
63
64template <input_range _View, size_t _Np>
65 requires view<_View> && __has_tuple_element<range_value_t<_View>, _Np> &&
66 __has_tuple_element<remove_reference_t<range_reference_t<_View>>, _Np> &&
67 __returnable_element<range_reference_t<_View>, _Np>
68class elements_view : public view_interface<elements_view<_View, _Np>> {
69public:
70 _LIBCPP_HIDE_FROM_ABI elements_view()
71 requires default_initializable<_View>
72 = default;
73
74 _LIBCPP_HIDE_FROM_ABI constexpr explicit elements_view(_View __base) : __base_(std::move(__base)) {}
75
76 _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
77 requires copy_constructible<_View>
78 {
79 return __base_;
80 }
81
82 _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
83
84 _LIBCPP_HIDE_FROM_ABI constexpr auto begin()
85 requires(!__simple_view<_View>)
86 {
87 return __iterator</*_Const=*/false>(ranges::begin(__base_));
88 }
89
90 _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
91 requires range<const _View>
92 {
93 return __iterator</*_Const=*/true>(ranges::begin(__base_));
94 }
95
96 _LIBCPP_HIDE_FROM_ABI constexpr auto end()
97 requires(!__simple_view<_View> && !common_range<_View>)
98 {
99 return __sentinel</*_Const=*/false>{ranges::end(__base_)};
100 }
101
102 _LIBCPP_HIDE_FROM_ABI constexpr auto end()
103 requires(!__simple_view<_View> && common_range<_View>)
104 {
105 return __iterator</*_Const=*/false>{ranges::end(__base_)};
106 }
107
108 _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
109 requires range<const _View>
110 {
111 return __sentinel</*_Const=*/true>{ranges::end(__base_)};
112 }
113
114 _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
115 requires common_range<const _View>
116 {
117 return __iterator</*_Const=*/true>{ranges::end(__base_)};
118 }
119
120 _LIBCPP_HIDE_FROM_ABI constexpr auto size()
121 requires sized_range<_View>
122 {
123 return ranges::size(__base_);
124 }
125
126 _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
127 requires sized_range<const _View>
128 {
129 return ranges::size(__base_);
130 }
131
132private:
133 template <bool _Const>
134 using __iterator = __elements_view_iterator<_View, _Np, _Const>;
135
136 template <bool _Const>
137 using __sentinel = __elements_view_sentinel<_View, _Np, _Const>;
138
139 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
140};
141
142template <class, size_t>
143struct __elements_view_iterator_category_base {};
144
145template <forward_range _Base, size_t _Np>
146struct __elements_view_iterator_category_base<_Base, _Np> {
147 static consteval auto __get_iterator_category() {
148 using _Result = decltype(std::get<_Np>(*std::declval<iterator_t<_Base>>()));
149 using _Cat = typename iterator_traits<iterator_t<_Base>>::iterator_category;
150
151 if constexpr (!is_lvalue_reference_v<_Result>) {
152 return input_iterator_tag{};
153 } else if constexpr (derived_from<_Cat, random_access_iterator_tag>) {
154 return random_access_iterator_tag{};
155 } else {
156 return _Cat{};
157 }
158 }
159
160 using iterator_category = decltype(__get_iterator_category());
161};
162
163template <class _View, size_t _Np, bool _Const>
164class __elements_view_iterator : public __elements_view_iterator_category_base<__maybe_const<_Const, _View>, _Np> {
165 template <class, size_t, bool >
166 friend class __elements_view_iterator;
167
168 template <class, size_t, bool >
169 friend class __elements_view_sentinel;
170
171 using _Base = __maybe_const<_Const, _View>;
172
173 iterator_t<_Base> __current_ = iterator_t<_Base>();
174
175 _LIBCPP_HIDE_FROM_ABI static constexpr decltype(auto) __get_element(const iterator_t<_Base>& __i) {
176 if constexpr (is_reference_v<range_reference_t<_Base>>) {
177 return std::get<_Np>(*__i);
178 } else {
179 using _Element = remove_cv_t<tuple_element_t<_Np, range_reference_t<_Base>>>;
180 return static_cast<_Element>(std::get<_Np>(*__i));
181 }
182 }
183
184 static consteval auto __get_iterator_concept() {
185 if constexpr (random_access_range<_Base>) {
186 return random_access_iterator_tag{};
187 } else if constexpr (bidirectional_range<_Base>) {
188 return bidirectional_iterator_tag{};
189 } else if constexpr (forward_range<_Base>) {
190 return forward_iterator_tag{};
191 } else {
192 return input_iterator_tag{};
193 }
194 }
195
196public:
197 using iterator_concept = decltype(__get_iterator_concept());
198 using value_type = remove_cvref_t<tuple_element_t<_Np, range_value_t<_Base>>>;
199 using difference_type = range_difference_t<_Base>;
200
201 _LIBCPP_HIDE_FROM_ABI __elements_view_iterator()
202 requires default_initializable<iterator_t<_Base>>
203 = default;
204
205 _LIBCPP_HIDE_FROM_ABI constexpr explicit __elements_view_iterator(iterator_t<_Base> __current)
206 : __current_(std::move(__current)) {}
207
208 _LIBCPP_HIDE_FROM_ABI constexpr __elements_view_iterator(__elements_view_iterator<_View, _Np, !_Const> __i)
209 requires _Const && convertible_to<iterator_t<_View>, iterator_t<_Base>>
210 : __current_(std::move(__i.__current_)) {}
211
212 _LIBCPP_HIDE_FROM_ABI constexpr const iterator_t<_Base>& base() const& noexcept { return __current_; }
213
214 _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_Base> base() && { return std::move(__current_); }
215
216 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const { return __get_element(__current_); }
217
218 _LIBCPP_HIDE_FROM_ABI constexpr __elements_view_iterator& operator++() {
219 ++__current_;
220 return *this;
221 }
222
223 _LIBCPP_HIDE_FROM_ABI constexpr void operator++(int) { ++__current_; }
224
225 _LIBCPP_HIDE_FROM_ABI constexpr __elements_view_iterator operator++(int)
226 requires forward_range<_Base>
227 {
228 auto temp = *this;
229 ++__current_;
230 return temp;
231 }
232
233 _LIBCPP_HIDE_FROM_ABI constexpr __elements_view_iterator& operator--()
234 requires bidirectional_range<_Base>
235 {
236 --__current_;
237 return *this;
238 }
239
240 _LIBCPP_HIDE_FROM_ABI constexpr __elements_view_iterator operator--(int)
241 requires bidirectional_range<_Base>
242 {
243 auto temp = *this;
244 --__current_;
245 return temp;
246 }
247
248 _LIBCPP_HIDE_FROM_ABI constexpr __elements_view_iterator& operator+=(difference_type __n)
249 requires random_access_range<_Base>
250 {
251 __current_ += __n;
252 return *this;
253 }
254
255 _LIBCPP_HIDE_FROM_ABI constexpr __elements_view_iterator& operator-=(difference_type __n)
256 requires random_access_range<_Base>
257 {
258 __current_ -= __n;
259 return *this;
260 }
261
262 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](difference_type __n) const
263 requires random_access_range<_Base>
264 {
265 return __get_element(__current_ + __n);
266 }
267
268 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
269 operator==(const __elements_view_iterator& __x, const __elements_view_iterator& __y)
270 requires equality_comparable<iterator_t<_Base>>
271 {
272 return __x.__current_ == __y.__current_;
273 }
274
275 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
276 operator<(const __elements_view_iterator& __x, const __elements_view_iterator& __y)
277 requires random_access_range<_Base>
278 {
279 return __x.__current_ < __y.__current_;
280 }
281
282 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
283 operator>(const __elements_view_iterator& __x, const __elements_view_iterator& __y)
284 requires random_access_range<_Base>
285 {
286 return __y < __x;
287 }
288
289 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
290 operator<=(const __elements_view_iterator& __x, const __elements_view_iterator& __y)
291 requires random_access_range<_Base>
292 {
293 return !(__y < __x);
294 }
295
296 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
297 operator>=(const __elements_view_iterator& __x, const __elements_view_iterator& __y)
298 requires random_access_range<_Base>
299 {
300 return !(__x < __y);
301 }
302
303 _LIBCPP_HIDE_FROM_ABI friend constexpr auto
304 operator<=>(const __elements_view_iterator& __x, const __elements_view_iterator& __y)
305 requires random_access_range<_Base> && three_way_comparable<iterator_t<_Base>>
306 {
307 return __x.__current_ <=> __y.__current_;
308 }
309
310 _LIBCPP_HIDE_FROM_ABI friend constexpr __elements_view_iterator
311 operator+(const __elements_view_iterator& __x, difference_type __y)
312 requires random_access_range<_Base>
313 {
314 return __elements_view_iterator{__x} += __y;
315 }
316
317 _LIBCPP_HIDE_FROM_ABI friend constexpr __elements_view_iterator
318 operator+(difference_type __x, const __elements_view_iterator& __y)
319 requires random_access_range<_Base>
320 {
321 return __y + __x;
322 }
323
324 _LIBCPP_HIDE_FROM_ABI friend constexpr __elements_view_iterator
325 operator-(const __elements_view_iterator& __x, difference_type __y)
326 requires random_access_range<_Base>
327 {
328 return __elements_view_iterator{__x} -= __y;
329 }
330
331 _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type
332 operator-(const __elements_view_iterator& __x, const __elements_view_iterator& __y)
333 requires sized_sentinel_for<iterator_t<_Base>, iterator_t<_Base>>
334 {
335 return __x.__current_ - __y.__current_;
336 }
337};
338
339template <class _View, size_t _Np, bool _Const>
340class __elements_view_sentinel {
341private:
342 using _Base = __maybe_const<_Const, _View>;
343 _LIBCPP_NO_UNIQUE_ADDRESS sentinel_t<_Base> __end_ = sentinel_t<_Base>();
344
345 template <class, size_t, bool >
346 friend class __elements_view_sentinel;
347
348 template <bool _AnyConst>
349 _LIBCPP_HIDE_FROM_ABI static constexpr decltype(auto)
350 __get_current(const __elements_view_iterator<_View, _Np, _AnyConst>& __iter) {
351 return (__iter.__current_);
352 }
353
354public:
355 _LIBCPP_HIDE_FROM_ABI __elements_view_sentinel() = default;
356
357 _LIBCPP_HIDE_FROM_ABI constexpr explicit __elements_view_sentinel(sentinel_t<_Base> __end)
358 : __end_(std::move(__end)) {}
359
360 _LIBCPP_HIDE_FROM_ABI constexpr __elements_view_sentinel(__elements_view_sentinel<_View, _Np, !_Const> __other)
361 requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
362 : __end_(std::move(__other.__end_)) {}
363
364 _LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_Base> base() const { return __end_; }
365
366 template <bool _OtherConst>
367 requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
368 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
369 operator==(const __elements_view_iterator<_View, _Np, _OtherConst>& __x, const __elements_view_sentinel& __y) {
370 return __get_current(__x) == __y.__end_;
371 }
372
373 template <bool _OtherConst>
374 requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
375 _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>>
376 operator-(const __elements_view_iterator<_View, _Np, _OtherConst>& __x, const __elements_view_sentinel& __y) {
377 return __get_current(__x) - __y.__end_;
378 }
379
380 template <bool _OtherConst>
381 requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
382 _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>>
383 operator-(const __elements_view_sentinel& __x, const __elements_view_iterator<_View, _Np, _OtherConst>& __y) {
384 return __x.__end_ - __get_current(__y);
385 }
386};
387
388template <class _Tp, size_t _Np>
389inline constexpr bool enable_borrowed_range<elements_view<_Tp, _Np>> = enable_borrowed_range<_Tp>;
390
391template <class _Tp>
392using keys_view = elements_view<_Tp, 0>;
393template <class _Tp>
394using values_view = elements_view<_Tp, 1>;
395
396namespace views {
397namespace __elements {
398
399template <size_t _Np>
400struct __fn : __range_adaptor_closure<__fn<_Np>> {
401 template <class _Range>
402 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range) const
403 /**/ noexcept(noexcept(elements_view<all_t<_Range&&>, _Np>(std::forward<_Range>(__range))))
404 /*------*/ -> decltype(elements_view<all_t<_Range&&>, _Np>(std::forward<_Range>(__range))) {
405 /*-------------*/ return elements_view<all_t<_Range&&>, _Np>(std::forward<_Range>(__range));
406 }
407};
408} // namespace __elements
409
410inline namespace __cpo {
411template <size_t _Np>
412inline constexpr auto elements = __elements::__fn<_Np>{};
413inline constexpr auto keys = elements<0>;
414inline constexpr auto values = elements<1>;
415} // namespace __cpo
416} // namespace views
417} // namespace ranges
418
419#endif // _LIBCPP_STD_VER >= 20
420
421_LIBCPP_END_NAMESPACE_STD
422
423#endif // _LIBCPP___RANGES_ELEMENTS_VIEW_H
lib/libcxx/include/__ranges/empty.h+3-3
......@@ -6,6 +6,7 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_EMPTY_H
1011#define _LIBCPP___RANGES_EMPTY_H
1112
......@@ -14,7 +15,6 @@
1415#include <__iterator/concepts.h>
1516#include <__ranges/access.h>
1617#include <__ranges/size.h>
17#include <type_traits>
1818
1919#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2020# pragma GCC system_header
......@@ -22,7 +22,7 @@
2222
2323_LIBCPP_BEGIN_NAMESPACE_STD
2424
25#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
25#if _LIBCPP_STD_VER > 17
2626
2727// [range.prim.empty]
2828
......@@ -75,7 +75,7 @@ inline namespace __cpo {
7575} // namespace __cpo
7676} // namespace ranges
7777
78#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
78#endif // _LIBCPP_STD_VER > 17
7979
8080_LIBCPP_END_NAMESPACE_STD
8181
lib/libcxx/include/__ranges/empty_view.h+3-2
......@@ -6,6 +6,7 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_EMPTY_VIEW_H
1011#define _LIBCPP___RANGES_EMPTY_VIEW_H
1112
......@@ -20,7 +21,7 @@
2021
2122_LIBCPP_BEGIN_NAMESPACE_STD
2223
23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
24#if _LIBCPP_STD_VER > 17
2425
2526namespace ranges {
2627 template<class _Tp>
......@@ -45,7 +46,7 @@ namespace ranges {
4546 } // namespace views
4647} // namespace ranges
4748
48#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
49#endif // _LIBCPP_STD_VER > 17
4950
5051_LIBCPP_END_NAMESPACE_STD
5152
lib/libcxx/include/__ranges/enable_view.h+5-2
......@@ -10,9 +10,12 @@
1010#ifndef _LIBCPP___RANGES_ENABLE_VIEW_H
1111#define _LIBCPP___RANGES_ENABLE_VIEW_H
1212
13#include <__concepts/derived_from.h>
14#include <__concepts/same_as.h>
1315#include <__config>
14#include <concepts>
15#include <type_traits>
16#include <__type_traits/is_class.h>
17#include <__type_traits/is_convertible.h>
18#include <__type_traits/remove_cv.h>
1619
1720#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1821# pragma GCC system_header
lib/libcxx/include/__ranges/filter_view.h+42-21
......@@ -6,10 +6,15 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_FILTER_VIEW_H
1011#define _LIBCPP___RANGES_FILTER_VIEW_H
1112
1213#include <__algorithm/ranges_find_if.h>
14#include <__concepts/constructible.h>
15#include <__concepts/copyable.h>
16#include <__concepts/derived_from.h>
17#include <__concepts/equality_comparable.h>
1318#include <__config>
1419#include <__debug>
1520#include <__functional/bind_back.h>
......@@ -30,7 +35,6 @@
3035#include <__utility/forward.h>
3136#include <__utility/in_place.h>
3237#include <__utility/move.h>
33#include <concepts>
3438#include <type_traits>
3539
3640#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -39,9 +43,18 @@
3943
4044_LIBCPP_BEGIN_NAMESPACE_STD
4145
42#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
46#if _LIBCPP_STD_VER > 17
4347
4448namespace ranges {
49
50 template <input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred>
51 requires view<_View> && is_object_v<_Pred>
52 class __filter_view_iterator;
53
54 template <input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred>
55 requires view<_View> && is_object_v<_Pred>
56 class __filter_view_sentinel;
57
4558 template<input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred>
4659 requires view<_View> && is_object_v<_Pred>
4760 class filter_view : public view_interface<filter_view<_View, _Pred>> {
......@@ -54,8 +67,11 @@ namespace ranges {
5467 using _Cache = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;
5568 _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache();
5669
57 class __iterator;
58 class __sentinel;
70 using __iterator = __filter_view_iterator<_View, _Pred>;
71 using __sentinel = __filter_view_sentinel<_View, _Pred>;
72
73 friend __iterator;
74 friend __sentinel;
5975
6076 public:
6177 _LIBCPP_HIDE_FROM_ABI
......@@ -115,10 +131,13 @@ namespace ranges {
115131
116132 template<input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred>
117133 requires view<_View> && is_object_v<_Pred>
118 class filter_view<_View, _Pred>::__iterator : public __filter_iterator_category<_View> {
134 class __filter_view_iterator : public __filter_iterator_category<_View> {
135
136 using __filter_view = filter_view<_View, _Pred>;
137
119138 public:
120139 _LIBCPP_NO_UNIQUE_ADDRESS iterator_t<_View> __current_ = iterator_t<_View>();
121 _LIBCPP_NO_UNIQUE_ADDRESS filter_view* __parent_ = nullptr;
140 _LIBCPP_NO_UNIQUE_ADDRESS __filter_view* __parent_ = nullptr;
122141
123142 using iterator_concept =
124143 _If<bidirectional_range<_View>, bidirectional_iterator_tag,
......@@ -130,10 +149,10 @@ namespace ranges {
130149 using difference_type = range_difference_t<_View>;
131150
132151 _LIBCPP_HIDE_FROM_ABI
133 __iterator() requires default_initializable<iterator_t<_View>> = default;
152 __filter_view_iterator() requires default_initializable<iterator_t<_View>> = default;
134153
135154 _LIBCPP_HIDE_FROM_ABI
136 constexpr __iterator(filter_view& __parent, iterator_t<_View> __current)
155 constexpr __filter_view_iterator(__filter_view& __parent, iterator_t<_View> __current)
137156 : __current_(std::move(__current)), __parent_(std::addressof(__parent))
138157 { }
139158
......@@ -152,7 +171,7 @@ namespace ranges {
152171 }
153172
154173 _LIBCPP_HIDE_FROM_ABI
155 constexpr __iterator& operator++() {
174 constexpr __filter_view_iterator& operator++() {
156175 __current_ = ranges::find_if(std::move(++__current_), ranges::end(__parent_->__base_),
157176 std::ref(*__parent_->__pred_));
158177 return *this;
......@@ -160,42 +179,42 @@ namespace ranges {
160179 _LIBCPP_HIDE_FROM_ABI
161180 constexpr void operator++(int) { ++*this; }
162181 _LIBCPP_HIDE_FROM_ABI
163 constexpr __iterator operator++(int) requires forward_range<_View> {
182 constexpr __filter_view_iterator operator++(int) requires forward_range<_View> {
164183 auto __tmp = *this;
165184 ++*this;
166185 return __tmp;
167186 }
168187
169188 _LIBCPP_HIDE_FROM_ABI
170 constexpr __iterator& operator--() requires bidirectional_range<_View> {
189 constexpr __filter_view_iterator& operator--() requires bidirectional_range<_View> {
171190 do {
172191 --__current_;
173192 } while (!std::invoke(*__parent_->__pred_, *__current_));
174193 return *this;
175194 }
176195 _LIBCPP_HIDE_FROM_ABI
177 constexpr __iterator operator--(int) requires bidirectional_range<_View> {
196 constexpr __filter_view_iterator operator--(int) requires bidirectional_range<_View> {
178197 auto tmp = *this;
179198 --*this;
180199 return tmp;
181200 }
182201
183202 _LIBCPP_HIDE_FROM_ABI
184 friend constexpr bool operator==(__iterator const& __x, __iterator const& __y)
203 friend constexpr bool operator==(__filter_view_iterator const& __x, __filter_view_iterator const& __y)
185204 requires equality_comparable<iterator_t<_View>>
186205 {
187206 return __x.__current_ == __y.__current_;
188207 }
189208
190209 _LIBCPP_HIDE_FROM_ABI
191 friend constexpr range_rvalue_reference_t<_View> iter_move(__iterator const& __it)
210 friend constexpr range_rvalue_reference_t<_View> iter_move(__filter_view_iterator const& __it)
192211 noexcept(noexcept(ranges::iter_move(__it.__current_)))
193212 {
194213 return ranges::iter_move(__it.__current_);
195214 }
196215
197216 _LIBCPP_HIDE_FROM_ABI
198 friend constexpr void iter_swap(__iterator const& __x, __iterator const& __y)
217 friend constexpr void iter_swap(__filter_view_iterator const& __x, __filter_view_iterator const& __y)
199218 noexcept(noexcept(ranges::iter_swap(__x.__current_, __y.__current_)))
200219 requires indirectly_swappable<iterator_t<_View>>
201220 {
......@@ -205,23 +224,25 @@ namespace ranges {
205224
206225 template<input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred>
207226 requires view<_View> && is_object_v<_Pred>
208 class filter_view<_View, _Pred>::__sentinel {
227 class __filter_view_sentinel {
228 using __filter_view = filter_view<_View, _Pred>;
229
209230 public:
210231 sentinel_t<_View> __end_ = sentinel_t<_View>();
211232
212233 _LIBCPP_HIDE_FROM_ABI
213 __sentinel() = default;
234 __filter_view_sentinel() = default;
214235
215236 _LIBCPP_HIDE_FROM_ABI
216 constexpr explicit __sentinel(filter_view& __parent)
237 constexpr explicit __filter_view_sentinel(__filter_view& __parent)
217238 : __end_(ranges::end(__parent.__base_))
218239 { }
219240
220241 _LIBCPP_HIDE_FROM_ABI
221242 constexpr sentinel_t<_View> base() const { return __end_; }
222243
223 _LIBCPP_HIDE_FROM_ABI
224 friend constexpr bool operator==(__iterator const& __x, __sentinel const& __y) {
244 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
245 operator==(__filter_view_iterator<_View, _Pred> const& __x, __filter_view_sentinel const& __y) {
225246 return __x.__current_ == __y.__end_;
226247 }
227248 };
......@@ -252,7 +273,7 @@ inline namespace __cpo {
252273
253274} // namespace ranges
254275
255#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
276#endif // _LIBCPP_STD_VER > 17
256277
257278_LIBCPP_END_NAMESPACE_STD
258279
lib/libcxx/include/__ranges/iota_view.h+231-205
......@@ -6,6 +6,7 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_IOTA_VIEW_H
1011#define _LIBCPP___RANGES_IOTA_VIEW_H
1112
......@@ -39,7 +40,7 @@
3940
4041_LIBCPP_BEGIN_NAMESPACE_STD
4142
42#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
43#if _LIBCPP_STD_VER > 17
4344
4445namespace ranges {
4546 template<class _Int>
......@@ -82,6 +83,14 @@ namespace ranges {
8283 { __j - __j } -> convertible_to<_IotaDiffT<_Iter>>;
8384 };
8485
86 template <weakly_incrementable _Start>
87 requires copyable<_Start>
88 struct __iota_view_iterator;
89
90 template <weakly_incrementable _Start, semiregular _BoundSentinel>
91 requires __weakly_equality_comparable_with<_Start, _BoundSentinel> && copyable<_Start>
92 struct __iota_view_sentinel;
93
8594 template<class>
8695 struct __iota_iterator_category {};
8796
......@@ -93,210 +102,9 @@ namespace ranges {
93102 template <weakly_incrementable _Start, semiregular _BoundSentinel = unreachable_sentinel_t>
94103 requires __weakly_equality_comparable_with<_Start, _BoundSentinel> && copyable<_Start>
95104 class iota_view : public view_interface<iota_view<_Start, _BoundSentinel>> {
96 struct __iterator : public __iota_iterator_category<_Start> {
97 friend class iota_view;
98
99 using iterator_concept =
100 _If<__advanceable<_Start>, random_access_iterator_tag,
101 _If<__decrementable<_Start>, bidirectional_iterator_tag,
102 _If<incrementable<_Start>, forward_iterator_tag,
103 /*Else*/ input_iterator_tag>>>;
104
105 using value_type = _Start;
106 using difference_type = _IotaDiffT<_Start>;
107
108 _Start __value_ = _Start();
109
110 _LIBCPP_HIDE_FROM_ABI
111 __iterator() requires default_initializable<_Start> = default;
112
113 _LIBCPP_HIDE_FROM_ABI
114 constexpr explicit __iterator(_Start __value) : __value_(std::move(__value)) {}
115
116 _LIBCPP_HIDE_FROM_ABI
117 constexpr _Start operator*() const noexcept(is_nothrow_copy_constructible_v<_Start>) {
118 return __value_;
119 }
120
121 _LIBCPP_HIDE_FROM_ABI
122 constexpr __iterator& operator++() {
123 ++__value_;
124 return *this;
125 }
126
127 _LIBCPP_HIDE_FROM_ABI
128 constexpr void operator++(int) { ++*this; }
129
130 _LIBCPP_HIDE_FROM_ABI
131 constexpr __iterator operator++(int) requires incrementable<_Start> {
132 auto __tmp = *this;
133 ++*this;
134 return __tmp;
135 }
136
137 _LIBCPP_HIDE_FROM_ABI
138 constexpr __iterator& operator--() requires __decrementable<_Start> {
139 --__value_;
140 return *this;
141 }
142
143 _LIBCPP_HIDE_FROM_ABI
144 constexpr __iterator operator--(int) requires __decrementable<_Start> {
145 auto __tmp = *this;
146 --*this;
147 return __tmp;
148 }
149
150 _LIBCPP_HIDE_FROM_ABI
151 constexpr __iterator& operator+=(difference_type __n)
152 requires __advanceable<_Start>
153 {
154 if constexpr (__integer_like<_Start> && !__signed_integer_like<_Start>) {
155 if (__n >= difference_type(0)) {
156 __value_ += static_cast<_Start>(__n);
157 } else {
158 __value_ -= static_cast<_Start>(-__n);
159 }
160 } else {
161 __value_ += __n;
162 }
163 return *this;
164 }
165
166 _LIBCPP_HIDE_FROM_ABI
167 constexpr __iterator& operator-=(difference_type __n)
168 requires __advanceable<_Start>
169 {
170 if constexpr (__integer_like<_Start> && !__signed_integer_like<_Start>) {
171 if (__n >= difference_type(0)) {
172 __value_ -= static_cast<_Start>(__n);
173 } else {
174 __value_ += static_cast<_Start>(-__n);
175 }
176 } else {
177 __value_ -= __n;
178 }
179 return *this;
180 }
181
182 _LIBCPP_HIDE_FROM_ABI
183 constexpr _Start operator[](difference_type __n) const
184 requires __advanceable<_Start>
185 {
186 return _Start(__value_ + __n);
187 }
188
189 _LIBCPP_HIDE_FROM_ABI
190 friend constexpr bool operator==(const __iterator& __x, const __iterator& __y)
191 requires equality_comparable<_Start>
192 {
193 return __x.__value_ == __y.__value_;
194 }
195
196 _LIBCPP_HIDE_FROM_ABI
197 friend constexpr bool operator<(const __iterator& __x, const __iterator& __y)
198 requires totally_ordered<_Start>
199 {
200 return __x.__value_ < __y.__value_;
201 }
202
203 _LIBCPP_HIDE_FROM_ABI
204 friend constexpr bool operator>(const __iterator& __x, const __iterator& __y)
205 requires totally_ordered<_Start>
206 {
207 return __y < __x;
208 }
209
210 _LIBCPP_HIDE_FROM_ABI
211 friend constexpr bool operator<=(const __iterator& __x, const __iterator& __y)
212 requires totally_ordered<_Start>
213 {
214 return !(__y < __x);
215 }
216
217 _LIBCPP_HIDE_FROM_ABI
218 friend constexpr bool operator>=(const __iterator& __x, const __iterator& __y)
219 requires totally_ordered<_Start>
220 {
221 return !(__x < __y);
222 }
223
224 friend constexpr auto operator<=>(const __iterator& __x, const __iterator& __y)
225 requires totally_ordered<_Start> && three_way_comparable<_Start>
226 {
227 return __x.__value_ <=> __y.__value_;
228 }
229105
230 _LIBCPP_HIDE_FROM_ABI
231 friend constexpr __iterator operator+(__iterator __i, difference_type __n)
232 requires __advanceable<_Start>
233 {
234 __i += __n;
235 return __i;
236 }
237
238 _LIBCPP_HIDE_FROM_ABI
239 friend constexpr __iterator operator+(difference_type __n, __iterator __i)
240 requires __advanceable<_Start>
241 {
242 return __i + __n;
243 }
244
245 _LIBCPP_HIDE_FROM_ABI
246 friend constexpr __iterator operator-(__iterator __i, difference_type __n)
247 requires __advanceable<_Start>
248 {
249 __i -= __n;
250 return __i;
251 }
252
253 _LIBCPP_HIDE_FROM_ABI
254 friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y)
255 requires __advanceable<_Start>
256 {
257 if constexpr (__integer_like<_Start>) {
258 if constexpr (__signed_integer_like<_Start>) {
259 return difference_type(difference_type(__x.__value_) - difference_type(__y.__value_));
260 }
261 if (__y.__value_ > __x.__value_) {
262 return difference_type(-difference_type(__y.__value_ - __x.__value_));
263 }
264 return difference_type(__x.__value_ - __y.__value_);
265 }
266 return __x.__value_ - __y.__value_;
267 }
268 };
269
270 struct __sentinel {
271 friend class iota_view;
272
273 private:
274 _BoundSentinel __bound_sentinel_ = _BoundSentinel();
275
276 public:
277 _LIBCPP_HIDE_FROM_ABI
278 __sentinel() = default;
279 constexpr explicit __sentinel(_BoundSentinel __bound_sentinel) : __bound_sentinel_(std::move(__bound_sentinel)) {}
280
281 _LIBCPP_HIDE_FROM_ABI
282 friend constexpr bool operator==(const __iterator& __x, const __sentinel& __y) {
283 return __x.__value_ == __y.__bound_sentinel_;
284 }
285
286 _LIBCPP_HIDE_FROM_ABI
287 friend constexpr iter_difference_t<_Start> operator-(const __iterator& __x, const __sentinel& __y)
288 requires sized_sentinel_for<_BoundSentinel, _Start>
289 {
290 return __x.__value_ - __y.__bound_sentinel_;
291 }
292
293 _LIBCPP_HIDE_FROM_ABI
294 friend constexpr iter_difference_t<_Start> operator-(const __sentinel& __x, const __iterator& __y)
295 requires sized_sentinel_for<_BoundSentinel, _Start>
296 {
297 return -(__y - __x);
298 }
299 };
106 using __iterator = __iota_view_iterator<_Start>;
107 using __sentinel = __iota_view_sentinel<_Start, _BoundSentinel>;
300108
301109 _Start __value_ = _Start();
302110 _BoundSentinel __bound_sentinel_ = _BoundSentinel();
......@@ -377,6 +185,224 @@ namespace ranges {
377185 template <class _Start, class _BoundSentinel>
378186 inline constexpr bool enable_borrowed_range<iota_view<_Start, _BoundSentinel>> = true;
379187
188 template <weakly_incrementable _Start>
189 requires copyable<_Start>
190 struct __iota_view_iterator : public __iota_iterator_category<_Start> {
191
192 template <weakly_incrementable _StartT, semiregular _BoundSentinelT>
193 requires __weakly_equality_comparable_with<_StartT, _BoundSentinelT> && copyable<_StartT>
194 friend class iota_view;
195
196 using iterator_concept =
197 _If<__advanceable<_Start>, random_access_iterator_tag,
198 _If<__decrementable<_Start>, bidirectional_iterator_tag,
199 _If<incrementable<_Start>, forward_iterator_tag,
200 /*Else*/ input_iterator_tag>>>;
201
202 using value_type = _Start;
203 using difference_type = _IotaDiffT<_Start>;
204
205 _Start __value_ = _Start();
206
207 _LIBCPP_HIDE_FROM_ABI
208 __iota_view_iterator() requires default_initializable<_Start> = default;
209
210 _LIBCPP_HIDE_FROM_ABI
211 constexpr explicit __iota_view_iterator(_Start __value) : __value_(std::move(__value)) {}
212
213 _LIBCPP_HIDE_FROM_ABI
214 constexpr _Start operator*() const noexcept(is_nothrow_copy_constructible_v<_Start>) {
215 return __value_;
216 }
217
218 _LIBCPP_HIDE_FROM_ABI
219 constexpr __iota_view_iterator& operator++() {
220 ++__value_;
221 return *this;
222 }
223
224 _LIBCPP_HIDE_FROM_ABI
225 constexpr void operator++(int) { ++*this; }
226
227 _LIBCPP_HIDE_FROM_ABI
228 constexpr __iota_view_iterator operator++(int) requires incrementable<_Start> {
229 auto __tmp = *this;
230 ++*this;
231 return __tmp;
232 }
233
234 _LIBCPP_HIDE_FROM_ABI
235 constexpr __iota_view_iterator& operator--() requires __decrementable<_Start> {
236 --__value_;
237 return *this;
238 }
239
240 _LIBCPP_HIDE_FROM_ABI
241 constexpr __iota_view_iterator operator--(int) requires __decrementable<_Start> {
242 auto __tmp = *this;
243 --*this;
244 return __tmp;
245 }
246
247 _LIBCPP_HIDE_FROM_ABI
248 constexpr __iota_view_iterator& operator+=(difference_type __n)
249 requires __advanceable<_Start>
250 {
251 if constexpr (__integer_like<_Start> && !__signed_integer_like<_Start>) {
252 if (__n >= difference_type(0)) {
253 __value_ += static_cast<_Start>(__n);
254 } else {
255 __value_ -= static_cast<_Start>(-__n);
256 }
257 } else {
258 __value_ += __n;
259 }
260 return *this;
261 }
262
263 _LIBCPP_HIDE_FROM_ABI
264 constexpr __iota_view_iterator& operator-=(difference_type __n)
265 requires __advanceable<_Start>
266 {
267 if constexpr (__integer_like<_Start> && !__signed_integer_like<_Start>) {
268 if (__n >= difference_type(0)) {
269 __value_ -= static_cast<_Start>(__n);
270 } else {
271 __value_ += static_cast<_Start>(-__n);
272 }
273 } else {
274 __value_ -= __n;
275 }
276 return *this;
277 }
278
279 _LIBCPP_HIDE_FROM_ABI
280 constexpr _Start operator[](difference_type __n) const
281 requires __advanceable<_Start>
282 {
283 return _Start(__value_ + __n);
284 }
285
286 _LIBCPP_HIDE_FROM_ABI
287 friend constexpr bool operator==(const __iota_view_iterator& __x, const __iota_view_iterator& __y)
288 requires equality_comparable<_Start>
289 {
290 return __x.__value_ == __y.__value_;
291 }
292
293 _LIBCPP_HIDE_FROM_ABI
294 friend constexpr bool operator<(const __iota_view_iterator& __x, const __iota_view_iterator& __y)
295 requires totally_ordered<_Start>
296 {
297 return __x.__value_ < __y.__value_;
298 }
299
300 _LIBCPP_HIDE_FROM_ABI
301 friend constexpr bool operator>(const __iota_view_iterator& __x, const __iota_view_iterator& __y)
302 requires totally_ordered<_Start>
303 {
304 return __y < __x;
305 }
306
307 _LIBCPP_HIDE_FROM_ABI
308 friend constexpr bool operator<=(const __iota_view_iterator& __x, const __iota_view_iterator& __y)
309 requires totally_ordered<_Start>
310 {
311 return !(__y < __x);
312 }
313
314 _LIBCPP_HIDE_FROM_ABI
315 friend constexpr bool operator>=(const __iota_view_iterator& __x, const __iota_view_iterator& __y)
316 requires totally_ordered<_Start>
317 {
318 return !(__x < __y);
319 }
320
321 _LIBCPP_HIDE_FROM_ABI
322 friend constexpr auto operator<=>(const __iota_view_iterator& __x, const __iota_view_iterator& __y)
323 requires totally_ordered<_Start> && three_way_comparable<_Start>
324 {
325 return __x.__value_ <=> __y.__value_;
326 }
327
328 _LIBCPP_HIDE_FROM_ABI
329 friend constexpr __iota_view_iterator operator+(__iota_view_iterator __i, difference_type __n)
330 requires __advanceable<_Start>
331 {
332 __i += __n;
333 return __i;
334 }
335
336 _LIBCPP_HIDE_FROM_ABI
337 friend constexpr __iota_view_iterator operator+(difference_type __n, __iota_view_iterator __i)
338 requires __advanceable<_Start>
339 {
340 return __i + __n;
341 }
342
343 _LIBCPP_HIDE_FROM_ABI
344 friend constexpr __iota_view_iterator operator-(__iota_view_iterator __i, difference_type __n)
345 requires __advanceable<_Start>
346 {
347 __i -= __n;
348 return __i;
349 }
350
351 _LIBCPP_HIDE_FROM_ABI
352 friend constexpr difference_type operator-(const __iota_view_iterator& __x, const __iota_view_iterator& __y)
353 requires __advanceable<_Start>
354 {
355 if constexpr (__integer_like<_Start>) {
356 if constexpr (__signed_integer_like<_Start>) {
357 return difference_type(difference_type(__x.__value_) - difference_type(__y.__value_));
358 }
359 if (__y.__value_ > __x.__value_) {
360 return difference_type(-difference_type(__y.__value_ - __x.__value_));
361 }
362 return difference_type(__x.__value_ - __y.__value_);
363 }
364 return __x.__value_ - __y.__value_;
365 }
366 };
367
368 template <weakly_incrementable _Start, semiregular _BoundSentinel>
369 requires __weakly_equality_comparable_with<_Start, _BoundSentinel> && copyable<_Start>
370 struct __iota_view_sentinel {
371
372 template <weakly_incrementable _StartT, semiregular _BoundSentinelT>
373 requires __weakly_equality_comparable_with<_StartT, _BoundSentinelT> && copyable<_StartT>
374 friend class iota_view;
375
376 using __iterator = __iota_view_iterator<_Start>;
377
378 private:
379 _BoundSentinel __bound_sentinel_ = _BoundSentinel();
380
381 public:
382 _LIBCPP_HIDE_FROM_ABI
383 __iota_view_sentinel() = default;
384 constexpr explicit __iota_view_sentinel(_BoundSentinel __bound_sentinel) : __bound_sentinel_(std::move(__bound_sentinel)) {}
385
386 _LIBCPP_HIDE_FROM_ABI
387 friend constexpr bool operator==(const __iterator& __x, const __iota_view_sentinel& __y) {
388 return __x.__value_ == __y.__bound_sentinel_;
389 }
390
391 _LIBCPP_HIDE_FROM_ABI
392 friend constexpr iter_difference_t<_Start> operator-(const __iterator& __x, const __iota_view_sentinel& __y)
393 requires sized_sentinel_for<_BoundSentinel, _Start>
394 {
395 return __x.__value_ - __y.__bound_sentinel_;
396 }
397
398 _LIBCPP_HIDE_FROM_ABI
399 friend constexpr iter_difference_t<_Start> operator-(const __iota_view_sentinel& __x, const __iterator& __y)
400 requires sized_sentinel_for<_BoundSentinel, _Start>
401 {
402 return -(__y - __x);
403 }
404 };
405
380406 namespace views {
381407 namespace __iota {
382408 struct __fn {
......@@ -401,7 +427,7 @@ inline namespace __cpo {
401427} // namespace views
402428} // namespace ranges
403429
404#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
430#endif // _LIBCPP_STD_VER > 17
405431
406432_LIBCPP_END_NAMESPACE_STD
407433
lib/libcxx/include/__ranges/istream_view.h created+149
......@@ -0,0 +1,149 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___RANGES_ISTREAM_VIEW_H
11#define _LIBCPP___RANGES_ISTREAM_VIEW_H
12
13#include <__concepts/constructible.h>
14#include <__concepts/derived_from.h>
15#include <__concepts/movable.h>
16#include <__config>
17#include <__iterator/default_sentinel.h>
18#include <__iterator/iterator_traits.h>
19#include <__memory/addressof.h>
20#include <__ranges/view_interface.h>
21#include <__type_traits/remove_cvref.h>
22#include <__utility/forward.h>
23#include <cstddef>
24#include <iosfwd>
25
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header
28#endif
29
30#if _LIBCPP_STD_VER >= 20
31
32_LIBCPP_BEGIN_NAMESPACE_STD
33
34namespace ranges {
35
36template <class _Val, class _CharT, class _Traits>
37concept __stream_extractable = requires(basic_istream<_CharT, _Traits>& __is, _Val& __t) { __is >> __t; };
38
39template <movable _Val, class _CharT, class _Traits>
40 requires default_initializable<_Val> && __stream_extractable<_Val, _CharT, _Traits>
41class __basic_istream_view_iterator;
42
43template <movable _Val, class _CharT, class _Traits = char_traits<_CharT>>
44 requires default_initializable<_Val> && __stream_extractable<_Val, _CharT, _Traits>
45class basic_istream_view : public view_interface<basic_istream_view<_Val, _CharT, _Traits>> {
46 using __iterator = __basic_istream_view_iterator<_Val, _CharT, _Traits>;
47
48 template <movable _ValueType, class _CharType, class _TraitsType>
49 requires default_initializable<_ValueType> && __stream_extractable<_ValueType, _CharType, _TraitsType>
50 friend class __basic_istream_view_iterator;
51
52public:
53 _LIBCPP_HIDE_FROM_ABI constexpr explicit basic_istream_view(basic_istream<_CharT, _Traits>& __stream)
54 : __stream_(std::addressof(__stream)) {}
55
56 _LIBCPP_HIDE_FROM_ABI constexpr auto begin() {
57 *__stream_ >> __value_;
58 return __iterator{*this};
59 }
60
61 _LIBCPP_HIDE_FROM_ABI constexpr default_sentinel_t end() const noexcept { return default_sentinel; }
62
63private:
64 basic_istream<_CharT, _Traits>* __stream_;
65 _LIBCPP_NO_UNIQUE_ADDRESS _Val __value_ = _Val();
66};
67
68template <movable _Val, class _CharT, class _Traits>
69 requires default_initializable<_Val> && __stream_extractable<_Val, _CharT, _Traits>
70class __basic_istream_view_iterator {
71public:
72 using iterator_concept = input_iterator_tag;
73 using difference_type = ptrdiff_t;
74 using value_type = _Val;
75
76 _LIBCPP_HIDE_FROM_ABI constexpr explicit __basic_istream_view_iterator(
77 basic_istream_view<_Val, _CharT, _Traits>& __parent) noexcept
78 : __parent_(std::addressof(__parent)) {}
79
80 __basic_istream_view_iterator(const __basic_istream_view_iterator&) = delete;
81 _LIBCPP_HIDE_FROM_ABI __basic_istream_view_iterator(__basic_istream_view_iterator&&) = default;
82
83 __basic_istream_view_iterator& operator=(const __basic_istream_view_iterator&) = delete;
84 _LIBCPP_HIDE_FROM_ABI __basic_istream_view_iterator& operator=(__basic_istream_view_iterator&&) = default;
85
86 _LIBCPP_HIDE_FROM_ABI __basic_istream_view_iterator& operator++() {
87 *__parent_->__stream_ >> __parent_->__value_;
88 return *this;
89 }
90
91 _LIBCPP_HIDE_FROM_ABI void operator++(int) { ++*this; }
92
93 _LIBCPP_HIDE_FROM_ABI _Val& operator*() const { return __parent_->__value_; }
94
95 _LIBCPP_HIDE_FROM_ABI friend bool operator==(const __basic_istream_view_iterator& __x, default_sentinel_t) {
96 return !*__x.__get_parent_stream();
97 }
98
99private:
100 basic_istream_view<_Val, _CharT, _Traits>* __parent_;
101
102 _LIBCPP_HIDE_FROM_ABI constexpr basic_istream<_CharT, _Traits>* __get_parent_stream() const {
103 return __parent_->__stream_;
104 }
105};
106
107template <class _Val>
108using istream_view = basic_istream_view<_Val, char>;
109
110# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
111template <class _Val>
112using wistream_view = basic_istream_view<_Val, wchar_t>;
113# endif
114
115namespace views {
116namespace __istream {
117
118// clang-format off
119template <class _Tp>
120struct __fn {
121 template <class _Up, class _UnCVRef = remove_cvref_t<_Up>>
122 requires derived_from<_UnCVRef, basic_istream<typename _UnCVRef::char_type,
123 typename _UnCVRef::traits_type>>
124 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Up&& __u) const
125 noexcept(noexcept(basic_istream_view<_Tp, typename _UnCVRef::char_type,
126 typename _UnCVRef::traits_type>(std::forward<_Up>(__u))))
127 -> decltype( basic_istream_view<_Tp, typename _UnCVRef::char_type,
128 typename _UnCVRef::traits_type>(std::forward<_Up>(__u)))
129 { return basic_istream_view<_Tp, typename _UnCVRef::char_type,
130 typename _UnCVRef::traits_type>(std::forward<_Up>(__u));
131 }
132};
133// clang-format on
134
135} // namespace __istream
136
137inline namespace __cpo {
138template <class _Tp>
139inline constexpr auto istream = __istream::__fn<_Tp>{};
140} // namespace __cpo
141} // namespace views
142
143} // namespace ranges
144
145_LIBCPP_END_NAMESPACE_STD
146
147#endif // _LIBCPP_STD_VER >= 20
148
149#endif // _LIBCPP___RANGES_ISTREAM_VIEW_H
lib/libcxx/include/__ranges/join_view.h+110-28
......@@ -6,6 +6,7 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_JOIN_VIEW_H
1011#define _LIBCPP___RANGES_JOIN_VIEW_H
1112
......@@ -19,12 +20,16 @@
1920#include <__iterator/iter_move.h>
2021#include <__iterator/iter_swap.h>
2122#include <__iterator/iterator_traits.h>
23#include <__iterator/iterator_with_data.h>
24#include <__iterator/segmented_iterator.h>
2225#include <__ranges/access.h>
2326#include <__ranges/all.h>
2427#include <__ranges/concepts.h>
28#include <__ranges/empty.h>
2529#include <__ranges/non_propagating_cache.h>
2630#include <__ranges/range_adaptor.h>
2731#include <__ranges/view_interface.h>
32#include <__type_traits/maybe_const.h>
2833#include <__utility/forward.h>
2934#include <optional>
3035#include <type_traits>
......@@ -35,7 +40,7 @@
3540
3641_LIBCPP_BEGIN_NAMESPACE_STD
3742
38#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
43#if _LIBCPP_STD_VER > 17
3944
4045namespace ranges {
4146 template<class>
......@@ -61,6 +66,14 @@ namespace ranges {
6166 >;
6267 };
6368
69 template <input_range _View, bool _Const>
70 requires view<_View> && input_range<range_reference_t<_View>>
71 struct __join_view_iterator;
72
73 template <input_range _View, bool _Const>
74 requires view<_View> && input_range<range_reference_t<_View>>
75 struct __join_view_sentinel;
76
6477 template<input_range _View>
6578 requires view<_View> && input_range<range_reference_t<_View>>
6679 class join_view
......@@ -68,8 +81,22 @@ namespace ranges {
6881 private:
6982 using _InnerRange = range_reference_t<_View>;
7083
71 template<bool> struct __iterator;
72 template<bool> struct __sentinel;
84 template<bool _Const>
85 using __iterator = __join_view_iterator<_View, _Const>;
86
87 template<bool _Const>
88 using __sentinel = __join_view_sentinel<_View, _Const>;
89
90 template <input_range _View2, bool _Const2>
91 requires view<_View2> && input_range<range_reference_t<_View2>>
92 friend struct __join_view_iterator;
93
94 template <input_range _View2, bool _Const2>
95 requires view<_View2> && input_range<range_reference_t<_View2>>
96 friend struct __join_view_sentinel;
97
98 template <class>
99 friend struct std::__segmented_iterator_traits;
73100
74101 static constexpr bool _UseCache = !is_reference_v<_InnerRange>;
75102 using _Cache = _If<_UseCache, __non_propagating_cache<remove_cvref_t<_InnerRange>>, __empty_cache>;
......@@ -137,49 +164,57 @@ namespace ranges {
137164 }
138165 };
139166
140 template<input_range _View>
167 template<input_range _View, bool _Const>
141168 requires view<_View> && input_range<range_reference_t<_View>>
142 template<bool _Const> struct join_view<_View>::__sentinel {
143 template<bool> friend struct __sentinel;
169 struct __join_view_sentinel {
170 template<input_range _View2, bool>
171 requires view<_View2> && input_range<range_reference_t<_View2>>
172 friend struct __join_view_sentinel;
144173
145174 private:
146 using _Parent = __maybe_const<_Const, join_view>;
175 using _Parent = __maybe_const<_Const, join_view<_View>>;
147176 using _Base = __maybe_const<_Const, _View>;
148177 sentinel_t<_Base> __end_ = sentinel_t<_Base>();
149178
150179 public:
151180 _LIBCPP_HIDE_FROM_ABI
152 __sentinel() = default;
181 __join_view_sentinel() = default;
153182
154183 _LIBCPP_HIDE_FROM_ABI
155 constexpr explicit __sentinel(_Parent& __parent)
184 constexpr explicit __join_view_sentinel(_Parent& __parent)
156185 : __end_(ranges::end(__parent.__base_)) {}
157186
158187 _LIBCPP_HIDE_FROM_ABI
159 constexpr __sentinel(__sentinel<!_Const> __s)
188 constexpr __join_view_sentinel(__join_view_sentinel<_View, !_Const> __s)
160189 requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
161190 : __end_(std::move(__s.__end_)) {}
162191
163192 template<bool _OtherConst>
164193 requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
165194 _LIBCPP_HIDE_FROM_ABI
166 friend constexpr bool operator==(const __iterator<_OtherConst>& __x, const __sentinel& __y) {
195 friend constexpr bool operator==(const __join_view_iterator<_View, _OtherConst>& __x, const __join_view_sentinel& __y) {
167196 return __x.__outer_ == __y.__end_;
168197 }
169198 };
170199
171 template<input_range _View>
200 template<input_range _View, bool _Const>
172201 requires view<_View> && input_range<range_reference_t<_View>>
173 template<bool _Const> struct join_view<_View>::__iterator
202 struct __join_view_iterator
174203 : public __join_view_iterator_category<__maybe_const<_Const, _View>> {
175204
176 template<bool> friend struct __iterator;
205 template<input_range _View2, bool>
206 requires view<_View2> && input_range<range_reference_t<_View2>>
207 friend struct __join_view_iterator;
208
209 template <class>
210 friend struct std::__segmented_iterator_traits;
177211
178212 private:
179 using _Parent = __maybe_const<_Const, join_view>;
213 using _Parent = __maybe_const<_Const, join_view<_View>>;
180214 using _Base = __maybe_const<_Const, _View>;
181215 using _Outer = iterator_t<_Base>;
182216 using _Inner = iterator_t<range_reference_t<_Base>>;
217 using _InnerRange = range_reference_t<_View>;
183218
184219 static constexpr bool __ref_is_glvalue = is_reference_v<range_reference_t<_Base>>;
185220
......@@ -208,9 +243,12 @@ namespace ranges {
208243 __inner_.reset();
209244 }
210245
246 _LIBCPP_HIDE_FROM_ABI constexpr __join_view_iterator(_Parent* __parent, _Outer __outer, _Inner __inner)
247 : __outer_(std::move(__outer)), __inner_(std::move(__inner)), __parent_(__parent) {}
248
211249 public:
212250 using iterator_concept = _If<
213 __ref_is_glvalue && bidirectional_range<_Base> && bidirectional_range<range_reference_t<_Base>> &&
251 __ref_is_glvalue && bidirectional_range<_Base> && bidirectional_range<range_reference_t<_Base>> &&
214252 common_range<range_reference_t<_Base>>,
215253 bidirectional_iterator_tag,
216254 _If<
......@@ -226,17 +264,17 @@ namespace ranges {
226264 range_difference_t<_Base>, range_difference_t<range_reference_t<_Base>>>;
227265
228266 _LIBCPP_HIDE_FROM_ABI
229 __iterator() requires default_initializable<_Outer> = default;
267 __join_view_iterator() requires default_initializable<_Outer> = default;
230268
231269 _LIBCPP_HIDE_FROM_ABI
232 constexpr __iterator(_Parent& __parent, _Outer __outer)
270 constexpr __join_view_iterator(_Parent& __parent, _Outer __outer)
233271 : __outer_(std::move(__outer))
234272 , __parent_(std::addressof(__parent)) {
235273 __satisfy();
236274 }
237275
238276 _LIBCPP_HIDE_FROM_ABI
239 constexpr __iterator(__iterator<!_Const> __i)
277 constexpr __join_view_iterator(__join_view_iterator<_View, !_Const> __i)
240278 requires _Const &&
241279 convertible_to<iterator_t<_View>, _Outer> &&
242280 convertible_to<iterator_t<_InnerRange>, _Inner>
......@@ -257,7 +295,7 @@ namespace ranges {
257295 }
258296
259297 _LIBCPP_HIDE_FROM_ABI
260 constexpr __iterator& operator++() {
298 constexpr __join_view_iterator& operator++() {
261299 auto&& __inner = [&]() -> auto&& {
262300 if constexpr (__ref_is_glvalue)
263301 return *__outer_;
......@@ -277,7 +315,7 @@ namespace ranges {
277315 }
278316
279317 _LIBCPP_HIDE_FROM_ABI
280 constexpr __iterator operator++(int)
318 constexpr __join_view_iterator operator++(int)
281319 requires __ref_is_glvalue &&
282320 forward_range<_Base> &&
283321 forward_range<range_reference_t<_Base>>
......@@ -288,7 +326,7 @@ namespace ranges {
288326 }
289327
290328 _LIBCPP_HIDE_FROM_ABI
291 constexpr __iterator& operator--()
329 constexpr __join_view_iterator& operator--()
292330 requires __ref_is_glvalue &&
293331 bidirectional_range<_Base> &&
294332 bidirectional_range<range_reference_t<_Base>> &&
......@@ -307,7 +345,7 @@ namespace ranges {
307345 }
308346
309347 _LIBCPP_HIDE_FROM_ABI
310 constexpr __iterator operator--(int)
348 constexpr __join_view_iterator operator--(int)
311349 requires __ref_is_glvalue &&
312350 bidirectional_range<_Base> &&
313351 bidirectional_range<range_reference_t<_Base>> &&
......@@ -319,7 +357,7 @@ namespace ranges {
319357 }
320358
321359 _LIBCPP_HIDE_FROM_ABI
322 friend constexpr bool operator==(const __iterator& __x, const __iterator& __y)
360 friend constexpr bool operator==(const __join_view_iterator& __x, const __join_view_iterator& __y)
323361 requires __ref_is_glvalue &&
324362 equality_comparable<iterator_t<_Base>> &&
325363 equality_comparable<iterator_t<range_reference_t<_Base>>>
......@@ -328,14 +366,14 @@ namespace ranges {
328366 }
329367
330368 _LIBCPP_HIDE_FROM_ABI
331 friend constexpr decltype(auto) iter_move(const __iterator& __i)
369 friend constexpr decltype(auto) iter_move(const __join_view_iterator& __i)
332370 noexcept(noexcept(ranges::iter_move(*__i.__inner_)))
333371 {
334372 return ranges::iter_move(*__i.__inner_);
335373 }
336374
337375 _LIBCPP_HIDE_FROM_ABI
338 friend constexpr void iter_swap(const __iterator& __x, const __iterator& __y)
376 friend constexpr void iter_swap(const __join_view_iterator& __x, const __join_view_iterator& __y)
339377 noexcept(noexcept(ranges::iter_swap(*__x.__inner_, *__y.__inner_)))
340378 requires indirectly_swappable<_Inner>
341379 {
......@@ -345,7 +383,7 @@ namespace ranges {
345383
346384 template<class _Range>
347385 explicit join_view(_Range&&) -> join_view<views::all_t<_Range>>;
348
386
349387namespace views {
350388namespace __join_view {
351389struct __fn : __range_adaptor_closure<__fn> {
......@@ -363,7 +401,51 @@ inline namespace __cpo {
363401} // namespace views
364402} // namespace ranges
365403
366#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
404template <class _View, bool _Const>
405 requires(ranges::common_range<typename ranges::__join_view_iterator<_View, _Const>::_Parent> &&
406 __is_cpp17_random_access_iterator<typename ranges::__join_view_iterator<_View, _Const>::_Outer>::value &&
407 __is_cpp17_random_access_iterator<typename ranges::__join_view_iterator<_View, _Const>::_Inner>::value)
408struct __segmented_iterator_traits<ranges::__join_view_iterator<_View, _Const>> {
409 using _JoinViewIterator = ranges::__join_view_iterator<_View, _Const>;
410
411 using __segment_iterator =
412 _LIBCPP_NODEBUG __iterator_with_data<typename _JoinViewIterator::_Outer, typename _JoinViewIterator::_Parent*>;
413 using __local_iterator = typename _JoinViewIterator::_Inner;
414
415 // TODO: Would it make sense to enable the optimization for other iterator types?
416
417 static constexpr _LIBCPP_HIDE_FROM_ABI __segment_iterator __segment(_JoinViewIterator __iter) {
418 if (ranges::empty(__iter.__parent_->__base_))
419 return {};
420 if (!__iter.__inner_.has_value())
421 return __segment_iterator(--__iter.__outer_, __iter.__parent_);
422 return __segment_iterator(__iter.__outer_, __iter.__parent_);
423 }
424
425 static constexpr _LIBCPP_HIDE_FROM_ABI __local_iterator __local(_JoinViewIterator __iter) {
426 if (ranges::empty(__iter.__parent_->__base_))
427 return {};
428 if (!__iter.__inner_.has_value())
429 return ranges::end(*--__iter.__outer_);
430 return *__iter.__inner_;
431 }
432
433 static constexpr _LIBCPP_HIDE_FROM_ABI __local_iterator __begin(__segment_iterator __iter) {
434 return ranges::begin(*__iter.__get_iter());
435 }
436
437 static constexpr _LIBCPP_HIDE_FROM_ABI __local_iterator __end(__segment_iterator __iter) {
438 return ranges::end(*__iter.__get_iter());
439 }
440
441 static constexpr _LIBCPP_HIDE_FROM_ABI _JoinViewIterator
442 __compose(__segment_iterator __seg_iter, __local_iterator __local_iter) {
443 return _JoinViewIterator(
444 std::move(__seg_iter).__get_data(), std::move(__seg_iter).__get_iter(), std::move(__local_iter));
445 }
446};
447
448#endif // _LIBCPP_STD_VER > 17
367449
368450_LIBCPP_END_NAMESPACE_STD
369451
lib/libcxx/include/__ranges/lazy_split_view.h+3-3
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___RANGES_LAZY_SPLIT_VIEW_H
1111#define _LIBCPP___RANGES_LAZY_SPLIT_VIEW_H
1212
13#include <__algorithm/in_in_result.h>
1413#include <__algorithm/ranges_find.h>
1514#include <__algorithm/ranges_mismatch.h>
1615#include <__concepts/constructible.h>
......@@ -35,6 +34,7 @@
3534#include <__ranges/single_view.h>
3635#include <__ranges/subrange.h>
3736#include <__ranges/view_interface.h>
37#include <__type_traits/maybe_const.h>
3838#include <__utility/forward.h>
3939#include <__utility/move.h>
4040#include <type_traits>
......@@ -45,7 +45,7 @@
4545
4646_LIBCPP_BEGIN_NAMESPACE_STD
4747
48#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
48#if _LIBCPP_STD_VER > 17
4949
5050namespace ranges {
5151
......@@ -458,7 +458,7 @@ inline namespace __cpo {
458458
459459} // namespace ranges
460460
461#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
461#endif // _LIBCPP_STD_VER > 17
462462
463463_LIBCPP_END_NAMESPACE_STD
464464
lib/libcxx/include/__ranges/non_propagating_cache.h+3-3
......@@ -6,6 +6,7 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_NON_PROPAGATING_CACHE_H
1011#define _LIBCPP___RANGES_NON_PROPAGATING_CACHE_H
1112
......@@ -14,7 +15,6 @@
1415#include <__iterator/iterator_traits.h> // iter_reference_t
1516#include <__memory/addressof.h>
1617#include <__utility/forward.h>
17#include <concepts> // constructible_from
1818#include <optional>
1919#include <type_traits>
2020
......@@ -24,7 +24,7 @@
2424
2525_LIBCPP_BEGIN_NAMESPACE_STD
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
27#if _LIBCPP_STD_VER > 17
2828
2929namespace ranges {
3030 // __non_propagating_cache is a helper type that allows storing an optional value in it,
......@@ -107,7 +107,7 @@ namespace ranges {
107107 struct __empty_cache { };
108108} // namespace ranges
109109
110#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
110#endif // _LIBCPP_STD_VER > 17
111111
112112_LIBCPP_END_NAMESPACE_STD
113113
lib/libcxx/include/__ranges/owning_view.h+4-2
......@@ -6,6 +6,7 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_OWNING_VIEW_H
1011#define _LIBCPP___RANGES_OWNING_VIEW_H
1112
......@@ -28,7 +29,7 @@
2829
2930_LIBCPP_BEGIN_NAMESPACE_STD
3031
31#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
32#if _LIBCPP_STD_VER > 17
3233
3334namespace ranges {
3435 template<range _Rp>
......@@ -68,13 +69,14 @@ public:
6869 _LIBCPP_HIDE_FROM_ABI constexpr auto data() const requires contiguous_range<const _Rp>
6970 { return ranges::data(__r_); }
7071 };
72 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(owning_view);
7173
7274 template<class _Tp>
7375 inline constexpr bool enable_borrowed_range<owning_view<_Tp>> = enable_borrowed_range<_Tp>;
7476
7577} // namespace ranges
7678
77#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
79#endif // _LIBCPP_STD_VER > 17
7880
7981_LIBCPP_END_NAMESPACE_STD
8082
lib/libcxx/include/__ranges/range_adaptor.h+7-3
......@@ -10,13 +10,16 @@
1010#ifndef _LIBCPP___RANGES_RANGE_ADAPTOR_H
1111#define _LIBCPP___RANGES_RANGE_ADAPTOR_H
1212
13#include <__concepts/constructible.h>
14#include <__concepts/derived_from.h>
15#include <__concepts/invocable.h>
16#include <__concepts/same_as.h>
1317#include <__config>
1418#include <__functional/compose.h>
1519#include <__functional/invoke.h>
1620#include <__ranges/concepts.h>
1721#include <__utility/forward.h>
1822#include <__utility/move.h>
19#include <concepts>
2023#include <type_traits>
2124
2225#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -25,7 +28,7 @@
2528
2629_LIBCPP_BEGIN_NAMESPACE_STD
2730
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
31#if _LIBCPP_STD_VER > 17
2932
3033// CRTP base that one can derive from in order to be considered a range adaptor closure
3134// by the library. When deriving from this class, a pipe operator will be provided to
......@@ -41,6 +44,7 @@ template <class _Fn>
4144struct __range_adaptor_closure_t : _Fn, __range_adaptor_closure<__range_adaptor_closure_t<_Fn>> {
4245 constexpr explicit __range_adaptor_closure_t(_Fn&& __f) : _Fn(std::move(__f)) { }
4346};
47_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__range_adaptor_closure_t);
4448
4549template <class _Tp>
4650concept _RangeAdaptorClosure = derived_from<remove_cvref_t<_Tp>, __range_adaptor_closure<remove_cvref_t<_Tp>>>;
......@@ -66,7 +70,7 @@ struct __range_adaptor_closure {
6670 { return __range_adaptor_closure_t(std::__compose(std::forward<_OtherClosure>(__c2), std::forward<_Closure>(__c1))); }
6771};
6872
69#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
73#endif // _LIBCPP_STD_VER > 17
7074
7175_LIBCPP_END_NAMESPACE_STD
7276
lib/libcxx/include/__ranges/rbegin.h+3-2
......@@ -6,6 +6,7 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_RBEGIN_H
1011#define _LIBCPP___RANGES_RBEGIN_H
1112
......@@ -25,7 +26,7 @@
2526
2627_LIBCPP_BEGIN_NAMESPACE_STD
2728
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
29#if _LIBCPP_STD_VER > 17
2930
3031// [ranges.access.rbegin]
3132
......@@ -123,7 +124,7 @@ inline namespace __cpo {
123124} // namespace __cpo
124125} // namespace ranges
125126
126#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
127#endif // _LIBCPP_STD_VER > 17
127128
128129_LIBCPP_END_NAMESPACE_STD
129130
lib/libcxx/include/__ranges/ref_view.h+6-4
......@@ -6,9 +6,12 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_REF_VIEW_H
1011#define _LIBCPP___RANGES_REF_VIEW_H
1112
13#include <__concepts/convertible_to.h>
14#include <__concepts/different_from.h>
1215#include <__config>
1316#include <__iterator/concepts.h>
1417#include <__iterator/incrementable_traits.h>
......@@ -22,7 +25,6 @@
2225#include <__ranges/size.h>
2326#include <__ranges/view_interface.h>
2427#include <__utility/forward.h>
25#include <concepts>
2628#include <type_traits>
2729
2830#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -31,7 +33,7 @@
3133
3234_LIBCPP_BEGIN_NAMESPACE_STD
3335
34#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
36#if _LIBCPP_STD_VER > 17
3537
3638namespace ranges {
3739 template<range _Range>
......@@ -45,7 +47,7 @@ namespace ranges {
4547public:
4648 template<class _Tp>
4749 requires __different_from<_Tp, ref_view> &&
48 convertible_to<_Tp, _Range&> && requires { __fun(declval<_Tp>()); }
50 convertible_to<_Tp, _Range&> && requires { __fun(std::declval<_Tp>()); }
4951 _LIBCPP_HIDE_FROM_ABI
5052 constexpr ref_view(_Tp&& __t)
5153 : __range_(std::addressof(static_cast<_Range&>(std::forward<_Tp>(__t))))
......@@ -79,7 +81,7 @@ public:
7981 inline constexpr bool enable_borrowed_range<ref_view<_Tp>> = true;
8082} // namespace ranges
8183
82#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
84#endif // _LIBCPP_STD_VER > 17
8385
8486_LIBCPP_END_NAMESPACE_STD
8587
lib/libcxx/include/__ranges/rend.h+3-2
......@@ -6,6 +6,7 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_REND_H
1011#define _LIBCPP___RANGES_REND_H
1112
......@@ -26,7 +27,7 @@
2627
2728_LIBCPP_BEGIN_NAMESPACE_STD
2829
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
30#if _LIBCPP_STD_VER > 17
3031
3132// [range.access.rend]
3233
......@@ -127,7 +128,7 @@ inline namespace __cpo {
127128} // namespace __cpo
128129} // namespace ranges
129130
130#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
131#endif // _LIBCPP_STD_VER > 17
131132
132133_LIBCPP_END_NAMESPACE_STD
133134
lib/libcxx/include/__ranges/reverse_view.h+3-2
......@@ -6,6 +6,7 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_REVERSE_VIEW_H
1011#define _LIBCPP___RANGES_REVERSE_VIEW_H
1112
......@@ -33,7 +34,7 @@
3334
3435_LIBCPP_BEGIN_NAMESPACE_STD
3536
36#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
37#if _LIBCPP_STD_VER > 17
3738
3839namespace ranges {
3940 template<view _View>
......@@ -183,7 +184,7 @@ namespace ranges {
183184 } // namespace views
184185} // namespace ranges
185186
186#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
187#endif // _LIBCPP_STD_VER > 17
187188
188189_LIBCPP_END_NAMESPACE_STD
189190
lib/libcxx/include/__ranges/single_view.h+4-3
......@@ -6,9 +6,11 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_SINGLE_VIEW_H
1011#define _LIBCPP___RANGES_SINGLE_VIEW_H
1112
13#include <__concepts/constructible.h>
1214#include <__config>
1315#include <__ranges/copyable_box.h>
1416#include <__ranges/range_adaptor.h>
......@@ -16,7 +18,6 @@
1618#include <__utility/forward.h>
1719#include <__utility/in_place.h>
1820#include <__utility/move.h>
19#include <concepts>
2021#include <type_traits>
2122
2223#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -25,7 +26,7 @@
2526
2627_LIBCPP_BEGIN_NAMESPACE_STD
2728
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
29#if _LIBCPP_STD_VER > 17
2930
3031namespace ranges {
3132 template<copy_constructible _Tp>
......@@ -94,7 +95,7 @@ inline namespace __cpo {
9495} // namespace views
9596} // namespace ranges
9697
97#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
98#endif // _LIBCPP_STD_VER > 17
9899
99100_LIBCPP_END_NAMESPACE_STD
100101
lib/libcxx/include/__ranges/size.h+8-3
......@@ -6,18 +6,23 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_SIZE_H
1011#define _LIBCPP___RANGES_SIZE_H
1112
13#include <__concepts/arithmetic.h>
1214#include <__concepts/class_or_enum.h>
1315#include <__config>
1416#include <__iterator/concepts.h>
1517#include <__iterator/iterator_traits.h>
1618#include <__ranges/access.h>
19#include <__type_traits/decay.h>
20#include <__type_traits/make_signed.h>
21#include <__type_traits/make_unsigned.h>
22#include <__type_traits/remove_cvref.h>
1723#include <__utility/auto_cast.h>
18#include <concepts>
24#include <__utility/declval.h>
1925#include <cstddef>
20#include <type_traits>
2126
2227#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2328# pragma GCC system_header
......@@ -66,7 +71,7 @@ concept __difference =
6671 __class_or_enum<remove_cvref_t<_Tp>> &&
6772 requires(_Tp&& __t) {
6873 { ranges::begin(__t) } -> forward_iterator;
69 { ranges::end(__t) } -> sized_sentinel_for<decltype(ranges::begin(declval<_Tp>()))>;
74 { ranges::end(__t) } -> sized_sentinel_for<decltype(ranges::begin(std::declval<_Tp>()))>;
7075 };
7176
7277struct __fn {
lib/libcxx/include/__ranges/split_view.h created+232
......@@ -0,0 +1,232 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___RANGES_SPLIT_VIEW_H
11#define _LIBCPP___RANGES_SPLIT_VIEW_H
12
13#include <__algorithm/ranges_search.h>
14#include <__concepts/constructible.h>
15#include <__config>
16#include <__functional/bind_back.h>
17#include <__functional/ranges_operations.h>
18#include <__iterator/indirectly_comparable.h>
19#include <__iterator/iterator_traits.h>
20#include <__memory/addressof.h>
21#include <__ranges/access.h>
22#include <__ranges/all.h>
23#include <__ranges/concepts.h>
24#include <__ranges/empty.h>
25#include <__ranges/non_propagating_cache.h>
26#include <__ranges/range_adaptor.h>
27#include <__ranges/single_view.h>
28#include <__ranges/subrange.h>
29#include <__ranges/view_interface.h>
30#include <__type_traits/decay.h>
31#include <__type_traits/is_nothrow_constructible.h>
32#include <__utility/forward.h>
33#include <__utility/move.h>
34
35#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
36# pragma GCC system_header
37#endif
38
39_LIBCPP_BEGIN_NAMESPACE_STD
40
41#if _LIBCPP_STD_VER >= 20
42
43namespace ranges {
44
45template <class _View, class _Pattern>
46struct __split_view_iterator;
47
48template <class _View, class _Pattern>
49struct __split_view_sentinel;
50
51template <forward_range _View, forward_range _Pattern>
52 requires view<_View> && view<_Pattern> &&
53 indirectly_comparable<iterator_t<_View>, iterator_t<_Pattern>, ranges::equal_to>
54class split_view : public view_interface<split_view<_View, _Pattern>> {
55private:
56 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
57 _LIBCPP_NO_UNIQUE_ADDRESS _Pattern __pattern_ = _Pattern();
58 using _Cache = __non_propagating_cache<subrange<iterator_t<_View>>>;
59 _Cache __cached_begin_ = _Cache();
60
61 template <class, class>
62 friend struct __split_view_iterator;
63
64 template <class, class>
65 friend struct __split_view_sentinel;
66
67 using __iterator = __split_view_iterator<_View, _Pattern>;
68 using __sentinel = __split_view_sentinel<_View, _Pattern>;
69
70 _LIBCPP_HIDE_FROM_ABI constexpr subrange<iterator_t<_View>> __find_next(iterator_t<_View> __it) {
71 auto [__begin, __end] = ranges::search(subrange(__it, ranges::end(__base_)), __pattern_);
72 if (__begin != ranges::end(__base_) && ranges::empty(__pattern_)) {
73 ++__begin;
74 ++__end;
75 }
76 return {__begin, __end};
77 }
78
79public:
80 _LIBCPP_HIDE_FROM_ABI split_view()
81 requires default_initializable<_View> && default_initializable<_Pattern>
82 = default;
83
84 _LIBCPP_HIDE_FROM_ABI constexpr split_view(_View __base, _Pattern __pattern)
85 : __base_(std::move(__base)), __pattern_(std::move((__pattern))) {}
86
87 template <forward_range _Range>
88 requires constructible_from<_View, views::all_t<_Range>> &&
89 constructible_from<_Pattern, single_view<range_value_t<_Range>>>
90 _LIBCPP_HIDE_FROM_ABI constexpr split_view(_Range&& __range, range_value_t<_Range> __elem)
91 : __base_(views::all(std::forward<_Range>(__range))), __pattern_(views::single(std::move(__elem))) {}
92
93 _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
94 requires copy_constructible<_View>
95 {
96 return __base_;
97 }
98
99 _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
100
101 _LIBCPP_HIDE_FROM_ABI constexpr __iterator begin() {
102 if (!__cached_begin_.__has_value()) {
103 __cached_begin_.__emplace(__find_next(ranges::begin(__base_)));
104 }
105 return {*this, ranges::begin(__base_), *__cached_begin_};
106 }
107
108 _LIBCPP_HIDE_FROM_ABI constexpr auto end() {
109 if constexpr (common_range<_View>) {
110 return __iterator{*this, ranges::end(__base_), {}};
111 } else {
112 return __sentinel{*this};
113 }
114 }
115};
116
117template <class _Range, class _Pattern>
118split_view(_Range&&, _Pattern&&) -> split_view<views::all_t<_Range>, views::all_t<_Pattern>>;
119
120template <forward_range _Range>
121split_view(_Range&&, range_value_t<_Range>) -> split_view<views::all_t<_Range>, single_view<range_value_t<_Range>>>;
122
123template <class _View, class _Pattern>
124struct __split_view_iterator {
125private:
126 split_view<_View, _Pattern>* __parent_ = nullptr;
127 _LIBCPP_NO_UNIQUE_ADDRESS iterator_t<_View> __cur_ = iterator_t<_View>();
128 _LIBCPP_NO_UNIQUE_ADDRESS subrange<iterator_t<_View>> __next_ = subrange<iterator_t<_View>>();
129 bool __trailing_empty_ = false;
130
131 template <class, class>
132 friend struct __split_view_sentinel;
133
134public:
135 using iterator_concept = forward_iterator_tag;
136 using iterator_category = input_iterator_tag;
137 using value_type = subrange<iterator_t<_View>>;
138 using difference_type = range_difference_t<_View>;
139
140 _LIBCPP_HIDE_FROM_ABI __split_view_iterator() = default;
141
142 _LIBCPP_HIDE_FROM_ABI constexpr __split_view_iterator(
143 split_view<_View, _Pattern>& __parent, iterator_t<_View> __current, subrange<iterator_t<_View>> __next)
144 : __parent_(std::addressof(__parent)), __cur_(std::move(__current)), __next_(std::move(__next)) {}
145
146 _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_View> base() const { return __cur_; }
147
148 _LIBCPP_HIDE_FROM_ABI constexpr value_type operator*() const { return {__cur_, __next_.begin()}; }
149
150 _LIBCPP_HIDE_FROM_ABI constexpr __split_view_iterator& operator++() {
151 __cur_ = __next_.begin();
152 if (__cur_ != ranges::end(__parent_->__base_)) {
153 __cur_ = __next_.end();
154 if (__cur_ == ranges::end(__parent_->__base_)) {
155 __trailing_empty_ = true;
156 __next_ = {__cur_, __cur_};
157 } else {
158 __next_ = __parent_->__find_next(__cur_);
159 }
160 } else {
161 __trailing_empty_ = false;
162 }
163 return *this;
164 }
165
166 _LIBCPP_HIDE_FROM_ABI constexpr __split_view_iterator operator++(int) {
167 auto __tmp = *this;
168 ++*this;
169 return __tmp;
170 }
171
172 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
173 operator==(const __split_view_iterator& __x, const __split_view_iterator& __y) {
174 return __x.__cur_ == __y.__cur_ && __x.__trailing_empty_ == __y.__trailing_empty_;
175 }
176};
177
178template <class _View, class _Pattern>
179struct __split_view_sentinel {
180private:
181 _LIBCPP_NO_UNIQUE_ADDRESS sentinel_t<_View> __end_ = sentinel_t<_View>();
182
183 _LIBCPP_HIDE_FROM_ABI static constexpr bool
184 __equals(const __split_view_iterator<_View, _Pattern>& __x, const __split_view_sentinel& __y) {
185 return __x.__cur_ == __y.__end_ && !__x.__trailing_empty_;
186 }
187
188public:
189 _LIBCPP_HIDE_FROM_ABI __split_view_sentinel() = default;
190
191 _LIBCPP_HIDE_FROM_ABI constexpr explicit __split_view_sentinel(split_view<_View, _Pattern>& __parent)
192 : __end_(ranges::end(__parent.__base_)) {}
193
194 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
195 operator==(const __split_view_iterator<_View, _Pattern>& __x, const __split_view_sentinel& __y) {
196 return __equals(__x, __y);
197 }
198};
199
200namespace views {
201namespace __split_view {
202struct __fn : __range_adaptor_closure<__fn> {
203 // clang-format off
204 template <class _Range, class _Pattern>
205 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI
206 constexpr auto operator()(_Range&& __range, _Pattern&& __pattern) const
207 noexcept(noexcept(split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern))))
208 -> decltype( split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern)))
209 { return split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern)); }
210 // clang-format on
211
212 template <class _Pattern>
213 requires constructible_from<decay_t<_Pattern>, _Pattern>
214 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pattern&& __pattern) const
215 noexcept(is_nothrow_constructible_v<decay_t<_Pattern>, _Pattern>) {
216 return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pattern>(__pattern)));
217 }
218};
219} // namespace __split_view
220
221inline namespace __cpo {
222inline constexpr auto split = __split_view::__fn{};
223} // namespace __cpo
224} // namespace views
225
226} // namespace ranges
227
228#endif // _LIBCPP_STD_VER >= 20
229
230_LIBCPP_END_NAMESPACE_STD
231
232#endif // _LIBCPP___RANGES_SPLIT_VIEW_H
lib/libcxx/include/__ranges/subrange.h+16-17
......@@ -6,6 +6,7 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_SUBRANGE_H
1011#define _LIBCPP___RANGES_SUBRANGE_H
1112
......@@ -16,6 +17,8 @@
1617#include <__concepts/derived_from.h>
1718#include <__concepts/different_from.h>
1819#include <__config>
20#include <__fwd/get.h>
21#include <__fwd/subrange.h>
1922#include <__iterator/advance.h>
2023#include <__iterator/concepts.h>
2124#include <__iterator/incrementable_traits.h>
......@@ -26,9 +29,18 @@
2629#include <__ranges/enable_borrowed_range.h>
2730#include <__ranges/size.h>
2831#include <__ranges/view_interface.h>
29#include <__tuple>
32#include <__tuple_dir/pair_like.h>
33#include <__tuple_dir/tuple_element.h>
34#include <__tuple_dir/tuple_size.h>
35#include <__type_traits/conditional.h>
36#include <__type_traits/decay.h>
37#include <__type_traits/is_pointer.h>
38#include <__type_traits/is_reference.h>
39#include <__type_traits/make_unsigned.h>
40#include <__type_traits/remove_const.h>
41#include <__type_traits/remove_pointer.h>
3042#include <__utility/move.h>
31#include <type_traits>
43#include <cstddef>
3244
3345#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3446# pragma GCC system_header
......@@ -36,7 +48,7 @@
3648
3749_LIBCPP_BEGIN_NAMESPACE_STD
3850
39#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
51#if _LIBCPP_STD_VER > 17
4052
4153namespace ranges {
4254 template<class _From, class _To>
......@@ -49,17 +61,6 @@ namespace ranges {
4961 convertible_to<_From, _To> &&
5062 !__uses_nonqualification_pointer_conversion<decay_t<_From>, decay_t<_To>>;
5163
52 template<class _Tp>
53 concept __pair_like =
54 !is_reference_v<_Tp> && requires(_Tp __t) {
55 typename tuple_size<_Tp>::type; // Ensures `tuple_size<T>` is complete.
56 requires derived_from<tuple_size<_Tp>, integral_constant<size_t, 2>>;
57 typename tuple_element_t<0, remove_const_t<_Tp>>;
58 typename tuple_element_t<1, remove_const_t<_Tp>>;
59 { std::get<0>(__t) } -> convertible_to<const tuple_element_t<0, _Tp>&>;
60 { std::get<1>(__t) } -> convertible_to<const tuple_element_t<1, _Tp>&>;
61 };
62
6364 template<class _Pair, class _Iter, class _Sent>
6465 concept __pair_like_convertible_from =
6566 !range<_Pair> && __pair_like<_Pair> &&
......@@ -67,8 +68,6 @@ namespace ranges {
6768 __convertible_to_non_slicing<_Iter, tuple_element_t<0, _Pair>> &&
6869 convertible_to<_Sent, tuple_element_t<1, _Pair>>;
6970
70 enum class _LIBCPP_ENUM_VIS subrange_kind : bool { unsized, sized };
71
7271 template<input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent = _Iter,
7372 subrange_kind _Kind = sized_sentinel_for<_Sent, _Iter>
7473 ? subrange_kind::sized
......@@ -285,7 +284,7 @@ struct tuple_element<1, const ranges::subrange<_Ip, _Sp, _Kp>> {
285284 using type = _Sp;
286285};
287286
288#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
287#endif // _LIBCPP_STD_VER > 17
289288
290289_LIBCPP_END_NAMESPACE_STD
291290
lib/libcxx/include/__ranges/take_view.h+12-6
......@@ -6,11 +6,15 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_TAKE_VIEW_H
1011#define _LIBCPP___RANGES_TAKE_VIEW_H
1112
1213#include <__algorithm/min.h>
1314#include <__algorithm/ranges_min.h>
15#include <__assert>
16#include <__concepts/constructible.h>
17#include <__concepts/convertible_to.h>
1418#include <__config>
1519#include <__functional/bind_back.h>
1620#include <__fwd/span.h>
......@@ -30,10 +34,10 @@
3034#include <__ranges/size.h>
3135#include <__ranges/subrange.h>
3236#include <__ranges/view_interface.h>
37#include <__type_traits/maybe_const.h>
3338#include <__utility/auto_cast.h>
3439#include <__utility/forward.h>
3540#include <__utility/move.h>
36#include <concepts>
3741#include <type_traits>
3842
3943#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -45,7 +49,7 @@ _LIBCPP_PUSH_MACROS
4549
4650_LIBCPP_BEGIN_NAMESPACE_STD
4751
48#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
52#if _LIBCPP_STD_VER > 17
4953
5054namespace ranges {
5155
......@@ -60,9 +64,10 @@ public:
6064 _LIBCPP_HIDE_FROM_ABI
6165 take_view() requires default_initializable<_View> = default;
6266
63 _LIBCPP_HIDE_FROM_ABI
64 constexpr take_view(_View __base, range_difference_t<_View> __count)
65 : __base_(std::move(__base)), __count_(__count) {}
67 _LIBCPP_HIDE_FROM_ABI constexpr take_view(_View __base, range_difference_t<_View> __count)
68 : __base_(std::move(__base)), __count_(__count) {
69 _LIBCPP_ASSERT(__count >= 0, "count has to be greater than or equal to zero");
70 }
6671
6772 _LIBCPP_HIDE_FROM_ABI
6873 constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
......@@ -225,6 +230,7 @@ struct __passthrough_type<basic_string_view<_CharT, _Traits>> {
225230};
226231
227232template <class _Iter, class _Sent, subrange_kind _Kind>
233 requires requires{typename subrange<_Iter>;}
228234struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> {
229235 using type = subrange<_Iter>;
230236};
......@@ -328,7 +334,7 @@ inline namespace __cpo {
328334
329335} // namespace ranges
330336
331#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
337#endif // _LIBCPP_STD_VER > 17
332338
333339_LIBCPP_END_NAMESPACE_STD
334340
lib/libcxx/include/__ranges/take_while_view.h created+183
......@@ -0,0 +1,183 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___RANGES_TAKE_WHILE_VIEW_H
11#define _LIBCPP___RANGES_TAKE_WHILE_VIEW_H
12
13#include <__concepts/constructible.h>
14#include <__concepts/convertible_to.h>
15#include <__config>
16#include <__functional/bind_back.h>
17#include <__functional/invoke.h>
18#include <__iterator/concepts.h>
19#include <__memory/addressof.h>
20#include <__ranges/access.h>
21#include <__ranges/all.h>
22#include <__ranges/concepts.h>
23#include <__ranges/copyable_box.h>
24#include <__ranges/range_adaptor.h>
25#include <__ranges/view_interface.h>
26#include <__type_traits/decay.h>
27#include <__type_traits/is_nothrow_constructible.h>
28#include <__type_traits/is_object.h>
29#include <__type_traits/maybe_const.h>
30#include <__utility/forward.h>
31#include <__utility/in_place.h>
32#include <__utility/move.h>
33
34#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
35# pragma GCC system_header
36#endif
37
38_LIBCPP_BEGIN_NAMESPACE_STD
39
40#if _LIBCPP_STD_VER >= 20
41
42namespace ranges {
43
44// The spec uses the unnamed requirement inside the `begin` and `end` member functions:
45// constexpr auto begin() const
46// requires range<const V> && indirect_unary_predicate<const Pred, iterator_t<const V>>
47// However, due to a clang-14 and clang-15 bug, the above produces a hard error when `const V` is not a range.
48// The workaround is to create a named concept and use the concept instead.
49// As of take_while_view is implemented, the clang-trunk has already fixed the bug.
50// It is OK to remove the workaround once our CI no longer uses clang-14, clang-15 based compilers,
51// because we don't actually expect a lot of vendors to ship a new libc++ with an old clang.
52template <class _View, class _Pred>
53concept __take_while_const_is_range =
54 range<const _View> && indirect_unary_predicate<const _Pred, iterator_t<const _View>>;
55
56template <class, class, bool>
57class __take_while_view_sentinel;
58
59template <view _View, class _Pred>
60 requires input_range<_View> && is_object_v<_Pred> && indirect_unary_predicate<const _Pred, iterator_t<_View>>
61class take_while_view : public view_interface<take_while_view<_View, _Pred>> {
62 template <class, class, bool>
63 friend class __take_while_view_sentinel;
64
65 template <bool _Const>
66 using __sentinel = __take_while_view_sentinel<_View, _Pred, _Const>;
67
68 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
69 _LIBCPP_NO_UNIQUE_ADDRESS __copyable_box<_Pred> __pred_;
70
71public:
72 _LIBCPP_HIDE_FROM_ABI take_while_view()
73 requires default_initializable<_View> && default_initializable<_Pred>
74 = default;
75
76 _LIBCPP_HIDE_FROM_ABI constexpr take_while_view(_View __base, _Pred __pred)
77 : __base_(std::move(__base)), __pred_(std::in_place, std::move(__pred)) {}
78
79 _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
80 requires copy_constructible<_View>
81 {
82 return __base_;
83 }
84
85 _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
86
87 _LIBCPP_HIDE_FROM_ABI constexpr const _Pred& pred() const { return *__pred_; }
88
89 _LIBCPP_HIDE_FROM_ABI constexpr auto begin()
90 requires(!__simple_view<_View>)
91 {
92 return ranges::begin(__base_);
93 }
94
95 _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
96 requires __take_while_const_is_range<_View, _Pred>
97 {
98 return ranges::begin(__base_);
99 }
100
101 _LIBCPP_HIDE_FROM_ABI constexpr auto end()
102 requires(!__simple_view<_View>)
103 {
104 return __sentinel</*_Const=*/false>(ranges::end(__base_), std::addressof(*__pred_));
105 }
106
107 _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
108 requires __take_while_const_is_range<_View, _Pred>
109 {
110 return __sentinel</*_Const=*/true>(ranges::end(__base_), std::addressof(*__pred_));
111 }
112};
113
114template <class _Range, class _Pred>
115take_while_view(_Range&&, _Pred) -> take_while_view<views::all_t<_Range>, _Pred>;
116
117template <class _View, class _Pred, bool _Const>
118class __take_while_view_sentinel {
119 using _Base = __maybe_const<_Const, _View>;
120
121 sentinel_t<_Base> __end_ = sentinel_t<_Base>();
122 const _Pred* __pred_ = nullptr;
123
124 template <class, class, bool>
125 friend class __take_while_view_sentinel;
126
127public:
128 _LIBCPP_HIDE_FROM_ABI __take_while_view_sentinel() = default;
129
130 _LIBCPP_HIDE_FROM_ABI constexpr explicit __take_while_view_sentinel(sentinel_t<_Base> __end, const _Pred* __pred)
131 : __end_(std::move(__end)), __pred_(__pred) {}
132
133 _LIBCPP_HIDE_FROM_ABI constexpr __take_while_view_sentinel(__take_while_view_sentinel<_View, _Pred, !_Const> __s)
134 requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
135 : __end_(std::move(__s.__end_)), __pred_(__s.__pred_) {}
136
137 _LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_Base> base() const { return __end_; }
138
139 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
140 operator==(const iterator_t<_Base>& __x, const __take_while_view_sentinel& __y) {
141 return __x == __y.__end_ || !std::invoke(*__y.__pred_, *__x);
142 }
143
144 template <bool _OtherConst = !_Const>
145 requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
146 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
147 operator==(const iterator_t<__maybe_const<_OtherConst, _View>>& __x, const __take_while_view_sentinel& __y) {
148 return __x == __y.__end_ || !std::invoke(*__y.__pred_, *__x);
149 }
150};
151
152namespace views {
153namespace __take_while {
154
155struct __fn {
156 template <class _Range, class _Pred>
157 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Pred&& __pred) const
158 noexcept(noexcept(/**/ take_while_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))))
159 -> decltype(/*--*/ take_while_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))) {
160 return /*-------------*/ take_while_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred));
161 }
162
163 template <class _Pred>
164 requires constructible_from<decay_t<_Pred>, _Pred>
165 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const
166 noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) {
167 return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pred>(__pred)));
168 }
169};
170
171} // namespace __take_while
172
173inline namespace __cpo {
174inline constexpr auto take_while = __take_while::__fn{};
175} // namespace __cpo
176} // namespace views
177} // namespace ranges
178
179#endif // _LIBCPP_STD_VER >= 20
180
181_LIBCPP_END_NAMESPACE_STD
182
183#endif // _LIBCPP___RANGES_TAKE_WHILE_VIEW_H
lib/libcxx/include/__ranges/transform_view.h+80-53
......@@ -6,6 +6,7 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_TRANSFORM_VIEW_H
1011#define _LIBCPP___RANGES_TRANSFORM_VIEW_H
1112
......@@ -30,6 +31,7 @@
3031#include <__ranges/range_adaptor.h>
3132#include <__ranges/size.h>
3233#include <__ranges/view_interface.h>
34#include <__type_traits/maybe_const.h>
3335#include <__utility/forward.h>
3436#include <__utility/in_place.h>
3537#include <__utility/move.h>
......@@ -41,7 +43,7 @@
4143
4244_LIBCPP_BEGIN_NAMESPACE_STD
4345
44#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
46#if _LIBCPP_STD_VER > 17
4547
4648namespace ranges {
4749
......@@ -55,11 +57,31 @@ concept __transform_view_constraints =
5557 regular_invocable<_Fn&, range_reference_t<_View>> &&
5658 __can_reference<invoke_result_t<_Fn&, range_reference_t<_View>>>;
5759
60template <input_range _View, copy_constructible _Function, bool _IsConst>
61 requires __transform_view_constraints<_View, _Function>
62class __transform_view_iterator;
63
64template <input_range _View, copy_constructible _Function, bool _IsConst>
65 requires __transform_view_constraints<_View, _Function>
66class __transform_view_sentinel;
67
5868template<input_range _View, copy_constructible _Fn>
5969 requires __transform_view_constraints<_View, _Fn>
6070class transform_view : public view_interface<transform_view<_View, _Fn>> {
61 template<bool> class __iterator;
62 template<bool> class __sentinel;
71
72 template <bool _IsConst>
73 using __iterator = __transform_view_iterator<_View, _Fn, _IsConst>;
74
75 template <bool _IsConst>
76 using __sentinel = __transform_view_sentinel<_View, _Fn, _IsConst>;
77
78 template <input_range _ViewType, copy_constructible _FunctionType, bool _IsConst>
79 requires __transform_view_constraints<_ViewType, _FunctionType>
80 friend class __transform_view_iterator;
81
82 template <input_range _ViewType, copy_constructible _FunctionType, bool _IsConst>
83 requires __transform_view_constraints<_ViewType, _FunctionType>
84 friend class __transform_view_sentinel;
6385
6486 _LIBCPP_NO_UNIQUE_ADDRESS __copyable_box<_Fn> __func_;
6587 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
......@@ -154,22 +176,23 @@ struct __transform_view_iterator_category_base<_View, _Fn> {
154176 >;
155177};
156178
157template<input_range _View, copy_constructible _Fn>
179template<input_range _View, copy_constructible _Fn, bool _Const>
158180 requires __transform_view_constraints<_View, _Fn>
159template<bool _Const>
160class transform_view<_View, _Fn>::__iterator
181class __transform_view_iterator
161182 : public __transform_view_iterator_category_base<_View, _Fn> {
162183
163 using _Parent = __maybe_const<_Const, transform_view>;
184 using _Parent = __maybe_const<_Const, transform_view<_View, _Fn>>;
164185 using _Base = __maybe_const<_Const, _View>;
165186
166187 _Parent *__parent_ = nullptr;
167188
168 template<bool>
169 friend class transform_view<_View, _Fn>::__iterator;
189 template<input_range _ViewType, copy_constructible _FunctionType, bool _IsConst>
190 requires __transform_view_constraints<_ViewType, _FunctionType>
191 friend class __transform_view_iterator;
170192
171 template<bool>
172 friend class transform_view<_View, _Fn>::__sentinel;
193 template<input_range _ViewType, copy_constructible _FunctionType, bool _IsConst>
194 requires __transform_view_constraints<_ViewType, _FunctionType>
195 friend class __transform_view_sentinel;
173196
174197public:
175198 iterator_t<_Base> __current_ = iterator_t<_Base>();
......@@ -179,17 +202,17 @@ public:
179202 using difference_type = range_difference_t<_Base>;
180203
181204 _LIBCPP_HIDE_FROM_ABI
182 __iterator() requires default_initializable<iterator_t<_Base>> = default;
205 __transform_view_iterator() requires default_initializable<iterator_t<_Base>> = default;
183206
184207 _LIBCPP_HIDE_FROM_ABI
185 constexpr __iterator(_Parent& __parent, iterator_t<_Base> __current)
208 constexpr __transform_view_iterator(_Parent& __parent, iterator_t<_Base> __current)
186209 : __parent_(std::addressof(__parent)), __current_(std::move(__current)) {}
187210
188 // Note: `__i` should always be `__iterator<false>`, but directly using
189 // `__iterator<false>` is ill-formed when `_Const` is false
211 // Note: `__i` should always be `__transform_view_iterator<false>`, but directly using
212 // `__transform_view_iterator<false>` is ill-formed when `_Const` is false
190213 // (see http://wg21.link/class.copy.ctor#5).
191214 _LIBCPP_HIDE_FROM_ABI
192 constexpr __iterator(__iterator<!_Const> __i)
215 constexpr __transform_view_iterator(__transform_view_iterator<_View, _Fn, !_Const> __i)
193216 requires _Const && convertible_to<iterator_t<_View>, iterator_t<_Base>>
194217 : __parent_(__i.__parent_), __current_(std::move(__i.__current_)) {}
195218
......@@ -211,7 +234,7 @@ public:
211234 }
212235
213236 _LIBCPP_HIDE_FROM_ABI
214 constexpr __iterator& operator++() {
237 constexpr __transform_view_iterator& operator++() {
215238 ++__current_;
216239 return *this;
217240 }
......@@ -220,7 +243,7 @@ public:
220243 constexpr void operator++(int) { ++__current_; }
221244
222245 _LIBCPP_HIDE_FROM_ABI
223 constexpr __iterator operator++(int)
246 constexpr __transform_view_iterator operator++(int)
224247 requires forward_range<_Base>
225248 {
226249 auto __tmp = *this;
......@@ -229,7 +252,7 @@ public:
229252 }
230253
231254 _LIBCPP_HIDE_FROM_ABI
232 constexpr __iterator& operator--()
255 constexpr __transform_view_iterator& operator--()
233256 requires bidirectional_range<_Base>
234257 {
235258 --__current_;
......@@ -237,7 +260,7 @@ public:
237260 }
238261
239262 _LIBCPP_HIDE_FROM_ABI
240 constexpr __iterator operator--(int)
263 constexpr __transform_view_iterator operator--(int)
241264 requires bidirectional_range<_Base>
242265 {
243266 auto __tmp = *this;
......@@ -246,7 +269,7 @@ public:
246269 }
247270
248271 _LIBCPP_HIDE_FROM_ABI
249 constexpr __iterator& operator+=(difference_type __n)
272 constexpr __transform_view_iterator& operator+=(difference_type __n)
250273 requires random_access_range<_Base>
251274 {
252275 __current_ += __n;
......@@ -254,7 +277,7 @@ public:
254277 }
255278
256279 _LIBCPP_HIDE_FROM_ABI
257 constexpr __iterator& operator-=(difference_type __n)
280 constexpr __transform_view_iterator& operator-=(difference_type __n)
258281 requires random_access_range<_Base>
259282 {
260283 __current_ -= __n;
......@@ -270,77 +293,77 @@ public:
270293 }
271294
272295 _LIBCPP_HIDE_FROM_ABI
273 friend constexpr bool operator==(const __iterator& __x, const __iterator& __y)
296 friend constexpr bool operator==(const __transform_view_iterator& __x, const __transform_view_iterator& __y)
274297 requires equality_comparable<iterator_t<_Base>>
275298 {
276299 return __x.__current_ == __y.__current_;
277300 }
278301
279302 _LIBCPP_HIDE_FROM_ABI
280 friend constexpr bool operator<(const __iterator& __x, const __iterator& __y)
303 friend constexpr bool operator<(const __transform_view_iterator& __x, const __transform_view_iterator& __y)
281304 requires random_access_range<_Base>
282305 {
283306 return __x.__current_ < __y.__current_;
284307 }
285308
286309 _LIBCPP_HIDE_FROM_ABI
287 friend constexpr bool operator>(const __iterator& __x, const __iterator& __y)
310 friend constexpr bool operator>(const __transform_view_iterator& __x, const __transform_view_iterator& __y)
288311 requires random_access_range<_Base>
289312 {
290313 return __x.__current_ > __y.__current_;
291314 }
292315
293316 _LIBCPP_HIDE_FROM_ABI
294 friend constexpr bool operator<=(const __iterator& __x, const __iterator& __y)
317 friend constexpr bool operator<=(const __transform_view_iterator& __x, const __transform_view_iterator& __y)
295318 requires random_access_range<_Base>
296319 {
297320 return __x.__current_ <= __y.__current_;
298321 }
299322
300323 _LIBCPP_HIDE_FROM_ABI
301 friend constexpr bool operator>=(const __iterator& __x, const __iterator& __y)
324 friend constexpr bool operator>=(const __transform_view_iterator& __x, const __transform_view_iterator& __y)
302325 requires random_access_range<_Base>
303326 {
304327 return __x.__current_ >= __y.__current_;
305328 }
306329
307330 _LIBCPP_HIDE_FROM_ABI
308 friend constexpr auto operator<=>(const __iterator& __x, const __iterator& __y)
331 friend constexpr auto operator<=>(const __transform_view_iterator& __x, const __transform_view_iterator& __y)
309332 requires random_access_range<_Base> && three_way_comparable<iterator_t<_Base>>
310333 {
311334 return __x.__current_ <=> __y.__current_;
312335 }
313336
314337 _LIBCPP_HIDE_FROM_ABI
315 friend constexpr __iterator operator+(__iterator __i, difference_type __n)
338 friend constexpr __transform_view_iterator operator+(__transform_view_iterator __i, difference_type __n)
316339 requires random_access_range<_Base>
317340 {
318 return __iterator{*__i.__parent_, __i.__current_ + __n};
341 return __transform_view_iterator{*__i.__parent_, __i.__current_ + __n};
319342 }
320343
321344 _LIBCPP_HIDE_FROM_ABI
322 friend constexpr __iterator operator+(difference_type __n, __iterator __i)
345 friend constexpr __transform_view_iterator operator+(difference_type __n, __transform_view_iterator __i)
323346 requires random_access_range<_Base>
324347 {
325 return __iterator{*__i.__parent_, __i.__current_ + __n};
348 return __transform_view_iterator{*__i.__parent_, __i.__current_ + __n};
326349 }
327350
328351 _LIBCPP_HIDE_FROM_ABI
329 friend constexpr __iterator operator-(__iterator __i, difference_type __n)
352 friend constexpr __transform_view_iterator operator-(__transform_view_iterator __i, difference_type __n)
330353 requires random_access_range<_Base>
331354 {
332 return __iterator{*__i.__parent_, __i.__current_ - __n};
355 return __transform_view_iterator{*__i.__parent_, __i.__current_ - __n};
333356 }
334357
335358 _LIBCPP_HIDE_FROM_ABI
336 friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y)
359 friend constexpr difference_type operator-(const __transform_view_iterator& __x, const __transform_view_iterator& __y)
337360 requires sized_sentinel_for<iterator_t<_Base>, iterator_t<_Base>>
338361 {
339362 return __x.__current_ - __y.__current_;
340363 }
341364
342365 _LIBCPP_HIDE_FROM_ABI
343 friend constexpr decltype(auto) iter_move(const __iterator& __i)
366 friend constexpr decltype(auto) iter_move(const __transform_view_iterator& __i)
344367 noexcept(noexcept(*__i))
345368 {
346369 if constexpr (is_lvalue_reference_v<decltype(*__i)>)
......@@ -350,33 +373,37 @@ public:
350373 }
351374};
352375
353template<input_range _View, copy_constructible _Fn>
376template<input_range _View, copy_constructible _Fn, bool _Const>
354377 requires __transform_view_constraints<_View, _Fn>
355template<bool _Const>
356class transform_view<_View, _Fn>::__sentinel {
357 using _Parent = __maybe_const<_Const, transform_view>;
378class __transform_view_sentinel {
379 using _Parent = __maybe_const<_Const, transform_view<_View, _Fn>>;
358380 using _Base = __maybe_const<_Const, _View>;
359381
382 template <bool _IsConst>
383 using __iterator = __transform_view_iterator<_View, _Fn, _IsConst>;
384
360385 sentinel_t<_Base> __end_ = sentinel_t<_Base>();
361386
362 template<bool>
363 friend class transform_view<_View, _Fn>::__iterator;
387 template<input_range _ViewType, copy_constructible _FunctionType, bool _IsConst>
388 requires __transform_view_constraints<_ViewType, _FunctionType>
389 friend class __transform_view_iterator;
364390
365 template<bool>
366 friend class transform_view<_View, _Fn>::__sentinel;
391 template<input_range _ViewType, copy_constructible _FunctionType, bool _IsConst>
392 requires __transform_view_constraints<_ViewType, _FunctionType>
393 friend class __transform_view_sentinel;
367394
368395public:
369396 _LIBCPP_HIDE_FROM_ABI
370 __sentinel() = default;
397 __transform_view_sentinel() = default;
371398
372399 _LIBCPP_HIDE_FROM_ABI
373 constexpr explicit __sentinel(sentinel_t<_Base> __end) : __end_(__end) {}
400 constexpr explicit __transform_view_sentinel(sentinel_t<_Base> __end) : __end_(__end) {}
374401
375 // Note: `__i` should always be `__sentinel<false>`, but directly using
376 // `__sentinel<false>` is ill-formed when `_Const` is false
402 // Note: `__i` should always be `__transform_view_sentinel<false>`, but directly using
403 // `__transform_view_sentinel<false>` is ill-formed when `_Const` is false
377404 // (see http://wg21.link/class.copy.ctor#5).
378405 _LIBCPP_HIDE_FROM_ABI
379 constexpr __sentinel(__sentinel<!_Const> __i)
406 constexpr __transform_view_sentinel(__transform_view_sentinel<_View, _Fn, !_Const> __i)
380407 requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
381408 : __end_(std::move(__i.__end_)) {}
382409
......@@ -386,7 +413,7 @@ public:
386413 template<bool _OtherConst>
387414 requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
388415 _LIBCPP_HIDE_FROM_ABI
389 friend constexpr bool operator==(const __iterator<_OtherConst>& __x, const __sentinel& __y) {
416 friend constexpr bool operator==(const __iterator<_OtherConst>& __x, const __transform_view_sentinel& __y) {
390417 return __x.__current_ == __y.__end_;
391418 }
392419
......@@ -394,7 +421,7 @@ public:
394421 requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
395422 _LIBCPP_HIDE_FROM_ABI
396423 friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>>
397 operator-(const __iterator<_OtherConst>& __x, const __sentinel& __y) {
424 operator-(const __iterator<_OtherConst>& __x, const __transform_view_sentinel& __y) {
398425 return __x.__current_ - __y.__end_;
399426 }
400427
......@@ -402,7 +429,7 @@ public:
402429 requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
403430 _LIBCPP_HIDE_FROM_ABI
404431 friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>>
405 operator-(const __sentinel& __x, const __iterator<_OtherConst>& __y) {
432 operator-(const __transform_view_sentinel& __x, const __iterator<_OtherConst>& __y) {
406433 return __x.__end_ - __y.__current_;
407434 }
408435};
......@@ -433,7 +460,7 @@ inline namespace __cpo {
433460
434461} // namespace ranges
435462
436#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
463#endif // _LIBCPP_STD_VER > 17
437464
438465_LIBCPP_END_NAMESPACE_STD
439466
lib/libcxx/include/__ranges/view_interface.h+8-5
......@@ -6,6 +6,7 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_VIEW_INTERFACE_H
1011#define _LIBCPP___RANGES_VIEW_INTERFACE_H
1112
......@@ -20,7 +21,9 @@
2021#include <__ranges/access.h>
2122#include <__ranges/concepts.h>
2223#include <__ranges/empty.h>
23#include <type_traits>
24#include <__type_traits/is_class.h>
25#include <__type_traits/make_unsigned.h>
26#include <__type_traits/remove_cv.h>
2427
2528#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2629# pragma GCC system_header
......@@ -28,7 +31,7 @@
2831
2932_LIBCPP_BEGIN_NAMESPACE_STD
3033
31#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
34#if _LIBCPP_STD_VER > 17
3235
3336namespace ranges {
3437
......@@ -99,7 +102,7 @@ public:
99102 constexpr auto size()
100103 requires forward_range<_D2> && sized_sentinel_for<sentinel_t<_D2>, iterator_t<_D2>>
101104 {
102 return ranges::end(__derived()) - ranges::begin(__derived());
105 return std::__to_unsigned_like(ranges::end(__derived()) - ranges::begin(__derived()));
103106 }
104107
105108 template<class _D2 = _Derived>
......@@ -107,7 +110,7 @@ public:
107110 constexpr auto size() const
108111 requires forward_range<const _D2> && sized_sentinel_for<sentinel_t<const _D2>, iterator_t<const _D2>>
109112 {
110 return ranges::end(__derived()) - ranges::begin(__derived());
113 return std::__to_unsigned_like(ranges::end(__derived()) - ranges::begin(__derived()));
111114 }
112115
113116 template<class _D2 = _Derived>
......@@ -167,7 +170,7 @@ public:
167170
168171} // namespace ranges
169172
170#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
173#endif // _LIBCPP_STD_VER > 17
171174
172175_LIBCPP_END_NAMESPACE_STD
173176
lib/libcxx/include/__ranges/views.h+2-2
......@@ -18,7 +18,7 @@
1818
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
21#if _LIBCPP_STD_VER > 17
2222
2323namespace ranges {
2424
......@@ -28,7 +28,7 @@ namespace views { }
2828
2929namespace views = ranges::views;
3030
31#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
31#endif // _LIBCPP_STD_VER > 17
3232
3333_LIBCPP_END_NAMESPACE_STD
3434
lib/libcxx/include/__ranges/zip_view.h+6-5
......@@ -6,6 +6,7 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___RANGES_ZIP_VIEW_H
1011#define _LIBCPP___RANGES_ZIP_VIEW_H
1112
......@@ -44,7 +45,7 @@ _LIBCPP_PUSH_MACROS
4445
4546_LIBCPP_BEGIN_NAMESPACE_STD
4647
47#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
48#if _LIBCPP_STD_VER > 20
4849
4950namespace ranges {
5051
......@@ -402,15 +403,15 @@ public:
402403
403404 _LIBCPP_HIDE_FROM_ABI
404405 friend constexpr auto iter_move(const __iterator& __i) noexcept(
405 (noexcept(ranges::iter_move(declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) && ...) &&
406 (noexcept(ranges::iter_move(std::declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) && ...) &&
406407 (is_nothrow_move_constructible_v<range_rvalue_reference_t<__maybe_const<_Const, _Views>>> && ...)) {
407408 return ranges::__tuple_transform(ranges::iter_move, __i.__current_);
408409 }
409410
410411 _LIBCPP_HIDE_FROM_ABI
411412 friend constexpr void iter_swap(const __iterator& __l, const __iterator& __r) noexcept(
412 (noexcept(ranges::iter_swap(declval<const iterator_t<__maybe_const<_Const, _Views>>&>(),
413 declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) &&
413 (noexcept(ranges::iter_swap(std::declval<const iterator_t<__maybe_const<_Const, _Views>>&>(),
414 std::declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) &&
414415 ...))
415416 requires(indirectly_swappable<iterator_t<__maybe_const<_Const, _Views>>> && ...) {
416417 ranges::__tuple_zip_for_each(ranges::iter_swap, __l.__current_, __r.__current_);
......@@ -502,7 +503,7 @@ inline namespace __cpo {
502503} // namespace views
503504} // namespace ranges
504505
505#endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
506#endif // _LIBCPP_STD_VER > 20
506507
507508_LIBCPP_END_NAMESPACE_STD
508509
lib/libcxx/include/__split_buffer+99-92
......@@ -17,11 +17,14 @@
1717#include <__iterator/distance.h>
1818#include <__iterator/iterator_traits.h>
1919#include <__iterator/move_iterator.h>
20#include <__memory/allocate_at_least.h>
2021#include <__memory/allocator.h>
22#include <__memory/allocator_traits.h>
2123#include <__memory/compressed_pair.h>
24#include <__memory/pointer_traits.h>
2225#include <__memory/swap_allocator.h>
2326#include <__utility/forward.h>
24#include <memory>
27#include <__utility/move.h>
2528#include <type_traits>
2629
2730#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -34,6 +37,10 @@ _LIBCPP_PUSH_MACROS
3437
3538_LIBCPP_BEGIN_NAMESPACE_STD
3639
40// __split_buffer allocates a contiguous chunk of memory and stores objects in the range [__begin_, __end_).
41// It has uninitialized memory in the ranges [__first_, __begin_) and [__end_, __end_cap_.first()). That allows
42// it to grow both in the front and back without having to move the data.
43
3744template <class _Tp, class _Allocator = allocator<_Tp> >
3845struct __split_buffer
3946{
......@@ -43,7 +50,7 @@ private:
4350public:
4451 typedef _Tp value_type;
4552 typedef _Allocator allocator_type;
46 typedef typename remove_reference<allocator_type>::type __alloc_rr;
53 typedef __libcpp_remove_reference_t<allocator_type> __alloc_rr;
4754 typedef allocator_traits<__alloc_rr> __alloc_traits;
4855 typedef value_type& reference;
4956 typedef const value_type& const_reference;
......@@ -59,110 +66,110 @@ public:
5966 pointer __end_;
6067 __compressed_pair<pointer, allocator_type> __end_cap_;
6168
62 typedef typename add_lvalue_reference<allocator_type>::type __alloc_ref;
63 typedef typename add_lvalue_reference<allocator_type>::type __alloc_const_ref;
69 typedef __add_lvalue_reference_t<allocator_type> __alloc_ref;
70 typedef __add_lvalue_reference_t<allocator_type> __alloc_const_ref;
6471
65 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY __alloc_rr& __alloc() _NOEXCEPT {return __end_cap_.second();}
66 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const __alloc_rr& __alloc() const _NOEXCEPT {return __end_cap_.second();}
67 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();}
68 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();}
72 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __alloc_rr& __alloc() _NOEXCEPT {return __end_cap_.second();}
73 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const __alloc_rr& __alloc() const _NOEXCEPT {return __end_cap_.second();}
74 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();}
75 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();}
6976
70 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
77 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
7178 __split_buffer()
7279 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
73 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
80 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
7481 explicit __split_buffer(__alloc_rr& __a);
75 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
82 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
7683 explicit __split_buffer(const __alloc_rr& __a);
77 _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
78 _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__split_buffer();
84 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
85 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~__split_buffer();
7986
80 _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(__split_buffer&& __c)
87 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(__split_buffer&& __c)
8188 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
82 _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(__split_buffer&& __c, const __alloc_rr& __a);
83 _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer& operator=(__split_buffer&& __c)
89 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(__split_buffer&& __c, const __alloc_rr& __a);
90 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer& operator=(__split_buffer&& __c)
8491 _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
8592 is_nothrow_move_assignable<allocator_type>::value) ||
8693 !__alloc_traits::propagate_on_container_move_assignment::value);
8794
88 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;}
89 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;}
90 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return __end_;}
91 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return __end_;}
95 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT {return __begin_;}
96 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT {return __begin_;}
97 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT {return __end_;}
98 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT {return __end_;}
9299
93 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
100 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
94101 void clear() _NOEXCEPT
95102 {__destruct_at_end(__begin_);}
96 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast<size_type>(__end_ - __begin_);}
97 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY bool empty() const {return __end_ == __begin_;}
98 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast<size_type>(__end_cap() - __first_);}
99 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __front_spare() const {return static_cast<size_type>(__begin_ - __first_);}
100 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __back_spare() const {return static_cast<size_type>(__end_cap() - __end_);}
101
102 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference front() {return *__begin_;}
103 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference front() const {return *__begin_;}
104 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference back() {return *(__end_ - 1);}
105 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference back() const {return *(__end_ - 1);}
106
107 _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n);
108 _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT;
109 _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_front(const_reference __x);
110 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
111 _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_front(value_type&& __x);
112 _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(value_type&& __x);
103 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type size() const {return static_cast<size_type>(__end_ - __begin_);}
104 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const {return __end_ == __begin_;}
105 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const {return static_cast<size_type>(__end_cap() - __first_);}
106 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __front_spare() const {return static_cast<size_type>(__begin_ - __first_);}
107 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __back_spare() const {return static_cast<size_type>(__end_cap() - __end_);}
108
109 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() {return *__begin_;}
110 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const {return *__begin_;}
111 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() {return *(__end_ - 1);}
112 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const {return *(__end_ - 1);}
113
114 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n);
115 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT;
116 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_front(const_reference __x);
117 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(const_reference __x);
118 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __x);
119 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x);
113120 template <class... _Args>
114 _LIBCPP_CONSTEXPR_AFTER_CXX17 void emplace_back(_Args&&... __args);
121 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args);
115122
116 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);}
117 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);}
123 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_front() {__destruct_at_begin(__begin_+1);}
124 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_back() {__destruct_at_end(__end_-1);}
118125
119 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n);
120 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n, const_reference __x);
126 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n);
127 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n, const_reference __x);
121128 template <class _InputIter>
122 _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
129 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
123130 __construct_at_end(_InputIter __first, _InputIter __last);
124131 template <class _ForwardIterator>
125 _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
132 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
126133 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
127134
128 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin)
135 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_begin(pointer __new_begin)
129136 {__destruct_at_begin(__new_begin, is_trivially_destructible<value_type>());}
130 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
137 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
131138 void __destruct_at_begin(pointer __new_begin, false_type);
132 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
139 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
133140 void __destruct_at_begin(pointer __new_begin, true_type);
134141
135 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
142 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
136143 void __destruct_at_end(pointer __new_last) _NOEXCEPT
137144 {__destruct_at_end(__new_last, false_type());}
138 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
145 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
139146 void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT;
140 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
147 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
141148 void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT;
142149
143 _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(__split_buffer& __x)
150 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(__split_buffer& __x)
144151 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
145152 __is_nothrow_swappable<__alloc_rr>::value);
146153
147 _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const;
154 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const;
148155
149156private:
150 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
157 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
151158 void __move_assign_alloc(__split_buffer& __c, true_type)
152159 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
153160 {
154161 __alloc() = _VSTD::move(__c.__alloc());
155162 }
156163
157 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
164 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
158165 void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT
159166 {}
160167
161168 struct _ConstructTransaction {
162 _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT
169 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT
163170 : __pos_(*__p), __end_(*__p + __n), __dest_(__p) {
164171 }
165 _LIBCPP_CONSTEXPR_AFTER_CXX17 ~_ConstructTransaction() {
172 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() {
166173 *__dest_ = __pos_;
167174 }
168175 pointer __pos_;
......@@ -173,7 +180,7 @@ private:
173180};
174181
175182template <class _Tp, class _Allocator>
176_LIBCPP_CONSTEXPR_AFTER_CXX17
183_LIBCPP_CONSTEXPR_SINCE_CXX20
177184bool
178185__split_buffer<_Tp, _Allocator>::__invariants() const
179186{
......@@ -204,7 +211,7 @@ __split_buffer<_Tp, _Allocator>::__invariants() const
204211// Precondition: size() + __n <= capacity()
205212// Postcondition: size() == size() + __n
206213template <class _Tp, class _Allocator>
207_LIBCPP_CONSTEXPR_AFTER_CXX17
214_LIBCPP_CONSTEXPR_SINCE_CXX20
208215void
209216__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)
210217{
......@@ -221,7 +228,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)
221228// Postcondition: size() == old size() + __n
222229// Postcondition: [i] == __x for all i in [size() - __n, __n)
223230template <class _Tp, class _Allocator>
224_LIBCPP_CONSTEXPR_AFTER_CXX17
231_LIBCPP_CONSTEXPR_SINCE_CXX20
225232void
226233__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
227234{
......@@ -234,7 +241,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_referen
234241
235242template <class _Tp, class _Allocator>
236243template <class _InputIter>
237_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
244_LIBCPP_CONSTEXPR_SINCE_CXX20 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
238245__split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last)
239246{
240247 __alloc_rr& __a = this->__alloc();
......@@ -257,7 +264,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIt
257264
258265template <class _Tp, class _Allocator>
259266template <class _ForwardIterator>
260_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
267_LIBCPP_CONSTEXPR_SINCE_CXX20 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
261268__split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
262269{
263270 _ConstructTransaction __tx(&this->__end_, _VSTD::distance(__first, __last));
......@@ -268,7 +275,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _F
268275}
269276
270277template <class _Tp, class _Allocator>
271_LIBCPP_CONSTEXPR_AFTER_CXX17
278_LIBCPP_CONSTEXPR_SINCE_CXX20
272279inline
273280void
274281__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type)
......@@ -278,7 +285,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_
278285}
279286
280287template <class _Tp, class _Allocator>
281_LIBCPP_CONSTEXPR_AFTER_CXX17
288_LIBCPP_CONSTEXPR_SINCE_CXX20
282289inline
283290void
284291__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type)
......@@ -287,8 +294,8 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_t
287294}
288295
289296template <class _Tp, class _Allocator>
290_LIBCPP_CONSTEXPR_AFTER_CXX17
291inline _LIBCPP_INLINE_VISIBILITY
297_LIBCPP_CONSTEXPR_SINCE_CXX20
298inline _LIBCPP_HIDE_FROM_ABI
292299void
293300__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT
294301{
......@@ -297,8 +304,8 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_typ
297304}
298305
299306template <class _Tp, class _Allocator>
300_LIBCPP_CONSTEXPR_AFTER_CXX17
301inline _LIBCPP_INLINE_VISIBILITY
307_LIBCPP_CONSTEXPR_SINCE_CXX20
308inline _LIBCPP_HIDE_FROM_ABI
302309void
303310__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT
304311{
......@@ -306,7 +313,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type
306313}
307314
308315template <class _Tp, class _Allocator>
309_LIBCPP_CONSTEXPR_AFTER_CXX17
316_LIBCPP_CONSTEXPR_SINCE_CXX20
310317__split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a)
311318 : __end_cap_(nullptr, __a)
312319{
......@@ -322,7 +329,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __sta
322329}
323330
324331template <class _Tp, class _Allocator>
325_LIBCPP_CONSTEXPR_AFTER_CXX17
332_LIBCPP_CONSTEXPR_SINCE_CXX20
326333inline
327334__split_buffer<_Tp, _Allocator>::__split_buffer()
328335 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
......@@ -331,7 +338,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer()
331338}
332339
333340template <class _Tp, class _Allocator>
334_LIBCPP_CONSTEXPR_AFTER_CXX17
341_LIBCPP_CONSTEXPR_SINCE_CXX20
335342inline
336343__split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
337344 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
......@@ -339,7 +346,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
339346}
340347
341348template <class _Tp, class _Allocator>
342_LIBCPP_CONSTEXPR_AFTER_CXX17
349_LIBCPP_CONSTEXPR_SINCE_CXX20
343350inline
344351__split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
345352 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
......@@ -347,7 +354,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
347354}
348355
349356template <class _Tp, class _Allocator>
350_LIBCPP_CONSTEXPR_AFTER_CXX17
357_LIBCPP_CONSTEXPR_SINCE_CXX20
351358__split_buffer<_Tp, _Allocator>::~__split_buffer()
352359{
353360 clear();
......@@ -356,7 +363,7 @@ __split_buffer<_Tp, _Allocator>::~__split_buffer()
356363}
357364
358365template <class _Tp, class _Allocator>
359_LIBCPP_CONSTEXPR_AFTER_CXX17
366_LIBCPP_CONSTEXPR_SINCE_CXX20
360367__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
361368 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
362369 : __first_(_VSTD::move(__c.__first_)),
......@@ -371,7 +378,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
371378}
372379
373380template <class _Tp, class _Allocator>
374_LIBCPP_CONSTEXPR_AFTER_CXX17
381_LIBCPP_CONSTEXPR_SINCE_CXX20
375382__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a)
376383 : __end_cap_(nullptr, __a)
377384{
......@@ -398,7 +405,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __al
398405}
399406
400407template <class _Tp, class _Allocator>
401_LIBCPP_CONSTEXPR_AFTER_CXX17
408_LIBCPP_CONSTEXPR_SINCE_CXX20
402409__split_buffer<_Tp, _Allocator>&
403410__split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
404411 _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
......@@ -419,7 +426,7 @@ __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
419426}
420427
421428template <class _Tp, class _Allocator>
422_LIBCPP_CONSTEXPR_AFTER_CXX17
429_LIBCPP_CONSTEXPR_SINCE_CXX20
423430void
424431__split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
425432 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
......@@ -433,7 +440,7 @@ __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
433440}
434441
435442template <class _Tp, class _Allocator>
436_LIBCPP_CONSTEXPR_AFTER_CXX17
443_LIBCPP_CONSTEXPR_SINCE_CXX20
437444void
438445__split_buffer<_Tp, _Allocator>::reserve(size_type __n)
439446{
......@@ -450,7 +457,7 @@ __split_buffer<_Tp, _Allocator>::reserve(size_type __n)
450457}
451458
452459template <class _Tp, class _Allocator>
453_LIBCPP_CONSTEXPR_AFTER_CXX17
460_LIBCPP_CONSTEXPR_SINCE_CXX20
454461void
455462__split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
456463{
......@@ -478,7 +485,7 @@ __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
478485}
479486
480487template <class _Tp, class _Allocator>
481_LIBCPP_CONSTEXPR_AFTER_CXX17
488_LIBCPP_CONSTEXPR_SINCE_CXX20
482489void
483490__split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
484491{
......@@ -493,7 +500,7 @@ __split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
493500 }
494501 else
495502 {
496 size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
503 size_type __c = std::max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
497504 __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc());
498505 __t.__construct_at_end(move_iterator<pointer>(__begin_),
499506 move_iterator<pointer>(__end_));
......@@ -508,7 +515,7 @@ __split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
508515}
509516
510517template <class _Tp, class _Allocator>
511_LIBCPP_CONSTEXPR_AFTER_CXX17
518_LIBCPP_CONSTEXPR_SINCE_CXX20
512519void
513520__split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
514521{
......@@ -523,7 +530,7 @@ __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
523530 }
524531 else
525532 {
526 size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
533 size_type __c = std::max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
527534 __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc());
528535 __t.__construct_at_end(move_iterator<pointer>(__begin_),
529536 move_iterator<pointer>(__end_));
......@@ -539,8 +546,8 @@ __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
539546}
540547
541548template <class _Tp, class _Allocator>
542_LIBCPP_CONSTEXPR_AFTER_CXX17
543inline _LIBCPP_INLINE_VISIBILITY
549_LIBCPP_CONSTEXPR_SINCE_CXX20
550inline _LIBCPP_HIDE_FROM_ABI
544551void
545552__split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
546553{
......@@ -555,7 +562,7 @@ __split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
555562 }
556563 else
557564 {
558 size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
565 size_type __c = std::max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
559566 __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());
560567 __t.__construct_at_end(move_iterator<pointer>(__begin_),
561568 move_iterator<pointer>(__end_));
......@@ -570,7 +577,7 @@ __split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
570577}
571578
572579template <class _Tp, class _Allocator>
573_LIBCPP_CONSTEXPR_AFTER_CXX17
580_LIBCPP_CONSTEXPR_SINCE_CXX20
574581void
575582__split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
576583{
......@@ -585,7 +592,7 @@ __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
585592 }
586593 else
587594 {
588 size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
595 size_type __c = std::max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
589596 __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());
590597 __t.__construct_at_end(move_iterator<pointer>(__begin_),
591598 move_iterator<pointer>(__end_));
......@@ -602,7 +609,7 @@ __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
602609
603610template <class _Tp, class _Allocator>
604611template <class... _Args>
605_LIBCPP_CONSTEXPR_AFTER_CXX17
612_LIBCPP_CONSTEXPR_SINCE_CXX20
606613void
607614__split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
608615{
......@@ -617,7 +624,7 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
617624 }
618625 else
619626 {
620 size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
627 size_type __c = std::max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
621628 __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());
622629 __t.__construct_at_end(move_iterator<pointer>(__begin_),
623630 move_iterator<pointer>(__end_));
......@@ -633,8 +640,8 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
633640}
634641
635642template <class _Tp, class _Allocator>
636_LIBCPP_CONSTEXPR_AFTER_CXX17
637inline _LIBCPP_INLINE_VISIBILITY
643_LIBCPP_CONSTEXPR_SINCE_CXX20
644inline _LIBCPP_HIDE_FROM_ABI
638645void
639646swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y)
640647 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
lib/libcxx/include/__string/char_traits.h+229-320
......@@ -14,14 +14,16 @@
1414#include <__algorithm/find_end.h>
1515#include <__algorithm/find_first_of.h>
1616#include <__algorithm/min.h>
17#include <__compare/ordering.h>
1718#include <__config>
1819#include <__functional/hash.h>
1920#include <__iterator/iterator_traits.h>
21#include <__type_traits/is_constant_evaluated.h>
22#include <cstddef>
2023#include <cstdint>
2124#include <cstdio>
2225#include <cstring>
2326#include <iosfwd>
24#include <type_traits>
2527
2628#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2729# include <cwchar> // for wmemcpy
......@@ -37,35 +39,124 @@ _LIBCPP_PUSH_MACROS
3739_LIBCPP_BEGIN_NAMESPACE_STD
3840
3941template <class _CharT>
40struct _LIBCPP_TEMPLATE_VIS char_traits
42struct char_traits;
43/*
44The Standard does not define the base template for char_traits because it is impossible to provide
45a correct definition for arbitrary character types. Instead, it requires implementations to provide
46specializations for predefined character types like `char`, `wchar_t` and others. We provide this as
47exposition-only to document what members a char_traits specialization should provide:
48{
49 using char_type = _CharT;
50 using int_type = ...;
51 using off_type = ...;
52 using pos_type = ...;
53 using state_type = ...;
54
55 static void assign(char_type&, const char_type&);
56 static bool eq(char_type, char_type);
57 static bool lt(char_type, char_type);
58
59 static int compare(const char_type*, const char_type*, size_t);
60 static size_t length(const char_type*);
61 static const char_type* find(const char_type*, size_t, const char_type&);
62 static char_type* move(char_type*, const char_type*, size_t);
63 static char_type* copy(char_type*, const char_type*, size_t);
64 static char_type* assign(char_type*, size_t, char_type);
65
66 static int_type not_eof(int_type);
67 static char_type to_char_type(int_type);
68 static int_type to_int_type(char_type);
69 static bool eq_int_type(int_type, int_type);
70 static int_type eof();
71};
72*/
73
74//
75// Temporary extension to provide a base template for std::char_traits.
76// TODO: Remove in LLVM 18.
77//
78template <class _CharT>
79struct _LIBCPP_DEPRECATED_("char_traits<T> for T not equal to char, wchar_t, char8_t, char16_t or char32_t is non-standard and is provided for a temporary period. It will be removed in LLVM 18, so please migrate off of it.")
80 char_traits
4181{
42 typedef _CharT char_type;
43 typedef int int_type;
44 typedef streamoff off_type;
45 typedef streampos pos_type;
46 typedef mbstate_t state_type;
82 using char_type = _CharT;
83 using int_type = int;
84 using off_type = streamoff;
85 using pos_type = streampos;
86 using state_type = mbstate_t;
4787
48 static inline void _LIBCPP_CONSTEXPR_AFTER_CXX14
88 static inline void _LIBCPP_CONSTEXPR_SINCE_CXX17
4989 assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
5090 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
5191 {return __c1 == __c2;}
5292 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
5393 {return __c1 < __c2;}
5494
55 static _LIBCPP_CONSTEXPR_AFTER_CXX14
56 int compare(const char_type* __s1, const char_type* __s2, size_t __n);
57 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
58 size_t length(const char_type* __s);
59 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
60 const char_type* find(const char_type* __s, size_t __n, const char_type& __a);
61 static _LIBCPP_CONSTEXPR_AFTER_CXX17
62 char_type* move(char_type* __s1, const char_type* __s2, size_t __n);
95 static _LIBCPP_CONSTEXPR_SINCE_CXX17
96 int compare(const char_type* __s1, const char_type* __s2, size_t __n) {
97 for (; __n; --__n, ++__s1, ++__s2)
98 {
99 if (lt(*__s1, *__s2))
100 return -1;
101 if (lt(*__s2, *__s1))
102 return 1;
103 }
104 return 0;
105 }
106 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_SINCE_CXX17
107 size_t length(const char_type* __s) {
108 size_t __len = 0;
109 for (; !eq(*__s, char_type(0)); ++__s)
110 ++__len;
111 return __len;
112 }
113 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_SINCE_CXX17
114 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) {
115 for (; __n; --__n)
116 {
117 if (eq(*__s, __a))
118 return __s;
119 ++__s;
120 }
121 return nullptr;
122 }
123 static _LIBCPP_CONSTEXPR_SINCE_CXX20
124 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) {
125 if (__n == 0) return __s1;
126 char_type* __r = __s1;
127 if (__s1 < __s2)
128 {
129 for (; __n; --__n, ++__s1, ++__s2)
130 assign(*__s1, *__s2);
131 }
132 else if (__s2 < __s1)
133 {
134 __s1 += __n;
135 __s2 += __n;
136 for (; __n; --__n)
137 assign(*--__s1, *--__s2);
138 }
139 return __r;
140 }
63141 _LIBCPP_INLINE_VISIBILITY
64 static _LIBCPP_CONSTEXPR_AFTER_CXX17
65 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n);
142 static _LIBCPP_CONSTEXPR_SINCE_CXX20
143 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) {
144 if (!__libcpp_is_constant_evaluated()) {
145 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
146 }
147 char_type* __r = __s1;
148 for (; __n; --__n, ++__s1, ++__s2)
149 assign(*__s1, *__s2);
150 return __r;
151 }
66152 _LIBCPP_INLINE_VISIBILITY
67 static _LIBCPP_CONSTEXPR_AFTER_CXX17
68 char_type* assign(char_type* __s, size_t __n, char_type __a);
153 static _LIBCPP_CONSTEXPR_SINCE_CXX20
154 char_type* assign(char_type* __s, size_t __n, char_type __a) {
155 char_type* __r = __s;
156 for (; __n; --__n, ++__s)
157 assign(*__s, __a);
158 return __r;
159 }
69160
70161 static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
71162 {return eq_int_type(__c, eof()) ? ~eof() : __c;}
......@@ -80,92 +171,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits
80171};
81172
82173template <class _CharT>
83_LIBCPP_CONSTEXPR_AFTER_CXX14 int
84char_traits<_CharT>::compare(const char_type* __s1, const char_type* __s2, size_t __n)
85{
86 for (; __n; --__n, ++__s1, ++__s2)
87 {
88 if (lt(*__s1, *__s2))
89 return -1;
90 if (lt(*__s2, *__s1))
91 return 1;
92 }
93 return 0;
94}
95
96template <class _CharT>
97inline
98_LIBCPP_CONSTEXPR_AFTER_CXX14 size_t
99char_traits<_CharT>::length(const char_type* __s)
100{
101 size_t __len = 0;
102 for (; !eq(*__s, char_type(0)); ++__s)
103 ++__len;
104 return __len;
105}
106
107template <class _CharT>
108inline
109_LIBCPP_CONSTEXPR_AFTER_CXX14 const _CharT*
110char_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a)
111{
112 for (; __n; --__n)
113 {
114 if (eq(*__s, __a))
115 return __s;
116 ++__s;
117 }
118 return nullptr;
119}
120
121template <class _CharT>
122_LIBCPP_CONSTEXPR_AFTER_CXX17 _CharT*
123char_traits<_CharT>::move(char_type* __s1, const char_type* __s2, size_t __n)
124{
125 if (__n == 0) return __s1;
126 char_type* __r = __s1;
127 if (__s1 < __s2)
128 {
129 for (; __n; --__n, ++__s1, ++__s2)
130 assign(*__s1, *__s2);
131 }
132 else if (__s2 < __s1)
133 {
134 __s1 += __n;
135 __s2 += __n;
136 for (; __n; --__n)
137 assign(*--__s1, *--__s2);
138 }
139 return __r;
140}
141
142template <class _CharT>
143inline _LIBCPP_CONSTEXPR_AFTER_CXX17
144_CharT*
145char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n)
146{
147 if (!__libcpp_is_constant_evaluated()) {
148 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
149 }
150 char_type* __r = __s1;
151 for (; __n; --__n, ++__s1, ++__s2)
152 assign(*__s1, *__s2);
153 return __r;
154}
155
156template <class _CharT>
157inline _LIBCPP_CONSTEXPR_AFTER_CXX17
158_CharT*
159char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a)
160{
161 char_type* __r = __s;
162 for (; __n; --__n, ++__s)
163 assign(*__s, __a);
164 return __r;
165}
166
167template <class _CharT>
168static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
174_LIBCPP_HIDE_FROM_ABI static inline _LIBCPP_CONSTEXPR_SINCE_CXX20
169175_CharT* __char_traits_move(_CharT* __dest, const _CharT* __source, size_t __n) _NOEXCEPT
170176{
171177#ifdef _LIBCPP_COMPILER_GCC
......@@ -188,45 +194,45 @@ _CharT* __char_traits_move(_CharT* __dest, const _CharT* __source, size_t __n) _
188194template <>
189195struct _LIBCPP_TEMPLATE_VIS char_traits<char>
190196{
191 typedef char char_type;
192 typedef int int_type;
193 typedef streamoff off_type;
194 typedef streampos pos_type;
195 typedef mbstate_t state_type;
197 using char_type = char;
198 using int_type = int;
199 using off_type = streamoff;
200 using pos_type = streampos;
201 using state_type = mbstate_t;
202#if _LIBCPP_STD_VER > 17
203 using comparison_category = strong_ordering;
204#endif
196205
197 static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
206 static inline _LIBCPP_CONSTEXPR_SINCE_CXX17
198207 void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
199208 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
200209 {return __c1 == __c2;}
201210 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
202211 {return (unsigned char)__c1 < (unsigned char)__c2;}
203212
204 static _LIBCPP_CONSTEXPR_AFTER_CXX14
205 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
213 static _LIBCPP_CONSTEXPR_SINCE_CXX17 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
214 if (__n == 0)
215 return 0;
216 return std::__constexpr_memcmp(__s1, __s2, __n);
217 }
206218
207 static inline size_t _LIBCPP_CONSTEXPR_AFTER_CXX14 length(const char_type* __s) _NOEXCEPT {
208 // GCC currently does not support __builtin_strlen during constant evaluation.
209 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70816
210#ifdef _LIBCPP_COMPILER_GCC
211 if (__libcpp_is_constant_evaluated()) {
212 size_t __i = 0;
213 for (; __s[__i] != char_type('\0'); ++__i)
214 ;
215 return __i;
216 }
217#endif
218 return __builtin_strlen(__s);
219 }
219 static inline size_t _LIBCPP_CONSTEXPR_SINCE_CXX17 length(const char_type* __s) _NOEXCEPT {
220 return std::__constexpr_strlen(__s);
221 }
220222
221 static _LIBCPP_CONSTEXPR_AFTER_CXX14
222 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
223 static _LIBCPP_CONSTEXPR_SINCE_CXX17
224 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT {
225 if (__n == 0)
226 return nullptr;
227 return std::__constexpr_char_memchr(__s, static_cast<int>(__a), __n);
228 }
223229
224 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
230 static inline _LIBCPP_CONSTEXPR_SINCE_CXX20
225231 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
226232 return std::__char_traits_move(__s1, __s2, __n);
227233 }
228234
229 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
235 static inline _LIBCPP_CONSTEXPR_SINCE_CXX20
230236 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
231237 if (!__libcpp_is_constant_evaluated())
232238 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
......@@ -234,7 +240,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char>
234240 return __s1;
235241 }
236242
237 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
243 static inline _LIBCPP_CONSTEXPR_SINCE_CXX20
238244 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
239245 std::fill_n(__s, __n, __a);
240246 return __s;
......@@ -252,82 +258,51 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char>
252258 {return int_type(EOF);}
253259};
254260
255inline _LIBCPP_CONSTEXPR_AFTER_CXX14
256int
257char_traits<char>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
258{
259 if (__n == 0)
260 return 0;
261#if __has_feature(cxx_constexpr_string_builtins)
262 return __builtin_memcmp(__s1, __s2, __n);
263#elif _LIBCPP_STD_VER <= 14
264 return _VSTD::memcmp(__s1, __s2, __n);
265#else
266 for (; __n; --__n, ++__s1, ++__s2)
267 {
268 if (lt(*__s1, *__s2))
269 return -1;
270 if (lt(*__s2, *__s1))
271 return 1;
272 }
273 return 0;
274#endif
275}
276
277inline _LIBCPP_CONSTEXPR_AFTER_CXX14
278const char*
279char_traits<char>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
280{
281 if (__n == 0)
282 return nullptr;
283#if __has_feature(cxx_constexpr_string_builtins)
284 return __builtin_char_memchr(__s, to_int_type(__a), __n);
285#elif _LIBCPP_STD_VER <= 14
286 return (const char_type*) _VSTD::memchr(__s, to_int_type(__a), __n);
287#else
288 for (; __n; --__n)
289 {
290 if (eq(*__s, __a))
291 return __s;
292 ++__s;
293 }
294 return nullptr;
295#endif
296}
297
298
299261// char_traits<wchar_t>
300262
301263#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
302264template <>
303265struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t>
304266{
305 typedef wchar_t char_type;
306 typedef wint_t int_type;
307 typedef streamoff off_type;
308 typedef streampos pos_type;
309 typedef mbstate_t state_type;
267 using char_type = wchar_t;
268 using int_type = wint_t;
269 using off_type = streamoff;
270 using pos_type = streampos;
271 using state_type = mbstate_t;
272#if _LIBCPP_STD_VER > 17
273 using comparison_category = strong_ordering;
274#endif
310275
311 static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
276 static inline _LIBCPP_CONSTEXPR_SINCE_CXX17
312277 void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
313278 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
314279 {return __c1 == __c2;}
315280 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
316281 {return __c1 < __c2;}
317282
318 static _LIBCPP_CONSTEXPR_AFTER_CXX14
319 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
320 static _LIBCPP_CONSTEXPR_AFTER_CXX14
321 size_t length(const char_type* __s) _NOEXCEPT;
322 static _LIBCPP_CONSTEXPR_AFTER_CXX14
323 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
283 static _LIBCPP_CONSTEXPR_SINCE_CXX17 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
284 if (__n == 0)
285 return 0;
286 return std::__constexpr_wmemcmp(__s1, __s2, __n);
287 }
288
289 static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT {
290 return std::__constexpr_wcslen(__s);
291 }
292
293 static _LIBCPP_CONSTEXPR_SINCE_CXX17
294 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT {
295 if (__n == 0)
296 return nullptr;
297 return std::__constexpr_wmemchr(__s, __a, __n);
298 }
324299
325 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
300 static inline _LIBCPP_CONSTEXPR_SINCE_CXX20
326301 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
327302 return std::__char_traits_move(__s1, __s2, __n);
328303 }
329304
330 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
305 static inline _LIBCPP_CONSTEXPR_SINCE_CXX20
331306 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
332307 if (!__libcpp_is_constant_evaluated())
333308 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
......@@ -335,7 +310,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t>
335310 return __s1;
336311 }
337312
338 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17
313 static inline _LIBCPP_CONSTEXPR_SINCE_CXX20
339314 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
340315 std::fill_n(__s, __n, __a);
341316 return __s;
......@@ -352,65 +327,6 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t>
352327 static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
353328 {return int_type(WEOF);}
354329};
355
356inline _LIBCPP_CONSTEXPR_AFTER_CXX14
357int
358char_traits<wchar_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
359{
360 if (__n == 0)
361 return 0;
362#if __has_feature(cxx_constexpr_string_builtins)
363 return __builtin_wmemcmp(__s1, __s2, __n);
364#elif _LIBCPP_STD_VER <= 14
365 return _VSTD::wmemcmp(__s1, __s2, __n);
366#else
367 for (; __n; --__n, ++__s1, ++__s2)
368 {
369 if (lt(*__s1, *__s2))
370 return -1;
371 if (lt(*__s2, *__s1))
372 return 1;
373 }
374 return 0;
375#endif
376}
377
378inline _LIBCPP_CONSTEXPR_AFTER_CXX14
379size_t
380char_traits<wchar_t>::length(const char_type* __s) _NOEXCEPT
381{
382#if __has_feature(cxx_constexpr_string_builtins)
383 return __builtin_wcslen(__s);
384#elif _LIBCPP_STD_VER <= 14
385 return _VSTD::wcslen(__s);
386#else
387 size_t __len = 0;
388 for (; !eq(*__s, char_type(0)); ++__s)
389 ++__len;
390 return __len;
391#endif
392}
393
394inline _LIBCPP_CONSTEXPR_AFTER_CXX14
395const wchar_t*
396char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
397{
398 if (__n == 0)
399 return nullptr;
400#if __has_feature(cxx_constexpr_string_builtins)
401 return __builtin_wmemchr(__s, __a, __n);
402#elif _LIBCPP_STD_VER <= 14
403 return _VSTD::wmemchr(__s, __a, __n);
404#else
405 for (; __n; --__n)
406 {
407 if (eq(*__s, __a))
408 return __s;
409 ++__s;
410 }
411 return nullptr;
412#endif
413}
414330#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
415331
416332#ifndef _LIBCPP_HAS_NO_CHAR8_T
......@@ -418,11 +334,14 @@ char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __
418334template <>
419335struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
420336{
421 typedef char8_t char_type;
422 typedef unsigned int int_type;
423 typedef streamoff off_type;
424 typedef u8streampos pos_type;
425 typedef mbstate_t state_type;
337 using char_type = char8_t;
338 using int_type = unsigned int;
339 using off_type = streamoff;
340 using pos_type = u8streampos;
341 using state_type = mbstate_t;
342#if _LIBCPP_STD_VER > 17
343 using comparison_category = strong_ordering;
344#endif
426345
427346 static inline constexpr void assign(char_type& __c1, const char_type& __c2) noexcept
428347 {__c1 = __c2;}
......@@ -431,8 +350,10 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
431350 static inline constexpr bool lt(char_type __c1, char_type __c2) noexcept
432351 {return __c1 < __c2;}
433352
434 static constexpr
435 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
353 static _LIBCPP_HIDE_FROM_ABI constexpr int
354 compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
355 return std::__constexpr_memcmp(__s1, __s2, __n);
356 }
436357
437358 static constexpr
438359 size_t length(const char_type* __s) _NOEXCEPT;
......@@ -440,12 +361,12 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
440361 _LIBCPP_INLINE_VISIBILITY static constexpr
441362 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
442363
443 static _LIBCPP_CONSTEXPR_AFTER_CXX17
364 static _LIBCPP_CONSTEXPR_SINCE_CXX20
444365 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
445366 return std::__char_traits_move(__s1, __s2, __n);
446367 }
447368
448 static _LIBCPP_CONSTEXPR_AFTER_CXX17
369 static _LIBCPP_CONSTEXPR_SINCE_CXX20
449370 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
450371 if (!__libcpp_is_constant_evaluated())
451372 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
......@@ -453,7 +374,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
453374 return __s1;
454375 }
455376
456 static _LIBCPP_CONSTEXPR_AFTER_CXX17
377 static _LIBCPP_CONSTEXPR_SINCE_CXX20
457378 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
458379 std::fill_n(__s, __n, __a);
459380 return __s;
......@@ -482,24 +403,6 @@ char_traits<char8_t>::length(const char_type* __s) _NOEXCEPT
482403 return __len;
483404}
484405
485inline constexpr
486int
487char_traits<char8_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
488{
489#if __has_feature(cxx_constexpr_string_builtins)
490 return __builtin_memcmp(__s1, __s2, __n);
491#else
492 for (; __n; --__n, ++__s1, ++__s2)
493 {
494 if (lt(*__s1, *__s2))
495 return -1;
496 if (lt(*__s2, *__s1))
497 return 1;
498 }
499 return 0;
500#endif
501}
502
503406// TODO use '__builtin_char_memchr' if it ever supports char8_t ??
504407inline constexpr
505408const char8_t*
......@@ -519,32 +422,35 @@ char_traits<char8_t>::find(const char_type* __s, size_t __n, const char_type& __
519422template <>
520423struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>
521424{
522 typedef char16_t char_type;
523 typedef uint_least16_t int_type;
524 typedef streamoff off_type;
525 typedef u16streampos pos_type;
526 typedef mbstate_t state_type;
425 using char_type = char16_t;
426 using int_type = uint_least16_t;
427 using off_type = streamoff;
428 using pos_type = u16streampos;
429 using state_type = mbstate_t;
430#if _LIBCPP_STD_VER > 17
431 using comparison_category = strong_ordering;
432#endif
527433
528 static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
434 static inline _LIBCPP_CONSTEXPR_SINCE_CXX17
529435 void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
530436 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
531437 {return __c1 == __c2;}
532438 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
533439 {return __c1 < __c2;}
534440
535 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
441 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_SINCE_CXX17
536442 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
537 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
443 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_SINCE_CXX17
538444 size_t length(const char_type* __s) _NOEXCEPT;
539 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
445 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_SINCE_CXX17
540446 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
541447
542 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
448 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
543449 static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
544450 return std::__char_traits_move(__s1, __s2, __n);
545451 }
546452
547 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
453 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
548454 static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
549455 if (!__libcpp_is_constant_evaluated())
550456 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
......@@ -552,7 +458,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>
552458 return __s1;
553459 }
554460
555 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
461 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
556462 static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
557463 std::fill_n(__s, __n, __a);
558464 return __s;
......@@ -570,7 +476,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>
570476 {return int_type(0xFFFF);}
571477};
572478
573inline _LIBCPP_CONSTEXPR_AFTER_CXX14
479inline _LIBCPP_CONSTEXPR_SINCE_CXX17
574480int
575481char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
576482{
......@@ -584,7 +490,7 @@ char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, siz
584490 return 0;
585491}
586492
587inline _LIBCPP_CONSTEXPR_AFTER_CXX14
493inline _LIBCPP_CONSTEXPR_SINCE_CXX17
588494size_t
589495char_traits<char16_t>::length(const char_type* __s) _NOEXCEPT
590496{
......@@ -594,7 +500,7 @@ char_traits<char16_t>::length(const char_type* __s) _NOEXCEPT
594500 return __len;
595501}
596502
597inline _LIBCPP_CONSTEXPR_AFTER_CXX14
503inline _LIBCPP_CONSTEXPR_SINCE_CXX17
598504const char16_t*
599505char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
600506{
......@@ -610,38 +516,41 @@ char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& _
610516template <>
611517struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t>
612518{
613 typedef char32_t char_type;
614 typedef uint_least32_t int_type;
615 typedef streamoff off_type;
616 typedef u32streampos pos_type;
617 typedef mbstate_t state_type;
519 using char_type = char32_t;
520 using int_type = uint_least32_t;
521 using off_type = streamoff;
522 using pos_type = u32streampos;
523 using state_type = mbstate_t;
524#if _LIBCPP_STD_VER > 17
525 using comparison_category = strong_ordering;
526#endif
618527
619 static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
528 static inline _LIBCPP_CONSTEXPR_SINCE_CXX17
620529 void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
621530 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
622531 {return __c1 == __c2;}
623532 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
624533 {return __c1 < __c2;}
625534
626 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
535 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_SINCE_CXX17
627536 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
628 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
537 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_SINCE_CXX17
629538 size_t length(const char_type* __s) _NOEXCEPT;
630 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
539 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_SINCE_CXX17
631540 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
632541
633 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
542 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
634543 static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
635544 return std::__char_traits_move(__s1, __s2, __n);
636545 }
637546
638 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
547 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
639548 static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
640549 std::copy_n(__s2, __n, __s1);
641550 return __s1;
642551 }
643552
644 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
553 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
645554 static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
646555 std::fill_n(__s, __n, __a);
647556 return __s;
......@@ -659,7 +568,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t>
659568 {return int_type(0xFFFFFFFF);}
660569};
661570
662inline _LIBCPP_CONSTEXPR_AFTER_CXX14
571inline _LIBCPP_CONSTEXPR_SINCE_CXX17
663572int
664573char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
665574{
......@@ -673,7 +582,7 @@ char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, siz
673582 return 0;
674583}
675584
676inline _LIBCPP_CONSTEXPR_AFTER_CXX14
585inline _LIBCPP_CONSTEXPR_SINCE_CXX17
677586size_t
678587char_traits<char32_t>::length(const char_type* __s) _NOEXCEPT
679588{
......@@ -683,7 +592,7 @@ char_traits<char32_t>::length(const char_type* __s) _NOEXCEPT
683592 return __len;
684593}
685594
686inline _LIBCPP_CONSTEXPR_AFTER_CXX14
595inline _LIBCPP_CONSTEXPR_SINCE_CXX17
687596const char32_t*
688597char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
689598{
......@@ -700,7 +609,7 @@ char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& _
700609
701610// __str_find
702611template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
703inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
612inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
704613__str_find(const _CharT *__p, _SizeT __sz,
705614 _CharT __c, _SizeT __pos) _NOEXCEPT
706615{
......@@ -713,7 +622,7 @@ __str_find(const _CharT *__p, _SizeT __sz,
713622}
714623
715624template <class _CharT, class _Traits>
716inline _LIBCPP_CONSTEXPR_AFTER_CXX11 const _CharT *
625_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_SINCE_CXX14 const _CharT *
717626__search_substring(const _CharT *__first1, const _CharT *__last1,
718627 const _CharT *__first2, const _CharT *__last2) _NOEXCEPT {
719628 // Take advantage of knowing source and pattern lengths.
......@@ -752,7 +661,7 @@ __search_substring(const _CharT *__first1, const _CharT *__last1,
752661}
753662
754663template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
755inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
664inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
756665__str_find(const _CharT *__p, _SizeT __sz,
757666 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
758667{
......@@ -762,7 +671,7 @@ __str_find(const _CharT *__p, _SizeT __sz,
762671 if (__n == 0) // There is nothing to search, just return __pos.
763672 return __pos;
764673
765 const _CharT *__r = __search_substring<_CharT, _Traits>(
674 const _CharT *__r = std::__search_substring<_CharT, _Traits>(
766675 __p + __pos, __p + __sz, __s, __s + __n);
767676
768677 if (__r == __p + __sz)
......@@ -774,7 +683,7 @@ __str_find(const _CharT *__p, _SizeT __sz,
774683// __str_rfind
775684
776685template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
777inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
686inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
778687__str_rfind(const _CharT *__p, _SizeT __sz,
779688 _CharT __c, _SizeT __pos) _NOEXCEPT
780689{
......@@ -793,7 +702,7 @@ __str_rfind(const _CharT *__p, _SizeT __sz,
793702}
794703
795704template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
796inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
705inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
797706__str_rfind(const _CharT *__p, _SizeT __sz,
798707 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
799708{
......@@ -810,7 +719,7 @@ __str_rfind(const _CharT *__p, _SizeT __sz,
810719
811720// __str_find_first_of
812721template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
813inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
722inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
814723__str_find_first_of(const _CharT *__p, _SizeT __sz,
815724 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
816725{
......@@ -826,7 +735,7 @@ __str_find_first_of(const _CharT *__p, _SizeT __sz,
826735
827736// __str_find_last_of
828737template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
829inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
738inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
830739__str_find_last_of(const _CharT *__p, _SizeT __sz,
831740 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
832741 {
......@@ -849,7 +758,7 @@ __str_find_last_of(const _CharT *__p, _SizeT __sz,
849758
850759// __str_find_first_not_of
851760template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
852inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
761inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
853762__str_find_first_not_of(const _CharT *__p, _SizeT __sz,
854763 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
855764{
......@@ -865,7 +774,7 @@ __str_find_first_not_of(const _CharT *__p, _SizeT __sz,
865774
866775
867776template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
868inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
777inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
869778__str_find_first_not_of(const _CharT *__p, _SizeT __sz,
870779 _CharT __c, _SizeT __pos) _NOEXCEPT
871780{
......@@ -882,7 +791,7 @@ __str_find_first_not_of(const _CharT *__p, _SizeT __sz,
882791
883792// __str_find_last_not_of
884793template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
885inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
794inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
886795__str_find_last_not_of(const _CharT *__p, _SizeT __sz,
887796 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
888797{
......@@ -898,7 +807,7 @@ __str_find_last_not_of(const _CharT *__p, _SizeT __sz,
898807
899808
900809template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
901inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
810inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
902811__str_find_last_not_of(const _CharT *__p, _SizeT __sz,
903812 _CharT __c, _SizeT __pos) _NOEXCEPT
904813{
lib/libcxx/include/__support/android/locale_bionic.h+3-3
......@@ -7,8 +7,8 @@
77//
88//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H
11#define _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H
10#ifndef _LIBCPP___SUPPORT_ANDROID_LOCALE_BIONIC_H
11#define _LIBCPP___SUPPORT_ANDROID_LOCALE_BIONIC_H
1212
1313#if defined(__BIONIC__)
1414
......@@ -72,4 +72,4 @@ strtol_l(const char* __nptr, char** __endptr, int __base, locale_t) {
7272#endif // defined(__ANDROID__)
7373
7474#endif // defined(__BIONIC__)
75#endif // _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H
75#endif // _LIBCPP___SUPPORT_ANDROID_LOCALE_BIONIC_H
lib/libcxx/include/__support/fuchsia/xlocale.h+3-3
......@@ -7,8 +7,8 @@
77//
88//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_SUPPORT_FUCHSIA_XLOCALE_H
11#define _LIBCPP_SUPPORT_FUCHSIA_XLOCALE_H
10#ifndef _LIBCPP___SUPPORT_FUCHSIA_XLOCALE_H
11#define _LIBCPP___SUPPORT_FUCHSIA_XLOCALE_H
1212
1313#if defined(__Fuchsia__)
1414
......@@ -19,4 +19,4 @@
1919
2020#endif // defined(__Fuchsia__)
2121
22#endif // _LIBCPP_SUPPORT_FUCHSIA_XLOCALE_H
22#endif // _LIBCPP___SUPPORT_FUCHSIA_XLOCALE_H
lib/libcxx/include/__support/ibm/gettod_zos.h+3-3
......@@ -7,8 +7,8 @@
77//
88//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_SUPPORT_IBM_GETTOD_ZOS_H
11#define _LIBCPP_SUPPORT_IBM_GETTOD_ZOS_H
10#ifndef _LIBCPP___SUPPORT_IBM_GETTOD_ZOS_H
11#define _LIBCPP___SUPPORT_IBM_GETTOD_ZOS_H
1212
1313#include <time.h>
1414
......@@ -51,4 +51,4 @@ gettimeofdayMonotonic(struct timespec64* Output) {
5151 return 0;
5252}
5353
54#endif // _LIBCPP_SUPPORT_IBM_GETTOD_ZOS_H
54#endif // _LIBCPP___SUPPORT_IBM_GETTOD_ZOS_H
lib/libcxx/include/__support/ibm/locale_mgmt_zos.h+3-3
......@@ -7,8 +7,8 @@
77//
88//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_ZOS_H
11#define _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_ZOS_H
10#ifndef _LIBCPP___SUPPORT_IBM_LOCALE_MGMT_ZOS_H
11#define _LIBCPP___SUPPORT_IBM_LOCALE_MGMT_ZOS_H
1212
1313#if defined(__MVS__)
1414#include <locale.h>
......@@ -50,4 +50,4 @@ locale_t uselocale(locale_t newloc);
5050}
5151#endif
5252#endif // defined(__MVS__)
53#endif // _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_ZOS_H
53#endif // _LIBCPP___SUPPORT_IBM_LOCALE_MGMT_ZOS_H
lib/libcxx/include/__support/ibm/nanosleep.h+3-3
......@@ -7,8 +7,8 @@
77//
88//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_SUPPORT_IBM_NANOSLEEP_H
11#define _LIBCPP_SUPPORT_IBM_NANOSLEEP_H
10#ifndef _LIBCPP___SUPPORT_IBM_NANOSLEEP_H
11#define _LIBCPP___SUPPORT_IBM_NANOSLEEP_H
1212
1313#include <unistd.h>
1414
......@@ -52,4 +52,4 @@ inline int nanosleep(const struct timespec* __req, struct timespec* __rem) {
5252 return 0;
5353}
5454
55#endif // _LIBCPP_SUPPORT_IBM_NANOSLEEP_H
55#endif // _LIBCPP___SUPPORT_IBM_NANOSLEEP_H
lib/libcxx/include/__support/ibm/xlocale.h+3-3
......@@ -7,8 +7,8 @@
77//
88//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_SUPPORT_IBM_XLOCALE_H
11#define _LIBCPP_SUPPORT_IBM_XLOCALE_H
10#ifndef _LIBCPP___SUPPORT_IBM_XLOCALE_H
11#define _LIBCPP___SUPPORT_IBM_XLOCALE_H
1212
1313#if defined(__MVS__)
1414#include <__support/ibm/locale_mgmt_zos.h>
......@@ -126,4 +126,4 @@ vasprintf(char **strp, const char *fmt, va_list ap) {
126126#ifdef __cplusplus
127127}
128128#endif
129#endif // _LIBCPP_SUPPORT_IBM_XLOCALE_H
129#endif // _LIBCPP___SUPPORT_IBM_XLOCALE_H
lib/libcxx/include/__support/musl/xlocale.h+4-4
......@@ -14,8 +14,8 @@
1414// in Musl.
1515//===----------------------------------------------------------------------===//
1616
17#ifndef _LIBCPP_SUPPORT_MUSL_XLOCALE_H
18#define _LIBCPP_SUPPORT_MUSL_XLOCALE_H
17#ifndef _LIBCPP___SUPPORT_MUSL_XLOCALE_H
18#define _LIBCPP___SUPPORT_MUSL_XLOCALE_H
1919
2020#include <cstdlib>
2121#include <cwchar>
......@@ -39,7 +39,7 @@ wcstoll_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {
3939 return ::wcstoll(__nptr, __endptr, __base);
4040}
4141
42inline _LIBCPP_HIDE_FROM_ABI long long
42inline _LIBCPP_HIDE_FROM_ABI unsigned long long
4343wcstoull_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {
4444 return ::wcstoull(__nptr, __endptr, __base);
4545}
......@@ -53,4 +53,4 @@ wcstold_l(const wchar_t *__nptr, wchar_t **__endptr, locale_t) {
5353}
5454#endif
5555
56#endif // _LIBCPP_SUPPORT_MUSL_XLOCALE_H
56#endif // _LIBCPP___SUPPORT_MUSL_XLOCALE_H
lib/libcxx/include/__support/newlib/xlocale.h+2-6
......@@ -6,15 +6,11 @@
66//
77//===----------------------------------------------------------------------===//
88
9#ifndef _LIBCPP_SUPPORT_NEWLIB_XLOCALE_H
10#define _LIBCPP_SUPPORT_NEWLIB_XLOCALE_H
9#ifndef _LIBCPP___SUPPORT_NEWLIB_XLOCALE_H
10#define _LIBCPP___SUPPORT_NEWLIB_XLOCALE_H
1111
1212#if defined(_NEWLIB_VERSION)
1313
14#include <cstdlib>
15#include <clocale>
16#include <cwctype>
17#include <ctype.h>
1814#if !defined(__NEWLIB__) || __NEWLIB__ < 2 || \
1915 __NEWLIB__ == 2 && __NEWLIB_MINOR__ < 5
2016#include <__support/xlocale/__nop_locale_mgmt.h>
lib/libcxx/include/__support/openbsd/xlocale.h+2-2
......@@ -7,8 +7,8 @@
77//
88//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_SUPPORT_OPENBSD_XLOCALE_H
11#define _LIBCPP_SUPPORT_OPENBSD_XLOCALE_H
10#ifndef _LIBCPP___SUPPORT_OPENBSD_XLOCALE_H
11#define _LIBCPP___SUPPORT_OPENBSD_XLOCALE_H
1212
1313#include <__support/xlocale/__strtonum_fallback.h>
1414#include <clocale>
lib/libcxx/include/__support/solaris/xlocale.h+1-1
......@@ -43,7 +43,7 @@ strtol_l(const char *__nptr, char **__endptr, int __base, locale_t __loc) {
4343}
4444
4545inline _LIBCPP_HIDE_FROM_ABI unsigned long long
46strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t __loc)
46strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t __loc)
4747 return ::strtoull(__nptr, __endptr, __base);
4848}
4949
lib/libcxx/include/__support/win32/limits_msvc_win32.h deleted-71
......@@ -1,71 +0,0 @@
1// -*- C++ -*-
2//===-----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_SUPPORT_WIN32_LIMITS_MSVC_WIN32_H
11#define _LIBCPP_SUPPORT_WIN32_LIMITS_MSVC_WIN32_H
12
13#if !defined(_LIBCPP_MSVCRT)
14#error "This header complements the Microsoft C Runtime library, and should not be included otherwise."
15#endif
16#if defined(__clang__)
17#error "This header should only be included when using Microsoft's C1XX frontend"
18#endif
19
20#include <float.h> // limit constants
21#include <limits.h> // CHAR_BIT
22#include <math.h> // HUGE_VAL
23#include <ymath.h> // internal MSVC header providing the needed functionality
24
25#define __CHAR_BIT__ CHAR_BIT
26
27#define __FLT_MANT_DIG__ FLT_MANT_DIG
28#define __FLT_DIG__ FLT_DIG
29#define __FLT_RADIX__ FLT_RADIX
30#define __FLT_MIN_EXP__ FLT_MIN_EXP
31#define __FLT_MIN_10_EXP__ FLT_MIN_10_EXP
32#define __FLT_MAX_EXP__ FLT_MAX_EXP
33#define __FLT_MAX_10_EXP__ FLT_MAX_10_EXP
34#define __FLT_MIN__ FLT_MIN
35#define __FLT_MAX__ FLT_MAX
36#define __FLT_EPSILON__ FLT_EPSILON
37// predefined by MinGW GCC
38#define __FLT_DENORM_MIN__ 1.40129846432481707092e-45F
39
40#define __DBL_MANT_DIG__ DBL_MANT_DIG
41#define __DBL_DIG__ DBL_DIG
42#define __DBL_RADIX__ DBL_RADIX
43#define __DBL_MIN_EXP__ DBL_MIN_EXP
44#define __DBL_MIN_10_EXP__ DBL_MIN_10_EXP
45#define __DBL_MAX_EXP__ DBL_MAX_EXP
46#define __DBL_MAX_10_EXP__ DBL_MAX_10_EXP
47#define __DBL_MIN__ DBL_MIN
48#define __DBL_MAX__ DBL_MAX
49#define __DBL_EPSILON__ DBL_EPSILON
50// predefined by MinGW GCC
51#define __DBL_DENORM_MIN__ double(4.94065645841246544177e-324L)
52
53#define __LDBL_MANT_DIG__ LDBL_MANT_DIG
54#define __LDBL_DIG__ LDBL_DIG
55#define __LDBL_RADIX__ LDBL_RADIX
56#define __LDBL_MIN_EXP__ LDBL_MIN_EXP
57#define __LDBL_MIN_10_EXP__ LDBL_MIN_10_EXP
58#define __LDBL_MAX_EXP__ LDBL_MAX_EXP
59#define __LDBL_MAX_10_EXP__ LDBL_MAX_10_EXP
60#define __LDBL_MIN__ LDBL_MIN
61#define __LDBL_MAX__ LDBL_MAX
62#define __LDBL_EPSILON__ LDBL_EPSILON
63// predefined by MinGW GCC
64#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
65
66// __builtin replacements/workarounds
67#define __builtin_huge_vall() _LInf._Long_double
68#define __builtin_nanl(__dummmy) _LNan._Long_double
69#define __builtin_nansl(__dummy) _LSnan._Long_double
70
71#endif // _LIBCPP_SUPPORT_WIN32_LIMITS_MSVC_WIN32_H
lib/libcxx/include/__support/win32/locale_win32.h+62-61
......@@ -7,13 +7,14 @@
77//
88//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
11#define _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
10#ifndef _LIBCPP___SUPPORT_WIN32_LOCALE_WIN32_H
11#define _LIBCPP___SUPPORT_WIN32_LOCALE_WIN32_H
1212
1313#include <__config>
1414#include <cstddef>
1515#include <locale.h> // _locale_t
1616#include <stdio.h>
17#include <string>
1718
1819#define _X_ALL LC_ALL
1920#define _X_COLLATE LC_COLLATE
......@@ -50,92 +51,92 @@
5051class __lconv_storage {
5152public:
5253 __lconv_storage(const lconv *__lc_input) {
53 __lc = *__lc_input;
54
55 __decimal_point = __lc_input->decimal_point;
56 __thousands_sep = __lc_input->thousands_sep;
57 __grouping = __lc_input->grouping;
58 __int_curr_symbol = __lc_input->int_curr_symbol;
59 __currency_symbol = __lc_input->currency_symbol;
60 __mon_decimal_point = __lc_input->mon_decimal_point;
61 __mon_thousands_sep = __lc_input->mon_thousands_sep;
62 __mon_grouping = __lc_input->mon_grouping;
63 __positive_sign = __lc_input->positive_sign;
64 __negative_sign = __lc_input->negative_sign;
65
66 __lc.decimal_point = const_cast<char *>(__decimal_point.c_str());
67 __lc.thousands_sep = const_cast<char *>(__thousands_sep.c_str());
68 __lc.grouping = const_cast<char *>(__grouping.c_str());
69 __lc.int_curr_symbol = const_cast<char *>(__int_curr_symbol.c_str());
70 __lc.currency_symbol = const_cast<char *>(__currency_symbol.c_str());
71 __lc.mon_decimal_point = const_cast<char *>(__mon_decimal_point.c_str());
72 __lc.mon_thousands_sep = const_cast<char *>(__mon_thousands_sep.c_str());
73 __lc.mon_grouping = const_cast<char *>(__mon_grouping.c_str());
74 __lc.positive_sign = const_cast<char *>(__positive_sign.c_str());
75 __lc.negative_sign = const_cast<char *>(__negative_sign.c_str());
54 __lc_ = *__lc_input;
55
56 __decimal_point_ = __lc_input->decimal_point;
57 __thousands_sep_ = __lc_input->thousands_sep;
58 __grouping_ = __lc_input->grouping;
59 __int_curr_symbol_ = __lc_input->int_curr_symbol;
60 __currency_symbol_ = __lc_input->currency_symbol;
61 __mon_decimal_point_ = __lc_input->mon_decimal_point;
62 __mon_thousands_sep_ = __lc_input->mon_thousands_sep;
63 __mon_grouping_ = __lc_input->mon_grouping;
64 __positive_sign_ = __lc_input->positive_sign;
65 __negative_sign_ = __lc_input->negative_sign;
66
67 __lc_.decimal_point = const_cast<char *>(__decimal_point_.c_str());
68 __lc_.thousands_sep = const_cast<char *>(__thousands_sep_.c_str());
69 __lc_.grouping = const_cast<char *>(__grouping_.c_str());
70 __lc_.int_curr_symbol = const_cast<char *>(__int_curr_symbol_.c_str());
71 __lc_.currency_symbol = const_cast<char *>(__currency_symbol_.c_str());
72 __lc_.mon_decimal_point = const_cast<char *>(__mon_decimal_point_.c_str());
73 __lc_.mon_thousands_sep = const_cast<char *>(__mon_thousands_sep_.c_str());
74 __lc_.mon_grouping = const_cast<char *>(__mon_grouping_.c_str());
75 __lc_.positive_sign = const_cast<char *>(__positive_sign_.c_str());
76 __lc_.negative_sign = const_cast<char *>(__negative_sign_.c_str());
7677 }
7778
7879 lconv *__get() {
79 return &__lc;
80 return &__lc_;
8081 }
8182private:
82 lconv __lc;
83 std::string __decimal_point;
84 std::string __thousands_sep;
85 std::string __grouping;
86 std::string __int_curr_symbol;
87 std::string __currency_symbol;
88 std::string __mon_decimal_point;
89 std::string __mon_thousands_sep;
90 std::string __mon_grouping;
91 std::string __positive_sign;
92 std::string __negative_sign;
83 lconv __lc_;
84 std::string __decimal_point_;
85 std::string __thousands_sep_;
86 std::string __grouping_;
87 std::string __int_curr_symbol_;
88 std::string __currency_symbol_;
89 std::string __mon_decimal_point_;
90 std::string __mon_thousands_sep_;
91 std::string __mon_grouping_;
92 std::string __positive_sign_;
93 std::string __negative_sign_;
9394};
9495
9596class locale_t {
9697public:
9798 locale_t()
98 : __locale(nullptr), __locale_str(nullptr), __lc(nullptr) {}
99 : __locale_(nullptr), __locale_str_(nullptr), __lc_(nullptr) {}
99100 locale_t(std::nullptr_t)
100 : __locale(nullptr), __locale_str(nullptr), __lc(nullptr) {}
101 : __locale_(nullptr), __locale_str_(nullptr), __lc_(nullptr) {}
101102 locale_t(_locale_t __xlocale, const char* __xlocale_str)
102 : __locale(__xlocale), __locale_str(__xlocale_str), __lc(nullptr) {}
103 : __locale_(__xlocale), __locale_str_(__xlocale_str), __lc_(nullptr) {}
103104 locale_t(const locale_t &__l)
104 : __locale(__l.__locale), __locale_str(__l.__locale_str), __lc(nullptr) {}
105 : __locale_(__l.__locale_), __locale_str_(__l.__locale_str_), __lc_(nullptr) {}
105106
106107 ~locale_t() {
107 delete __lc;
108 delete __lc_;
108109 }
109110
110111 locale_t &operator =(const locale_t &__l) {
111 __locale = __l.__locale;
112 __locale_str = __l.__locale_str;
113 // __lc not copied
112 __locale_ = __l.__locale_;
113 __locale_str_ = __l.__locale_str_;
114 // __lc_ not copied
114115 return *this;
115116 }
116117
117118 friend bool operator==(const locale_t& __left, const locale_t& __right) {
118 return __left.__locale == __right.__locale;
119 return __left.__locale_ == __right.__locale_;
119120 }
120121
121122 friend bool operator==(const locale_t& __left, int __right) {
122 return __left.__locale == nullptr && __right == 0;
123 return __left.__locale_ == nullptr && __right == 0;
123124 }
124125
125126 friend bool operator==(const locale_t& __left, long long __right) {
126 return __left.__locale == nullptr && __right == 0;
127 return __left.__locale_ == nullptr && __right == 0;
127128 }
128129
129130 friend bool operator==(const locale_t& __left, std::nullptr_t) {
130 return __left.__locale == nullptr;
131 return __left.__locale_ == nullptr;
131132 }
132133
133134 friend bool operator==(int __left, const locale_t& __right) {
134 return __left == 0 && nullptr == __right.__locale;
135 return __left == 0 && nullptr == __right.__locale_;
135136 }
136137
137138 friend bool operator==(std::nullptr_t, const locale_t& __right) {
138 return nullptr == __right.__locale;
139 return nullptr == __right.__locale_;
139140 }
140141
141142 friend bool operator!=(const locale_t& __left, const locale_t& __right) {
......@@ -163,24 +164,24 @@ public:
163164 }
164165
165166 operator bool() const {
166 return __locale != nullptr;
167 return __locale_ != nullptr;
167168 }
168169
169 const char* __get_locale() const { return __locale_str; }
170 const char* __get_locale() const { return __locale_str_; }
170171
171172 operator _locale_t() const {
172 return __locale;
173 return __locale_;
173174 }
174175
175176 lconv *__store_lconv(const lconv *__input_lc) {
176 delete __lc;
177 __lc = new __lconv_storage(__input_lc);
178 return __lc->__get();
177 delete __lc_;
178 __lc_ = new __lconv_storage(__input_lc);
179 return __lc_->__get();
179180 }
180181private:
181 _locale_t __locale;
182 const char* __locale_str;
183 __lconv_storage *__lc = nullptr;
182 _locale_t __locale_;
183 const char* __locale_str_;
184 __lconv_storage *__lc_ = nullptr;
184185};
185186
186187// Locale management functions
......@@ -278,4 +279,4 @@ inline int iswblank_l( wint_t __c, locale_t /*loc*/ )
278279 return ( __c == L' ' || __c == L'\t' );
279280}
280281
281#endif // _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
282#endif // _LIBCPP___SUPPORT_WIN32_LOCALE_WIN32_H
lib/libcxx/include/__support/xlocale/__nop_locale_mgmt.h+5-3
......@@ -7,8 +7,10 @@
77//
88//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
11#define _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
10#ifndef _LIBCPP___SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
11#define _LIBCPP___SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
12
13#include <__config>
1214
1315#ifdef __cplusplus
1416extern "C" {
......@@ -53,4 +55,4 @@ uselocale(locale_t) {
5355} // extern "C"
5456#endif
5557
56#endif // _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
58#endif // _LIBCPP___SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
lib/libcxx/include/__support/xlocale/__posix_l_fallback.h+23-11
......@@ -12,8 +12,16 @@
1212// Android's bionic and Newlib).
1313//===----------------------------------------------------------------------===//
1414
15#ifndef _LIBCPP_SUPPORT_XLOCALE_POSIX_L_FALLBACK_H
16#define _LIBCPP_SUPPORT_XLOCALE_POSIX_L_FALLBACK_H
15#ifndef _LIBCPP___SUPPORT_XLOCALE_POSIX_L_FALLBACK_H
16#define _LIBCPP___SUPPORT_XLOCALE_POSIX_L_FALLBACK_H
17
18#include <__config>
19#include <ctype.h>
20#include <time.h>
21
22#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
23# include <wctype.h>
24#endif
1725
1826#ifdef __cplusplus
1927extern "C" {
......@@ -67,6 +75,15 @@ inline _LIBCPP_HIDE_FROM_ABI int isxdigit_l(int __c, locale_t) {
6775 return ::isxdigit(__c);
6876}
6977
78inline _LIBCPP_HIDE_FROM_ABI int toupper_l(int __c, locale_t) {
79 return ::toupper(__c);
80}
81
82inline _LIBCPP_HIDE_FROM_ABI int tolower_l(int __c, locale_t) {
83 return ::tolower(__c);
84}
85
86#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
7087inline _LIBCPP_HIDE_FROM_ABI int iswalnum_l(wint_t __c, locale_t) {
7188 return ::iswalnum(__c);
7289}
......@@ -115,14 +132,6 @@ inline _LIBCPP_HIDE_FROM_ABI int iswxdigit_l(wint_t __c, locale_t) {
115132 return ::iswxdigit(__c);
116133}
117134
118inline _LIBCPP_HIDE_FROM_ABI int toupper_l(int __c, locale_t) {
119 return ::toupper(__c);
120}
121
122inline _LIBCPP_HIDE_FROM_ABI int tolower_l(int __c, locale_t) {
123 return ::tolower(__c);
124}
125
126135inline _LIBCPP_HIDE_FROM_ABI wint_t towupper_l(wint_t __c, locale_t) {
127136 return ::towupper(__c);
128137}
......@@ -130,6 +139,7 @@ inline _LIBCPP_HIDE_FROM_ABI wint_t towupper_l(wint_t __c, locale_t) {
130139inline _LIBCPP_HIDE_FROM_ABI wint_t towlower_l(wint_t __c, locale_t) {
131140 return ::towlower(__c);
132141}
142#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
133143
134144inline _LIBCPP_HIDE_FROM_ABI int
135145strcoll_l(const char *__s1, const char *__s2, locale_t) {
......@@ -147,6 +157,7 @@ strftime_l(char *__s, size_t __max, const char *__format, const struct tm *__tm,
147157 return ::strftime(__s, __max, __format, __tm);
148158}
149159
160#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
150161inline _LIBCPP_HIDE_FROM_ABI int
151162wcscoll_l(const wchar_t *__ws1, const wchar_t *__ws2, locale_t) {
152163 return ::wcscoll(__ws1, __ws2);
......@@ -156,9 +167,10 @@ inline _LIBCPP_HIDE_FROM_ABI size_t
156167wcsxfrm_l(wchar_t *__dest, const wchar_t *__src, size_t __n, locale_t) {
157168 return ::wcsxfrm(__dest, __src, __n);
158169}
170#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
159171
160172#ifdef __cplusplus
161173}
162174#endif
163175
164#endif // _LIBCPP_SUPPORT_XLOCALE_POSIX_L_FALLBACK_H
176#endif // _LIBCPP___SUPPORT_XLOCALE_POSIX_L_FALLBACK_H
lib/libcxx/include/__support/xlocale/__strtonum_fallback.h+12-3
......@@ -12,8 +12,15 @@
1212// convert strings to some numeric type.
1313//===----------------------------------------------------------------------===//
1414
15#ifndef _LIBCPP_SUPPORT_XLOCALE_STRTONUM_FALLBACK_H
16#define _LIBCPP_SUPPORT_XLOCALE_STRTONUM_FALLBACK_H
15#ifndef _LIBCPP___SUPPORT_XLOCALE_STRTONUM_FALLBACK_H
16#define _LIBCPP___SUPPORT_XLOCALE_STRTONUM_FALLBACK_H
17
18#include <__config>
19#include <stdlib.h>
20
21#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
22# include <wchar.h>
23#endif
1724
1825#ifdef __cplusplus
1926extern "C" {
......@@ -44,6 +51,7 @@ strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t) {
4451 return ::strtoull(__nptr, __endptr, __base);
4552}
4653
54#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
4755inline _LIBCPP_HIDE_FROM_ABI long long
4856wcstoll_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {
4957 return ::wcstoll(__nptr, __endptr, __base);
......@@ -58,9 +66,10 @@ inline _LIBCPP_HIDE_FROM_ABI long double
5866wcstold_l(const wchar_t *__nptr, wchar_t **__endptr, locale_t) {
5967 return ::wcstold(__nptr, __endptr);
6068}
69#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
6170
6271#ifdef __cplusplus
6372}
6473#endif
6574
66#endif // _LIBCPP_SUPPORT_XLOCALE_STRTONUM_FALLBACK_H
75#endif // _LIBCPP___SUPPORT_XLOCALE_STRTONUM_FALLBACK_H
lib/libcxx/include/__thread/poll_with_backoff.h+1-3
......@@ -6,16 +6,14 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___THREAD_POLL_WITH_BACKOFF_H
1011#define _LIBCPP___THREAD_POLL_WITH_BACKOFF_H
1112
1213#include <__availability>
1314#include <__chrono/duration.h>
1415#include <__chrono/high_resolution_clock.h>
15#include <__chrono/steady_clock.h>
16#include <__chrono/time_point.h>
1716#include <__config>
18#include <__filesystem/file_time_type.h>
1917
2018#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2119# pragma GCC system_header
lib/libcxx/include/__thread/timed_backoff_policy.h+1
......@@ -6,6 +6,7 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP___THREAD_TIMED_BACKOFF_POLICY_H
1011#define _LIBCPP___THREAD_TIMED_BACKOFF_POLICY_H
1112
lib/libcxx/include/__threading_support+54-25
......@@ -13,7 +13,9 @@
1313#include <__availability>
1414#include <__chrono/convert_to_timespec.h>
1515#include <__chrono/duration.h>
16#include <__compare/ordering.h>
1617#include <__config>
18#include <__fwd/hash.h>
1719#include <__thread/poll_with_backoff.h>
1820#include <errno.h>
1921#include <iosfwd>
......@@ -609,40 +611,28 @@ class _LIBCPP_TEMPLATE_VIS __thread_id
609611 // on other platforms. We assume 0 works everywhere for now.
610612 __libcpp_thread_id __id_;
611613
612public:
613 _LIBCPP_INLINE_VISIBILITY
614 __thread_id() _NOEXCEPT : __id_(0) {}
615
616 friend _LIBCPP_INLINE_VISIBILITY
617 bool operator==(__thread_id __x, __thread_id __y) _NOEXCEPT
618 { // don't pass id==0 to underlying routines
619 if (__x.__id_ == 0) return __y.__id_ == 0;
620 if (__y.__id_ == 0) return false;
621 return __libcpp_thread_id_equal(__x.__id_, __y.__id_);
622 }
623 friend _LIBCPP_INLINE_VISIBILITY
624 bool operator!=(__thread_id __x, __thread_id __y) _NOEXCEPT
625 {return !(__x == __y);}
626 friend _LIBCPP_INLINE_VISIBILITY
627 bool operator< (__thread_id __x, __thread_id __y) _NOEXCEPT
614 static _LIBCPP_HIDE_FROM_ABI
615 bool __lt_impl(__thread_id __x, __thread_id __y) _NOEXCEPT
628616 { // id==0 is always less than any other thread_id
629617 if (__x.__id_ == 0) return __y.__id_ != 0;
630618 if (__y.__id_ == 0) return false;
631619 return __libcpp_thread_id_less(__x.__id_, __y.__id_);
632620 }
633 friend _LIBCPP_INLINE_VISIBILITY
634 bool operator<=(__thread_id __x, __thread_id __y) _NOEXCEPT
635 {return !(__y < __x);}
636 friend _LIBCPP_INLINE_VISIBILITY
637 bool operator> (__thread_id __x, __thread_id __y) _NOEXCEPT
638 {return __y < __x ;}
639 friend _LIBCPP_INLINE_VISIBILITY
640 bool operator>=(__thread_id __x, __thread_id __y) _NOEXCEPT
641 {return !(__x < __y);}
621
622public:
623 _LIBCPP_INLINE_VISIBILITY
624 __thread_id() _NOEXCEPT : __id_(0) {}
642625
643626 _LIBCPP_INLINE_VISIBILITY
644627 void __reset() { __id_ = 0; }
645628
629 friend _LIBCPP_HIDE_FROM_ABI bool operator==(__thread_id __x, __thread_id __y) _NOEXCEPT;
630#if _LIBCPP_STD_VER <= 17
631 friend _LIBCPP_HIDE_FROM_ABI bool operator<(__thread_id __x, __thread_id __y) _NOEXCEPT;
632#else // _LIBCPP_STD_VER <= 17
633 friend _LIBCPP_HIDE_FROM_ABI strong_ordering operator<=>(__thread_id __x, __thread_id __y) noexcept;
634#endif // _LIBCPP_STD_VER <= 17
635
646636 template<class _CharT, class _Traits>
647637 friend
648638 _LIBCPP_INLINE_VISIBILITY
......@@ -658,6 +648,45 @@ private:
658648 friend struct _LIBCPP_TEMPLATE_VIS hash<__thread_id>;
659649};
660650
651inline _LIBCPP_HIDE_FROM_ABI
652bool operator==(__thread_id __x, __thread_id __y) _NOEXCEPT {
653 // Don't pass id==0 to underlying routines
654 if (__x.__id_ == 0)
655 return __y.__id_ == 0;
656 if (__y.__id_ == 0)
657 return false;
658 return __libcpp_thread_id_equal(__x.__id_, __y.__id_);
659}
660
661#if _LIBCPP_STD_VER <= 17
662
663inline _LIBCPP_HIDE_FROM_ABI
664bool operator!=(__thread_id __x, __thread_id __y) _NOEXCEPT {
665 return !(__x == __y);
666}
667
668inline _LIBCPP_HIDE_FROM_ABI
669bool operator<(__thread_id __x, __thread_id __y) _NOEXCEPT {
670 return __thread_id::__lt_impl(__x.__id_, __y.__id_);
671}
672
673inline _LIBCPP_HIDE_FROM_ABI bool operator<=(__thread_id __x, __thread_id __y) _NOEXCEPT { return !(__y < __x); }
674inline _LIBCPP_HIDE_FROM_ABI bool operator>(__thread_id __x, __thread_id __y) _NOEXCEPT { return __y < __x; }
675inline _LIBCPP_HIDE_FROM_ABI bool operator>=(__thread_id __x, __thread_id __y) _NOEXCEPT { return !(__x < __y); }
676
677#else // _LIBCPP_STD_VER <= 17
678
679inline _LIBCPP_HIDE_FROM_ABI
680strong_ordering operator<=>(__thread_id __x, __thread_id __y) noexcept {
681 if (__x == __y)
682 return strong_ordering::equal;
683 if (__thread_id::__lt_impl(__x, __y))
684 return strong_ordering::less;
685 return strong_ordering::greater;
686}
687
688#endif // _LIBCPP_STD_VER <= 17
689
661690namespace this_thread
662691{
663692
lib/libcxx/include/__tree+43-30
......@@ -14,14 +14,32 @@
1414#include <__assert>
1515#include <__config>
1616#include <__debug>
17#include <__functional/invoke.h>
1718#include <__iterator/distance.h>
1819#include <__iterator/iterator_traits.h>
1920#include <__iterator/next.h>
21#include <__memory/allocator_traits.h>
22#include <__memory/compressed_pair.h>
23#include <__memory/pointer_traits.h>
2024#include <__memory/swap_allocator.h>
25#include <__memory/unique_ptr.h>
26#include <__type_traits/can_extract_key.h>
27#include <__type_traits/conditional.h>
28#include <__type_traits/is_const.h>
29#include <__type_traits/is_nothrow_copy_constructible.h>
30#include <__type_traits/is_nothrow_default_constructible.h>
31#include <__type_traits/is_nothrow_move_assignable.h>
32#include <__type_traits/is_nothrow_move_constructible.h>
33#include <__type_traits/is_pointer.h>
34#include <__type_traits/is_same.h>
35#include <__type_traits/is_swappable.h>
36#include <__type_traits/remove_const_ref.h>
37#include <__type_traits/remove_cvref.h>
2138#include <__utility/forward.h>
39#include <__utility/move.h>
40#include <__utility/pair.h>
2241#include <__utility/swap.h>
2342#include <limits>
24#include <memory>
2543#include <stdexcept>
2644
2745#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -126,7 +144,7 @@ __tree_sub_invariant(_NodePtr __x)
126144// __root == nullptr is a proper tree. Returns true is __root is a proper
127145// red black tree, else returns false.
128146template <class _NodePtr>
129bool
147_LIBCPP_HIDE_FROM_ABI bool
130148__tree_invariant(_NodePtr __root)
131149{
132150 if (__root == nullptr)
......@@ -169,7 +187,7 @@ __tree_max(_NodePtr __x) _NOEXCEPT
169187
170188// Returns: pointer to the next in-order node after __x.
171189template <class _NodePtr>
172_NodePtr
190_LIBCPP_HIDE_FROM_ABI _NodePtr
173191__tree_next(_NodePtr __x) _NOEXCEPT
174192{
175193 _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
......@@ -211,7 +229,7 @@ __tree_prev_iter(_EndNodePtr __x) _NOEXCEPT
211229
212230// Returns: pointer to a node which has no children
213231template <class _NodePtr>
214_NodePtr
232_LIBCPP_HIDE_FROM_ABI _NodePtr
215233__tree_leaf(_NodePtr __x) _NOEXCEPT
216234{
217235 _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
......@@ -235,7 +253,7 @@ __tree_leaf(_NodePtr __x) _NOEXCEPT
235253// Effects: Makes __x->__right_ the subtree root with __x as its left child
236254// while preserving in-order order.
237255template <class _NodePtr>
238void
256_LIBCPP_HIDE_FROM_ABI void
239257__tree_left_rotate(_NodePtr __x) _NOEXCEPT
240258{
241259 _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
......@@ -256,7 +274,7 @@ __tree_left_rotate(_NodePtr __x) _NOEXCEPT
256274// Effects: Makes __x->__left_ the subtree root with __x as its right child
257275// while preserving in-order order.
258276template <class _NodePtr>
259void
277_LIBCPP_HIDE_FROM_ABI void
260278__tree_right_rotate(_NodePtr __x) _NOEXCEPT
261279{
262280 _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
......@@ -282,7 +300,7 @@ __tree_right_rotate(_NodePtr __x) _NOEXCEPT
282300// Postcondition: __tree_invariant(end_node->__left_) == true. end_node->__left_
283301// may be different than the value passed in as __root.
284302template <class _NodePtr>
285void
303_LIBCPP_HIDE_FROM_ABI void
286304__tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT
287305{
288306 _LIBCPP_ASSERT(__root != nullptr, "Root of the tree shouldn't be null");
......@@ -352,7 +370,7 @@ __tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT
352370// nor any of its children refer to __z. end_node->__left_
353371// may be different than the value passed in as __root.
354372template <class _NodePtr>
355void
373_LIBCPP_HIDE_FROM_ABI void
356374__tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT
357375{
358376 _LIBCPP_ASSERT(__root != nullptr, "Root node should not be null");
......@@ -554,7 +572,7 @@ template <class ..._Args>
554572struct __is_tree_value_type : false_type {};
555573
556574template <class _One>
557struct __is_tree_value_type<_One> : __is_tree_value_type_imp<__uncvref_t<_One> > {};
575struct __is_tree_value_type<_One> : __is_tree_value_type_imp<__remove_cvref_t<_One> > {};
558576
559577template <class _Tp>
560578struct __tree_key_value_types {
......@@ -632,19 +650,17 @@ struct __tree_node_base_types {
632650 typedef _VoidPtr __void_pointer;
633651
634652 typedef __tree_node_base<__void_pointer> __node_base_type;
635 typedef typename __rebind_pointer<_VoidPtr, __node_base_type>::type
653 typedef __rebind_pointer_t<_VoidPtr, __node_base_type>
636654 __node_base_pointer;
637655
638656 typedef __tree_end_node<__node_base_pointer> __end_node_type;
639 typedef typename __rebind_pointer<_VoidPtr, __end_node_type>::type
657 typedef __rebind_pointer_t<_VoidPtr, __end_node_type>
640658 __end_node_pointer;
641659#if defined(_LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB)
642660 typedef __end_node_pointer __parent_pointer;
643661#else
644 typedef typename conditional<
645 is_pointer<__end_node_pointer>::value,
646 __end_node_pointer,
647 __node_base_pointer>::type __parent_pointer;
662 typedef __conditional_t< is_pointer<__end_node_pointer>::value, __end_node_pointer, __node_base_pointer>
663 __parent_pointer;
648664#endif
649665
650666private:
......@@ -659,9 +675,9 @@ struct __tree_map_pointer_types {};
659675template <class _Tp, class _AllocPtr, class _KVTypes>
660676struct __tree_map_pointer_types<_Tp, _AllocPtr, _KVTypes, true> {
661677 typedef typename _KVTypes::__map_value_type _Mv;
662 typedef typename __rebind_pointer<_AllocPtr, _Mv>::type
678 typedef __rebind_pointer_t<_AllocPtr, _Mv>
663679 __map_value_type_pointer;
664 typedef typename __rebind_pointer<_AllocPtr, const _Mv>::type
680 typedef __rebind_pointer_t<_AllocPtr, const _Mv>
665681 __const_map_value_type_pointer;
666682};
667683
......@@ -683,28 +699,26 @@ public:
683699 typedef _NodePtr __node_pointer;
684700
685701 typedef _Tp __node_value_type;
686 typedef typename __rebind_pointer<_VoidPtr, __node_value_type>::type
702 typedef __rebind_pointer_t<_VoidPtr, __node_value_type>
687703 __node_value_type_pointer;
688 typedef typename __rebind_pointer<_VoidPtr, const __node_value_type>::type
704 typedef __rebind_pointer_t<_VoidPtr, const __node_value_type>
689705 __const_node_value_type_pointer;
690706#if defined(_LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB)
691707 typedef typename __base::__end_node_pointer __iter_pointer;
692708#else
693 typedef typename conditional<
694 is_pointer<__node_pointer>::value,
695 typename __base::__end_node_pointer,
696 __node_pointer>::type __iter_pointer;
709 typedef __conditional_t< is_pointer<__node_pointer>::value, typename __base::__end_node_pointer, __node_pointer>
710 __iter_pointer;
697711#endif
698712private:
699713 static_assert(!is_const<__node_type>::value,
700714 "_NodePtr should never be a pointer to const");
701 static_assert((is_same<typename __rebind_pointer<_VoidPtr, __node_type>::type,
715 static_assert((is_same<__rebind_pointer_t<_VoidPtr, __node_type>,
702716 _NodePtr>::value), "_VoidPtr does not rebind to _NodePtr.");
703717};
704718
705719template <class _ValueTp, class _VoidPtr>
706720struct __make_tree_node_types {
707 typedef typename __rebind_pointer<_VoidPtr, __tree_node<_ValueTp, _VoidPtr> >::type
721 typedef __rebind_pointer_t<_VoidPtr, __tree_node<_ValueTp, _VoidPtr> >
708722 _NodePtr;
709723 typedef __tree_node_types<_NodePtr> type;
710724};
......@@ -1019,7 +1033,7 @@ public:
10191033 typedef typename _NodeTypes::__parent_pointer __parent_pointer;
10201034 typedef typename _NodeTypes::__iter_pointer __iter_pointer;
10211035
1022 typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator;
1036 typedef __rebind_alloc<__alloc_traits, __node> __node_allocator;
10231037 typedef allocator_traits<__node_allocator> __node_traits;
10241038
10251039private:
......@@ -1028,8 +1042,7 @@ private:
10281042 // the pointer using 'pointer_traits'.
10291043 static_assert((is_same<__node_pointer, typename __node_traits::pointer>::value),
10301044 "Allocator does not rebind pointers in a sane manner.");
1031 typedef typename __rebind_alloc_helper<__node_traits, __node_base>::type
1032 __node_base_allocator;
1045 typedef __rebind_alloc<__node_traits, __node_base> __node_base_allocator;
10331046 typedef allocator_traits<__node_base_allocator> __node_base_traits;
10341047 static_assert((is_same<__node_base_pointer, typename __node_base_traits::pointer>::value),
10351048 "Allocator does not rebind pointers in a sane manner.");
......@@ -1271,14 +1284,14 @@ public:
12711284 }
12721285
12731286 template <class _Vp,
1274 class = __enable_if_t<!is_same<typename __unconstref<_Vp>::type, __container_value_type>::value> >
1287 class = __enable_if_t<!is_same<__remove_const_ref_t<_Vp>, __container_value_type>::value> >
12751288 _LIBCPP_INLINE_VISIBILITY
12761289 pair<iterator, bool> __insert_unique(_Vp&& __v) {
12771290 return __emplace_unique(_VSTD::forward<_Vp>(__v));
12781291 }
12791292
12801293 template <class _Vp,
1281 class = __enable_if_t<!is_same<typename __unconstref<_Vp>::type, __container_value_type>::value> >
1294 class = __enable_if_t<!is_same<__remove_const_ref_t<_Vp>, __container_value_type>::value> >
12821295 _LIBCPP_INLINE_VISIBILITY
12831296 iterator __insert_unique(const_iterator __p, _Vp&& __v) {
12841297 return __emplace_hint_unique(__p, _VSTD::forward<_Vp>(__v));
lib/libcxx/include/__tuple deleted-550
......@@ -1,550 +0,0 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___TUPLE
11#define _LIBCPP___TUPLE
12
13#include <__config>
14#include <cstddef>
15#include <type_traits>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size;
25
26#if !defined(_LIBCPP_CXX03_LANG)
27template <class _Tp, class...>
28using __enable_if_tuple_size_imp = _Tp;
29
30template <class _Tp>
31struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
32 const _Tp,
33 __enable_if_t<!is_volatile<_Tp>::value>,
34 integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
35 : public integral_constant<size_t, tuple_size<_Tp>::value> {};
36
37template <class _Tp>
38struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
39 volatile _Tp,
40 __enable_if_t<!is_const<_Tp>::value>,
41 integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
42 : public integral_constant<size_t, tuple_size<_Tp>::value> {};
43
44template <class _Tp>
45struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
46 const volatile _Tp,
47 integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
48 : public integral_constant<size_t, tuple_size<_Tp>::value> {};
49
50#else
51template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<const _Tp> : public tuple_size<_Tp> {};
52template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<volatile _Tp> : public tuple_size<_Tp> {};
53template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<const volatile _Tp> : public tuple_size<_Tp> {};
54#endif
55
56template <size_t _Ip, class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_element;
57
58template <size_t _Ip, class _Tp>
59struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp>
60{
61 typedef _LIBCPP_NODEBUG typename add_const<typename tuple_element<_Ip, _Tp>::type>::type type;
62};
63
64template <size_t _Ip, class _Tp>
65struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp>
66{
67 typedef _LIBCPP_NODEBUG typename add_volatile<typename tuple_element<_Ip, _Tp>::type>::type type;
68};
69
70template <size_t _Ip, class _Tp>
71struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp>
72{
73 typedef _LIBCPP_NODEBUG typename add_cv<typename tuple_element<_Ip, _Tp>::type>::type type;
74};
75
76template <class _Tp> struct __tuple_like : false_type {};
77
78template <class _Tp> struct __tuple_like<const _Tp> : public __tuple_like<_Tp> {};
79template <class _Tp> struct __tuple_like<volatile _Tp> : public __tuple_like<_Tp> {};
80template <class _Tp> struct __tuple_like<const volatile _Tp> : public __tuple_like<_Tp> {};
81
82// tuple specializations
83
84#ifndef _LIBCPP_CXX03_LANG
85
86template <size_t...> struct __tuple_indices {};
87
88template <class _IdxType, _IdxType... _Values>
89struct __integer_sequence {
90 template <template <class _OIdxType, _OIdxType...> class _ToIndexSeq, class _ToIndexType>
91 using __convert = _ToIndexSeq<_ToIndexType, _Values...>;
92
93 template <size_t _Sp>
94 using __to_tuple_indices = __tuple_indices<(_Values + _Sp)...>;
95};
96
97#if !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
98namespace __detail {
99
100template<typename _Tp, size_t ..._Extra> struct __repeat;
101template<typename _Tp, _Tp ..._Np, size_t ..._Extra> struct __repeat<__integer_sequence<_Tp, _Np...>, _Extra...> {
102 typedef _LIBCPP_NODEBUG __integer_sequence<_Tp,
103 _Np...,
104 sizeof...(_Np) + _Np...,
105 2 * sizeof...(_Np) + _Np...,
106 3 * sizeof...(_Np) + _Np...,
107 4 * sizeof...(_Np) + _Np...,
108 5 * sizeof...(_Np) + _Np...,
109 6 * sizeof...(_Np) + _Np...,
110 7 * sizeof...(_Np) + _Np...,
111 _Extra...> type;
112};
113
114template<size_t _Np> struct __parity;
115template<size_t _Np> struct __make : __parity<_Np % 8>::template __pmake<_Np> {};
116
117template<> struct __make<0> { typedef __integer_sequence<size_t> type; };
118template<> struct __make<1> { typedef __integer_sequence<size_t, 0> type; };
119template<> struct __make<2> { typedef __integer_sequence<size_t, 0, 1> type; };
120template<> struct __make<3> { typedef __integer_sequence<size_t, 0, 1, 2> type; };
121template<> struct __make<4> { typedef __integer_sequence<size_t, 0, 1, 2, 3> type; };
122template<> struct __make<5> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4> type; };
123template<> struct __make<6> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5> type; };
124template<> struct __make<7> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5, 6> type; };
125
126template<> struct __parity<0> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type> {}; };
127template<> struct __parity<1> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 1> {}; };
128template<> struct __parity<2> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 2, _Np - 1> {}; };
129template<> struct __parity<3> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 3, _Np - 2, _Np - 1> {}; };
130template<> struct __parity<4> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
131template<> struct __parity<5> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
132template<> struct __parity<6> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
133template<> struct __parity<7> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 7, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
134
135} // namespace detail
136
137#endif // !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
138
139#if __has_builtin(__make_integer_seq)
140template <size_t _Ep, size_t _Sp>
141using __make_indices_imp =
142 typename __make_integer_seq<__integer_sequence, size_t, _Ep - _Sp>::template
143 __to_tuple_indices<_Sp>;
144#else
145template <size_t _Ep, size_t _Sp>
146using __make_indices_imp =
147 typename __detail::__make<_Ep - _Sp>::type::template __to_tuple_indices<_Sp>;
148
149#endif
150
151template <size_t _Ep, size_t _Sp = 0>
152struct __make_tuple_indices
153{
154 static_assert(_Sp <= _Ep, "__make_tuple_indices input error");
155 typedef __make_indices_imp<_Ep, _Sp> type;
156};
157
158
159template <class ..._Tp> class _LIBCPP_TEMPLATE_VIS tuple;
160
161template <class... _Tp> struct __tuple_like<tuple<_Tp...> > : true_type {};
162
163template <class ..._Tp>
164struct _LIBCPP_TEMPLATE_VIS tuple_size<tuple<_Tp...> >
165 : public integral_constant<size_t, sizeof...(_Tp)>
166{
167};
168
169template <size_t _Ip, class ..._Tp>
170_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
171typename tuple_element<_Ip, tuple<_Tp...> >::type&
172get(tuple<_Tp...>&) _NOEXCEPT;
173
174template <size_t _Ip, class ..._Tp>
175_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
176const typename tuple_element<_Ip, tuple<_Tp...> >::type&
177get(const tuple<_Tp...>&) _NOEXCEPT;
178
179template <size_t _Ip, class ..._Tp>
180_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
181typename tuple_element<_Ip, tuple<_Tp...> >::type&&
182get(tuple<_Tp...>&&) _NOEXCEPT;
183
184template <size_t _Ip, class ..._Tp>
185_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
186const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
187get(const tuple<_Tp...>&&) _NOEXCEPT;
188
189#endif // !defined(_LIBCPP_CXX03_LANG)
190
191// pair specializations
192
193template <class _T1, class _T2> struct __tuple_like<pair<_T1, _T2> > : true_type {};
194
195template <size_t _Ip, class _T1, class _T2>
196_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
197typename tuple_element<_Ip, pair<_T1, _T2> >::type&
198get(pair<_T1, _T2>&) _NOEXCEPT;
199
200template <size_t _Ip, class _T1, class _T2>
201_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
202const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
203get(const pair<_T1, _T2>&) _NOEXCEPT;
204
205#ifndef _LIBCPP_CXX03_LANG
206template <size_t _Ip, class _T1, class _T2>
207_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
208typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
209get(pair<_T1, _T2>&&) _NOEXCEPT;
210
211template <size_t _Ip, class _T1, class _T2>
212_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
213const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
214get(const pair<_T1, _T2>&&) _NOEXCEPT;
215#endif
216
217// array specializations
218
219template <class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS array;
220
221template <class _Tp, size_t _Size> struct __tuple_like<array<_Tp, _Size> > : true_type {};
222
223template <size_t _Ip, class _Tp, size_t _Size>
224_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
225_Tp&
226get(array<_Tp, _Size>&) _NOEXCEPT;
227
228template <size_t _Ip, class _Tp, size_t _Size>
229_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
230const _Tp&
231get(const array<_Tp, _Size>&) _NOEXCEPT;
232
233#ifndef _LIBCPP_CXX03_LANG
234template <size_t _Ip, class _Tp, size_t _Size>
235_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
236_Tp&&
237get(array<_Tp, _Size>&&) _NOEXCEPT;
238
239template <size_t _Ip, class _Tp, size_t _Size>
240_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
241const _Tp&&
242get(const array<_Tp, _Size>&&) _NOEXCEPT;
243#endif
244
245#ifndef _LIBCPP_CXX03_LANG
246
247// __tuple_types
248
249template <class ..._Tp> struct __tuple_types {};
250
251#if !__has_builtin(__type_pack_element)
252
253namespace __indexer_detail {
254
255template <size_t _Idx, class _Tp>
256struct __indexed { using type _LIBCPP_NODEBUG = _Tp; };
257
258template <class _Types, class _Indexes> struct __indexer;
259
260template <class ..._Types, size_t ..._Idx>
261struct __indexer<__tuple_types<_Types...>, __tuple_indices<_Idx...>>
262 : __indexed<_Idx, _Types>...
263{};
264
265template <size_t _Idx, class _Tp>
266__indexed<_Idx, _Tp> __at_index(__indexed<_Idx, _Tp> const&);
267
268} // namespace __indexer_detail
269
270template <size_t _Idx, class ..._Types>
271using __type_pack_element _LIBCPP_NODEBUG = typename decltype(
272 __indexer_detail::__at_index<_Idx>(
273 __indexer_detail::__indexer<
274 __tuple_types<_Types...>,
275 typename __make_tuple_indices<sizeof...(_Types)>::type
276 >{})
277 )::type;
278#endif
279
280template <size_t _Ip, class ..._Types>
281struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...> >
282{
283 static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");
284 typedef _LIBCPP_NODEBUG __type_pack_element<_Ip, _Types...> type;
285};
286
287
288template <class ..._Tp>
289struct _LIBCPP_TEMPLATE_VIS tuple_size<__tuple_types<_Tp...> >
290 : public integral_constant<size_t, sizeof...(_Tp)>
291{
292};
293
294template <class... _Tp> struct __tuple_like<__tuple_types<_Tp...> > : true_type {};
295
296template <bool _ApplyLV, bool _ApplyConst, bool _ApplyVolatile>
297struct __apply_cv_mf;
298template <>
299struct __apply_cv_mf<false, false, false> {
300 template <class _Tp> using __apply = _Tp;
301};
302template <>
303struct __apply_cv_mf<false, true, false> {
304 template <class _Tp> using __apply _LIBCPP_NODEBUG = const _Tp;
305};
306template <>
307struct __apply_cv_mf<false, false, true> {
308 template <class _Tp> using __apply _LIBCPP_NODEBUG = volatile _Tp;
309};
310template <>
311struct __apply_cv_mf<false, true, true> {
312 template <class _Tp> using __apply _LIBCPP_NODEBUG = const volatile _Tp;
313};
314template <>
315struct __apply_cv_mf<true, false, false> {
316 template <class _Tp> using __apply _LIBCPP_NODEBUG = _Tp&;
317};
318template <>
319struct __apply_cv_mf<true, true, false> {
320 template <class _Tp> using __apply _LIBCPP_NODEBUG = const _Tp&;
321};
322template <>
323struct __apply_cv_mf<true, false, true> {
324 template <class _Tp> using __apply _LIBCPP_NODEBUG = volatile _Tp&;
325};
326template <>
327struct __apply_cv_mf<true, true, true> {
328 template <class _Tp> using __apply _LIBCPP_NODEBUG = const volatile _Tp&;
329};
330template <class _Tp, class _RawTp = typename remove_reference<_Tp>::type>
331using __apply_cv_t _LIBCPP_NODEBUG = __apply_cv_mf<
332 is_lvalue_reference<_Tp>::value,
333 is_const<_RawTp>::value,
334 is_volatile<_RawTp>::value>;
335
336// __make_tuple_types
337
338// __make_tuple_types<_Tuple<_Types...>, _Ep, _Sp>::type is a
339// __tuple_types<_Types...> using only those _Types in the range [_Sp, _Ep).
340// _Sp defaults to 0 and _Ep defaults to tuple_size<_Tuple>. If _Tuple is a
341// lvalue_reference type, then __tuple_types<_Types&...> is the result.
342
343template <class _TupleTypes, class _TupleIndices>
344struct __make_tuple_types_flat;
345
346template <template <class...> class _Tuple, class ..._Types, size_t ..._Idx>
347struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>> {
348 // Specialization for pair, tuple, and __tuple_types
349 template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>>
350 using __apply_quals _LIBCPP_NODEBUG = __tuple_types<
351 typename _ApplyFn::template __apply<__type_pack_element<_Idx, _Types...>>...
352 >;
353};
354
355template <class _Vt, size_t _Np, size_t ..._Idx>
356struct __make_tuple_types_flat<array<_Vt, _Np>, __tuple_indices<_Idx...>> {
357 template <size_t>
358 using __value_type = _Vt;
359 template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>>
360 using __apply_quals = __tuple_types<
361 typename _ApplyFn::template __apply<__value_type<_Idx>>...
362 >;
363};
364
365template <class _Tp, size_t _Ep = tuple_size<typename remove_reference<_Tp>::type>::value,
366 size_t _Sp = 0,
367 bool _SameSize = (_Ep == tuple_size<typename remove_reference<_Tp>::type>::value)>
368struct __make_tuple_types
369{
370 static_assert(_Sp <= _Ep, "__make_tuple_types input error");
371 using _RawTp = typename remove_cv<typename remove_reference<_Tp>::type>::type;
372 using _Maker = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>;
373 using type = typename _Maker::template __apply_quals<_Tp>;
374};
375
376template <class ..._Types, size_t _Ep>
377struct __make_tuple_types<tuple<_Types...>, _Ep, 0, true> {
378 typedef _LIBCPP_NODEBUG __tuple_types<_Types...> type;
379};
380
381template <class ..._Types, size_t _Ep>
382struct __make_tuple_types<__tuple_types<_Types...>, _Ep, 0, true> {
383 typedef _LIBCPP_NODEBUG __tuple_types<_Types...> type;
384};
385
386template <bool ..._Preds>
387struct __all_dummy;
388
389template <bool ..._Pred>
390struct __all : _IsSame<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)...>> {};
391
392struct __tuple_sfinae_base {
393 template <template <class, class...> class _Trait,
394 class ..._LArgs, class ..._RArgs>
395 static auto __do_test(__tuple_types<_LArgs...>, __tuple_types<_RArgs...>)
396 -> __all<__enable_if_t<_Trait<_LArgs, _RArgs>::value, bool>{true}...>;
397 template <template <class...> class>
398 static auto __do_test(...) -> false_type;
399
400 template <class _FromArgs, class _ToArgs>
401 using __constructible = decltype(__do_test<is_constructible>(_ToArgs{}, _FromArgs{}));
402 template <class _FromArgs, class _ToArgs>
403 using __convertible = decltype(__do_test<is_convertible>(_FromArgs{}, _ToArgs{}));
404 template <class _FromArgs, class _ToArgs>
405 using __assignable = decltype(__do_test<is_assignable>(_ToArgs{}, _FromArgs{}));
406};
407
408// __tuple_convertible
409
410template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
411 bool = __tuple_like<_Up>::value>
412struct __tuple_convertible
413 : public false_type {};
414
415template <class _Tp, class _Up>
416struct __tuple_convertible<_Tp, _Up, true, true>
417 : public __tuple_sfinae_base::__convertible<
418 typename __make_tuple_types<_Tp>::type
419 , typename __make_tuple_types<_Up>::type
420 >
421{};
422
423// __tuple_constructible
424
425template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
426 bool = __tuple_like<_Up>::value>
427struct __tuple_constructible
428 : public false_type {};
429
430template <class _Tp, class _Up>
431struct __tuple_constructible<_Tp, _Up, true, true>
432 : public __tuple_sfinae_base::__constructible<
433 typename __make_tuple_types<_Tp>::type
434 , typename __make_tuple_types<_Up>::type
435 >
436{};
437
438// __tuple_assignable
439
440template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
441 bool = __tuple_like<_Up>::value>
442struct __tuple_assignable
443 : public false_type {};
444
445template <class _Tp, class _Up>
446struct __tuple_assignable<_Tp, _Up, true, true>
447 : public __tuple_sfinae_base::__assignable<
448 typename __make_tuple_types<_Tp>::type
449 , typename __make_tuple_types<_Up&>::type
450 >
451{};
452
453
454template <size_t _Ip, class ..._Tp>
455struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> >
456{
457 typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
458};
459
460#if _LIBCPP_STD_VER > 11
461template <size_t _Ip, class ..._Tp>
462using tuple_element_t _LIBCPP_NODEBUG = typename tuple_element <_Ip, _Tp...>::type;
463#endif
464
465template <bool _IsTuple, class _SizeTrait, size_t _Expected>
466struct __tuple_like_with_size_imp : false_type {};
467
468template <class _SizeTrait, size_t _Expected>
469struct __tuple_like_with_size_imp<true, _SizeTrait, _Expected>
470 : integral_constant<bool, _SizeTrait::value == _Expected> {};
471
472template <class _Tuple, size_t _ExpectedSize, class _RawTuple = __uncvref_t<_Tuple> >
473using __tuple_like_with_size _LIBCPP_NODEBUG = __tuple_like_with_size_imp<
474 __tuple_like<_RawTuple>::value,
475 tuple_size<_RawTuple>, _ExpectedSize
476 >;
477
478struct _LIBCPP_TYPE_VIS __check_tuple_constructor_fail {
479
480 static constexpr bool __enable_explicit_default() { return false; }
481 static constexpr bool __enable_implicit_default() { return false; }
482 template <class ...>
483 static constexpr bool __enable_explicit() { return false; }
484 template <class ...>
485 static constexpr bool __enable_implicit() { return false; }
486 template <class ...>
487 static constexpr bool __enable_assign() { return false; }
488};
489#endif // !defined(_LIBCPP_CXX03_LANG)
490
491#if _LIBCPP_STD_VER > 14
492
493template <bool _CanCopy, bool _CanMove>
494struct __sfinae_ctor_base {};
495template <>
496struct __sfinae_ctor_base<false, false> {
497 __sfinae_ctor_base() = default;
498 __sfinae_ctor_base(__sfinae_ctor_base const&) = delete;
499 __sfinae_ctor_base(__sfinae_ctor_base &&) = delete;
500 __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
501 __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
502};
503template <>
504struct __sfinae_ctor_base<true, false> {
505 __sfinae_ctor_base() = default;
506 __sfinae_ctor_base(__sfinae_ctor_base const&) = default;
507 __sfinae_ctor_base(__sfinae_ctor_base &&) = delete;
508 __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
509 __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
510};
511template <>
512struct __sfinae_ctor_base<false, true> {
513 __sfinae_ctor_base() = default;
514 __sfinae_ctor_base(__sfinae_ctor_base const&) = delete;
515 __sfinae_ctor_base(__sfinae_ctor_base &&) = default;
516 __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
517 __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
518};
519
520template <bool _CanCopy, bool _CanMove>
521struct __sfinae_assign_base {};
522template <>
523struct __sfinae_assign_base<false, false> {
524 __sfinae_assign_base() = default;
525 __sfinae_assign_base(__sfinae_assign_base const&) = default;
526 __sfinae_assign_base(__sfinae_assign_base &&) = default;
527 __sfinae_assign_base& operator=(__sfinae_assign_base const&) = delete;
528 __sfinae_assign_base& operator=(__sfinae_assign_base&&) = delete;
529};
530template <>
531struct __sfinae_assign_base<true, false> {
532 __sfinae_assign_base() = default;
533 __sfinae_assign_base(__sfinae_assign_base const&) = default;
534 __sfinae_assign_base(__sfinae_assign_base &&) = default;
535 __sfinae_assign_base& operator=(__sfinae_assign_base const&) = default;
536 __sfinae_assign_base& operator=(__sfinae_assign_base&&) = delete;
537};
538template <>
539struct __sfinae_assign_base<false, true> {
540 __sfinae_assign_base() = default;
541 __sfinae_assign_base(__sfinae_assign_base const&) = default;
542 __sfinae_assign_base(__sfinae_assign_base &&) = default;
543 __sfinae_assign_base& operator=(__sfinae_assign_base const&) = delete;
544 __sfinae_assign_base& operator=(__sfinae_assign_base&&) = default;
545};
546#endif // _LIBCPP_STD_VER > 14
547
548_LIBCPP_END_NAMESPACE_STD
549
550#endif // _LIBCPP___TUPLE
lib/libcxx/include/__tuple_dir/apply_cv.h created+70
......@@ -0,0 +1,70 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TUPLE_APPLY_CV_H
10#define _LIBCPP___TUPLE_APPLY_CV_H
11
12#include <__config>
13#include <__type_traits/is_const.h>
14#include <__type_traits/is_reference.h>
15#include <__type_traits/is_volatile.h>
16#include <__type_traits/remove_reference.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22#ifndef _LIBCPP_CXX03_LANG
23
24_LIBCPP_BEGIN_NAMESPACE_STD
25
26template <bool _ApplyLV, bool _ApplyConst, bool _ApplyVolatile>
27struct __apply_cv_mf;
28template <>
29struct __apply_cv_mf<false, false, false> {
30 template <class _Tp> using __apply = _Tp;
31};
32template <>
33struct __apply_cv_mf<false, true, false> {
34 template <class _Tp> using __apply _LIBCPP_NODEBUG = const _Tp;
35};
36template <>
37struct __apply_cv_mf<false, false, true> {
38 template <class _Tp> using __apply _LIBCPP_NODEBUG = volatile _Tp;
39};
40template <>
41struct __apply_cv_mf<false, true, true> {
42 template <class _Tp> using __apply _LIBCPP_NODEBUG = const volatile _Tp;
43};
44template <>
45struct __apply_cv_mf<true, false, false> {
46 template <class _Tp> using __apply _LIBCPP_NODEBUG = _Tp&;
47};
48template <>
49struct __apply_cv_mf<true, true, false> {
50 template <class _Tp> using __apply _LIBCPP_NODEBUG = const _Tp&;
51};
52template <>
53struct __apply_cv_mf<true, false, true> {
54 template <class _Tp> using __apply _LIBCPP_NODEBUG = volatile _Tp&;
55};
56template <>
57struct __apply_cv_mf<true, true, true> {
58 template <class _Tp> using __apply _LIBCPP_NODEBUG = const volatile _Tp&;
59};
60template <class _Tp, class _RawTp = __libcpp_remove_reference_t<_Tp> >
61using __apply_cv_t _LIBCPP_NODEBUG = __apply_cv_mf<
62 is_lvalue_reference<_Tp>::value,
63 is_const<_RawTp>::value,
64 is_volatile<_RawTp>::value>;
65
66_LIBCPP_END_NAMESPACE_STD
67
68#endif // _LIBCPP_CXX03_LANG
69
70#endif // _LIBCPP___TUPLE_APPLY_CV_H
lib/libcxx/include/__tuple_dir/make_tuple_types.h created+84
......@@ -0,0 +1,84 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TUPLE_MAKE_TUPLE_TYPES_H
10#define _LIBCPP___TUPLE_MAKE_TUPLE_TYPES_H
11
12#include <__config>
13#include <__fwd/array.h>
14#include <__fwd/tuple.h>
15#include <__tuple_dir/apply_cv.h>
16#include <__tuple_dir/tuple_element.h>
17#include <__tuple_dir/tuple_indices.h>
18#include <__tuple_dir/tuple_size.h>
19#include <__tuple_dir/tuple_types.h>
20#include <__type_traits/remove_cv.h>
21#include <__type_traits/remove_reference.h>
22#include <cstddef>
23
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header
26#endif
27
28#ifndef _LIBCPP_CXX03_LANG
29
30_LIBCPP_BEGIN_NAMESPACE_STD
31
32// __make_tuple_types<_Tuple<_Types...>, _Ep, _Sp>::type is a
33// __tuple_types<_Types...> using only those _Types in the range [_Sp, _Ep).
34// _Sp defaults to 0 and _Ep defaults to tuple_size<_Tuple>. If _Tuple is a
35// lvalue_reference type, then __tuple_types<_Types&...> is the result.
36
37template <class _TupleTypes, class _TupleIndices>
38struct __make_tuple_types_flat;
39
40template <template <class...> class _Tuple, class ..._Types, size_t ..._Idx>
41struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>> {
42 // Specialization for pair, tuple, and __tuple_types
43 template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>>
44 using __apply_quals _LIBCPP_NODEBUG = __tuple_types<
45 typename _ApplyFn::template __apply<__type_pack_element<_Idx, _Types...>>...
46 >;
47};
48
49template <class _Vt, size_t _Np, size_t ..._Idx>
50struct __make_tuple_types_flat<array<_Vt, _Np>, __tuple_indices<_Idx...>> {
51 template <size_t>
52 using __value_type = _Vt;
53 template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>>
54 using __apply_quals = __tuple_types<
55 typename _ApplyFn::template __apply<__value_type<_Idx>>...
56 >;
57};
58
59template <class _Tp, size_t _Ep = tuple_size<__libcpp_remove_reference_t<_Tp> >::value,
60 size_t _Sp = 0,
61 bool _SameSize = (_Ep == tuple_size<__libcpp_remove_reference_t<_Tp> >::value)>
62struct __make_tuple_types
63{
64 static_assert(_Sp <= _Ep, "__make_tuple_types input error");
65 using _RawTp = __remove_cv_t<__libcpp_remove_reference_t<_Tp> >;
66 using _Maker = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>;
67 using type = typename _Maker::template __apply_quals<_Tp>;
68};
69
70template <class ..._Types, size_t _Ep>
71struct __make_tuple_types<tuple<_Types...>, _Ep, 0, true> {
72 typedef _LIBCPP_NODEBUG __tuple_types<_Types...> type;
73};
74
75template <class ..._Types, size_t _Ep>
76struct __make_tuple_types<__tuple_types<_Types...>, _Ep, 0, true> {
77 typedef _LIBCPP_NODEBUG __tuple_types<_Types...> type;
78};
79
80_LIBCPP_END_NAMESPACE_STD
81
82#endif // _LIBCPP_CXX03_LANG
83
84#endif // _LIBCPP___TUPLE_MAKE_TUPLE_TYPES_H
lib/libcxx/include/__tuple_dir/pair_like.h created+32
......@@ -0,0 +1,32 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TUPLE_PAIR_LIKE_H
10#define _LIBCPP___TUPLE_PAIR_LIKE_H
11
12#include <__config>
13#include <__tuple_dir/tuple_like.h>
14#include <__tuple_dir/tuple_size.h>
15#include <__type_traits/remove_cvref.h>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23#if _LIBCPP_STD_VER >= 20
24
25template <class _Tp>
26concept __pair_like = __tuple_like<_Tp> && tuple_size<remove_cvref_t<_Tp>>::value == 2;
27
28#endif // _LIBCPP_STD_VER >= 20
29
30_LIBCPP_END_NAMESPACE_STD
31
32#endif // _LIBCPP___TUPLE_PAIR_LIKE_H
lib/libcxx/include/__tuple_dir/sfinae_helpers.h created+196
......@@ -0,0 +1,196 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TUPLE_SFINAE_HELPERS_H
10#define _LIBCPP___TUPLE_SFINAE_HELPERS_H
11
12#include <__config>
13#include <__fwd/tuple.h>
14#include <__tuple_dir/make_tuple_types.h>
15#include <__tuple_dir/tuple_element.h>
16#include <__tuple_dir/tuple_like_ext.h>
17#include <__tuple_dir/tuple_size.h>
18#include <__tuple_dir/tuple_types.h>
19#include <__type_traits/enable_if.h>
20#include <__type_traits/integral_constant.h>
21#include <__type_traits/is_assignable.h>
22#include <__type_traits/is_constructible.h>
23#include <__type_traits/is_convertible.h>
24#include <__type_traits/is_same.h>
25#include <__type_traits/remove_cvref.h>
26#include <__type_traits/remove_reference.h>
27#include <cstddef>
28
29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
30# pragma GCC system_header
31#endif
32
33_LIBCPP_BEGIN_NAMESPACE_STD
34
35#ifndef _LIBCPP_CXX03_LANG
36
37template <bool ..._Preds>
38struct __all_dummy;
39
40template <bool ..._Pred>
41struct __all : _IsSame<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)...>> {};
42
43struct __tuple_sfinae_base {
44 template <template <class, class...> class _Trait,
45 class ..._LArgs, class ..._RArgs>
46 static auto __do_test(__tuple_types<_LArgs...>, __tuple_types<_RArgs...>)
47 -> __all<__enable_if_t<_Trait<_LArgs, _RArgs>::value, bool>{true}...>;
48 template <template <class...> class>
49 static auto __do_test(...) -> false_type;
50
51 template <class _FromArgs, class _ToArgs>
52 using __constructible = decltype(__do_test<is_constructible>(_ToArgs{}, _FromArgs{}));
53 template <class _FromArgs, class _ToArgs>
54 using __convertible = decltype(__do_test<is_convertible>(_FromArgs{}, _ToArgs{}));
55 template <class _FromArgs, class _ToArgs>
56 using __assignable = decltype(__do_test<is_assignable>(_ToArgs{}, _FromArgs{}));
57};
58
59// __tuple_convertible
60
61template <class _Tp, class _Up, bool = __tuple_like_ext<__libcpp_remove_reference_t<_Tp> >::value,
62 bool = __tuple_like_ext<_Up>::value>
63struct __tuple_convertible
64 : public false_type {};
65
66template <class _Tp, class _Up>
67struct __tuple_convertible<_Tp, _Up, true, true>
68 : public __tuple_sfinae_base::__convertible<
69 typename __make_tuple_types<_Tp>::type
70 , typename __make_tuple_types<_Up>::type
71 >
72{};
73
74// __tuple_constructible
75
76template <class _Tp, class _Up, bool = __tuple_like_ext<__libcpp_remove_reference_t<_Tp> >::value,
77 bool = __tuple_like_ext<_Up>::value>
78struct __tuple_constructible
79 : public false_type {};
80
81template <class _Tp, class _Up>
82struct __tuple_constructible<_Tp, _Up, true, true>
83 : public __tuple_sfinae_base::__constructible<
84 typename __make_tuple_types<_Tp>::type
85 , typename __make_tuple_types<_Up>::type
86 >
87{};
88
89// __tuple_assignable
90
91template <class _Tp, class _Up, bool = __tuple_like_ext<__libcpp_remove_reference_t<_Tp> >::value,
92 bool = __tuple_like_ext<_Up>::value>
93struct __tuple_assignable
94 : public false_type {};
95
96template <class _Tp, class _Up>
97struct __tuple_assignable<_Tp, _Up, true, true>
98 : public __tuple_sfinae_base::__assignable<
99 typename __make_tuple_types<_Tp>::type
100 , typename __make_tuple_types<_Up&>::type
101 >
102{};
103
104
105template <size_t _Ip, class ..._Tp>
106struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> >
107{
108 typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
109};
110
111template <bool _IsTuple, class _SizeTrait, size_t _Expected>
112struct __tuple_like_with_size_imp : false_type {};
113
114template <class _SizeTrait, size_t _Expected>
115struct __tuple_like_with_size_imp<true, _SizeTrait, _Expected>
116 : integral_constant<bool, _SizeTrait::value == _Expected> {};
117
118template <class _Tuple, size_t _ExpectedSize, class _RawTuple = __libcpp_remove_reference_t<_Tuple> >
119using __tuple_like_with_size _LIBCPP_NODEBUG = __tuple_like_with_size_imp<
120 __tuple_like_ext<_RawTuple>::value,
121 tuple_size<_RawTuple>, _ExpectedSize
122 >;
123
124struct _LIBCPP_TYPE_VIS __check_tuple_constructor_fail {
125
126 static constexpr bool __enable_explicit_default() { return false; }
127 static constexpr bool __enable_implicit_default() { return false; }
128 template <class ...>
129 static constexpr bool __enable_explicit() { return false; }
130 template <class ...>
131 static constexpr bool __enable_implicit() { return false; }
132 template <class ...>
133 static constexpr bool __enable_assign() { return false; }
134};
135#endif // !defined(_LIBCPP_CXX03_LANG)
136
137#if _LIBCPP_STD_VER > 14
138
139template <bool _CanCopy, bool _CanMove>
140struct __sfinae_ctor_base {};
141template <>
142struct __sfinae_ctor_base<false, false> {
143 __sfinae_ctor_base() = default;
144 __sfinae_ctor_base(__sfinae_ctor_base const&) = delete;
145 __sfinae_ctor_base(__sfinae_ctor_base &&) = delete;
146 __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
147 __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
148};
149template <>
150struct __sfinae_ctor_base<true, false> {
151 __sfinae_ctor_base() = default;
152 __sfinae_ctor_base(__sfinae_ctor_base const&) = default;
153 __sfinae_ctor_base(__sfinae_ctor_base &&) = delete;
154 __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
155 __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
156};
157template <>
158struct __sfinae_ctor_base<false, true> {
159 __sfinae_ctor_base() = default;
160 __sfinae_ctor_base(__sfinae_ctor_base const&) = delete;
161 __sfinae_ctor_base(__sfinae_ctor_base &&) = default;
162 __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
163 __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
164};
165
166template <bool _CanCopy, bool _CanMove>
167struct __sfinae_assign_base {};
168template <>
169struct __sfinae_assign_base<false, false> {
170 __sfinae_assign_base() = default;
171 __sfinae_assign_base(__sfinae_assign_base const&) = default;
172 __sfinae_assign_base(__sfinae_assign_base &&) = default;
173 __sfinae_assign_base& operator=(__sfinae_assign_base const&) = delete;
174 __sfinae_assign_base& operator=(__sfinae_assign_base&&) = delete;
175};
176template <>
177struct __sfinae_assign_base<true, false> {
178 __sfinae_assign_base() = default;
179 __sfinae_assign_base(__sfinae_assign_base const&) = default;
180 __sfinae_assign_base(__sfinae_assign_base &&) = default;
181 __sfinae_assign_base& operator=(__sfinae_assign_base const&) = default;
182 __sfinae_assign_base& operator=(__sfinae_assign_base&&) = delete;
183};
184template <>
185struct __sfinae_assign_base<false, true> {
186 __sfinae_assign_base() = default;
187 __sfinae_assign_base(__sfinae_assign_base const&) = default;
188 __sfinae_assign_base(__sfinae_assign_base &&) = default;
189 __sfinae_assign_base& operator=(__sfinae_assign_base const&) = delete;
190 __sfinae_assign_base& operator=(__sfinae_assign_base&&) = default;
191};
192#endif // _LIBCPP_STD_VER > 14
193
194_LIBCPP_END_NAMESPACE_STD
195
196#endif // _LIBCPP___TUPLE_SFINAE_HELPERS_H
lib/libcxx/include/__tuple_dir/tuple_element.h created+93
......@@ -0,0 +1,93 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TUPLE_TUPLE_ELEMENT_H
10#define _LIBCPP___TUPLE_TUPLE_ELEMENT_H
11
12#include <__config>
13#include <__tuple_dir/tuple_indices.h>
14#include <__tuple_dir/tuple_types.h>
15#include <__type_traits/add_const.h>
16#include <__type_traits/add_cv.h>
17#include <__type_traits/add_volatile.h>
18#include <cstddef>
19
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header
22#endif
23
24_LIBCPP_BEGIN_NAMESPACE_STD
25
26template <size_t _Ip, class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_element;
27
28template <size_t _Ip, class _Tp>
29struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp>
30{
31 typedef _LIBCPP_NODEBUG typename add_const<typename tuple_element<_Ip, _Tp>::type>::type type;
32};
33
34template <size_t _Ip, class _Tp>
35struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp>
36{
37 typedef _LIBCPP_NODEBUG typename add_volatile<typename tuple_element<_Ip, _Tp>::type>::type type;
38};
39
40template <size_t _Ip, class _Tp>
41struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp>
42{
43 typedef _LIBCPP_NODEBUG typename add_cv<typename tuple_element<_Ip, _Tp>::type>::type type;
44};
45
46#ifndef _LIBCPP_CXX03_LANG
47
48#if !__has_builtin(__type_pack_element)
49
50namespace __indexer_detail {
51
52template <size_t _Idx, class _Tp>
53struct __indexed { using type _LIBCPP_NODEBUG = _Tp; };
54
55template <class _Types, class _Indexes> struct __indexer;
56
57template <class ..._Types, size_t ..._Idx>
58struct __indexer<__tuple_types<_Types...>, __tuple_indices<_Idx...>>
59 : __indexed<_Idx, _Types>...
60{};
61
62template <size_t _Idx, class _Tp>
63__indexed<_Idx, _Tp> __at_index(__indexed<_Idx, _Tp> const&);
64
65} // namespace __indexer_detail
66
67template <size_t _Idx, class ..._Types>
68using __type_pack_element _LIBCPP_NODEBUG = typename decltype(
69 __indexer_detail::__at_index<_Idx>(
70 __indexer_detail::__indexer<
71 __tuple_types<_Types...>,
72 typename __make_tuple_indices<sizeof...(_Types)>::type
73 >{})
74 )::type;
75#endif
76
77template <size_t _Ip, class ..._Types>
78struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...> >
79{
80 static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");
81 typedef _LIBCPP_NODEBUG __type_pack_element<_Ip, _Types...> type;
82};
83
84#if _LIBCPP_STD_VER > 11
85template <size_t _Ip, class ..._Tp>
86using tuple_element_t _LIBCPP_NODEBUG = typename tuple_element <_Ip, _Tp...>::type;
87#endif
88
89#endif // _LIBCPP_CXX03_LANG
90
91_LIBCPP_END_NAMESPACE_STD
92
93#endif // _LIBCPP___TUPLE_TUPLE_ELEMENT_H
lib/libcxx/include/__tuple_dir/tuple_indices.h created+37
......@@ -0,0 +1,37 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TUPLE_MAKE_TUPLE_INDICES_H
10#define _LIBCPP___TUPLE_MAKE_TUPLE_INDICES_H
11
12#include <__config>
13#include <__utility/integer_sequence.h>
14#include <cstddef>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20#ifndef _LIBCPP_CXX03_LANG
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24template <size_t...> struct __tuple_indices {};
25
26template <size_t _Ep, size_t _Sp = 0>
27struct __make_tuple_indices
28{
29 static_assert(_Sp <= _Ep, "__make_tuple_indices input error");
30 typedef __make_indices_imp<_Ep, _Sp> type;
31};
32
33_LIBCPP_END_NAMESPACE_STD
34
35#endif // _LIBCPP_CXX03_LANG
36
37#endif // _LIBCPP___TUPLE_MAKE_TUPLE_INDICES_H
lib/libcxx/include/__tuple_dir/tuple_like.h created+51
......@@ -0,0 +1,51 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TUPLE_TUPLE_LIKE_H
10#define _LIBCPP___TUPLE_TUPLE_LIKE_H
11
12#include <__config>
13#include <__fwd/array.h>
14#include <__fwd/pair.h>
15#include <__fwd/subrange.h>
16#include <__fwd/tuple.h>
17#include <__type_traits/integral_constant.h>
18#include <__type_traits/remove_cvref.h>
19#include <cstddef>
20
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header
23#endif
24
25_LIBCPP_BEGIN_NAMESPACE_STD
26
27#if _LIBCPP_STD_VER >= 20
28
29template <class _Tp>
30struct __tuple_like_impl : false_type {};
31
32template <class... _Tp>
33struct __tuple_like_impl<tuple<_Tp...> > : true_type {};
34
35template <class _T1, class _T2>
36struct __tuple_like_impl<pair<_T1, _T2> > : true_type {};
37
38template <class _Tp, size_t _Size>
39struct __tuple_like_impl<array<_Tp, _Size> > : true_type {};
40
41template <class _Ip, class _Sp, ranges::subrange_kind _Kp>
42struct __tuple_like_impl<ranges::subrange<_Ip, _Sp, _Kp> > : true_type {};
43
44template <class _Tp>
45concept __tuple_like = __tuple_like_impl<remove_cvref_t<_Tp>>::value;
46
47#endif // _LIBCPP_STD_VER >= 20
48
49_LIBCPP_END_NAMESPACE_STD
50
51#endif // _LIBCPP___TUPLE_TUPLE_LIKE_H
lib/libcxx/include/__tuple_dir/tuple_like_ext.h created+44
......@@ -0,0 +1,44 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TUPLE_TUPLE_LIKE_EXT_H
10#define _LIBCPP___TUPLE_TUPLE_LIKE_EXT_H
11
12#include <__config>
13#include <__fwd/array.h>
14#include <__fwd/pair.h>
15#include <__fwd/tuple.h>
16#include <__tuple_dir/tuple_types.h>
17#include <__type_traits/integral_constant.h>
18#include <cstddef>
19
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header
22#endif
23
24_LIBCPP_BEGIN_NAMESPACE_STD
25
26template <class _Tp> struct __tuple_like_ext : false_type {};
27
28template <class _Tp> struct __tuple_like_ext<const _Tp> : public __tuple_like_ext<_Tp> {};
29template <class _Tp> struct __tuple_like_ext<volatile _Tp> : public __tuple_like_ext<_Tp> {};
30template <class _Tp> struct __tuple_like_ext<const volatile _Tp> : public __tuple_like_ext<_Tp> {};
31
32#ifndef _LIBCPP_CXX03_LANG
33template <class... _Tp> struct __tuple_like_ext<tuple<_Tp...> > : true_type {};
34#endif
35
36template <class _T1, class _T2> struct __tuple_like_ext<pair<_T1, _T2> > : true_type {};
37
38template <class _Tp, size_t _Size> struct __tuple_like_ext<array<_Tp, _Size> > : true_type {};
39
40template <class... _Tp> struct __tuple_like_ext<__tuple_types<_Tp...> > : true_type {};
41
42_LIBCPP_END_NAMESPACE_STD
43
44#endif // _LIBCPP___TUPLE_TUPLE_LIKE_EXT_H
lib/libcxx/include/__tuple_dir/tuple_size.h created+75
......@@ -0,0 +1,75 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TUPLE_TUPLE_SIZE_H
10#define _LIBCPP___TUPLE_TUPLE_SIZE_H
11
12#include <__config>
13#include <__fwd/tuple.h>
14#include <__tuple_dir/tuple_types.h>
15#include <__type_traits/is_const.h>
16#include <__type_traits/is_volatile.h>
17#include <cstddef>
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size;
26
27#if !defined(_LIBCPP_CXX03_LANG)
28template <class _Tp, class...>
29using __enable_if_tuple_size_imp = _Tp;
30
31template <class _Tp>
32struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
33 const _Tp,
34 __enable_if_t<!is_volatile<_Tp>::value>,
35 integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
36 : public integral_constant<size_t, tuple_size<_Tp>::value> {};
37
38template <class _Tp>
39struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
40 volatile _Tp,
41 __enable_if_t<!is_const<_Tp>::value>,
42 integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
43 : public integral_constant<size_t, tuple_size<_Tp>::value> {};
44
45template <class _Tp>
46struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
47 const volatile _Tp,
48 integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
49 : public integral_constant<size_t, tuple_size<_Tp>::value> {};
50
51#else
52template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<const _Tp> : public tuple_size<_Tp> {};
53template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<volatile _Tp> : public tuple_size<_Tp> {};
54template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<const volatile _Tp> : public tuple_size<_Tp> {};
55#endif
56
57#ifndef _LIBCPP_CXX03_LANG
58
59template <class ..._Tp>
60struct _LIBCPP_TEMPLATE_VIS tuple_size<tuple<_Tp...> >
61 : public integral_constant<size_t, sizeof...(_Tp)>
62{
63};
64
65template <class ..._Tp>
66struct _LIBCPP_TEMPLATE_VIS tuple_size<__tuple_types<_Tp...> >
67 : public integral_constant<size_t, sizeof...(_Tp)>
68{
69};
70
71#endif // _LIBCPP_CXX03_LANG
72
73_LIBCPP_END_NAMESPACE_STD
74
75#endif // _LIBCPP___TUPLE_TUPLE_SIZE_H
lib/libcxx/include/__tuple_dir/tuple_types.h created+24
......@@ -0,0 +1,24 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TUPLE_TUPLE_TYPES_H
10#define _LIBCPP___TUPLE_TUPLE_TYPES_H
11
12#include <__config>
13
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# pragma GCC system_header
16#endif
17
18_LIBCPP_BEGIN_NAMESPACE_STD
19
20template <class ..._Tp> struct __tuple_types {};
21
22_LIBCPP_END_NAMESPACE_STD
23
24#endif // _LIBCPP___TUPLE_TUPLE_TYPES_H
lib/libcxx/include/__type_traits/add_lvalue_reference.h+25-5
......@@ -18,14 +18,34 @@
1818
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; };
22template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp& type; };
21#if __has_builtin(__add_lvalue_reference)
2322
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference
25{typedef _LIBCPP_NODEBUG typename __add_lvalue_reference_impl<_Tp>::type type;};
23template <class _Tp>
24using __add_lvalue_reference_t = __add_lvalue_reference(_Tp);
25
26#else
27
28template <class _Tp, bool = __libcpp_is_referenceable<_Tp>::value>
29struct __add_lvalue_reference_impl {
30 typedef _LIBCPP_NODEBUG _Tp type;
31};
32template <class _Tp >
33struct __add_lvalue_reference_impl<_Tp, true> {
34 typedef _LIBCPP_NODEBUG _Tp& type;
35};
36
37template <class _Tp>
38using __add_lvalue_reference_t = typename __add_lvalue_reference_impl<_Tp>::type;
39
40#endif // __has_builtin(__add_lvalue_reference)
41
42template <class _Tp>
43struct add_lvalue_reference {
44 using type _LIBCPP_NODEBUG = __add_lvalue_reference_t<_Tp>;
45};
2646
2747#if _LIBCPP_STD_VER > 11
28template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
48template <class _Tp> using add_lvalue_reference_t = __add_lvalue_reference_t<_Tp>;
2949#endif
3050
3151_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/add_pointer.h+21-7
......@@ -12,6 +12,7 @@
1212#include <__config>
1313#include <__type_traits/is_referenceable.h>
1414#include <__type_traits/is_same.h>
15#include <__type_traits/is_void.h>
1516#include <__type_traits/remove_cv.h>
1617#include <__type_traits/remove_reference.h>
1718
......@@ -21,19 +22,32 @@
2122
2223_LIBCPP_BEGIN_NAMESPACE_STD
2324
25#if __has_builtin(__add_pointer)
26
27template <class _Tp>
28using __add_pointer_t = __add_pointer(_Tp);
29
30#else
2431template <class _Tp,
25 bool = __is_referenceable<_Tp>::value ||
26 _IsSame<typename remove_cv<_Tp>::type, void>::value>
27struct __add_pointer_impl
28 {typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type* type;};
32 bool = __libcpp_is_referenceable<_Tp>::value || is_void<_Tp>::value>
33struct __add_pointer_impl {
34 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tp>* type;
35};
2936template <class _Tp> struct __add_pointer_impl<_Tp, false>
3037 {typedef _LIBCPP_NODEBUG _Tp type;};
3138
32template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer
33 {typedef _LIBCPP_NODEBUG typename __add_pointer_impl<_Tp>::type type;};
39template <class _Tp>
40using __add_pointer_t = typename __add_pointer_impl<_Tp>::type;
41
42#endif // __has_builtin(__add_pointer)
43
44template <class _Tp>
45struct add_pointer {
46 using type _LIBCPP_NODEBUG = __add_pointer_t<_Tp>;
47};
3448
3549#if _LIBCPP_STD_VER > 11
36template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
50template <class _Tp> using add_pointer_t = __add_pointer_t<_Tp>;
3751#endif
3852
3953_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/add_rvalue_reference.h+26-5
......@@ -18,14 +18,35 @@
1818
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; };
22template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp&& type; };
21#if __has_builtin(__add_rvalue_reference)
2322
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference
25{typedef _LIBCPP_NODEBUG typename __add_rvalue_reference_impl<_Tp>::type type;};
23template <class _Tp>
24using __add_rvalue_reference_t = __add_rvalue_reference(_Tp);
25
26#else
27
28template <class _Tp, bool = __libcpp_is_referenceable<_Tp>::value>
29struct __add_rvalue_reference_impl {
30 typedef _LIBCPP_NODEBUG _Tp type;
31};
32template <class _Tp >
33struct __add_rvalue_reference_impl<_Tp, true> {
34 typedef _LIBCPP_NODEBUG _Tp&& type;
35};
36
37template <class _Tp>
38using __add_rvalue_reference_t = typename __add_rvalue_reference_impl<_Tp>::type;
39
40#endif // __has_builtin(__add_rvalue_reference)
41
42template <class _Tp>
43struct add_rvalue_reference {
44 using type = __add_rvalue_reference_t<_Tp>;
45};
2646
2747#if _LIBCPP_STD_VER > 11
28template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
48template <class _Tp>
49using add_rvalue_reference_t = __add_rvalue_reference_t<_Tp>;
2950#endif
3051
3152_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/aligned_storage.h+9-13
......@@ -54,21 +54,13 @@ template <class _TL, size_t _Align> struct __find_pod;
5454template <class _Hp, size_t _Align>
5555struct __find_pod<__type_list<_Hp, __nat>, _Align>
5656{
57 typedef typename conditional<
58 _Align == _Hp::value,
59 typename _Hp::type,
60 __fallback_overaligned<_Align>
61 >::type type;
57 typedef __conditional_t<_Align == _Hp::value, typename _Hp::type, __fallback_overaligned<_Align> > type;
6258};
6359
6460template <class _Hp, class _Tp, size_t _Align>
6561struct __find_pod<__type_list<_Hp, _Tp>, _Align>
6662{
67 typedef typename conditional<
68 _Align == _Hp::value,
69 typename _Hp::type,
70 typename __find_pod<_Tp, _Align>::type
71 >::type type;
63 typedef __conditional_t<_Align == _Hp::value, typename _Hp::type, typename __find_pod<_Tp, _Align>::type> type;
7264};
7365
7466template <class _TL, size_t _Len> struct __find_max_align;
......@@ -91,7 +83,7 @@ struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
9183 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
9284
9385template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
94struct _LIBCPP_TEMPLATE_VIS aligned_storage
86struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_TEMPLATE_VIS aligned_storage
9587{
9688 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
9789 union type
......@@ -102,13 +94,17 @@ struct _LIBCPP_TEMPLATE_VIS aligned_storage
10294};
10395
10496#if _LIBCPP_STD_VER > 11
97
98 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
10599template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
106 using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
100 using aligned_storage_t _LIBCPP_DEPRECATED_IN_CXX23 = typename aligned_storage<_Len, _Align>::type;
101 _LIBCPP_SUPPRESS_DEPRECATED_POP
102
107103#endif
108104
109105#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
110106template <size_t _Len>\
111struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
107struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
112108{\
113109 struct _ALIGNAS(n) type\
114110 {\
lib/libcxx/include/__type_traits/aligned_union.h+3-2
......@@ -37,7 +37,7 @@ struct __static_max<_I0, _I1, _In...>
3737};
3838
3939template <size_t _Len, class _Type0, class ..._Types>
40struct aligned_union
40struct _LIBCPP_DEPRECATED_IN_CXX23 aligned_union
4141{
4242 static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0),
4343 _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value;
......@@ -47,7 +47,8 @@ struct aligned_union
4747};
4848
4949#if _LIBCPP_STD_VER > 11
50template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
50template <size_t _Len, class... _Types>
51using aligned_union_t _LIBCPP_DEPRECATED_IN_CXX23 = typename aligned_union<_Len, _Types...>::type;
5152#endif
5253
5354_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/alignment_of.h+1-1
......@@ -24,7 +24,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of
2424
2525#if _LIBCPP_STD_VER > 14
2626template <class _Tp>
27inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value;
27inline constexpr size_t alignment_of_v = _LIBCPP_ALIGNOF(_Tp);
2828#endif
2929
3030_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/apply_cv.h+2-3
......@@ -10,7 +10,6 @@
1010#define _LIBCPP___TYPE_TRAITS_APPLY_CV_H
1111
1212#include <__config>
13#include <__type_traits/integral_constant.h>
1413#include <__type_traits/is_const.h>
1514#include <__type_traits/is_volatile.h>
1615#include <__type_traits/remove_reference.h>
......@@ -22,8 +21,8 @@
2221
2322_LIBCPP_BEGIN_NAMESPACE_STD
2423
25template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
26 bool = is_volatile<typename remove_reference<_Tp>::type>::value>
24template <class _Tp, class _Up, bool = is_const<__libcpp_remove_reference_t<_Tp> >::value,
25 bool = is_volatile<__libcpp_remove_reference_t<_Tp> >::value>
2726struct __apply_cv
2827{
2928 typedef _LIBCPP_NODEBUG _Up type;
lib/libcxx/include/__type_traits/can_extract_key.h created+56
......@@ -0,0 +1,56 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_CAN_EXTRACT_KEY_H
10#define _LIBCPP___TYPE_TRAITS_CAN_EXTRACT_KEY_H
11
12#include <__config>
13#include <__fwd/pair.h>
14#include <__type_traits/conditional.h>
15#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_same.h>
17#include <__type_traits/remove_const.h>
18#include <__type_traits/remove_const_ref.h>
19
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header
22#endif
23
24_LIBCPP_BEGIN_NAMESPACE_STD
25
26// These traits are used in __tree and __hash_table
27struct __extract_key_fail_tag {};
28struct __extract_key_self_tag {};
29struct __extract_key_first_tag {};
30
31template <class _ValTy, class _Key, class _RawValTy = __remove_const_ref_t<_ValTy> >
32struct __can_extract_key
33 : __conditional_t<_IsSame<_RawValTy, _Key>::value, __extract_key_self_tag, __extract_key_fail_tag> {};
34
35template <class _Pair, class _Key, class _First, class _Second>
36struct __can_extract_key<_Pair, _Key, pair<_First, _Second> >
37 : __conditional_t<_IsSame<__remove_const_t<_First>, _Key>::value, __extract_key_first_tag, __extract_key_fail_tag> {
38};
39
40// __can_extract_map_key uses true_type/false_type instead of the tags.
41// It returns true if _Key != _ContainerValueTy (the container is a map not a set)
42// and _ValTy == _Key.
43template <class _ValTy, class _Key, class _ContainerValueTy,
44 class _RawValTy = __remove_const_ref_t<_ValTy> >
45struct __can_extract_map_key
46 : integral_constant<bool, _IsSame<_RawValTy, _Key>::value> {};
47
48// This specialization returns __extract_key_fail_tag for non-map containers
49// because _Key == _ContainerValueTy
50template <class _ValTy, class _Key, class _RawValTy>
51struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
52 : false_type {};
53
54_LIBCPP_END_NAMESPACE_STD
55
56#endif // _LIBCPP___TYPE_TRAITS_CAN_EXTRACT_KEY_H
lib/libcxx/include/__type_traits/common_reference.h+1-1
......@@ -31,7 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3131// Let COND_RES(X, Y) be:
3232template <class _Xp, class _Yp>
3333using __cond_res =
34 decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()());
34 decltype(false ? std::declval<_Xp(&)()>()() : std::declval<_Yp(&)()>()());
3535
3636// Let `XREF(A)` denote a unary alias template `T` such that `T<U>` denotes the same type as `U`
3737// with the addition of `A`'s cv and reference qualifiers, for a non-reference cv-unqualified type
lib/libcxx/include/__type_traits/common_type.h+5-9
......@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2626#if _LIBCPP_STD_VER > 17
2727// Let COND_RES(X, Y) be:
2828template <class _Tp, class _Up>
29using __cond_type = decltype(false ? declval<_Tp>() : declval<_Up>());
29using __cond_type = decltype(false ? std::declval<_Tp>() : std::declval<_Up>());
3030
3131template <class _Tp, class _Up, class = void>
3232struct __common_type3 {};
......@@ -47,13 +47,10 @@ struct __common_type2_imp {};
4747
4848// sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..."
4949template <class _Tp, class _Up>
50struct __common_type2_imp<_Tp, _Up,
51 typename __void_t<decltype(
52 true ? declval<_Tp>() : declval<_Up>()
53 )>::type>
50struct __common_type2_imp<_Tp, _Up, __void_t<decltype(true ? std::declval<_Tp>() : std::declval<_Up>())> >
5451{
5552 typedef _LIBCPP_NODEBUG typename decay<decltype(
56 true ? declval<_Tp>() : declval<_Up>()
53 true ? std::declval<_Tp>() : std::declval<_Up>()
5754 )>::type type;
5855};
5956
......@@ -82,8 +79,7 @@ struct common_type {
8279
8380template <class _Tp, class _Up>
8481struct __common_type_impl<
85 __common_types<_Tp, _Up>,
86 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
82 __common_types<_Tp, _Up>, __void_t<typename common_type<_Tp, _Up>::type> >
8783{
8884 typedef typename common_type<_Tp, _Up>::type type;
8985};
......@@ -91,7 +87,7 @@ struct __common_type_impl<
9187template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
9288struct __common_type_impl<
9389 __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>,
94 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
90 __void_t<typename common_type<_Tp, _Up>::type> >
9591 : __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type,
9692 _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {
9793};
lib/libcxx/include/__type_traits/conditional.h+9-4
......@@ -36,17 +36,22 @@ template <bool _Cond, class _IfRes, class _ElseRes>
3636using _If _LIBCPP_NODEBUG = typename _IfImpl<_Cond>::template _Select<_IfRes, _ElseRes>;
3737
3838template <bool _Bp, class _If, class _Then>
39 struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;};
39struct _LIBCPP_TEMPLATE_VIS conditional {
40 using type _LIBCPP_NODEBUG = _If;
41};
4042template <class _If, class _Then>
41 struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;};
43struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {
44 using type _LIBCPP_NODEBUG = _Then;
45};
4246
4347#if _LIBCPP_STD_VER > 11
4448template <bool _Bp, class _IfRes, class _ElseRes>
45using conditional_t = typename conditional<_Bp, _IfRes, _ElseRes>::type;
49using conditional_t _LIBCPP_NODEBUG = typename conditional<_Bp, _IfRes, _ElseRes>::type;
4650#endif
4751
4852// Helper so we can use "conditional_t" in all language versions.
49template <bool _Bp, class _If, class _Then> using __conditional_t = typename conditional<_Bp, _If, _Then>::type;
53template <bool _Bp, class _If, class _Then>
54using __conditional_t _LIBCPP_NODEBUG = typename conditional<_Bp, _If, _Then>::type;
5055
5156_LIBCPP_END_NAMESPACE_STD
5257
lib/libcxx/include/__type_traits/conjunction.h+22-21
......@@ -20,26 +20,6 @@
2020
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if _LIBCPP_STD_VER > 14
24
25template <class _Arg, class... _Args>
26struct __conjunction_impl {
27 using type = conditional_t<!bool(_Arg::value), _Arg, typename __conjunction_impl<_Args...>::type>;
28};
29
30template <class _Arg>
31struct __conjunction_impl<_Arg> {
32 using type = _Arg;
33};
34
35template <class... _Args>
36struct conjunction : __conjunction_impl<true_type, _Args...>::type {};
37
38template<class... _Args>
39inline constexpr bool conjunction_v = conjunction<_Args...>::value;
40
41#endif // _LIBCPP_STD_VER > 14
42
4323template <class...>
4424using __expand_to_true = true_type;
4525
......@@ -49,8 +29,29 @@ __expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int);
4929template <class...>
5030false_type __and_helper(...);
5131
32// _And always performs lazy evaluation of its arguments.
33//
34// However, `_And<_Pred...>` itself will evaluate its result immediately (without having to
35// be instantiated) since it is an alias, unlike `conjunction<_Pred...>`, which is a struct.
36// If you want to defer the evaluation of `_And<_Pred...>` itself, use `_Lazy<_And, _Pred...>`.
5237template <class... _Pred>
53using _And _LIBCPP_NODEBUG = decltype(__and_helper<_Pred...>(0));
38using _And _LIBCPP_NODEBUG = decltype(std::__and_helper<_Pred...>(0));
39
40#if _LIBCPP_STD_VER > 14
41
42template <class...>
43struct conjunction : true_type {};
44
45template <class _Arg>
46struct conjunction<_Arg> : _Arg {};
47
48template <class _Arg, class... _Args>
49struct conjunction<_Arg, _Args...> : conditional_t<!bool(_Arg::value), _Arg, conjunction<_Args...>> {};
50
51template <class... _Args>
52inline constexpr bool conjunction_v = conjunction<_Args...>::value;
53
54#endif // _LIBCPP_STD_VER > 14
5455
5556_LIBCPP_END_NAMESPACE_STD
5657
lib/libcxx/include/__type_traits/copy_cvref.h+2-2
......@@ -29,13 +29,13 @@ struct __copy_cvref
2929template <class _From, class _To>
3030struct __copy_cvref<_From&, _To>
3131{
32 using type = typename add_lvalue_reference<__copy_cv_t<_From, _To> >::type;
32 using type = __add_lvalue_reference_t<__copy_cv_t<_From, _To> >;
3333};
3434
3535template <class _From, class _To>
3636struct __copy_cvref<_From&&, _To>
3737{
38 using type = typename add_rvalue_reference<__copy_cv_t<_From, _To> >::type;
38 using type = __add_rvalue_reference_t<__copy_cv_t<_From, _To> >;
3939};
4040
4141template <class _From, class _To>
lib/libcxx/include/__type_traits/decay.h+12-6
......@@ -12,7 +12,6 @@
1212#include <__config>
1313#include <__type_traits/add_pointer.h>
1414#include <__type_traits/conditional.h>
15#include <__type_traits/integral_constant.h>
1615#include <__type_traits/is_array.h>
1716#include <__type_traits/is_function.h>
1817#include <__type_traits/is_referenceable.h>
......@@ -26,9 +25,15 @@
2625
2726_LIBCPP_BEGIN_NAMESPACE_STD
2827
28#if __has_builtin(__decay)
29template <class _Tp>
30struct decay {
31 using type _LIBCPP_NODEBUG = __decay(_Tp);
32};
33#else
2934template <class _Up, bool>
3035struct __decay {
31 typedef _LIBCPP_NODEBUG typename remove_cv<_Up>::type type;
36 typedef _LIBCPP_NODEBUG __remove_cv_t<_Up> type;
3237};
3338
3439template <class _Up>
......@@ -37,12 +42,12 @@ public:
3742 typedef _LIBCPP_NODEBUG typename conditional
3843 <
3944 is_array<_Up>::value,
40 typename remove_extent<_Up>::type*,
45 __add_pointer_t<__remove_extent_t<_Up> >,
4146 typename conditional
4247 <
4348 is_function<_Up>::value,
4449 typename add_pointer<_Up>::type,
45 typename remove_cv<_Up>::type
50 __remove_cv_t<_Up>
4651 >::type
4752 >::type type;
4853};
......@@ -51,10 +56,11 @@ template <class _Tp>
5156struct _LIBCPP_TEMPLATE_VIS decay
5257{
5358private:
54 typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type _Up;
59 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tp> _Up;
5560public:
56 typedef _LIBCPP_NODEBUG typename __decay<_Up, __is_referenceable<_Up>::value>::type type;
61 typedef _LIBCPP_NODEBUG typename __decay<_Up, __libcpp_is_referenceable<_Up>::value>::type type;
5762};
63#endif // __has_builtin(__decay)
5864
5965#if _LIBCPP_STD_VER > 11
6066template <class _Tp> using decay_t = typename decay<_Tp>::type;
lib/libcxx/include/__type_traits/dependent_type.h created+25
......@@ -0,0 +1,25 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_DEPENDENT_TYPE_H
10#define _LIBCPP___TYPE_TRAITS_DEPENDENT_TYPE_H
11
12#include <__config>
13
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# pragma GCC system_header
16#endif
17
18_LIBCPP_BEGIN_NAMESPACE_STD
19
20template <class _Tp, bool>
21struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};
22
23_LIBCPP_END_NAMESPACE_STD
24
25#endif // _LIBCPP___TYPE_TRAITS_DEPENDENT_TYPE_H
lib/libcxx/include/__type_traits/disjunction.h+6-1
......@@ -10,7 +10,6 @@
1010#define _LIBCPP___TYPE_TRAITS_DISJUNCTION_H
1111
1212#include <__config>
13#include <__type_traits/conditional.h>
1413#include <__type_traits/integral_constant.h>
1514
1615#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -35,6 +34,12 @@ struct _OrImpl<false> {
3534 using _Result = _Res;
3635};
3736
37// _Or always performs lazy evaluation of its arguments.
38//
39// However, `_Or<_Pred...>` itself will evaluate its result immediately (without having to
40// be instantiated) since it is an alias, unlike `disjunction<_Pred...>`, which is a struct.
41// If you want to defer the evaluation of `_Or<_Pred...>` itself, use `_Lazy<_Or, _Pred...>`
42// or `disjunction<_Pred...>` directly.
3843template <class... _Args>
3944using _Or _LIBCPP_NODEBUG = typename _OrImpl<sizeof...(_Args) != 0>::template _Result<false_type, _Args...>;
4045
lib/libcxx/include/__type_traits/has_virtual_destructor.h+1-10
......@@ -18,21 +18,12 @@
1818
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if __has_builtin(__has_virtual_destructor)
22
2321template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
2422 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
2523
26#else
27
28template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
29 : public false_type {};
30
31#endif
32
3324#if _LIBCPP_STD_VER > 14
3425template <class _Tp>
35inline constexpr bool has_virtual_destructor_v = has_virtual_destructor<_Tp>::value;
26inline constexpr bool has_virtual_destructor_v = __has_virtual_destructor(_Tp);
3627#endif
3728
3829_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_allocator.h created+36
......@@ -0,0 +1,36 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_IS_ALLOCATOR_H
10#define _LIBCPP___TYPE_IS_ALLOCATOR_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/void_t.h>
15#include <__utility/declval.h>
16#include <cstddef>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24template<typename _Alloc, typename = void, typename = void>
25struct __is_allocator : false_type {};
26
27template<typename _Alloc>
28struct __is_allocator<_Alloc,
29 __void_t<typename _Alloc::value_type>,
30 __void_t<decltype(std::declval<_Alloc&>().allocate(size_t(0)))>
31 >
32 : true_type {};
33
34_LIBCPP_END_NAMESPACE_STD
35
36#endif // _LIBCPP___TYPE_IS_ALLOCATOR_H
lib/libcxx/include/__type_traits/is_always_bitcastable.h created+82
......@@ -0,0 +1,82 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_ALWAYS_BITCASTABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_ALWAYS_BITCASTABLE_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_integral.h>
15#include <__type_traits/is_object.h>
16#include <__type_traits/is_same.h>
17#include <__type_traits/is_trivially_copyable.h>
18#include <__type_traits/remove_cv.h>
19
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header
22#endif
23
24_LIBCPP_BEGIN_NAMESPACE_STD
25
26// Checks whether an object of type `From` can always be bit-cast to an object of type `To` and represent a valid value
27// of type `To`. In other words, `From` and `To` have the same value representation and the set of values of `From` is
28// a subset of the set of values of `To`.
29//
30// Note that types that cannot be assigned to each other using built-in assignment (e.g. arrays) might still be
31// considered bit-castable.
32template <class _From, class _To>
33struct __is_always_bitcastable {
34 using _UnqualFrom = __remove_cv_t<_From>;
35 using _UnqualTo = __remove_cv_t<_To>;
36
37 static const bool value =
38 // First, the simple case -- `From` and `To` are the same object type.
39 (is_same<_UnqualFrom, _UnqualTo>::value && is_trivially_copyable<_UnqualFrom>::value) ||
40
41 // Beyond the simple case, we say that one type is "always bit-castable" to another if:
42 // - (1) `From` and `To` have the same value representation, and in addition every possible value of `From` has
43 // a corresponding value in the `To` type (in other words, the set of values of `To` is a superset of the set of
44 // values of `From`);
45 // - (2) When the corresponding values are not the same value (as, for example, between an unsigned and a signed
46 // integer, where a large positive value of the unsigned integer corresponds to a negative value in the signed
47 // integer type), the value of `To` that results from a bitwise copy of `From` is the same what would be produced
48 // by the built-in assignment (if it were defined for the two types, to which there are minor exceptions, e.g.
49 // built-in arrays).
50 //
51 // In practice, that means:
52 // - all integral types (except `bool`, see below) -- that is, character types and `int` types, both signed and
53 // unsigned...
54 // - as well as arrays of such types...
55 // - ...that have the same size.
56 //
57 // Other trivially-copyable types can't be validly bit-cast outside of their own type:
58 // - floating-point types normally have different sizes and thus aren't bit-castable between each other (fails #1);
59 // - integral types and floating-point types use different representations, so for example bit-casting an integral
60 // `1` to `float` results in a very small less-than-one value, unlike built-in assignment that produces `1.0`
61 // (fails #2);
62 // - booleans normally use only a single bit of their object representation; bit-casting an integer to a boolean
63 // will result in a boolean object with an incorrect representation, which is undefined behavior (fails #2).
64 // Bit-casting from a boolean into an integer, however, is valid;
65 // - enumeration types may have different ranges of possible values (fails #1);
66 // - for pointers, it is not guaranteed that pointers to different types use the same set of values to represent
67 // addresses, and the conversion results are explicitly unspecified for types with different alignments
68 // (fails #1);
69 // - for structs and unions it is impossible to determine whether the set of values of one of them is a subset of
70 // the other (fails #1);
71 // - there is no need to consider `nullptr_t` for practical purposes.
72 (
73 sizeof(_From) == sizeof(_To) &&
74 is_integral<_From>::value &&
75 is_integral<_To>::value &&
76 !is_same<_UnqualTo, bool>::value
77 );
78};
79
80_LIBCPP_END_NAMESPACE_STD
81
82#endif // _LIBCPP___TYPE_TRAITS_IS_ALWAYS_BITCASTABLE_H
lib/libcxx/include/__type_traits/is_assignable.h-35
......@@ -18,10 +18,6 @@
1818
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG _Tp type; };
22
23#if __has_builtin(__is_assignable)
24
2521template<class _Tp, class _Up>
2622struct _LIBCPP_TEMPLATE_VIS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> { };
2723
......@@ -30,37 +26,6 @@ template <class _Tp, class _Arg>
3026inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Arg);
3127#endif
3228
33#else // __has_builtin(__is_assignable)
34
35template <class _Tp, class _Arg>
36typename __select_2nd<decltype((declval<_Tp>() = declval<_Arg>())), true_type>::type
37__is_assignable_test(int);
38
39template <class, class>
40false_type __is_assignable_test(...);
41
42
43template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
44struct __is_assignable_imp
45 : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
46
47template <class _Tp, class _Arg>
48struct __is_assignable_imp<_Tp, _Arg, true>
49 : public false_type
50{
51};
52
53template <class _Tp, class _Arg>
54struct is_assignable
55 : public __is_assignable_imp<_Tp, _Arg> {};
56
57#if _LIBCPP_STD_VER > 14
58template <class _Tp, class _Arg>
59inline constexpr bool is_assignable_v = is_assignable<_Tp, _Arg>::value;
60#endif
61
62#endif // __has_builtin(__is_assignable)
63
6429_LIBCPP_END_NAMESPACE_STD
6530
6631#endif // _LIBCPP___TYPE_TRAITS_IS_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_callable.h+1-1
......@@ -25,7 +25,7 @@ template<class...>
2525false_type __is_callable_helper(...);
2626
2727template<class _Func, class... _Args>
28struct __is_callable : decltype(__is_callable_helper<_Func, _Args...>(0)) {};
28struct __is_callable : decltype(std::__is_callable_helper<_Func, _Args...>(0)) {};
2929
3030_LIBCPP_END_NAMESPACE_STD
3131
lib/libcxx/include/__type_traits/is_char_like_type.h created+28
......@@ -0,0 +1,28 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_CHAR_LIKE_TYPE_H
10#define _LIBCPP___TYPE_TRAITS_IS_CHAR_LIKE_TYPE_H
11
12#include <__config>
13#include <__type_traits/conjunction.h>
14#include <__type_traits/is_standard_layout.h>
15#include <__type_traits/is_trivial.h>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23template <class _CharT>
24using _IsCharLikeType = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >;
25
26_LIBCPP_END_NAMESPACE_STD
27
28#endif // _LIBCPP___TYPE_TRAITS_IS_CHAR_LIKE_TYPE_H
lib/libcxx/include/__type_traits/is_class.h-2
......@@ -11,8 +11,6 @@
1111
1212#include <__config>
1313#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_union.h>
15#include <__type_traits/remove_cv.h>
1614
1715#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1816# pragma GCC system_header
lib/libcxx/include/__type_traits/is_constant_evaluated.h+1-1
......@@ -24,7 +24,7 @@ inline constexpr bool is_constant_evaluated() noexcept {
2424}
2525#endif
2626
27inline _LIBCPP_CONSTEXPR
27_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR
2828bool __libcpp_is_constant_evaluated() _NOEXCEPT { return __builtin_is_constant_evaluated(); }
2929
3030_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_constructible.h+1-1
......@@ -25,7 +25,7 @@ struct _LIBCPP_TEMPLATE_VIS is_constructible
2525
2626#if _LIBCPP_STD_VER > 14
2727template <class _Tp, class ..._Args>
28inline constexpr bool is_constructible_v = is_constructible<_Tp, _Args...>::value;
28inline constexpr bool is_constructible_v = __is_constructible(_Tp, _Args...);
2929#endif
3030
3131_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_convertible.h+2-2
......@@ -40,7 +40,7 @@ struct __is_convertible_test : public false_type {};
4040
4141template <class _From, class _To>
4242struct __is_convertible_test<_From, _To,
43 decltype(__is_convertible_imp::__test_convert<_To>(declval<_From>()))> : public true_type
43 decltype(__is_convertible_imp::__test_convert<_To>(std::declval<_From>()))> : public true_type
4444{};
4545
4646template <class _Tp, bool _IsArray = is_array<_Tp>::value,
......@@ -53,7 +53,7 @@ template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true>
5353}
5454
5555template <class _Tp,
56 unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
56 unsigned = __is_convertible_imp::__is_array_function_or_void<__libcpp_remove_reference_t<_Tp> >::value>
5757struct __is_convertible_check
5858{
5959 static const size_t __v = 0;
lib/libcxx/include/__type_traits/is_copy_assignable.h+6-4
......@@ -13,7 +13,6 @@
1313#include <__type_traits/add_const.h>
1414#include <__type_traits/add_lvalue_reference.h>
1515#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_assignable.h>
1716
1817#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1918# pragma GCC system_header
......@@ -21,9 +20,12 @@
2120
2221_LIBCPP_BEGIN_NAMESPACE_STD
2322
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
25 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
26 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
23template <class _Tp>
24struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
25 : public integral_constant<
26 bool,
27 __is_assignable(__add_lvalue_reference_t<_Tp>,
28 __add_lvalue_reference_t<typename add_const<_Tp>::type>)> {};
2729
2830#if _LIBCPP_STD_VER > 14
2931template <class _Tp>
lib/libcxx/include/__type_traits/is_copy_constructible.h+3-3
......@@ -13,7 +13,6 @@
1313#include <__type_traits/add_const.h>
1414#include <__type_traits/add_lvalue_reference.h>
1515#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_constructible.h>
1716
1817#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1918# pragma GCC system_header
......@@ -23,8 +22,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2322
2423template <class _Tp>
2524struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
26 : public is_constructible<_Tp,
27 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
25 : public integral_constant<
26 bool,
27 __is_constructible(_Tp, __add_lvalue_reference_t<typename add_const<_Tp>::type>)> {};
2828
2929#if _LIBCPP_STD_VER > 14
3030template <class _Tp>
lib/libcxx/include/__type_traits/is_default_constructible.h+2-3
......@@ -11,7 +11,6 @@
1111
1212#include <__config>
1313#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_constructible.h>
1514
1615#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1716# pragma GCC system_header
......@@ -21,12 +20,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2120
2221template <class _Tp>
2322struct _LIBCPP_TEMPLATE_VIS is_default_constructible
24 : public is_constructible<_Tp>
23 : public integral_constant<bool, __is_constructible(_Tp)>
2524 {};
2625
2726#if _LIBCPP_STD_VER > 14
2827template <class _Tp>
29inline constexpr bool is_default_constructible_v = is_default_constructible<_Tp>::value;
28inline constexpr bool is_default_constructible_v = __is_constructible(_Tp);
3029#endif
3130
3231_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_destructible.h+2-2
......@@ -48,7 +48,7 @@ template <typename _Tp>
4848struct __is_destructor_wellformed {
4949 template <typename _Tp1>
5050 static true_type __test (
51 typename __is_destructible_apply<decltype(declval<_Tp1&>().~_Tp1())>::type
51 typename __is_destructible_apply<decltype(std::declval<_Tp1&>().~_Tp1())>::type
5252 );
5353
5454 template <typename _Tp1>
......@@ -63,7 +63,7 @@ struct __destructible_imp;
6363template <class _Tp>
6464struct __destructible_imp<_Tp, false>
6565 : public integral_constant<bool,
66 __is_destructor_wellformed<typename remove_all_extents<_Tp>::type>::value> {};
66 __is_destructor_wellformed<__remove_all_extents_t<_Tp> >::value> {};
6767
6868template <class _Tp>
6969struct __destructible_imp<_Tp, true>
lib/libcxx/include/__type_traits/is_enum.h-1
......@@ -11,7 +11,6 @@
1111
1212#include <__config>
1313#include <__type_traits/integral_constant.h>
14#include <__type_traits/remove_cv.h>
1514
1615#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1716# pragma GCC system_header
lib/libcxx/include/__type_traits/is_floating_point.h+1-1
......@@ -25,7 +25,7 @@ template <> struct __libcpp_is_floating_point<double> : public tru
2525template <> struct __libcpp_is_floating_point<long double> : public true_type {};
2626
2727template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point
28 : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
28 : public __libcpp_is_floating_point<__remove_cv_t<_Tp> > {};
2929
3030#if _LIBCPP_STD_VER > 14
3131template <class _Tp>
lib/libcxx/include/__type_traits/is_implicitly_default_constructible.h created+48
......@@ -0,0 +1,48 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_IMPLICITLY_DEFAULT_CONSTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_IMPLICITLY_DEFAULT_CONSTRUCTIBLE_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_default_constructible.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22#ifndef _LIBCPP_CXX03_LANG
23// First of all, we can't implement this check in C++03 mode because the {}
24// default initialization syntax isn't valid.
25// Second, we implement the trait in a funny manner with two defaulted template
26// arguments to workaround Clang's PR43454.
27template <class _Tp>
28void __test_implicit_default_constructible(_Tp);
29
30template <class _Tp, class = void, class = typename is_default_constructible<_Tp>::type>
31struct __is_implicitly_default_constructible
32 : false_type
33{ };
34
35template <class _Tp>
36struct __is_implicitly_default_constructible<_Tp, decltype(std::__test_implicit_default_constructible<_Tp const&>({})), true_type>
37 : true_type
38{ };
39
40template <class _Tp>
41struct __is_implicitly_default_constructible<_Tp, decltype(std::__test_implicit_default_constructible<_Tp const&>({})), false_type>
42 : false_type
43{ };
44#endif // !C++03
45
46_LIBCPP_END_NAMESPACE_STD
47
48#endif // _LIBCPP___TYPE_TRAITS_IS_IMPLICITLY_DEFAULT_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_integral.h+1-1
......@@ -58,7 +58,7 @@ inline constexpr bool is_integral_v = __is_integral(_Tp);
5858#else
5959
6060template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral
61 : public _BoolConstant<__libcpp_is_integral<typename remove_cv<_Tp>::type>::value> {};
61 : public _BoolConstant<__libcpp_is_integral<__remove_cv_t<_Tp> >::value> {};
6262
6363#if _LIBCPP_STD_VER > 14
6464template <class _Tp>
lib/libcxx/include/__type_traits/is_literal_type.h+1-1
......@@ -25,7 +25,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 is_
2525
2626#if _LIBCPP_STD_VER > 14
2727template <class _Tp>
28_LIBCPP_DEPRECATED_IN_CXX17 inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value;
28_LIBCPP_DEPRECATED_IN_CXX17 inline constexpr bool is_literal_type_v = __is_literal_type(_Tp);
2929#endif // _LIBCPP_STD_VER > 14
3030#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
3131
lib/libcxx/include/__type_traits/is_member_function_pointer.h+1-1
......@@ -50,7 +50,7 @@ inline constexpr bool is_member_function_pointer_v = __is_member_function_pointe
5050#else // __has_builtin(__is_member_function_pointer)
5151
5252template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
53 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_func > {};
53 : public _BoolConstant< __libcpp_is_member_pointer<__remove_cv_t<_Tp> >::__is_func > {};
5454
5555#if _LIBCPP_STD_VER > 14
5656template <class _Tp>
lib/libcxx/include/__type_traits/is_member_object_pointer.h+1-1
......@@ -32,7 +32,7 @@ inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_T
3232#else // __has_builtin(__is_member_object_pointer)
3333
3434template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
35 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_obj > {};
35 : public _BoolConstant< __libcpp_is_member_pointer<__remove_cv_t<_Tp> >::__is_obj > {};
3636
3737#if _LIBCPP_STD_VER > 14
3838template <class _Tp>
lib/libcxx/include/__type_traits/is_member_pointer.h+2-1
......@@ -11,6 +11,7 @@
1111
1212#include <__config>
1313#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_member_function_pointer.h>
1415
1516#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1617# pragma GCC system_header
......@@ -31,7 +32,7 @@ inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp);
3132#else // __has_builtin(__is_member_pointer)
3233
3334template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer
34 : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_member > {};
35 : public _BoolConstant< __libcpp_is_member_pointer<__remove_cv_t<_Tp> >::__is_member > {};
3536
3637#if _LIBCPP_STD_VER > 14
3738template <class _Tp>
lib/libcxx/include/__type_traits/is_move_assignable.h+5-5
......@@ -10,11 +10,9 @@
1010#define _LIBCPP___TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H
1111
1212#include <__config>
13#include <__type_traits/add_const.h>
1413#include <__type_traits/add_lvalue_reference.h>
1514#include <__type_traits/add_rvalue_reference.h>
1615#include <__type_traits/integral_constant.h>
17#include <__type_traits/is_assignable.h>
1816
1917#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2018# pragma GCC system_header
......@@ -22,9 +20,11 @@
2220
2321_LIBCPP_BEGIN_NAMESPACE_STD
2422
25template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable
26 : public is_assignable<typename add_lvalue_reference<_Tp>::type,
27 typename add_rvalue_reference<_Tp>::type> {};
23template <class _Tp>
24struct _LIBCPP_TEMPLATE_VIS is_move_assignable
25 : public integral_constant<
26 bool,
27 __is_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {};
2828
2929#if _LIBCPP_STD_VER > 14
3030template <class _Tp>
lib/libcxx/include/__type_traits/is_move_constructible.h+1-2
......@@ -12,7 +12,6 @@
1212#include <__config>
1313#include <__type_traits/add_rvalue_reference.h>
1414#include <__type_traits/integral_constant.h>
15#include <__type_traits/is_constructible.h>
1615
1716#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1817# pragma GCC system_header
......@@ -22,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2221
2322template <class _Tp>
2423struct _LIBCPP_TEMPLATE_VIS is_move_constructible
25 : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
24 : public integral_constant<bool, __is_constructible(_Tp, __add_rvalue_reference_t<_Tp>)>
2625 {};
2726
2827#if _LIBCPP_STD_VER > 14
lib/libcxx/include/__type_traits/is_nothrow_assignable.h+1-28
......@@ -10,7 +10,6 @@
1010#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H
1111
1212#include <__config>
13#include <__type_traits/add_const.h>
1413#include <__type_traits/integral_constant.h>
1514
1615#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -19,39 +18,13 @@
1918
2019_LIBCPP_BEGIN_NAMESPACE_STD
2120
22#if __has_builtin(__is_nothrow_assignable)
23
2421template <class _Tp, class _Arg>
2522struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
2623 : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {};
2724
28#else
29
30template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
31
32template <class _Tp, class _Arg>
33struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
34 : public false_type
35{
36};
37
38template <class _Tp, class _Arg>
39struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
40 : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Arg>()) >
41{
42};
43
44template <class _Tp, class _Arg>
45struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
46 : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
47{
48};
49
50#endif // __has_builtin(__is_nothrow_assignable)
51
5225#if _LIBCPP_STD_VER > 14
5326template <class _Tp, class _Arg>
54inline constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<_Tp, _Arg>::value;
27inline constexpr bool is_nothrow_assignable_v = __is_nothrow_assignable(_Tp, _Arg);
5528#endif
5629
5730_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_nothrow_constructible.h+7-4
......@@ -11,7 +11,10 @@
1111
1212#include <__config>
1313#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_constructible.h>
15#include <__type_traits/is_reference.h>
1416#include <__utility/declval.h>
17#include <cstddef>
1518
1619#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1720# pragma GCC system_header
......@@ -21,17 +24,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2124
2225#if __has_builtin(__is_nothrow_constructible)
2326
24template <class _Tp, class... _Args>
27template <
28 class _Tp, class... _Args>
2529struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
2630 : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {};
27
2831#else
2932
3033template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
3134
3235template <class _Tp, class... _Args>
3336struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
34 : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
37 : public integral_constant<bool, noexcept(_Tp(std::declval<_Args>()...))>
3538{
3639};
3740
......@@ -40,7 +43,7 @@ void __implicit_conversion_to(_Tp) noexcept { }
4043
4144template <class _Tp, class _Arg>
4245struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
43 : public integral_constant<bool, noexcept(_VSTD::__implicit_conversion_to<_Tp>(declval<_Arg>()))>
46 : public integral_constant<bool, noexcept(_VSTD::__implicit_conversion_to<_Tp>(std::declval<_Arg>()))>
4447{
4548};
4649
lib/libcxx/include/__type_traits/is_nothrow_convertible.h+1-1
......@@ -30,7 +30,7 @@ template <typename _Tp>
3030static void __test_noexcept(_Tp) noexcept;
3131
3232template<typename _Fm, typename _To>
33static bool_constant<noexcept(_VSTD::__test_noexcept<_To>(declval<_Fm>()))>
33static bool_constant<noexcept(_VSTD::__test_noexcept<_To>(std::declval<_Fm>()))>
3434__is_nothrow_convertible_test();
3535
3636template <typename _Fm, typename _To>
lib/libcxx/include/__type_traits/is_nothrow_copy_assignable.h+7-4
......@@ -13,7 +13,6 @@
1313#include <__type_traits/add_const.h>
1414#include <__type_traits/add_lvalue_reference.h>
1515#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_nothrow_assignable.h>
1716
1817#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1918# pragma GCC system_header
......@@ -21,9 +20,13 @@
2120
2221_LIBCPP_BEGIN_NAMESPACE_STD
2322
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
25 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
26 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
23template <class _Tp>
24struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
25 : public integral_constant<
26 bool,
27 __is_nothrow_assignable(
28 __add_lvalue_reference_t<_Tp>,
29 __add_lvalue_reference_t<typename add_const<_Tp>::type>)> {};
2730
2831#if _LIBCPP_STD_VER > 14
2932template <class _Tp>
lib/libcxx/include/__type_traits/is_nothrow_copy_constructible.h+14-1
......@@ -21,9 +21,22 @@
2121
2222_LIBCPP_BEGIN_NAMESPACE_STD
2323
24// TODO: remove this implementation once https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611 is fixed
25#ifdef _LIBCPP_COMPILER_GCC
26
2427template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
2528 : public is_nothrow_constructible<_Tp,
26 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
29 __add_lvalue_reference_t<typename add_const<_Tp>::type> > {};
30
31#else // _LIBCPP_COMPILER_GCC
32
33template <class _Tp>
34struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
35 : public integral_constant<
36 bool,
37 __is_nothrow_constructible(_Tp, typename add_lvalue_reference<typename add_const<_Tp>::type>::type)> {};
38
39#endif // _LIBCPP_COMPILER_GCC
2740
2841#if _LIBCPP_STD_VER > 14
2942template <class _Tp>
lib/libcxx/include/__type_traits/is_nothrow_default_constructible.h+2-3
......@@ -11,7 +11,6 @@
1111
1212#include <__config>
1313#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_nothrow_constructible.h>
1514
1615#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1716# pragma GCC system_header
......@@ -20,12 +19,12 @@
2019_LIBCPP_BEGIN_NAMESPACE_STD
2120
2221template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible
23 : public is_nothrow_constructible<_Tp>
22 : public integral_constant<bool, __is_nothrow_constructible(_Tp)>
2423 {};
2524
2625#if _LIBCPP_STD_VER > 14
2726template <class _Tp>
28inline constexpr bool is_nothrow_default_constructible_v = is_nothrow_default_constructible<_Tp>::value;
27inline constexpr bool is_nothrow_default_constructible_v = __is_nothrow_constructible(_Tp);
2928#endif
3029
3130_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_nothrow_destructible.h+2-3
......@@ -10,7 +10,6 @@
1010#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DESTRUCTIBLE_H
1111
1212#include <__config>
13#include <__type_traits/add_const.h>
1413#include <__type_traits/integral_constant.h>
1514#include <__type_traits/is_destructible.h>
1615#include <__type_traits/is_reference.h>
......@@ -37,7 +36,7 @@ struct __libcpp_is_nothrow_destructible<false, _Tp>
3736
3837template <class _Tp>
3938struct __libcpp_is_nothrow_destructible<true, _Tp>
40 : public integral_constant<bool, noexcept(declval<_Tp>().~_Tp()) >
39 : public integral_constant<bool, noexcept(std::declval<_Tp>().~_Tp()) >
4140{
4241};
4342
......@@ -72,7 +71,7 @@ template <class _Tp> struct __libcpp_nothrow_destructor
7271 is_reference<_Tp>::value> {};
7372
7473template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible
75 : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
74 : public __libcpp_nothrow_destructor<__remove_all_extents_t<_Tp> > {};
7675
7776template <class _Tp>
7877struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>
lib/libcxx/include/__type_traits/is_nothrow_move_assignable.h+6-5
......@@ -13,7 +13,6 @@
1313#include <__type_traits/add_lvalue_reference.h>
1414#include <__type_traits/add_rvalue_reference.h>
1515#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_nothrow_assignable.h>
1716
1817#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1918# pragma GCC system_header
......@@ -21,10 +20,12 @@
2120
2221_LIBCPP_BEGIN_NAMESPACE_STD
2322
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
25 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
26 typename add_rvalue_reference<_Tp>::type>
27 {};
23template <class _Tp>
24struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
25 : public integral_constant<
26 bool,
27 __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {
28};
2829
2930#if _LIBCPP_STD_VER > 14
3031template <class _Tp>
lib/libcxx/include/__type_traits/is_nothrow_move_constructible.h+12-1
......@@ -20,10 +20,21 @@
2020
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
23// TODO: remove this implementation once https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611 is fixed
24#ifndef _LIBCPP_COMPILER_GCC
25
26template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
27 : public integral_constant<bool, __is_nothrow_constructible(_Tp, __add_rvalue_reference_t<_Tp>)>
28 {};
29
30#else // _LIBCPP_COMPILER_GCC
31
2332template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
24 : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
33 : public is_nothrow_constructible<_Tp, __add_rvalue_reference_t<_Tp> >
2534 {};
2635
36#endif // _LIBCPP_COMPILER_GCC
37
2738#if _LIBCPP_STD_VER > 14
2839template <class _Tp>
2940inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value;
lib/libcxx/include/__type_traits/is_null_pointer.h+2-2
......@@ -24,11 +24,11 @@ template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
2424template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
2525
2626template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t
27 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
27 : public __is_nullptr_t_impl<__remove_cv_t<_Tp> > {};
2828
2929#if _LIBCPP_STD_VER > 11
3030template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer
31 : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
31 : public __is_nullptr_t_impl<__remove_cv_t<_Tp> > {};
3232
3333#if _LIBCPP_STD_VER > 14
3434template <class _Tp>
lib/libcxx/include/__type_traits/is_pod.h+1-13
......@@ -18,24 +18,12 @@
1818
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if __has_builtin(__is_pod)
22
2321template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
2422 : public integral_constant<bool, __is_pod(_Tp)> {};
2523
26#else
27
28template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
29 : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value &&
30 is_trivially_copy_constructible<_Tp>::value &&
31 is_trivially_copy_assignable<_Tp>::value &&
32 is_trivially_destructible<_Tp>::value> {};
33
34#endif // __has_builtin(__is_pod)
35
3624#if _LIBCPP_STD_VER > 14
3725template <class _Tp>
38inline constexpr bool is_pod_v = is_pod<_Tp>::value;
26inline constexpr bool is_pod_v = __is_pod(_Tp);
3927#endif
4028
4129_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_pointer.h+1-1
......@@ -43,7 +43,7 @@ template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretai
4343#endif
4444
4545template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer
46 : public __libcpp_is_pointer<typename __libcpp_remove_objc_qualifiers<typename remove_cv<_Tp>::type>::type> {};
46 : public __libcpp_is_pointer<typename __libcpp_remove_objc_qualifiers<__remove_cv_t<_Tp> >::type> {};
4747
4848#if _LIBCPP_STD_VER > 14
4949template <class _Tp>
lib/libcxx/include/__type_traits/is_reference_wrapper.h+1-1
......@@ -24,7 +24,7 @@ template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper;
2424template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
2525template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
2626template <class _Tp> struct __is_reference_wrapper
27 : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
27 : public __is_reference_wrapper_impl<__remove_cv_t<_Tp> > {};
2828
2929_LIBCPP_END_NAMESPACE_STD
3030
lib/libcxx/include/__type_traits/is_referenceable.h+13-5
......@@ -19,14 +19,22 @@
1919
2020_LIBCPP_BEGIN_NAMESPACE_STD
2121
22struct __is_referenceable_impl {
23 template <class _Tp> static _Tp& __test(int);
24 template <class _Tp> static false_type __test(...);
22#if __has_builtin(__is_referenceable)
23template <class _Tp>
24struct __libcpp_is_referenceable : integral_constant<bool, __is_referenceable(_Tp)> {};
25#else
26struct __libcpp_is_referenceable_impl {
27 template <class _Tp>
28 static _Tp& __test(int);
29 template <class _Tp>
30 static false_type __test(...);
2531};
2632
2733template <class _Tp>
28struct __is_referenceable : integral_constant<bool,
29 _IsNotSame<decltype(__is_referenceable_impl::__test<_Tp>(0)), false_type>::value> {};
34struct __libcpp_is_referenceable
35 : integral_constant<bool, _IsNotSame<decltype(__libcpp_is_referenceable_impl::__test<_Tp>(0)), false_type>::value> {
36};
37#endif // __has_builtin(__is_referenceable)
3038
3139_LIBCPP_END_NAMESPACE_STD
3240
lib/libcxx/include/__type_traits/is_scalar.h+1
......@@ -14,6 +14,7 @@
1414#include <__type_traits/is_arithmetic.h>
1515#include <__type_traits/is_enum.h>
1616#include <__type_traits/is_member_pointer.h>
17#include <__type_traits/is_null_pointer.h>
1718#include <__type_traits/is_pointer.h>
1819
1920#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__type_traits/is_signed.h+2
......@@ -11,6 +11,8 @@
1111
1212#include <__config>
1313#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_arithmetic.h>
15#include <__type_traits/is_integral.h>
1416
1517#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1618# pragma GCC system_header
lib/libcxx/include/__type_traits/is_specialization.h created+45
......@@ -0,0 +1,45 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___TYPE_TRAITS_IS_SPECIALIZATION
11#define _LIBCPP___TYPE_TRAITS_IS_SPECIALIZATION
12
13// This contains parts of P2098R1 but is based on MSVC STL's implementation.
14//
15// The paper has been rejected
16// We will not pursue P2098R0 (std::is_specialization_of) at this time; we'd
17// like to see a solution to this problem, but it requires language evolution
18// too.
19//
20// Since it is expected a real solution will be provided in the future only the
21// minimal part is implemented.
22//
23// Note a cvref qualified _Tp is never considered a specialization.
24
25#include <__config>
26
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header
29#endif
30
31_LIBCPP_BEGIN_NAMESPACE_STD
32
33#if _LIBCPP_STD_VER > 14
34
35template <class _Tp, template <class...> class _Template>
36inline constexpr bool __is_specialization_v = false; // true if and only if _Tp is a specialization of _Template
37
38template <template <class...> class _Template, class... _Args>
39inline constexpr bool __is_specialization_v<_Template<_Args...>, _Template> = true;
40
41#endif // _LIBCPP_STD_VER > 14
42
43_LIBCPP_END_NAMESPACE_STD
44
45#endif // _LIBCPP___TYPE_TRAITS_IS_SPECIALIZATION
lib/libcxx/include/__type_traits/is_standard_layout.h+1-5
......@@ -19,16 +19,12 @@
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
2121template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
22#if __has_builtin(__is_standard_layout)
2322 : public integral_constant<bool, __is_standard_layout(_Tp)>
24#else
25 : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
26#endif
2723 {};
2824
2925#if _LIBCPP_STD_VER > 14
3026template <class _Tp>
31inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value;
27inline constexpr bool is_standard_layout_v = __is_standard_layout(_Tp);
3228#endif
3329
3430_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_swappable.h created+165
......@@ -0,0 +1,165 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_SWAPPABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_SWAPPABLE_H
11
12#include <__config>
13#include <__type_traits/add_lvalue_reference.h>
14#include <__type_traits/conditional.h>
15#include <__type_traits/enable_if.h>
16#include <__type_traits/is_move_assignable.h>
17#include <__type_traits/is_move_constructible.h>
18#include <__type_traits/is_nothrow_move_assignable.h>
19#include <__type_traits/is_nothrow_move_constructible.h>
20#include <__type_traits/is_referenceable.h>
21#include <__type_traits/is_same.h>
22#include <__type_traits/is_void.h>
23#include <__type_traits/nat.h>
24#include <__utility/declval.h>
25#include <cstddef>
26
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header
29#endif
30
31_LIBCPP_BEGIN_NAMESPACE_STD
32
33template <class _Tp> struct __is_swappable;
34template <class _Tp> struct __is_nothrow_swappable;
35
36
37#ifndef _LIBCPP_CXX03_LANG
38template <class _Tp>
39using __swap_result_t = typename enable_if<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>::type;
40#else
41template <class>
42using __swap_result_t = void;
43#endif
44
45template <class _Tp>
46inline _LIBCPP_INLINE_VISIBILITY
47_LIBCPP_CONSTEXPR_SINCE_CXX20 __swap_result_t<_Tp>
48swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
49 is_nothrow_move_assignable<_Tp>::value);
50
51template<class _Tp, size_t _Np>
52inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
53typename enable_if<
54 __is_swappable<_Tp>::value
55>::type
56swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
57
58namespace __detail
59{
60// ALL generic swap overloads MUST already have a declaration available at this point.
61
62template <class _Tp, class _Up = _Tp,
63 bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
64struct __swappable_with
65{
66 template <class _LHS, class _RHS>
67 static decltype(swap(std::declval<_LHS>(), std::declval<_RHS>()))
68 __test_swap(int);
69 template <class, class>
70 static __nat __test_swap(long);
71
72 // Extra parens are needed for the C++03 definition of decltype.
73 typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
74 typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
75
76 static const bool value = _IsNotSame<__swap1, __nat>::value
77 && _IsNotSame<__swap2, __nat>::value;
78};
79
80template <class _Tp, class _Up>
81struct __swappable_with<_Tp, _Up, false> : false_type {};
82
83template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
84struct __nothrow_swappable_with {
85 static const bool value =
86#ifndef _LIBCPP_HAS_NO_NOEXCEPT
87 noexcept(swap(std::declval<_Tp>(), std::declval<_Up>()))
88 && noexcept(swap(std::declval<_Up>(), std::declval<_Tp>()));
89#else
90 false;
91#endif
92};
93
94template <class _Tp, class _Up>
95struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
96
97} // namespace __detail
98
99template <class _Tp>
100struct __is_swappable
101 : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
102{
103};
104
105template <class _Tp>
106struct __is_nothrow_swappable
107 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
108{
109};
110
111#if _LIBCPP_STD_VER > 14
112
113template <class _Tp, class _Up>
114struct _LIBCPP_TEMPLATE_VIS is_swappable_with
115 : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value>
116{
117};
118
119template <class _Tp>
120struct _LIBCPP_TEMPLATE_VIS is_swappable
121 : public __conditional_t<
122 __libcpp_is_referenceable<_Tp>::value,
123 is_swappable_with<
124 __add_lvalue_reference_t<_Tp>,
125 __add_lvalue_reference_t<_Tp> >,
126 false_type
127 >
128{
129};
130
131template <class _Tp, class _Up>
132struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with
133 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value>
134{
135};
136
137template <class _Tp>
138struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable
139 : public __conditional_t<
140 __libcpp_is_referenceable<_Tp>::value,
141 is_nothrow_swappable_with<
142 __add_lvalue_reference_t<_Tp>,
143 __add_lvalue_reference_t<_Tp> >,
144 false_type
145 >
146{
147};
148
149template <class _Tp, class _Up>
150inline constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value;
151
152template <class _Tp>
153inline constexpr bool is_swappable_v = is_swappable<_Tp>::value;
154
155template <class _Tp, class _Up>
156inline constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<_Tp, _Up>::value;
157
158template <class _Tp>
159inline constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value;
160
161#endif // _LIBCPP_STD_VER > 14
162
163_LIBCPP_END_NAMESPACE_STD
164
165#endif // _LIBCPP___TYPE_TRAITS_IS_SWAPPABLE_H
lib/libcxx/include/__type_traits/is_trivial.h+1-6
......@@ -19,17 +19,12 @@
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
2121template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial
22#if __has_builtin(__is_trivial)
2322 : public integral_constant<bool, __is_trivial(_Tp)>
24#else
25 : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
26 is_trivially_default_constructible<_Tp>::value>
27#endif
2823 {};
2924
3025#if _LIBCPP_STD_VER > 14
3126template <class _Tp>
32inline constexpr bool is_trivial_v = is_trivial<_Tp>::value;
27inline constexpr bool is_trivial_v = __is_trivial(_Tp);
3328#endif
3429
3530_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_trivially_assignable.h+1-1
......@@ -25,7 +25,7 @@ struct is_trivially_assignable
2525
2626#if _LIBCPP_STD_VER > 14
2727template <class _Tp, class _Arg>
28inline constexpr bool is_trivially_assignable_v = is_trivially_assignable<_Tp, _Arg>::value;
28inline constexpr bool is_trivially_assignable_v = __is_trivially_assignable(_Tp, _Arg);
2929#endif
3030
3131_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_trivially_constructible.h+1-1
......@@ -26,7 +26,7 @@ struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
2626
2727#if _LIBCPP_STD_VER > 14
2828template <class _Tp, class... _Args>
29inline constexpr bool is_trivially_constructible_v = is_trivially_constructible<_Tp, _Args...>::value;
29inline constexpr bool is_trivially_constructible_v = __is_trivially_constructible(_Tp, _Args...);
3030#endif
3131
3232_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_trivially_copy_assignable.h+7-4
......@@ -13,7 +13,6 @@
1313#include <__type_traits/add_const.h>
1414#include <__type_traits/add_lvalue_reference.h>
1515#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_trivially_assignable.h>
1716
1817#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1918# pragma GCC system_header
......@@ -21,9 +20,13 @@
2120
2221_LIBCPP_BEGIN_NAMESPACE_STD
2322
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
25 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
26 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
23template <class _Tp>
24struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
25 : public integral_constant<
26 bool,
27 __is_trivially_assignable(
28 __add_lvalue_reference_t<_Tp>,
29 __add_lvalue_reference_t<typename add_const<_Tp>::type>)> {};
2730
2831#if _LIBCPP_STD_VER > 14
2932template <class _Tp>
lib/libcxx/include/__type_traits/is_trivially_copy_constructible.h+1-2
......@@ -12,7 +12,6 @@
1212#include <__config>
1313#include <__type_traits/add_lvalue_reference.h>
1414#include <__type_traits/integral_constant.h>
15#include <__type_traits/is_trivially_constructible.h>
1615
1716#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1817# pragma GCC system_header
......@@ -21,7 +20,7 @@
2120_LIBCPP_BEGIN_NAMESPACE_STD
2221
2322template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible
24 : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
23 : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)>
2524 {};
2625
2726#if _LIBCPP_STD_VER > 14
lib/libcxx/include/__type_traits/is_trivially_copyable.h+1-1
......@@ -24,7 +24,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable
2424
2525#if _LIBCPP_STD_VER > 14
2626template <class _Tp>
27inline constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value;
27inline constexpr bool is_trivially_copyable_v = __is_trivially_copyable(_Tp);
2828#endif
2929
3030_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_trivially_default_constructible.h+2-3
......@@ -11,7 +11,6 @@
1111
1212#include <__config>
1313#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_trivially_constructible.h>
1514
1615#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1716# pragma GCC system_header
......@@ -20,12 +19,12 @@
2019_LIBCPP_BEGIN_NAMESPACE_STD
2120
2221template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible
23 : public is_trivially_constructible<_Tp>
22 : public integral_constant<bool, __is_trivially_constructible(_Tp)>
2423 {};
2524
2625#if _LIBCPP_STD_VER > 14
2726template <class _Tp>
28inline constexpr bool is_trivially_default_constructible_v = is_trivially_default_constructible<_Tp>::value;
27inline constexpr bool is_trivially_default_constructible_v = __is_trivially_constructible(_Tp);
2928#endif
3029
3130_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_trivially_destructible.h+2-9
......@@ -11,6 +11,7 @@
1111
1212#include <__config>
1313#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_destructible.h>
1415
1516#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1617# pragma GCC system_header
......@@ -30,15 +31,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3031
3132#else
3233
33template <class _Tp> struct __libcpp_trivial_destructor
34 : public integral_constant<bool, is_scalar<_Tp>::value ||
35 is_reference<_Tp>::value> {};
36
37template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
38 : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
39
40template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]>
41 : public false_type {};
34#error is_trivially_destructible is not implemented
4235
4336#endif // __has_builtin(__is_trivially_destructible)
4437
lib/libcxx/include/__type_traits/is_trivially_move_assignable.h+5-5
......@@ -13,7 +13,6 @@
1313#include <__type_traits/add_lvalue_reference.h>
1414#include <__type_traits/add_rvalue_reference.h>
1515#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_trivially_assignable.h>
1716
1817#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1918# pragma GCC system_header
......@@ -21,10 +20,11 @@
2120
2221_LIBCPP_BEGIN_NAMESPACE_STD
2322
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
25 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
26 typename add_rvalue_reference<_Tp>::type>
27 {};
23template <class _Tp>
24struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
25 : public integral_constant<
26 bool,
27 __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {};
2828
2929#if _LIBCPP_STD_VER > 14
3030template <class _Tp>
lib/libcxx/include/__type_traits/is_trivially_move_constructible.h+3-4
......@@ -12,7 +12,6 @@
1212#include <__config>
1313#include <__type_traits/add_rvalue_reference.h>
1414#include <__type_traits/integral_constant.h>
15#include <__type_traits/is_trivially_constructible.h>
1615
1716#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1817# pragma GCC system_header
......@@ -20,9 +19,9 @@
2019
2120_LIBCPP_BEGIN_NAMESPACE_STD
2221
23template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
24 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
25 {};
22template <class _Tp>
23struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
24 : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {};
2625
2726#if _LIBCPP_STD_VER > 14
2827template <class _Tp>
lib/libcxx/include/__type_traits/is_union.h-1
......@@ -11,7 +11,6 @@
1111
1212#include <__config>
1313#include <__type_traits/integral_constant.h>
14#include <__type_traits/remove_cv.h>
1514
1615#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1716# pragma GCC system_header
lib/libcxx/include/__type_traits/is_unsigned.h+1-2
......@@ -20,8 +20,7 @@
2020
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
23// Before AppleClang 14, __is_unsigned returned true for enums with signed underlying type.
24#if __has_builtin(__is_unsigned) && !(defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1400)
23#if __has_builtin(__is_unsigned)
2524
2625template<class _Tp>
2726struct _LIBCPP_TEMPLATE_VIS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> { };
lib/libcxx/include/__type_traits/is_valid_expansion.h+1-1
......@@ -24,7 +24,7 @@ template <template <class...> class, class ...>
2424false_type __sfinae_test_impl(...);
2525
2626template <template <class ...> class _Templ, class ..._Args>
27using _IsValidExpansion _LIBCPP_NODEBUG = decltype(__sfinae_test_impl<_Templ, _Args...>(0));
27using _IsValidExpansion _LIBCPP_NODEBUG = decltype(std::__sfinae_test_impl<_Templ, _Args...>(0));
2828
2929_LIBCPP_END_NAMESPACE_STD
3030
lib/libcxx/include/__type_traits/is_void.h+3-1
......@@ -11,6 +11,8 @@
1111
1212#include <__config>
1313#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_same.h>
15#include <__type_traits/remove_cv.h>
1416
1517#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1618# pragma GCC system_header
......@@ -31,7 +33,7 @@ inline constexpr bool is_void_v = __is_void(_Tp);
3133#else
3234
3335template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void
34 : public is_same<typename remove_cv<_Tp>::type, void> {};
36 : public is_same<__remove_cv_t<_Tp>, void> {};
3537
3638#if _LIBCPP_STD_VER > 14
3739template <class _Tp>
lib/libcxx/include/__type_traits/make_const_lvalue_ref.h created+26
......@@ -0,0 +1,26 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_MAKE_CONST_LVALUE_REF_H
10#define _LIBCPP___TYPE_TRAITS_MAKE_CONST_LVALUE_REF_H
11
12#include <__config>
13#include <__type_traits/remove_reference.h>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20
21template<class _Tp>
22using __make_const_lvalue_ref = const __libcpp_remove_reference_t<_Tp>&;
23
24_LIBCPP_END_NAMESPACE_STD
25
26#endif // _LIBCPP___TYPE_TRAITS_MAKE_CONST_LVALUE_REF_H
lib/libcxx/include/__type_traits/make_signed.h+20-10
......@@ -23,19 +23,25 @@
2323
2424_LIBCPP_BEGIN_NAMESPACE_STD
2525
26#if __has_builtin(__make_signed)
27
28template <class _Tp>
29using __make_signed_t = __make_signed(_Tp);
30
31#else
2632typedef
2733 __type_list<signed char,
2834 __type_list<signed short,
2935 __type_list<signed int,
3036 __type_list<signed long,
3137 __type_list<signed long long,
32#ifndef _LIBCPP_HAS_NO_INT128
38# ifndef _LIBCPP_HAS_NO_INT128
3339 __type_list<__int128_t,
34#endif
40# endif
3541 __nat
36#ifndef _LIBCPP_HAS_NO_INT128
42# ifndef _LIBCPP_HAS_NO_INT128
3743 >
38#endif
44# endif
3945 > > > > > __signed_types;
4046
4147template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
......@@ -56,19 +62,23 @@ template <> struct __make_signed< signed long, true> {typedef long ty
5662template <> struct __make_signed<unsigned long, true> {typedef long type;};
5763template <> struct __make_signed< signed long long, true> {typedef long long type;};
5864template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
59#ifndef _LIBCPP_HAS_NO_INT128
65# ifndef _LIBCPP_HAS_NO_INT128
6066template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
6167template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
62#endif
68# endif
6369
6470template <class _Tp>
65struct _LIBCPP_TEMPLATE_VIS make_signed
66{
67 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
71using __make_signed_t = typename __apply_cv<_Tp, typename __make_signed<__remove_cv_t<_Tp> >::type>::type;
72
73#endif // __has_builtin(__make_signed)
74
75template <class _Tp>
76struct make_signed {
77 using type _LIBCPP_NODEBUG = __make_signed_t<_Tp>;
6878};
6979
7080#if _LIBCPP_STD_VER > 11
71template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
81template <class _Tp> using make_signed_t = __make_signed_t<_Tp>;
7282#endif
7383
7484_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/make_unsigned.h+23-13
......@@ -25,19 +25,25 @@
2525
2626_LIBCPP_BEGIN_NAMESPACE_STD
2727
28#if __has_builtin(__make_unsigned)
29
30template <class _Tp>
31using __make_unsigned_t = __make_unsigned(_Tp);
32
33#else
2834typedef
2935 __type_list<unsigned char,
3036 __type_list<unsigned short,
3137 __type_list<unsigned int,
3238 __type_list<unsigned long,
3339 __type_list<unsigned long long,
34#ifndef _LIBCPP_HAS_NO_INT128
40# ifndef _LIBCPP_HAS_NO_INT128
3541 __type_list<__uint128_t,
36#endif
42# endif
3743 __nat
38#ifndef _LIBCPP_HAS_NO_INT128
44# ifndef _LIBCPP_HAS_NO_INT128
3945 >
40#endif
46# endif
4147 > > > > > __unsigned_types;
4248
4349template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
......@@ -58,31 +64,35 @@ template <> struct __make_unsigned< signed long, true> {typedef unsigned l
5864template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
5965template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
6066template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
61#ifndef _LIBCPP_HAS_NO_INT128
67# ifndef _LIBCPP_HAS_NO_INT128
6268template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
6369template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
64#endif
70# endif
6571
6672template <class _Tp>
67struct _LIBCPP_TEMPLATE_VIS make_unsigned
68{
69 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
73using __make_unsigned_t = typename __apply_cv<_Tp, typename __make_unsigned<__remove_cv_t<_Tp> >::type>::type;
74
75#endif // __has_builtin(__make_unsigned)
76
77template <class _Tp>
78struct make_unsigned {
79 using type _LIBCPP_NODEBUG = __make_unsigned_t<_Tp>;
7080};
7181
7282#if _LIBCPP_STD_VER > 11
73template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
83template <class _Tp> using make_unsigned_t = __make_unsigned_t<_Tp>;
7484#endif
7585
7686#ifndef _LIBCPP_CXX03_LANG
7787template <class _Tp>
7888_LIBCPP_HIDE_FROM_ABI constexpr
79typename make_unsigned<_Tp>::type __to_unsigned_like(_Tp __x) noexcept {
80 return static_cast<typename make_unsigned<_Tp>::type>(__x);
89__make_unsigned_t<_Tp> __to_unsigned_like(_Tp __x) noexcept {
90 return static_cast<__make_unsigned_t<_Tp> >(__x);
8191}
8292#endif
8393
8494template <class _Tp, class _Up>
85using __copy_unsigned_t = __conditional_t<is_unsigned<_Tp>::value, typename make_unsigned<_Up>::type, _Up>;
95using __copy_unsigned_t = __conditional_t<is_unsigned<_Tp>::value, __make_unsigned_t<_Up>, _Up>;
8696
8797_LIBCPP_END_NAMESPACE_STD
8898
lib/libcxx/include/__type_traits/maybe_const.h created+26
......@@ -0,0 +1,26 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_MAYBE_CONST_H
10#define _LIBCPP___TYPE_TRAITS_MAYBE_CONST_H
11
12#include <__config>
13#include <__type_traits/conditional.h>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20
21template<bool _Const, class _Tp>
22using __maybe_const = __conditional_t<_Const, const _Tp, _Tp>;
23
24_LIBCPP_END_NAMESPACE_STD
25
26#endif // _LIBCPP___TYPE_TRAITS_MAYBE_CONST_H
lib/libcxx/include/__type_traits/negation.h+1-1
......@@ -25,7 +25,7 @@ struct _Not : _BoolConstant<!_Pred::value> {};
2525template <class _Tp>
2626struct negation : _Not<_Tp> {};
2727template<class _Tp>
28inline constexpr bool negation_v = negation<_Tp>::value;
28inline constexpr bool negation_v = !_Tp::value;
2929#endif // _LIBCPP_STD_VER > 14
3030
3131_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/noexcept_move_assign_container.h created+35
......@@ -0,0 +1,35 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_NOEXCEPT_MOVE_ASSIGN_CONTAINER_H
10#define _LIBCPP___TYPE_TRAITS_NOEXCEPT_MOVE_ASSIGN_CONTAINER_H
11
12#include <__config>
13#include <__memory/allocator_traits.h>
14#include <__type_traits/integral_constant.h>
15#include <__type_traits/is_nothrow_move_assignable.h>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23template <typename _Alloc, typename _Traits=allocator_traits<_Alloc> >
24struct __noexcept_move_assign_container : public integral_constant<bool,
25 _Traits::propagate_on_container_move_assignment::value
26#if _LIBCPP_STD_VER > 14
27 || _Traits::is_always_equal::value
28#else
29 && is_nothrow_move_assignable<_Alloc>::value
30#endif
31 > {};
32
33_LIBCPP_END_NAMESPACE_STD
34
35#endif // _LIBCPP___TYPE_TRAITS_NOEXCEPT_MOVE_ASSIGN_CONTAINER_H
lib/libcxx/include/__type_traits/promote.h+5-1
......@@ -33,10 +33,14 @@ struct __numeric_type
3333 static double __test(unsigned long);
3434 static double __test(long long);
3535 static double __test(unsigned long long);
36#ifndef _LIBCPP_HAS_NO_INT128
37 static double __test(__int128_t);
38 static double __test(__uint128_t);
39#endif
3640 static double __test(double);
3741 static long double __test(long double);
3842
39 typedef decltype(__test(declval<_Tp>())) type;
43 typedef decltype(__test(std::declval<_Tp>())) type;
4044 static const bool value = _IsNotSame<type, void>::value;
4145};
4246
lib/libcxx/include/__type_traits/rank.h+10
......@@ -19,6 +19,14 @@
1919
2020_LIBCPP_BEGIN_NAMESPACE_STD
2121
22// TODO: Enable using the builtin __array_rank when https://llvm.org/PR57133 is resolved
23#if __has_builtin(__array_rank) && 0
24
25template <class _Tp>
26struct rank : integral_constant<size_t, __array_rank(_Tp)> {};
27
28#else
29
2230template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank
2331 : public integral_constant<size_t, 0> {};
2432template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
......@@ -26,6 +34,8 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
2634template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]>
2735 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
2836
37#endif // __has_builtin(__array_rank)
38
2939#if _LIBCPP_STD_VER > 14
3040template <class _Tp>
3141inline constexpr size_t rank_v = rank<_Tp>::value;
lib/libcxx/include/__type_traits/remove_all_extents.h+14-1
......@@ -18,6 +18,15 @@
1818
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if __has_builtin(__remove_all_extents)
22template <class _Tp>
23struct remove_all_extents {
24 using type _LIBCPP_NODEBUG = __remove_all_extents(_Tp);
25};
26
27template <class _Tp>
28using __remove_all_extents_t = __remove_all_extents(_Tp);
29#else
2130template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents
2231 {typedef _Tp type;};
2332template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>
......@@ -25,8 +34,12 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>
2534template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]>
2635 {typedef typename remove_all_extents<_Tp>::type type;};
2736
37template <class _Tp>
38using __remove_all_extents_t = typename remove_all_extents<_Tp>::type;
39#endif // __has_builtin(__remove_all_extents)
40
2841#if _LIBCPP_STD_VER > 11
29template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
42template <class _Tp> using remove_all_extents_t = __remove_all_extents_t<_Tp>;
3043#endif
3144
3245_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/remove_const.h+15-1
......@@ -17,10 +17,24 @@
1717
1818_LIBCPP_BEGIN_NAMESPACE_STD
1919
20#if __has_builtin(__remove_const)
21template <class _Tp>
22struct remove_const {
23 using type _LIBCPP_NODEBUG = __remove_const(_Tp);
24};
25
26template <class _Tp>
27using __remove_const_t = __remove_const(_Tp);
28#else
2029template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;};
2130template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;};
31
32template <class _Tp>
33using __remove_const_t = typename remove_const<_Tp>::type;
34#endif // __has_builtin(__remove_const)
35
2236#if _LIBCPP_STD_VER > 11
23template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
37template <class _Tp> using remove_const_t = __remove_const_t<_Tp>;
2438#endif
2539
2640_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/remove_const_ref.h created+27
......@@ -0,0 +1,27 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_REMOVE_CONST_REF_H
10#define _LIBCPP___TYPE_TRAITS_REMOVE_CONST_REF_H
11
12#include <__config>
13#include <__type_traits/remove_const.h>
14#include <__type_traits/remove_reference.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22template <class _Tp>
23using __remove_const_ref_t = __remove_const_t<__libcpp_remove_reference_t<_Tp> >;
24
25_LIBCPP_END_NAMESPACE_STD
26
27#endif // _LIBCPP___TYPE_TRAITS_REMOVE_CONST_REF_H
lib/libcxx/include/__type_traits/remove_cv.h+16-2
......@@ -19,10 +19,24 @@
1919
2020_LIBCPP_BEGIN_NAMESPACE_STD
2121
22#if __has_builtin(__remove_cv)
23template <class _Tp>
24struct remove_cv {
25 using type _LIBCPP_NODEBUG = __remove_cv(_Tp);
26};
27
28template <class _Tp>
29using __remove_cv_t = __remove_cv(_Tp);
30#else
2231template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
23{typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
32{typedef __remove_volatile_t<__remove_const_t<_Tp> > type;};
33
34template <class _Tp>
35using __remove_cv_t = __remove_volatile_t<__remove_const_t<_Tp> >;
36#endif // __has_builtin(__remove_cv)
37
2438#if _LIBCPP_STD_VER > 11
25template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
39template <class _Tp> using remove_cv_t = __remove_cv_t<_Tp>;
2640#endif
2741
2842_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/remove_cvref.h+9-5
......@@ -20,20 +20,24 @@
2020
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if __has_builtin(__remove_cvref)
2324template <class _Tp>
24using __uncvref_t _LIBCPP_NODEBUG = typename remove_cv<typename remove_reference<_Tp>::type>::type;
25using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cvref(_Tp);
26#else
27template <class _Tp>
28using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cv_t<__libcpp_remove_reference_t<_Tp> >;
29#endif // __has_builtin(__remove_cvref)
2530
2631template <class _Tp, class _Up>
27struct __is_same_uncvref : _IsSame<__uncvref_t<_Tp>, __uncvref_t<_Up> > {};
32struct __is_same_uncvref : _IsSame<__remove_cvref_t<_Tp>, __remove_cvref_t<_Up> > {};
2833
2934#if _LIBCPP_STD_VER > 17
30// remove_cvref - same as __uncvref
3135template <class _Tp>
3236struct remove_cvref {
33 using type _LIBCPP_NODEBUG = __uncvref_t<_Tp>;
37 using type _LIBCPP_NODEBUG = __remove_cvref_t<_Tp>;
3438};
3539
36template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
40template <class _Tp> using remove_cvref_t = __remove_cvref_t<_Tp>;
3741#endif
3842
3943_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/remove_extent.h+14-1
......@@ -18,6 +18,15 @@
1818
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if __has_builtin(__remove_extent)
22template <class _Tp>
23struct remove_extent {
24 using type _LIBCPP_NODEBUG = __remove_extent(_Tp);
25};
26
27template <class _Tp>
28using __remove_extent_t = __remove_extent(_Tp);
29#else
2130template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent
2231 {typedef _Tp type;};
2332template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
......@@ -25,8 +34,12 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
2534template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]>
2635 {typedef _Tp type;};
2736
37template <class _Tp>
38using __remove_extent_t = typename remove_extent<_Tp>::type;
39#endif // __has_builtin(__remove_extent)
40
2841#if _LIBCPP_STD_VER > 11
29template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
42template <class _Tp> using remove_extent_t = __remove_extent_t<_Tp>;
3043#endif
3144
3245_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/remove_pointer.h+14-1
......@@ -17,14 +17,27 @@
1717
1818_LIBCPP_BEGIN_NAMESPACE_STD
1919
20#if __has_builtin(__remove_pointer)
21template <class _Tp>
22struct remove_pointer {
23 using type _LIBCPP_NODEBUG = __remove_pointer(_Tp);
24};
25
26template <class _Tp>
27using __remove_pointer_t = __remove_pointer(_Tp);
28#else
2029template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG _Tp type;};
2130template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _LIBCPP_NODEBUG _Tp type;};
2231template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _LIBCPP_NODEBUG _Tp type;};
2332template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _LIBCPP_NODEBUG _Tp type;};
2433template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _LIBCPP_NODEBUG _Tp type;};
2534
35template <class _Tp>
36using __remove_pointer_t = typename remove_pointer<_Tp>::type;
37#endif // __has_builtin(__remove_pointer)
38
2639#if _LIBCPP_STD_VER > 11
27template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
40template <class _Tp> using remove_pointer_t = __remove_pointer_t<_Tp>;
2841#endif
2942
3043_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/remove_reference.h+14-1
......@@ -18,12 +18,25 @@
1818
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if __has_builtin(__remove_reference_t)
22template <class _Tp>
23struct remove_reference {
24 using type _LIBCPP_NODEBUG = __remove_reference_t(_Tp);
25};
26
27template <class _Tp>
28using __libcpp_remove_reference_t = __remove_reference_t(_Tp);
29#else
2130template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG _Tp type;};
2231template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG _Tp type;};
2332template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG _Tp type;};
2433
34template <class _Tp>
35using __libcpp_remove_reference_t = typename remove_reference<_Tp>::type;
36#endif // __has_builtin(__remove_reference_t)
37
2538#if _LIBCPP_STD_VER > 11
26template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
39template <class _Tp> using remove_reference_t = __libcpp_remove_reference_t<_Tp>;
2740#endif
2841
2942_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/remove_volatile.h+15-1
......@@ -17,10 +17,24 @@
1717
1818_LIBCPP_BEGIN_NAMESPACE_STD
1919
20#if __has_builtin(__remove_volatile)
21template <class _Tp>
22struct remove_volatile {
23 using type _LIBCPP_NODEBUG = __remove_volatile(_Tp);
24};
25
26template <class _Tp>
27using __remove_volatile_t = __remove_volatile(_Tp);
28#else
2029template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;};
2130template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};
31
32template <class _Tp>
33using __remove_volatile_t = typename remove_volatile<_Tp>::type;
34#endif // __has_builtin(__remove_volatile)
35
2236#if _LIBCPP_STD_VER > 11
23template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
37template <class _Tp> using remove_volatile_t = __remove_volatile_t<_Tp>;
2438#endif
2539
2640_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/result_of.h created+39
......@@ -0,0 +1,39 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_RESULT_OF_H
10#define _LIBCPP___TYPE_TRAITS_RESULT_OF_H
11
12#include <__config>
13#include <__functional/invoke.h>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20
21// result_of
22
23#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
24template <class _Callable> class _LIBCPP_DEPRECATED_IN_CXX17 result_of;
25
26template <class _Fp, class ..._Args>
27class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
28 : public __invoke_of<_Fp, _Args...>
29{
30};
31
32#if _LIBCPP_STD_VER > 11
33template <class _Tp> using result_of_t _LIBCPP_DEPRECATED_IN_CXX17 = typename result_of<_Tp>::type;
34#endif // _LIBCPP_STD_VER > 11
35#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
36
37_LIBCPP_END_NAMESPACE_STD
38
39#endif // _LIBCPP___TYPE_TRAITS_RESULT_OF_H
lib/libcxx/include/__type_traits/strip_signature.h created+79
......@@ -0,0 +1,79 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_STRIP_SIGNATURE_H
10#define _LIBCPP___TYPE_TRAITS_STRIP_SIGNATURE_H
11
12#include <__config>
13
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# pragma GCC system_header
16#endif
17
18#if _LIBCPP_STD_VER >= 17
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22template<class _Fp>
23struct __strip_signature;
24
25# if defined(__cpp_static_call_operator) && __cpp_static_call_operator >= 202207L
26
27template <class _Rp, class... _Args>
28struct __strip_signature<_Rp(*)(_Args...)> {
29 using type = _Rp(_Args...);
30};
31
32template <class _Rp, class... _Args>
33struct __strip_signature<_Rp(*)(_Args...) noexcept> {
34 using type = _Rp(_Args...);
35};
36
37# endif // defined(__cpp_static_call_operator) && __cpp_static_call_operator >= 202207L
38
39template<class _Rp, class _Gp, class ..._Ap>
40struct __strip_signature<_Rp (_Gp::*) (_Ap...)> { using type = _Rp(_Ap...); };
41template<class _Rp, class _Gp, class ..._Ap>
42struct __strip_signature<_Rp (_Gp::*) (_Ap...) const> { using type = _Rp(_Ap...); };
43template<class _Rp, class _Gp, class ..._Ap>
44struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile> { using type = _Rp(_Ap...); };
45template<class _Rp, class _Gp, class ..._Ap>
46struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile> { using type = _Rp(_Ap...); };
47
48template<class _Rp, class _Gp, class ..._Ap>
49struct __strip_signature<_Rp (_Gp::*) (_Ap...) &> { using type = _Rp(_Ap...); };
50template<class _Rp, class _Gp, class ..._Ap>
51struct __strip_signature<_Rp (_Gp::*) (_Ap...) const &> { using type = _Rp(_Ap...); };
52template<class _Rp, class _Gp, class ..._Ap>
53struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile &> { using type = _Rp(_Ap...); };
54template<class _Rp, class _Gp, class ..._Ap>
55struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile &> { using type = _Rp(_Ap...); };
56
57template<class _Rp, class _Gp, class ..._Ap>
58struct __strip_signature<_Rp (_Gp::*) (_Ap...) noexcept> { using type = _Rp(_Ap...); };
59template<class _Rp, class _Gp, class ..._Ap>
60struct __strip_signature<_Rp (_Gp::*) (_Ap...) const noexcept> { using type = _Rp(_Ap...); };
61template<class _Rp, class _Gp, class ..._Ap>
62struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile noexcept> { using type = _Rp(_Ap...); };
63template<class _Rp, class _Gp, class ..._Ap>
64struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile noexcept> { using type = _Rp(_Ap...); };
65
66template<class _Rp, class _Gp, class ..._Ap>
67struct __strip_signature<_Rp (_Gp::*) (_Ap...) & noexcept> { using type = _Rp(_Ap...); };
68template<class _Rp, class _Gp, class ..._Ap>
69struct __strip_signature<_Rp (_Gp::*) (_Ap...) const & noexcept> { using type = _Rp(_Ap...); };
70template<class _Rp, class _Gp, class ..._Ap>
71struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile & noexcept> { using type = _Rp(_Ap...); };
72template<class _Rp, class _Gp, class ..._Ap>
73struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile & noexcept> { using type = _Rp(_Ap...); };
74
75_LIBCPP_END_NAMESPACE_STD
76
77#endif // _LIBCPP_STD_VER >= 17
78
79#endif // _LIBCPP___TYPE_TRAITS_STRIP_SIGNATURE_H
lib/libcxx/include/__type_traits/void_t.h+2-2
......@@ -21,8 +21,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2121template <class...> using void_t = void;
2222#endif
2323
24template <class>
25struct __void_t { typedef void type; };
24template <class...>
25using __void_t = void;
2626
2727_LIBCPP_END_NAMESPACE_STD
2828
lib/libcxx/include/__utility/as_const.h+2-2
......@@ -10,9 +10,9 @@
1010#define _LIBCPP___UTILITY_AS_CONST_H
1111
1212#include <__config>
13#include <__type_traits/add_const.h>
1314#include <__utility/forward.h>
1415#include <__utility/move.h>
15#include <type_traits>
1616
1717#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1818# pragma GCC system_header
......@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222
2323#if _LIBCPP_STD_VER > 14
2424template <class _Tp>
25_LIBCPP_NODISCARD_EXT constexpr add_const_t<_Tp>& as_const(_Tp& __t) noexcept { return __t; }
25_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr add_const_t<_Tp>& as_const(_Tp& __t) noexcept { return __t; }
2626
2727template <class _Tp>
2828void as_const(const _Tp&&) = delete;
lib/libcxx/include/__utility/auto_cast.h+1-1
......@@ -11,7 +11,7 @@
1111#define _LIBCPP___UTILITY_AUTO_CAST_H
1212
1313#include <__config>
14#include <type_traits>
14#include <__type_traits/decay.h>
1515
1616#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1717# pragma GCC system_header
lib/libcxx/include/__utility/cmp.h+5-1
......@@ -10,10 +10,14 @@
1010#define _LIBCPP___UTILITY_CMP_H
1111
1212#include <__config>
13#include <__type_traits/disjunction.h>
14#include <__type_traits/is_integral.h>
15#include <__type_traits/is_same.h>
16#include <__type_traits/is_signed.h>
17#include <__type_traits/make_unsigned.h>
1318#include <__utility/forward.h>
1419#include <__utility/move.h>
1520#include <limits>
16#include <type_traits>
1721
1822#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1923# pragma GCC system_header
lib/libcxx/include/__utility/convert_to_integral.h created+72
......@@ -0,0 +1,72 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___UTILITY_CONVERT_TO_INTEGRAL_H
10#define _LIBCPP___UTILITY_CONVERT_TO_INTEGRAL_H
11
12#include <__config>
13#include <__type_traits/enable_if.h>
14#include <__type_traits/is_enum.h>
15#include <__type_traits/is_floating_point.h>
16#include <__type_traits/underlying_type.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
25int __convert_to_integral(int __val) { return __val; }
26
27inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
28unsigned __convert_to_integral(unsigned __val) { return __val; }
29
30inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
31long __convert_to_integral(long __val) { return __val; }
32
33inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
34unsigned long __convert_to_integral(unsigned long __val) { return __val; }
35
36inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
37long long __convert_to_integral(long long __val) { return __val; }
38
39inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
40unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
41
42template<typename _Fp>
43inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
44typename enable_if<is_floating_point<_Fp>::value, long long>::type
45 __convert_to_integral(_Fp __val) { return __val; }
46
47#ifndef _LIBCPP_HAS_NO_INT128
48inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
49__int128_t __convert_to_integral(__int128_t __val) { return __val; }
50
51inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
52__uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
53#endif
54
55template <class _Tp, bool = is_enum<_Tp>::value>
56struct __sfinae_underlying_type
57{
58 typedef typename underlying_type<_Tp>::type type;
59 typedef decltype(((type)1) + 0) __promoted_type;
60};
61
62template <class _Tp>
63struct __sfinae_underlying_type<_Tp, false> {};
64
65template <class _Tp>
66inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
67typename __sfinae_underlying_type<_Tp>::__promoted_type
68__convert_to_integral(_Tp __val) { return __val; }
69
70_LIBCPP_END_NAMESPACE_STD
71
72#endif // _LIBCPP___UTILITY_CONVERT_TO_INTEGRAL_H
lib/libcxx/include/__utility/declval.h+1-1
......@@ -27,7 +27,7 @@ _Tp __declval(long);
2727_LIBCPP_SUPPRESS_DEPRECATED_POP
2828
2929template <class _Tp>
30decltype(__declval<_Tp>(0)) declval() _NOEXCEPT;
30decltype(std::__declval<_Tp>(0)) declval() _NOEXCEPT;
3131
3232_LIBCPP_END_NAMESPACE_STD
3333
lib/libcxx/include/__utility/exception_guard.h created+128
......@@ -0,0 +1,128 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___UTILITY_TRANSACTION_H
10#define _LIBCPP___UTILITY_TRANSACTION_H
11
12#include <__assert>
13#include <__config>
14#include <__type_traits/is_nothrow_move_constructible.h>
15#include <__utility/exchange.h>
16#include <__utility/move.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24// __exception_guard is a helper class for writing code with the strong exception guarantee.
25//
26// When writing code that can throw an exception, one can store rollback instructions in an
27// exception guard so that if an exception is thrown at any point during the lifetime of the
28// exception guard, it will be rolled back automatically. When the exception guard is done, one
29// must mark it as being complete so it isn't rolled back when the exception guard is destroyed.
30//
31// Exception guards are not default constructible, they can't be copied or assigned to, but
32// they can be moved around for convenience.
33//
34// __exception_guard is a no-op in -fno-exceptions mode to produce better code-gen. This means
35// that we don't provide the strong exception guarantees. However, Clang doesn't generate cleanup
36// code with exceptions disabled, so even if we wanted to provide the strong exception guarantees
37// we couldn't. This is also only relevant for constructs with a stack of
38// -fexceptions > -fno-exceptions > -fexceptions code, since the exception can't be caught where
39// exceptions are disabled. While -fexceptions > -fno-exceptions is quite common
40// (e.g. libc++.dylib > -fno-exceptions), having another layer with exceptions enabled seems a lot
41// less common, especially one that tries to catch an exception through -fno-exceptions code.
42//
43// __exception_guard can help greatly simplify code that would normally be cluttered by
44// `#if _LIBCPP_NO_EXCEPTIONS`. For example:
45//
46// template <class Iterator, class Size, class OutputIterator>
47// Iterator uninitialized_copy_n(Iterator iter, Size n, OutputIterator out) {
48// typedef typename iterator_traits<Iterator>::value_type value_type;
49// __exception_guard guard([start=out, &out] {
50// std::destroy(start, out);
51// });
52//
53// for (; n > 0; ++iter, ++out, --n) {
54// ::new ((void*)std::addressof(*out)) value_type(*iter);
55// }
56// guard.__complete();
57// return out;
58// }
59//
60
61#ifndef _LIBCPP_NO_EXCEPTIONS
62template <class _Rollback>
63struct __exception_guard {
64 __exception_guard() = delete;
65
66 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __exception_guard(_Rollback __rollback)
67 : __rollback_(std::move(__rollback)), __completed_(false) {}
68
69 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __exception_guard(__exception_guard&& __other)
70 _NOEXCEPT_(is_nothrow_move_constructible<_Rollback>::value)
71 : __rollback_(std::move(__other.__rollback_)), __completed_(__other.__completed_) {
72 __other.__completed_ = true;
73 }
74
75 __exception_guard(__exception_guard const&) = delete;
76 __exception_guard& operator=(__exception_guard const&) = delete;
77 __exception_guard& operator=(__exception_guard&&) = delete;
78
79 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __complete() _NOEXCEPT { __completed_ = true; }
80
81 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__exception_guard() {
82 if (!__completed_)
83 __rollback_();
84 }
85
86private:
87 _Rollback __rollback_;
88 bool __completed_;
89};
90#else // _LIBCPP_NO_EXCEPTIONS
91template <class _Rollback>
92struct __exception_guard {
93 __exception_guard() = delete;
94 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NODEBUG explicit __exception_guard(_Rollback) {}
95
96 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NODEBUG __exception_guard(__exception_guard&& __other)
97 _NOEXCEPT_(is_nothrow_move_constructible<_Rollback>::value)
98 : __completed_(__other.__completed_) {
99 __other.__completed_ = true;
100 }
101
102 __exception_guard(__exception_guard const&) = delete;
103 __exception_guard& operator=(__exception_guard const&) = delete;
104 __exception_guard& operator=(__exception_guard&&) = delete;
105
106 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NODEBUG void __complete() _NOEXCEPT {
107 __completed_ = true;
108 }
109
110 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NODEBUG ~__exception_guard() {
111 _LIBCPP_ASSERT(__completed_, "__exception_guard not completed with exceptions disabled");
112 }
113
114private:
115 bool __completed_ = false;
116};
117#endif // _LIBCPP_NO_EXCEPTIONS
118
119_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__exception_guard);
120
121template <class _Rollback>
122_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __exception_guard<_Rollback> __make_exception_guard(_Rollback __rollback) {
123 return __exception_guard<_Rollback>(std::move(__rollback));
124}
125
126_LIBCPP_END_NAMESPACE_STD
127
128#endif // _LIBCPP___UTILITY_TRANSACTION_H
lib/libcxx/include/__utility/exchange.h+3-2
......@@ -10,9 +10,10 @@
1010#define _LIBCPP___UTILITY_EXCHANGE_H
1111
1212#include <__config>
13#include <__type_traits/is_nothrow_assignable.h>
14#include <__type_traits/is_nothrow_move_constructible.h>
1315#include <__utility/forward.h>
1416#include <__utility/move.h>
15#include <type_traits>
1617
1718#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1819# pragma GCC system_header
......@@ -22,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2223
2324#if _LIBCPP_STD_VER > 11
2425template<class _T1, class _T2 = _T1>
25inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
26inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
2627_T1 exchange(_T1& __obj, _T2&& __new_value)
2728 noexcept(is_nothrow_move_constructible<_T1>::value && is_nothrow_assignable<_T1&, _T2>::value)
2829{
lib/libcxx/include/__utility/forward.h+4-4
......@@ -21,14 +21,14 @@
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
2323template <class _Tp>
24_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR _Tp&&
25forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT {
24_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&&
25forward(_LIBCPP_LIFETIMEBOUND __libcpp_remove_reference_t<_Tp>& __t) _NOEXCEPT {
2626 return static_cast<_Tp&&>(__t);
2727}
2828
2929template <class _Tp>
30_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR _Tp&&
31forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT {
30_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&&
31forward(_LIBCPP_LIFETIMEBOUND __libcpp_remove_reference_t<_Tp>&& __t) _NOEXCEPT {
3232 static_assert(!is_lvalue_reference<_Tp>::value, "cannot forward an rvalue as an lvalue");
3333 return static_cast<_Tp&&>(__t);
3434}
lib/libcxx/include/__utility/forward_like.h created+46
......@@ -0,0 +1,46 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___UTILITY_FORWARD_LIKE_H
11#define _LIBCPP___UTILITY_FORWARD_LIKE_H
12
13#include <__config>
14#include <__type_traits/conditional.h>
15#include <__type_traits/is_const.h>
16#include <__type_traits/is_reference.h>
17#include <__type_traits/remove_reference.h>
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25#if _LIBCPP_STD_VER > 20
26
27template <class _Ap, class _Bp>
28using _CopyConst = _If<is_const_v<_Ap>, const _Bp, _Bp>;
29
30template <class _Ap, class _Bp>
31using _OverrideRef = _If<is_rvalue_reference_v<_Ap>, remove_reference_t<_Bp>&&, _Bp&>;
32
33template <class _Ap, class _Bp>
34using _ForwardLike = _OverrideRef<_Ap&&, _CopyConst<remove_reference_t<_Ap>, remove_reference_t<_Bp>>>;
35
36template <class _Tp, class _Up>
37[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto forward_like(_LIBCPP_LIFETIMEBOUND _Up&& __ux) noexcept
38 -> _ForwardLike<_Tp, _Up> {
39 return static_cast<_ForwardLike<_Tp, _Up>>(__ux);
40}
41
42#endif // _LIBCPP_STD_VER > 20
43
44_LIBCPP_END_NAMESPACE_STD
45
46#endif // _LIBCPP___UTILITY_FORWARD_LIKE_H
lib/libcxx/include/__utility/in_place.h+4-3
......@@ -10,7 +10,8 @@
1010#define _LIBCPP___UTILITY_IN_PLACE_H
1111
1212#include <__config>
13#include <type_traits>
13#include <__type_traits/remove_cvref.h>
14#include <cstddef>
1415
1516#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1617# pragma GCC system_header
......@@ -43,13 +44,13 @@ template <class _Tp> struct __is_inplace_type_imp : false_type {};
4344template <class _Tp> struct __is_inplace_type_imp<in_place_type_t<_Tp>> : true_type {};
4445
4546template <class _Tp>
46using __is_inplace_type = __is_inplace_type_imp<__uncvref_t<_Tp>>;
47using __is_inplace_type = __is_inplace_type_imp<__remove_cvref_t<_Tp>>;
4748
4849template <class _Tp> struct __is_inplace_index_imp : false_type {};
4950template <size_t _Idx> struct __is_inplace_index_imp<in_place_index_t<_Idx>> : true_type {};
5051
5152template <class _Tp>
52using __is_inplace_index = __is_inplace_index_imp<__uncvref_t<_Tp>>;
53using __is_inplace_index = __is_inplace_index_imp<__remove_cvref_t<_Tp>>;
5354
5455#endif // _LIBCPP_STD_VER > 14
5556
lib/libcxx/include/__utility/integer_sequence.h+76-1
......@@ -10,7 +10,8 @@
1010#define _LIBCPP___UTILITY_INTEGER_SEQUENCE_H
1111
1212#include <__config>
13#include <type_traits>
13#include <__type_traits/is_integral.h>
14#include <cstddef>
1415
1516#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1617# pragma GCC system_header
......@@ -18,6 +19,72 @@
1819
1920_LIBCPP_BEGIN_NAMESPACE_STD
2021
22template <size_t...> struct __tuple_indices;
23
24template <class _IdxType, _IdxType... _Values>
25struct __integer_sequence {
26 template <template <class _OIdxType, _OIdxType...> class _ToIndexSeq, class _ToIndexType>
27 using __convert = _ToIndexSeq<_ToIndexType, _Values...>;
28
29 template <size_t _Sp>
30 using __to_tuple_indices = __tuple_indices<(_Values + _Sp)...>;
31};
32
33#if !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
34
35namespace __detail {
36
37template<typename _Tp, size_t ..._Extra> struct __repeat;
38template<typename _Tp, _Tp ..._Np, size_t ..._Extra> struct __repeat<__integer_sequence<_Tp, _Np...>, _Extra...> {
39 typedef _LIBCPP_NODEBUG __integer_sequence<_Tp,
40 _Np...,
41 sizeof...(_Np) + _Np...,
42 2 * sizeof...(_Np) + _Np...,
43 3 * sizeof...(_Np) + _Np...,
44 4 * sizeof...(_Np) + _Np...,
45 5 * sizeof...(_Np) + _Np...,
46 6 * sizeof...(_Np) + _Np...,
47 7 * sizeof...(_Np) + _Np...,
48 _Extra...> type;
49};
50
51template<size_t _Np> struct __parity;
52template<size_t _Np> struct __make : __parity<_Np % 8>::template __pmake<_Np> {};
53
54template<> struct __make<0> { typedef __integer_sequence<size_t> type; };
55template<> struct __make<1> { typedef __integer_sequence<size_t, 0> type; };
56template<> struct __make<2> { typedef __integer_sequence<size_t, 0, 1> type; };
57template<> struct __make<3> { typedef __integer_sequence<size_t, 0, 1, 2> type; };
58template<> struct __make<4> { typedef __integer_sequence<size_t, 0, 1, 2, 3> type; };
59template<> struct __make<5> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4> type; };
60template<> struct __make<6> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5> type; };
61template<> struct __make<7> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5, 6> type; };
62
63template<> struct __parity<0> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type> {}; };
64template<> struct __parity<1> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 1> {}; };
65template<> struct __parity<2> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 2, _Np - 1> {}; };
66template<> struct __parity<3> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 3, _Np - 2, _Np - 1> {}; };
67template<> struct __parity<4> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
68template<> struct __parity<5> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
69template<> struct __parity<6> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
70template<> struct __parity<7> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 7, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
71
72} // namespace detail
73
74#endif
75
76#if __has_builtin(__make_integer_seq)
77template <size_t _Ep, size_t _Sp>
78using __make_indices_imp =
79 typename __make_integer_seq<__integer_sequence, size_t, _Ep - _Sp>::template
80 __to_tuple_indices<_Sp>;
81#else
82template <size_t _Ep, size_t _Sp>
83using __make_indices_imp =
84 typename __detail::__make<_Ep - _Sp>::type::template __to_tuple_indices<_Sp>;
85
86#endif
87
2188#if _LIBCPP_STD_VER > 11
2289
2390template<class _Tp, _Tp... _Ip>
......@@ -71,6 +138,14 @@ template<size_t _Np>
71138template<class... _Tp>
72139 using index_sequence_for = make_index_sequence<sizeof...(_Tp)>;
73140
141# if _LIBCPP_STD_VER > 17
142// Executes __func for every element in an index_sequence.
143template <size_t... _Index, class _Function>
144_LIBCPP_HIDE_FROM_ABI constexpr void __for_each_index_sequence(index_sequence<_Index...>, _Function __func) {
145 (__func.template operator()<_Index>(), ...);
146}
147# endif // _LIBCPP_STD_VER > 17
148
74149#endif // _LIBCPP_STD_VER > 11
75150
76151_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__utility/move.h+11-9
......@@ -11,7 +11,10 @@
1111#define _LIBCPP___UTILITY_MOVE_H
1212
1313#include <__config>
14#include <type_traits>
14#include <__type_traits/conditional.h>
15#include <__type_traits/is_copy_constructible.h>
16#include <__type_traits/is_nothrow_move_constructible.h>
17#include <__type_traits/remove_reference.h>
1518
1619#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1720# pragma GCC system_header
......@@ -20,21 +23,20 @@
2023_LIBCPP_BEGIN_NAMESPACE_STD
2124
2225template <class _Tp>
23_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename remove_reference<_Tp>::type&&
24move(_Tp&& __t) _NOEXCEPT {
25 typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type _Up;
26_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __libcpp_remove_reference_t<_Tp>&&
27move(_LIBCPP_LIFETIMEBOUND _Tp&& __t) _NOEXCEPT {
28 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tp> _Up;
2629 return static_cast<_Up&&>(__t);
2730}
2831
2932template <class _Tp>
3033using __move_if_noexcept_result_t =
31 typename conditional<!is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value, const _Tp&,
32 _Tp&&>::type;
34 __conditional_t<!is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value, const _Tp&, _Tp&&>;
3335
3436template <class _Tp>
35_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 __move_if_noexcept_result_t<_Tp>
36move_if_noexcept(_Tp& __x) _NOEXCEPT {
37 return _VSTD::move(__x);
37_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __move_if_noexcept_result_t<_Tp>
38move_if_noexcept(_LIBCPP_LIFETIMEBOUND _Tp& __x) _NOEXCEPT {
39 return std::move(__x);
3840}
3941
4042_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__utility/pair.h+173-77
......@@ -13,12 +13,35 @@
1313#include <__compare/synth_three_way.h>
1414#include <__config>
1515#include <__functional/unwrap_ref.h>
16#include <__tuple>
16#include <__fwd/get.h>
17#include <__fwd/tuple.h>
18#include <__tuple_dir/sfinae_helpers.h>
19#include <__tuple_dir/tuple_element.h>
20#include <__tuple_dir/tuple_indices.h>
21#include <__tuple_dir/tuple_size.h>
22#include <__type_traits/common_reference.h>
23#include <__type_traits/common_type.h>
24#include <__type_traits/conditional.h>
25#include <__type_traits/is_assignable.h>
26#include <__type_traits/is_constructible.h>
27#include <__type_traits/is_convertible.h>
28#include <__type_traits/is_copy_assignable.h>
29#include <__type_traits/is_default_constructible.h>
30#include <__type_traits/is_implicitly_default_constructible.h>
31#include <__type_traits/is_move_assignable.h>
32#include <__type_traits/is_nothrow_assignable.h>
33#include <__type_traits/is_nothrow_constructible.h>
34#include <__type_traits/is_nothrow_copy_assignable.h>
35#include <__type_traits/is_nothrow_copy_constructible.h>
36#include <__type_traits/is_nothrow_default_constructible.h>
37#include <__type_traits/is_nothrow_move_assignable.h>
38#include <__type_traits/is_same.h>
39#include <__type_traits/is_swappable.h>
40#include <__type_traits/nat.h>
1741#include <__utility/forward.h>
1842#include <__utility/move.h>
1943#include <__utility/piecewise_construct.h>
2044#include <cstddef>
21#include <type_traits>
2245
2346#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2447# pragma GCC system_header
......@@ -31,7 +54,7 @@ template <class, class>
3154struct __non_trivially_copyable_base {
3255 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
3356 __non_trivially_copyable_base() _NOEXCEPT {}
34 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
57 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
3558 __non_trivially_copyable_base(__non_trivially_copyable_base const&) _NOEXCEPT {}
3659};
3760#endif
......@@ -48,12 +71,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
4871 _T1 first;
4972 _T2 second;
5073
51#if !defined(_LIBCPP_CXX03_LANG)
5274 pair(pair const&) = default;
5375 pair(pair&&) = default;
54#else
55 // Use the implicitly declared copy constructor in C++03
56#endif
5776
5877#ifdef _LIBCPP_CXX03_LANG
5978 _LIBCPP_INLINE_VISIBILITY
......@@ -88,20 +107,26 @@ struct _LIBCPP_TEMPLATE_VIS pair
88107 }
89108
90109 template <class _U1, class _U2>
91 static constexpr bool __enable_explicit() {
110 static constexpr bool __is_pair_constructible() {
92111 return is_constructible<first_type, _U1>::value
93 && is_constructible<second_type, _U2>::value
94 && (!is_convertible<_U1, first_type>::value
95 || !is_convertible<_U2, second_type>::value);
112 && is_constructible<second_type, _U2>::value;
96113 }
97114
98115 template <class _U1, class _U2>
99 static constexpr bool __enable_implicit() {
100 return is_constructible<first_type, _U1>::value
101 && is_constructible<second_type, _U2>::value
102 && is_convertible<_U1, first_type>::value
116 static constexpr bool __is_implicit() {
117 return is_convertible<_U1, first_type>::value
103118 && is_convertible<_U2, second_type>::value;
104119 }
120
121 template <class _U1, class _U2>
122 static constexpr bool __enable_explicit() {
123 return __is_pair_constructible<_U1, _U2>() && !__is_implicit<_U1, _U2>();
124 }
125
126 template <class _U1, class _U2>
127 static constexpr bool __enable_implicit() {
128 return __is_pair_constructible<_U1, _U2>() && __is_implicit<_U1, _U2>();
129 }
105130 };
106131
107132 template <bool _MaybeEnable>
......@@ -127,12 +152,12 @@ struct _LIBCPP_TEMPLATE_VIS pair
127152 };
128153
129154 template <class _Tuple>
130 using _CheckTLC _LIBCPP_NODEBUG = typename conditional<
155 using _CheckTLC _LIBCPP_NODEBUG = __conditional_t<
131156 __tuple_like_with_size<_Tuple, 2>::value
132157 && !is_same<typename decay<_Tuple>::type, pair>::value,
133158 _CheckTupleLikeConstructor,
134159 __check_tuple_constructor_fail
135 >::type;
160 >;
136161
137162 template<bool _Dummy = true, typename enable_if<
138163 _CheckArgsDep<_Dummy>::__enable_explicit_default()
......@@ -153,7 +178,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
153178 template <bool _Dummy = true, typename enable_if<
154179 _CheckArgsDep<_Dummy>::template __enable_explicit<_T1 const&, _T2 const&>()
155180 >::type* = nullptr>
156 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
181 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
157182 explicit pair(_T1 const& __t1, _T2 const& __t2)
158183 _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
159184 is_nothrow_copy_constructible<second_type>::value)
......@@ -162,7 +187,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
162187 template<bool _Dummy = true, typename enable_if<
163188 _CheckArgsDep<_Dummy>::template __enable_implicit<_T1 const&, _T2 const&>()
164189 >::type* = nullptr>
165 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
190 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
166191 pair(_T1 const& __t1, _T2 const& __t2)
167192 _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
168193 is_nothrow_copy_constructible<second_type>::value)
......@@ -176,7 +201,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
176201#endif
177202 typename enable_if<_CheckArgs::template __enable_explicit<_U1, _U2>()>::type* = nullptr
178203 >
179 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
204 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
180205 explicit pair(_U1&& __u1, _U2&& __u2)
181206 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value &&
182207 is_nothrow_constructible<second_type, _U2>::value))
......@@ -190,16 +215,27 @@ struct _LIBCPP_TEMPLATE_VIS pair
190215#endif
191216 typename enable_if<_CheckArgs::template __enable_implicit<_U1, _U2>()>::type* = nullptr
192217 >
193 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
218 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
194219 pair(_U1&& __u1, _U2&& __u2)
195220 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value &&
196221 is_nothrow_constructible<second_type, _U2>::value))
197222 : first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {}
198223
224#if _LIBCPP_STD_VER > 20
225 template<class _U1, class _U2, __enable_if_t<
226 _CheckArgs::template __is_pair_constructible<_U1&, _U2&>()
227 >* = nullptr>
228 _LIBCPP_HIDE_FROM_ABI constexpr
229 explicit(!_CheckArgs::template __is_implicit<_U1&, _U2&>()) pair(pair<_U1, _U2>& __p)
230 noexcept((is_nothrow_constructible<first_type, _U1&>::value &&
231 is_nothrow_constructible<second_type, _U2&>::value))
232 : first(__p.first), second(__p.second) {}
233#endif
234
199235 template<class _U1, class _U2, typename enable_if<
200236 _CheckArgs::template __enable_explicit<_U1 const&, _U2 const&>()
201237 >::type* = nullptr>
202 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
238 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
203239 explicit pair(pair<_U1, _U2> const& __p)
204240 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value &&
205241 is_nothrow_constructible<second_type, _U2 const&>::value))
......@@ -208,7 +244,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
208244 template<class _U1, class _U2, typename enable_if<
209245 _CheckArgs::template __enable_implicit<_U1 const&, _U2 const&>()
210246 >::type* = nullptr>
211 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
247 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
212248 pair(pair<_U1, _U2> const& __p)
213249 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value &&
214250 is_nothrow_constructible<second_type, _U2 const&>::value))
......@@ -217,7 +253,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
217253 template<class _U1, class _U2, typename enable_if<
218254 _CheckArgs::template __enable_explicit<_U1, _U2>()
219255 >::type* = nullptr>
220 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
256 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
221257 explicit pair(pair<_U1, _U2>&&__p)
222258 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value &&
223259 is_nothrow_constructible<second_type, _U2&&>::value))
......@@ -226,16 +262,28 @@ struct _LIBCPP_TEMPLATE_VIS pair
226262 template<class _U1, class _U2, typename enable_if<
227263 _CheckArgs::template __enable_implicit<_U1, _U2>()
228264 >::type* = nullptr>
229 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
265 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
230266 pair(pair<_U1, _U2>&& __p)
231267 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value &&
232268 is_nothrow_constructible<second_type, _U2&&>::value))
233269 : first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {}
234270
271#if _LIBCPP_STD_VER > 20
272 template<class _U1, class _U2, __enable_if_t<
273 _CheckArgs::template __is_pair_constructible<const _U1&&, const _U2&&>()
274 >* = nullptr>
275 _LIBCPP_HIDE_FROM_ABI constexpr
276 explicit(!_CheckArgs::template __is_implicit<const _U1&&, const _U2&&>())
277 pair(const pair<_U1, _U2>&& __p)
278 noexcept(is_nothrow_constructible<first_type, const _U1&&>::value &&
279 is_nothrow_constructible<second_type, const _U2&&>::value)
280 : first(std::move(__p.first)), second(std::move(__p.second)) {}
281#endif
282
235283 template<class _Tuple, typename enable_if<
236284 _CheckTLC<_Tuple>::template __enable_explicit<_Tuple>()
237285 >::type* = nullptr>
238 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
286 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
239287 explicit pair(_Tuple&& __p)
240288 : first(_VSTD::get<0>(_VSTD::forward<_Tuple>(__p))),
241289 second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {}
......@@ -243,13 +291,13 @@ struct _LIBCPP_TEMPLATE_VIS pair
243291 template<class _Tuple, typename enable_if<
244292 _CheckTLC<_Tuple>::template __enable_implicit<_Tuple>()
245293 >::type* = nullptr>
246 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
294 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
247295 pair(_Tuple&& __p)
248296 : first(_VSTD::get<0>(_VSTD::forward<_Tuple>(__p))),
249297 second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {}
250298
251299 template <class... _Args1, class... _Args2>
252 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
300 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
253301 pair(piecewise_construct_t __pc,
254302 tuple<_Args1...> __first_args, tuple<_Args2...> __second_args)
255303 _NOEXCEPT_((is_nothrow_constructible<first_type, _Args1...>::value &&
......@@ -258,11 +306,11 @@ struct _LIBCPP_TEMPLATE_VIS pair
258306 typename __make_tuple_indices<sizeof...(_Args1)>::type(),
259307 typename __make_tuple_indices<sizeof...(_Args2) >::type()) {}
260308
261 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
262 pair& operator=(typename conditional<
309 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
310 pair& operator=(__conditional_t<
263311 is_copy_assignable<first_type>::value &&
264312 is_copy_assignable<second_type>::value,
265 pair, __nat>::type const& __p)
313 pair, __nat> const& __p)
266314 _NOEXCEPT_(is_nothrow_copy_assignable<first_type>::value &&
267315 is_nothrow_copy_assignable<second_type>::value)
268316 {
......@@ -271,11 +319,11 @@ struct _LIBCPP_TEMPLATE_VIS pair
271319 return *this;
272320 }
273321
274 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
275 pair& operator=(typename conditional<
322 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
323 pair& operator=(__conditional_t<
276324 is_move_assignable<first_type>::value &&
277325 is_move_assignable<second_type>::value,
278 pair, __nat>::type&& __p)
326 pair, __nat>&& __p)
279327 _NOEXCEPT_(is_nothrow_move_assignable<first_type>::value &&
280328 is_nothrow_move_assignable<second_type>::value)
281329 {
......@@ -284,10 +332,54 @@ struct _LIBCPP_TEMPLATE_VIS pair
284332 return *this;
285333 }
286334
335#if _LIBCPP_STD_VER > 20
336 _LIBCPP_HIDE_FROM_ABI constexpr
337 const pair& operator=(pair const& __p) const
338 noexcept(is_nothrow_copy_assignable_v<const first_type> &&
339 is_nothrow_copy_assignable_v<const second_type>)
340 requires(is_copy_assignable_v<const first_type> &&
341 is_copy_assignable_v<const second_type>) {
342 first = __p.first;
343 second = __p.second;
344 return *this;
345 }
346
347 _LIBCPP_HIDE_FROM_ABI constexpr
348 const pair& operator=(pair&& __p) const
349 noexcept(is_nothrow_assignable_v<const first_type&, first_type> &&
350 is_nothrow_assignable_v<const second_type&, second_type>)
351 requires(is_assignable_v<const first_type&, first_type> &&
352 is_assignable_v<const second_type&, second_type>) {
353 first = std::forward<first_type>(__p.first);
354 second = std::forward<second_type>(__p.second);
355 return *this;
356 }
357
358 template<class _U1, class _U2>
359 _LIBCPP_HIDE_FROM_ABI constexpr
360 const pair& operator=(const pair<_U1, _U2>& __p) const
361 requires(is_assignable_v<const first_type&, const _U1&> &&
362 is_assignable_v<const second_type&, const _U2&>) {
363 first = __p.first;
364 second = __p.second;
365 return *this;
366 }
367
368 template<class _U1, class _U2>
369 _LIBCPP_HIDE_FROM_ABI constexpr
370 const pair& operator=(pair<_U1, _U2>&& __p) const
371 requires(is_assignable_v<const first_type&, _U1> &&
372 is_assignable_v<const second_type&, _U2>) {
373 first = std::forward<_U1>(__p.first);
374 second = std::forward<_U2>(__p.second);
375 return *this;
376 }
377#endif // _LIBCPP_STD_VER > 20
378
287379 template <class _Tuple, typename enable_if<
288380 _CheckTLC<_Tuple>::template __enable_assign<_Tuple>()
289381 >::type* = nullptr>
290 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
382 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
291383 pair& operator=(_Tuple&& __p) {
292384 first = _VSTD::get<0>(_VSTD::forward<_Tuple>(__p));
293385 second = _VSTD::get<1>(_VSTD::forward<_Tuple>(__p));
......@@ -295,7 +387,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
295387 }
296388#endif
297389
298 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
390 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
299391 void
300392 swap(pair& __p) _NOEXCEPT_(__is_nothrow_swappable<first_type>::value &&
301393 __is_nothrow_swappable<second_type>::value)
......@@ -304,11 +396,23 @@ struct _LIBCPP_TEMPLATE_VIS pair
304396 swap(first, __p.first);
305397 swap(second, __p.second);
306398 }
399
400#if _LIBCPP_STD_VER > 20
401 _LIBCPP_HIDE_FROM_ABI constexpr
402 void swap(const pair& __p) const
403 noexcept(__is_nothrow_swappable<const first_type>::value &&
404 __is_nothrow_swappable<const second_type>::value)
405 {
406 using std::swap;
407 swap(first, __p.first);
408 swap(second, __p.second);
409 }
410#endif
307411private:
308412
309413#ifndef _LIBCPP_CXX03_LANG
310414 template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
311 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
415 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
312416 pair(piecewise_construct_t,
313417 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
314418 __tuple_indices<_I1...>, __tuple_indices<_I2...>);
......@@ -323,7 +427,7 @@ pair(_T1, _T2) -> pair<_T1, _T2>;
323427// [pairs.spec], specialized algorithms
324428
325429template <class _T1, class _T2>
326inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
430inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
327431bool
328432operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
329433{
......@@ -348,7 +452,7 @@ operator<=>(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
348452#else // _LIBCPP_STD_VER > 17
349453
350454template <class _T1, class _T2>
351inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
455inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
352456bool
353457operator!=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
354458{
......@@ -356,7 +460,7 @@ operator!=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
356460}
357461
358462template <class _T1, class _T2>
359inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
463inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
360464bool
361465operator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
362466{
......@@ -364,7 +468,7 @@ operator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
364468}
365469
366470template <class _T1, class _T2>
367inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
471inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
368472bool
369473operator> (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
370474{
......@@ -372,7 +476,7 @@ operator> (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
372476}
373477
374478template <class _T1, class _T2>
375inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
479inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
376480bool
377481operator>=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
378482{
......@@ -380,7 +484,7 @@ operator>=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
380484}
381485
382486template <class _T1, class _T2>
383inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
487inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
384488bool
385489operator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
386490{
......@@ -406,7 +510,7 @@ struct common_type<pair<_T1, _T2>, pair<_U1, _U2>> {
406510#endif // _LIBCPP_STD_VER > 20
407511
408512template <class _T1, class _T2>
409inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
513inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
410514typename enable_if
411515<
412516 __is_swappable<_T1>::value &&
......@@ -420,10 +524,20 @@ swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
420524 __x.swap(__y);
421525}
422526
423#ifndef _LIBCPP_CXX03_LANG
527#if _LIBCPP_STD_VER > 20
528template <class _T1, class _T2>
529 requires (__is_swappable<const _T1>::value &&
530 __is_swappable<const _T2>::value)
531_LIBCPP_HIDE_FROM_ABI constexpr
532void swap(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
533 noexcept(noexcept(__x.swap(__y)))
534{
535 __x.swap(__y);
536}
537#endif
424538
425539template <class _T1, class _T2>
426inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
540inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
427541pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type>
428542make_pair(_T1&& __t1, _T2&& __t2)
429543{
......@@ -431,18 +545,6 @@ make_pair(_T1&& __t1, _T2&& __t2)
431545 (_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2));
432546}
433547
434#else // _LIBCPP_CXX03_LANG
435
436template <class _T1, class _T2>
437inline _LIBCPP_INLINE_VISIBILITY
438pair<_T1,_T2>
439make_pair(_T1 __x, _T2 __y)
440{
441 return pair<_T1, _T2>(__x, __y);
442}
443
444#endif // _LIBCPP_CXX03_LANG
445
446548template <class _T1, class _T2>
447549 struct _LIBCPP_TEMPLATE_VIS tuple_size<pair<_T1, _T2> >
448550 : public integral_constant<size_t, 2> {};
......@@ -472,29 +574,27 @@ struct __get_pair<0>
472574{
473575 template <class _T1, class _T2>
474576 static
475 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
577 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
476578 _T1&
477579 get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;}
478580
479581 template <class _T1, class _T2>
480582 static
481 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
583 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
482584 const _T1&
483585 get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;}
484586
485#ifndef _LIBCPP_CXX03_LANG
486587 template <class _T1, class _T2>
487588 static
488 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
589 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
489590 _T1&&
490591 get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T1>(__p.first);}
491592
492593 template <class _T1, class _T2>
493594 static
494 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
595 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
495596 const _T1&&
496597 get(const pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<const _T1>(__p.first);}
497#endif // _LIBCPP_CXX03_LANG
498598};
499599
500600template <>
......@@ -502,33 +602,31 @@ struct __get_pair<1>
502602{
503603 template <class _T1, class _T2>
504604 static
505 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
605 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
506606 _T2&
507607 get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;}
508608
509609 template <class _T1, class _T2>
510610 static
511 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
611 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
512612 const _T2&
513613 get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;}
514614
515#ifndef _LIBCPP_CXX03_LANG
516615 template <class _T1, class _T2>
517616 static
518 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
617 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
519618 _T2&&
520619 get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T2>(__p.second);}
521620
522621 template <class _T1, class _T2>
523622 static
524 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
623 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
525624 const _T2&&
526625 get(const pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<const _T2>(__p.second);}
527#endif // _LIBCPP_CXX03_LANG
528626};
529627
530628template <size_t _Ip, class _T1, class _T2>
531inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
629inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
532630typename tuple_element<_Ip, pair<_T1, _T2> >::type&
533631get(pair<_T1, _T2>& __p) _NOEXCEPT
534632{
......@@ -536,16 +634,15 @@ get(pair<_T1, _T2>& __p) _NOEXCEPT
536634}
537635
538636template <size_t _Ip, class _T1, class _T2>
539inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
637inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
540638const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
541639get(const pair<_T1, _T2>& __p) _NOEXCEPT
542640{
543641 return __get_pair<_Ip>::get(__p);
544642}
545643
546#ifndef _LIBCPP_CXX03_LANG
547644template <size_t _Ip, class _T1, class _T2>
548inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
645inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
549646typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
550647get(pair<_T1, _T2>&& __p) _NOEXCEPT
551648{
......@@ -553,13 +650,12 @@ get(pair<_T1, _T2>&& __p) _NOEXCEPT
553650}
554651
555652template <size_t _Ip, class _T1, class _T2>
556inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
653inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
557654const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
558655get(const pair<_T1, _T2>&& __p) _NOEXCEPT
559656{
560657 return __get_pair<_Ip>::get(_VSTD::move(__p));
561658}
562#endif // _LIBCPP_CXX03_LANG
563659
564660#if _LIBCPP_STD_VER > 11
565661template <class _T1, class _T2>
......@@ -618,7 +714,7 @@ constexpr _T1 const && get(pair<_T2, _T1> const&& __p) _NOEXCEPT
618714 return __get_pair<1>::get(_VSTD::move(__p));
619715}
620716
621#endif
717#endif // _LIBCPP_STD_VER > 11
622718
623719_LIBCPP_END_NAMESPACE_STD
624720
lib/libcxx/include/__utility/rel_ops.h-3
......@@ -10,9 +10,6 @@
1010#define _LIBCPP___UTILITY_REL_OPS_H
1111
1212#include <__config>
13#include <__utility/forward.h>
14#include <__utility/move.h>
15#include <type_traits>
1613
1714#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1815# pragma GCC system_header
lib/libcxx/include/__utility/swap.h+7-3
......@@ -10,10 +10,14 @@
1010#define _LIBCPP___UTILITY_SWAP_H
1111
1212#include <__config>
13#include <__type_traits/is_move_assignable.h>
14#include <__type_traits/is_move_constructible.h>
15#include <__type_traits/is_nothrow_move_assignable.h>
16#include <__type_traits/is_nothrow_move_constructible.h>
17#include <__type_traits/is_swappable.h>
1318#include <__utility/declval.h>
1419#include <__utility/move.h>
1520#include <cstddef>
16#include <type_traits>
1721
1822#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1923# pragma GCC system_header
......@@ -30,7 +34,7 @@ using __swap_result_t = void;
3034#endif
3135
3236template <class _Tp>
33inline _LIBCPP_INLINE_VISIBILITY __swap_result_t<_Tp> _LIBCPP_CONSTEXPR_AFTER_CXX17 swap(_Tp& __x, _Tp& __y)
37inline _LIBCPP_INLINE_VISIBILITY __swap_result_t<_Tp> _LIBCPP_CONSTEXPR_SINCE_CXX20 swap(_Tp& __x, _Tp& __y)
3438 _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value&& is_nothrow_move_assignable<_Tp>::value) {
3539 _Tp __t(_VSTD::move(__x));
3640 __x = _VSTD::move(__y);
......@@ -38,7 +42,7 @@ inline _LIBCPP_INLINE_VISIBILITY __swap_result_t<_Tp> _LIBCPP_CONSTEXPR_AFTER_CX
3842}
3943
4044template <class _Tp, size_t _Np>
41inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if<__is_swappable<_Tp>::value>::type
45inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 typename enable_if<__is_swappable<_Tp>::value>::type
4246swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
4347 for (size_t __i = 0; __i != _Np; ++__i) {
4448 swap(__a[__i], __b[__i]);
lib/libcxx/include/__utility/to_underlying.h+1-1
......@@ -11,7 +11,7 @@
1111#define _LIBCPP___UTILITY_TO_UNDERLYING_H
1212
1313#include <__config>
14#include <type_traits>
14#include <__type_traits/underlying_type.h>
1515
1616#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1717# pragma GCC system_header
lib/libcxx/include/__utility/transaction.h deleted-96
......@@ -1,96 +0,0 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___UTILITY_TRANSACTION_H
10#define _LIBCPP___UTILITY_TRANSACTION_H
11
12#include <__config>
13#include <__utility/exchange.h>
14#include <__utility/move.h>
15#include <type_traits>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23// __transaction is a helper class for writing code with the strong exception guarantee.
24//
25// When writing code that can throw an exception, one can store rollback instructions in a
26// transaction so that if an exception is thrown at any point during the lifetime of the
27// transaction, it will be rolled back automatically. When the transaction is done, one
28// must mark it as being complete so it isn't rolled back when the transaction is destroyed.
29//
30// Transactions are not default constructible, they can't be copied or assigned to, but
31// they can be moved around for convenience.
32//
33// __transaction can help greatly simplify code that would normally be cluttered by
34// `#if _LIBCPP_NO_EXCEPTIONS`. For example:
35//
36// template <class Iterator, class Size, class OutputIterator>
37// Iterator uninitialized_copy_n(Iterator iter, Size n, OutputIterator out) {
38// typedef typename iterator_traits<Iterator>::value_type value_type;
39// __transaction transaction([start=out, &out] {
40// std::destroy(start, out);
41// });
42//
43// for (; n > 0; ++iter, ++out, --n) {
44// ::new ((void*)std::addressof(*out)) value_type(*iter);
45// }
46// transaction.__complete();
47// return out;
48// }
49//
50template <class _Rollback>
51struct __transaction {
52 __transaction() = delete;
53
54 _LIBCPP_HIDE_FROM_ABI
55 _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit __transaction(_Rollback __rollback)
56 : __rollback_(_VSTD::move(__rollback))
57 , __completed_(false)
58 { }
59
60 _LIBCPP_HIDE_FROM_ABI
61 _LIBCPP_CONSTEXPR_AFTER_CXX17 __transaction(__transaction&& __other)
62 _NOEXCEPT_(is_nothrow_move_constructible<_Rollback>::value)
63 : __rollback_(_VSTD::move(__other.__rollback_))
64 , __completed_(__other.__completed_)
65 {
66 __other.__completed_ = true;
67 }
68
69 __transaction(__transaction const&) = delete;
70 __transaction& operator=(__transaction const&) = delete;
71 __transaction& operator=(__transaction&&) = delete;
72
73 _LIBCPP_HIDE_FROM_ABI
74 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __complete() _NOEXCEPT {
75 __completed_ = true;
76 }
77
78 _LIBCPP_HIDE_FROM_ABI
79 _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__transaction() {
80 if (!__completed_)
81 __rollback_();
82 }
83
84private:
85 _Rollback __rollback_;
86 bool __completed_;
87};
88
89template <class _Rollback>
90_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __transaction<_Rollback> __make_transaction(_Rollback __rollback) {
91 return __transaction<_Rollback>(std::move(__rollback));
92}
93
94_LIBCPP_END_NAMESPACE_STD
95
96#endif // _LIBCPP___UTILITY_TRANSACTION_H
lib/libcxx/include/__utility/unreachable.h+6-10
......@@ -9,8 +9,8 @@
99#ifndef _LIBCPP___UTILITY_UNREACHABLE_H
1010#define _LIBCPP___UTILITY_UNREACHABLE_H
1111
12#include <__assert>
1213#include <__config>
13#include <cstdlib>
1414
1515#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1616# pragma GCC system_header
......@@ -18,21 +18,17 @@
1818
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
21_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void __libcpp_unreachable()
22{
23#if __has_builtin(__builtin_unreachable)
24 __builtin_unreachable();
25#else
26 std::abort();
27#endif
21_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void __libcpp_unreachable() {
22 _LIBCPP_ASSERT(false, "std::unreachable() was reached");
23 __builtin_unreachable();
2824}
2925
3026#if _LIBCPP_STD_VER > 20
3127
3228[[noreturn]] _LIBCPP_HIDE_FROM_ABI inline void unreachable() { __libcpp_unreachable(); }
3329
34#endif // _LIBCPP_STD_VER > 20
30#endif
3531
3632_LIBCPP_END_NAMESPACE_STD
3733
38#endif
34#endif // _LIBCPP___UTILITY_UNREACHABLE_H
lib/libcxx/include/__variant/monostate.h+18-14
......@@ -10,6 +10,7 @@
1010#ifndef _LIBCPP___VARIANT_MONOSTATE_H
1111#define _LIBCPP___VARIANT_MONOSTATE_H
1212
13#include <__compare/ordering.h>
1314#include <__config>
1415#include <__functional/hash.h>
1516#include <cstddef>
......@@ -24,31 +25,34 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2425
2526struct _LIBCPP_TEMPLATE_VIS monostate {};
2627
27inline _LIBCPP_INLINE_VISIBILITY
28constexpr bool operator<(monostate, monostate) noexcept { return false; }
28_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(monostate, monostate) noexcept { return true; }
2929
30inline _LIBCPP_INLINE_VISIBILITY
31constexpr bool operator>(monostate, monostate) noexcept { return false; }
30# if _LIBCPP_STD_VER > 17
3231
33inline _LIBCPP_INLINE_VISIBILITY
34constexpr bool operator<=(monostate, monostate) noexcept { return true; }
32_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(monostate, monostate) noexcept {
33 return strong_ordering::equal;
34}
3535
36inline _LIBCPP_INLINE_VISIBILITY
37constexpr bool operator>=(monostate, monostate) noexcept { return true; }
36# else // _LIBCPP_STD_VER > 17
3837
39inline _LIBCPP_INLINE_VISIBILITY
40constexpr bool operator==(monostate, monostate) noexcept { return true; }
38_LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(monostate, monostate) noexcept { return false; }
4139
42inline _LIBCPP_INLINE_VISIBILITY
43constexpr bool operator!=(monostate, monostate) noexcept { return false; }
40_LIBCPP_HIDE_FROM_ABI constexpr bool operator<(monostate, monostate) noexcept { return false; }
41
42_LIBCPP_HIDE_FROM_ABI constexpr bool operator>(monostate, monostate) noexcept { return false; }
43
44_LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(monostate, monostate) noexcept { return true; }
45
46_LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(monostate, monostate) noexcept { return true; }
47
48# endif // _LIBCPP_STD_VER > 17
4449
4550template <>
4651struct _LIBCPP_TEMPLATE_VIS hash<monostate> {
4752 using argument_type = monostate;
4853 using result_type = size_t;
4954
50 inline _LIBCPP_INLINE_VISIBILITY
51 result_type operator()(const argument_type&) const _NOEXCEPT {
55 inline _LIBCPP_HIDE_FROM_ABI result_type operator()(const argument_type&) const _NOEXCEPT {
5256 return 66740831; // return a fundamentally attractive random value.
5357 }
5458};
lib/libcxx/include/__verbose_abort+30-24
......@@ -17,35 +17,41 @@
1717# pragma GCC system_header
1818#endif
1919
20// Provide a default implementation of __libcpp_verbose_abort if we know that neither the built
21// library not the user is providing one. Otherwise, just declare it and use the one from the
22// built library or the one provided by the user.
23//
24// We can't provide a great implementation because it needs to be pretty much
25// dependency-free (this is included everywhere else in the library).
26#if defined(_LIBCPP_HAS_NO_VERBOSE_ABORT_IN_LIBRARY) && !defined(_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED)
27
28extern "C" void abort();
29
30_LIBCPP_BEGIN_NAMESPACE_STD
31
32_LIBCPP_NORETURN _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) _LIBCPP_HIDE_FROM_ABI inline
33void __libcpp_verbose_abort(const char *, ...) {
34 ::abort();
35 __builtin_unreachable(); // never reached, but needed to tell the compiler that the function never returns
36}
37
38_LIBCPP_END_NAMESPACE_STD
39
40#else
41
4220_LIBCPP_BEGIN_NAMESPACE_STD
4321
22// This function should never be called directly from the code -- it should only be called through
23// the _LIBCPP_VERBOSE_ABORT macro.
4424_LIBCPP_NORETURN _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2)
4525void __libcpp_verbose_abort(const char *__format, ...);
4626
47_LIBCPP_END_NAMESPACE_STD
27// _LIBCPP_VERBOSE_ABORT(format, args...)
28//
29// This macro is used to abort the program abnormally while providing additional diagnostic information.
30//
31// The first argument is a printf-style format string, and the remaining arguments are values to format
32// into the format-string. This macro can be customized by users to provide fine-grained control over
33// how verbose termination is triggered.
34//
35// If the user does not supply their own version of the _LIBCPP_VERBOSE_ABORT macro, we pick the default
36// behavior based on whether we know the built library we're running against provides support for the
37// verbose termination handler or not. If it does, we call it. If it doesn't, we call __builtin_abort to
38// make sure that the program terminates but without taking any complex dependencies in this header.
39#if !defined(_LIBCPP_VERBOSE_ABORT)
40
41// Support _LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED until LLVM 18, but tell people
42// to move to customizing _LIBCPP_VERBOSE_ABORT instead.
43# if defined(_LIBCPP_HAS_NO_VERBOSE_ABORT_IN_LIBRARY) && defined(_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED)
44# undef _LIBCPP_HAS_NO_VERBOSE_ABORT_IN_LIBRARY
45# warning _LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED is deprecated, please customize _LIBCPP_VERBOSE_ABORT instead
46# endif
47
48# if defined(_LIBCPP_HAS_NO_VERBOSE_ABORT_IN_LIBRARY)
49# define _LIBCPP_VERBOSE_ABORT(...) __builtin_abort()
50# else
51# define _LIBCPP_VERBOSE_ABORT(...) ::std::__libcpp_verbose_abort(__VA_ARGS__)
52# endif
53#endif // !defined(_LIBCPP_VERBOSE_ABORT)
4854
49#endif
55_LIBCPP_END_NAMESPACE_STD
5056
5157#endif // _LIBCPP___VERBOSE_ABORT
lib/libcxx/include/algorithm+17-10
......@@ -1704,12 +1704,9 @@ template <class BidirectionalIterator, class Compare>
17041704*/
17051705
17061706#include <__assert> // all public C++ headers provide the assertion handler
1707#include <__bits>
17081707#include <__config>
17091708#include <__debug>
17101709#include <cstddef>
1711#include <cstring>
1712#include <memory>
17131710#include <type_traits>
17141711#include <version>
17151712
......@@ -1899,13 +1896,9 @@ template <class BidirectionalIterator, class Compare>
18991896#include <__algorithm/unwrap_iter.h>
19001897#include <__algorithm/upper_bound.h>
19011898
1902#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
1903# include <chrono>
1904# include <iterator>
1905# include <utility>
1906#endif
1907
19081899// standard-mandated includes
1900
1901// [algorithm.syn]
19091902#include <initializer_list>
19101903
19111904#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -1913,7 +1906,21 @@ template <class BidirectionalIterator, class Compare>
19131906#endif
19141907
19151908#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
1916# include <__pstl_algorithm>
1909# include <__pstl_algorithm>
1910#endif
1911
1912#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
1913# include <chrono>
1914#endif
1915
1916#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1917# include <atomic>
1918# include <concepts>
1919# include <cstring>
1920# include <iterator>
1921# include <memory>
1922# include <stdexcept>
1923# include <utility>
19171924#endif
19181925
19191926#endif // _LIBCPP_ALGORITHM
lib/libcxx/include/any+57-43
......@@ -83,21 +83,20 @@ namespace std {
8383#include <__assert> // all public C++ headers provide the assertion handler
8484#include <__availability>
8585#include <__config>
86#include <__memory/allocator.h>
87#include <__memory/allocator_destructor.h>
88#include <__memory/allocator_traits.h>
89#include <__memory/unique_ptr.h>
8690#include <__utility/forward.h>
8791#include <__utility/in_place.h>
8892#include <__utility/move.h>
8993#include <__utility/unreachable.h>
9094#include <cstdlib>
9195#include <initializer_list>
92#include <memory>
9396#include <type_traits>
9497#include <typeinfo>
9598#include <version>
9699
97#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
98# include <chrono>
99#endif
100
101100#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
102101# pragma GCC system_header
103102#endif
......@@ -106,7 +105,7 @@ namespace std {
106105class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast
107106{
108107public:
109 virtual const char* what() const _NOEXCEPT;
108 const char* what() const _NOEXCEPT override;
110109};
111110} // namespace std
112111
......@@ -139,7 +138,9 @@ add_pointer_t<_ValueType> any_cast(any *) _NOEXCEPT;
139138
140139namespace __any_imp
141140{
141 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
142142 using _Buffer = aligned_storage_t<3*sizeof(void*), alignment_of<void*>::value>;
143 _LIBCPP_SUPPRESS_DEPRECATED_POP
143144
144145 template <class _Tp>
145146 using _IsSmallObject = integral_constant<bool
......@@ -194,18 +195,18 @@ class _LIBCPP_TEMPLATE_VIS any
194195public:
195196 // construct/destruct
196197 _LIBCPP_INLINE_VISIBILITY
197 constexpr any() _NOEXCEPT : __h(nullptr) {}
198 constexpr any() _NOEXCEPT : __h_(nullptr) {}
198199
199200 _LIBCPP_INLINE_VISIBILITY
200 any(any const & __other) : __h(nullptr)
201 any(any const & __other) : __h_(nullptr)
201202 {
202 if (__other.__h) __other.__call(_Action::_Copy, this);
203 if (__other.__h_) __other.__call(_Action::_Copy, this);
203204 }
204205
205206 _LIBCPP_INLINE_VISIBILITY
206 any(any && __other) _NOEXCEPT : __h(nullptr)
207 any(any && __other) _NOEXCEPT : __h_(nullptr)
207208 {
208 if (__other.__h) __other.__call(_Action::_Move, this);
209 if (__other.__h_) __other.__call(_Action::_Move, this);
209210 }
210211
211212 template <
......@@ -284,19 +285,19 @@ public:
284285
285286 // 6.3.3 any modifiers
286287 _LIBCPP_INLINE_VISIBILITY
287 void reset() _NOEXCEPT { if (__h) this->__call(_Action::_Destroy); }
288 void reset() _NOEXCEPT { if (__h_) this->__call(_Action::_Destroy); }
288289
289290 _LIBCPP_INLINE_VISIBILITY
290291 void swap(any & __rhs) _NOEXCEPT;
291292
292293 // 6.3.4 any observers
293294 _LIBCPP_INLINE_VISIBILITY
294 bool has_value() const _NOEXCEPT { return __h != nullptr; }
295 bool has_value() const _NOEXCEPT { return __h_ != nullptr; }
295296
296297#if !defined(_LIBCPP_NO_RTTI)
297298 _LIBCPP_INLINE_VISIBILITY
298299 const type_info & type() const _NOEXCEPT {
299 if (__h) {
300 if (__h_) {
300301 return *static_cast<type_info const *>(this->__call(_Action::_TypeInfo));
301302 } else {
302303 return typeid(void);
......@@ -320,7 +321,7 @@ private:
320321 type_info const * __info = nullptr,
321322 const void* __fallback_info = nullptr) const
322323 {
323 return __h(__a, this, __other, __info, __fallback_info);
324 return __h_(__a, this, __other, __info, __fallback_info);
324325 }
325326
326327 _LIBCPP_INLINE_VISIBILITY
......@@ -328,7 +329,7 @@ private:
328329 type_info const * __info = nullptr,
329330 const void* __fallback_info = nullptr)
330331 {
331 return __h(__a, this, __other, __info, __fallback_info);
332 return __h_(__a, this, __other, __info, __fallback_info);
332333 }
333334
334335 template <class>
......@@ -344,8 +345,8 @@ private:
344345 friend add_pointer_t<_ValueType>
345346 any_cast(any *) _NOEXCEPT;
346347
347 _HandleFuncPtr __h = nullptr;
348 _Storage __s;
348 _HandleFuncPtr __h_ = nullptr;
349 _Storage __s_;
349350};
350351
351352namespace __any_imp
......@@ -382,9 +383,9 @@ namespace __any_imp
382383 typedef allocator<_Tp> _Alloc;
383384 typedef allocator_traits<_Alloc> _ATraits;
384385 _Alloc __a;
385 _Tp * __ret = static_cast<_Tp*>(static_cast<void*>(&__dest.__s.__buf));
386 _Tp * __ret = static_cast<_Tp*>(static_cast<void*>(&__dest.__s_.__buf));
386387 _ATraits::construct(__a, __ret, _VSTD::forward<_Args>(__args)...);
387 __dest.__h = &_SmallHandler::__handle;
388 __dest.__h_ = &_SmallHandler::__handle;
388389 return *__ret;
389390 }
390391
......@@ -394,21 +395,21 @@ namespace __any_imp
394395 typedef allocator<_Tp> _Alloc;
395396 typedef allocator_traits<_Alloc> _ATraits;
396397 _Alloc __a;
397 _Tp * __p = static_cast<_Tp *>(static_cast<void*>(&__this.__s.__buf));
398 _Tp * __p = static_cast<_Tp *>(static_cast<void*>(&__this.__s_.__buf));
398399 _ATraits::destroy(__a, __p);
399 __this.__h = nullptr;
400 __this.__h_ = nullptr;
400401 }
401402
402403 _LIBCPP_INLINE_VISIBILITY
403404 static void __copy(any const & __this, any & __dest) {
404405 _SmallHandler::__create(__dest, *static_cast<_Tp const *>(
405 static_cast<void const *>(&__this.__s.__buf)));
406 static_cast<void const *>(&__this.__s_.__buf)));
406407 }
407408
408409 _LIBCPP_INLINE_VISIBILITY
409410 static void __move(any & __this, any & __dest) {
410411 _SmallHandler::__create(__dest, _VSTD::move(
411 *static_cast<_Tp*>(static_cast<void*>(&__this.__s.__buf))));
412 *static_cast<_Tp*>(static_cast<void*>(&__this.__s_.__buf))));
412413 __destroy(__this);
413414 }
414415
......@@ -418,7 +419,7 @@ namespace __any_imp
418419 const void* __fallback_id)
419420 {
420421 if (__any_imp::__compare_typeid<_Tp>(__info, __fallback_id))
421 return static_cast<void*>(&__this.__s.__buf);
422 return static_cast<void*>(&__this.__s_.__buf);
422423 return nullptr;
423424 }
424425
......@@ -470,8 +471,8 @@ namespace __any_imp
470471 unique_ptr<_Tp, _Dp> __hold(_ATraits::allocate(__a, 1), _Dp(__a, 1));
471472 _Tp * __ret = __hold.get();
472473 _ATraits::construct(__a, __ret, _VSTD::forward<_Args>(__args)...);
473 __dest.__s.__ptr = __hold.release();
474 __dest.__h = &_LargeHandler::__handle;
474 __dest.__s_.__ptr = __hold.release();
475 __dest.__h_ = &_LargeHandler::__handle;
475476 return *__ret;
476477 }
477478
......@@ -482,22 +483,22 @@ namespace __any_imp
482483 typedef allocator<_Tp> _Alloc;
483484 typedef allocator_traits<_Alloc> _ATraits;
484485 _Alloc __a;
485 _Tp * __p = static_cast<_Tp *>(__this.__s.__ptr);
486 _Tp * __p = static_cast<_Tp *>(__this.__s_.__ptr);
486487 _ATraits::destroy(__a, __p);
487488 _ATraits::deallocate(__a, __p, 1);
488 __this.__h = nullptr;
489 __this.__h_ = nullptr;
489490 }
490491
491492 _LIBCPP_INLINE_VISIBILITY
492493 static void __copy(any const & __this, any & __dest) {
493 _LargeHandler::__create(__dest, *static_cast<_Tp const *>(__this.__s.__ptr));
494 _LargeHandler::__create(__dest, *static_cast<_Tp const *>(__this.__s_.__ptr));
494495 }
495496
496497 _LIBCPP_INLINE_VISIBILITY
497498 static void __move(any & __this, any & __dest) {
498 __dest.__s.__ptr = __this.__s.__ptr;
499 __dest.__h = &_LargeHandler::__handle;
500 __this.__h = nullptr;
499 __dest.__s_.__ptr = __this.__s_.__ptr;
500 __dest.__h_ = &_LargeHandler::__handle;
501 __this.__h_ = nullptr;
501502 }
502503
503504 _LIBCPP_INLINE_VISIBILITY
......@@ -505,7 +506,7 @@ namespace __any_imp
505506 void const* __fallback_info)
506507 {
507508 if (__any_imp::__compare_typeid<_Tp>(__info, __fallback_info))
508 return static_cast<void*>(__this.__s.__ptr);
509 return static_cast<void*>(__this.__s_.__ptr);
509510 return nullptr;
510511
511512 }
......@@ -525,7 +526,7 @@ namespace __any_imp
525526
526527
527528template <class _ValueType, class _Tp, class>
528any::any(_ValueType && __v) : __h(nullptr)
529any::any(_ValueType && __v) : __h_(nullptr)
529530{
530531 __any_imp::_Handler<_Tp>::__create(*this, _VSTD::forward<_ValueType>(__v));
531532}
......@@ -567,16 +568,16 @@ void any::swap(any & __rhs) _NOEXCEPT
567568{
568569 if (this == &__rhs)
569570 return;
570 if (__h && __rhs.__h) {
571 if (__h_ && __rhs.__h_) {
571572 any __tmp;
572573 __rhs.__call(_Action::_Move, &__tmp);
573574 this->__call(_Action::_Move, &__rhs);
574575 __tmp.__call(_Action::_Move, this);
575576 }
576 else if (__h) {
577 else if (__h_) {
577578 this->__call(_Action::_Move, &__rhs);
578579 }
579 else if (__rhs.__h) {
580 else if (__rhs.__h_) {
580581 __rhs.__call(_Action::_Move, this);
581582 }
582583}
......@@ -606,7 +607,7 @@ inline _LIBCPP_INLINE_VISIBILITY
606607_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
607608_ValueType any_cast(any const & __v)
608609{
609 using _RawValueType = __uncvref_t<_ValueType>;
610 using _RawValueType = __remove_cvref_t<_ValueType>;
610611 static_assert(is_constructible<_ValueType, _RawValueType const &>::value,
611612 "ValueType is required to be a const lvalue reference "
612613 "or a CopyConstructible type");
......@@ -621,7 +622,7 @@ inline _LIBCPP_INLINE_VISIBILITY
621622_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
622623_ValueType any_cast(any & __v)
623624{
624 using _RawValueType = __uncvref_t<_ValueType>;
625 using _RawValueType = __remove_cvref_t<_ValueType>;
625626 static_assert(is_constructible<_ValueType, _RawValueType &>::value,
626627 "ValueType is required to be an lvalue reference "
627628 "or a CopyConstructible type");
......@@ -636,7 +637,7 @@ inline _LIBCPP_INLINE_VISIBILITY
636637_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
637638_ValueType any_cast(any && __v)
638639{
639 using _RawValueType = __uncvref_t<_ValueType>;
640 using _RawValueType = __remove_cvref_t<_ValueType>;
640641 static_assert(is_constructible<_ValueType, _RawValueType>::value,
641642 "ValueType is required to be an rvalue reference "
642643 "or a CopyConstructible type");
......@@ -676,8 +677,8 @@ any_cast(any * __any) _NOEXCEPT
676677 using __any_imp::_Action;
677678 static_assert(!is_reference<_ValueType>::value,
678679 "_ValueType may not be a reference.");
679 typedef typename add_pointer<_ValueType>::type _ReturnType;
680 if (__any && __any->__h) {
680 typedef add_pointer_t<_ValueType> _ReturnType;
681 if (__any && __any->__h_) {
681682 void *__p = __any->__call(_Action::_Get, nullptr,
682683#if !defined(_LIBCPP_NO_RTTI)
683684 &typeid(_ValueType),
......@@ -695,4 +696,17 @@ any_cast(any * __any) _NOEXCEPT
695696
696697_LIBCPP_END_NAMESPACE_STD
697698
699#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
700# include <chrono>
701#endif
702
703#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
704# include <atomic>
705# include <concepts>
706# include <iosfwd>
707# include <iterator>
708# include <memory>
709# include <variant>
710#endif
711
698712#endif // _LIBCPP_ANY
lib/libcxx/include/array+72-68
......@@ -115,7 +115,7 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
115115#include <__assert> // all public C++ headers provide the assertion handler
116116#include <__config>
117117#include <__iterator/reverse_iterator.h>
118#include <__tuple>
118#include <__tuple_dir/sfinae_helpers.h>
119119#include <__utility/integer_sequence.h>
120120#include <__utility/move.h>
121121#include <__utility/unreachable.h>
......@@ -123,12 +123,6 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
123123#include <type_traits>
124124#include <version>
125125
126#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
127# include <algorithm>
128# include <iterator>
129# include <utility>
130#endif
131
132126// standard-mandated includes
133127
134128// [iterator.range]
......@@ -142,6 +136,10 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
142136#include <compare>
143137#include <initializer_list>
144138
139// [tuple.helper]
140#include <__tuple_dir/tuple_element.h>
141#include <__tuple_dir/tuple_size.h>
142
145143#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
146144# pragma GCC system_header
147145#endif
......@@ -168,42 +166,42 @@ struct _LIBCPP_TEMPLATE_VIS array
168166 _Tp __elems_[_Size];
169167
170168 // No explicit construct/copy/destroy for aggregate type
171 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
169 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
172170 void fill(const value_type& __u) {
173171 _VSTD::fill_n(data(), _Size, __u);
174172 }
175173
176 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
174 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
177175 void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
178176 _VSTD::swap_ranges(data(), data() + _Size, __a.data());
179177 }
180178
181179 // iterators:
182 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
180 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
183181 iterator begin() _NOEXCEPT {return iterator(data());}
184 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
182 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
185183 const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
186 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
184 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
187185 iterator end() _NOEXCEPT {return iterator(data() + _Size);}
188 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
186 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
189187 const_iterator end() const _NOEXCEPT {return const_iterator(data() + _Size);}
190188
191 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
189 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
192190 reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
193 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
191 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
194192 const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
195 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
193 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
196194 reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
197 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
195 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
198196 const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
199197
200 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
198 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
201199 const_iterator cbegin() const _NOEXCEPT {return begin();}
202 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
200 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
203201 const_iterator cend() const _NOEXCEPT {return end();}
204 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
202 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
205203 const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
206 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
204 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
207205 const_reverse_iterator crend() const _NOEXCEPT {return rend();}
208206
209207 // capacity:
......@@ -215,39 +213,39 @@ struct _LIBCPP_TEMPLATE_VIS array
215213 _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return _Size == 0;}
216214
217215 // element access:
218 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
216 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
219217 reference operator[](size_type __n) _NOEXCEPT {
220218 _LIBCPP_ASSERT(__n < _Size, "out-of-bounds access in std::array<T, N>");
221219 return __elems_[__n];
222220 }
223 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
221 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
224222 const_reference operator[](size_type __n) const _NOEXCEPT {
225223 _LIBCPP_ASSERT(__n < _Size, "out-of-bounds access in std::array<T, N>");
226224 return __elems_[__n];
227225 }
228226
229 _LIBCPP_CONSTEXPR_AFTER_CXX14 reference at(size_type __n)
227 _LIBCPP_CONSTEXPR_SINCE_CXX17 reference at(size_type __n)
230228 {
231229 if (__n >= _Size)
232230 __throw_out_of_range("array::at");
233231 return __elems_[__n];
234232 }
235233
236 _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference at(size_type __n) const
234 _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference at(size_type __n) const
237235 {
238236 if (__n >= _Size)
239237 __throw_out_of_range("array::at");
240238 return __elems_[__n];
241239 }
242240
243 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference front() _NOEXCEPT {return (*this)[0];}
244 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const _NOEXCEPT {return (*this)[0];}
245 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back() _NOEXCEPT {return (*this)[_Size - 1];}
246 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const _NOEXCEPT {return (*this)[_Size - 1];}
241 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 reference front() _NOEXCEPT {return (*this)[0];}
242 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference front() const _NOEXCEPT {return (*this)[0];}
243 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 reference back() _NOEXCEPT {return (*this)[_Size - 1];}
244 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference back() const _NOEXCEPT {return (*this)[_Size - 1];}
247245
248 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
246 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
249247 value_type* data() _NOEXCEPT {return __elems_;}
250 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
248 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
251249 const value_type* data() const _NOEXCEPT {return __elems_;}
252250};
253251
......@@ -268,56 +266,55 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>
268266 typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
269267 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
270268
271 typedef typename conditional<is_const<_Tp>::value, const char,
272 char>::type _CharType;
269 typedef __conditional_t<is_const<_Tp>::value, const char, char> _CharType;
273270
274271 struct _ArrayInStructT { _Tp __data_[1]; };
275272 _ALIGNAS_TYPE(_ArrayInStructT) _CharType __elems_[sizeof(_ArrayInStructT)];
276273
277 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
274 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
278275 value_type* data() _NOEXCEPT {return nullptr;}
279 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
276 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
280277 const value_type* data() const _NOEXCEPT {return nullptr;}
281278
282279 // No explicit construct/copy/destroy for aggregate type
283 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
280 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
284281 void fill(const value_type&) {
285282 static_assert(!is_const<_Tp>::value,
286283 "cannot fill zero-sized array of type 'const T'");
287284 }
288285
289 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
286 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
290287 void swap(array&) _NOEXCEPT {
291288 static_assert(!is_const<_Tp>::value,
292289 "cannot swap zero-sized array of type 'const T'");
293290 }
294291
295292 // iterators:
296 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
293 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
297294 iterator begin() _NOEXCEPT {return iterator(data());}
298 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
295 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
299296 const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
300 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
297 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
301298 iterator end() _NOEXCEPT {return iterator(data());}
302 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
299 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
303300 const_iterator end() const _NOEXCEPT {return const_iterator(data());}
304301
305 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
302 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
306303 reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
307 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
304 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
308305 const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
309 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
306 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
310307 reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
311 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
308 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
312309 const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
313310
314 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
311 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
315312 const_iterator cbegin() const _NOEXCEPT {return begin();}
316 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
313 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
317314 const_iterator cend() const _NOEXCEPT {return end();}
318 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
315 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
319316 const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
320 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
317 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
321318 const_reverse_iterator crend() const _NOEXCEPT {return rend();}
322319
323320 // capacity:
......@@ -329,49 +326,49 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>
329326 _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return true;}
330327
331328 // element access:
332 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
329 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
333330 reference operator[](size_type) _NOEXCEPT {
334331 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
335332 __libcpp_unreachable();
336333 }
337334
338 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
335 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
339336 const_reference operator[](size_type) const _NOEXCEPT {
340337 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
341338 __libcpp_unreachable();
342339 }
343340
344 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
341 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
345342 reference at(size_type) {
346343 __throw_out_of_range("array<T, 0>::at");
347344 __libcpp_unreachable();
348345 }
349346
350 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
347 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
351348 const_reference at(size_type) const {
352349 __throw_out_of_range("array<T, 0>::at");
353350 __libcpp_unreachable();
354351 }
355352
356 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
353 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
357354 reference front() _NOEXCEPT {
358355 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
359356 __libcpp_unreachable();
360357 }
361358
362 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
359 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
363360 const_reference front() const _NOEXCEPT {
364361 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
365362 __libcpp_unreachable();
366363 }
367364
368 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
365 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
369366 reference back() _NOEXCEPT {
370367 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
371368 __libcpp_unreachable();
372369 }
373370
374 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
371 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
375372 const_reference back() const _NOEXCEPT {
376373 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
377374 __libcpp_unreachable();
......@@ -389,7 +386,7 @@ array(_Tp, _Args...)
389386
390387template <class _Tp, size_t _Size>
391388inline _LIBCPP_INLINE_VISIBILITY
392_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
389_LIBCPP_CONSTEXPR_SINCE_CXX20 bool
393390operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
394391{
395392 return _VSTD::equal(__x.begin(), __x.end(), __y.begin());
......@@ -397,7 +394,7 @@ operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
397394
398395template <class _Tp, size_t _Size>
399396inline _LIBCPP_INLINE_VISIBILITY
400_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
397_LIBCPP_CONSTEXPR_SINCE_CXX20 bool
401398operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
402399{
403400 return !(__x == __y);
......@@ -405,7 +402,7 @@ operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
405402
406403template <class _Tp, size_t _Size>
407404inline _LIBCPP_INLINE_VISIBILITY
408_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
405_LIBCPP_CONSTEXPR_SINCE_CXX20 bool
409406operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
410407{
411408 return _VSTD::lexicographical_compare(__x.begin(), __x.end(),
......@@ -414,7 +411,7 @@ operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
414411
415412template <class _Tp, size_t _Size>
416413inline _LIBCPP_INLINE_VISIBILITY
417_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
414_LIBCPP_CONSTEXPR_SINCE_CXX20 bool
418415operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
419416{
420417 return __y < __x;
......@@ -422,7 +419,7 @@ operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
422419
423420template <class _Tp, size_t _Size>
424421inline _LIBCPP_INLINE_VISIBILITY
425_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
422_LIBCPP_CONSTEXPR_SINCE_CXX20 bool
426423operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
427424{
428425 return !(__y < __x);
......@@ -430,14 +427,14 @@ operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
430427
431428template <class _Tp, size_t _Size>
432429inline _LIBCPP_INLINE_VISIBILITY
433_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
430_LIBCPP_CONSTEXPR_SINCE_CXX20 bool
434431operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
435432{
436433 return !(__x < __y);
437434}
438435
439436template <class _Tp, size_t _Size>
440inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
437inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
441438__enable_if_t<_Size == 0 || __is_swappable<_Tp>::value, void>
442439swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
443440 _NOEXCEPT_(noexcept(__x.swap(__y)))
......@@ -457,7 +454,7 @@ struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> >
457454};
458455
459456template <size_t _Ip, class _Tp, size_t _Size>
460inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
457inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
461458_Tp&
462459get(array<_Tp, _Size>& __a) _NOEXCEPT
463460{
......@@ -466,7 +463,7 @@ get(array<_Tp, _Size>& __a) _NOEXCEPT
466463}
467464
468465template <size_t _Ip, class _Tp, size_t _Size>
469inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
466inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
470467const _Tp&
471468get(const array<_Tp, _Size>& __a) _NOEXCEPT
472469{
......@@ -475,7 +472,7 @@ get(const array<_Tp, _Size>& __a) _NOEXCEPT
475472}
476473
477474template <size_t _Ip, class _Tp, size_t _Size>
478inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
475inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
479476_Tp&&
480477get(array<_Tp, _Size>&& __a) _NOEXCEPT
481478{
......@@ -484,7 +481,7 @@ get(array<_Tp, _Size>&& __a) _NOEXCEPT
484481}
485482
486483template <size_t _Ip, class _Tp, size_t _Size>
487inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
484inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
488485const _Tp&&
489486get(const array<_Tp, _Size>&& __a) _NOEXCEPT
490487{
......@@ -535,4 +532,11 @@ to_array(_Tp(&&__arr)[_Size]) noexcept(is_nothrow_move_constructible_v<_Tp>) {
535532
536533_LIBCPP_END_NAMESPACE_STD
537534
535#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
536# include <algorithm>
537# include <concepts>
538# include <iterator>
539# include <utility>
540#endif
541
538542#endif // _LIBCPP_ARRAY
lib/libcxx/include/atomic+85-89
......@@ -377,23 +377,23 @@ template<class T>
377377 memory_order) noexcept;
378378
379379template<class T>
380 void atomic_wait(const volatile atomic<T>*, atomic<T>::value_type);
380 void atomic_wait(const volatile atomic<T>*, atomic<T>::value_type) noexcept;
381381template<class T>
382 void atomic_wait(const atomic<T>*, atomic<T>::value_type);
382 void atomic_wait(const atomic<T>*, atomic<T>::value_type) noexcept;
383383template<class T>
384384 void atomic_wait_explicit(const volatile atomic<T>*, atomic<T>::value_type,
385 memory_order);
385 memory_order) noexcept;
386386template<class T>
387387 void atomic_wait_explicit(const atomic<T>*, atomic<T>::value_type,
388 memory_order);
388 memory_order) noexcept;
389389template<class T>
390 void atomic_notify_one(volatile atomic<T>*);
390 void atomic_notify_one(volatile atomic<T>*) noexcept;
391391template<class T>
392 void atomic_notify_one(atomic<T>*);
392 void atomic_notify_one(atomic<T>*) noexcept;
393393template<class T>
394 void atomic_notify_all(volatile atomic<T>*);
394 void atomic_notify_all(volatile atomic<T>*) noexcept;
395395template<class T>
396 void atomic_notify_all(atomic<T>*);
396 void atomic_notify_all(atomic<T>*) noexcept;
397397
398398// Atomics for standard typedef types
399399
......@@ -524,20 +524,25 @@ template <class T>
524524#include <__config>
525525#include <__thread/poll_with_backoff.h>
526526#include <__thread/timed_backoff_policy.h>
527#include <__type_traits/conditional.h>
528#include <__type_traits/decay.h>
529#include <__type_traits/is_assignable.h>
530#include <__type_traits/is_function.h>
531#include <__type_traits/is_nothrow_default_constructible.h>
532#include <__type_traits/is_same.h>
533#include <__type_traits/is_trivially_copyable.h>
534#include <__type_traits/remove_const.h>
535#include <__type_traits/remove_pointer.h>
536#include <__type_traits/underlying_type.h>
527537#include <cstddef>
528538#include <cstdint>
529539#include <cstring>
530#include <type_traits>
531540#include <version>
532541
533542#ifndef _LIBCPP_HAS_NO_THREADS
534543# include <__threading_support>
535544#endif
536545
537#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
538# include <chrono>
539#endif
540
541546#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
542547# pragma GCC system_header
543548#endif
......@@ -948,13 +953,13 @@ void __cxx_atomic_store(__cxx_atomic_base_impl<_Tp> * __a, _Tp __val, memory_ord
948953template<class _Tp>
949954_LIBCPP_INLINE_VISIBILITY
950955_Tp __cxx_atomic_load(__cxx_atomic_base_impl<_Tp> const volatile* __a, memory_order __order) _NOEXCEPT {
951 using __ptr_type = typename remove_const<decltype(__a->__a_value)>::type*;
956 using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*;
952957 return __c11_atomic_load(const_cast<__ptr_type>(&__a->__a_value), static_cast<__memory_order_underlying_t>(__order));
953958}
954959template<class _Tp>
955960_LIBCPP_INLINE_VISIBILITY
956961_Tp __cxx_atomic_load(__cxx_atomic_base_impl<_Tp> const* __a, memory_order __order) _NOEXCEPT {
957 using __ptr_type = typename remove_const<decltype(__a->__a_value)>::type*;
962 using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*;
958963 return __c11_atomic_load(const_cast<__ptr_type>(&__a->__a_value), static_cast<__memory_order_underlying_t>(__order));
959964}
960965
......@@ -1435,17 +1440,7 @@ struct __cxx_atomic_impl : public _Base {
14351440
14361441using __cxx_atomic_contention_t = __cxx_atomic_impl<__cxx_contention_t>;
14371442
1438#if defined(_LIBCPP_HAS_NO_THREADS)
1439# define _LIBCPP_HAS_NO_PLATFORM_WAIT
1440#endif
1441
1442// TODO:
1443// _LIBCPP_HAS_NO_PLATFORM_WAIT is currently a "dead" macro, in the sense that
1444// it is not tied anywhere into the build system or even documented. We should
1445// clean it up because it is technically never defined except when threads are
1446// disabled. We should clean it up in its own changeset in case we break "bad"
1447// users.
1448#ifndef _LIBCPP_HAS_NO_PLATFORM_WAIT
1443#ifndef _LIBCPP_HAS_NO_THREADS
14491444
14501445_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile*);
14511446_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile*);
......@@ -1466,10 +1461,10 @@ struct __libcpp_atomic_wait_backoff_impl {
14661461 {
14671462 if(__elapsed > chrono::microseconds(64))
14681463 {
1469 auto const __monitor = __libcpp_atomic_monitor(__a);
1464 auto const __monitor = std::__libcpp_atomic_monitor(__a);
14701465 if(__test_fn())
14711466 return true;
1472 __libcpp_atomic_wait(__a, __monitor);
1467 std::__libcpp_atomic_wait(__a, __monitor);
14731468 }
14741469 else if(__elapsed > chrono::microseconds(4))
14751470 __libcpp_thread_yield();
......@@ -1484,10 +1479,10 @@ _LIBCPP_AVAILABILITY_SYNC
14841479_LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp* __a, _Fn && __test_fn)
14851480{
14861481 __libcpp_atomic_wait_backoff_impl<_Atp, typename decay<_Fn>::type> __backoff_fn = {__a, __test_fn};
1487 return __libcpp_thread_poll_with_backoff(__test_fn, __backoff_fn);
1482 return std::__libcpp_thread_poll_with_backoff(__test_fn, __backoff_fn);
14881483}
14891484
1490#else // _LIBCPP_HAS_NO_PLATFORM_WAIT
1485#else // _LIBCPP_HAS_NO_THREADS
14911486
14921487template <class _Tp>
14931488_LIBCPP_INLINE_VISIBILITY void __cxx_atomic_notify_all(__cxx_atomic_impl<_Tp> const volatile*) { }
......@@ -1496,15 +1491,10 @@ _LIBCPP_INLINE_VISIBILITY void __cxx_atomic_notify_one(__cxx_atomic_impl<_Tp> co
14961491template <class _Atp, class _Fn>
14971492_LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp*, _Fn && __test_fn)
14981493{
1499#if defined(_LIBCPP_HAS_NO_THREADS)
1500 using _Policy = __spinning_backoff_policy;
1501#else
1502 using _Policy = __libcpp_timed_backoff_policy;
1503#endif
1504 return __libcpp_thread_poll_with_backoff(__test_fn, _Policy());
1494 return __libcpp_thread_poll_with_backoff(__test_fn, __spinning_backoff_policy());
15051495}
15061496
1507#endif // _LIBCPP_HAS_NO_PLATFORM_WAIT
1497#endif // _LIBCPP_HAS_NO_THREADS
15081498
15091499template <class _Atp, class _Tp>
15101500struct __cxx_atomic_wait_test_fn_impl {
......@@ -1513,7 +1503,7 @@ struct __cxx_atomic_wait_test_fn_impl {
15131503 memory_order __order;
15141504 _LIBCPP_INLINE_VISIBILITY bool operator()() const
15151505 {
1516 return !__cxx_nonatomic_compare_equal(__cxx_atomic_load(__a, __order), __val);
1506 return !std::__cxx_nonatomic_compare_equal(std::__cxx_atomic_load(__a, __order), __val);
15171507 }
15181508};
15191509
......@@ -1522,7 +1512,7 @@ _LIBCPP_AVAILABILITY_SYNC
15221512_LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp* __a, _Tp const __val, memory_order __order)
15231513{
15241514 __cxx_atomic_wait_test_fn_impl<_Atp, _Tp> __test_fn = {__a, __val, __order};
1525 return __cxx_atomic_wait(__a, __test_fn);
1515 return std::__cxx_atomic_wait(__a, __test_fn);
15261516}
15271517
15281518// general atomic<T>
......@@ -1545,78 +1535,78 @@ struct __atomic_base // false
15451535 _LIBCPP_INLINE_VISIBILITY
15461536 void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
15471537 _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)
1548 {__cxx_atomic_store(&__a_, __d, __m);}
1538 {std::__cxx_atomic_store(&__a_, __d, __m);}
15491539 _LIBCPP_INLINE_VISIBILITY
15501540 void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT
15511541 _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)
1552 {__cxx_atomic_store(&__a_, __d, __m);}
1542 {std::__cxx_atomic_store(&__a_, __d, __m);}
15531543 _LIBCPP_INLINE_VISIBILITY
15541544 _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT
15551545 _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m)
1556 {return __cxx_atomic_load(&__a_, __m);}
1546 {return std::__cxx_atomic_load(&__a_, __m);}
15571547 _LIBCPP_INLINE_VISIBILITY
15581548 _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT
15591549 _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m)
1560 {return __cxx_atomic_load(&__a_, __m);}
1550 {return std::__cxx_atomic_load(&__a_, __m);}
15611551 _LIBCPP_INLINE_VISIBILITY
15621552 operator _Tp() const volatile _NOEXCEPT {return load();}
15631553 _LIBCPP_INLINE_VISIBILITY
15641554 operator _Tp() const _NOEXCEPT {return load();}
15651555 _LIBCPP_INLINE_VISIBILITY
15661556 _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
1567 {return __cxx_atomic_exchange(&__a_, __d, __m);}
1557 {return std::__cxx_atomic_exchange(&__a_, __d, __m);}
15681558 _LIBCPP_INLINE_VISIBILITY
15691559 _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT
1570 {return __cxx_atomic_exchange(&__a_, __d, __m);}
1560 {return std::__cxx_atomic_exchange(&__a_, __d, __m);}
15711561 _LIBCPP_INLINE_VISIBILITY
15721562 bool compare_exchange_weak(_Tp& __e, _Tp __d,
15731563 memory_order __s, memory_order __f) volatile _NOEXCEPT
15741564 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
1575 {return __cxx_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
1565 {return std::__cxx_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
15761566 _LIBCPP_INLINE_VISIBILITY
15771567 bool compare_exchange_weak(_Tp& __e, _Tp __d,
15781568 memory_order __s, memory_order __f) _NOEXCEPT
15791569 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
1580 {return __cxx_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
1570 {return std::__cxx_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
15811571 _LIBCPP_INLINE_VISIBILITY
15821572 bool compare_exchange_strong(_Tp& __e, _Tp __d,
15831573 memory_order __s, memory_order __f) volatile _NOEXCEPT
15841574 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
1585 {return __cxx_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
1575 {return std::__cxx_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
15861576 _LIBCPP_INLINE_VISIBILITY
15871577 bool compare_exchange_strong(_Tp& __e, _Tp __d,
15881578 memory_order __s, memory_order __f) _NOEXCEPT
15891579 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
1590 {return __cxx_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
1580 {return std::__cxx_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
15911581 _LIBCPP_INLINE_VISIBILITY
15921582 bool compare_exchange_weak(_Tp& __e, _Tp __d,
15931583 memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
1594 {return __cxx_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);}
1584 {return std::__cxx_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);}
15951585 _LIBCPP_INLINE_VISIBILITY
15961586 bool compare_exchange_weak(_Tp& __e, _Tp __d,
15971587 memory_order __m = memory_order_seq_cst) _NOEXCEPT
1598 {return __cxx_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);}
1588 {return std::__cxx_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);}
15991589 _LIBCPP_INLINE_VISIBILITY
16001590 bool compare_exchange_strong(_Tp& __e, _Tp __d,
16011591 memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
1602 {return __cxx_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
1592 {return std::__cxx_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
16031593 _LIBCPP_INLINE_VISIBILITY
16041594 bool compare_exchange_strong(_Tp& __e, _Tp __d,
16051595 memory_order __m = memory_order_seq_cst) _NOEXCEPT
1606 {return __cxx_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
1596 {return std::__cxx_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
16071597
16081598 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT
1609 {__cxx_atomic_wait(&__a_, __v, __m);}
1599 {std::__cxx_atomic_wait(&__a_, __v, __m);}
16101600 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT
1611 {__cxx_atomic_wait(&__a_, __v, __m);}
1601 {std::__cxx_atomic_wait(&__a_, __v, __m);}
16121602 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_one() volatile _NOEXCEPT
1613 {__cxx_atomic_notify_one(&__a_);}
1603 {std::__cxx_atomic_notify_one(&__a_);}
16141604 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_one() _NOEXCEPT
1615 {__cxx_atomic_notify_one(&__a_);}
1605 {std::__cxx_atomic_notify_one(&__a_);}
16161606 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_all() volatile _NOEXCEPT
1617 {__cxx_atomic_notify_all(&__a_);}
1607 {std::__cxx_atomic_notify_all(&__a_);}
16181608 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_all() _NOEXCEPT
1619 {__cxx_atomic_notify_all(&__a_);}
1609 {std::__cxx_atomic_notify_all(&__a_);}
16201610
16211611#if _LIBCPP_STD_VER > 17
16221612 _LIBCPP_INLINE_VISIBILITY constexpr
......@@ -1645,7 +1635,7 @@ struct __atomic_base<_Tp, true>
16451635{
16461636 typedef __atomic_base<_Tp, false> __base;
16471637
1648 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1638 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
16491639 __atomic_base() _NOEXCEPT = default;
16501640
16511641 _LIBCPP_INLINE_VISIBILITY
......@@ -1653,34 +1643,34 @@ struct __atomic_base<_Tp, true>
16531643
16541644 _LIBCPP_INLINE_VISIBILITY
16551645 _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
1656 {return __cxx_atomic_fetch_add(&this->__a_, __op, __m);}
1646 {return std::__cxx_atomic_fetch_add(&this->__a_, __op, __m);}
16571647 _LIBCPP_INLINE_VISIBILITY
16581648 _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
1659 {return __cxx_atomic_fetch_add(&this->__a_, __op, __m);}
1649 {return std::__cxx_atomic_fetch_add(&this->__a_, __op, __m);}
16601650 _LIBCPP_INLINE_VISIBILITY
16611651 _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
1662 {return __cxx_atomic_fetch_sub(&this->__a_, __op, __m);}
1652 {return std::__cxx_atomic_fetch_sub(&this->__a_, __op, __m);}
16631653 _LIBCPP_INLINE_VISIBILITY
16641654 _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
1665 {return __cxx_atomic_fetch_sub(&this->__a_, __op, __m);}
1655 {return std::__cxx_atomic_fetch_sub(&this->__a_, __op, __m);}
16661656 _LIBCPP_INLINE_VISIBILITY
16671657 _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
1668 {return __cxx_atomic_fetch_and(&this->__a_, __op, __m);}
1658 {return std::__cxx_atomic_fetch_and(&this->__a_, __op, __m);}
16691659 _LIBCPP_INLINE_VISIBILITY
16701660 _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
1671 {return __cxx_atomic_fetch_and(&this->__a_, __op, __m);}
1661 {return std::__cxx_atomic_fetch_and(&this->__a_, __op, __m);}
16721662 _LIBCPP_INLINE_VISIBILITY
16731663 _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
1674 {return __cxx_atomic_fetch_or(&this->__a_, __op, __m);}
1664 {return std::__cxx_atomic_fetch_or(&this->__a_, __op, __m);}
16751665 _LIBCPP_INLINE_VISIBILITY
16761666 _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
1677 {return __cxx_atomic_fetch_or(&this->__a_, __op, __m);}
1667 {return std::__cxx_atomic_fetch_or(&this->__a_, __op, __m);}
16781668 _LIBCPP_INLINE_VISIBILITY
16791669 _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
1680 {return __cxx_atomic_fetch_xor(&this->__a_, __op, __m);}
1670 {return std::__cxx_atomic_fetch_xor(&this->__a_, __op, __m);}
16811671 _LIBCPP_INLINE_VISIBILITY
16821672 _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
1683 {return __cxx_atomic_fetch_xor(&this->__a_, __op, __m);}
1673 {return std::__cxx_atomic_fetch_xor(&this->__a_, __op, __m);}
16841674
16851675 _LIBCPP_INLINE_VISIBILITY
16861676 _Tp operator++(int) volatile _NOEXCEPT {return fetch_add(_Tp(1));}
......@@ -1778,29 +1768,29 @@ struct atomic<_Tp*>
17781768 _LIBCPP_INLINE_VISIBILITY
17791769 _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
17801770 // __atomic_fetch_add accepts function pointers, guard against them.
1781 static_assert(!is_function<typename remove_pointer<_Tp>::type>::value, "Pointer to function isn't allowed");
1782 return __cxx_atomic_fetch_add(&this->__a_, __op, __m);
1771 static_assert(!is_function<__remove_pointer_t<_Tp> >::value, "Pointer to function isn't allowed");
1772 return std::__cxx_atomic_fetch_add(&this->__a_, __op, __m);
17831773 }
17841774
17851775 _LIBCPP_INLINE_VISIBILITY
17861776 _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT {
17871777 // __atomic_fetch_add accepts function pointers, guard against them.
1788 static_assert(!is_function<typename remove_pointer<_Tp>::type>::value, "Pointer to function isn't allowed");
1789 return __cxx_atomic_fetch_add(&this->__a_, __op, __m);
1778 static_assert(!is_function<__remove_pointer_t<_Tp> >::value, "Pointer to function isn't allowed");
1779 return std::__cxx_atomic_fetch_add(&this->__a_, __op, __m);
17901780 }
17911781
17921782 _LIBCPP_INLINE_VISIBILITY
17931783 _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
17941784 // __atomic_fetch_add accepts function pointers, guard against them.
1795 static_assert(!is_function<typename remove_pointer<_Tp>::type>::value, "Pointer to function isn't allowed");
1796 return __cxx_atomic_fetch_sub(&this->__a_, __op, __m);
1785 static_assert(!is_function<__remove_pointer_t<_Tp> >::value, "Pointer to function isn't allowed");
1786 return std::__cxx_atomic_fetch_sub(&this->__a_, __op, __m);
17971787 }
17981788
17991789 _LIBCPP_INLINE_VISIBILITY
18001790 _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT {
18011791 // __atomic_fetch_add accepts function pointers, guard against them.
1802 static_assert(!is_function<typename remove_pointer<_Tp>::type>::value, "Pointer to function isn't allowed");
1803 return __cxx_atomic_fetch_sub(&this->__a_, __op, __m);
1792 static_assert(!is_function<__remove_pointer_t<_Tp> >::value, "Pointer to function isn't allowed");
1793 return std::__cxx_atomic_fetch_sub(&this->__a_, __op, __m);
18041794 }
18051795
18061796 _LIBCPP_INLINE_VISIBILITY
......@@ -1857,7 +1847,7 @@ _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_INLINE_VISIBILITY
18571847void
18581848atomic_init(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
18591849{
1860 __cxx_atomic_init(&__o->__a_, __d);
1850 std::__cxx_atomic_init(&__o->__a_, __d);
18611851}
18621852
18631853template <class _Tp>
......@@ -1865,7 +1855,7 @@ _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_INLINE_VISIBILITY
18651855void
18661856atomic_init(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
18671857{
1868 __cxx_atomic_init(&__o->__a_, __d);
1858 std::__cxx_atomic_init(&__o->__a_, __d);
18691859}
18701860
18711861// atomic_store
......@@ -2118,7 +2108,7 @@ void atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT
21182108 __o->notify_one();
21192109}
21202110
2121// atomic_notify_one
2111// atomic_notify_all
21222112
21232113template <class _Tp>
21242114_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
......@@ -2642,17 +2632,17 @@ typedef atomic<uintmax_t> atomic_uintmax_t;
26422632#endif
26432633
26442634#if ATOMIC_LLONG_LOCK_FREE == 2
2645typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, long long>::type __libcpp_signed_lock_free;
2646typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned long long>::type __libcpp_unsigned_lock_free;
2635typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, long long> __libcpp_signed_lock_free;
2636typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned long long> __libcpp_unsigned_lock_free;
26472637#elif ATOMIC_INT_LOCK_FREE == 2
2648typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, int>::type __libcpp_signed_lock_free;
2649typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned int>::type __libcpp_unsigned_lock_free;
2638typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, int> __libcpp_signed_lock_free;
2639typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned int> __libcpp_unsigned_lock_free;
26502640#elif ATOMIC_SHORT_LOCK_FREE == 2
2651typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, short>::type __libcpp_signed_lock_free;
2652typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned short>::type __libcpp_unsigned_lock_free;
2641typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, short> __libcpp_signed_lock_free;
2642typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned short> __libcpp_unsigned_lock_free;
26532643#elif ATOMIC_CHAR_LOCK_FREE == 2
2654typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, char>::type __libcpp_signed_lock_free;
2655typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned char>::type __libcpp_unsigned_lock_free;
2644typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, char> __libcpp_signed_lock_free;
2645typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned char> __libcpp_unsigned_lock_free;
26562646#else
26572647 // No signed/unsigned lock-free types
26582648#define _LIBCPP_NO_LOCK_FREE_TYPES
......@@ -2674,4 +2664,10 @@ typedef atomic<__libcpp_unsigned_lock_free> atomic_unsigned_lock_free;
26742664
26752665_LIBCPP_END_NAMESPACE_STD
26762666
2667#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
2668# include <cmath>
2669# include <compare>
2670# include <type_traits>
2671#endif
2672
26772673#endif // _LIBCPP_ATOMIC
lib/libcxx/include/barrier+17-8
......@@ -48,10 +48,11 @@ namespace std
4848#include <__assert> // all public C++ headers provide the assertion handler
4949#include <__availability>
5050#include <__config>
51#include <__memory/unique_ptr.h>
5152#include <__thread/timed_backoff_policy.h>
53#include <__utility/move.h>
5254#include <atomic>
5355#include <limits>
54#include <memory>
5556
5657#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
5758# pragma GCC system_header
......@@ -124,7 +125,7 @@ public:
124125
125126 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
126127 __barrier_base(ptrdiff_t __expected, _CompletionF __completion = _CompletionF())
127 : __expected_(__expected), __base_(__construct_barrier_algorithm_base(this->__expected_),
128 : __expected_(__expected), __base_(std::__construct_barrier_algorithm_base(this->__expected_),
128129 &__destroy_barrier_algorithm_base),
129130 __expected_adjustment_(0), __completion_(std::move(__completion)), __phase_(0)
130131 {
......@@ -149,7 +150,7 @@ public:
149150 auto const __test_fn = [this, __old_phase]() -> bool {
150151 return __phase_.load(memory_order_acquire) != __old_phase;
151152 };
152 __libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy());
153 std::__libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy());
153154 }
154155 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
155156 void arrive_and_drop()
......@@ -283,7 +284,7 @@ public:
283284template<class _CompletionF = __empty_completion>
284285class barrier {
285286
286 __barrier_base<_CompletionF> __b;
287 __barrier_base<_CompletionF> __b_;
287288public:
288289 using arrival_token = typename __barrier_base<_CompletionF>::arrival_token;
289290
......@@ -293,7 +294,7 @@ public:
293294
294295 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
295296 barrier(ptrdiff_t __count, _CompletionF __completion = _CompletionF())
296 : __b(__count, _VSTD::move(__completion)) {
297 : __b_(__count, _VSTD::move(__completion)) {
297298 }
298299
299300 barrier(barrier const&) = delete;
......@@ -302,12 +303,12 @@ public:
302303 [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
303304 arrival_token arrive(ptrdiff_t __update = 1)
304305 {
305 return __b.arrive(__update);
306 return __b_.arrive(__update);
306307 }
307308 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
308309 void wait(arrival_token&& __phase) const
309310 {
310 __b.wait(_VSTD::move(__phase));
311 __b_.wait(_VSTD::move(__phase));
311312 }
312313 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
313314 void arrive_and_wait()
......@@ -317,7 +318,7 @@ public:
317318 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
318319 void arrive_and_drop()
319320 {
320 __b.arrive_and_drop();
321 __b_.arrive_and_drop();
321322 }
322323};
323324
......@@ -327,4 +328,12 @@ _LIBCPP_END_NAMESPACE_STD
327328
328329_LIBCPP_POP_MACROS
329330
331#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
332# include <concepts>
333# include <iterator>
334# include <memory>
335# include <stdexcept>
336# include <variant>
337#endif
338
330339#endif //_LIBCPP_BARRIER
lib/libcxx/include/bit+16-184
......@@ -63,197 +63,29 @@ namespace std {
6363
6464#include <__assert> // all public C++ headers provide the assertion handler
6565#include <__bit/bit_cast.h>
66#include <__bit/bit_ceil.h>
67#include <__bit/bit_floor.h>
68#include <__bit/bit_log2.h>
69#include <__bit/bit_width.h>
70#include <__bit/blsr.h>
6671#include <__bit/byteswap.h>
67#include <__bits> // __libcpp_clz
68#include <__concepts/arithmetic.h>
72#include <__bit/countl.h>
73#include <__bit/countr.h>
74#include <__bit/endian.h>
75#include <__bit/has_single_bit.h>
76#include <__bit/popcount.h>
77#include <__bit/rotate.h>
6978#include <__config>
70#include <limits>
71#include <type_traits>
7279#include <version>
7380
74#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
75# include <iosfwd>
76#endif
77
78#if defined(_LIBCPP_COMPILER_MSVC)
79# include <intrin.h>
80#endif
81
8281#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
8382# pragma GCC system_header
8483#endif
8584
86_LIBCPP_PUSH_MACROS
87#include <__undef_macros>
88
89_LIBCPP_BEGIN_NAMESPACE_STD
90
91template<class _Tp>
92_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
93_Tp __rotr(_Tp __t, unsigned int __cnt) _NOEXCEPT
94{
95 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an unsigned integer type");
96 const unsigned int __dig = numeric_limits<_Tp>::digits;
97 if ((__cnt % __dig) == 0)
98 return __t;
99 return (__t >> (__cnt % __dig)) | (__t << (__dig - (__cnt % __dig)));
100}
101
102template<class _Tp>
103_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
104int __countl_zero(_Tp __t) _NOEXCEPT
105{
106 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countl_zero requires an unsigned integer type");
107 if (__t == 0)
108 return numeric_limits<_Tp>::digits;
109
110 if (sizeof(_Tp) <= sizeof(unsigned int))
111 return std::__libcpp_clz(static_cast<unsigned int>(__t))
112 - (numeric_limits<unsigned int>::digits - numeric_limits<_Tp>::digits);
113 else if (sizeof(_Tp) <= sizeof(unsigned long))
114 return std::__libcpp_clz(static_cast<unsigned long>(__t))
115 - (numeric_limits<unsigned long>::digits - numeric_limits<_Tp>::digits);
116 else if (sizeof(_Tp) <= sizeof(unsigned long long))
117 return std::__libcpp_clz(static_cast<unsigned long long>(__t))
118 - (numeric_limits<unsigned long long>::digits - numeric_limits<_Tp>::digits);
119 else
120 {
121 int __ret = 0;
122 int __iter = 0;
123 const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits;
124 while (true) {
125 __t = std::__rotr(__t, __ulldigits);
126 if ((__iter = std::__countl_zero(static_cast<unsigned long long>(__t))) != __ulldigits)
127 break;
128 __ret += __iter;
129 }
130 return __ret + __iter;
131 }
132}
133
134#if _LIBCPP_STD_VER > 17
135
136template <__libcpp_unsigned_integer _Tp>
137_LIBCPP_HIDE_FROM_ABI constexpr _Tp rotl(_Tp __t, unsigned int __cnt) noexcept {
138 const unsigned int __dig = numeric_limits<_Tp>::digits;
139 if ((__cnt % __dig) == 0)
140 return __t;
141 return (__t << (__cnt % __dig)) | (__t >> (__dig - (__cnt % __dig)));
142}
143
144template <__libcpp_unsigned_integer _Tp>
145_LIBCPP_HIDE_FROM_ABI constexpr _Tp rotr(_Tp __t, unsigned int __cnt) noexcept {
146 return std::__rotr(__t, __cnt);
147}
148
149template <__libcpp_unsigned_integer _Tp>
150_LIBCPP_HIDE_FROM_ABI constexpr int countl_zero(_Tp __t) noexcept {
151 return std::__countl_zero(__t);
152}
153
154template <__libcpp_unsigned_integer _Tp>
155_LIBCPP_HIDE_FROM_ABI constexpr int countl_one(_Tp __t) noexcept {
156 return __t != numeric_limits<_Tp>::max() ? std::countl_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits;
157}
158
159template <__libcpp_unsigned_integer _Tp>
160_LIBCPP_HIDE_FROM_ABI constexpr int countr_zero(_Tp __t) noexcept {
161 if (__t == 0)
162 return numeric_limits<_Tp>::digits;
163
164 if (sizeof(_Tp) <= sizeof(unsigned int))
165 return std::__libcpp_ctz(static_cast<unsigned int>(__t));
166 else if (sizeof(_Tp) <= sizeof(unsigned long))
167 return std::__libcpp_ctz(static_cast<unsigned long>(__t));
168 else if (sizeof(_Tp) <= sizeof(unsigned long long))
169 return std::__libcpp_ctz(static_cast<unsigned long long>(__t));
170 else {
171 int __ret = 0;
172 const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits;
173 while (static_cast<unsigned long long>(__t) == 0uLL) {
174 __ret += __ulldigits;
175 __t >>= __ulldigits;
176 }
177 return __ret + std::__libcpp_ctz(static_cast<unsigned long long>(__t));
178 }
179}
180
181template <__libcpp_unsigned_integer _Tp>
182_LIBCPP_HIDE_FROM_ABI constexpr int countr_one(_Tp __t) noexcept {
183 return __t != numeric_limits<_Tp>::max() ? std::countr_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits;
184}
185
186template <__libcpp_unsigned_integer _Tp>
187_LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noexcept {
188 if (sizeof(_Tp) <= sizeof(unsigned int))
189 return std::__libcpp_popcount(static_cast<unsigned int>(__t));
190 else if (sizeof(_Tp) <= sizeof(unsigned long))
191 return std::__libcpp_popcount(static_cast<unsigned long>(__t));
192 else if (sizeof(_Tp) <= sizeof(unsigned long long))
193 return std::__libcpp_popcount(static_cast<unsigned long long>(__t));
194 else {
195 int __ret = 0;
196 while (__t != 0) {
197 __ret += std::__libcpp_popcount(static_cast<unsigned long long>(__t));
198 __t >>= numeric_limits<unsigned long long>::digits;
199 }
200 return __ret;
201 }
202}
203
204template <__libcpp_unsigned_integer _Tp>
205_LIBCPP_HIDE_FROM_ABI constexpr bool has_single_bit(_Tp __t) noexcept {
206 return __t != 0 && (((__t & (__t - 1)) == 0));
207}
208
209// integral log base 2
210template <__libcpp_unsigned_integer _Tp>
211_LIBCPP_HIDE_FROM_ABI constexpr _Tp __bit_log2(_Tp __t) noexcept {
212 return numeric_limits<_Tp>::digits - 1 - std::countl_zero(__t);
213}
214
215template <__libcpp_unsigned_integer _Tp>
216_LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_floor(_Tp __t) noexcept {
217 return __t == 0 ? 0 : _Tp{1} << std::__bit_log2(__t);
218}
219
220template <__libcpp_unsigned_integer _Tp>
221_LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_ceil(_Tp __t) noexcept {
222 if (__t < 2)
223 return 1;
224 const unsigned __n = numeric_limits<_Tp>::digits - std::countl_zero((_Tp)(__t - 1u));
225 _LIBCPP_ASSERT(__n != numeric_limits<_Tp>::digits, "Bad input to bit_ceil");
226
227 if constexpr (sizeof(_Tp) >= sizeof(unsigned))
228 return _Tp{1} << __n;
229 else {
230 const unsigned __extra = numeric_limits<unsigned>::digits - numeric_limits<_Tp>::digits;
231 const unsigned __retVal = 1u << (__n + __extra);
232 return (_Tp)(__retVal >> __extra);
233 }
234}
235
236template <__libcpp_unsigned_integer _Tp>
237_LIBCPP_HIDE_FROM_ABI constexpr int bit_width(_Tp __t) noexcept {
238 return __t == 0 ? 0 : std::__bit_log2(__t) + 1;
239}
240
241enum class endian {
242 little = 0xDEAD,
243 big = 0xFACE,
244# if defined(_LIBCPP_LITTLE_ENDIAN)
245 native = little
246# elif defined(_LIBCPP_BIG_ENDIAN)
247 native = big
248# else
249 native = 0xCAFE
250# endif
251};
252
253#endif // _LIBCPP_STD_VER > 17
254
255_LIBCPP_END_NAMESPACE_STD
256
257_LIBCPP_POP_MACROS
85#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
86# include <iosfwd>
87# include <limits>
88# include <type_traits>
89#endif
25890
25991#endif // _LIBCPP_BIT
lib/libcxx/include/bitset+164-117
......@@ -42,61 +42,61 @@ public:
4242 template <class charT>
4343 explicit bitset(const charT* str,
4444 typename basic_string<charT>::size_type n = basic_string<charT>::npos,
45 charT zero = charT('0'), charT one = charT('1'));
45 charT zero = charT('0'), charT one = charT('1')); // constexpr since C++23
4646 template<class charT, class traits, class Allocator>
4747 explicit bitset(const basic_string<charT,traits,Allocator>& str,
4848 typename basic_string<charT,traits,Allocator>::size_type pos = 0,
4949 typename basic_string<charT,traits,Allocator>::size_type n =
5050 basic_string<charT,traits,Allocator>::npos,
51 charT zero = charT('0'), charT one = charT('1'));
51 charT zero = charT('0'), charT one = charT('1')); // constexpr since C++23
5252
5353 // 23.3.5.2 bitset operations:
54 bitset& operator&=(const bitset& rhs) noexcept;
55 bitset& operator|=(const bitset& rhs) noexcept;
56 bitset& operator^=(const bitset& rhs) noexcept;
57 bitset& operator<<=(size_t pos) noexcept;
58 bitset& operator>>=(size_t pos) noexcept;
59 bitset& set() noexcept;
60 bitset& set(size_t pos, bool val = true);
61 bitset& reset() noexcept;
62 bitset& reset(size_t pos);
63 bitset operator~() const noexcept;
64 bitset& flip() noexcept;
65 bitset& flip(size_t pos);
54 bitset& operator&=(const bitset& rhs) noexcept; // constexpr since C++23
55 bitset& operator|=(const bitset& rhs) noexcept; // constexpr since C++23
56 bitset& operator^=(const bitset& rhs) noexcept; // constexpr since C++23
57 bitset& operator<<=(size_t pos) noexcept; // constexpr since C++23
58 bitset& operator>>=(size_t pos) noexcept; // constexpr since C++23
59 bitset& set() noexcept; // constexpr since C++23
60 bitset& set(size_t pos, bool val = true); // constexpr since C++23
61 bitset& reset() noexcept; // constexpr since C++23
62 bitset& reset(size_t pos); // constexpr since C++23
63 bitset operator~() const noexcept; // constexpr since C++23
64 bitset& flip() noexcept; // constexpr since C++23
65 bitset& flip(size_t pos); // constexpr since C++23
6666
6767 // element access:
68 constexpr bool operator[](size_t pos) const; // for b[i];
69 reference operator[](size_t pos); // for b[i];
70 unsigned long to_ulong() const;
71 unsigned long long to_ullong() const;
72 template <class charT, class traits, class Allocator>
68 constexpr bool operator[](size_t pos) const;
69 reference operator[](size_t pos); // constexpr since C++23
70 unsigned long to_ulong() const; // constexpr since C++23
71 unsigned long long to_ullong() const; // constexpr since C++23
72 template <class charT, class traits, class Allocator> // constexpr since C++23
7373 basic_string<charT, traits, Allocator> to_string(charT zero = charT('0'), charT one = charT('1')) const;
74 template <class charT, class traits>
74 template <class charT, class traits> // constexpr since C++23
7575 basic_string<charT, traits, allocator<charT> > to_string(charT zero = charT('0'), charT one = charT('1')) const;
76 template <class charT>
76 template <class charT> // constexpr since C++23
7777 basic_string<charT, char_traits<charT>, allocator<charT> > to_string(charT zero = charT('0'), charT one = charT('1')) const;
78 basic_string<char, char_traits<char>, allocator<char> > to_string(char zero = '0', char one = '1') const;
79 size_t count() const noexcept;
80 constexpr size_t size() const noexcept;
81 bool operator==(const bitset& rhs) const noexcept;
82 bool operator!=(const bitset& rhs) const noexcept;
83 bool test(size_t pos) const;
84 bool all() const noexcept;
85 bool any() const noexcept;
86 bool none() const noexcept;
87 bitset operator<<(size_t pos) const noexcept;
88 bitset operator>>(size_t pos) const noexcept;
78 basic_string<char, char_traits<char>, allocator<char> > to_string(char zero = '0', char one = '1') const; // constexpr since C++23
79 size_t count() const noexcept; // constexpr since C++23
80 constexpr size_t size() const noexcept; // constexpr since C++23
81 bool operator==(const bitset& rhs) const noexcept; // constexpr since C++23
82 bool operator!=(const bitset& rhs) const noexcept; // constexpr since C++23
83 bool test(size_t pos) const; // constexpr since C++23
84 bool all() const noexcept; // constexpr since C++23
85 bool any() const noexcept; // constexpr since C++23
86 bool none() const noexcept; // constexpr since C++23
87 bitset<N> operator<<(size_t pos) const noexcept; // constexpr since C++23
88 bitset<N> operator>>(size_t pos) const noexcept; // constexpr since C++23
8989};
9090
9191// 23.3.5.3 bitset operators:
9292template <size_t N>
93bitset<N> operator&(const bitset<N>&, const bitset<N>&) noexcept;
93bitset<N> operator&(const bitset<N>&, const bitset<N>&) noexcept; // constexpr since C++23
9494
9595template <size_t N>
96bitset<N> operator|(const bitset<N>&, const bitset<N>&) noexcept;
96bitset<N> operator|(const bitset<N>&, const bitset<N>&) noexcept; // constexpr since C++23
9797
9898template <size_t N>
99bitset<N> operator^(const bitset<N>&, const bitset<N>&) noexcept;
99bitset<N> operator^(const bitset<N>&, const bitset<N>&) noexcept; // constexpr since C++23
100100
101101template <class charT, class traits, size_t N>
102102basic_istream<charT, traits>&
......@@ -118,12 +118,15 @@ template <size_t N> struct hash<std::bitset<N>>;
118118#include <__config>
119119#include <__functional/hash.h>
120120#include <__functional/unary_function.h>
121#include <__type_traits/is_char_like_type.h>
121122#include <climits>
122123#include <cstddef>
123124#include <stdexcept>
124125#include <version>
125126
126127// standard-mandated includes
128
129// [bitset.syn]
127130#include <iosfwd>
128131#include <string>
129132
......@@ -177,30 +180,30 @@ protected:
177180 _LIBCPP_INLINE_VISIBILITY
178181 explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;
179182
180 _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT
183 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t __pos) _NOEXCEPT
181184 {return reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}
182185 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT
183186 {return const_reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}
184 _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t __pos) _NOEXCEPT
187 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 iterator __make_iter(size_t __pos) _NOEXCEPT
185188 {return iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
186 _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t __pos) const _NOEXCEPT
189 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 const_iterator __make_iter(size_t __pos) const _NOEXCEPT
187190 {return const_iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
188191
189 _LIBCPP_INLINE_VISIBILITY
192 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
190193 void operator&=(const __bitset& __v) _NOEXCEPT;
191 _LIBCPP_INLINE_VISIBILITY
194 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
192195 void operator|=(const __bitset& __v) _NOEXCEPT;
193 _LIBCPP_INLINE_VISIBILITY
196 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
194197 void operator^=(const __bitset& __v) _NOEXCEPT;
195198
196 void flip() _NOEXCEPT;
197 _LIBCPP_INLINE_VISIBILITY unsigned long to_ulong() const
199 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip() _NOEXCEPT;
200 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const
198201 {return to_ulong(integral_constant<bool, _Size < sizeof(unsigned long) * CHAR_BIT>());}
199 _LIBCPP_INLINE_VISIBILITY unsigned long long to_ullong() const
202 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const
200203 {return to_ullong(integral_constant<bool, _Size < sizeof(unsigned long long) * CHAR_BIT>());}
201204
202 bool all() const _NOEXCEPT;
203 bool any() const _NOEXCEPT;
205 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT;
206 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT;
204207 _LIBCPP_INLINE_VISIBILITY
205208 size_t __hash_code() const _NOEXCEPT;
206209private:
......@@ -209,14 +212,17 @@ private:
209212 _LIBCPP_INLINE_VISIBILITY
210213 void __init(unsigned long long __v, true_type) _NOEXCEPT;
211214#endif // _LIBCPP_CXX03_LANG
215 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
212216 unsigned long to_ulong(false_type) const;
213 _LIBCPP_INLINE_VISIBILITY
217 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
214218 unsigned long to_ulong(true_type) const;
219 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
215220 unsigned long long to_ullong(false_type) const;
216 _LIBCPP_INLINE_VISIBILITY
221 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
217222 unsigned long long to_ullong(true_type) const;
218 _LIBCPP_INLINE_VISIBILITY
223 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
219224 unsigned long long to_ullong(true_type, false_type) const;
225 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
220226 unsigned long long to_ullong(true_type, true_type) const;
221227};
222228
......@@ -289,7 +295,7 @@ __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
289295
290296template <size_t _N_words, size_t _Size>
291297inline
292void
298_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
293299__bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT
294300{
295301 for (size_type __i = 0; __i < _N_words; ++__i)
......@@ -298,7 +304,7 @@ __bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT
298304
299305template <size_t _N_words, size_t _Size>
300306inline
301void
307_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
302308__bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT
303309{
304310 for (size_type __i = 0; __i < _N_words; ++__i)
......@@ -307,7 +313,7 @@ __bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT
307313
308314template <size_t _N_words, size_t _Size>
309315inline
310void
316_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
311317__bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT
312318{
313319 for (size_type __i = 0; __i < _N_words; ++__i)
......@@ -315,7 +321,7 @@ __bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT
315321}
316322
317323template <size_t _N_words, size_t _Size>
318void
324_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
319325__bitset<_N_words, _Size>::flip() _NOEXCEPT
320326{
321327 // do middle whole words
......@@ -334,7 +340,7 @@ __bitset<_N_words, _Size>::flip() _NOEXCEPT
334340}
335341
336342template <size_t _N_words, size_t _Size>
337unsigned long
343_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
338344__bitset<_N_words, _Size>::to_ulong(false_type) const
339345{
340346 const_iterator __e = __make_iter(_Size);
......@@ -347,14 +353,14 @@ __bitset<_N_words, _Size>::to_ulong(false_type) const
347353
348354template <size_t _N_words, size_t _Size>
349355inline
350unsigned long
356_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
351357__bitset<_N_words, _Size>::to_ulong(true_type) const
352358{
353359 return __first_[0];
354360}
355361
356362template <size_t _N_words, size_t _Size>
357unsigned long long
363_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
358364__bitset<_N_words, _Size>::to_ullong(false_type) const
359365{
360366 const_iterator __e = __make_iter(_Size);
......@@ -367,7 +373,7 @@ __bitset<_N_words, _Size>::to_ullong(false_type) const
367373
368374template <size_t _N_words, size_t _Size>
369375inline
370unsigned long long
376_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
371377__bitset<_N_words, _Size>::to_ullong(true_type) const
372378{
373379 return to_ullong(true_type(), integral_constant<bool, sizeof(__storage_type) < sizeof(unsigned long long)>());
......@@ -375,14 +381,14 @@ __bitset<_N_words, _Size>::to_ullong(true_type) const
375381
376382template <size_t _N_words, size_t _Size>
377383inline
378unsigned long long
384_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
379385__bitset<_N_words, _Size>::to_ullong(true_type, false_type) const
380386{
381387 return __first_[0];
382388}
383389
384390template <size_t _N_words, size_t _Size>
385unsigned long long
391_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
386392__bitset<_N_words, _Size>::to_ullong(true_type, true_type) const
387393{
388394 unsigned long long __r = __first_[0];
......@@ -392,7 +398,7 @@ __bitset<_N_words, _Size>::to_ullong(true_type, true_type) const
392398}
393399
394400template <size_t _N_words, size_t _Size>
395bool
401_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
396402__bitset<_N_words, _Size>::all() const _NOEXCEPT
397403{
398404 // do middle whole words
......@@ -412,7 +418,7 @@ __bitset<_N_words, _Size>::all() const _NOEXCEPT
412418}
413419
414420template <size_t _N_words, size_t _Size>
415bool
421_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
416422__bitset<_N_words, _Size>::any() const _NOEXCEPT
417423{
418424 // do middle whole words
......@@ -473,33 +479,33 @@ protected:
473479 _LIBCPP_INLINE_VISIBILITY
474480 explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;
475481
476 _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT
482 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t __pos) _NOEXCEPT
477483 {return reference(&__first_, __storage_type(1) << __pos);}
478484 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT
479485 {return const_reference(&__first_, __storage_type(1) << __pos);}
480 _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t __pos) _NOEXCEPT
486 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 iterator __make_iter(size_t __pos) _NOEXCEPT
481487 {return iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
482 _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t __pos) const _NOEXCEPT
488 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 const_iterator __make_iter(size_t __pos) const _NOEXCEPT
483489 {return const_iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
484490
485 _LIBCPP_INLINE_VISIBILITY
491 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
486492 void operator&=(const __bitset& __v) _NOEXCEPT;
487 _LIBCPP_INLINE_VISIBILITY
493 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
488494 void operator|=(const __bitset& __v) _NOEXCEPT;
489 _LIBCPP_INLINE_VISIBILITY
495 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
490496 void operator^=(const __bitset& __v) _NOEXCEPT;
491497
492 _LIBCPP_INLINE_VISIBILITY
498 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
493499 void flip() _NOEXCEPT;
494500
495 _LIBCPP_INLINE_VISIBILITY
501 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
496502 unsigned long to_ulong() const;
497 _LIBCPP_INLINE_VISIBILITY
503 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
498504 unsigned long long to_ullong() const;
499505
500 _LIBCPP_INLINE_VISIBILITY
506 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
501507 bool all() const _NOEXCEPT;
502 _LIBCPP_INLINE_VISIBILITY
508 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
503509 bool any() const _NOEXCEPT;
504510
505511 _LIBCPP_INLINE_VISIBILITY
......@@ -527,7 +533,7 @@ __bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
527533
528534template <size_t _Size>
529535inline
530void
536_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
531537__bitset<1, _Size>::operator&=(const __bitset& __v) _NOEXCEPT
532538{
533539 __first_ &= __v.__first_;
......@@ -535,7 +541,7 @@ __bitset<1, _Size>::operator&=(const __bitset& __v) _NOEXCEPT
535541
536542template <size_t _Size>
537543inline
538void
544_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
539545__bitset<1, _Size>::operator|=(const __bitset& __v) _NOEXCEPT
540546{
541547 __first_ |= __v.__first_;
......@@ -543,7 +549,7 @@ __bitset<1, _Size>::operator|=(const __bitset& __v) _NOEXCEPT
543549
544550template <size_t _Size>
545551inline
546void
552_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
547553__bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT
548554{
549555 __first_ ^= __v.__first_;
......@@ -551,7 +557,7 @@ __bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT
551557
552558template <size_t _Size>
553559inline
554void
560_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
555561__bitset<1, _Size>::flip() _NOEXCEPT
556562{
557563 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
......@@ -561,7 +567,7 @@ __bitset<1, _Size>::flip() _NOEXCEPT
561567
562568template <size_t _Size>
563569inline
564unsigned long
570_LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
565571__bitset<1, _Size>::to_ulong() const
566572{
567573 return __first_;
......@@ -569,7 +575,7 @@ __bitset<1, _Size>::to_ulong() const
569575
570576template <size_t _Size>
571577inline
572unsigned long long
578_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
573579__bitset<1, _Size>::to_ullong() const
574580{
575581 return __first_;
......@@ -577,7 +583,7 @@ __bitset<1, _Size>::to_ullong() const
577583
578584template <size_t _Size>
579585inline
580bool
586_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
581587__bitset<1, _Size>::all() const _NOEXCEPT
582588{
583589 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
......@@ -586,7 +592,7 @@ __bitset<1, _Size>::all() const _NOEXCEPT
586592
587593template <size_t _Size>
588594inline
589bool
595_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
590596__bitset<1, _Size>::any() const _NOEXCEPT
591597{
592598 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
......@@ -630,26 +636,26 @@ protected:
630636 _LIBCPP_INLINE_VISIBILITY
631637 explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT;
632638
633 _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t) _NOEXCEPT
639 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t) _NOEXCEPT
634640 {return reference(nullptr, 1);}
635641 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t) const _NOEXCEPT
636642 {return const_reference(nullptr, 1);}
637 _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t) _NOEXCEPT
643 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 iterator __make_iter(size_t) _NOEXCEPT
638644 {return iterator(nullptr, 0);}
639 _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t) const _NOEXCEPT
645 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 const_iterator __make_iter(size_t) const _NOEXCEPT
640646 {return const_iterator(nullptr, 0);}
641647
642 _LIBCPP_INLINE_VISIBILITY void operator&=(const __bitset&) _NOEXCEPT {}
643 _LIBCPP_INLINE_VISIBILITY void operator|=(const __bitset&) _NOEXCEPT {}
644 _LIBCPP_INLINE_VISIBILITY void operator^=(const __bitset&) _NOEXCEPT {}
648 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset&) _NOEXCEPT {}
649 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator|=(const __bitset&) _NOEXCEPT {}
650 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator^=(const __bitset&) _NOEXCEPT {}
645651
646 _LIBCPP_INLINE_VISIBILITY void flip() _NOEXCEPT {}
652 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip() _NOEXCEPT {}
647653
648 _LIBCPP_INLINE_VISIBILITY unsigned long to_ulong() const {return 0;}
649 _LIBCPP_INLINE_VISIBILITY unsigned long long to_ullong() const {return 0;}
654 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const {return 0;}
655 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const {return 0;}
650656
651 _LIBCPP_INLINE_VISIBILITY bool all() const _NOEXCEPT {return true;}
652 _LIBCPP_INLINE_VISIBILITY bool any() const _NOEXCEPT {return false;}
657 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT {return true;}
658 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT {return false;}
653659
654660 _LIBCPP_INLINE_VISIBILITY size_t __hash_code() const _NOEXCEPT {return 0;}
655661};
......@@ -686,10 +692,12 @@ public:
686692 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
687693 bitset(unsigned long long __v) _NOEXCEPT : base(__v) {}
688694 template<class _CharT, class = __enable_if_t<_IsCharLikeType<_CharT>::value> >
695 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
689696 explicit bitset(const _CharT* __str,
690697 typename basic_string<_CharT>::size_type __n = basic_string<_CharT>::npos,
691698 _CharT __zero = _CharT('0'), _CharT __one = _CharT('1'));
692699 template<class _CharT, class _Traits, class _Allocator>
700 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
693701 explicit bitset(const basic_string<_CharT,_Traits,_Allocator>& __str,
694702 typename basic_string<_CharT,_Traits,_Allocator>::size_type __pos = 0,
695703 typename basic_string<_CharT,_Traits,_Allocator>::size_type __n =
......@@ -697,24 +705,29 @@ public:
697705 _CharT __zero = _CharT('0'), _CharT __one = _CharT('1'));
698706
699707 // 23.3.5.2 bitset operations:
700 _LIBCPP_INLINE_VISIBILITY
708 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
701709 bitset& operator&=(const bitset& __rhs) _NOEXCEPT;
702 _LIBCPP_INLINE_VISIBILITY
710 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
703711 bitset& operator|=(const bitset& __rhs) _NOEXCEPT;
704 _LIBCPP_INLINE_VISIBILITY
712 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
705713 bitset& operator^=(const bitset& __rhs) _NOEXCEPT;
714 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
706715 bitset& operator<<=(size_t __pos) _NOEXCEPT;
716 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
707717 bitset& operator>>=(size_t __pos) _NOEXCEPT;
708 _LIBCPP_INLINE_VISIBILITY
718 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
709719 bitset& set() _NOEXCEPT;
720 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
710721 bitset& set(size_t __pos, bool __val = true);
711 _LIBCPP_INLINE_VISIBILITY
722 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
712723 bitset& reset() _NOEXCEPT;
724 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
713725 bitset& reset(size_t __pos);
714 _LIBCPP_INLINE_VISIBILITY
726 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
715727 bitset operator~() const _NOEXCEPT;
716 _LIBCPP_INLINE_VISIBILITY
728 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
717729 bitset& flip() _NOEXCEPT;
730 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
718731 bitset& flip(size_t __pos);
719732
720733 // element access:
......@@ -723,41 +736,43 @@ public:
723736#else
724737 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference operator[](size_t __p) const {return base::__make_ref(__p);}
725738#endif
726 _LIBCPP_HIDE_FROM_ABI reference operator[](size_t __p) {return base::__make_ref(__p);}
727 _LIBCPP_INLINE_VISIBILITY
739 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference operator[](size_t __p) {return base::__make_ref(__p);}
740 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
728741 unsigned long to_ulong() const;
729 _LIBCPP_INLINE_VISIBILITY
742 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
730743 unsigned long long to_ullong() const;
731744 template <class _CharT, class _Traits, class _Allocator>
745 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
732746 basic_string<_CharT, _Traits, _Allocator> to_string(_CharT __zero = _CharT('0'),
733747 _CharT __one = _CharT('1')) const;
734748 template <class _CharT, class _Traits>
735 _LIBCPP_INLINE_VISIBILITY
749 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
736750 basic_string<_CharT, _Traits, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'),
737751 _CharT __one = _CharT('1')) const;
738752 template <class _CharT>
739 _LIBCPP_INLINE_VISIBILITY
753 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
740754 basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'),
741755 _CharT __one = _CharT('1')) const;
742 _LIBCPP_INLINE_VISIBILITY
756 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
743757 basic_string<char, char_traits<char>, allocator<char> > to_string(char __zero = '0',
744758 char __one = '1') const;
745 _LIBCPP_INLINE_VISIBILITY
759 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
746760 size_t count() const _NOEXCEPT;
747761 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR size_t size() const _NOEXCEPT {return _Size;}
748 _LIBCPP_INLINE_VISIBILITY
762 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
749763 bool operator==(const bitset& __rhs) const _NOEXCEPT;
750 _LIBCPP_INLINE_VISIBILITY
764 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
751765 bool operator!=(const bitset& __rhs) const _NOEXCEPT;
766 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
752767 bool test(size_t __pos) const;
753 _LIBCPP_INLINE_VISIBILITY
768 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
754769 bool all() const _NOEXCEPT;
755 _LIBCPP_INLINE_VISIBILITY
770 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
756771 bool any() const _NOEXCEPT;
757 _LIBCPP_INLINE_VISIBILITY bool none() const _NOEXCEPT {return !any();}
758 _LIBCPP_INLINE_VISIBILITY
772 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool none() const _NOEXCEPT {return !any();}
773 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
759774 bitset operator<<(size_t __pos) const _NOEXCEPT;
760 _LIBCPP_INLINE_VISIBILITY
775 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
761776 bitset operator>>(size_t __pos) const _NOEXCEPT;
762777
763778private:
......@@ -770,6 +785,7 @@ private:
770785
771786template <size_t _Size>
772787template<class _CharT, class>
788_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
773789bitset<_Size>::bitset(const _CharT* __str,
774790 typename basic_string<_CharT>::size_type __n,
775791 _CharT __zero, _CharT __one)
......@@ -791,6 +807,7 @@ bitset<_Size>::bitset(const _CharT* __str,
791807
792808template <size_t _Size>
793809template<class _CharT, class _Traits, class _Allocator>
810_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
794811bitset<_Size>::bitset(const basic_string<_CharT,_Traits,_Allocator>& __str,
795812 typename basic_string<_CharT,_Traits,_Allocator>::size_type __pos,
796813 typename basic_string<_CharT,_Traits,_Allocator>::size_type __n,
......@@ -816,6 +833,7 @@ bitset<_Size>::bitset(const basic_string<_CharT,_Traits,_Allocator>& __str,
816833
817834template <size_t _Size>
818835inline
836_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
819837bitset<_Size>&
820838bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT
821839{
......@@ -825,6 +843,7 @@ bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT
825843
826844template <size_t _Size>
827845inline
846_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
828847bitset<_Size>&
829848bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT
830849{
......@@ -834,6 +853,7 @@ bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT
834853
835854template <size_t _Size>
836855inline
856_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
837857bitset<_Size>&
838858bitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT
839859{
......@@ -842,6 +862,7 @@ bitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT
842862}
843863
844864template <size_t _Size>
865_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
845866bitset<_Size>&
846867bitset<_Size>::operator<<=(size_t __pos) _NOEXCEPT
847868{
......@@ -852,6 +873,7 @@ bitset<_Size>::operator<<=(size_t __pos) _NOEXCEPT
852873}
853874
854875template <size_t _Size>
876_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
855877bitset<_Size>&
856878bitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT
857879{
......@@ -863,6 +885,7 @@ bitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT
863885
864886template <size_t _Size>
865887inline
888_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
866889bitset<_Size>&
867890bitset<_Size>::set() _NOEXCEPT
868891{
......@@ -871,6 +894,7 @@ bitset<_Size>::set() _NOEXCEPT
871894}
872895
873896template <size_t _Size>
897_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
874898bitset<_Size>&
875899bitset<_Size>::set(size_t __pos, bool __val)
876900{
......@@ -883,6 +907,7 @@ bitset<_Size>::set(size_t __pos, bool __val)
883907
884908template <size_t _Size>
885909inline
910_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
886911bitset<_Size>&
887912bitset<_Size>::reset() _NOEXCEPT
888913{
......@@ -891,6 +916,7 @@ bitset<_Size>::reset() _NOEXCEPT
891916}
892917
893918template <size_t _Size>
919_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
894920bitset<_Size>&
895921bitset<_Size>::reset(size_t __pos)
896922{
......@@ -903,6 +929,7 @@ bitset<_Size>::reset(size_t __pos)
903929
904930template <size_t _Size>
905931inline
932_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
906933bitset<_Size>
907934bitset<_Size>::operator~() const _NOEXCEPT
908935{
......@@ -913,6 +940,7 @@ bitset<_Size>::operator~() const _NOEXCEPT
913940
914941template <size_t _Size>
915942inline
943_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
916944bitset<_Size>&
917945bitset<_Size>::flip() _NOEXCEPT
918946{
......@@ -921,6 +949,7 @@ bitset<_Size>::flip() _NOEXCEPT
921949}
922950
923951template <size_t _Size>
952_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
924953bitset<_Size>&
925954bitset<_Size>::flip(size_t __pos)
926955{
......@@ -934,6 +963,7 @@ bitset<_Size>::flip(size_t __pos)
934963
935964template <size_t _Size>
936965inline
966_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
937967unsigned long
938968bitset<_Size>::to_ulong() const
939969{
......@@ -942,6 +972,7 @@ bitset<_Size>::to_ulong() const
942972
943973template <size_t _Size>
944974inline
975_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
945976unsigned long long
946977bitset<_Size>::to_ullong() const
947978{
......@@ -950,6 +981,7 @@ bitset<_Size>::to_ullong() const
950981
951982template <size_t _Size>
952983template <class _CharT, class _Traits, class _Allocator>
984_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
953985basic_string<_CharT, _Traits, _Allocator>
954986bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
955987{
......@@ -965,6 +997,7 @@ bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
965997template <size_t _Size>
966998template <class _CharT, class _Traits>
967999inline
1000_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
9681001basic_string<_CharT, _Traits, allocator<_CharT> >
9691002bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
9701003{
......@@ -974,6 +1007,7 @@ bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
9741007template <size_t _Size>
9751008template <class _CharT>
9761009inline
1010_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
9771011basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> >
9781012bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
9791013{
......@@ -982,6 +1016,7 @@ bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
9821016
9831017template <size_t _Size>
9841018inline
1019_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
9851020basic_string<char, char_traits<char>, allocator<char> >
9861021bitset<_Size>::to_string(char __zero, char __one) const
9871022{
......@@ -990,6 +1025,7 @@ bitset<_Size>::to_string(char __zero, char __one) const
9901025
9911026template <size_t _Size>
9921027inline
1028_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
9931029size_t
9941030bitset<_Size>::count() const _NOEXCEPT
9951031{
......@@ -998,6 +1034,7 @@ bitset<_Size>::count() const _NOEXCEPT
9981034
9991035template <size_t _Size>
10001036inline
1037_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
10011038bool
10021039bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT
10031040{
......@@ -1006,6 +1043,7 @@ bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT
10061043
10071044template <size_t _Size>
10081045inline
1046_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
10091047bool
10101048bitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT
10111049{
......@@ -1013,6 +1051,7 @@ bitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT
10131051}
10141052
10151053template <size_t _Size>
1054_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
10161055bool
10171056bitset<_Size>::test(size_t __pos) const
10181057{
......@@ -1024,6 +1063,7 @@ bitset<_Size>::test(size_t __pos) const
10241063
10251064template <size_t _Size>
10261065inline
1066_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
10271067bool
10281068bitset<_Size>::all() const _NOEXCEPT
10291069{
......@@ -1032,6 +1072,7 @@ bitset<_Size>::all() const _NOEXCEPT
10321072
10331073template <size_t _Size>
10341074inline
1075_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
10351076bool
10361077bitset<_Size>::any() const _NOEXCEPT
10371078{
......@@ -1040,6 +1081,7 @@ bitset<_Size>::any() const _NOEXCEPT
10401081
10411082template <size_t _Size>
10421083inline
1084_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
10431085bitset<_Size>
10441086bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT
10451087{
......@@ -1050,6 +1092,7 @@ bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT
10501092
10511093template <size_t _Size>
10521094inline
1095_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
10531096bitset<_Size>
10541097bitset<_Size>::operator>>(size_t __pos) const _NOEXCEPT
10551098{
......@@ -1059,7 +1102,7 @@ bitset<_Size>::operator>>(size_t __pos) const _NOEXCEPT
10591102}
10601103
10611104template <size_t _Size>
1062inline _LIBCPP_INLINE_VISIBILITY
1105inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
10631106bitset<_Size>
10641107operator&(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
10651108{
......@@ -1069,7 +1112,7 @@ operator&(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
10691112}
10701113
10711114template <size_t _Size>
1072inline _LIBCPP_INLINE_VISIBILITY
1115inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
10731116bitset<_Size>
10741117operator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
10751118{
......@@ -1079,7 +1122,7 @@ operator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
10791122}
10801123
10811124template <size_t _Size>
1082inline _LIBCPP_INLINE_VISIBILITY
1125inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
10831126bitset<_Size>
10841127operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
10851128{
......@@ -1098,15 +1141,19 @@ struct _LIBCPP_TEMPLATE_VIS hash<bitset<_Size> >
10981141};
10991142
11001143template <class _CharT, class _Traits, size_t _Size>
1101basic_istream<_CharT, _Traits>&
1144_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
11021145operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x);
11031146
11041147template <class _CharT, class _Traits, size_t _Size>
1105basic_ostream<_CharT, _Traits>&
1148_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
11061149operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x);
11071150
11081151_LIBCPP_END_NAMESPACE_STD
11091152
11101153_LIBCPP_POP_MACROS
11111154
1155#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1156# include <concepts>
1157#endif
1158
11121159#endif // _LIBCPP_BITSET
lib/libcxx/include/cassert+8-1
......@@ -18,7 +18,14 @@ Macros:
1818
1919#include <__assert> // all public C++ headers provide the assertion handler
2020#include <__config>
21#include <assert.h>
21
22// <assert.h> is not provided by libc++
23#if __has_include(<assert.h>)
24# include <assert.h>
25# ifdef _LIBCPP_ASSERT_H
26# error "If libc++ starts defining <assert.h>, the __has_include check should move to libc++'s <assert.h>"
27# endif
28#endif
2229
2330#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2431# pragma GCC system_header
lib/libcxx/include/cctype+8
......@@ -36,8 +36,16 @@ int toupper(int c);
3636
3737#include <__assert> // all public C++ headers provide the assertion handler
3838#include <__config>
39
3940#include <ctype.h>
4041
42#ifndef _LIBCPP_CTYPE_H
43# error <cctype> tried including <ctype.h> but didn't find libc++'s <ctype.h> header. \
44 This usually means that your header search paths are not configured properly. \
45 The header search paths should contain the C++ Standard Library headers before \
46 any C Standard Library.
47#endif
48
4149#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
4250# pragma GCC system_header
4351#endif
lib/libcxx/include/cerrno+9
......@@ -24,8 +24,17 @@ Macros:
2424
2525#include <__assert> // all public C++ headers provide the assertion handler
2626#include <__config>
27
2728#include <errno.h>
2829
30#ifndef _LIBCPP_ERRNO_H
31# error <cerrno> tried including <errno.h> but didn't find libc++'s <errno.h> header. \
32 This usually means that your header search paths are not configured properly. \
33 The header search paths should contain the C++ Standard Library headers before \
34 any C Standard Library, and you are probably using compiler flags that make that \
35 not be the case.
36#endif
37
2938#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3039# pragma GCC system_header
3140#endif
lib/libcxx/include/cfenv+9
......@@ -54,8 +54,17 @@ int feupdateenv(const fenv_t* envp);
5454
5555#include <__assert> // all public C++ headers provide the assertion handler
5656#include <__config>
57
5758#include <fenv.h>
5859
60#ifndef _LIBCPP_FENV_H
61# error <cfenv> tried including <fenv.h> but didn't find libc++'s <fenv.h> header. \
62 This usually means that your header search paths are not configured properly. \
63 The header search paths should contain the C++ Standard Library headers before \
64 any C Standard Library, and you are probably using compiler flags that make that \
65 not be the case.
66#endif
67
5968#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
6069# pragma GCC system_header
6170#endif
lib/libcxx/include/cfloat+9
......@@ -71,8 +71,17 @@ Macros:
7171
7272#include <__assert> // all public C++ headers provide the assertion handler
7373#include <__config>
74
7475#include <float.h>
7576
77#ifndef _LIBCPP_FLOAT_H
78# error <cfloat> tried including <float.h> but didn't find libc++'s <float.h> header. \
79 This usually means that your header search paths are not configured properly. \
80 The header search paths should contain the C++ Standard Library headers before \
81 any C Standard Library, and you are probably using compiler flags that make that \
82 not be the case.
83#endif
84
7685#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
7786# pragma GCC system_header
7887#endif
lib/libcxx/include/charconv+125-105
......@@ -30,8 +30,8 @@ namespace std {
3030 friend bool operator==(const to_chars_result&, const to_chars_result&) = default; // since C++20
3131 };
3232
33 to_chars_result to_chars(char* first, char* last, see below value,
34 int base = 10);
33 constexpr to_chars_result to_chars(char* first, char* last, see below value,
34 int base = 10); // constexpr since C++23
3535 to_chars_result to_chars(char* first, char* last, bool value,
3636 int base = 10) = delete;
3737
......@@ -60,8 +60,8 @@ namespace std {
6060 friend bool operator==(const from_chars_result&, const from_chars_result&) = default; // since C++20
6161 };
6262
63 from_chars_result from_chars(const char* first, const char* last,
64 see below& value, int base = 10);
63 constexpr from_chars_result from_chars(const char* first, const char* last,
64 see below& value, int base = 10); // constexpr since C++23
6565
6666 from_chars_result from_chars(const char* first, const char* last,
6767 float& value,
......@@ -77,9 +77,10 @@ namespace std {
7777
7878*/
7979
80#include <__algorithm/copy_n.h>
8081#include <__assert> // all public C++ headers provide the assertion handler
8182#include <__availability>
82#include <__bits>
83#include <__bit/countl.h>
8384#include <__charconv/chars_format.h>
8485#include <__charconv/from_chars_result.h>
8586#include <__charconv/tables.h>
......@@ -88,6 +89,7 @@ namespace std {
8889#include <__config>
8990#include <__debug>
9091#include <__errc>
92#include <__memory/addressof.h>
9193#include <__type_traits/make_32_64_or_128_bit.h>
9294#include <__utility/unreachable.h>
9395#include <cmath> // for log2f
......@@ -97,10 +99,6 @@ namespace std {
9799#include <limits>
98100#include <type_traits>
99101
100#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
101# include <iosfwd>
102#endif
103
104102#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
105103# pragma GCC system_header
106104#endif
......@@ -110,7 +108,7 @@ _LIBCPP_PUSH_MACROS
110108
111109_LIBCPP_BEGIN_NAMESPACE_STD
112110
113#ifndef _LIBCPP_CXX03_LANG
111#if _LIBCPP_STD_VER > 14
114112
115113to_chars_result to_chars(char*, char*, bool, int = 10) = delete;
116114from_chars_result from_chars(const char*, const char*, bool, int = 10) = delete;
......@@ -134,18 +132,18 @@ struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) <= sizeof(uin
134132 /// function requires its input to have at least one bit set the value of
135133 /// zero is set to one. This means the first element of the lookup table is
136134 /// zero.
137 static _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v)
135 static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v)
138136 {
139137 auto __t = (32 - std::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12;
140 return __t - (__v < __table<>::__pow10_32[__t]) + 1;
138 return __t - (__v < __itoa::__pow10_32[__t]) + 1;
141139 }
142140
143 static _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v)
141 static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v)
144142 {
145143 return __itoa::__base_10_u32(__p, __v);
146144 }
147145
148 static _LIBCPP_HIDE_FROM_ABI decltype(__table<>::__pow10_32)& __pow() { return __table<>::__pow10_32; }
146 static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI decltype(__pow10_32)& __pow() { return __itoa::__pow10_32; }
149147};
150148
151149template <typename _Tp>
......@@ -161,14 +159,14 @@ struct _LIBCPP_HIDDEN
161159 /// function requires its input to have at least one bit set the value of
162160 /// zero is set to one. This means the first element of the lookup table is
163161 /// zero.
164 static _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) {
162 static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) {
165163 auto __t = (64 - std::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12;
166 return __t - (__v < __table<>::__pow10_64[__t]) + 1;
164 return __t - (__v < __itoa::__pow10_64[__t]) + 1;
167165 }
168166
169 static _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v) { return __itoa::__base_10_u64(__p, __v); }
167 static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v) { return __itoa::__base_10_u64(__p, __v); }
170168
171 static _LIBCPP_HIDE_FROM_ABI decltype(__table<>::__pow10_64)& __pow() { return __table<>::__pow10_64; }
169 static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI decltype(__pow10_64)& __pow() { return __itoa::__pow10_64; }
172170};
173171
174172
......@@ -186,25 +184,25 @@ struct _LIBCPP_HIDDEN
186184 /// function requires its input to have at least one bit set the value of
187185 /// zero is set to one. This means the first element of the lookup table is
188186 /// zero.
189 static _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) {
187 static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) {
190188 _LIBCPP_ASSERT(__v > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fail when this isn't true.");
191189 // There's always a bit set in the upper 64-bits.
192190 auto __t = (128 - std::__libcpp_clz(static_cast<uint64_t>(__v >> 64))) * 1233 >> 12;
193 _LIBCPP_ASSERT(__t >= __table<>::__pow10_128_offset, "Index out of bounds");
191 _LIBCPP_ASSERT(__t >= __itoa::__pow10_128_offset, "Index out of bounds");
194192 // __t is adjusted since the lookup table misses the lower entries.
195 return __t - (__v < __table<>::__pow10_128[__t - __table<>::__pow10_128_offset]) + 1;
193 return __t - (__v < __itoa::__pow10_128[__t - __itoa::__pow10_128_offset]) + 1;
196194 }
197195
198 static _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v) { return __itoa::__base_10_u128(__p, __v); }
196 static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v) { return __itoa::__base_10_u128(__p, __v); }
199197
200198 // TODO FMT This pow function should get an index.
201199 // By moving this to its own header it can be reused by the pow function in to_chars_base_10.
202 static _LIBCPP_HIDE_FROM_ABI decltype(__table<>::__pow10_128)& __pow() { return __table<>::__pow10_128; }
200 static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI decltype(__pow10_128)& __pow() { return __itoa::__pow10_128; }
203201};
204202#endif
205203
206204template <typename _Tp>
207inline _LIBCPP_HIDE_FROM_ABI bool
205inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool
208206__mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r)
209207{
210208 auto __c = __a * __b;
......@@ -213,7 +211,7 @@ __mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r)
213211}
214212
215213template <typename _Tp>
216inline _LIBCPP_HIDE_FROM_ABI bool
214inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool
217215__mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r)
218216{
219217 auto __c = __a * __b;
......@@ -222,24 +220,18 @@ __mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r)
222220}
223221
224222template <typename _Tp>
225inline _LIBCPP_HIDE_FROM_ABI bool
223inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool
226224__mul_overflowed(_Tp __a, _Tp __b, _Tp& __r)
227225{
228226 static_assert(is_unsigned<_Tp>::value, "");
229#if !defined(_LIBCPP_COMPILER_MSVC)
230227 return __builtin_mul_overflow(__a, __b, &__r);
231#else
232 bool __did = __b && (numeric_limits<_Tp>::max() / __b) < __a;
233 __r = __a * __b;
234 return __did;
235#endif
236228}
237229
238230template <typename _Tp, typename _Up>
239231inline _LIBCPP_HIDE_FROM_ABI bool
240__mul_overflowed(_Tp __a, _Up __b, _Tp& __r)
232_LIBCPP_CONSTEXPR_SINCE_CXX23 __mul_overflowed(_Tp __a, _Up __b, _Tp& __r)
241233{
242 return __mul_overflowed(__a, static_cast<_Tp>(__b), __r);
234 return __itoa::__mul_overflowed(__a, static_cast<_Tp>(__b), __r);
243235}
244236
245237template <typename _Tp>
......@@ -250,7 +242,7 @@ struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>
250242 using typename __traits_base<_Tp>::type;
251243
252244 // precondition: at least one non-zero character available
253 static _LIBCPP_HIDE_FROM_ABI char const*
245 static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI char const*
254246 __read(char const* __p, char const* __ep, type& __a, type& __b)
255247 {
256248 type __cprod[digits];
......@@ -258,20 +250,20 @@ struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>
258250 int __i = digits;
259251 do
260252 {
261 if (!('0' <= *__p && *__p <= '9'))
253 if (*__p < '0' || *__p > '9')
262254 break;
263255 __cprod[--__i] = *__p++ - '0';
264256 } while (__p != __ep && __i != 0);
265257
266258 __a = __inner_product(__cprod + __i + 1, __cprod + __j, __pow() + 1,
267259 __cprod[__i]);
268 if (__mul_overflowed(__cprod[__j], __pow()[__j - __i], __b))
260 if (__itoa::__mul_overflowed(__cprod[__j], __pow()[__j - __i], __b))
269261 --__p;
270262 return __p;
271263 }
272264
273265 template <typename _It1, typename _It2, class _Up>
274 static _LIBCPP_HIDE_FROM_ABI _Up
266 static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _Up
275267 __inner_product(_It1 __first1, _It1 __last1, _It2 __first2, _Up __init)
276268 {
277269 for (; __first1 < __last1; ++__first1, ++__first2)
......@@ -283,7 +275,7 @@ struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>
283275} // namespace __itoa
284276
285277template <typename _Tp>
286inline _LIBCPP_HIDE_FROM_ABI _Tp
278inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _Tp
287279__complement(_Tp __x)
288280{
289281 static_assert(is_unsigned<_Tp>::value, "cast to unsigned first");
......@@ -291,21 +283,25 @@ __complement(_Tp __x)
291283}
292284
293285template <typename _Tp>
294inline _LIBCPP_HIDE_FROM_ABI to_chars_result
286inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
287__to_chars_itoa(char* __first, char* __last, _Tp __value, false_type);
288
289template <typename _Tp>
290inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
295291__to_chars_itoa(char* __first, char* __last, _Tp __value, true_type)
296292{
297 auto __x = __to_unsigned_like(__value);
293 auto __x = std::__to_unsigned_like(__value);
298294 if (__value < 0 && __first != __last)
299295 {
300296 *__first++ = '-';
301 __x = __complement(__x);
297 __x = std::__complement(__x);
302298 }
303299
304 return __to_chars_itoa(__first, __last, __x, false_type());
300 return std::__to_chars_itoa(__first, __last, __x, false_type());
305301}
306302
307303template <typename _Tp>
308inline _LIBCPP_HIDE_FROM_ABI to_chars_result
304inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
309305__to_chars_itoa(char* __first, char* __last, _Tp __value, false_type)
310306{
311307 using __tx = __itoa::__traits<_Tp>;
......@@ -319,7 +315,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type)
319315
320316# ifndef _LIBCPP_HAS_NO_INT128
321317template <>
322inline _LIBCPP_HIDE_FROM_ABI to_chars_result
318inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
323319__to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type)
324320{
325321 // When the value fits in 64-bits use the 64-bit code path. This reduces
......@@ -339,19 +335,23 @@ __to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type)
339335}
340336#endif
341337
338template <class _Tp>
339inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
340__to_chars_integral(char* __first, char* __last, _Tp __value, int __base, false_type);
341
342342template <typename _Tp>
343inline _LIBCPP_HIDE_FROM_ABI to_chars_result
343inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
344344__to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
345345 true_type)
346346{
347 auto __x = __to_unsigned_like(__value);
347 auto __x = std::__to_unsigned_like(__value);
348348 if (__value < 0 && __first != __last)
349349 {
350350 *__first++ = '-';
351 __x = __complement(__x);
351 __x = std::__complement(__x);
352352 }
353353
354 return __to_chars_integral(__first, __last, __x, __base, false_type());
354 return std::__to_chars_integral(__first, __last, __x, __base, false_type());
355355}
356356
357357namespace __itoa {
......@@ -370,7 +370,7 @@ struct _LIBCPP_HIDDEN __integral<2> {
370370 }
371371
372372 template <typename _Tp>
373 _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) {
373 _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) {
374374 ptrdiff_t __cap = __last - __first;
375375 int __n = __width(__value);
376376 if (__n > __cap)
......@@ -383,7 +383,7 @@ struct _LIBCPP_HIDDEN __integral<2> {
383383 unsigned __c = __value % __divisor;
384384 __value /= __divisor;
385385 __p -= 4;
386 std::memcpy(__p, &__table<>::__base_2_lut[4 * __c], 4);
386 std::copy_n(&__base_2_lut[4 * __c], 4, __p);
387387 }
388388 do {
389389 unsigned __c = __value % 2;
......@@ -405,7 +405,7 @@ struct _LIBCPP_HIDDEN __integral<8> {
405405 }
406406
407407 template <typename _Tp>
408 _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) {
408 _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) {
409409 ptrdiff_t __cap = __last - __first;
410410 int __n = __width(__value);
411411 if (__n > __cap)
......@@ -418,7 +418,7 @@ struct _LIBCPP_HIDDEN __integral<8> {
418418 unsigned __c = __value % __divisor;
419419 __value /= __divisor;
420420 __p -= 2;
421 std::memcpy(__p, &__table<>::__base_8_lut[2 * __c], 2);
421 std::copy_n(&__base_8_lut[2 * __c], 2, __p);
422422 }
423423 do {
424424 unsigned __c = __value % 8;
......@@ -441,7 +441,7 @@ struct _LIBCPP_HIDDEN __integral<16> {
441441 }
442442
443443 template <typename _Tp>
444 _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) {
444 _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) {
445445 ptrdiff_t __cap = __last - __first;
446446 int __n = __width(__value);
447447 if (__n > __cap)
......@@ -454,7 +454,7 @@ struct _LIBCPP_HIDDEN __integral<16> {
454454 unsigned __c = __value % __divisor;
455455 __value /= __divisor;
456456 __p -= 2;
457 std::memcpy(__p, &__table<>::__base_16_lut[2 * __c], 2);
457 std::copy_n(&__base_16_lut[2 * __c], 2, __p);
458458 }
459459 if (__first != __last)
460460 do {
......@@ -470,34 +470,34 @@ struct _LIBCPP_HIDDEN __integral<16> {
470470
471471template <unsigned _Base, typename _Tp,
472472 typename enable_if<(sizeof(_Tp) >= sizeof(unsigned)), int>::type = 0>
473_LIBCPP_HIDE_FROM_ABI int
473_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int
474474__to_chars_integral_width(_Tp __value) {
475475 return __itoa::__integral<_Base>::__width(__value);
476476}
477477
478478template <unsigned _Base, typename _Tp,
479479 typename enable_if<(sizeof(_Tp) < sizeof(unsigned)), int>::type = 0>
480_LIBCPP_HIDE_FROM_ABI int
480_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int
481481__to_chars_integral_width(_Tp __value) {
482482 return std::__to_chars_integral_width<_Base>(static_cast<unsigned>(__value));
483483}
484484
485485template <unsigned _Base, typename _Tp,
486486 typename enable_if<(sizeof(_Tp) >= sizeof(unsigned)), int>::type = 0>
487_LIBCPP_HIDE_FROM_ABI to_chars_result
487_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
488488__to_chars_integral(char* __first, char* __last, _Tp __value) {
489489 return __itoa::__integral<_Base>::__to_chars(__first, __last, __value);
490490}
491491
492492template <unsigned _Base, typename _Tp,
493493 typename enable_if<(sizeof(_Tp) < sizeof(unsigned)), int>::type = 0>
494_LIBCPP_HIDE_FROM_ABI to_chars_result
494_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
495495__to_chars_integral(char* __first, char* __last, _Tp __value) {
496496 return std::__to_chars_integral<_Base>(__first, __last, static_cast<unsigned>(__value));
497497}
498498
499499template <typename _Tp>
500_LIBCPP_HIDE_FROM_ABI int
500_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int
501501__to_chars_integral_width(_Tp __value, unsigned __base) {
502502 _LIBCPP_ASSERT(__value >= 0, "The function requires a non-negative value.");
503503
......@@ -524,24 +524,24 @@ __to_chars_integral_width(_Tp __value, unsigned __base) {
524524}
525525
526526template <typename _Tp>
527inline _LIBCPP_HIDE_FROM_ABI to_chars_result
527inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
528528__to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
529529 false_type)
530530{
531531 if (__base == 10) [[likely]]
532 return __to_chars_itoa(__first, __last, __value, false_type());
532 return std::__to_chars_itoa(__first, __last, __value, false_type());
533533
534534 switch (__base) {
535535 case 2:
536 return __to_chars_integral<2>(__first, __last, __value);
536 return std::__to_chars_integral<2>(__first, __last, __value);
537537 case 8:
538 return __to_chars_integral<8>(__first, __last, __value);
538 return std::__to_chars_integral<8>(__first, __last, __value);
539539 case 16:
540 return __to_chars_integral<16>(__first, __last, __value);
540 return std::__to_chars_integral<16>(__first, __last, __value);
541541 }
542542
543543 ptrdiff_t __cap = __last - __first;
544 int __n = __to_chars_integral_width(__value, __base);
544 int __n = std::__to_chars_integral_width(__value, __base);
545545 if (__n > __cap)
546546 return {__last, errc::value_too_large};
547547
......@@ -556,7 +556,7 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
556556}
557557
558558template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
559inline _LIBCPP_HIDE_FROM_ABI to_chars_result
559inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
560560to_chars(char* __first, char* __last, _Tp __value)
561561{
562562 using _Type = __make_32_64_or_128_bit_t<_Tp>;
......@@ -565,7 +565,7 @@ to_chars(char* __first, char* __last, _Tp __value)
565565}
566566
567567template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
568inline _LIBCPP_HIDE_FROM_ABI to_chars_result
568inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
569569to_chars(char* __first, char* __last, _Tp __value, int __base)
570570{
571571 _LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]");
......@@ -575,11 +575,11 @@ to_chars(char* __first, char* __last, _Tp __value, int __base)
575575}
576576
577577template <typename _It, typename _Tp, typename _Fn, typename... _Ts>
578inline _LIBCPP_HIDE_FROM_ABI from_chars_result
578inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
579579__sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)
580580{
581581 using __tl = numeric_limits<_Tp>;
582 decltype(__to_unsigned_like(__value)) __x;
582 decltype(std::__to_unsigned_like(__value)) __x;
583583
584584 bool __neg = (__first != __last && *__first == '-');
585585 auto __r = __f(__neg ? __first + 1 : __first, __last, __x, __args...);
......@@ -595,16 +595,16 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)
595595
596596 if (__neg)
597597 {
598 if (__x <= __complement(__to_unsigned_like(__tl::min())))
598 if (__x <= std::__complement(std::__to_unsigned_like(__tl::min())))
599599 {
600 __x = __complement(__x);
601 std::memcpy(&__value, &__x, sizeof(__x));
600 __x = std::__complement(__x);
601 std::copy_n(std::addressof(__x), 1, std::addressof(__value));
602602 return __r;
603603 }
604604 }
605605 else
606606 {
607 if (__x <= __to_unsigned_like(__tl::max()))
607 if (__x <= std::__to_unsigned_like(__tl::max()))
608608 {
609609 __value = __x;
610610 return __r;
......@@ -615,7 +615,7 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)
615615}
616616
617617template <typename _Tp>
618inline _LIBCPP_HIDE_FROM_ABI bool
618inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool
619619__in_pattern(_Tp __c)
620620{
621621 return '0' <= __c && __c <= '9';
......@@ -626,16 +626,16 @@ struct _LIBCPP_HIDDEN __in_pattern_result
626626 bool __ok;
627627 int __val;
628628
629 explicit _LIBCPP_HIDE_FROM_ABI operator bool() const { return __ok; }
629 explicit _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI operator bool() const { return __ok; }
630630};
631631
632632template <typename _Tp>
633inline _LIBCPP_HIDE_FROM_ABI __in_pattern_result
633inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __in_pattern_result
634634__in_pattern(_Tp __c, int __base)
635635{
636636 if (__base <= 10)
637637 return {'0' <= __c && __c < '0' + __base, __c - '0'};
638 else if (__in_pattern(__c))
638 else if (std::__in_pattern(__c))
639639 return {true, __c - '0'};
640640 else if ('a' <= __c && __c < 'a' + __base - 10)
641641 return {true, __c - 'a' + 10};
......@@ -644,7 +644,7 @@ __in_pattern(_Tp __c, int __base)
644644}
645645
646646template <typename _It, typename _Tp, typename _Fn, typename... _Ts>
647inline _LIBCPP_HIDE_FROM_ABI from_chars_result
647inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
648648__subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,
649649 _Ts... __args)
650650{
......@@ -656,7 +656,7 @@ __subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,
656656 };
657657
658658 auto __p = __find_non_zero(__first, __last);
659 if (__p == __last || !__in_pattern(*__p, __args...))
659 if (__p == __last || !std::__in_pattern(*__p, __args...))
660660 {
661661 if (__p == __first)
662662 return {__first, errc::invalid_argument};
......@@ -672,7 +672,7 @@ __subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,
672672 {
673673 for (; __r.ptr != __last; ++__r.ptr)
674674 {
675 if (!__in_pattern(*__r.ptr, __args...))
675 if (!std::__in_pattern(*__r.ptr, __args...))
676676 break;
677677 }
678678 }
......@@ -681,19 +681,19 @@ __subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,
681681}
682682
683683template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0>
684inline _LIBCPP_HIDE_FROM_ABI from_chars_result
684inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
685685__from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
686686{
687687 using __tx = __itoa::__traits<_Tp>;
688688 using __output_type = typename __tx::type;
689689
690 return __subject_seq_combinator(
690 return std::__subject_seq_combinator(
691691 __first, __last, __value,
692692 [](const char* __f, const char* __l,
693693 _Tp& __val) -> from_chars_result {
694694 __output_type __a, __b;
695695 auto __p = __tx::__read(__f, __l, __a, __b);
696 if (__p == __l || !__in_pattern(*__p))
696 if (__p == __l || !std::__in_pattern(*__p))
697697 {
698698 __output_type __m = numeric_limits<_Tp>::max();
699699 if (__m >= __a && __m - __a >= __b)
......@@ -707,27 +707,47 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
707707}
708708
709709template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0>
710inline _LIBCPP_HIDE_FROM_ABI from_chars_result
710inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
711711__from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
712712{
713 using __t = decltype(__to_unsigned_like(__value));
714 return __sign_combinator(__first, __last, __value, __from_chars_atoi<__t>);
713 using __t = decltype(std::__to_unsigned_like(__value));
714 return std::__sign_combinator(__first, __last, __value, __from_chars_atoi<__t>);
715}
716
717
718/*
719// Code used to generate __from_chars_log2f_lut.
720#include <cmath>
721#include <iostream>
722#include <format>
723
724int main() {
725 for (int i = 2; i <= 36; ++i)
726 std::cout << std::format("{},\n", log2f(i));
715727}
728*/
729/// log2f table for bases [2, 36].
730inline constexpr float __from_chars_log2f_lut[35] = {
731 1, 1.5849625, 2, 2.321928, 2.5849626, 2.807355, 3, 3.169925, 3.321928,
732 3.4594316, 3.5849626, 3.7004397, 3.807355, 3.9068906, 4, 4.087463, 4.169925, 4.2479277,
733 4.321928, 4.3923173, 4.4594316, 4.523562, 4.5849624, 4.643856, 4.70044, 4.7548876, 4.807355,
734 4.857981, 4.9068904, 4.9541965, 5, 5.044394, 5.087463, 5.129283, 5.169925};
716735
717736template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0>
718inline _LIBCPP_HIDE_FROM_ABI from_chars_result
737inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
719738__from_chars_integral(const char* __first, const char* __last, _Tp& __value,
720739 int __base)
721740{
722741 if (__base == 10)
723 return __from_chars_atoi(__first, __last, __value);
742 return std::__from_chars_atoi(__first, __last, __value);
724743
725 return __subject_seq_combinator(
744 return std::__subject_seq_combinator(
726745 __first, __last, __value,
727746 [](const char* __p, const char* __lastp, _Tp& __val,
728747 int __b) -> from_chars_result {
729748 using __tl = numeric_limits<_Tp>;
730 auto __digits = __tl::digits / log2f(float(__b));
749 // __base is always between 2 and 36 inclusive.
750 auto __digits = __tl::digits / __from_chars_log2f_lut[__b - 2];
731751 _Tp __x = __in_pattern(*__p++, __b).__val, __y = 0;
732752
733753 for (int __i = 1; __p != __lastp; ++__i, ++__p)
......@@ -762,34 +782,30 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,
762782}
763783
764784template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0>
765inline _LIBCPP_HIDE_FROM_ABI from_chars_result
785inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
766786__from_chars_integral(const char* __first, const char* __last, _Tp& __value,
767787 int __base)
768788{
769 using __t = decltype(__to_unsigned_like(__value));
770 return __sign_combinator(__first, __last, __value,
771 __from_chars_integral<__t>, __base);
789 using __t = decltype(std::__to_unsigned_like(__value));
790 return std::__sign_combinator(__first, __last, __value,
791 __from_chars_integral<__t>, __base);
772792}
773793
774794template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
775inline _LIBCPP_HIDE_FROM_ABI from_chars_result
795inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
776796from_chars(const char* __first, const char* __last, _Tp& __value)
777797{
778 return __from_chars_atoi(__first, __last, __value);
798 return std::__from_chars_atoi(__first, __last, __value);
779799}
780800
781801template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
782inline _LIBCPP_HIDE_FROM_ABI from_chars_result
802inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
783803from_chars(const char* __first, const char* __last, _Tp& __value, int __base)
784804{
785805 _LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]");
786 return __from_chars_integral(__first, __last, __value, __base);
806 return std::__from_chars_integral(__first, __last, __value, __base);
787807}
788808
789// Floating-point implementation starts here.
790// Unlike the other parts of charconv this is only available in C++17 and newer.
791#if _LIBCPP_STD_VER > 14
792
793809_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
794810to_chars_result to_chars(char* __first, char* __last, float __value);
795811
......@@ -817,11 +833,15 @@ to_chars_result to_chars(char* __first, char* __last, double __value, chars_form
817833_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
818834to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt, int __precision);
819835
820# endif // _LIBCPP_STD_VER > 14
821#endif // _LIBCPP_CXX03_LANG
836#endif // _LIBCPP_STD_VER > 14
822837
823838_LIBCPP_END_NAMESPACE_STD
824839
825840_LIBCPP_POP_MACROS
826841
842#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
843# include <concepts>
844# include <iosfwd>
845#endif
846
827847#endif // _LIBCPP_CHARCONV
lib/libcxx/include/chrono+106-43
......@@ -207,7 +207,11 @@ template <class ToDuration, class Rep, class Period>
207207template <class ToDuration, class Rep, class Period>
208208 constexpr ToDuration round(const duration<Rep, Period>& d); // C++17
209209
210// duration I/O is elsewhere
210// duration I/O
211template<class charT, class traits, class Rep, class Period> // C++20
212 basic_ostream<charT, traits>&
213 operator<<(basic_ostream<charT, traits>& os,
214 const duration<Rep, Period>& d);
211215
212216// time_point arithmetic (all constexpr in C++14)
213217template <class Clock, class Duration1, class Rep2, class Period2>
......@@ -332,32 +336,35 @@ constexpr day operator+(const day& x, const days& y) noexcept;
332336constexpr day operator+(const days& x, const day& y) noexcept;
333337constexpr day operator-(const day& x, const days& y) noexcept;
334338constexpr days operator-(const day& x, const day& y) noexcept;
339template<class charT, class traits>
340 basic_ostream<charT, traits>&
341 operator<<(basic_ostream<charT, traits>& os, const day& d);
335342
336343// 25.8.4, class month // C++20
337344class month;
338345constexpr bool operator==(const month& x, const month& y) noexcept;
339constexpr bool operator!=(const month& x, const month& y) noexcept;
340constexpr bool operator< (const month& x, const month& y) noexcept;
341constexpr bool operator> (const month& x, const month& y) noexcept;
342constexpr bool operator<=(const month& x, const month& y) noexcept;
343constexpr bool operator>=(const month& x, const month& y) noexcept;
346constexpr strong_ordering operator<=>(const month& x, const month& y) noexcept;
347
344348constexpr month operator+(const month& x, const months& y) noexcept;
345349constexpr month operator+(const months& x, const month& y) noexcept;
346350constexpr month operator-(const month& x, const months& y) noexcept;
347351constexpr months operator-(const month& x, const month& y) noexcept;
352template<class charT, class traits>
353 basic_ostream<charT, traits>&
354 operator<<(basic_ostream<charT, traits>& os, const month& m);
348355
349356// 25.8.5, class year // C++20
350357class year;
351358constexpr bool operator==(const year& x, const year& y) noexcept;
352constexpr bool operator!=(const year& x, const year& y) noexcept;
353constexpr bool operator< (const year& x, const year& y) noexcept;
354constexpr bool operator> (const year& x, const year& y) noexcept;
355constexpr bool operator<=(const year& x, const year& y) noexcept;
356constexpr bool operator>=(const year& x, const year& y) noexcept;
359constexpr strong_ordering operator<=>(const year& x, const year& y) noexcept;
360
357361constexpr year operator+(const year& x, const years& y) noexcept;
358362constexpr year operator+(const years& x, const year& y) noexcept;
359363constexpr year operator-(const year& x, const years& y) noexcept;
360364constexpr years operator-(const year& x, const year& y) noexcept;
365template<class charT, class traits>
366 basic_ostream<charT, traits>&
367 operator<<(basic_ostream<charT, traits>& os, const year& y);
361368
362369// 25.8.6, class weekday // C++20
363370class weekday;
......@@ -368,6 +375,9 @@ constexpr weekday operator+(const weekday& x, const days& y) noexcept;
368375constexpr weekday operator+(const days& x, const weekday& y) noexcept;
369376constexpr weekday operator-(const weekday& x, const days& y) noexcept;
370377constexpr days operator-(const weekday& x, const weekday& y) noexcept;
378template<class charT, class traits>
379 basic_ostream<charT, traits>&
380 operator<<(basic_ostream<charT, traits>& os, const weekday& wd);
371381
372382// 25.8.7, class weekday_indexed // C++20
373383
......@@ -375,32 +385,39 @@ class weekday_indexed;
375385constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept;
376386constexpr bool operator!=(const weekday_indexed& x, const weekday_indexed& y) noexcept;
377387
388template<class charT, class traits>
389 basic_ostream<charT, traits>&
390 operator<<(basic_ostream<charT, traits>& os, const weekday_indexed& wdi);
391
378392// 25.8.8, class weekday_last // C++20
379393class weekday_last;
380394
381395constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept;
382396constexpr bool operator!=(const weekday_last& x, const weekday_last& y) noexcept;
383397
398template<class charT, class traits>
399 basic_ostream<charT, traits>&
400 operator<<(basic_ostream<charT, traits>& os, const weekday_last& wdl);
401
384402// 25.8.9, class month_day // C++20
385403class month_day;
386404
387405constexpr bool operator==(const month_day& x, const month_day& y) noexcept;
388constexpr bool operator!=(const month_day& x, const month_day& y) noexcept;
389constexpr bool operator< (const month_day& x, const month_day& y) noexcept;
390constexpr bool operator> (const month_day& x, const month_day& y) noexcept;
391constexpr bool operator<=(const month_day& x, const month_day& y) noexcept;
392constexpr bool operator>=(const month_day& x, const month_day& y) noexcept;
406constexpr strong_ordering operator<=>(const month_day& x, const month_day& y) noexcept;
393407
408template<class charT, class traits>
409 basic_ostream<charT, traits>&
410 operator<<(basic_ostream<charT, traits>& os, const month_day& md);
394411
395412// 25.8.10, class month_day_last // C++20
396413class month_day_last;
397414
398415constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept;
399constexpr bool operator!=(const month_day_last& x, const month_day_last& y) noexcept;
400constexpr bool operator< (const month_day_last& x, const month_day_last& y) noexcept;
401constexpr bool operator> (const month_day_last& x, const month_day_last& y) noexcept;
402constexpr bool operator<=(const month_day_last& x, const month_day_last& y) noexcept;
403constexpr bool operator>=(const month_day_last& x, const month_day_last& y) noexcept;
416constexpr strong_ordering operator<=>(const month_day_last& x, const month_day_last& y) noexcept;
417
418template<class charT, class traits>
419 basic_ostream<charT, traits>&
420 operator<<(basic_ostream<charT, traits>& os, const month_day_last& mdl);
404421
405422// 25.8.11, class month_weekday // C++20
406423class month_weekday;
......@@ -408,22 +425,26 @@ class month_weekday;
408425constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept;
409426constexpr bool operator!=(const month_weekday& x, const month_weekday& y) noexcept;
410427
428template<class charT, class traits>
429 basic_ostream<charT, traits>&
430 operator<<(basic_ostream<charT, traits>& os, const month_weekday& mwd);
431
411432// 25.8.12, class month_weekday_last // C++20
412433class month_weekday_last;
413434
414435constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept;
415436constexpr bool operator!=(const month_weekday_last& x, const month_weekday_last& y) noexcept;
416437
438template<class charT, class traits>
439 basic_ostream<charT, traits>&
440 operator<<(basic_ostream<charT, traits>& os, const month_weekday_last& mwdl);
441
417442
418443// 25.8.13, class year_month // C++20
419444class year_month;
420445
421446constexpr bool operator==(const year_month& x, const year_month& y) noexcept;
422constexpr bool operator!=(const year_month& x, const year_month& y) noexcept;
423constexpr bool operator< (const year_month& x, const year_month& y) noexcept;
424constexpr bool operator> (const year_month& x, const year_month& y) noexcept;
425constexpr bool operator<=(const year_month& x, const year_month& y) noexcept;
426constexpr bool operator>=(const year_month& x, const year_month& y) noexcept;
447constexpr strong_ordering operator<=>(const year_month& x, const year_month& y) noexcept;
427448
428449constexpr year_month operator+(const year_month& ym, const months& dm) noexcept;
429450constexpr year_month operator+(const months& dm, const year_month& ym) noexcept;
......@@ -433,15 +454,15 @@ constexpr year_month operator+(const year_month& ym, const years& dy) noexcept;
433454constexpr year_month operator+(const years& dy, const year_month& ym) noexcept;
434455constexpr year_month operator-(const year_month& ym, const years& dy) noexcept;
435456
457template<class charT, class traits>
458 basic_ostream<charT, traits>&
459 operator<<(basic_ostream<charT, traits>& os, const year_month& ym);
460
436461// 25.8.14, class year_month_day class // C++20
437462year_month_day;
438463
439464constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept;
440constexpr bool operator!=(const year_month_day& x, const year_month_day& y) noexcept;
441constexpr bool operator< (const year_month_day& x, const year_month_day& y) noexcept;
442constexpr bool operator> (const year_month_day& x, const year_month_day& y) noexcept;
443constexpr bool operator<=(const year_month_day& x, const year_month_day& y) noexcept;
444constexpr bool operator>=(const year_month_day& x, const year_month_day& y) noexcept;
465constexpr strong_ordering operator<=>(const year_month_day& x, const year_month_day& y) noexcept;
445466
446467constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept;
447468constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept;
......@@ -450,22 +471,15 @@ constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) n
450471constexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept;
451472constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept;
452473
474template<class charT, class traits>
475 basic_ostream<charT, traits>&
476 operator<<(basic_ostream<charT, traits>& os, const year_month_day& ymd);
453477
454478// 25.8.15, class year_month_day_last // C++20
455479class year_month_day_last;
456480
457constexpr bool operator==(const year_month_day_last& x,
458 const year_month_day_last& y) noexcept;
459constexpr bool operator!=(const year_month_day_last& x,
460 const year_month_day_last& y) noexcept;
461constexpr bool operator< (const year_month_day_last& x,
462 const year_month_day_last& y) noexcept;
463constexpr bool operator> (const year_month_day_last& x,
464 const year_month_day_last& y) noexcept;
465constexpr bool operator<=(const year_month_day_last& x,
466 const year_month_day_last& y) noexcept;
467constexpr bool operator>=(const year_month_day_last& x,
468 const year_month_day_last& y) noexcept;
481constexpr bool operator==(const year_month_day_last& x, const year_month_day_last& y) noexcept;
482constexpr strong_ordering operator<=>(const year_month_day_last_day& x, const year_month_day_last_day& y) noexcept;
469483
470484constexpr year_month_day_last
471485 operator+(const year_month_day_last& ymdl, const months& dm) noexcept;
......@@ -480,6 +494,10 @@ constexpr year_month_day_last
480494constexpr year_month_day_last
481495 operator-(const year_month_day_last& ymdl, const years& dy) noexcept;
482496
497template<class charT, class traits>
498 basic_ostream<charT, traits>&
499 operator<<(basic_ostream<charT, traits>& os, const year_month_day_last& ymdl);
500
483501// 25.8.16, class year_month_weekday // C++20
484502class year_month_weekday;
485503
......@@ -501,6 +519,10 @@ constexpr year_month_weekday
501519constexpr year_month_weekday
502520 operator-(const year_month_weekday& ymwd, const years& dy) noexcept;
503521
522template<class charT, class traits>
523 basic_ostream<charT, traits>&
524 operator<<(basic_ostream<charT, traits>& os, const year_month_weekday& ymwd);
525
504526// 25.8.17, class year_month_weekday_last // C++20
505527class year_month_weekday_last;
506528
......@@ -521,6 +543,10 @@ constexpr year_month_weekday_last
521543constexpr year_month_weekday_last
522544 operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
523545
546template<class charT, class traits>
547 basic_ostream<charT, traits>&
548 operator<<(basic_ostream<charT, traits>& os, const year_month_weekday_last& ymwdl);
549
524550// 25.8.18, civil calendar conventional syntax operators // C++20
525551constexpr year_month
526552 operator/(const year& y, const month& m) noexcept;
......@@ -645,7 +671,29 @@ bool operator<(const time_zone& x, const time_zone& y) noexcept;
645671bool operator>(const time_zone& x, const time_zone& y) noexcept;
646672bool operator<=(const time_zone& x, const time_zone& y) noexcept;
647673bool operator>=(const time_zone& x, const time_zone& y) noexcept;
674} // chrono
675
676namespace std {
677 template<class Rep, class Period, class charT>
678 struct formatter<chrono::duration<Rep, Period>, charT>; // C++20
679 template<class charT> struct formatter<chrono::day, charT>; // C++20
680 template<class charT> struct formatter<chrono::month, charT>; // C++20
681 template<class charT> struct formatter<chrono::year, charT>; // C++20
682 template<class charT> struct formatter<chrono::weekday, charT>; // C++20
683 template<class charT> struct formatter<chrono::weekday_indexed, charT>; // C++20
684 template<class charT> struct formatter<chrono::weekday_last, charT>; // C++20
685 template<class charT> struct formatter<chrono::month_day, charT>; // C++20
686 template<class charT> struct formatter<chrono::month_day_last, charT>; // C++20
687 template<class charT> struct formatter<chrono::month_weekday, charT>; // C++20
688 template<class charT> struct formatter<chrono::month_weekday_last, charT>; // C++20
689 template<class charT> struct formatter<chrono::year_month, charT>; // C++20
690 template<class charT> struct formatter<chrono::year_month_day, charT>; // C++20
691 template<class charT> struct formatter<chrono::year_month_day_last, charT>; // C++20
692 template<class charT> struct formatter<chrono::year_month_weekday, charT>; // C++20
693 template<class charT> struct formatter<chrono::year_month_weekday_last, charT>; // C++20
694} // namespace std
648695
696namespace chrono {
649697// calendrical constants
650698inline constexpr last_spec last{}; // C++20
651699inline constexpr chrono::weekday Sunday{0}; // C++20
......@@ -695,6 +743,7 @@ constexpr chrono::year operator ""y(unsigned lo
695743#include <__assert> // all public C++ headers provide the assertion handler
696744#include <__chrono/calendar.h>
697745#include <__chrono/convert_to_timespec.h>
746#include <__chrono/convert_to_tm.h>
698747#include <__chrono/day.h>
699748#include <__chrono/duration.h>
700749#include <__chrono/file_clock.h>
......@@ -716,10 +765,24 @@ constexpr chrono::year operator ""y(unsigned lo
716765#include <version>
717766
718767// standard-mandated includes
768
769// [time.syn]
719770#include <compare>
720771
772#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) && _LIBCPP_STD_VER > 17
773# include <__chrono/formatter.h>
774# include <__chrono/ostream.h>
775# include <__chrono/parser_std_format_spec.h>
776# include <__chrono/statically_widen.h>
777#endif
778
779
721780#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
722781# pragma GCC system_header
723782#endif
724783
784#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
785# include <concepts>
786#endif
787
725788#endif // _LIBCPP_CHRONO
lib/libcxx/include/cinttypes+13
......@@ -236,9 +236,22 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int
236236
237237#include <__assert> // all public C++ headers provide the assertion handler
238238#include <__config>
239
240// standard-mandated includes
241
242// [cinttypes.syn]
239243#include <cstdint>
244
240245#include <inttypes.h>
241246
247#ifndef _LIBCPP_INTTYPES_H
248# error <cinttypes> tried including <inttypes.h> but didn't find libc++'s <inttypes.h> header. \
249 This usually means that your header search paths are not configured properly. \
250 The header search paths should contain the C++ Standard Library headers before \
251 any C Standard Library, and you are probably using compiler flags that make that \
252 not be the case.
253#endif
254
242255#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
243256# pragma GCC system_header
244257#endif
lib/libcxx/include/climits+9
......@@ -39,8 +39,17 @@ Macros:
3939
4040#include <__assert> // all public C++ headers provide the assertion handler
4141#include <__config>
42
4243#include <limits.h>
4344
45#ifndef _LIBCPP_LIMITS_H
46# error <climits> tried including <limits.h> but didn't find libc++'s <limits.h> header. \
47 This usually means that your header search paths are not configured properly. \
48 The header search paths should contain the C++ Standard Library headers before \
49 any C Standard Library, and you are probably using compiler flags that make that \
50 not be the case.
51#endif
52
4453#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
4554# pragma GCC system_header
4655#endif
lib/libcxx/include/clocale+9
......@@ -36,8 +36,17 @@ lconv* localeconv();
3636
3737#include <__assert> // all public C++ headers provide the assertion handler
3838#include <__config>
39
3940#include <locale.h>
4041
42#ifndef _LIBCPP_LOCALE_H
43# error <clocale> tried including <locale.h> but didn't find libc++'s <locale.h> header. \
44 This usually means that your header search paths are not configured properly. \
45 The header search paths should contain the C++ Standard Library headers before \
46 any C Standard Library, and you are probably using compiler flags that make that \
47 not be the case.
48#endif
49
4150#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
4251# pragma GCC system_header
4352#endif
lib/libcxx/include/cmath+190-17
......@@ -306,10 +306,24 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept
306306
307307#include <__assert> // all public C++ headers provide the assertion handler
308308#include <__config>
309#include <math.h>
310#include <type_traits>
309#include <__type_traits/enable_if.h>
310#include <__type_traits/is_arithmetic.h>
311#include <__type_traits/is_constant_evaluated.h>
312#include <__type_traits/is_floating_point.h>
313#include <__type_traits/is_same.h>
314#include <__type_traits/remove_cv.h>
311315#include <version>
312316
317#include <math.h>
318
319#ifndef _LIBCPP_MATH_H
320# error <cmath> tried including <math.h> but didn't find libc++'s <math.h> header. \
321 This usually means that your header search paths are not configured properly. \
322 The header search paths should contain the C++ Standard Library headers before \
323 any C Standard Library, and you are probably using compiler flags that make that \
324 not be the case.
325#endif
326
313327#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
314328# pragma GCC system_header
315329#endif
......@@ -549,14 +563,14 @@ hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
549563 static_assert((!(is_same<_A1, __result_type>::value &&
550564 is_same<_A2, __result_type>::value &&
551565 is_same<_A3, __result_type>::value)), "");
552 return hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
566 return std::hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
553567}
554568#endif
555569
556570template <class _A1>
557571_LIBCPP_INLINE_VISIBILITY
558572_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
559__libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
573__constexpr_isnan(_A1 __lcpp_x) _NOEXCEPT
560574{
561575#if __has_builtin(__builtin_isnan)
562576 return __builtin_isnan(__lcpp_x);
......@@ -568,15 +582,15 @@ __libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
568582template <class _A1>
569583_LIBCPP_INLINE_VISIBILITY
570584_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
571__libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
585__constexpr_isnan(_A1 __lcpp_x) _NOEXCEPT
572586{
573 return isnan(__lcpp_x);
587 return std::isnan(__lcpp_x);
574588}
575589
576590template <class _A1>
577591_LIBCPP_INLINE_VISIBILITY
578592_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
579__libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
593__constexpr_isinf(_A1 __lcpp_x) _NOEXCEPT
580594{
581595#if __has_builtin(__builtin_isinf)
582596 return __builtin_isinf(__lcpp_x);
......@@ -588,15 +602,15 @@ __libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
588602template <class _A1>
589603_LIBCPP_INLINE_VISIBILITY
590604_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
591__libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
605__constexpr_isinf(_A1 __lcpp_x) _NOEXCEPT
592606{
593 return isinf(__lcpp_x);
607 return std::isinf(__lcpp_x);
594608}
595609
596610template <class _A1>
597611_LIBCPP_INLINE_VISIBILITY
598612_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
599__libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
613__constexpr_isfinite(_A1 __lcpp_x) _NOEXCEPT
600614{
601615#if __has_builtin(__builtin_isfinite)
602616 return __builtin_isfinite(__lcpp_x);
......@@ -608,14 +622,169 @@ __libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
608622template <class _A1>
609623_LIBCPP_INLINE_VISIBILITY
610624_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
611__libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
625__constexpr_isfinite(_A1 __lcpp_x) _NOEXCEPT
612626{
613 return isfinite(__lcpp_x);
627 return __builtin_isfinite(__lcpp_x);
628}
629
630_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI float __constexpr_copysign(float __x, float __y) _NOEXCEPT {
631 return __builtin_copysignf(__x, __y);
632}
633
634_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI double __constexpr_copysign(double __x, double __y) _NOEXCEPT {
635 return __builtin_copysign(__x, __y);
636}
637
638_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI long double
639__constexpr_copysign(long double __x, long double __y) _NOEXCEPT {
640 return __builtin_copysignl(__x, __y);
641}
642
643template <class _A1, class _A2>
644_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI
645 typename std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value,
646 std::__promote<_A1, _A2> >::type
647 __constexpr_copysign(_A1 __x, _A2 __y) _NOEXCEPT {
648 typedef typename std::__promote<_A1, _A2>::type __result_type;
649 static_assert((!(std::_IsSame<_A1, __result_type>::value && std::_IsSame<_A2, __result_type>::value)), "");
650 return __builtin_copysign((__result_type)__x, (__result_type)__y);
651}
652
653inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR float __constexpr_fabs(float __x) _NOEXCEPT {
654 return __builtin_fabsf(__x);
655}
656
657inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR double __constexpr_fabs(double __x) _NOEXCEPT {
658 return __builtin_fabs(__x);
659}
660
661inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR long double __constexpr_fabs(long double __x) _NOEXCEPT {
662 return __builtin_fabsl(__x);
663}
664
665template <class _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0>
666_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR double __constexpr_fabs(_Tp __x) _NOEXCEPT {
667 return __builtin_fabs(static_cast<double>(__x));
668}
669
670inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 float __constexpr_fmax(float __x, float __y) _NOEXCEPT {
671#if !__has_constexpr_builtin(__builtin_fmaxf)
672 if (__libcpp_is_constant_evaluated()) {
673 if (std::__constexpr_isnan(__x))
674 return __y;
675 if (std::__constexpr_isnan(__y))
676 return __x;
677 return __x < __y ? __y : __x;
678 }
679#endif
680 return __builtin_fmaxf(__x, __y);
681}
682
683inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 double __constexpr_fmax(double __x, double __y) _NOEXCEPT {
684#if !__has_constexpr_builtin(__builtin_fmax)
685 if (__libcpp_is_constant_evaluated()) {
686 if (std::__constexpr_isnan(__x))
687 return __y;
688 if (std::__constexpr_isnan(__y))
689 return __x;
690 return __x < __y ? __y : __x;
691 }
692#endif
693 return __builtin_fmax(__x, __y);
694}
695
696inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 long double
697__constexpr_fmax(long double __x, long double __y) _NOEXCEPT {
698#if !__has_constexpr_builtin(__builtin_fmaxl)
699 if (__libcpp_is_constant_evaluated()) {
700 if (std::__constexpr_isnan(__x))
701 return __y;
702 if (std::__constexpr_isnan(__y))
703 return __x;
704 return __x < __y ? __y : __x;
705 }
706#endif
707 return __builtin_fmaxl(__x, __y);
708}
709
710template <class _Tp, class _Up, __enable_if_t<is_arithmetic<_Tp>::value && is_arithmetic<_Up>::value, int> = 0>
711_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename __promote<_Tp, _Up>::type
712__constexpr_fmax(_Tp __x, _Up __y) _NOEXCEPT {
713 using __result_type = typename __promote<_Tp, _Up>::type;
714 return std::__constexpr_fmax(static_cast<__result_type>(__x), static_cast<__result_type>(__y));
715}
716
717template <class _Tp>
718_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __constexpr_logb(_Tp __x) {
719#if !__has_constexpr_builtin(__builtin_logb)
720 if (__libcpp_is_constant_evaluated()) {
721 if (__x == _Tp(0)) {
722 // raise FE_DIVBYZERO
723 return -numeric_limits<_Tp>::infinity();
724 }
725
726 if (std::__constexpr_isinf(__x))
727 return numeric_limits<_Tp>::infinity();
728
729 if (std::__constexpr_isnan(__x))
730 return numeric_limits<_Tp>::quiet_NaN();
731
732 __x = std::__constexpr_fabs(__x);
733 unsigned long long __exp = 0;
734 while (__x >= numeric_limits<_Tp>::radix) {
735 __x /= numeric_limits<_Tp>::radix;
736 __exp += 1;
737 }
738 return _Tp(__exp);
739 }
740#endif // !__has_constexpr_builtin(__builtin_logb)
741 return __builtin_logb(__x);
742}
743
744template <class _Tp>
745_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp __constexpr_scalbn(_Tp __x, int __exp) {
746#if !__has_constexpr_builtin(__builtin_scalbln)
747 if (__libcpp_is_constant_evaluated()) {
748 if (__x == _Tp(0))
749 return __x;
750
751 if (std::__constexpr_isinf(__x))
752 return __x;
753
754 if (__exp == _Tp(0))
755 return __x;
756
757 if (std::__constexpr_isnan(__x))
758 return numeric_limits<_Tp>::quiet_NaN();
759
760 _Tp __mult(1);
761 if (__exp > 0) {
762 __mult = numeric_limits<_Tp>::radix;
763 --__exp;
764 } else {
765 ++__exp;
766 __exp = -__exp;
767 __mult /= numeric_limits<_Tp>::radix;
768 }
769
770 while (__exp > 0) {
771 if (!(__exp & 1)) {
772 __mult *= __mult;
773 __exp >>= 1;
774 } else {
775 __x *= __mult;
776 --__exp;
777 }
778 }
779 return __x;
780 }
781#endif // !__has_constexpr_builtin(__builtin_scalbln)
782 return __builtin_scalbn(__x, __exp);
614783}
615784
616785#if _LIBCPP_STD_VER > 17
617786template <typename _Fp>
618constexpr
787_LIBCPP_HIDE_FROM_ABI constexpr
619788_Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept {
620789 if ((__a <= 0 && __b >= 0) || (__a >= 0 && __b <= 0))
621790 return __t * __b + (1 - __t) * __a;
......@@ -628,13 +797,13 @@ _Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept {
628797 return __x < __b ? __x : __b;
629798}
630799
631constexpr float
800_LIBCPP_HIDE_FROM_ABI constexpr float
632801lerp(float __a, float __b, float __t) _NOEXCEPT { return __lerp(__a, __b, __t); }
633802
634constexpr double
803_LIBCPP_HIDE_FROM_ABI constexpr double
635804lerp(double __a, double __b, double __t) _NOEXCEPT { return __lerp(__a, __b, __t); }
636805
637constexpr long double
806_LIBCPP_HIDE_FROM_ABI constexpr long double
638807lerp(long double __a, long double __b, long double __t) _NOEXCEPT { return __lerp(__a, __b, __t); }
639808
640809template <class _A1, class _A2, class _A3>
......@@ -652,7 +821,7 @@ lerp(_A1 __a, _A2 __b, _A3 __t) noexcept
652821 static_assert(!(_IsSame<_A1, __result_type>::value &&
653822 _IsSame<_A2, __result_type>::value &&
654823 _IsSame<_A3, __result_type>::value));
655 return __lerp((__result_type)__a, (__result_type)__b, (__result_type)__t);
824 return std::__lerp((__result_type)__a, (__result_type)__b, (__result_type)__t);
656825}
657826#endif // _LIBCPP_STD_VER > 17
658827
......@@ -660,4 +829,8 @@ _LIBCPP_END_NAMESPACE_STD
660829
661830_LIBCPP_POP_MACROS
662831
832#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
833# include <type_traits>
834#endif
835
663836#endif // _LIBCPP_CMATH
lib/libcxx/include/codecvt+208-240
......@@ -81,9 +81,9 @@ template <>
8181class _LIBCPP_TYPE_VIS __codecvt_utf8<wchar_t>
8282 : public codecvt<wchar_t, char, mbstate_t>
8383{
84 unsigned long _Maxcode_;
84 unsigned long __maxcode_;
8585_LIBCPP_SUPPRESS_DEPRECATED_PUSH
86 codecvt_mode _Mode_;
86 codecvt_mode __mode_;
8787_LIBCPP_SUPPRESS_DEPRECATED_POP
8888public:
8989 typedef wchar_t intern_type;
......@@ -94,26 +94,22 @@ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
9494 _LIBCPP_INLINE_VISIBILITY
9595 explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode,
9696 codecvt_mode __mode)
97 : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
98 _Mode_(__mode) {}
97 : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
98 __mode_(__mode) {}
9999_LIBCPP_SUPPRESS_DEPRECATED_POP
100100protected:
101 virtual result
102 do_out(state_type& __st,
103 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
104 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
105 virtual result
106 do_in(state_type& __st,
107 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
108 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
109 virtual result
110 do_unshift(state_type& __st,
111 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
112 virtual int do_encoding() const _NOEXCEPT;
113 virtual bool do_always_noconv() const _NOEXCEPT;
114 virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
115 size_t __mx) const;
116 virtual int do_max_length() const _NOEXCEPT;
101 result do_out(state_type& __st,
102 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
103 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
104 result do_in(state_type& __st,
105 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
106 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
107 result do_unshift(state_type& __st,
108 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
109 int do_encoding() const _NOEXCEPT override;
110 bool do_always_noconv() const _NOEXCEPT override;
111 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
112 int do_max_length() const _NOEXCEPT override;
117113};
118114#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
119115
......@@ -122,8 +118,8 @@ template <>
122118class _LIBCPP_TYPE_VIS __codecvt_utf8<char16_t>
123119 : public codecvt<char16_t, char, mbstate_t>
124120{
125 unsigned long _Maxcode_;
126 codecvt_mode _Mode_;
121 unsigned long __maxcode_;
122 codecvt_mode __mode_;
127123public:
128124 typedef char16_t intern_type;
129125 typedef char extern_type;
......@@ -132,27 +128,23 @@ public:
132128 _LIBCPP_INLINE_VISIBILITY
133129 explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode,
134130 codecvt_mode __mode)
135 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
136 _Mode_(__mode) {}
131 : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
132 __mode_(__mode) {}
137133_LIBCPP_SUPPRESS_DEPRECATED_POP
138134
139135protected:
140 virtual result
141 do_out(state_type& __st,
142 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
143 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
144 virtual result
145 do_in(state_type& __st,
146 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
147 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
148 virtual result
149 do_unshift(state_type& __st,
150 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
151 virtual int do_encoding() const _NOEXCEPT;
152 virtual bool do_always_noconv() const _NOEXCEPT;
153 virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
154 size_t __mx) const;
155 virtual int do_max_length() const _NOEXCEPT;
136 result do_out(state_type& __st,
137 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
138 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
139 result do_in(state_type& __st,
140 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
141 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
142 result do_unshift(state_type& __st,
143 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
144 int do_encoding() const _NOEXCEPT override;
145 bool do_always_noconv() const _NOEXCEPT override;
146 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
147 int do_max_length() const _NOEXCEPT override;
156148};
157149
158150_LIBCPP_SUPPRESS_DEPRECATED_PUSH
......@@ -160,8 +152,8 @@ template <>
160152class _LIBCPP_TYPE_VIS __codecvt_utf8<char32_t>
161153 : public codecvt<char32_t, char, mbstate_t>
162154{
163 unsigned long _Maxcode_;
164 codecvt_mode _Mode_;
155 unsigned long __maxcode_;
156 codecvt_mode __mode_;
165157public:
166158 typedef char32_t intern_type;
167159 typedef char extern_type;
......@@ -170,27 +162,23 @@ public:
170162 _LIBCPP_INLINE_VISIBILITY
171163 explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode,
172164 codecvt_mode __mode)
173 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
174 _Mode_(__mode) {}
165 : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
166 __mode_(__mode) {}
175167_LIBCPP_SUPPRESS_DEPRECATED_POP
176168
177169protected:
178 virtual result
179 do_out(state_type& __st,
180 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
181 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
182 virtual result
183 do_in(state_type& __st,
184 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
185 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
186 virtual result
187 do_unshift(state_type& __st,
188 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
189 virtual int do_encoding() const _NOEXCEPT;
190 virtual bool do_always_noconv() const _NOEXCEPT;
191 virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
192 size_t __mx) const;
193 virtual int do_max_length() const _NOEXCEPT;
170 result do_out(state_type& __st,
171 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
172 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
173 result do_in(state_type& __st,
174 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
175 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
176 result do_unshift(state_type& __st,
177 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
178 int do_encoding() const _NOEXCEPT override;
179 bool do_always_noconv() const _NOEXCEPT override;
180 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
181 int do_max_length() const _NOEXCEPT override;
194182};
195183
196184_LIBCPP_SUPPRESS_DEPRECATED_PUSH
......@@ -218,9 +206,9 @@ template <>
218206class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, false>
219207 : public codecvt<wchar_t, char, mbstate_t>
220208{
221 unsigned long _Maxcode_;
209 unsigned long __maxcode_;
222210_LIBCPP_SUPPRESS_DEPRECATED_PUSH
223 codecvt_mode _Mode_;
211 codecvt_mode __mode_;
224212_LIBCPP_SUPPRESS_DEPRECATED_POP
225213public:
226214 typedef wchar_t intern_type;
......@@ -231,35 +219,32 @@ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
231219 _LIBCPP_INLINE_VISIBILITY
232220 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
233221 codecvt_mode __mode)
234 : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
235 _Mode_(__mode) {}
222 : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
223 __mode_(__mode) {}
236224_LIBCPP_SUPPRESS_DEPRECATED_POP
237225protected:
238 virtual result
239 do_out(state_type& __st,
240 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
241 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
242 virtual result
243 do_in(state_type& __st,
244 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
245 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
246 virtual result
247 do_unshift(state_type& __st,
248 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
249 virtual int do_encoding() const _NOEXCEPT;
250 virtual bool do_always_noconv() const _NOEXCEPT;
251 virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
252 size_t __mx) const;
253 virtual int do_max_length() const _NOEXCEPT;
226 result do_out(state_type& __st,
227 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
228 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
229 result do_in(state_type& __st,
230 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
231 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
232 result do_unshift(state_type& __st,
233 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
234 int do_encoding() const _NOEXCEPT override;
235 bool do_always_noconv() const _NOEXCEPT override;
236 int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
237 size_t __mx) const override;
238 int do_max_length() const _NOEXCEPT override;
254239};
255240
256241template <>
257242class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, true>
258243 : public codecvt<wchar_t, char, mbstate_t>
259244{
260 unsigned long _Maxcode_;
245 unsigned long __maxcode_;
261246_LIBCPP_SUPPRESS_DEPRECATED_PUSH
262 codecvt_mode _Mode_;
247 codecvt_mode __mode_;
263248_LIBCPP_SUPPRESS_DEPRECATED_POP
264249public:
265250 typedef wchar_t intern_type;
......@@ -270,26 +255,22 @@ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
270255 _LIBCPP_INLINE_VISIBILITY
271256 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
272257 codecvt_mode __mode)
273 : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
274 _Mode_(__mode) {}
258 : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
259 __mode_(__mode) {}
275260_LIBCPP_SUPPRESS_DEPRECATED_POP
276261protected:
277 virtual result
278 do_out(state_type& __st,
279 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
280 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
281 virtual result
282 do_in(state_type& __st,
283 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
284 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
285 virtual result
286 do_unshift(state_type& __st,
287 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
288 virtual int do_encoding() const _NOEXCEPT;
289 virtual bool do_always_noconv() const _NOEXCEPT;
290 virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
291 size_t __mx) const;
292 virtual int do_max_length() const _NOEXCEPT;
262 result do_out(state_type& __st,
263 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
264 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
265 result do_in(state_type& __st,
266 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
267 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
268 result do_unshift(state_type& __st,
269 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
270 int do_encoding() const _NOEXCEPT override;
271 bool do_always_noconv() const _NOEXCEPT override;
272 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
273 int do_max_length() const _NOEXCEPT override;
293274};
294275#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
295276
......@@ -298,8 +279,8 @@ template <>
298279class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, false>
299280 : public codecvt<char16_t, char, mbstate_t>
300281{
301 unsigned long _Maxcode_;
302 codecvt_mode _Mode_;
282 unsigned long __maxcode_;
283 codecvt_mode __mode_;
303284public:
304285 typedef char16_t intern_type;
305286 typedef char extern_type;
......@@ -308,27 +289,23 @@ public:
308289 _LIBCPP_INLINE_VISIBILITY
309290 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
310291 codecvt_mode __mode)
311 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
312 _Mode_(__mode) {}
292 : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
293 __mode_(__mode) {}
313294_LIBCPP_SUPPRESS_DEPRECATED_POP
314295
315296protected:
316 virtual result
317 do_out(state_type& __st,
318 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
319 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
320 virtual result
321 do_in(state_type& __st,
322 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
323 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
324 virtual result
325 do_unshift(state_type& __st,
326 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
327 virtual int do_encoding() const _NOEXCEPT;
328 virtual bool do_always_noconv() const _NOEXCEPT;
329 virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
330 size_t __mx) const;
331 virtual int do_max_length() const _NOEXCEPT;
297 result do_out(state_type& __st,
298 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
299 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
300 result do_in(state_type& __st,
301 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
302 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
303 result do_unshift(state_type& __st,
304 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
305 int do_encoding() const _NOEXCEPT override;
306 bool do_always_noconv() const _NOEXCEPT override;
307 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
308 int do_max_length() const _NOEXCEPT override;
332309};
333310
334311_LIBCPP_SUPPRESS_DEPRECATED_PUSH
......@@ -336,8 +313,8 @@ template <>
336313class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, true>
337314 : public codecvt<char16_t, char, mbstate_t>
338315{
339 unsigned long _Maxcode_;
340 codecvt_mode _Mode_;
316 unsigned long __maxcode_;
317 codecvt_mode __mode_;
341318public:
342319 typedef char16_t intern_type;
343320 typedef char extern_type;
......@@ -346,27 +323,23 @@ public:
346323 _LIBCPP_INLINE_VISIBILITY
347324 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
348325 codecvt_mode __mode)
349 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
350 _Mode_(__mode) {}
326 : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
327 __mode_(__mode) {}
351328_LIBCPP_SUPPRESS_DEPRECATED_POP
352329
353330protected:
354 virtual result
355 do_out(state_type& __st,
356 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
357 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
358 virtual result
359 do_in(state_type& __st,
360 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
361 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
362 virtual result
363 do_unshift(state_type& __st,
364 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
365 virtual int do_encoding() const _NOEXCEPT;
366 virtual bool do_always_noconv() const _NOEXCEPT;
367 virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
368 size_t __mx) const;
369 virtual int do_max_length() const _NOEXCEPT;
331 result do_out(state_type& __st,
332 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
333 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
334 result do_in(state_type& __st,
335 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
336 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
337 result do_unshift(state_type& __st,
338 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
339 int do_encoding() const _NOEXCEPT override;
340 bool do_always_noconv() const _NOEXCEPT override;
341 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
342 int do_max_length() const _NOEXCEPT override;
370343};
371344
372345_LIBCPP_SUPPRESS_DEPRECATED_PUSH
......@@ -374,8 +347,8 @@ template <>
374347class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, false>
375348 : public codecvt<char32_t, char, mbstate_t>
376349{
377 unsigned long _Maxcode_;
378 codecvt_mode _Mode_;
350 unsigned long __maxcode_;
351 codecvt_mode __mode_;
379352public:
380353 typedef char32_t intern_type;
381354 typedef char extern_type;
......@@ -384,27 +357,23 @@ public:
384357 _LIBCPP_INLINE_VISIBILITY
385358 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
386359 codecvt_mode __mode)
387 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
388 _Mode_(__mode) {}
360 : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
361 __mode_(__mode) {}
389362_LIBCPP_SUPPRESS_DEPRECATED_POP
390363
391364protected:
392 virtual result
393 do_out(state_type& __st,
394 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
395 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
396 virtual result
397 do_in(state_type& __st,
398 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
399 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
400 virtual result
401 do_unshift(state_type& __st,
402 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
403 virtual int do_encoding() const _NOEXCEPT;
404 virtual bool do_always_noconv() const _NOEXCEPT;
405 virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
406 size_t __mx) const;
407 virtual int do_max_length() const _NOEXCEPT;
365 result do_out(state_type& __st,
366 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
367 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
368 result do_in(state_type& __st,
369 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
370 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
371 result do_unshift(state_type& __st,
372 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
373 int do_encoding() const _NOEXCEPT override;
374 bool do_always_noconv() const _NOEXCEPT override;
375 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
376 int do_max_length() const _NOEXCEPT override;
408377};
409378
410379_LIBCPP_SUPPRESS_DEPRECATED_PUSH
......@@ -412,8 +381,8 @@ template <>
412381class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, true>
413382 : public codecvt<char32_t, char, mbstate_t>
414383{
415 unsigned long _Maxcode_;
416 codecvt_mode _Mode_;
384 unsigned long __maxcode_;
385 codecvt_mode __mode_;
417386public:
418387 typedef char32_t intern_type;
419388 typedef char extern_type;
......@@ -422,27 +391,23 @@ public:
422391 _LIBCPP_INLINE_VISIBILITY
423392 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
424393 codecvt_mode __mode)
425 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
426 _Mode_(__mode) {}
394 : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
395 __mode_(__mode) {}
427396_LIBCPP_SUPPRESS_DEPRECATED_POP
428397
429398protected:
430 virtual result
431 do_out(state_type& __st,
432 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
433 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
434 virtual result
435 do_in(state_type& __st,
436 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
437 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
438 virtual result
439 do_unshift(state_type& __st,
440 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
441 virtual int do_encoding() const _NOEXCEPT;
442 virtual bool do_always_noconv() const _NOEXCEPT;
443 virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
444 size_t __mx) const;
445 virtual int do_max_length() const _NOEXCEPT;
399 result do_out(state_type& __st,
400 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
401 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
402 result do_in(state_type& __st,
403 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
404 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
405 result do_unshift(state_type& __st,
406 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
407 int do_encoding() const _NOEXCEPT override;
408 bool do_always_noconv() const _NOEXCEPT override;
409 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
410 int do_max_length() const _NOEXCEPT override;
446411};
447412
448413_LIBCPP_SUPPRESS_DEPRECATED_PUSH
......@@ -470,9 +435,9 @@ template <>
470435class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<wchar_t>
471436 : public codecvt<wchar_t, char, mbstate_t>
472437{
473 unsigned long _Maxcode_;
438 unsigned long __maxcode_;
474439_LIBCPP_SUPPRESS_DEPRECATED_PUSH
475 codecvt_mode _Mode_;
440 codecvt_mode __mode_;
476441_LIBCPP_SUPPRESS_DEPRECATED_POP
477442public:
478443 typedef wchar_t intern_type;
......@@ -483,26 +448,22 @@ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
483448 _LIBCPP_INLINE_VISIBILITY
484449 explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode,
485450 codecvt_mode __mode)
486 : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
487 _Mode_(__mode) {}
451 : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
452 __mode_(__mode) {}
488453_LIBCPP_SUPPRESS_DEPRECATED_POP
489454protected:
490 virtual result
491 do_out(state_type& __st,
492 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
493 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
494 virtual result
495 do_in(state_type& __st,
496 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
497 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
498 virtual result
499 do_unshift(state_type& __st,
500 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
501 virtual int do_encoding() const _NOEXCEPT;
502 virtual bool do_always_noconv() const _NOEXCEPT;
503 virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
504 size_t __mx) const;
505 virtual int do_max_length() const _NOEXCEPT;
455 result do_out(state_type& __st,
456 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
457 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
458 result do_in(state_type& __st,
459 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
460 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
461 result do_unshift(state_type& __st,
462 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
463 int do_encoding() const _NOEXCEPT override;
464 bool do_always_noconv() const _NOEXCEPT override;
465 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
466 int do_max_length() const _NOEXCEPT override;
506467};
507468#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
508469
......@@ -511,8 +472,8 @@ template <>
511472class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char32_t>
512473 : public codecvt<char32_t, char, mbstate_t>
513474{
514 unsigned long _Maxcode_;
515 codecvt_mode _Mode_;
475 unsigned long __maxcode_;
476 codecvt_mode __mode_;
516477public:
517478 typedef char32_t intern_type;
518479 typedef char extern_type;
......@@ -521,27 +482,23 @@ public:
521482 _LIBCPP_INLINE_VISIBILITY
522483 explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode,
523484 codecvt_mode __mode)
524 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
525 _Mode_(__mode) {}
485 : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
486 __mode_(__mode) {}
526487_LIBCPP_SUPPRESS_DEPRECATED_POP
527488
528489protected:
529 virtual result
530 do_out(state_type& __st,
531 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
532 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
533 virtual result
534 do_in(state_type& __st,
535 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
536 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
537 virtual result
538 do_unshift(state_type& __st,
539 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
540 virtual int do_encoding() const _NOEXCEPT;
541 virtual bool do_always_noconv() const _NOEXCEPT;
542 virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
543 size_t __mx) const;
544 virtual int do_max_length() const _NOEXCEPT;
490 result do_out(state_type& __st,
491 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
492 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
493 result do_in(state_type& __st,
494 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
495 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
496 result do_unshift(state_type& __st,
497 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
498 int do_encoding() const _NOEXCEPT override;
499 bool do_always_noconv() const _NOEXCEPT override;
500 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
501 int do_max_length() const _NOEXCEPT override;
545502};
546503
547504_LIBCPP_SUPPRESS_DEPRECATED_PUSH
......@@ -549,8 +506,8 @@ template <>
549506class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char16_t>
550507 : public codecvt<char16_t, char, mbstate_t>
551508{
552 unsigned long _Maxcode_;
553 codecvt_mode _Mode_;
509 unsigned long __maxcode_;
510 codecvt_mode __mode_;
554511public:
555512 typedef char16_t intern_type;
556513 typedef char extern_type;
......@@ -559,27 +516,23 @@ public:
559516 _LIBCPP_INLINE_VISIBILITY
560517 explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode,
561518 codecvt_mode __mode)
562 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),
563 _Mode_(__mode) {}
519 : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
520 __mode_(__mode) {}
564521_LIBCPP_SUPPRESS_DEPRECATED_POP
565522
566523protected:
567 virtual result
568 do_out(state_type& __st,
569 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
570 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
571 virtual result
572 do_in(state_type& __st,
573 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
574 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
575 virtual result
576 do_unshift(state_type& __st,
577 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
578 virtual int do_encoding() const _NOEXCEPT;
579 virtual bool do_always_noconv() const _NOEXCEPT;
580 virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
581 size_t __mx) const;
582 virtual int do_max_length() const _NOEXCEPT;
524 result do_out(state_type& __st,
525 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
526 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
527 result do_in(state_type& __st,
528 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
529 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
530 result do_unshift(state_type& __st,
531 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
532 int do_encoding() const _NOEXCEPT override;
533 bool do_always_noconv() const _NOEXCEPT override;
534 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
535 int do_max_length() const _NOEXCEPT override;
583536};
584537
585538_LIBCPP_SUPPRESS_DEPRECATED_PUSH
......@@ -600,4 +553,19 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
600553
601554_LIBCPP_END_NAMESPACE_STD
602555
556#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
557# include <atomic>
558# include <concepts>
559# include <cstddef>
560# include <cstdlib>
561# include <cstring>
562# include <initializer_list>
563# include <iosfwd>
564# include <limits>
565# include <new>
566# include <stdexcept>
567# include <type_traits>
568# include <typeinfo>
569#endif
570
603571#endif // _LIBCPP_CODECVT
lib/libcxx/include/compare+4
......@@ -160,4 +160,8 @@ namespace std {
160160# pragma GCC system_header
161161#endif
162162
163#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
164# include <type_traits>
165#endif
166
163167#endif // _LIBCPP_COMPARE
lib/libcxx/include/complex+422-349
......@@ -29,21 +29,21 @@ public:
2929 T real() const; // constexpr in C++14
3030 T imag() const; // constexpr in C++14
3131
32 void real(T);
33 void imag(T);
34
35 complex<T>& operator= (const T&);
36 complex<T>& operator+=(const T&);
37 complex<T>& operator-=(const T&);
38 complex<T>& operator*=(const T&);
39 complex<T>& operator/=(const T&);
40
41 complex& operator=(const complex&);
42 template<class X> complex<T>& operator= (const complex<X>&);
43 template<class X> complex<T>& operator+=(const complex<X>&);
44 template<class X> complex<T>& operator-=(const complex<X>&);
45 template<class X> complex<T>& operator*=(const complex<X>&);
46 template<class X> complex<T>& operator/=(const complex<X>&);
32 void real(T); // constexpr in C++20
33 void imag(T); // constexpr in C++20
34
35 complex<T>& operator= (const T&); // constexpr in C++20
36 complex<T>& operator+=(const T&); // constexpr in C++20
37 complex<T>& operator-=(const T&); // constexpr in C++20
38 complex<T>& operator*=(const T&); // constexpr in C++20
39 complex<T>& operator/=(const T&); // constexpr in C++20
40
41 complex& operator=(const complex&); // constexpr in C++20
42 template<class X> complex<T>& operator= (const complex<X>&); // constexpr in C++20
43 template<class X> complex<T>& operator+=(const complex<X>&); // constexpr in C++20
44 template<class X> complex<T>& operator-=(const complex<X>&); // constexpr in C++20
45 template<class X> complex<T>& operator*=(const complex<X>&); // constexpr in C++20
46 template<class X> complex<T>& operator/=(const complex<X>&); // constexpr in C++20
4747};
4848
4949template<>
......@@ -57,22 +57,22 @@ public:
5757 explicit constexpr complex(const complex<long double>&);
5858
5959 constexpr float real() const;
60 void real(float);
60 void real(float); // constexpr in C++20
6161 constexpr float imag() const;
62 void imag(float);
63
64 complex<float>& operator= (float);
65 complex<float>& operator+=(float);
66 complex<float>& operator-=(float);
67 complex<float>& operator*=(float);
68 complex<float>& operator/=(float);
69
70 complex<float>& operator=(const complex<float>&);
71 template<class X> complex<float>& operator= (const complex<X>&);
72 template<class X> complex<float>& operator+=(const complex<X>&);
73 template<class X> complex<float>& operator-=(const complex<X>&);
74 template<class X> complex<float>& operator*=(const complex<X>&);
75 template<class X> complex<float>& operator/=(const complex<X>&);
62 void imag(float); // constexpr in C++20
63
64 complex<float>& operator= (float); // constexpr in C++20
65 complex<float>& operator+=(float); // constexpr in C++20
66 complex<float>& operator-=(float); // constexpr in C++20
67 complex<float>& operator*=(float); // constexpr in C++20
68 complex<float>& operator/=(float); // constexpr in C++20
69
70 complex<float>& operator=(const complex<float>&); // constexpr in C++20
71 template<class X> complex<float>& operator= (const complex<X>&); // constexpr in C++20
72 template<class X> complex<float>& operator+=(const complex<X>&); // constexpr in C++20
73 template<class X> complex<float>& operator-=(const complex<X>&); // constexpr in C++20
74 template<class X> complex<float>& operator*=(const complex<X>&); // constexpr in C++20
75 template<class X> complex<float>& operator/=(const complex<X>&); // constexpr in C++20
7676};
7777
7878template<>
......@@ -86,22 +86,22 @@ public:
8686 explicit constexpr complex(const complex<long double>&);
8787
8888 constexpr double real() const;
89 void real(double);
89 void real(double); // constexpr in C++20
9090 constexpr double imag() const;
91 void imag(double);
92
93 complex<double>& operator= (double);
94 complex<double>& operator+=(double);
95 complex<double>& operator-=(double);
96 complex<double>& operator*=(double);
97 complex<double>& operator/=(double);
98 complex<double>& operator=(const complex<double>&);
99
100 template<class X> complex<double>& operator= (const complex<X>&);
101 template<class X> complex<double>& operator+=(const complex<X>&);
102 template<class X> complex<double>& operator-=(const complex<X>&);
103 template<class X> complex<double>& operator*=(const complex<X>&);
104 template<class X> complex<double>& operator/=(const complex<X>&);
91 void imag(double); // constexpr in C++20
92
93 complex<double>& operator= (double); // constexpr in C++20
94 complex<double>& operator+=(double); // constexpr in C++20
95 complex<double>& operator-=(double); // constexpr in C++20
96 complex<double>& operator*=(double); // constexpr in C++20
97 complex<double>& operator/=(double); // constexpr in C++20
98 complex<double>& operator=(const complex<double>&); // constexpr in C++20
99
100 template<class X> complex<double>& operator= (const complex<X>&); // constexpr in C++20
101 template<class X> complex<double>& operator+=(const complex<X>&); // constexpr in C++20
102 template<class X> complex<double>& operator-=(const complex<X>&); // constexpr in C++20
103 template<class X> complex<double>& operator*=(const complex<X>&); // constexpr in C++20
104 template<class X> complex<double>& operator/=(const complex<X>&); // constexpr in C++20
105105};
106106
107107template<>
......@@ -115,39 +115,39 @@ public:
115115 constexpr complex(const complex<double>&);
116116
117117 constexpr long double real() const;
118 void real(long double);
118 void real(long double); // constexpr in C++20
119119 constexpr long double imag() const;
120 void imag(long double);
121
122 complex<long double>& operator=(const complex<long double>&);
123 complex<long double>& operator= (long double);
124 complex<long double>& operator+=(long double);
125 complex<long double>& operator-=(long double);
126 complex<long double>& operator*=(long double);
127 complex<long double>& operator/=(long double);
128
129 template<class X> complex<long double>& operator= (const complex<X>&);
130 template<class X> complex<long double>& operator+=(const complex<X>&);
131 template<class X> complex<long double>& operator-=(const complex<X>&);
132 template<class X> complex<long double>& operator*=(const complex<X>&);
133 template<class X> complex<long double>& operator/=(const complex<X>&);
120 void imag(long double); // constexpr in C++20
121
122 complex<long double>& operator=(const complex<long double>&); // constexpr in C++20
123 complex<long double>& operator= (long double); // constexpr in C++20
124 complex<long double>& operator+=(long double); // constexpr in C++20
125 complex<long double>& operator-=(long double); // constexpr in C++20
126 complex<long double>& operator*=(long double); // constexpr in C++20
127 complex<long double>& operator/=(long double); // constexpr in C++20
128
129 template<class X> complex<long double>& operator= (const complex<X>&); // constexpr in C++20
130 template<class X> complex<long double>& operator+=(const complex<X>&); // constexpr in C++20
131 template<class X> complex<long double>& operator-=(const complex<X>&); // constexpr in C++20
132 template<class X> complex<long double>& operator*=(const complex<X>&); // constexpr in C++20
133 template<class X> complex<long double>& operator/=(const complex<X>&); // constexpr in C++20
134134};
135135
136136// 26.3.6 operators:
137template<class T> complex<T> operator+(const complex<T>&, const complex<T>&);
138template<class T> complex<T> operator+(const complex<T>&, const T&);
139template<class T> complex<T> operator+(const T&, const complex<T>&);
140template<class T> complex<T> operator-(const complex<T>&, const complex<T>&);
141template<class T> complex<T> operator-(const complex<T>&, const T&);
142template<class T> complex<T> operator-(const T&, const complex<T>&);
143template<class T> complex<T> operator*(const complex<T>&, const complex<T>&);
144template<class T> complex<T> operator*(const complex<T>&, const T&);
145template<class T> complex<T> operator*(const T&, const complex<T>&);
146template<class T> complex<T> operator/(const complex<T>&, const complex<T>&);
147template<class T> complex<T> operator/(const complex<T>&, const T&);
148template<class T> complex<T> operator/(const T&, const complex<T>&);
149template<class T> complex<T> operator+(const complex<T>&);
150template<class T> complex<T> operator-(const complex<T>&);
137template<class T> complex<T> operator+(const complex<T>&, const complex<T>&); // constexpr in C++20
138template<class T> complex<T> operator+(const complex<T>&, const T&); // constexpr in C++20
139template<class T> complex<T> operator+(const T&, const complex<T>&); // constexpr in C++20
140template<class T> complex<T> operator-(const complex<T>&, const complex<T>&); // constexpr in C++20
141template<class T> complex<T> operator-(const complex<T>&, const T&); // constexpr in C++20
142template<class T> complex<T> operator-(const T&, const complex<T>&); // constexpr in C++20
143template<class T> complex<T> operator*(const complex<T>&, const complex<T>&); // constexpr in C++20
144template<class T> complex<T> operator*(const complex<T>&, const T&); // constexpr in C++20
145template<class T> complex<T> operator*(const T&, const complex<T>&); // constexpr in C++20
146template<class T> complex<T> operator/(const complex<T>&, const complex<T>&); // constexpr in C++20
147template<class T> complex<T> operator/(const complex<T>&, const T&); // constexpr in C++20
148template<class T> complex<T> operator/(const T&, const complex<T>&); // constexpr in C++20
149template<class T> complex<T> operator+(const complex<T>&); // constexpr in C++20
150template<class T> complex<T> operator-(const complex<T>&); // constexpr in C++20
151151template<class T> bool operator==(const complex<T>&, const complex<T>&); // constexpr in C++14
152152template<class T> bool operator==(const complex<T>&, const T&); // constexpr in C++14
153153template<class T> bool operator==(const T&, const complex<T>&); // constexpr in C++14
......@@ -184,17 +184,17 @@ template<class T> T arg(const complex<T>&);
184184template<Integral T> double arg(T);
185185 float arg(float);
186186
187template<class T> T norm(const complex<T>&);
188 long double norm(long double);
189 double norm(double);
190template<Integral T> double norm(T);
191 float norm(float);
187template<class T> T norm(const complex<T>&); // constexpr in C++20
188 long double norm(long double); // constexpr in C++20
189 double norm(double); // constexpr in C++20
190template<Integral T> double norm(T); // constexpr in C++20
191 float norm(float); // constexpr in C++20
192192
193template<class T> complex<T> conj(const complex<T>&);
194 complex<long double> conj(long double);
195 complex<double> conj(double);
196template<Integral T> complex<double> conj(T);
197 complex<float> conj(float);
193template<class T> complex<T> conj(const complex<T>&); // constexpr in C++20
194 complex<long double> conj(long double); // constexpr in C++20
195 complex<double> conj(double); // constexpr in C++20
196template<Integral T> complex<double> conj(T); // constexpr in C++20
197 complex<float> conj(float); // constexpr in C++20
198198
199199template<class T> complex<T> proj(const complex<T>&);
200200 complex<long double> proj(long double);
......@@ -251,8 +251,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
251251
252252template<class _Tp> class _LIBCPP_TEMPLATE_VIS complex;
253253
254template<class _Tp> complex<_Tp> operator*(const complex<_Tp>& __z, const complex<_Tp>& __w);
255template<class _Tp> complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y);
254template<class _Tp> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> operator*(const complex<_Tp>& __z, const complex<_Tp>& __w);
255template<class _Tp> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y);
256256
257257template<class _Tp>
258258class _LIBCPP_TEMPLATE_VIS complex
......@@ -263,50 +263,50 @@ private:
263263 value_type __re_;
264264 value_type __im_;
265265public:
266 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
266 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
267267 complex(const value_type& __re = value_type(), const value_type& __im = value_type())
268268 : __re_(__re), __im_(__im) {}
269 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
269 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
270270 complex(const complex<_Xp>& __c)
271271 : __re_(__c.real()), __im_(__c.imag()) {}
272272
273 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 value_type real() const {return __re_;}
274 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 value_type imag() const {return __im_;}
273 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 value_type real() const {return __re_;}
274 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 value_type imag() const {return __im_;}
275275
276 _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;}
277 _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}
276 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) {__re_ = __re;}
277 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) {__im_ = __im;}
278278
279 _LIBCPP_INLINE_VISIBILITY complex& operator= (const value_type& __re)
279 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator= (const value_type& __re)
280280 {__re_ = __re; __im_ = value_type(); return *this;}
281 _LIBCPP_INLINE_VISIBILITY complex& operator+=(const value_type& __re) {__re_ += __re; return *this;}
282 _LIBCPP_INLINE_VISIBILITY complex& operator-=(const value_type& __re) {__re_ -= __re; return *this;}
283 _LIBCPP_INLINE_VISIBILITY complex& operator*=(const value_type& __re) {__re_ *= __re; __im_ *= __re; return *this;}
284 _LIBCPP_INLINE_VISIBILITY complex& operator/=(const value_type& __re) {__re_ /= __re; __im_ /= __re; return *this;}
281 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(const value_type& __re) {__re_ += __re; return *this;}
282 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(const value_type& __re) {__re_ -= __re; return *this;}
283 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(const value_type& __re) {__re_ *= __re; __im_ *= __re; return *this;}
284 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(const value_type& __re) {__re_ /= __re; __im_ /= __re; return *this;}
285285
286 template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c)
286 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator= (const complex<_Xp>& __c)
287287 {
288288 __re_ = __c.real();
289289 __im_ = __c.imag();
290290 return *this;
291291 }
292 template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c)
292 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(const complex<_Xp>& __c)
293293 {
294294 __re_ += __c.real();
295295 __im_ += __c.imag();
296296 return *this;
297297 }
298 template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c)
298 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(const complex<_Xp>& __c)
299299 {
300300 __re_ -= __c.real();
301301 __im_ -= __c.imag();
302302 return *this;
303303 }
304 template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c)
304 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(const complex<_Xp>& __c)
305305 {
306306 *this = *this * complex(__c.real(), __c.imag());
307307 return *this;
308308 }
309 template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c)
309 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(const complex<_Xp>& __c)
310310 {
311311 *this = *this / complex(__c.real(), __c.imag());
312312 return *this;
......@@ -334,40 +334,40 @@ public:
334334 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR float real() const {return __re_;}
335335 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR float imag() const {return __im_;}
336336
337 _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;}
338 _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}
337 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) {__re_ = __re;}
338 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) {__im_ = __im;}
339339
340 _LIBCPP_INLINE_VISIBILITY complex& operator= (float __re)
340 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator= (float __re)
341341 {__re_ = __re; __im_ = value_type(); return *this;}
342 _LIBCPP_INLINE_VISIBILITY complex& operator+=(float __re) {__re_ += __re; return *this;}
343 _LIBCPP_INLINE_VISIBILITY complex& operator-=(float __re) {__re_ -= __re; return *this;}
344 _LIBCPP_INLINE_VISIBILITY complex& operator*=(float __re) {__re_ *= __re; __im_ *= __re; return *this;}
345 _LIBCPP_INLINE_VISIBILITY complex& operator/=(float __re) {__re_ /= __re; __im_ /= __re; return *this;}
342 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(float __re) {__re_ += __re; return *this;}
343 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(float __re) {__re_ -= __re; return *this;}
344 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(float __re) {__re_ *= __re; __im_ *= __re; return *this;}
345 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(float __re) {__re_ /= __re; __im_ /= __re; return *this;}
346346
347 template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c)
347 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator= (const complex<_Xp>& __c)
348348 {
349349 __re_ = __c.real();
350350 __im_ = __c.imag();
351351 return *this;
352352 }
353 template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c)
353 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(const complex<_Xp>& __c)
354354 {
355355 __re_ += __c.real();
356356 __im_ += __c.imag();
357357 return *this;
358358 }
359 template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c)
359 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(const complex<_Xp>& __c)
360360 {
361361 __re_ -= __c.real();
362362 __im_ -= __c.imag();
363363 return *this;
364364 }
365 template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c)
365 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(const complex<_Xp>& __c)
366366 {
367367 *this = *this * complex(__c.real(), __c.imag());
368368 return *this;
369369 }
370 template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c)
370 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(const complex<_Xp>& __c)
371371 {
372372 *this = *this / complex(__c.real(), __c.imag());
373373 return *this;
......@@ -392,40 +392,40 @@ public:
392392 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR double real() const {return __re_;}
393393 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR double imag() const {return __im_;}
394394
395 _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;}
396 _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}
395 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) {__re_ = __re;}
396 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) {__im_ = __im;}
397397
398 _LIBCPP_INLINE_VISIBILITY complex& operator= (double __re)
398 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator= (double __re)
399399 {__re_ = __re; __im_ = value_type(); return *this;}
400 _LIBCPP_INLINE_VISIBILITY complex& operator+=(double __re) {__re_ += __re; return *this;}
401 _LIBCPP_INLINE_VISIBILITY complex& operator-=(double __re) {__re_ -= __re; return *this;}
402 _LIBCPP_INLINE_VISIBILITY complex& operator*=(double __re) {__re_ *= __re; __im_ *= __re; return *this;}
403 _LIBCPP_INLINE_VISIBILITY complex& operator/=(double __re) {__re_ /= __re; __im_ /= __re; return *this;}
400 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(double __re) {__re_ += __re; return *this;}
401 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(double __re) {__re_ -= __re; return *this;}
402 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(double __re) {__re_ *= __re; __im_ *= __re; return *this;}
403 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(double __re) {__re_ /= __re; __im_ /= __re; return *this;}
404404
405 template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c)
405 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator= (const complex<_Xp>& __c)
406406 {
407407 __re_ = __c.real();
408408 __im_ = __c.imag();
409409 return *this;
410410 }
411 template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c)
411 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(const complex<_Xp>& __c)
412412 {
413413 __re_ += __c.real();
414414 __im_ += __c.imag();
415415 return *this;
416416 }
417 template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c)
417 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(const complex<_Xp>& __c)
418418 {
419419 __re_ -= __c.real();
420420 __im_ -= __c.imag();
421421 return *this;
422422 }
423 template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c)
423 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(const complex<_Xp>& __c)
424424 {
425425 *this = *this * complex(__c.real(), __c.imag());
426426 return *this;
427427 }
428 template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c)
428 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(const complex<_Xp>& __c)
429429 {
430430 *this = *this / complex(__c.real(), __c.imag());
431431 return *this;
......@@ -450,40 +450,40 @@ public:
450450 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR long double real() const {return __re_;}
451451 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR long double imag() const {return __im_;}
452452
453 _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;}
454 _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}
453 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) {__re_ = __re;}
454 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) {__im_ = __im;}
455455
456 _LIBCPP_INLINE_VISIBILITY complex& operator= (long double __re)
456 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator= (long double __re)
457457 {__re_ = __re; __im_ = value_type(); return *this;}
458 _LIBCPP_INLINE_VISIBILITY complex& operator+=(long double __re) {__re_ += __re; return *this;}
459 _LIBCPP_INLINE_VISIBILITY complex& operator-=(long double __re) {__re_ -= __re; return *this;}
460 _LIBCPP_INLINE_VISIBILITY complex& operator*=(long double __re) {__re_ *= __re; __im_ *= __re; return *this;}
461 _LIBCPP_INLINE_VISIBILITY complex& operator/=(long double __re) {__re_ /= __re; __im_ /= __re; return *this;}
458 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(long double __re) {__re_ += __re; return *this;}
459 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(long double __re) {__re_ -= __re; return *this;}
460 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(long double __re) {__re_ *= __re; __im_ *= __re; return *this;}
461 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(long double __re) {__re_ /= __re; __im_ /= __re; return *this;}
462462
463 template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c)
463 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator= (const complex<_Xp>& __c)
464464 {
465465 __re_ = __c.real();
466466 __im_ = __c.imag();
467467 return *this;
468468 }
469 template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c)
469 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(const complex<_Xp>& __c)
470470 {
471471 __re_ += __c.real();
472472 __im_ += __c.imag();
473473 return *this;
474474 }
475 template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c)
475 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator-=(const complex<_Xp>& __c)
476476 {
477477 __re_ -= __c.real();
478478 __im_ -= __c.imag();
479479 return *this;
480480 }
481 template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c)
481 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator*=(const complex<_Xp>& __c)
482482 {
483483 *this = *this * complex(__c.real(), __c.imag());
484484 return *this;
485485 }
486 template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c)
486 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator/=(const complex<_Xp>& __c)
487487 {
488488 *this = *this / complex(__c.real(), __c.imag());
489489 return *this;
......@@ -523,7 +523,7 @@ complex<long double>::complex(const complex<double>& __c)
523523// 26.3.6 operators:
524524
525525template<class _Tp>
526inline _LIBCPP_INLINE_VISIBILITY
526inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
527527complex<_Tp>
528528operator+(const complex<_Tp>& __x, const complex<_Tp>& __y)
529529{
......@@ -533,7 +533,7 @@ operator+(const complex<_Tp>& __x, const complex<_Tp>& __y)
533533}
534534
535535template<class _Tp>
536inline _LIBCPP_INLINE_VISIBILITY
536inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
537537complex<_Tp>
538538operator+(const complex<_Tp>& __x, const _Tp& __y)
539539{
......@@ -543,7 +543,7 @@ operator+(const complex<_Tp>& __x, const _Tp& __y)
543543}
544544
545545template<class _Tp>
546inline _LIBCPP_INLINE_VISIBILITY
546inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
547547complex<_Tp>
548548operator+(const _Tp& __x, const complex<_Tp>& __y)
549549{
......@@ -553,7 +553,7 @@ operator+(const _Tp& __x, const complex<_Tp>& __y)
553553}
554554
555555template<class _Tp>
556inline _LIBCPP_INLINE_VISIBILITY
556inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
557557complex<_Tp>
558558operator-(const complex<_Tp>& __x, const complex<_Tp>& __y)
559559{
......@@ -563,7 +563,7 @@ operator-(const complex<_Tp>& __x, const complex<_Tp>& __y)
563563}
564564
565565template<class _Tp>
566inline _LIBCPP_INLINE_VISIBILITY
566inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
567567complex<_Tp>
568568operator-(const complex<_Tp>& __x, const _Tp& __y)
569569{
......@@ -573,7 +573,7 @@ operator-(const complex<_Tp>& __x, const _Tp& __y)
573573}
574574
575575template<class _Tp>
576inline _LIBCPP_INLINE_VISIBILITY
576inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
577577complex<_Tp>
578578operator-(const _Tp& __x, const complex<_Tp>& __y)
579579{
......@@ -583,53 +583,86 @@ operator-(const _Tp& __x, const complex<_Tp>& __y)
583583}
584584
585585template<class _Tp>
586complex<_Tp>
586_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
587587operator*(const complex<_Tp>& __z, const complex<_Tp>& __w)
588588{
589589 _Tp __a = __z.real();
590590 _Tp __b = __z.imag();
591591 _Tp __c = __w.real();
592592 _Tp __d = __w.imag();
593
594 // Avoid floating point operations that are invalid during constant evaluation
595 if (__libcpp_is_constant_evaluated()) {
596 bool __z_zero = __a == _Tp(0) && __b == _Tp(0);
597 bool __w_zero = __c == _Tp(0) && __d == _Tp(0);
598 bool __z_inf = std::__constexpr_isinf(__a) || std::__constexpr_isinf(__b);
599 bool __w_inf = std::__constexpr_isinf(__c) || std::__constexpr_isinf(__d);
600 bool __z_nan = !__z_inf && (
601 (std::__constexpr_isnan(__a) && std::__constexpr_isnan(__b))
602 || (std::__constexpr_isnan(__a) && __b == _Tp(0))
603 || (__a == _Tp(0) && std::__constexpr_isnan(__b))
604 );
605 bool __w_nan = !__w_inf && (
606 (std::__constexpr_isnan(__c) && std::__constexpr_isnan(__d))
607 || (std::__constexpr_isnan(__c) && __d == _Tp(0))
608 || (__c == _Tp(0) && std::__constexpr_isnan(__d))
609 );
610 if (__z_nan || __w_nan) {
611 return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
612 }
613 if (__z_inf || __w_inf) {
614 if (__z_zero || __w_zero) {
615 return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
616 }
617 return complex<_Tp>(_Tp(numeric_limits<_Tp>::infinity()), _Tp(numeric_limits<_Tp>::infinity()));
618 }
619 bool __z_nonzero_nan = !__z_inf && !__z_nan && (std::__constexpr_isnan(__a) || std::__constexpr_isnan(__b));
620 bool __w_nonzero_nan = !__w_inf && !__w_nan && (std::__constexpr_isnan(__c) || std::__constexpr_isnan(__d));
621 if (__z_nonzero_nan || __w_nonzero_nan) {
622 return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
623 }
624 }
625
593626 _Tp __ac = __a * __c;
594627 _Tp __bd = __b * __d;
595628 _Tp __ad = __a * __d;
596629 _Tp __bc = __b * __c;
597630 _Tp __x = __ac - __bd;
598631 _Tp __y = __ad + __bc;
599 if (__libcpp_isnan_or_builtin(__x) && __libcpp_isnan_or_builtin(__y))
632 if (std::__constexpr_isnan(__x) && std::__constexpr_isnan(__y))
600633 {
601634 bool __recalc = false;
602 if (__libcpp_isinf_or_builtin(__a) || __libcpp_isinf_or_builtin(__b))
635 if (std::__constexpr_isinf(__a) || std::__constexpr_isinf(__b))
603636 {
604 __a = copysign(__libcpp_isinf_or_builtin(__a) ? _Tp(1) : _Tp(0), __a);
605 __b = copysign(__libcpp_isinf_or_builtin(__b) ? _Tp(1) : _Tp(0), __b);
606 if (__libcpp_isnan_or_builtin(__c))
607 __c = copysign(_Tp(0), __c);
608 if (__libcpp_isnan_or_builtin(__d))
609 __d = copysign(_Tp(0), __d);
637 __a = std::__constexpr_copysign(std::__constexpr_isinf(__a) ? _Tp(1) : _Tp(0), __a);
638 __b = std::__constexpr_copysign(std::__constexpr_isinf(__b) ? _Tp(1) : _Tp(0), __b);
639 if (std::__constexpr_isnan(__c))
640 __c = std::__constexpr_copysign(_Tp(0), __c);
641 if (std::__constexpr_isnan(__d))
642 __d = std::__constexpr_copysign(_Tp(0), __d);
610643 __recalc = true;
611644 }
612 if (__libcpp_isinf_or_builtin(__c) || __libcpp_isinf_or_builtin(__d))
645 if (std::__constexpr_isinf(__c) || std::__constexpr_isinf(__d))
613646 {
614 __c = copysign(__libcpp_isinf_or_builtin(__c) ? _Tp(1) : _Tp(0), __c);
615 __d = copysign(__libcpp_isinf_or_builtin(__d) ? _Tp(1) : _Tp(0), __d);
616 if (__libcpp_isnan_or_builtin(__a))
617 __a = copysign(_Tp(0), __a);
618 if (__libcpp_isnan_or_builtin(__b))
619 __b = copysign(_Tp(0), __b);
647 __c = std::__constexpr_copysign(std::__constexpr_isinf(__c) ? _Tp(1) : _Tp(0), __c);
648 __d = std::__constexpr_copysign(std::__constexpr_isinf(__d) ? _Tp(1) : _Tp(0), __d);
649 if (std::__constexpr_isnan(__a))
650 __a = std::__constexpr_copysign(_Tp(0), __a);
651 if (std::__constexpr_isnan(__b))
652 __b = std::__constexpr_copysign(_Tp(0), __b);
620653 __recalc = true;
621654 }
622 if (!__recalc && (__libcpp_isinf_or_builtin(__ac) || __libcpp_isinf_or_builtin(__bd) ||
623 __libcpp_isinf_or_builtin(__ad) || __libcpp_isinf_or_builtin(__bc)))
655 if (!__recalc && (std::__constexpr_isinf(__ac) || std::__constexpr_isinf(__bd) ||
656 std::__constexpr_isinf(__ad) || std::__constexpr_isinf(__bc)))
624657 {
625 if (__libcpp_isnan_or_builtin(__a))
626 __a = copysign(_Tp(0), __a);
627 if (__libcpp_isnan_or_builtin(__b))
628 __b = copysign(_Tp(0), __b);
629 if (__libcpp_isnan_or_builtin(__c))
630 __c = copysign(_Tp(0), __c);
631 if (__libcpp_isnan_or_builtin(__d))
632 __d = copysign(_Tp(0), __d);
658 if (std::__constexpr_isnan(__a))
659 __a = std::__constexpr_copysign(_Tp(0), __a);
660 if (std::__constexpr_isnan(__b))
661 __b = std::__constexpr_copysign(_Tp(0), __b);
662 if (std::__constexpr_isnan(__c))
663 __c = std::__constexpr_copysign(_Tp(0), __c);
664 if (std::__constexpr_isnan(__d))
665 __d = std::__constexpr_copysign(_Tp(0), __d);
633666 __recalc = true;
634667 }
635668 if (__recalc)
......@@ -642,7 +675,7 @@ operator*(const complex<_Tp>& __z, const complex<_Tp>& __w)
642675}
643676
644677template<class _Tp>
645inline _LIBCPP_INLINE_VISIBILITY
678inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
646679complex<_Tp>
647680operator*(const complex<_Tp>& __x, const _Tp& __y)
648681{
......@@ -652,7 +685,7 @@ operator*(const complex<_Tp>& __x, const _Tp& __y)
652685}
653686
654687template<class _Tp>
655inline _LIBCPP_INLINE_VISIBILITY
688inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
656689complex<_Tp>
657690operator*(const _Tp& __x, const complex<_Tp>& __y)
658691{
......@@ -662,7 +695,7 @@ operator*(const _Tp& __x, const complex<_Tp>& __y)
662695}
663696
664697template<class _Tp>
665complex<_Tp>
698_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
666699operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
667700{
668701 int __ilogbw = 0;
......@@ -670,34 +703,74 @@ operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
670703 _Tp __b = __z.imag();
671704 _Tp __c = __w.real();
672705 _Tp __d = __w.imag();
673 _Tp __logbw = logb(fmax(fabs(__c), fabs(__d)));
674 if (__libcpp_isfinite_or_builtin(__logbw))
706 _Tp __logbw = std::__constexpr_logb(std::__constexpr_fmax(std::__constexpr_fabs(__c), std::__constexpr_fabs(__d)));
707 if (std::__constexpr_isfinite(__logbw))
675708 {
676709 __ilogbw = static_cast<int>(__logbw);
677 __c = scalbn(__c, -__ilogbw);
678 __d = scalbn(__d, -__ilogbw);
710 __c = std::__constexpr_scalbn(__c, -__ilogbw);
711 __d = std::__constexpr_scalbn(__d, -__ilogbw);
712 }
713
714 // Avoid floating point operations that are invalid during constant evaluation
715 if (__libcpp_is_constant_evaluated()) {
716 bool __z_zero = __a == _Tp(0) && __b == _Tp(0);
717 bool __w_zero = __c == _Tp(0) && __d == _Tp(0);
718 bool __z_inf = std::__constexpr_isinf(__a) || std::__constexpr_isinf(__b);
719 bool __w_inf = std::__constexpr_isinf(__c) || std::__constexpr_isinf(__d);
720 bool __z_nan = !__z_inf && (
721 (std::__constexpr_isnan(__a) && std::__constexpr_isnan(__b))
722 || (std::__constexpr_isnan(__a) && __b == _Tp(0))
723 || (__a == _Tp(0) && std::__constexpr_isnan(__b))
724 );
725 bool __w_nan = !__w_inf && (
726 (std::__constexpr_isnan(__c) && std::__constexpr_isnan(__d))
727 || (std::__constexpr_isnan(__c) && __d == _Tp(0))
728 || (__c == _Tp(0) && std::__constexpr_isnan(__d))
729 );
730 if ((__z_nan || __w_nan) || (__z_inf && __w_inf)) {
731 return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
732 }
733 bool __z_nonzero_nan = !__z_inf && !__z_nan && (std::__constexpr_isnan(__a) || std::__constexpr_isnan(__b));
734 bool __w_nonzero_nan = !__w_inf && !__w_nan && (std::__constexpr_isnan(__c) || std::__constexpr_isnan(__d));
735 if (__z_nonzero_nan || __w_nonzero_nan) {
736 if (__w_zero) {
737 return complex<_Tp>(_Tp(numeric_limits<_Tp>::infinity()), _Tp(numeric_limits<_Tp>::infinity()));
738 }
739 return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
740 }
741 if (__w_inf) {
742 return complex<_Tp>(_Tp(0), _Tp(0));
743 }
744 if (__z_inf) {
745 return complex<_Tp>(_Tp(numeric_limits<_Tp>::infinity()), _Tp(numeric_limits<_Tp>::infinity()));
746 }
747 if (__w_zero) {
748 if (__z_zero) {
749 return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
750 }
751 return complex<_Tp>(_Tp(numeric_limits<_Tp>::infinity()), _Tp(numeric_limits<_Tp>::infinity()));
752 }
679753 }
754
680755 _Tp __denom = __c * __c + __d * __d;
681 _Tp __x = scalbn((__a * __c + __b * __d) / __denom, -__ilogbw);
682 _Tp __y = scalbn((__b * __c - __a * __d) / __denom, -__ilogbw);
683 if (__libcpp_isnan_or_builtin(__x) && __libcpp_isnan_or_builtin(__y))
756 _Tp __x = std::__constexpr_scalbn((__a * __c + __b * __d) / __denom, -__ilogbw);
757 _Tp __y = std::__constexpr_scalbn((__b * __c - __a * __d) / __denom, -__ilogbw);
758 if (std::__constexpr_isnan(__x) && std::__constexpr_isnan(__y))
684759 {
685 if ((__denom == _Tp(0)) && (!__libcpp_isnan_or_builtin(__a) || !__libcpp_isnan_or_builtin(__b)))
760 if ((__denom == _Tp(0)) && (!std::__constexpr_isnan(__a) || !std::__constexpr_isnan(__b)))
686761 {
687 __x = copysign(_Tp(INFINITY), __c) * __a;
688 __y = copysign(_Tp(INFINITY), __c) * __b;
689 }
690 else if ((__libcpp_isinf_or_builtin(__a) || __libcpp_isinf_or_builtin(__b)) && __libcpp_isfinite_or_builtin(__c) && __libcpp_isfinite_or_builtin(__d))
691 {
692 __a = copysign(__libcpp_isinf_or_builtin(__a) ? _Tp(1) : _Tp(0), __a);
693 __b = copysign(__libcpp_isinf_or_builtin(__b) ? _Tp(1) : _Tp(0), __b);
762 __x = std::__constexpr_copysign(_Tp(INFINITY), __c) * __a;
763 __y = std::__constexpr_copysign(_Tp(INFINITY), __c) * __b;
764 } else if ((std::__constexpr_isinf(__a) || std::__constexpr_isinf(__b)) && std::__constexpr_isfinite(__c) &&
765 std::__constexpr_isfinite(__d)) {
766 __a = std::__constexpr_copysign(std::__constexpr_isinf(__a) ? _Tp(1) : _Tp(0), __a);
767 __b = std::__constexpr_copysign(std::__constexpr_isinf(__b) ? _Tp(1) : _Tp(0), __b);
694768 __x = _Tp(INFINITY) * (__a * __c + __b * __d);
695769 __y = _Tp(INFINITY) * (__b * __c - __a * __d);
696 }
697 else if (__libcpp_isinf_or_builtin(__logbw) && __logbw > _Tp(0) && __libcpp_isfinite_or_builtin(__a) && __libcpp_isfinite_or_builtin(__b))
698 {
699 __c = copysign(__libcpp_isinf_or_builtin(__c) ? _Tp(1) : _Tp(0), __c);
700 __d = copysign(__libcpp_isinf_or_builtin(__d) ? _Tp(1) : _Tp(0), __d);
770 } else if (std::__constexpr_isinf(__logbw) && __logbw > _Tp(0) && std::__constexpr_isfinite(__a) &&
771 std::__constexpr_isfinite(__b)) {
772 __c = std::__constexpr_copysign(std::__constexpr_isinf(__c) ? _Tp(1) : _Tp(0), __c);
773 __d = std::__constexpr_copysign(std::__constexpr_isinf(__d) ? _Tp(1) : _Tp(0), __d);
701774 __x = _Tp(0) * (__a * __c + __b * __d);
702775 __y = _Tp(0) * (__b * __c - __a * __d);
703776 }
......@@ -706,7 +779,7 @@ operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
706779}
707780
708781template<class _Tp>
709inline _LIBCPP_INLINE_VISIBILITY
782inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
710783complex<_Tp>
711784operator/(const complex<_Tp>& __x, const _Tp& __y)
712785{
......@@ -714,7 +787,7 @@ operator/(const complex<_Tp>& __x, const _Tp& __y)
714787}
715788
716789template<class _Tp>
717inline _LIBCPP_INLINE_VISIBILITY
790inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
718791complex<_Tp>
719792operator/(const _Tp& __x, const complex<_Tp>& __y)
720793{
......@@ -724,7 +797,7 @@ operator/(const _Tp& __x, const complex<_Tp>& __y)
724797}
725798
726799template<class _Tp>
727inline _LIBCPP_INLINE_VISIBILITY
800inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
728801complex<_Tp>
729802operator+(const complex<_Tp>& __x)
730803{
......@@ -732,7 +805,7 @@ operator+(const complex<_Tp>& __x)
732805}
733806
734807template<class _Tp>
735inline _LIBCPP_INLINE_VISIBILITY
808inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
736809complex<_Tp>
737810operator-(const complex<_Tp>& __x)
738811{
......@@ -740,7 +813,7 @@ operator-(const complex<_Tp>& __x)
740813}
741814
742815template<class _Tp>
743inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
816inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
744817bool
745818operator==(const complex<_Tp>& __x, const complex<_Tp>& __y)
746819{
......@@ -748,7 +821,7 @@ operator==(const complex<_Tp>& __x, const complex<_Tp>& __y)
748821}
749822
750823template<class _Tp>
751inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
824inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
752825bool
753826operator==(const complex<_Tp>& __x, const _Tp& __y)
754827{
......@@ -756,7 +829,7 @@ operator==(const complex<_Tp>& __x, const _Tp& __y)
756829}
757830
758831template<class _Tp>
759inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
832inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
760833bool
761834operator==(const _Tp& __x, const complex<_Tp>& __y)
762835{
......@@ -764,7 +837,7 @@ operator==(const _Tp& __x, const complex<_Tp>& __y)
764837}
765838
766839template<class _Tp>
767inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
840inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
768841bool
769842operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y)
770843{
......@@ -772,7 +845,7 @@ operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y)
772845}
773846
774847template<class _Tp>
775inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
848inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
776849bool
777850operator!=(const complex<_Tp>& __x, const _Tp& __y)
778851{
......@@ -780,7 +853,7 @@ operator!=(const complex<_Tp>& __x, const _Tp& __y)
780853}
781854
782855template<class _Tp>
783inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
856inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
784857bool
785858operator!=(const _Tp& __x, const complex<_Tp>& __y)
786859{
......@@ -813,7 +886,7 @@ struct __libcpp_complex_overload_traits<_Tp, false, true>
813886// real
814887
815888template<class _Tp>
816inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
889inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
817890_Tp
818891real(const complex<_Tp>& __c)
819892{
......@@ -821,7 +894,7 @@ real(const complex<_Tp>& __c)
821894}
822895
823896template <class _Tp>
824inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
897inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
825898typename __libcpp_complex_overload_traits<_Tp>::_ValueType
826899real(_Tp __re)
827900{
......@@ -831,7 +904,7 @@ real(_Tp __re)
831904// imag
832905
833906template<class _Tp>
834inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
907inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
835908_Tp
836909imag(const complex<_Tp>& __c)
837910{
......@@ -839,7 +912,7 @@ imag(const complex<_Tp>& __c)
839912}
840913
841914template <class _Tp>
842inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
915inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
843916typename __libcpp_complex_overload_traits<_Tp>::_ValueType
844917imag(_Tp)
845918{
......@@ -853,7 +926,7 @@ inline _LIBCPP_INLINE_VISIBILITY
853926_Tp
854927abs(const complex<_Tp>& __c)
855928{
856 return hypot(__c.real(), __c.imag());
929 return std::hypot(__c.real(), __c.imag());
857930}
858931
859932// arg
......@@ -863,7 +936,7 @@ inline _LIBCPP_INLINE_VISIBILITY
863936_Tp
864937arg(const complex<_Tp>& __c)
865938{
866 return atan2(__c.imag(), __c.real());
939 return std::atan2(__c.imag(), __c.real());
867940}
868941
869942template <class _Tp>
......@@ -874,7 +947,7 @@ typename enable_if<
874947>::type
875948arg(_Tp __re)
876949{
877 return atan2l(0.L, __re);
950 return std::atan2l(0.L, __re);
878951}
879952
880953template<class _Tp>
......@@ -886,7 +959,7 @@ typename enable_if
886959>::type
887960arg(_Tp __re)
888961{
889 return atan2(0., __re);
962 return std::atan2(0., __re);
890963}
891964
892965template <class _Tp>
......@@ -897,25 +970,25 @@ typename enable_if<
897970>::type
898971arg(_Tp __re)
899972{
900 return atan2f(0.F, __re);
973 return std::atan2f(0.F, __re);
901974}
902975
903976// norm
904977
905978template<class _Tp>
906inline _LIBCPP_INLINE_VISIBILITY
979inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
907980_Tp
908981norm(const complex<_Tp>& __c)
909982{
910 if (__libcpp_isinf_or_builtin(__c.real()))
911 return abs(__c.real());
912 if (__libcpp_isinf_or_builtin(__c.imag()))
913 return abs(__c.imag());
983 if (std::__constexpr_isinf(__c.real()))
984 return std::abs(__c.real());
985 if (std::__constexpr_isinf(__c.imag()))
986 return std::abs(__c.imag());
914987 return __c.real() * __c.real() + __c.imag() * __c.imag();
915988}
916989
917990template <class _Tp>
918inline _LIBCPP_INLINE_VISIBILITY
991inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
919992typename __libcpp_complex_overload_traits<_Tp>::_ValueType
920993norm(_Tp __re)
921994{
......@@ -926,7 +999,7 @@ norm(_Tp __re)
926999// conj
9271000
9281001template<class _Tp>
929inline _LIBCPP_INLINE_VISIBILITY
1002inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
9301003complex<_Tp>
9311004conj(const complex<_Tp>& __c)
9321005{
......@@ -934,7 +1007,7 @@ conj(const complex<_Tp>& __c)
9341007}
9351008
9361009template <class _Tp>
937inline _LIBCPP_INLINE_VISIBILITY
1010inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
9381011typename __libcpp_complex_overload_traits<_Tp>::_ComplexType
9391012conj(_Tp __re)
9401013{
......@@ -952,8 +1025,8 @@ complex<_Tp>
9521025proj(const complex<_Tp>& __c)
9531026{
9541027 complex<_Tp> __r = __c;
955 if (__libcpp_isinf_or_builtin(__c.real()) || __libcpp_isinf_or_builtin(__c.imag()))
956 __r = complex<_Tp>(INFINITY, copysign(_Tp(0), __c.imag()));
1028 if (std::__constexpr_isinf(__c.real()) || std::__constexpr_isinf(__c.imag()))
1029 __r = complex<_Tp>(INFINITY, std::copysign(_Tp(0), __c.imag()));
9571030 return __r;
9581031}
9591032
......@@ -966,8 +1039,8 @@ typename enable_if
9661039>::type
9671040proj(_Tp __re)
9681041{
969 if (__libcpp_isinf_or_builtin(__re))
970 __re = abs(__re);
1042 if (std::__constexpr_isinf(__re))
1043 __re = std::abs(__re);
9711044 return complex<_Tp>(__re);
9721045}
9731046
......@@ -987,28 +1060,28 @@ proj(_Tp __re)
9871060// polar
9881061
9891062template<class _Tp>
990complex<_Tp>
1063_LIBCPP_HIDE_FROM_ABI complex<_Tp>
9911064polar(const _Tp& __rho, const _Tp& __theta = _Tp())
9921065{
993 if (__libcpp_isnan_or_builtin(__rho) || signbit(__rho))
1066 if (std::__constexpr_isnan(__rho) || std::signbit(__rho))
9941067 return complex<_Tp>(_Tp(NAN), _Tp(NAN));
995 if (__libcpp_isnan_or_builtin(__theta))
1068 if (std::__constexpr_isnan(__theta))
9961069 {
997 if (__libcpp_isinf_or_builtin(__rho))
1070 if (std::__constexpr_isinf(__rho))
9981071 return complex<_Tp>(__rho, __theta);
9991072 return complex<_Tp>(__theta, __theta);
10001073 }
1001 if (__libcpp_isinf_or_builtin(__theta))
1074 if (std::__constexpr_isinf(__theta))
10021075 {
1003 if (__libcpp_isinf_or_builtin(__rho))
1076 if (std::__constexpr_isinf(__rho))
10041077 return complex<_Tp>(__rho, _Tp(NAN));
10051078 return complex<_Tp>(_Tp(NAN), _Tp(NAN));
10061079 }
1007 _Tp __x = __rho * cos(__theta);
1008 if (__libcpp_isnan_or_builtin(__x))
1080 _Tp __x = __rho * std::cos(__theta);
1081 if (std::__constexpr_isnan(__x))
10091082 __x = 0;
1010 _Tp __y = __rho * sin(__theta);
1011 if (__libcpp_isnan_or_builtin(__y))
1083 _Tp __y = __rho * std::sin(__theta);
1084 if (std::__constexpr_isnan(__y))
10121085 __y = 0;
10131086 return complex<_Tp>(__x, __y);
10141087}
......@@ -1020,7 +1093,7 @@ inline _LIBCPP_INLINE_VISIBILITY
10201093complex<_Tp>
10211094log(const complex<_Tp>& __x)
10221095{
1023 return complex<_Tp>(log(abs(__x)), arg(__x));
1096 return complex<_Tp>(std::log(std::abs(__x)), std::arg(__x));
10241097}
10251098
10261099// log10
......@@ -1030,52 +1103,52 @@ inline _LIBCPP_INLINE_VISIBILITY
10301103complex<_Tp>
10311104log10(const complex<_Tp>& __x)
10321105{
1033 return log(__x) / log(_Tp(10));
1106 return std::log(__x) / std::log(_Tp(10));
10341107}
10351108
10361109// sqrt
10371110
10381111template<class _Tp>
1039complex<_Tp>
1112_LIBCPP_HIDE_FROM_ABI complex<_Tp>
10401113sqrt(const complex<_Tp>& __x)
10411114{
1042 if (__libcpp_isinf_or_builtin(__x.imag()))
1115 if (std::__constexpr_isinf(__x.imag()))
10431116 return complex<_Tp>(_Tp(INFINITY), __x.imag());
1044 if (__libcpp_isinf_or_builtin(__x.real()))
1117 if (std::__constexpr_isinf(__x.real()))
10451118 {
10461119 if (__x.real() > _Tp(0))
1047 return complex<_Tp>(__x.real(), __libcpp_isnan_or_builtin(__x.imag()) ? __x.imag() : copysign(_Tp(0), __x.imag()));
1048 return complex<_Tp>(__libcpp_isnan_or_builtin(__x.imag()) ? __x.imag() : _Tp(0), copysign(__x.real(), __x.imag()));
1120 return complex<_Tp>(__x.real(), std::__constexpr_isnan(__x.imag()) ? __x.imag() : std::copysign(_Tp(0), __x.imag()));
1121 return complex<_Tp>(std::__constexpr_isnan(__x.imag()) ? __x.imag() : _Tp(0), std::copysign(__x.real(), __x.imag()));
10491122 }
1050 return polar(sqrt(abs(__x)), arg(__x) / _Tp(2));
1123 return std::polar(std::sqrt(std::abs(__x)), std::arg(__x) / _Tp(2));
10511124}
10521125
10531126// exp
10541127
10551128template<class _Tp>
1056complex<_Tp>
1129_LIBCPP_HIDE_FROM_ABI complex<_Tp>
10571130exp(const complex<_Tp>& __x)
10581131{
10591132 _Tp __i = __x.imag();
10601133 if (__i == 0) {
1061 return complex<_Tp>(exp(__x.real()), copysign(_Tp(0), __x.imag()));
1134 return complex<_Tp>(std::exp(__x.real()), std::copysign(_Tp(0), __x.imag()));
10621135 }
1063 if (__libcpp_isinf_or_builtin(__x.real()))
1136 if (std::__constexpr_isinf(__x.real()))
10641137 {
10651138 if (__x.real() < _Tp(0))
10661139 {
1067 if (!__libcpp_isfinite_or_builtin(__i))
1140 if (!std::__constexpr_isfinite(__i))
10681141 __i = _Tp(1);
10691142 }
1070 else if (__i == 0 || !__libcpp_isfinite_or_builtin(__i))
1143 else if (__i == 0 || !std::__constexpr_isfinite(__i))
10711144 {
1072 if (__libcpp_isinf_or_builtin(__i))
1145 if (std::__constexpr_isinf(__i))
10731146 __i = _Tp(NAN);
10741147 return complex<_Tp>(__x.real(), __i);
10751148 }
10761149 }
1077 _Tp __e = exp(__x.real());
1078 return complex<_Tp>(__e * cos(__i), __e * sin(__i));
1150 _Tp __e = std::exp(__x.real());
1151 return complex<_Tp>(__e * std::cos(__i), __e * std::sin(__i));
10791152}
10801153
10811154// pow
......@@ -1085,7 +1158,7 @@ inline _LIBCPP_INLINE_VISIBILITY
10851158complex<_Tp>
10861159pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
10871160{
1088 return exp(__y * log(__x));
1161 return std::exp(__y * std::log(__x));
10891162}
10901163
10911164template<class _Tp, class _Up>
......@@ -1137,219 +1210,219 @@ __sqr(const complex<_Tp>& __x)
11371210// asinh
11381211
11391212template<class _Tp>
1140complex<_Tp>
1213_LIBCPP_HIDE_FROM_ABI complex<_Tp>
11411214asinh(const complex<_Tp>& __x)
11421215{
11431216 const _Tp __pi(atan2(+0., -0.));
1144 if (__libcpp_isinf_or_builtin(__x.real()))
1217 if (std::__constexpr_isinf(__x.real()))
11451218 {
1146 if (__libcpp_isnan_or_builtin(__x.imag()))
1219 if (std::__constexpr_isnan(__x.imag()))
11471220 return __x;
1148 if (__libcpp_isinf_or_builtin(__x.imag()))
1149 return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag()));
1150 return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag()));
1221 if (std::__constexpr_isinf(__x.imag()))
1222 return complex<_Tp>(__x.real(), std::copysign(__pi * _Tp(0.25), __x.imag()));
1223 return complex<_Tp>(__x.real(), std::copysign(_Tp(0), __x.imag()));
11511224 }
1152 if (__libcpp_isnan_or_builtin(__x.real()))
1225 if (std::__constexpr_isnan(__x.real()))
11531226 {
1154 if (__libcpp_isinf_or_builtin(__x.imag()))
1227 if (std::__constexpr_isinf(__x.imag()))
11551228 return complex<_Tp>(__x.imag(), __x.real());
11561229 if (__x.imag() == 0)
11571230 return __x;
11581231 return complex<_Tp>(__x.real(), __x.real());
11591232 }
1160 if (__libcpp_isinf_or_builtin(__x.imag()))
1161 return complex<_Tp>(copysign(__x.imag(), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
1162 complex<_Tp> __z = log(__x + sqrt(__sqr(__x) + _Tp(1)));
1163 return complex<_Tp>(copysign(__z.real(), __x.real()), copysign(__z.imag(), __x.imag()));
1233 if (std::__constexpr_isinf(__x.imag()))
1234 return complex<_Tp>(std::copysign(__x.imag(), __x.real()), std::copysign(__pi/_Tp(2), __x.imag()));
1235 complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) + _Tp(1)));
1236 return complex<_Tp>(std::copysign(__z.real(), __x.real()), std::copysign(__z.imag(), __x.imag()));
11641237}
11651238
11661239// acosh
11671240
11681241template<class _Tp>
1169complex<_Tp>
1242_LIBCPP_HIDE_FROM_ABI complex<_Tp>
11701243acosh(const complex<_Tp>& __x)
11711244{
11721245 const _Tp __pi(atan2(+0., -0.));
1173 if (__libcpp_isinf_or_builtin(__x.real()))
1246 if (std::__constexpr_isinf(__x.real()))
11741247 {
1175 if (__libcpp_isnan_or_builtin(__x.imag()))
1176 return complex<_Tp>(abs(__x.real()), __x.imag());
1177 if (__libcpp_isinf_or_builtin(__x.imag()))
1248 if (std::__constexpr_isnan(__x.imag()))
1249 return complex<_Tp>(std::abs(__x.real()), __x.imag());
1250 if (std::__constexpr_isinf(__x.imag()))
11781251 {
11791252 if (__x.real() > 0)
1180 return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag()));
1253 return complex<_Tp>(__x.real(), std::copysign(__pi * _Tp(0.25), __x.imag()));
11811254 else
1182 return complex<_Tp>(-__x.real(), copysign(__pi * _Tp(0.75), __x.imag()));
1255 return complex<_Tp>(-__x.real(), std::copysign(__pi * _Tp(0.75), __x.imag()));
11831256 }
11841257 if (__x.real() < 0)
1185 return complex<_Tp>(-__x.real(), copysign(__pi, __x.imag()));
1186 return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag()));
1258 return complex<_Tp>(-__x.real(), std::copysign(__pi, __x.imag()));
1259 return complex<_Tp>(__x.real(), std::copysign(_Tp(0), __x.imag()));
11871260 }
1188 if (__libcpp_isnan_or_builtin(__x.real()))
1261 if (std::__constexpr_isnan(__x.real()))
11891262 {
1190 if (__libcpp_isinf_or_builtin(__x.imag()))
1191 return complex<_Tp>(abs(__x.imag()), __x.real());
1263 if (std::__constexpr_isinf(__x.imag()))
1264 return complex<_Tp>(std::abs(__x.imag()), __x.real());
11921265 return complex<_Tp>(__x.real(), __x.real());
11931266 }
1194 if (__libcpp_isinf_or_builtin(__x.imag()))
1195 return complex<_Tp>(abs(__x.imag()), copysign(__pi/_Tp(2), __x.imag()));
1196 complex<_Tp> __z = log(__x + sqrt(__sqr(__x) - _Tp(1)));
1197 return complex<_Tp>(copysign(__z.real(), _Tp(0)), copysign(__z.imag(), __x.imag()));
1267 if (std::__constexpr_isinf(__x.imag()))
1268 return complex<_Tp>(std::abs(__x.imag()), std::copysign(__pi/_Tp(2), __x.imag()));
1269 complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) - _Tp(1)));
1270 return complex<_Tp>(std::copysign(__z.real(), _Tp(0)), std::copysign(__z.imag(), __x.imag()));
11981271}
11991272
12001273// atanh
12011274
12021275template<class _Tp>
1203complex<_Tp>
1276_LIBCPP_HIDE_FROM_ABI complex<_Tp>
12041277atanh(const complex<_Tp>& __x)
12051278{
12061279 const _Tp __pi(atan2(+0., -0.));
1207 if (__libcpp_isinf_or_builtin(__x.imag()))
1280 if (std::__constexpr_isinf(__x.imag()))
12081281 {
1209 return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
1282 return complex<_Tp>(std::copysign(_Tp(0), __x.real()), std::copysign(__pi/_Tp(2), __x.imag()));
12101283 }
1211 if (__libcpp_isnan_or_builtin(__x.imag()))
1284 if (std::__constexpr_isnan(__x.imag()))
12121285 {
1213 if (__libcpp_isinf_or_builtin(__x.real()) || __x.real() == 0)
1214 return complex<_Tp>(copysign(_Tp(0), __x.real()), __x.imag());
1286 if (std::__constexpr_isinf(__x.real()) || __x.real() == 0)
1287 return complex<_Tp>(std::copysign(_Tp(0), __x.real()), __x.imag());
12151288 return complex<_Tp>(__x.imag(), __x.imag());
12161289 }
1217 if (__libcpp_isnan_or_builtin(__x.real()))
1290 if (std::__constexpr_isnan(__x.real()))
12181291 {
12191292 return complex<_Tp>(__x.real(), __x.real());
12201293 }
1221 if (__libcpp_isinf_or_builtin(__x.real()))
1294 if (std::__constexpr_isinf(__x.real()))
12221295 {
1223 return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
1296 return complex<_Tp>(std::copysign(_Tp(0), __x.real()), std::copysign(__pi/_Tp(2), __x.imag()));
12241297 }
1225 if (abs(__x.real()) == _Tp(1) && __x.imag() == _Tp(0))
1298 if (std::abs(__x.real()) == _Tp(1) && __x.imag() == _Tp(0))
12261299 {
1227 return complex<_Tp>(copysign(_Tp(INFINITY), __x.real()), copysign(_Tp(0), __x.imag()));
1300 return complex<_Tp>(std::copysign(_Tp(INFINITY), __x.real()), std::copysign(_Tp(0), __x.imag()));
12281301 }
1229 complex<_Tp> __z = log((_Tp(1) + __x) / (_Tp(1) - __x)) / _Tp(2);
1230 return complex<_Tp>(copysign(__z.real(), __x.real()), copysign(__z.imag(), __x.imag()));
1302 complex<_Tp> __z = std::log((_Tp(1) + __x) / (_Tp(1) - __x)) / _Tp(2);
1303 return complex<_Tp>(std::copysign(__z.real(), __x.real()), std::copysign(__z.imag(), __x.imag()));
12311304}
12321305
12331306// sinh
12341307
12351308template<class _Tp>
1236complex<_Tp>
1309_LIBCPP_HIDE_FROM_ABI complex<_Tp>
12371310sinh(const complex<_Tp>& __x)
12381311{
1239 if (__libcpp_isinf_or_builtin(__x.real()) && !__libcpp_isfinite_or_builtin(__x.imag()))
1312 if (std::__constexpr_isinf(__x.real()) && !std::__constexpr_isfinite(__x.imag()))
12401313 return complex<_Tp>(__x.real(), _Tp(NAN));
1241 if (__x.real() == 0 && !__libcpp_isfinite_or_builtin(__x.imag()))
1314 if (__x.real() == 0 && !std::__constexpr_isfinite(__x.imag()))
12421315 return complex<_Tp>(__x.real(), _Tp(NAN));
1243 if (__x.imag() == 0 && !__libcpp_isfinite_or_builtin(__x.real()))
1316 if (__x.imag() == 0 && !std::__constexpr_isfinite(__x.real()))
12441317 return __x;
1245 return complex<_Tp>(sinh(__x.real()) * cos(__x.imag()), cosh(__x.real()) * sin(__x.imag()));
1318 return complex<_Tp>(std::sinh(__x.real()) * std::cos(__x.imag()), std::cosh(__x.real()) * std::sin(__x.imag()));
12461319}
12471320
12481321// cosh
12491322
12501323template<class _Tp>
1251complex<_Tp>
1324_LIBCPP_HIDE_FROM_ABI complex<_Tp>
12521325cosh(const complex<_Tp>& __x)
12531326{
1254 if (__libcpp_isinf_or_builtin(__x.real()) && !__libcpp_isfinite_or_builtin(__x.imag()))
1255 return complex<_Tp>(abs(__x.real()), _Tp(NAN));
1256 if (__x.real() == 0 && !__libcpp_isfinite_or_builtin(__x.imag()))
1327 if (std::__constexpr_isinf(__x.real()) && !std::__constexpr_isfinite(__x.imag()))
1328 return complex<_Tp>(std::abs(__x.real()), _Tp(NAN));
1329 if (__x.real() == 0 && !std::__constexpr_isfinite(__x.imag()))
12571330 return complex<_Tp>(_Tp(NAN), __x.real());
12581331 if (__x.real() == 0 && __x.imag() == 0)
12591332 return complex<_Tp>(_Tp(1), __x.imag());
1260 if (__x.imag() == 0 && !__libcpp_isfinite_or_builtin(__x.real()))
1261 return complex<_Tp>(abs(__x.real()), __x.imag());
1262 return complex<_Tp>(cosh(__x.real()) * cos(__x.imag()), sinh(__x.real()) * sin(__x.imag()));
1333 if (__x.imag() == 0 && !std::__constexpr_isfinite(__x.real()))
1334 return complex<_Tp>(std::abs(__x.real()), __x.imag());
1335 return complex<_Tp>(std::cosh(__x.real()) * std::cos(__x.imag()), std::sinh(__x.real()) * std::sin(__x.imag()));
12631336}
12641337
12651338// tanh
12661339
12671340template<class _Tp>
1268complex<_Tp>
1341_LIBCPP_HIDE_FROM_ABI complex<_Tp>
12691342tanh(const complex<_Tp>& __x)
12701343{
1271 if (__libcpp_isinf_or_builtin(__x.real()))
1344 if (std::__constexpr_isinf(__x.real()))
12721345 {
1273 if (!__libcpp_isfinite_or_builtin(__x.imag()))
1274 return complex<_Tp>(copysign(_Tp(1), __x.real()), _Tp(0));
1275 return complex<_Tp>(copysign(_Tp(1), __x.real()), copysign(_Tp(0), sin(_Tp(2) * __x.imag())));
1346 if (!std::__constexpr_isfinite(__x.imag()))
1347 return complex<_Tp>(std::copysign(_Tp(1), __x.real()), _Tp(0));
1348 return complex<_Tp>(std::copysign(_Tp(1), __x.real()), std::copysign(_Tp(0), std::sin(_Tp(2) * __x.imag())));
12761349 }
1277 if (__libcpp_isnan_or_builtin(__x.real()) && __x.imag() == 0)
1350 if (std::__constexpr_isnan(__x.real()) && __x.imag() == 0)
12781351 return __x;
12791352 _Tp __2r(_Tp(2) * __x.real());
12801353 _Tp __2i(_Tp(2) * __x.imag());
1281 _Tp __d(cosh(__2r) + cos(__2i));
1282 _Tp __2rsh(sinh(__2r));
1283 if (__libcpp_isinf_or_builtin(__2rsh) && __libcpp_isinf_or_builtin(__d))
1354 _Tp __d(std::cosh(__2r) + std::cos(__2i));
1355 _Tp __2rsh(std::sinh(__2r));
1356 if (std::__constexpr_isinf(__2rsh) && std::__constexpr_isinf(__d))
12841357 return complex<_Tp>(__2rsh > _Tp(0) ? _Tp(1) : _Tp(-1),
12851358 __2i > _Tp(0) ? _Tp(0) : _Tp(-0.));
1286 return complex<_Tp>(__2rsh/__d, sin(__2i)/__d);
1359 return complex<_Tp>(__2rsh/__d, std::sin(__2i)/__d);
12871360}
12881361
12891362// asin
12901363
12911364template<class _Tp>
1292complex<_Tp>
1365_LIBCPP_HIDE_FROM_ABI complex<_Tp>
12931366asin(const complex<_Tp>& __x)
12941367{
1295 complex<_Tp> __z = asinh(complex<_Tp>(-__x.imag(), __x.real()));
1368 complex<_Tp> __z = std::asinh(complex<_Tp>(-__x.imag(), __x.real()));
12961369 return complex<_Tp>(__z.imag(), -__z.real());
12971370}
12981371
12991372// acos
13001373
13011374template<class _Tp>
1302complex<_Tp>
1375_LIBCPP_HIDE_FROM_ABI complex<_Tp>
13031376acos(const complex<_Tp>& __x)
13041377{
13051378 const _Tp __pi(atan2(+0., -0.));
1306 if (__libcpp_isinf_or_builtin(__x.real()))
1379 if (std::__constexpr_isinf(__x.real()))
13071380 {
1308 if (__libcpp_isnan_or_builtin(__x.imag()))
1381 if (std::__constexpr_isnan(__x.imag()))
13091382 return complex<_Tp>(__x.imag(), __x.real());
1310 if (__libcpp_isinf_or_builtin(__x.imag()))
1383 if (std::__constexpr_isinf(__x.imag()))
13111384 {
13121385 if (__x.real() < _Tp(0))
13131386 return complex<_Tp>(_Tp(0.75) * __pi, -__x.imag());
13141387 return complex<_Tp>(_Tp(0.25) * __pi, -__x.imag());
13151388 }
13161389 if (__x.real() < _Tp(0))
1317 return complex<_Tp>(__pi, signbit(__x.imag()) ? -__x.real() : __x.real());
1318 return complex<_Tp>(_Tp(0), signbit(__x.imag()) ? __x.real() : -__x.real());
1390 return complex<_Tp>(__pi, std::signbit(__x.imag()) ? -__x.real() : __x.real());
1391 return complex<_Tp>(_Tp(0), std::signbit(__x.imag()) ? __x.real() : -__x.real());
13191392 }
1320 if (__libcpp_isnan_or_builtin(__x.real()))
1393 if (std::__constexpr_isnan(__x.real()))
13211394 {
1322 if (__libcpp_isinf_or_builtin(__x.imag()))
1395 if (std::__constexpr_isinf(__x.imag()))
13231396 return complex<_Tp>(__x.real(), -__x.imag());
13241397 return complex<_Tp>(__x.real(), __x.real());
13251398 }
1326 if (__libcpp_isinf_or_builtin(__x.imag()))
1399 if (std::__constexpr_isinf(__x.imag()))
13271400 return complex<_Tp>(__pi/_Tp(2), -__x.imag());
1328 if (__x.real() == 0 && (__x.imag() == 0 || isnan(__x.imag())))
1401 if (__x.real() == 0 && (__x.imag() == 0 || std::isnan(__x.imag())))
13291402 return complex<_Tp>(__pi/_Tp(2), -__x.imag());
1330 complex<_Tp> __z = log(__x + sqrt(__sqr(__x) - _Tp(1)));
1331 if (signbit(__x.imag()))
1332 return complex<_Tp>(abs(__z.imag()), abs(__z.real()));
1333 return complex<_Tp>(abs(__z.imag()), -abs(__z.real()));
1403 complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) - _Tp(1)));
1404 if (std::signbit(__x.imag()))
1405 return complex<_Tp>(std::abs(__z.imag()), std::abs(__z.real()));
1406 return complex<_Tp>(std::abs(__z.imag()), -std::abs(__z.real()));
13341407}
13351408
13361409// atan
13371410
13381411template<class _Tp>
1339complex<_Tp>
1412_LIBCPP_HIDE_FROM_ABI complex<_Tp>
13401413atan(const complex<_Tp>& __x)
13411414{
1342 complex<_Tp> __z = atanh(complex<_Tp>(-__x.imag(), __x.real()));
1415 complex<_Tp> __z = std::atanh(complex<_Tp>(-__x.imag(), __x.real()));
13431416 return complex<_Tp>(__z.imag(), -__z.real());
13441417}
13451418
13461419// sin
13471420
13481421template<class _Tp>
1349complex<_Tp>
1422_LIBCPP_HIDE_FROM_ABI complex<_Tp>
13501423sin(const complex<_Tp>& __x)
13511424{
1352 complex<_Tp> __z = sinh(complex<_Tp>(-__x.imag(), __x.real()));
1425 complex<_Tp> __z = std::sinh(complex<_Tp>(-__x.imag(), __x.real()));
13531426 return complex<_Tp>(__z.imag(), -__z.real());
13541427}
13551428
......@@ -1360,26 +1433,27 @@ inline _LIBCPP_INLINE_VISIBILITY
13601433complex<_Tp>
13611434cos(const complex<_Tp>& __x)
13621435{
1363 return cosh(complex<_Tp>(-__x.imag(), __x.real()));
1436 return std::cosh(complex<_Tp>(-__x.imag(), __x.real()));
13641437}
13651438
13661439// tan
13671440
13681441template<class _Tp>
1369complex<_Tp>
1442_LIBCPP_HIDE_FROM_ABI complex<_Tp>
13701443tan(const complex<_Tp>& __x)
13711444{
1372 complex<_Tp> __z = tanh(complex<_Tp>(-__x.imag(), __x.real()));
1445 complex<_Tp> __z = std::tanh(complex<_Tp>(-__x.imag(), __x.real()));
13731446 return complex<_Tp>(__z.imag(), -__z.real());
13741447}
13751448
1449#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
13761450template<class _Tp, class _CharT, class _Traits>
1377basic_istream<_CharT, _Traits>&
1451_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
13781452operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
13791453{
13801454 if (__is.good())
13811455 {
1382 ws(__is);
1456 std::ws(__is);
13831457 if (__is.peek() == _CharT('('))
13841458 {
13851459 __is.get();
......@@ -1387,7 +1461,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
13871461 __is >> __r;
13881462 if (!__is.fail())
13891463 {
1390 ws(__is);
1464 std::ws(__is);
13911465 _CharT __c = __is.peek();
13921466 if (__c == _CharT(','))
13931467 {
......@@ -1396,7 +1470,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
13961470 __is >> __i;
13971471 if (!__is.fail())
13981472 {
1399 ws(__is);
1473 std::ws(__is);
14001474 __c = __is.peek();
14011475 if (__c == _CharT(')'))
14021476 {
......@@ -1435,9 +1509,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
14351509 return __is;
14361510}
14371511
1438#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
14391512template<class _Tp, class _CharT, class _Traits>
1440basic_ostream<_CharT, _Traits>&
1513_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
14411514operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x)
14421515{
14431516 basic_ostringstream<_CharT, _Traits> __s;
......@@ -1455,34 +1528,34 @@ inline namespace literals
14551528{
14561529 inline namespace complex_literals
14571530 {
1458 constexpr complex<long double> operator""il(long double __im)
1531 _LIBCPP_HIDE_FROM_ABI constexpr complex<long double> operator""il(long double __im)
14591532 {
14601533 return { 0.0l, __im };
14611534 }
14621535
1463 constexpr complex<long double> operator""il(unsigned long long __im)
1536 _LIBCPP_HIDE_FROM_ABI constexpr complex<long double> operator""il(unsigned long long __im)
14641537 {
14651538 return { 0.0l, static_cast<long double>(__im) };
14661539 }
14671540
14681541
1469 constexpr complex<double> operator""i(long double __im)
1542 _LIBCPP_HIDE_FROM_ABI constexpr complex<double> operator""i(long double __im)
14701543 {
14711544 return { 0.0, static_cast<double>(__im) };
14721545 }
14731546
1474 constexpr complex<double> operator""i(unsigned long long __im)
1547 _LIBCPP_HIDE_FROM_ABI constexpr complex<double> operator""i(unsigned long long __im)
14751548 {
14761549 return { 0.0, static_cast<double>(__im) };
14771550 }
14781551
14791552
1480 constexpr complex<float> operator""if(long double __im)
1553 _LIBCPP_HIDE_FROM_ABI constexpr complex<float> operator""if(long double __im)
14811554 {
14821555 return { 0.0f, static_cast<float>(__im) };
14831556 }
14841557
1485 constexpr complex<float> operator""if(unsigned long long __im)
1558 _LIBCPP_HIDE_FROM_ABI constexpr complex<float> operator""if(unsigned long long __im)
14861559 {
14871560 return { 0.0f, static_cast<float>(__im) };
14881561 }
lib/libcxx/include/complex.h+4-8
......@@ -24,13 +24,9 @@
2424#endif
2525
2626#ifdef __cplusplus
27
28#include <ccomplex>
29
30#else // __cplusplus
31
32#include_next <complex.h>
33
34#endif // __cplusplus
27# include <ccomplex>
28#elif __has_include_next(<complex.h>)
29# include_next <complex.h>
30#endif
3531
3632#endif // _LIBCPP_COMPLEX_H
lib/libcxx/include/concepts+4
......@@ -155,6 +155,10 @@ namespace std {
155155#include <__config>
156156#include <version>
157157
158#if _LIBCPP_STD_VER <= 20 && !defined(_LIPCPP_REMOVE_TRANSITIVE_INCLUDES)
159# include <type_traits>
160#endif
161
158162#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
159163# pragma GCC system_header
160164#endif
lib/libcxx/include/condition_variable+7-1
......@@ -108,8 +108,9 @@ public:
108108
109109#include <__assert> // all public C++ headers provide the assertion handler
110110#include <__config>
111#include <__memory/shared_ptr.h>
112#include <__memory/unique_ptr.h>
111113#include <__mutex_base>
112#include <memory>
113114#include <version>
114115
115116#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -267,4 +268,9 @@ _LIBCPP_END_NAMESPACE_STD
267268
268269#endif // !_LIBCPP_HAS_NO_THREADS
269270
271#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
272# include <concepts>
273# include <type_traits>
274#endif
275
270276#endif // _LIBCPP_CONDITION_VARIABLE
lib/libcxx/include/coroutine+7-4
......@@ -46,15 +46,18 @@ struct suspend_always;
4646#include <__coroutine/trivial_awaitables.h>
4747#include <version>
4848
49#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
50# include <iosfwd>
51#endif
52
5349// standard-mandated includes
50
51// [coroutine.syn]
5452#include <compare>
5553
5654#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
5755# pragma GCC system_header
5856#endif
5957
58#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
59# include <iosfwd>
60# include <type_traits>
61#endif
62
6063#endif // _LIBCPP_COROUTINE
lib/libcxx/include/csetjmp+9
......@@ -32,8 +32,17 @@ void longjmp(jmp_buf env, int val);
3232
3333#include <__assert> // all public C++ headers provide the assertion handler
3434#include <__config>
35
3536#include <setjmp.h>
3637
38#ifndef _LIBCPP_SETJMP_H
39# error <csetjmp> tried including <setjmp.h> but didn't find libc++'s <setjmp.h> header. \
40 This usually means that your header search paths are not configured properly. \
41 The header search paths should contain the C++ Standard Library headers before \
42 any C Standard Library, and you are probably using compiler flags that make that \
43 not be the case.
44#endif
45
3746#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3847# pragma GCC system_header
3948#endif
lib/libcxx/include/csignal+5-1
......@@ -42,8 +42,12 @@ int raise(int sig);
4242#include <__assert> // all public C++ headers provide the assertion handler
4343#include <__config>
4444
45// <signal.h> is not provided by libc++
4546#if __has_include(<signal.h>)
46# include <signal.h>
47# include <signal.h>
48# ifdef _LIBCPP_SIGNAL_H
49# error "If libc++ starts defining <signal.h>, the __has_include check should move to libc++'s <signal.h>"
50# endif
4751#endif
4852
4953#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/cstdarg+8-1
......@@ -33,7 +33,14 @@ Types:
3333
3434#include <__assert> // all public C++ headers provide the assertion handler
3535#include <__config>
36#include <stdarg.h>
36
37// <stdarg.h> is not provided by libc++
38#if __has_include(<stdarg.h>)
39# include <stdarg.h>
40# ifdef _LIBCPP_STDARG_H
41# error "If libc++ starts defining <stdarg.h>, the __has_include check should move to libc++'s <stdarg.h>"
42# endif
43#endif
3744
3845#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3946# pragma GCC system_header
lib/libcxx/include/cstddef+22-13
......@@ -38,9 +38,18 @@ Types:
3838#include <__type_traits/enable_if.h>
3939#include <__type_traits/integral_constant.h>
4040#include <__type_traits/is_integral.h>
41#include <stddef.h>
4241#include <version>
4342
43#include <stddef.h>
44
45#ifndef _LIBCPP_STDDEF_H
46# error <cstddef> tried including <stddef.h> but didn't find libc++'s <stddef.h> header. \
47 This usually means that your header search paths are not configured properly. \
48 The header search paths should contain the C++ Standard Library headers before \
49 any C Standard Library, and you are probably using compiler flags that make that \
50 not be the case.
51#endif
52
4453#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
4554# pragma GCC system_header
4655#endif
......@@ -62,7 +71,7 @@ namespace std // purposefully not versioned
6271{
6372enum class byte : unsigned char {};
6473
65constexpr byte operator| (byte __lhs, byte __rhs) noexcept
74_LIBCPP_HIDE_FROM_ABI constexpr byte operator| (byte __lhs, byte __rhs) noexcept
6675{
6776 return static_cast<byte>(
6877 static_cast<unsigned char>(
......@@ -70,10 +79,10 @@ constexpr byte operator| (byte __lhs, byte __rhs) noexcept
7079 ));
7180}
7281
73constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept
82_LIBCPP_HIDE_FROM_ABI constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept
7483{ return __lhs = __lhs | __rhs; }
7584
76constexpr byte operator& (byte __lhs, byte __rhs) noexcept
85_LIBCPP_HIDE_FROM_ABI constexpr byte operator& (byte __lhs, byte __rhs) noexcept
7786{
7887 return static_cast<byte>(
7988 static_cast<unsigned char>(
......@@ -81,10 +90,10 @@ constexpr byte operator& (byte __lhs, byte __rhs) noexcept
8190 ));
8291}
8392
84constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept
93_LIBCPP_HIDE_FROM_ABI constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept
8594{ return __lhs = __lhs & __rhs; }
8695
87constexpr byte operator^ (byte __lhs, byte __rhs) noexcept
96_LIBCPP_HIDE_FROM_ABI constexpr byte operator^ (byte __lhs, byte __rhs) noexcept
8897{
8998 return static_cast<byte>(
9099 static_cast<unsigned char>(
......@@ -92,10 +101,10 @@ constexpr byte operator^ (byte __lhs, byte __rhs) noexcept
92101 ));
93102}
94103
95constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept
104_LIBCPP_HIDE_FROM_ABI constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept
96105{ return __lhs = __lhs ^ __rhs; }
97106
98constexpr byte operator~ (byte __b) noexcept
107_LIBCPP_HIDE_FROM_ABI constexpr byte operator~ (byte __b) noexcept
99108{
100109 return static_cast<byte>(
101110 static_cast<unsigned char>(
......@@ -107,27 +116,27 @@ template <class _Tp>
107116using _EnableByteOverload = __enable_if_t<is_integral<_Tp>::value, byte>;
108117
109118template <class _Integer>
110 constexpr _EnableByteOverload<_Integer> &
119_LIBCPP_HIDE_FROM_ABI constexpr _EnableByteOverload<_Integer> &
111120 operator<<=(byte& __lhs, _Integer __shift) noexcept
112121 { return __lhs = __lhs << __shift; }
113122
114123template <class _Integer>
115 constexpr _EnableByteOverload<_Integer>
124_LIBCPP_HIDE_FROM_ABI constexpr _EnableByteOverload<_Integer>
116125 operator<< (byte __lhs, _Integer __shift) noexcept
117126 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); }
118127
119128template <class _Integer>
120 constexpr _EnableByteOverload<_Integer> &
129_LIBCPP_HIDE_FROM_ABI constexpr _EnableByteOverload<_Integer> &
121130 operator>>=(byte& __lhs, _Integer __shift) noexcept
122131 { return __lhs = __lhs >> __shift; }
123132
124133template <class _Integer>
125 constexpr _EnableByteOverload<_Integer>
134_LIBCPP_HIDE_FROM_ABI constexpr _EnableByteOverload<_Integer>
126135 operator>> (byte __lhs, _Integer __shift) noexcept
127136 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); }
128137
129138template <class _Integer, class = _EnableByteOverload<_Integer> >
130 _LIBCPP_NODISCARD_EXT constexpr _Integer
139_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Integer
131140 to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); }
132141
133142} // namespace std
lib/libcxx/include/cstdint+9
......@@ -142,8 +142,17 @@ Types:
142142
143143#include <__assert> // all public C++ headers provide the assertion handler
144144#include <__config>
145
145146#include <stdint.h>
146147
148#ifndef _LIBCPP_STDINT_H
149# error <cstdint> tried including <stdint.h> but didn't find libc++'s <stdint.h> header. \
150 This usually means that your header search paths are not configured properly. \
151 The header search paths should contain the C++ Standard Library headers before \
152 any C Standard Library, and you are probably using compiler flags that make that \
153 not be the case.
154#endif
155
147156#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
148157# pragma GCC system_header
149158#endif
lib/libcxx/include/cstdio+9
......@@ -97,8 +97,17 @@ void perror(const char* s);
9797
9898#include <__assert> // all public C++ headers provide the assertion handler
9999#include <__config>
100
100101#include <stdio.h>
101102
103#ifndef _LIBCPP_STDIO_H
104# error <cstdio> tried including <stdio.h> but didn't find libc++'s <stdio.h> header. \
105 This usually means that your header search paths are not configured properly. \
106 The header search paths should contain the C++ Standard Library headers before \
107 any C Standard Library, and you are probably using compiler flags that make that \
108 not be the case.
109#endif
110
102111#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
103112# pragma GCC system_header
104113#endif
lib/libcxx/include/cstdlib+9
......@@ -83,8 +83,17 @@ void *aligned_alloc(size_t alignment, size_t size); // C11
8383
8484#include <__assert> // all public C++ headers provide the assertion handler
8585#include <__config>
86
8687#include <stdlib.h>
8788
89#ifndef _LIBCPP_STDLIB_H
90# error <cstdlib> tried including <stdlib.h> but didn't find libc++'s <stdlib.h> header. \
91 This usually means that your header search paths are not configured properly. \
92 The header search paths should contain the C++ Standard Library headers before \
93 any C Standard Library, and you are probably using compiler flags that make that \
94 not be the case.
95#endif
96
8897#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
8998# pragma GCC system_header
9099#endif
lib/libcxx/include/cstring+57
......@@ -58,8 +58,18 @@ size_t strlen(const char* s);
5858
5959#include <__assert> // all public C++ headers provide the assertion handler
6060#include <__config>
61#include <__type_traits/is_constant_evaluated.h>
62
6163#include <string.h>
6264
65#ifndef _LIBCPP_STRING_H
66# error <cstring> tried including <string.h> but didn't find libc++'s <string.h> header. \
67 This usually means that your header search paths are not configured properly. \
68 The header search paths should contain the C++ Standard Library headers before \
69 any C Standard Library, and you are probably using compiler flags that make that \
70 not be the case.
71#endif
72
6373#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
6474# pragma GCC system_header
6575#endif
......@@ -90,6 +100,53 @@ using ::memset _LIBCPP_USING_IF_EXISTS;
90100using ::strerror _LIBCPP_USING_IF_EXISTS;
91101using ::strlen _LIBCPP_USING_IF_EXISTS;
92102
103inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_strlen(const char* __str) {
104 // GCC currently doesn't support __builtin_strlen for heap-allocated memory during constant evaluation.
105 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70816
106#ifdef _LIBCPP_COMPILER_GCC
107 if (__libcpp_is_constant_evaluated()) {
108 size_t __i = 0;
109 for (; __str[__i] != '\0'; ++__i)
110 ;
111 return __i;
112 }
113#endif
114 return __builtin_strlen(__str);
115}
116
117template <class _Tp>
118_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int
119__constexpr_memcmp(const _Tp* __lhs, const _Tp* __rhs, size_t __count) {
120#ifdef _LIBCPP_COMPILER_GCC
121 if (__libcpp_is_constant_evaluated()) {
122 for (; __count; --__count, ++__lhs, ++__rhs) {
123 if (*__lhs < *__rhs)
124 return -1;
125 if (*__rhs < *__lhs)
126 return 1;
127 }
128 return 0;
129 }
130#endif
131 return __builtin_memcmp(__lhs, __rhs, __count);
132}
133
134inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const char*
135__constexpr_char_memchr(const char* __str, int __char, size_t __count) {
136#if __has_builtin(__builtin_char_memchr)
137 return __builtin_char_memchr(__str, __char, __count);
138#else
139 if (!__libcpp_is_constant_evaluated())
140 return static_cast<const char*>(std::memchr(__str, __char, __count));
141 for (; __count; --__count) {
142 if (*__str == __char)
143 return __str;
144 ++__str;
145 }
146 return nullptr;
147#endif
148}
149
93150_LIBCPP_END_NAMESPACE_STD
94151
95152#endif // _LIBCPP_CSTRING
lib/libcxx/include/ctime+8-1
......@@ -47,7 +47,14 @@ int timespec_get( struct timespec *ts, int base); // C++17
4747
4848#include <__assert> // all public C++ headers provide the assertion handler
4949#include <__config>
50#include <time.h>
50
51// <time.h> is not provided by libc++
52#if __has_include(<time.h>)
53# include <time.h>
54# ifdef _LIBCPP_TIME_H
55# error "If libc++ starts defining <time.h>, the __has_include check should move to libc++'s <time.h>"
56# endif
57#endif
5158
5259#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
5360# pragma GCC system_header
lib/libcxx/include/ctype.h+3-1
......@@ -35,7 +35,9 @@ int toupper(int c);
3535# pragma GCC system_header
3636#endif
3737
38#include_next <ctype.h>
38#if __has_include_next(<ctype.h>)
39# include_next <ctype.h>
40#endif
3941
4042#ifdef __cplusplus
4143
lib/libcxx/include/cuchar+15
......@@ -25,6 +25,8 @@ Types:
2525 mbstate_t
2626 size_t
2727
28size_t mbrtoc8(char8_t* pc8, const char* s, size_t n, mbstate_t* ps); // since C++20
29size_t c8rtomb(char* s, char8_t c8, mbstate_t* ps); // since C++20
2830size_t mbrtoc16(char16_t* pc16, const char* s, size_t n, mbstate_t* ps);
2931size_t c16rtomb(char* s, char16_t c16, mbstate_t* ps);
3032size_t mbrtoc32(char32_t* pc32, const char* s, size_t n, mbstate_t* ps);
......@@ -36,8 +38,17 @@ size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps);
3638
3739#include <__assert> // all public C++ headers provide the assertion handler
3840#include <__config>
41
3942#include <uchar.h>
4043
44#ifndef _LIBCPP_UCHAR_H
45# error <cuchar> tried including <uchar.h> but didn't find libc++'s <uchar.h> header. \
46 This usually means that your header search paths are not configured properly. \
47 The header search paths should contain the C++ Standard Library headers before \
48 any C Standard Library, and you are probably using compiler flags that make that \
49 not be the case.
50#endif
51
4152#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
4253# pragma GCC system_header
4354#endif
......@@ -49,6 +60,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
4960using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
5061using ::size_t _LIBCPP_USING_IF_EXISTS;
5162
63# if !defined(_LIBCPP_HAS_NO_C8RTOMB_MBRTOC8)
64using ::mbrtoc8 _LIBCPP_USING_IF_EXISTS;
65using ::c8rtomb _LIBCPP_USING_IF_EXISTS;
66# endif
5267using ::mbrtoc16 _LIBCPP_USING_IF_EXISTS;
5368using ::c16rtomb _LIBCPP_USING_IF_EXISTS;
5469using ::mbrtoc32 _LIBCPP_USING_IF_EXISTS;
lib/libcxx/include/cwchar+59
......@@ -104,9 +104,19 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
104104
105105#include <__assert> // all public C++ headers provide the assertion handler
106106#include <__config>
107#include <__type_traits/is_constant_evaluated.h>
107108#include <cwctype>
109
108110#include <wchar.h>
109111
112#ifndef _LIBCPP_WCHAR_H
113# error <cwchar> tried including <wchar.h> but didn't find libc++'s <wchar.h> header. \
114 This usually means that your header search paths are not configured properly. \
115 The header search paths should contain the C++ Standard Library headers before \
116 any C Standard Library, and you are probably using compiler flags that make that \
117 not be the case.
118#endif
119
110120#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
111121# pragma GCC system_header
112122#endif
......@@ -180,6 +190,55 @@ using ::putwchar _LIBCPP_USING_IF_EXISTS;
180190using ::vwprintf _LIBCPP_USING_IF_EXISTS;
181191using ::wprintf _LIBCPP_USING_IF_EXISTS;
182192
193inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_wcslen(const wchar_t* __str) {
194#if __has_builtin(__builtin_wcslen)
195 return __builtin_wcslen(__str);
196#else
197 if (!__libcpp_is_constant_evaluated())
198 return std::wcslen(__str);
199
200 size_t __len = 0;
201 for (; *__str != L'\0'; ++__str)
202 ++__len;
203 return __len;
204#endif
205}
206
207inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int
208__constexpr_wmemcmp(const wchar_t* __lhs, const wchar_t* __rhs, size_t __count) {
209#if __has_builtin(__builtin_wmemcmp)
210 return __builtin_wmemcmp(__lhs, __rhs, __count);
211#else
212 if (!__libcpp_is_constant_evaluated())
213 return std::wmemcmp(__lhs, __rhs, __count);
214
215 for (; __count; --__count, ++__lhs, ++__rhs) {
216 if (*__lhs < *__rhs)
217 return -1;
218 if (*__rhs < *__lhs)
219 return 1;
220 }
221 return 0;
222#endif
223}
224
225inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const wchar_t*
226__constexpr_wmemchr(const wchar_t* __str, wchar_t __char, size_t __count) {
227#if __has_feature(cxx_constexpr_string_builtins)
228 return __builtin_wmemchr(__str, __char, __count);
229#else
230 if (!__libcpp_is_constant_evaluated())
231 return std::wmemchr(__str, __char, __count);
232
233 for (; __count; --__count) {
234 if (*__str == __char)
235 return __str;
236 ++__str;
237 }
238 return nullptr;
239#endif
240}
241
183242_LIBCPP_END_NAMESPACE_STD
184243
185244#endif // _LIBCPP_CWCHAR
lib/libcxx/include/cwctype+9
......@@ -52,8 +52,17 @@ wctrans_t wctrans(const char* property);
5252#include <__assert> // all public C++ headers provide the assertion handler
5353#include <__config>
5454#include <cctype>
55
5556#include <wctype.h>
5657
58#ifndef _LIBCPP_WCTYPE_H
59# error <cwctype> tried including <wctype.h> but didn't find libc++'s <wctype.h> header. \
60 This usually means that your header search paths are not configured properly. \
61 The header search paths should contain the C++ Standard Library headers before \
62 any C Standard Library, and you are probably using compiler flags that make that \
63 not be the case.
64#endif
65
5766#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
5867# pragma GCC system_header
5968#endif
lib/libcxx/include/deque+757-1374
......@@ -176,7 +176,14 @@ template <class T, class Allocator, class Predicate>
176176#include <__iterator/next.h>
177177#include <__iterator/prev.h>
178178#include <__iterator/reverse_iterator.h>
179#include <__iterator/segmented_iterator.h>
180#include <__memory/allocator_destructor.h>
181#include <__memory/pointer_traits.h>
182#include <__memory/temp_value.h>
183#include <__memory/unique_ptr.h>
184#include <__memory_resource/polymorphic_allocator.h>
179185#include <__split_buffer>
186#include <__type_traits/is_allocator.h>
180187#include <__utility/forward.h>
181188#include <__utility/move.h>
182189#include <__utility/swap.h>
......@@ -185,12 +192,6 @@ template <class T, class Allocator, class Predicate>
185192#include <type_traits>
186193#include <version>
187194
188#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
189# include <algorithm>
190# include <functional>
191# include <iterator>
192#endif
193
194195// standard-mandated includes
195196
196197// [iterator.range]
......@@ -214,101 +215,8 @@ _LIBCPP_PUSH_MACROS
214215
215216_LIBCPP_BEGIN_NAMESPACE_STD
216217
217template <class _Tp, class _Allocator> class __deque_base;
218218template <class _Tp, class _Allocator = allocator<_Tp> > class _LIBCPP_TEMPLATE_VIS deque;
219219
220template <class _ValueType, class _Pointer, class _Reference, class _MapPointer,
221 class _DiffType, _DiffType _BlockSize>
222class _LIBCPP_TEMPLATE_VIS __deque_iterator;
223
224template <class _RAIter,
225 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
226__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
227copy(_RAIter __f,
228 _RAIter __l,
229 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
230 typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type* = 0);
231
232template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
233 class _OutputIterator>
234_OutputIterator
235copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
236 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
237 _OutputIterator __r);
238
239template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
240 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
241__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
242copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
243 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
244 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r);
245
246template <class _RAIter,
247 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
248__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
249copy_backward(_RAIter __f,
250 _RAIter __l,
251 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
252 typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type* = 0);
253
254template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
255 class _OutputIterator>
256_OutputIterator
257copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
258 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
259 _OutputIterator __r);
260
261template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
262 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
263__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
264copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
265 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
266 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r);
267
268template <class _RAIter,
269 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
270__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
271move(_RAIter __f,
272 _RAIter __l,
273 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
274 typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type* = 0);
275
276template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
277 class _OutputIterator>
278_OutputIterator
279move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
280 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
281 _OutputIterator __r);
282
283template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
284 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
285__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
286move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
287 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
288 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r);
289
290template <class _RAIter,
291 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
292__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
293move_backward(_RAIter __f,
294 _RAIter __l,
295 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
296 typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type* = 0);
297
298template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
299 class _OutputIterator>
300_OutputIterator
301move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
302 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
303 _OutputIterator __r);
304
305template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
306 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
307__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
308move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
309 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
310 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r);
311
312220template <class _ValueType, class _DiffType>
313221struct __deque_block_size {
314222 static const _DiffType value = sizeof(_ValueType) < 256 ? 4096 / sizeof(_ValueType) : 16;
......@@ -340,22 +248,22 @@ public:
340248 typedef random_access_iterator_tag iterator_category;
341249 typedef _Reference reference;
342250
343 _LIBCPP_INLINE_VISIBILITY __deque_iterator() _NOEXCEPT
251 _LIBCPP_HIDE_FROM_ABI __deque_iterator() _NOEXCEPT
344252#if _LIBCPP_STD_VER > 11
345253 : __m_iter_(nullptr), __ptr_(nullptr)
346254#endif
347255 {}
348256
349257 template <class _Pp, class _Rp, class _MP>
350 _LIBCPP_INLINE_VISIBILITY
258 _LIBCPP_HIDE_FROM_ABI
351259 __deque_iterator(const __deque_iterator<value_type, _Pp, _Rp, _MP, difference_type, _BS>& __it,
352260 typename enable_if<is_convertible<_Pp, pointer>::value>::type* = 0) _NOEXCEPT
353261 : __m_iter_(__it.__m_iter_), __ptr_(__it.__ptr_) {}
354262
355 _LIBCPP_INLINE_VISIBILITY reference operator*() const {return *__ptr_;}
356 _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return __ptr_;}
263 _LIBCPP_HIDE_FROM_ABI reference operator*() const {return *__ptr_;}
264 _LIBCPP_HIDE_FROM_ABI pointer operator->() const {return __ptr_;}
357265
358 _LIBCPP_INLINE_VISIBILITY __deque_iterator& operator++()
266 _LIBCPP_HIDE_FROM_ABI __deque_iterator& operator++()
359267 {
360268 if (++__ptr_ - *__m_iter_ == __block_size)
361269 {
......@@ -365,14 +273,14 @@ public:
365273 return *this;
366274 }
367275
368 _LIBCPP_INLINE_VISIBILITY __deque_iterator operator++(int)
276 _LIBCPP_HIDE_FROM_ABI __deque_iterator operator++(int)
369277 {
370278 __deque_iterator __tmp = *this;
371279 ++(*this);
372280 return __tmp;
373281 }
374282
375 _LIBCPP_INLINE_VISIBILITY __deque_iterator& operator--()
283 _LIBCPP_HIDE_FROM_ABI __deque_iterator& operator--()
376284 {
377285 if (__ptr_ == *__m_iter_)
378286 {
......@@ -383,14 +291,14 @@ public:
383291 return *this;
384292 }
385293
386 _LIBCPP_INLINE_VISIBILITY __deque_iterator operator--(int)
294 _LIBCPP_HIDE_FROM_ABI __deque_iterator operator--(int)
387295 {
388296 __deque_iterator __tmp = *this;
389297 --(*this);
390298 return __tmp;
391299 }
392300
393 _LIBCPP_INLINE_VISIBILITY __deque_iterator& operator+=(difference_type __n)
301 _LIBCPP_HIDE_FROM_ABI __deque_iterator& operator+=(difference_type __n)
394302 {
395303 if (__n != 0)
396304 {
......@@ -410,30 +318,30 @@ public:
410318 return *this;
411319 }
412320
413 _LIBCPP_INLINE_VISIBILITY __deque_iterator& operator-=(difference_type __n)
321 _LIBCPP_HIDE_FROM_ABI __deque_iterator& operator-=(difference_type __n)
414322 {
415323 return *this += -__n;
416324 }
417325
418 _LIBCPP_INLINE_VISIBILITY __deque_iterator operator+(difference_type __n) const
326 _LIBCPP_HIDE_FROM_ABI __deque_iterator operator+(difference_type __n) const
419327 {
420328 __deque_iterator __t(*this);
421329 __t += __n;
422330 return __t;
423331 }
424332
425 _LIBCPP_INLINE_VISIBILITY __deque_iterator operator-(difference_type __n) const
333 _LIBCPP_HIDE_FROM_ABI __deque_iterator operator-(difference_type __n) const
426334 {
427335 __deque_iterator __t(*this);
428336 __t -= __n;
429337 return __t;
430338 }
431339
432 _LIBCPP_INLINE_VISIBILITY
340 _LIBCPP_HIDE_FROM_ABI
433341 friend __deque_iterator operator+(difference_type __n, const __deque_iterator& __it)
434342 {return __it + __n;}
435343
436 _LIBCPP_INLINE_VISIBILITY
344 _LIBCPP_HIDE_FROM_ABI
437345 friend difference_type operator-(const __deque_iterator& __x, const __deque_iterator& __y)
438346 {
439347 if (__x != __y)
......@@ -443,142 +351,72 @@ public:
443351 return 0;
444352 }
445353
446 _LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const
354 _LIBCPP_HIDE_FROM_ABI reference operator[](difference_type __n) const
447355 {return *(*this + __n);}
448356
449 _LIBCPP_INLINE_VISIBILITY friend
357 _LIBCPP_HIDE_FROM_ABI friend
450358 bool operator==(const __deque_iterator& __x, const __deque_iterator& __y)
451359 {return __x.__ptr_ == __y.__ptr_;}
452360
453 _LIBCPP_INLINE_VISIBILITY friend
361 _LIBCPP_HIDE_FROM_ABI friend
454362 bool operator!=(const __deque_iterator& __x, const __deque_iterator& __y)
455363 {return !(__x == __y);}
456364
457 _LIBCPP_INLINE_VISIBILITY friend
365 _LIBCPP_HIDE_FROM_ABI friend
458366 bool operator<(const __deque_iterator& __x, const __deque_iterator& __y)
459367 {return __x.__m_iter_ < __y.__m_iter_ ||
460368 (__x.__m_iter_ == __y.__m_iter_ && __x.__ptr_ < __y.__ptr_);}
461369
462 _LIBCPP_INLINE_VISIBILITY friend
370 _LIBCPP_HIDE_FROM_ABI friend
463371 bool operator>(const __deque_iterator& __x, const __deque_iterator& __y)
464372 {return __y < __x;}
465373
466 _LIBCPP_INLINE_VISIBILITY friend
374 _LIBCPP_HIDE_FROM_ABI friend
467375 bool operator<=(const __deque_iterator& __x, const __deque_iterator& __y)
468376 {return !(__y < __x);}
469377
470 _LIBCPP_INLINE_VISIBILITY friend
378 _LIBCPP_HIDE_FROM_ABI friend
471379 bool operator>=(const __deque_iterator& __x, const __deque_iterator& __y)
472380 {return !(__x < __y);}
473381
474382private:
475 _LIBCPP_INLINE_VISIBILITY explicit __deque_iterator(__map_iterator __m, pointer __p) _NOEXCEPT
383 _LIBCPP_HIDE_FROM_ABI explicit __deque_iterator(__map_iterator __m, pointer __p) _NOEXCEPT
476384 : __m_iter_(__m), __ptr_(__p) {}
477385
478 template <class _Tp, class _Ap> friend class __deque_base;
479386 template <class _Tp, class _Ap> friend class _LIBCPP_TEMPLATE_VIS deque;
480387 template <class _Vp, class _Pp, class _Rp, class _MP, class _Dp, _Dp>
481388 friend class _LIBCPP_TEMPLATE_VIS __deque_iterator;
482389
483 template <class _RAIter,
484 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
485 friend
486 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
487 copy(_RAIter __f,
488 _RAIter __l,
489 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
490 typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*);
491
492 template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
493 class _OutputIterator>
494 friend
495 _OutputIterator
496 copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
497 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
498 _OutputIterator __r);
499
500 template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
501 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
502 friend
503 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
504 copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
505 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
506 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r);
507
508 template <class _RAIter,
509 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
510 friend
511 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
512 copy_backward(_RAIter __f,
513 _RAIter __l,
514 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
515 typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*);
516
517 template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
518 class _OutputIterator>
519 friend
520 _OutputIterator
521 copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
522 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
523 _OutputIterator __r);
524
525 template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
526 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
527 friend
528 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
529 copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
530 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
531 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r);
532
533 template <class _RAIter,
534 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
535 friend
536 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
537 move(_RAIter __f,
538 _RAIter __l,
539 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
540 typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*);
541
542 template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
543 class _OutputIterator>
544 friend
545 _OutputIterator
546 move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
547 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
548 _OutputIterator __r);
549
550 template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
551 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
552 friend
553 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
554 move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
555 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
556 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r);
557
558 template <class _RAIter,
559 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
560 friend
561 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
562 move_backward(_RAIter __f,
563 _RAIter __l,
564 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
565 typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*);
566
567 template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
568 class _OutputIterator>
569 friend
570 _OutputIterator
571 move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
572 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
573 _OutputIterator __r);
574
575 template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
576 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
577 friend
578 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
579 move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
580 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
581 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r);
390 template <class>
391 friend struct __segmented_iterator_traits;
392};
393
394template <class _ValueType, class _Pointer, class _Reference, class _MapPointer, class _DiffType, _DiffType _BlockSize>
395struct __segmented_iterator_traits<
396 __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, _DiffType, _BlockSize> > {
397private:
398 using _Iterator = __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, _DiffType, _BlockSize>;
399
400public:
401 using __is_segmented_iterator = true_type;
402 using __segment_iterator = _MapPointer;
403 using __local_iterator = _Pointer;
404
405 static _LIBCPP_HIDE_FROM_ABI __segment_iterator __segment(_Iterator __iter) { return __iter.__m_iter_; }
406 static _LIBCPP_HIDE_FROM_ABI __local_iterator __local(_Iterator __iter) { return __iter.__ptr_; }
407 static _LIBCPP_HIDE_FROM_ABI __local_iterator __begin(__segment_iterator __iter) { return *__iter; }
408
409 static _LIBCPP_HIDE_FROM_ABI __local_iterator __end(__segment_iterator __iter) {
410 return *__iter + _Iterator::__block_size;
411 }
412
413 static _LIBCPP_HIDE_FROM_ABI _Iterator __compose(__segment_iterator __segment, __local_iterator __local) {
414 if (__local == __end(__segment)) {
415 ++__segment;
416 return _Iterator(__segment, *__segment);
417 }
418 return _Iterator(__segment, __local);
419 }
582420};
583421
584422template <class _ValueType, class _Pointer, class _Reference, class _MapPointer,
......@@ -587,897 +425,329 @@ const _DiffType __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer,
587425 _DiffType, _BlockSize>::__block_size =
588426 __deque_block_size<_ValueType, _DiffType>::value;
589427
590// copy
591
592template <class _RAIter,
593 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
594__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
595copy(_RAIter __f,
596 _RAIter __l,
597 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
598 typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*)
428template <class _Tp, class _Allocator /*= allocator<_Tp>*/>
429class _LIBCPP_TEMPLATE_VIS deque
599430{
600 typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::difference_type difference_type;
601 typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer;
602 const difference_type __block_size = __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::__block_size;
603 while (__f != __l)
604 {
605 pointer __rb = __r.__ptr_;
606 pointer __re = *__r.__m_iter_ + __block_size;
607 difference_type __bs = __re - __rb;
608 difference_type __n = __l - __f;
609 _RAIter __m = __l;
610 if (__n > __bs)
611 {
612 __n = __bs;
613 __m = __f + __n;
614 }
615 _VSTD::copy(__f, __m, __rb);
616 __f = __m;
617 __r += __n;
618 }
619 return __r;
620}
431public:
432 // types:
621433
622template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
623 class _OutputIterator>
624_OutputIterator
625copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
626 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
627 _OutputIterator __r)
628{
629 typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type;
630 typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer;
631 const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::__block_size;
632 difference_type __n = __l - __f;
633 while (__n > 0)
634 {
635 pointer __fb = __f.__ptr_;
636 pointer __fe = *__f.__m_iter_ + __block_size;
637 difference_type __bs = __fe - __fb;
638 if (__bs > __n)
639 {
640 __bs = __n;
641 __fe = __fb + __bs;
642 }
643 __r = _VSTD::copy(__fb, __fe, __r);
644 __n -= __bs;
645 __f += __bs;
646 }
647 return __r;
648}
434 using value_type = _Tp;
649435
650template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
651 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
652__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
653copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
654 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
655 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r)
656{
657 typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type;
658 typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer;
659 const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::__block_size;
660 difference_type __n = __l - __f;
661 while (__n > 0)
662 {
663 pointer __fb = __f.__ptr_;
664 pointer __fe = *__f.__m_iter_ + __block_size;
665 difference_type __bs = __fe - __fb;
666 if (__bs > __n)
667 {
668 __bs = __n;
669 __fe = __fb + __bs;
670 }
671 __r = _VSTD::copy(__fb, __fe, __r);
672 __n -= __bs;
673 __f += __bs;
674 }
675 return __r;
676}
436 static_assert((is_same<typename _Allocator::value_type, value_type>::value),
437 "Allocator::value_type must be same type as value_type");
677438
678// copy_backward
439 using allocator_type = _Allocator;
440 using __alloc_traits = allocator_traits<allocator_type>;
679441
680template <class _RAIter,
681 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
682__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
683copy_backward(_RAIter __f,
684 _RAIter __l,
685 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
686 typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*)
687{
688 typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::difference_type difference_type;
689 typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer;
690 while (__f != __l)
691 {
692 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __rp = _VSTD::prev(__r);
693 pointer __rb = *__rp.__m_iter_;
694 pointer __re = __rp.__ptr_ + 1;
695 difference_type __bs = __re - __rb;
696 difference_type __n = __l - __f;
697 _RAIter __m = __f;
698 if (__n > __bs)
699 {
700 __n = __bs;
701 __m = __l - __n;
702 }
703 _VSTD::copy_backward(__m, __l, __re);
704 __l = __m;
705 __r -= __n;
706 }
707 return __r;
708}
442 using size_type = typename __alloc_traits::size_type;
443 using difference_type = typename __alloc_traits::difference_type;
709444
710template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
711 class _OutputIterator>
712_OutputIterator
713copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
714 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
715 _OutputIterator __r)
716{
717 typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type;
718 typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer;
719 difference_type __n = __l - __f;
720 while (__n > 0)
721 {
722 --__l;
723 pointer __lb = *__l.__m_iter_;
724 pointer __le = __l.__ptr_ + 1;
725 difference_type __bs = __le - __lb;
726 if (__bs > __n)
727 {
728 __bs = __n;
729 __lb = __le - __bs;
730 }
731 __r = _VSTD::copy_backward(__lb, __le, __r);
732 __n -= __bs;
733 __l -= __bs - 1;
734 }
735 return __r;
736}
445 using pointer = typename __alloc_traits::pointer;
446 using const_pointer = typename __alloc_traits::const_pointer;
737447
738template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
739 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
740__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
741copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
742 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
743 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r)
744{
745 typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type;
746 typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer;
747 difference_type __n = __l - __f;
748 while (__n > 0)
749 {
750 --__l;
751 pointer __lb = *__l.__m_iter_;
752 pointer __le = __l.__ptr_ + 1;
753 difference_type __bs = __le - __lb;
754 if (__bs > __n)
755 {
756 __bs = __n;
757 __lb = __le - __bs;
758 }
759 __r = _VSTD::copy_backward(__lb, __le, __r);
760 __n -= __bs;
761 __l -= __bs - 1;
762 }
763 return __r;
764}
448 using __pointer_allocator = __rebind_alloc<__alloc_traits, pointer>;
449 using __const_pointer_allocator = __rebind_alloc<__alloc_traits, const_pointer>;
450 using __map = __split_buffer<pointer, __pointer_allocator>;
451 using __map_alloc_traits = allocator_traits<__pointer_allocator>;
452 using __map_pointer = typename __map_alloc_traits::pointer;
453 using __map_const_pointer = typename allocator_traits<__const_pointer_allocator>::const_pointer;
765454
766// move
455 using reference = value_type&;
456 using const_reference = const value_type&;
767457
768template <class _RAIter,
769 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
770__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
771move(_RAIter __f,
772 _RAIter __l,
773 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
774 typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*)
775{
776 typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::difference_type difference_type;
777 typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer;
778 const difference_type __block_size = __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::__block_size;
779 while (__f != __l)
780 {
781 pointer __rb = __r.__ptr_;
782 pointer __re = *__r.__m_iter_ + __block_size;
783 difference_type __bs = __re - __rb;
784 difference_type __n = __l - __f;
785 _RAIter __m = __l;
786 if (__n > __bs)
787 {
788 __n = __bs;
789 __m = __f + __n;
790 }
791 _VSTD::move(__f, __m, __rb);
792 __f = __m;
793 __r += __n;
794 }
795 return __r;
796}
458 using iterator = __deque_iterator<value_type, pointer, reference, __map_pointer, difference_type>;
459 using const_iterator =
460 __deque_iterator<value_type, const_pointer, const_reference, __map_const_pointer, difference_type>;
461 using reverse_iterator = std::reverse_iterator<iterator>;
462 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
797463
798template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
799 class _OutputIterator>
800_OutputIterator
801move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
802 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
803 _OutputIterator __r)
804{
805 typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type;
806 typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer;
807 const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::__block_size;
808 difference_type __n = __l - __f;
809 while (__n > 0)
810 {
811 pointer __fb = __f.__ptr_;
812 pointer __fe = *__f.__m_iter_ + __block_size;
813 difference_type __bs = __fe - __fb;
814 if (__bs > __n)
815 {
816 __bs = __n;
817 __fe = __fb + __bs;
818 }
819 __r = _VSTD::move(__fb, __fe, __r);
820 __n -= __bs;
821 __f += __bs;
822 }
823 return __r;
824}
464 static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
465 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
466 "original allocator");
467 static_assert(is_nothrow_default_constructible<allocator_type>::value ==
468 is_nothrow_default_constructible<__pointer_allocator>::value,
469 "rebinding an allocator should not change excpetion guarantees");
470 static_assert(is_nothrow_move_constructible<allocator_type>::value ==
471 is_nothrow_move_constructible<typename __map::allocator_type>::value,
472 "rebinding an allocator should not change excpetion guarantees");
825473
826template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
827 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
828__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
829move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
830 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
831 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r)
832{
833 typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type;
834 typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer;
835 const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::__block_size;
836 difference_type __n = __l - __f;
837 while (__n > 0)
838 {
839 pointer __fb = __f.__ptr_;
840 pointer __fe = *__f.__m_iter_ + __block_size;
841 difference_type __bs = __fe - __fb;
842 if (__bs > __n)
843 {
844 __bs = __n;
845 __fe = __fb + __bs;
846 }
847 __r = _VSTD::move(__fb, __fe, __r);
848 __n -= __bs;
849 __f += __bs;
850 }
851 return __r;
852}
474private:
475 struct __deque_block_range {
476 explicit _LIBCPP_HIDE_FROM_ABI
477 __deque_block_range(pointer __b, pointer __e) _NOEXCEPT : __begin_(__b), __end_(__e) {}
478 const pointer __begin_;
479 const pointer __end_;
480 };
853481
854// move_backward
482 struct __deque_range {
483 iterator __pos_;
484 const iterator __end_;
855485
856template <class _RAIter,
857 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
858__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
859move_backward(_RAIter __f,
860 _RAIter __l,
861 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
862 typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*)
863{
864 typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::difference_type difference_type;
865 typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer;
866 while (__f != __l)
867 {
868 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __rp = _VSTD::prev(__r);
869 pointer __rb = *__rp.__m_iter_;
870 pointer __re = __rp.__ptr_ + 1;
871 difference_type __bs = __re - __rb;
872 difference_type __n = __l - __f;
873 _RAIter __m = __f;
874 if (__n > __bs)
875 {
876 __n = __bs;
877 __m = __l - __n;
878 }
879 _VSTD::move_backward(__m, __l, __re);
880 __l = __m;
881 __r -= __n;
882 }
883 return __r;
884}
486 _LIBCPP_HIDE_FROM_ABI __deque_range(iterator __pos, iterator __e) _NOEXCEPT
487 : __pos_(__pos), __end_(__e) {}
885488
886template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
887 class _OutputIterator>
888_OutputIterator
889move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
890 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
891 _OutputIterator __r)
892{
893 typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type;
894 typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer;
895 difference_type __n = __l - __f;
896 while (__n > 0)
897 {
898 --__l;
899 pointer __lb = *__l.__m_iter_;
900 pointer __le = __l.__ptr_ + 1;
901 difference_type __bs = __le - __lb;
902 if (__bs > __n)
903 {
904 __bs = __n;
905 __lb = __le - __bs;
906 }
907 __r = _VSTD::move_backward(__lb, __le, __r);
908 __n -= __bs;
909 __l -= __bs - 1;
489 explicit _LIBCPP_HIDE_FROM_ABI operator bool() const _NOEXCEPT {
490 return __pos_ != __end_;
910491 }
911 return __r;
912}
913492
914template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
915 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
916__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
917move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
918 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
919 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r)
920{
921 typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type;
922 typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer;
923 difference_type __n = __l - __f;
924 while (__n > 0)
925 {
926 --__l;
927 pointer __lb = *__l.__m_iter_;
928 pointer __le = __l.__ptr_ + 1;
929 difference_type __bs = __le - __lb;
930 if (__bs > __n)
931 {
932 __bs = __n;
933 __lb = __le - __bs;
934 }
935 __r = _VSTD::move_backward(__lb, __le, __r);
936 __n -= __bs;
937 __l -= __bs - 1;
493 _LIBCPP_HIDE_FROM_ABI __deque_range begin() const {
494 return *this;
938495 }
939 return __r;
940}
941
942template <class _Tp, class _Allocator>
943class __deque_base
944{
945 __deque_base(const __deque_base& __c);
946 __deque_base& operator=(const __deque_base& __c);
947public:
948 typedef _Allocator allocator_type;
949 typedef allocator_traits<allocator_type> __alloc_traits;
950 typedef typename __alloc_traits::size_type size_type;
951496
952 typedef _Tp value_type;
953 typedef value_type& reference;
954 typedef const value_type& const_reference;
955 typedef typename __alloc_traits::difference_type difference_type;
956 typedef typename __alloc_traits::pointer pointer;
957 typedef typename __alloc_traits::const_pointer const_pointer;
958
959 static const difference_type __block_size;
960
961 typedef typename __rebind_alloc_helper<__alloc_traits, pointer>::type __pointer_allocator;
962 typedef allocator_traits<__pointer_allocator> __map_traits;
963 typedef typename __map_traits::pointer __map_pointer;
964 typedef typename __rebind_alloc_helper<__alloc_traits, const_pointer>::type __const_pointer_allocator;
965 typedef typename allocator_traits<__const_pointer_allocator>::const_pointer __map_const_pointer;
966 typedef __split_buffer<pointer, __pointer_allocator> __map;
967
968 typedef __deque_iterator<value_type, pointer, reference, __map_pointer,
969 difference_type> iterator;
970 typedef __deque_iterator<value_type, const_pointer, const_reference, __map_const_pointer,
971 difference_type> const_iterator;
972
973 struct __deque_block_range {
974 explicit __deque_block_range(pointer __b, pointer __e) _NOEXCEPT : __begin_(__b), __end_(__e) {}
975 const pointer __begin_;
976 const pointer __end_;
977 };
978
979 struct __deque_range {
980 iterator __pos_;
981 const iterator __end_;
982
983 __deque_range(iterator __pos, iterator __e) _NOEXCEPT
984 : __pos_(__pos), __end_(__e) {}
985
986 explicit operator bool() const _NOEXCEPT {
987 return __pos_ != __end_;
988 }
989
990 __deque_range begin() const {
991 return *this;
992 }
993
994 __deque_range end() const {
995 return __deque_range(__end_, __end_);
996 }
997 __deque_block_range operator*() const _NOEXCEPT {
998 if (__pos_.__m_iter_ == __end_.__m_iter_) {
999 return __deque_block_range(__pos_.__ptr_, __end_.__ptr_);
1000 }
1001 return __deque_block_range(__pos_.__ptr_, *__pos_.__m_iter_ + __block_size);
1002 }
1003
1004 __deque_range& operator++() _NOEXCEPT {
497 _LIBCPP_HIDE_FROM_ABI __deque_range end() const {
498 return __deque_range(__end_, __end_);
499 }
500 _LIBCPP_HIDE_FROM_ABI __deque_block_range operator*() const _NOEXCEPT {
1005501 if (__pos_.__m_iter_ == __end_.__m_iter_) {
1006 __pos_ = __end_;
1007 } else {
1008 ++__pos_.__m_iter_;
1009 __pos_.__ptr_ = *__pos_.__m_iter_;
1010 }
1011 return *this;
1012 }
1013
1014
1015 friend bool operator==(__deque_range const& __lhs, __deque_range const& __rhs) {
1016 return __lhs.__pos_ == __rhs.__pos_;
502 return __deque_block_range(__pos_.__ptr_, __end_.__ptr_);
1017503 }
1018 friend bool operator!=(__deque_range const& __lhs, __deque_range const& __rhs) {
1019 return !(__lhs == __rhs);
1020 }
1021 };
1022
1023
1024
1025 struct _ConstructTransaction {
1026 _ConstructTransaction(__deque_base* __db, __deque_block_range& __r)
1027 : __pos_(__r.__begin_), __end_(__r.__end_), __begin_(__r.__begin_), __base_(__db) {}
1028
504 return __deque_block_range(__pos_.__ptr_, *__pos_.__m_iter_ + __block_size);
505 }
1029506
1030 ~_ConstructTransaction() {
1031 __base_->size() += (__pos_ - __begin_);
507 _LIBCPP_HIDE_FROM_ABI __deque_range& operator++() _NOEXCEPT {
508 if (__pos_.__m_iter_ == __end_.__m_iter_) {
509 __pos_ = __end_;
510 } else {
511 ++__pos_.__m_iter_;
512 __pos_.__ptr_ = *__pos_.__m_iter_;
1032513 }
1033
1034 pointer __pos_;
1035 const pointer __end_;
1036 private:
1037 const pointer __begin_;
1038 __deque_base * const __base_;
1039 };
1040
1041protected:
1042 __map __map_;
1043 size_type __start_;
1044 __compressed_pair<size_type, allocator_type> __size_;
1045
1046 iterator begin() _NOEXCEPT;
1047 const_iterator begin() const _NOEXCEPT;
1048 iterator end() _NOEXCEPT;
1049 const_iterator end() const _NOEXCEPT;
1050
1051 _LIBCPP_INLINE_VISIBILITY size_type& size() {return __size_.first();}
1052 _LIBCPP_INLINE_VISIBILITY
1053 const size_type& size() const _NOEXCEPT {return __size_.first();}
1054 _LIBCPP_INLINE_VISIBILITY allocator_type& __alloc() {return __size_.second();}
1055 _LIBCPP_INLINE_VISIBILITY
1056 const allocator_type& __alloc() const _NOEXCEPT {return __size_.second();}
1057
1058 _LIBCPP_INLINE_VISIBILITY
1059 __deque_base()
1060 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
1061 _LIBCPP_INLINE_VISIBILITY
1062 explicit __deque_base(const allocator_type& __a);
1063public:
1064 ~__deque_base();
1065
1066#ifndef _LIBCPP_CXX03_LANG
1067 __deque_base(__deque_base&& __c)
1068 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
1069 __deque_base(__deque_base&& __c, const allocator_type& __a);
1070#endif // _LIBCPP_CXX03_LANG
1071
1072 void swap(__deque_base& __c)
1073#if _LIBCPP_STD_VER >= 14
1074 _NOEXCEPT;
1075#else
1076 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
1077 __is_nothrow_swappable<allocator_type>::value);
1078#endif
1079protected:
1080 void clear() _NOEXCEPT;
1081
1082 bool __invariants() const;
1083
1084 _LIBCPP_INLINE_VISIBILITY
1085 void __move_assign(__deque_base& __c)
1086 _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value &&
1087 is_nothrow_move_assignable<allocator_type>::value)
1088 {
1089 __map_ = _VSTD::move(__c.__map_);
1090 __start_ = __c.__start_;
1091 size() = __c.size();
1092 __move_assign_alloc(__c);
1093 __c.__start_ = __c.size() = 0;
514 return *this;
1094515 }
1095516
1096 _LIBCPP_INLINE_VISIBILITY
1097 void __move_assign_alloc(__deque_base& __c)
1098 _NOEXCEPT_(!__alloc_traits::propagate_on_container_move_assignment::value ||
1099 is_nothrow_move_assignable<allocator_type>::value)
1100 {__move_assign_alloc(__c, integral_constant<bool,
1101 __alloc_traits::propagate_on_container_move_assignment::value>());}
1102517
1103private:
1104 _LIBCPP_INLINE_VISIBILITY
1105 void __move_assign_alloc(__deque_base& __c, true_type)
1106 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
1107 {
1108 __alloc() = _VSTD::move(__c.__alloc());
1109 }
1110
1111 _LIBCPP_INLINE_VISIBILITY
1112 void __move_assign_alloc(__deque_base&, false_type) _NOEXCEPT
1113 {}
1114};
1115
1116template <class _Tp, class _Allocator>
1117const typename __deque_base<_Tp, _Allocator>::difference_type
1118 __deque_base<_Tp, _Allocator>::__block_size =
1119 __deque_block_size<value_type, difference_type>::value;
1120
1121template <class _Tp, class _Allocator>
1122bool
1123__deque_base<_Tp, _Allocator>::__invariants() const
1124{
1125 if (!__map_.__invariants())
1126 return false;
1127 if (__map_.size() >= size_type(-1) / __block_size)
1128 return false;
1129 for (typename __map::const_iterator __i = __map_.begin(), __e = __map_.end();
1130 __i != __e; ++__i)
1131 if (*__i == nullptr)
1132 return false;
1133 if (__map_.size() != 0)
1134 {
1135 if (size() >= __map_.size() * __block_size)
1136 return false;
1137 if (__start_ >= __map_.size() * __block_size - size())
1138 return false;
518 _LIBCPP_HIDE_FROM_ABI friend bool operator==(__deque_range const& __lhs, __deque_range const& __rhs) {
519 return __lhs.__pos_ == __rhs.__pos_;
1139520 }
1140 else
1141 {
1142 if (size() != 0)
1143 return false;
1144 if (__start_ != 0)
1145 return false;
521 _LIBCPP_HIDE_FROM_ABI friend bool operator!=(__deque_range const& __lhs, __deque_range const& __rhs) {
522 return !(__lhs == __rhs);
1146523 }
1147 return true;
1148}
1149
1150template <class _Tp, class _Allocator>
1151typename __deque_base<_Tp, _Allocator>::iterator
1152__deque_base<_Tp, _Allocator>::begin() _NOEXCEPT
1153{
1154 __map_pointer __mp = __map_.begin() + __start_ / __block_size;
1155 return iterator(__mp, __map_.empty() ? 0 : *__mp + __start_ % __block_size);
1156}
1157
1158template <class _Tp, class _Allocator>
1159typename __deque_base<_Tp, _Allocator>::const_iterator
1160__deque_base<_Tp, _Allocator>::begin() const _NOEXCEPT
1161{
1162 __map_const_pointer __mp = static_cast<__map_const_pointer>(__map_.begin() + __start_ / __block_size);
1163 return const_iterator(__mp, __map_.empty() ? 0 : *__mp + __start_ % __block_size);
1164}
1165
1166template <class _Tp, class _Allocator>
1167typename __deque_base<_Tp, _Allocator>::iterator
1168__deque_base<_Tp, _Allocator>::end() _NOEXCEPT
1169{
1170 size_type __p = size() + __start_;
1171 __map_pointer __mp = __map_.begin() + __p / __block_size;
1172 return iterator(__mp, __map_.empty() ? 0 : *__mp + __p % __block_size);
1173}
1174
1175template <class _Tp, class _Allocator>
1176typename __deque_base<_Tp, _Allocator>::const_iterator
1177__deque_base<_Tp, _Allocator>::end() const _NOEXCEPT
1178{
1179 size_type __p = size() + __start_;
1180 __map_const_pointer __mp = static_cast<__map_const_pointer>(__map_.begin() + __p / __block_size);
1181 return const_iterator(__mp, __map_.empty() ? 0 : *__mp + __p % __block_size);
1182}
1183
1184template <class _Tp, class _Allocator>
1185inline
1186__deque_base<_Tp, _Allocator>::__deque_base()
1187 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
1188 : __start_(0), __size_(0, __default_init_tag()) {}
1189
1190template <class _Tp, class _Allocator>
1191inline
1192__deque_base<_Tp, _Allocator>::__deque_base(const allocator_type& __a)
1193 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) {}
524 };
1194525
1195template <class _Tp, class _Allocator>
1196__deque_base<_Tp, _Allocator>::~__deque_base()
1197{
1198 clear();
1199 typename __map::iterator __i = __map_.begin();
1200 typename __map::iterator __e = __map_.end();
1201 for (; __i != __e; ++__i)
1202 __alloc_traits::deallocate(__alloc(), *__i, __block_size);
1203}
526 struct _ConstructTransaction {
527 _LIBCPP_HIDE_FROM_ABI _ConstructTransaction(deque* __db, __deque_block_range& __r)
528 : __pos_(__r.__begin_), __end_(__r.__end_), __begin_(__r.__begin_), __base_(__db) {}
1204529
1205#ifndef _LIBCPP_CXX03_LANG
1206530
1207template <class _Tp, class _Allocator>
1208__deque_base<_Tp, _Allocator>::__deque_base(__deque_base&& __c)
1209 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
1210 : __map_(_VSTD::move(__c.__map_)),
1211 __start_(_VSTD::move(__c.__start_)),
1212 __size_(_VSTD::move(__c.__size_))
1213{
1214 __c.__start_ = 0;
1215 __c.size() = 0;
1216}
1217
1218template <class _Tp, class _Allocator>
1219__deque_base<_Tp, _Allocator>::__deque_base(__deque_base&& __c, const allocator_type& __a)
1220 : __map_(_VSTD::move(__c.__map_), __pointer_allocator(__a)),
1221 __start_(_VSTD::move(__c.__start_)),
1222 __size_(_VSTD::move(__c.size()), __a)
1223{
1224 if (__a == __c.__alloc())
1225 {
1226 __c.__start_ = 0;
1227 __c.size() = 0;
531 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() {
532 __base_->__size() += (__pos_ - __begin_);
1228533 }
1229 else
1230 {
1231 __map_.clear();
1232 __start_ = 0;
1233 size() = 0;
1234 }
1235}
1236534
1237#endif // _LIBCPP_CXX03_LANG
535 pointer __pos_;
536 const pointer __end_;
537 private:
538 const pointer __begin_;
539 deque* const __base_;
540 };
1238541
1239template <class _Tp, class _Allocator>
1240void
1241__deque_base<_Tp, _Allocator>::swap(__deque_base& __c)
1242#if _LIBCPP_STD_VER >= 14
1243 _NOEXCEPT
1244#else
1245 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
1246 __is_nothrow_swappable<allocator_type>::value)
1247#endif
1248{
1249 __map_.swap(__c.__map_);
1250 _VSTD::swap(__start_, __c.__start_);
1251 _VSTD::swap(size(), __c.size());
1252 _VSTD::__swap_allocator(__alloc(), __c.__alloc());
1253}
542 static const difference_type __block_size;
1254543
1255template <class _Tp, class _Allocator>
1256void
1257__deque_base<_Tp, _Allocator>::clear() _NOEXCEPT
1258{
1259 allocator_type& __a = __alloc();
1260 for (iterator __i = begin(), __e = end(); __i != __e; ++__i)
1261 __alloc_traits::destroy(__a, _VSTD::addressof(*__i));
1262 size() = 0;
1263 while (__map_.size() > 2)
1264 {
1265 __alloc_traits::deallocate(__a, __map_.front(), __block_size);
1266 __map_.pop_front();
1267 }
1268 switch (__map_.size())
1269 {
1270 case 1:
1271 __start_ = __block_size / 2;
1272 break;
1273 case 2:
1274 __start_ = __block_size;
1275 break;
1276 }
1277}
544 __map __map_;
545 size_type __start_;
546 __compressed_pair<size_type, allocator_type> __size_;
1278547
1279template <class _Tp, class _Allocator /*= allocator<_Tp>*/>
1280class _LIBCPP_TEMPLATE_VIS deque
1281 : private __deque_base<_Tp, _Allocator>
1282{
1283548public:
1284 // types:
1285
1286 typedef _Tp value_type;
1287 typedef _Allocator allocator_type;
1288549
1289 static_assert((is_same<typename allocator_type::value_type, value_type>::value),
1290 "Allocator::value_type must be same type as value_type");
1291
1292 typedef __deque_base<value_type, allocator_type> __base;
1293
1294 typedef typename __base::__alloc_traits __alloc_traits;
1295 typedef typename __base::reference reference;
1296 typedef typename __base::const_reference const_reference;
1297 typedef typename __base::iterator iterator;
1298 typedef typename __base::const_iterator const_iterator;
1299 typedef typename __base::size_type size_type;
1300 typedef typename __base::difference_type difference_type;
550 // construct/copy/destroy:
551 _LIBCPP_HIDE_FROM_ABI
552 deque() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
553 : __start_(0), __size_(0, __default_init_tag()) {}
1301554
1302 typedef typename __base::pointer pointer;
1303 typedef typename __base::const_pointer const_pointer;
1304 typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
1305 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
555 _LIBCPP_HIDE_FROM_ABI ~deque() {
556 clear();
557 typename __map::iterator __i = __map_.begin();
558 typename __map::iterator __e = __map_.end();
559 for (; __i != __e; ++__i)
560 __alloc_traits::deallocate(__alloc(), *__i, __block_size);
561 }
1306562
1307 using typename __base::__deque_range;
1308 using typename __base::__deque_block_range;
1309 using typename __base::_ConstructTransaction;
563 _LIBCPP_HIDE_FROM_ABI explicit deque(const allocator_type& __a)
564 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) {}
1310565
1311 // construct/copy/destroy:
1312 _LIBCPP_INLINE_VISIBILITY
1313 deque()
1314 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
1315 {}
1316 _LIBCPP_INLINE_VISIBILITY explicit deque(const allocator_type& __a) : __base(__a) {}
1317 explicit deque(size_type __n);
566 explicit _LIBCPP_HIDE_FROM_ABI deque(size_type __n);
1318567#if _LIBCPP_STD_VER > 11
1319 explicit deque(size_type __n, const _Allocator& __a);
568 explicit _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const _Allocator& __a);
1320569#endif
1321 deque(size_type __n, const value_type& __v);
570 _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v);
1322571
1323572 template <class = __enable_if_t<__is_allocator<_Allocator>::value> >
1324 deque(size_type __n, const value_type& __v, const allocator_type& __a) : __base(__a)
573 _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v, const allocator_type& __a)
574 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a)
1325575 {
1326576 if (__n > 0)
1327577 __append(__n, __v);
1328578 }
1329579
1330580 template <class _InputIter>
1331 deque(_InputIter __f, _InputIter __l,
581 _LIBCPP_HIDE_FROM_ABI deque(_InputIter __f, _InputIter __l,
1332582 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type* = 0);
1333583 template <class _InputIter>
1334 deque(_InputIter __f, _InputIter __l, const allocator_type& __a,
584 _LIBCPP_HIDE_FROM_ABI deque(_InputIter __f, _InputIter __l, const allocator_type& __a,
1335585 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type* = 0);
1336 deque(const deque& __c);
1337 deque(const deque& __c, const __type_identity_t<allocator_type>& __a);
586 _LIBCPP_HIDE_FROM_ABI deque(const deque& __c);
587 _LIBCPP_HIDE_FROM_ABI deque(const deque& __c, const __type_identity_t<allocator_type>& __a);
1338588
1339 deque& operator=(const deque& __c);
589 _LIBCPP_HIDE_FROM_ABI deque& operator=(const deque& __c);
1340590
1341591#ifndef _LIBCPP_CXX03_LANG
1342 deque(initializer_list<value_type> __il);
1343 deque(initializer_list<value_type> __il, const allocator_type& __a);
592 _LIBCPP_HIDE_FROM_ABI deque(initializer_list<value_type> __il);
593 _LIBCPP_HIDE_FROM_ABI deque(initializer_list<value_type> __il, const allocator_type& __a);
1344594
1345 _LIBCPP_INLINE_VISIBILITY
595 _LIBCPP_HIDE_FROM_ABI
1346596 deque& operator=(initializer_list<value_type> __il) {assign(__il); return *this;}
1347597
1348 _LIBCPP_INLINE_VISIBILITY
1349 deque(deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value);
1350 _LIBCPP_INLINE_VISIBILITY
598 _LIBCPP_HIDE_FROM_ABI
599 deque(deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
600 _LIBCPP_HIDE_FROM_ABI
1351601 deque(deque&& __c, const __type_identity_t<allocator_type>& __a);
1352 _LIBCPP_INLINE_VISIBILITY
602 _LIBCPP_HIDE_FROM_ABI
1353603 deque& operator=(deque&& __c)
1354604 _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value &&
1355605 is_nothrow_move_assignable<allocator_type>::value);
1356606
1357 _LIBCPP_INLINE_VISIBILITY
607 _LIBCPP_HIDE_FROM_ABI
1358608 void assign(initializer_list<value_type> __il) {assign(__il.begin(), __il.end());}
1359609#endif // _LIBCPP_CXX03_LANG
1360610
1361611 template <class _InputIter>
1362 void assign(_InputIter __f, _InputIter __l,
612 _LIBCPP_HIDE_FROM_ABI void assign(_InputIter __f, _InputIter __l,
1363613 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value &&
1364614 !__is_cpp17_random_access_iterator<_InputIter>::value>::type* = 0);
1365615 template <class _RAIter>
1366 void assign(_RAIter __f, _RAIter __l,
616 _LIBCPP_HIDE_FROM_ABI void assign(_RAIter __f, _RAIter __l,
1367617 typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type* = 0);
1368 void assign(size_type __n, const value_type& __v);
618 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __v);
1369619
1370 _LIBCPP_INLINE_VISIBILITY
620 _LIBCPP_HIDE_FROM_ABI
1371621 allocator_type get_allocator() const _NOEXCEPT;
1372
1373 // iterators:
1374
1375 _LIBCPP_INLINE_VISIBILITY
1376 iterator begin() _NOEXCEPT {return __base::begin();}
1377 _LIBCPP_INLINE_VISIBILITY
1378 const_iterator begin() const _NOEXCEPT {return __base::begin();}
1379 _LIBCPP_INLINE_VISIBILITY
1380 iterator end() _NOEXCEPT {return __base::end();}
1381 _LIBCPP_INLINE_VISIBILITY
1382 const_iterator end() const _NOEXCEPT {return __base::end();}
1383
1384 _LIBCPP_INLINE_VISIBILITY
622 _LIBCPP_HIDE_FROM_ABI allocator_type& __alloc() _NOEXCEPT { return __size_.second(); }
623 _LIBCPP_HIDE_FROM_ABI const allocator_type& __alloc() const _NOEXCEPT { return __size_.second(); }
624
625 // iterators:
626
627 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT {
628 __map_pointer __mp = __map_.begin() + __start_ / __block_size;
629 return iterator(__mp, __map_.empty() ? 0 : *__mp + __start_ % __block_size);
630 }
631
632 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT {
633 __map_const_pointer __mp =
634 static_cast<__map_const_pointer>(__map_.begin() + __start_ / __block_size);
635 return const_iterator(__mp, __map_.empty() ? 0 : *__mp + __start_ % __block_size);
636 }
637
638 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT {
639 size_type __p = size() + __start_;
640 __map_pointer __mp = __map_.begin() + __p / __block_size;
641 return iterator(__mp, __map_.empty() ? 0 : *__mp + __p % __block_size);
642 }
643
644 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT {
645 size_type __p = size() + __start_;
646 __map_const_pointer __mp = static_cast<__map_const_pointer>(__map_.begin() + __p / __block_size);
647 return const_iterator(__mp, __map_.empty() ? 0 : *__mp + __p % __block_size);
648 }
649
650 _LIBCPP_HIDE_FROM_ABI
1385651 reverse_iterator rbegin() _NOEXCEPT
1386 {return reverse_iterator(__base::end());}
1387 _LIBCPP_INLINE_VISIBILITY
652 {return reverse_iterator(end());}
653 _LIBCPP_HIDE_FROM_ABI
1388654 const_reverse_iterator rbegin() const _NOEXCEPT
1389 {return const_reverse_iterator(__base::end());}
1390 _LIBCPP_INLINE_VISIBILITY
655 {return const_reverse_iterator(end());}
656 _LIBCPP_HIDE_FROM_ABI
1391657 reverse_iterator rend() _NOEXCEPT
1392 {return reverse_iterator(__base::begin());}
1393 _LIBCPP_INLINE_VISIBILITY
658 {return reverse_iterator(begin());}
659 _LIBCPP_HIDE_FROM_ABI
1394660 const_reverse_iterator rend() const _NOEXCEPT
1395 {return const_reverse_iterator(__base::begin());}
661 {return const_reverse_iterator(begin());}
1396662
1397 _LIBCPP_INLINE_VISIBILITY
663 _LIBCPP_HIDE_FROM_ABI
1398664 const_iterator cbegin() const _NOEXCEPT
1399 {return __base::begin();}
1400 _LIBCPP_INLINE_VISIBILITY
665 {return begin();}
666 _LIBCPP_HIDE_FROM_ABI
1401667 const_iterator cend() const _NOEXCEPT
1402 {return __base::end();}
1403 _LIBCPP_INLINE_VISIBILITY
668 {return end();}
669 _LIBCPP_HIDE_FROM_ABI
1404670 const_reverse_iterator crbegin() const _NOEXCEPT
1405 {return const_reverse_iterator(__base::end());}
1406 _LIBCPP_INLINE_VISIBILITY
671 {return const_reverse_iterator(end());}
672 _LIBCPP_HIDE_FROM_ABI
1407673 const_reverse_iterator crend() const _NOEXCEPT
1408 {return const_reverse_iterator(__base::begin());}
674 {return const_reverse_iterator(begin());}
1409675
1410676 // capacity:
1411 _LIBCPP_INLINE_VISIBILITY
1412 size_type size() const _NOEXCEPT {return __base::size();}
1413 _LIBCPP_INLINE_VISIBILITY
677 _LIBCPP_HIDE_FROM_ABI
678 size_type size() const _NOEXCEPT {return __size();}
679
680 _LIBCPP_HIDE_FROM_ABI size_type& __size() _NOEXCEPT { return __size_.first(); }
681 _LIBCPP_HIDE_FROM_ABI const size_type& __size() const _NOEXCEPT { return __size_.first(); }
682
683 _LIBCPP_HIDE_FROM_ABI
1414684 size_type max_size() const _NOEXCEPT
1415685 {return _VSTD::min<size_type>(
1416 __alloc_traits::max_size(__base::__alloc()),
686 __alloc_traits::max_size(__alloc()),
1417687 numeric_limits<difference_type>::max());}
1418 void resize(size_type __n);
1419 void resize(size_type __n, const value_type& __v);
1420 void shrink_to_fit() _NOEXCEPT;
1421 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
1422 bool empty() const _NOEXCEPT {return __base::size() == 0;}
688 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n);
689 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __v);
690 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT;
691 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
692 bool empty() const _NOEXCEPT {return size() == 0;}
1423693
1424694 // element access:
1425 _LIBCPP_INLINE_VISIBILITY
695 _LIBCPP_HIDE_FROM_ABI
1426696 reference operator[](size_type __i) _NOEXCEPT;
1427 _LIBCPP_INLINE_VISIBILITY
697 _LIBCPP_HIDE_FROM_ABI
1428698 const_reference operator[](size_type __i) const _NOEXCEPT;
1429 _LIBCPP_INLINE_VISIBILITY
699 _LIBCPP_HIDE_FROM_ABI
1430700 reference at(size_type __i);
1431 _LIBCPP_INLINE_VISIBILITY
701 _LIBCPP_HIDE_FROM_ABI
1432702 const_reference at(size_type __i) const;
1433 _LIBCPP_INLINE_VISIBILITY
703 _LIBCPP_HIDE_FROM_ABI
1434704 reference front() _NOEXCEPT;
1435 _LIBCPP_INLINE_VISIBILITY
705 _LIBCPP_HIDE_FROM_ABI
1436706 const_reference front() const _NOEXCEPT;
1437 _LIBCPP_INLINE_VISIBILITY
707 _LIBCPP_HIDE_FROM_ABI
1438708 reference back() _NOEXCEPT;
1439 _LIBCPP_INLINE_VISIBILITY
709 _LIBCPP_HIDE_FROM_ABI
1440710 const_reference back() const _NOEXCEPT;
1441711
1442712 // 23.2.2.3 modifiers:
1443 void push_front(const value_type& __v);
1444 void push_back(const value_type& __v);
713 _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __v);
714 _LIBCPP_HIDE_FROM_ABI void push_back(const value_type& __v);
1445715#ifndef _LIBCPP_CXX03_LANG
1446716#if _LIBCPP_STD_VER > 14
1447 template <class... _Args> reference emplace_front(_Args&&... __args);
1448 template <class... _Args> reference emplace_back (_Args&&... __args);
717 template <class... _Args> _LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args);
718 template <class... _Args> _LIBCPP_HIDE_FROM_ABI reference emplace_back (_Args&&... __args);
1449719#else
1450 template <class... _Args> void emplace_front(_Args&&... __args);
1451 template <class... _Args> void emplace_back (_Args&&... __args);
720 template <class... _Args> _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args);
721 template <class... _Args> _LIBCPP_HIDE_FROM_ABI void emplace_back (_Args&&... __args);
1452722#endif
1453 template <class... _Args> iterator emplace(const_iterator __p, _Args&&... __args);
723 template <class... _Args> _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __p, _Args&&... __args);
1454724
1455 void push_front(value_type&& __v);
1456 void push_back(value_type&& __v);
1457 iterator insert(const_iterator __p, value_type&& __v);
725 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __v);
726 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __v);
727 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v);
1458728
1459 _LIBCPP_INLINE_VISIBILITY
729 _LIBCPP_HIDE_FROM_ABI
1460730 iterator insert(const_iterator __p, initializer_list<value_type> __il)
1461731 {return insert(__p, __il.begin(), __il.end());}
1462732#endif // _LIBCPP_CXX03_LANG
1463 iterator insert(const_iterator __p, const value_type& __v);
1464 iterator insert(const_iterator __p, size_type __n, const value_type& __v);
733 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v);
734 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, size_type __n, const value_type& __v);
1465735 template <class _InputIter>
1466 iterator insert(const_iterator __p, _InputIter __f, _InputIter __l,
736 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _InputIter __f, _InputIter __l,
1467737 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIter>::value>::type* = 0);
1468738 template <class _ForwardIterator>
1469 iterator insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l,
739 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l,
1470740 typename enable_if<__is_exactly_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);
1471741 template <class _BiIter>
1472 iterator insert(const_iterator __p, _BiIter __f, _BiIter __l,
742 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _BiIter __f, _BiIter __l,
1473743 typename enable_if<__is_cpp17_bidirectional_iterator<_BiIter>::value>::type* = 0);
1474744
1475 void pop_front();
1476 void pop_back();
1477 iterator erase(const_iterator __p);
1478 iterator erase(const_iterator __f, const_iterator __l);
745 _LIBCPP_HIDE_FROM_ABI void pop_front();
746 _LIBCPP_HIDE_FROM_ABI void pop_back();
747 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p);
748 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l);
1479749
1480 _LIBCPP_INLINE_VISIBILITY
750 _LIBCPP_HIDE_FROM_ABI
1481751 void swap(deque& __c)
1482752#if _LIBCPP_STD_VER >= 14
1483753 _NOEXCEPT;
......@@ -1485,121 +755,177 @@ public:
1485755 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
1486756 __is_nothrow_swappable<allocator_type>::value);
1487757#endif
1488 _LIBCPP_INLINE_VISIBILITY
758 _LIBCPP_HIDE_FROM_ABI
1489759 void clear() _NOEXCEPT;
1490760
1491 _LIBCPP_INLINE_VISIBILITY
1492 bool __invariants() const {return __base::__invariants();}
761 _LIBCPP_HIDE_FROM_ABI
762 bool __invariants() const {
763 if (!__map_.__invariants())
764 return false;
765 if (__map_.size() >= size_type(-1) / __block_size)
766 return false;
767 for (typename __map::const_iterator __i = __map_.begin(), __e = __map_.end();
768 __i != __e; ++__i)
769 if (*__i == nullptr)
770 return false;
771 if (__map_.size() != 0)
772 {
773 if (size() >= __map_.size() * __block_size)
774 return false;
775 if (__start_ >= __map_.size() * __block_size - size())
776 return false;
777 }
778 else
779 {
780 if (size() != 0)
781 return false;
782 if (__start_ != 0)
783 return false;
784 }
785 return true;
786 }
1493787
1494 typedef typename __base::__map_const_pointer __map_const_pointer;
788 _LIBCPP_HIDE_FROM_ABI
789 void __move_assign_alloc(deque& __c)
790 _NOEXCEPT_(!__alloc_traits::propagate_on_container_move_assignment::value ||
791 is_nothrow_move_assignable<allocator_type>::value)
792 {__move_assign_alloc(__c, integral_constant<bool,
793 __alloc_traits::propagate_on_container_move_assignment::value>());}
794
795 _LIBCPP_HIDE_FROM_ABI
796 void __move_assign_alloc(deque& __c, true_type)
797 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
798 {
799 __alloc() = _VSTD::move(__c.__alloc());
800 }
801
802 _LIBCPP_HIDE_FROM_ABI
803 void __move_assign_alloc(deque&, false_type) _NOEXCEPT
804 {}
805
806 _LIBCPP_HIDE_FROM_ABI
807 void __move_assign(deque& __c)
808 _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value &&
809 is_nothrow_move_assignable<allocator_type>::value)
810 {
811 __map_ = _VSTD::move(__c.__map_);
812 __start_ = __c.__start_;
813 __size() = __c.size();
814 __move_assign_alloc(__c);
815 __c.__start_ = __c.__size() = 0;
816 }
1495817
1496 _LIBCPP_INLINE_VISIBILITY
818 _LIBCPP_HIDE_FROM_ABI
1497819 static size_type __recommend_blocks(size_type __n)
1498820 {
1499 return __n / __base::__block_size + (__n % __base::__block_size != 0);
821 return __n / __block_size + (__n % __block_size != 0);
1500822 }
1501 _LIBCPP_INLINE_VISIBILITY
823 _LIBCPP_HIDE_FROM_ABI
1502824 size_type __capacity() const
1503825 {
1504 return __base::__map_.size() == 0 ? 0 : __base::__map_.size() * __base::__block_size - 1;
826 return __map_.size() == 0 ? 0 : __map_.size() * __block_size - 1;
1505827 }
1506 _LIBCPP_INLINE_VISIBILITY
828 _LIBCPP_HIDE_FROM_ABI
1507829 size_type __block_count() const
1508830 {
1509 return __base::__map_.size();
831 return __map_.size();
1510832 }
1511833
1512 _LIBCPP_INLINE_VISIBILITY
834 _LIBCPP_HIDE_FROM_ABI
1513835 size_type __front_spare() const
1514836 {
1515 return __base::__start_;
837 return __start_;
1516838 }
1517 _LIBCPP_INLINE_VISIBILITY
839 _LIBCPP_HIDE_FROM_ABI
1518840 size_type __front_spare_blocks() const {
1519 return __front_spare() / __base::__block_size;
841 return __front_spare() / __block_size;
1520842 }
1521 _LIBCPP_INLINE_VISIBILITY
843 _LIBCPP_HIDE_FROM_ABI
1522844 size_type __back_spare() const
1523845 {
1524 return __capacity() - (__base::__start_ + __base::size());
846 return __capacity() - (__start_ + size());
1525847 }
1526 _LIBCPP_INLINE_VISIBILITY
848 _LIBCPP_HIDE_FROM_ABI
1527849 size_type __back_spare_blocks() const {
1528 return __back_spare() / __base::__block_size;
850 return __back_spare() / __block_size;
1529851 }
1530852
1531853 private:
1532 _LIBCPP_INLINE_VISIBILITY
854 _LIBCPP_HIDE_FROM_ABI
1533855 bool __maybe_remove_front_spare(bool __keep_one = true) {
1534856 if (__front_spare_blocks() >= 2 || (!__keep_one && __front_spare_blocks())) {
1535 __alloc_traits::deallocate(__base::__alloc(), __base::__map_.front(),
1536 __base::__block_size);
1537 __base::__map_.pop_front();
1538 __base::__start_ -= __base::__block_size;
857 __alloc_traits::deallocate(__alloc(), __map_.front(),
858 __block_size);
859 __map_.pop_front();
860 __start_ -= __block_size;
1539861 return true;
1540862 }
1541863 return false;
1542864 }
1543865
1544 _LIBCPP_INLINE_VISIBILITY
866 _LIBCPP_HIDE_FROM_ABI
1545867 bool __maybe_remove_back_spare(bool __keep_one = true) {
1546868 if (__back_spare_blocks() >= 2 || (!__keep_one && __back_spare_blocks())) {
1547 __alloc_traits::deallocate(__base::__alloc(), __base::__map_.back(),
1548 __base::__block_size);
1549 __base::__map_.pop_back();
869 __alloc_traits::deallocate(__alloc(), __map_.back(),
870 __block_size);
871 __map_.pop_back();
1550872 return true;
1551873 }
1552874 return false;
1553875 }
1554876
1555877 template <class _InpIter>
1556 void __append(_InpIter __f, _InpIter __l,
878 _LIBCPP_HIDE_FROM_ABI void __append(_InpIter __f, _InpIter __l,
1557879 typename enable_if<__is_exactly_cpp17_input_iterator<_InpIter>::value>::type* = 0);
1558880 template <class _ForIter>
1559 void __append(_ForIter __f, _ForIter __l,
881 _LIBCPP_HIDE_FROM_ABI void __append(_ForIter __f, _ForIter __l,
1560882 typename enable_if<__is_cpp17_forward_iterator<_ForIter>::value>::type* = 0);
1561 void __append(size_type __n);
1562 void __append(size_type __n, const value_type& __v);
1563 void __erase_to_end(const_iterator __f);
1564 void __add_front_capacity();
1565 void __add_front_capacity(size_type __n);
1566 void __add_back_capacity();
1567 void __add_back_capacity(size_type __n);
1568 iterator __move_and_check(iterator __f, iterator __l, iterator __r,
883 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n);
884 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n, const value_type& __v);
885 _LIBCPP_HIDE_FROM_ABI void __erase_to_end(const_iterator __f);
886 _LIBCPP_HIDE_FROM_ABI void __add_front_capacity();
887 _LIBCPP_HIDE_FROM_ABI void __add_front_capacity(size_type __n);
888 _LIBCPP_HIDE_FROM_ABI void __add_back_capacity();
889 _LIBCPP_HIDE_FROM_ABI void __add_back_capacity(size_type __n);
890 _LIBCPP_HIDE_FROM_ABI iterator __move_and_check(iterator __f, iterator __l, iterator __r,
1569891 const_pointer& __vt);
1570 iterator __move_backward_and_check(iterator __f, iterator __l, iterator __r,
892 _LIBCPP_HIDE_FROM_ABI iterator __move_backward_and_check(iterator __f, iterator __l, iterator __r,
1571893 const_pointer& __vt);
1572 void __move_construct_and_check(iterator __f, iterator __l,
894 _LIBCPP_HIDE_FROM_ABI void __move_construct_and_check(iterator __f, iterator __l,
1573895 iterator __r, const_pointer& __vt);
1574 void __move_construct_backward_and_check(iterator __f, iterator __l,
896 _LIBCPP_HIDE_FROM_ABI void __move_construct_backward_and_check(iterator __f, iterator __l,
1575897 iterator __r, const_pointer& __vt);
1576898
1577 _LIBCPP_INLINE_VISIBILITY
899 _LIBCPP_HIDE_FROM_ABI
1578900 void __copy_assign_alloc(const deque& __c)
1579901 {__copy_assign_alloc(__c, integral_constant<bool,
1580902 __alloc_traits::propagate_on_container_copy_assignment::value>());}
1581903
1582 _LIBCPP_INLINE_VISIBILITY
904 _LIBCPP_HIDE_FROM_ABI
1583905 void __copy_assign_alloc(const deque& __c, true_type)
1584906 {
1585 if (__base::__alloc() != __c.__alloc())
907 if (__alloc() != __c.__alloc())
1586908 {
1587909 clear();
1588910 shrink_to_fit();
1589911 }
1590 __base::__alloc() = __c.__alloc();
1591 __base::__map_.__alloc() = __c.__map_.__alloc();
912 __alloc() = __c.__alloc();
913 __map_.__alloc() = __c.__map_.__alloc();
1592914 }
1593915
1594 _LIBCPP_INLINE_VISIBILITY
916 _LIBCPP_HIDE_FROM_ABI
1595917 void __copy_assign_alloc(const deque&, false_type)
1596918 {}
1597919
1598 void __move_assign(deque& __c, true_type)
920 _LIBCPP_HIDE_FROM_ABI void __move_assign(deque& __c, true_type)
1599921 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
1600 void __move_assign(deque& __c, false_type);
922 _LIBCPP_HIDE_FROM_ABI void __move_assign(deque& __c, false_type);
1601923};
1602924
925template <class _Tp, class _Alloc>
926_LIBCPP_CONSTEXPR const typename allocator_traits<_Alloc>::difference_type deque<_Tp, _Alloc>::__block_size =
927 __deque_block_size<value_type, difference_type>::value;
928
1603929#if _LIBCPP_STD_VER >= 17
1604930template<class _InputIterator,
1605931 class _Alloc = allocator<__iter_value_type<_InputIterator>>,
......@@ -1620,6 +946,7 @@ deque(_InputIterator, _InputIterator, _Alloc)
1620946
1621947template <class _Tp, class _Allocator>
1622948deque<_Tp, _Allocator>::deque(size_type __n)
949 : __start_(0), __size_(0, __default_init_tag())
1623950{
1624951 if (__n > 0)
1625952 __append(__n);
......@@ -1628,7 +955,7 @@ deque<_Tp, _Allocator>::deque(size_type __n)
1628955#if _LIBCPP_STD_VER > 11
1629956template <class _Tp, class _Allocator>
1630957deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a)
1631 : __base(__a)
958 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a)
1632959{
1633960 if (__n > 0)
1634961 __append(__n);
......@@ -1637,6 +964,7 @@ deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a)
1637964
1638965template <class _Tp, class _Allocator>
1639966deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v)
967 : __start_(0), __size_(0, __default_init_tag())
1640968{
1641969 if (__n > 0)
1642970 __append(__n, __v);
......@@ -1646,6 +974,7 @@ template <class _Tp, class _Allocator>
1646974template <class _InputIter>
1647975deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l,
1648976 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type*)
977 : __start_(0), __size_(0, __default_init_tag())
1649978{
1650979 __append(__f, __l);
1651980}
......@@ -1654,21 +983,23 @@ template <class _Tp, class _Allocator>
1654983template <class _InputIter>
1655984deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l, const allocator_type& __a,
1656985 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type*)
1657 : __base(__a)
986 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a)
1658987{
1659988 __append(__f, __l);
1660989}
1661990
1662991template <class _Tp, class _Allocator>
1663992deque<_Tp, _Allocator>::deque(const deque& __c)
1664 : __base(__alloc_traits::select_on_container_copy_construction(__c.__alloc()))
993 : __map_(__pointer_allocator(__alloc_traits::select_on_container_copy_construction(__c.__alloc()))),
994 __start_(0),
995 __size_(0, __map_.__alloc())
1665996{
1666997 __append(__c.begin(), __c.end());
1667998}
1668999
16691000template <class _Tp, class _Allocator>
16701001deque<_Tp, _Allocator>::deque(const deque& __c, const __type_identity_t<allocator_type>& __a)
1671 : __base(__a)
1002 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a)
16721003{
16731004 __append(__c.begin(), __c.end());
16741005}
......@@ -1689,13 +1020,14 @@ deque<_Tp, _Allocator>::operator=(const deque& __c)
16891020
16901021template <class _Tp, class _Allocator>
16911022deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il)
1023 : __start_(0), __size_(0, __default_init_tag())
16921024{
16931025 __append(__il.begin(), __il.end());
16941026}
16951027
16961028template <class _Tp, class _Allocator>
16971029deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il, const allocator_type& __a)
1698 : __base(__a)
1030 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a)
16991031{
17001032 __append(__il.begin(), __il.end());
17011033}
......@@ -1703,18 +1035,30 @@ deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il, const allocator
17031035template <class _Tp, class _Allocator>
17041036inline
17051037deque<_Tp, _Allocator>::deque(deque&& __c)
1706 _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
1707 : __base(_VSTD::move(__c))
1038 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
1039 : __map_(std::move(__c.__map_)), __start_(std::move(__c.__start_)), __size_(std::move(__c.__size_))
17081040{
1041 __c.__start_ = 0;
1042 __c.__size() = 0;
17091043}
17101044
17111045template <class _Tp, class _Allocator>
17121046inline
17131047deque<_Tp, _Allocator>::deque(deque&& __c, const __type_identity_t<allocator_type>& __a)
1714 : __base(_VSTD::move(__c), __a)
1048 : __map_(std::move(__c.__map_), __pointer_allocator(__a)),
1049 __start_(std::move(__c.__start_)),
1050 __size_(std::move(__c.__size()), __a)
17151051{
1716 if (__a != __c.__alloc())
1052 if (__a == __c.__alloc())
17171053 {
1054 __c.__start_ = 0;
1055 __c.__size() = 0;
1056 }
1057 else
1058 {
1059 __map_.clear();
1060 __start_ = 0;
1061 __size() = 0;
17181062 typedef move_iterator<iterator> _Ip;
17191063 assign(_Ip(__c.begin()), _Ip(__c.end()));
17201064 }
......@@ -1736,7 +1080,7 @@ template <class _Tp, class _Allocator>
17361080void
17371081deque<_Tp, _Allocator>::__move_assign(deque& __c, false_type)
17381082{
1739 if (__base::__alloc() != __c.__alloc())
1083 if (__alloc() != __c.__alloc())
17401084 {
17411085 typedef move_iterator<iterator> _Ip;
17421086 assign(_Ip(__c.begin()), _Ip(__c.end()));
......@@ -1752,7 +1096,7 @@ deque<_Tp, _Allocator>::__move_assign(deque& __c, true_type)
17521096{
17531097 clear();
17541098 shrink_to_fit();
1755 __base::__move_assign(__c);
1099 __move_assign(__c);
17561100}
17571101
17581102#endif // _LIBCPP_CXX03_LANG
......@@ -1764,8 +1108,8 @@ deque<_Tp, _Allocator>::assign(_InputIter __f, _InputIter __l,
17641108 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value &&
17651109 !__is_cpp17_random_access_iterator<_InputIter>::value>::type*)
17661110{
1767 iterator __i = __base::begin();
1768 iterator __e = __base::end();
1111 iterator __i = begin();
1112 iterator __e = end();
17691113 for (; __f != __l && __i != __e; ++__f, (void) ++__i)
17701114 *__i = *__f;
17711115 if (__f != __l)
......@@ -1780,28 +1124,28 @@ void
17801124deque<_Tp, _Allocator>::assign(_RAIter __f, _RAIter __l,
17811125 typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*)
17821126{
1783 if (static_cast<size_type>(__l - __f) > __base::size())
1127 if (static_cast<size_type>(__l - __f) > size())
17841128 {
1785 _RAIter __m = __f + __base::size();
1786 _VSTD::copy(__f, __m, __base::begin());
1129 _RAIter __m = __f + size();
1130 _VSTD::copy(__f, __m, begin());
17871131 __append(__m, __l);
17881132 }
17891133 else
1790 __erase_to_end(_VSTD::copy(__f, __l, __base::begin()));
1134 __erase_to_end(_VSTD::copy(__f, __l, begin()));
17911135}
17921136
17931137template <class _Tp, class _Allocator>
17941138void
17951139deque<_Tp, _Allocator>::assign(size_type __n, const value_type& __v)
17961140{
1797 if (__n > __base::size())
1141 if (__n > size())
17981142 {
1799 _VSTD::fill_n(__base::begin(), __base::size(), __v);
1800 __n -= __base::size();
1143 _VSTD::fill_n(begin(), size(), __v);
1144 __n -= size();
18011145 __append(__n, __v);
18021146 }
18031147 else
1804 __erase_to_end(_VSTD::fill_n(__base::begin(), __n, __v));
1148 __erase_to_end(_VSTD::fill_n(begin(), __n, __v));
18051149}
18061150
18071151template <class _Tp, class _Allocator>
......@@ -1809,49 +1153,49 @@ inline
18091153_Allocator
18101154deque<_Tp, _Allocator>::get_allocator() const _NOEXCEPT
18111155{
1812 return __base::__alloc();
1156 return __alloc();
18131157}
18141158
18151159template <class _Tp, class _Allocator>
18161160void
18171161deque<_Tp, _Allocator>::resize(size_type __n)
18181162{
1819 if (__n > __base::size())
1820 __append(__n - __base::size());
1821 else if (__n < __base::size())
1822 __erase_to_end(__base::begin() + __n);
1163 if (__n > size())
1164 __append(__n - size());
1165 else if (__n < size())
1166 __erase_to_end(begin() + __n);
18231167}
18241168
18251169template <class _Tp, class _Allocator>
18261170void
18271171deque<_Tp, _Allocator>::resize(size_type __n, const value_type& __v)
18281172{
1829 if (__n > __base::size())
1830 __append(__n - __base::size(), __v);
1831 else if (__n < __base::size())
1832 __erase_to_end(__base::begin() + __n);
1173 if (__n > size())
1174 __append(__n - size(), __v);
1175 else if (__n < size())
1176 __erase_to_end(begin() + __n);
18331177}
18341178
18351179template <class _Tp, class _Allocator>
18361180void
18371181deque<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
18381182{
1839 allocator_type& __a = __base::__alloc();
1183 allocator_type& __a = __alloc();
18401184 if (empty())
18411185 {
1842 while (__base::__map_.size() > 0)
1186 while (__map_.size() > 0)
18431187 {
1844 __alloc_traits::deallocate(__a, __base::__map_.back(), __base::__block_size);
1845 __base::__map_.pop_back();
1188 __alloc_traits::deallocate(__a, __map_.back(), __block_size);
1189 __map_.pop_back();
18461190 }
1847 __base::__start_ = 0;
1191 __start_ = 0;
18481192 }
18491193 else
18501194 {
18511195 __maybe_remove_front_spare(/*__keep_one=*/false);
18521196 __maybe_remove_back_spare(/*__keep_one=*/false);
18531197 }
1854 __base::__map_.shrink_to_fit();
1198 __map_.shrink_to_fit();
18551199}
18561200
18571201template <class _Tp, class _Allocator>
......@@ -1859,8 +1203,8 @@ inline
18591203typename deque<_Tp, _Allocator>::reference
18601204deque<_Tp, _Allocator>::operator[](size_type __i) _NOEXCEPT
18611205{
1862 size_type __p = __base::__start_ + __i;
1863 return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
1206 size_type __p = __start_ + __i;
1207 return *(*(__map_.begin() + __p / __block_size) + __p % __block_size);
18641208}
18651209
18661210template <class _Tp, class _Allocator>
......@@ -1868,8 +1212,8 @@ inline
18681212typename deque<_Tp, _Allocator>::const_reference
18691213deque<_Tp, _Allocator>::operator[](size_type __i) const _NOEXCEPT
18701214{
1871 size_type __p = __base::__start_ + __i;
1872 return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
1215 size_type __p = __start_ + __i;
1216 return *(*(__map_.begin() + __p / __block_size) + __p % __block_size);
18731217}
18741218
18751219template <class _Tp, class _Allocator>
......@@ -1877,10 +1221,10 @@ inline
18771221typename deque<_Tp, _Allocator>::reference
18781222deque<_Tp, _Allocator>::at(size_type __i)
18791223{
1880 if (__i >= __base::size())
1224 if (__i >= size())
18811225 _VSTD::__throw_out_of_range("deque");
1882 size_type __p = __base::__start_ + __i;
1883 return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
1226 size_type __p = __start_ + __i;
1227 return *(*(__map_.begin() + __p / __block_size) + __p % __block_size);
18841228}
18851229
18861230template <class _Tp, class _Allocator>
......@@ -1888,10 +1232,10 @@ inline
18881232typename deque<_Tp, _Allocator>::const_reference
18891233deque<_Tp, _Allocator>::at(size_type __i) const
18901234{
1891 if (__i >= __base::size())
1235 if (__i >= size())
18921236 _VSTD::__throw_out_of_range("deque");
1893 size_type __p = __base::__start_ + __i;
1894 return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
1237 size_type __p = __start_ + __i;
1238 return *(*(__map_.begin() + __p / __block_size) + __p % __block_size);
18951239}
18961240
18971241template <class _Tp, class _Allocator>
......@@ -1899,8 +1243,8 @@ inline
18991243typename deque<_Tp, _Allocator>::reference
19001244deque<_Tp, _Allocator>::front() _NOEXCEPT
19011245{
1902 return *(*(__base::__map_.begin() + __base::__start_ / __base::__block_size)
1903 + __base::__start_ % __base::__block_size);
1246 return *(*(__map_.begin() + __start_ / __block_size)
1247 + __start_ % __block_size);
19041248}
19051249
19061250template <class _Tp, class _Allocator>
......@@ -1908,8 +1252,8 @@ inline
19081252typename deque<_Tp, _Allocator>::const_reference
19091253deque<_Tp, _Allocator>::front() const _NOEXCEPT
19101254{
1911 return *(*(__base::__map_.begin() + __base::__start_ / __base::__block_size)
1912 + __base::__start_ % __base::__block_size);
1255 return *(*(__map_.begin() + __start_ / __block_size)
1256 + __start_ % __block_size);
19131257}
19141258
19151259template <class _Tp, class _Allocator>
......@@ -1917,8 +1261,8 @@ inline
19171261typename deque<_Tp, _Allocator>::reference
19181262deque<_Tp, _Allocator>::back() _NOEXCEPT
19191263{
1920 size_type __p = __base::size() + __base::__start_ - 1;
1921 return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
1264 size_type __p = size() + __start_ - 1;
1265 return *(*(__map_.begin() + __p / __block_size) + __p % __block_size);
19221266}
19231267
19241268template <class _Tp, class _Allocator>
......@@ -1926,33 +1270,33 @@ inline
19261270typename deque<_Tp, _Allocator>::const_reference
19271271deque<_Tp, _Allocator>::back() const _NOEXCEPT
19281272{
1929 size_type __p = __base::size() + __base::__start_ - 1;
1930 return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
1273 size_type __p = size() + __start_ - 1;
1274 return *(*(__map_.begin() + __p / __block_size) + __p % __block_size);
19311275}
19321276
19331277template <class _Tp, class _Allocator>
19341278void
19351279deque<_Tp, _Allocator>::push_back(const value_type& __v)
19361280{
1937 allocator_type& __a = __base::__alloc();
1281 allocator_type& __a = __alloc();
19381282 if (__back_spare() == 0)
19391283 __add_back_capacity();
19401284 // __back_spare() >= 1
1941 __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), __v);
1942 ++__base::size();
1285 __alloc_traits::construct(__a, _VSTD::addressof(*end()), __v);
1286 ++__size();
19431287}
19441288
19451289template <class _Tp, class _Allocator>
19461290void
19471291deque<_Tp, _Allocator>::push_front(const value_type& __v)
19481292{
1949 allocator_type& __a = __base::__alloc();
1293 allocator_type& __a = __alloc();
19501294 if (__front_spare() == 0)
19511295 __add_front_capacity();
19521296 // __front_spare() >= 1
1953 __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), __v);
1954 --__base::__start_;
1955 ++__base::size();
1297 __alloc_traits::construct(__a, _VSTD::addressof(*--begin()), __v);
1298 --__start_;
1299 ++__size();
19561300}
19571301
19581302#ifndef _LIBCPP_CXX03_LANG
......@@ -1960,12 +1304,12 @@ template <class _Tp, class _Allocator>
19601304void
19611305deque<_Tp, _Allocator>::push_back(value_type&& __v)
19621306{
1963 allocator_type& __a = __base::__alloc();
1307 allocator_type& __a = __alloc();
19641308 if (__back_spare() == 0)
19651309 __add_back_capacity();
19661310 // __back_spare() >= 1
1967 __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), _VSTD::move(__v));
1968 ++__base::size();
1311 __alloc_traits::construct(__a, _VSTD::addressof(*end()), _VSTD::move(__v));
1312 ++__size();
19691313}
19701314
19711315template <class _Tp, class _Allocator>
......@@ -1977,15 +1321,15 @@ void
19771321#endif
19781322deque<_Tp, _Allocator>::emplace_back(_Args&&... __args)
19791323{
1980 allocator_type& __a = __base::__alloc();
1324 allocator_type& __a = __alloc();
19811325 if (__back_spare() == 0)
19821326 __add_back_capacity();
19831327 // __back_spare() >= 1
1984 __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()),
1328 __alloc_traits::construct(__a, _VSTD::addressof(*end()),
19851329 _VSTD::forward<_Args>(__args)...);
1986 ++__base::size();
1330 ++__size();
19871331#if _LIBCPP_STD_VER > 14
1988 return *--__base::end();
1332 return *--end();
19891333#endif
19901334}
19911335
......@@ -1993,13 +1337,13 @@ template <class _Tp, class _Allocator>
19931337void
19941338deque<_Tp, _Allocator>::push_front(value_type&& __v)
19951339{
1996 allocator_type& __a = __base::__alloc();
1340 allocator_type& __a = __alloc();
19971341 if (__front_spare() == 0)
19981342 __add_front_capacity();
19991343 // __front_spare() >= 1
2000 __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), _VSTD::move(__v));
2001 --__base::__start_;
2002 ++__base::size();
1344 __alloc_traits::construct(__a, _VSTD::addressof(*--begin()), _VSTD::move(__v));
1345 --__start_;
1346 ++__size();
20031347}
20041348
20051349
......@@ -2012,15 +1356,15 @@ void
20121356#endif
20131357deque<_Tp, _Allocator>::emplace_front(_Args&&... __args)
20141358{
2015 allocator_type& __a = __base::__alloc();
1359 allocator_type& __a = __alloc();
20161360 if (__front_spare() == 0)
20171361 __add_front_capacity();
20181362 // __front_spare() >= 1
2019 __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), _VSTD::forward<_Args>(__args)...);
2020 --__base::__start_;
2021 ++__base::size();
1363 __alloc_traits::construct(__a, _VSTD::addressof(*--begin()), _VSTD::forward<_Args>(__args)...);
1364 --__start_;
1365 ++__size();
20221366#if _LIBCPP_STD_VER > 14
2023 return *__base::begin();
1367 return *begin();
20241368#endif
20251369}
20261370
......@@ -2028,9 +1372,9 @@ template <class _Tp, class _Allocator>
20281372typename deque<_Tp, _Allocator>::iterator
20291373deque<_Tp, _Allocator>::insert(const_iterator __p, value_type&& __v)
20301374{
2031 size_type __pos = __p - __base::begin();
2032 size_type __to_end = __base::size() - __pos;
2033 allocator_type& __a = __base::__alloc();
1375 size_type __pos = __p - begin();
1376 size_type __to_end = size() - __pos;
1377 allocator_type& __a = __alloc();
20341378 if (__pos < __to_end)
20351379 { // insert by shifting things backward
20361380 if (__front_spare() == 0)
......@@ -2038,17 +1382,17 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, value_type&& __v)
20381382 // __front_spare() >= 1
20391383 if (__pos == 0)
20401384 {
2041 __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), _VSTD::move(__v));
2042 --__base::__start_;
2043 ++__base::size();
1385 __alloc_traits::construct(__a, _VSTD::addressof(*--begin()), _VSTD::move(__v));
1386 --__start_;
1387 ++__size();
20441388 }
20451389 else
20461390 {
2047 iterator __b = __base::begin();
1391 iterator __b = begin();
20481392 iterator __bm1 = _VSTD::prev(__b);
20491393 __alloc_traits::construct(__a, _VSTD::addressof(*__bm1), _VSTD::move(*__b));
2050 --__base::__start_;
2051 ++__base::size();
1394 --__start_;
1395 ++__size();
20521396 if (__pos > 1)
20531397 __b = _VSTD::move(_VSTD::next(__b), __b + __pos, __b);
20541398 *__b = _VSTD::move(__v);
......@@ -2059,24 +1403,24 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, value_type&& __v)
20591403 if (__back_spare() == 0)
20601404 __add_back_capacity();
20611405 // __back_capacity >= 1
2062 size_type __de = __base::size() - __pos;
1406 size_type __de = size() - __pos;
20631407 if (__de == 0)
20641408 {
2065 __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), _VSTD::move(__v));
2066 ++__base::size();
1409 __alloc_traits::construct(__a, _VSTD::addressof(*end()), _VSTD::move(__v));
1410 ++__size();
20671411 }
20681412 else
20691413 {
2070 iterator __e = __base::end();
1414 iterator __e = end();
20711415 iterator __em1 = _VSTD::prev(__e);
20721416 __alloc_traits::construct(__a, _VSTD::addressof(*__e), _VSTD::move(*__em1));
2073 ++__base::size();
1417 ++__size();
20741418 if (__de > 1)
20751419 __e = _VSTD::move_backward(__e - __de, __em1, __e);
20761420 *--__e = _VSTD::move(__v);
20771421 }
20781422 }
2079 return __base::begin() + __pos;
1423 return begin() + __pos;
20801424}
20811425
20821426template <class _Tp, class _Allocator>
......@@ -2084,9 +1428,9 @@ template <class... _Args>
20841428typename deque<_Tp, _Allocator>::iterator
20851429deque<_Tp, _Allocator>::emplace(const_iterator __p, _Args&&... __args)
20861430{
2087 size_type __pos = __p - __base::begin();
2088 size_type __to_end = __base::size() - __pos;
2089 allocator_type& __a = __base::__alloc();
1431 size_type __pos = __p - begin();
1432 size_type __to_end = size() - __pos;
1433 allocator_type& __a = __alloc();
20901434 if (__pos < __to_end)
20911435 { // insert by shifting things backward
20921436 if (__front_spare() == 0)
......@@ -2094,18 +1438,18 @@ deque<_Tp, _Allocator>::emplace(const_iterator __p, _Args&&... __args)
20941438 // __front_spare() >= 1
20951439 if (__pos == 0)
20961440 {
2097 __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), _VSTD::forward<_Args>(__args)...);
2098 --__base::__start_;
2099 ++__base::size();
1441 __alloc_traits::construct(__a, _VSTD::addressof(*--begin()), _VSTD::forward<_Args>(__args)...);
1442 --__start_;
1443 ++__size();
21001444 }
21011445 else
21021446 {
2103 __temp_value<value_type, _Allocator> __tmp(this->__alloc(), _VSTD::forward<_Args>(__args)...);
2104 iterator __b = __base::begin();
1447 __temp_value<value_type, _Allocator> __tmp(__alloc(), _VSTD::forward<_Args>(__args)...);
1448 iterator __b = begin();
21051449 iterator __bm1 = _VSTD::prev(__b);
21061450 __alloc_traits::construct(__a, _VSTD::addressof(*__bm1), _VSTD::move(*__b));
2107 --__base::__start_;
2108 ++__base::size();
1451 --__start_;
1452 ++__size();
21091453 if (__pos > 1)
21101454 __b = _VSTD::move(_VSTD::next(__b), __b + __pos, __b);
21111455 *__b = _VSTD::move(__tmp.get());
......@@ -2116,25 +1460,25 @@ deque<_Tp, _Allocator>::emplace(const_iterator __p, _Args&&... __args)
21161460 if (__back_spare() == 0)
21171461 __add_back_capacity();
21181462 // __back_capacity >= 1
2119 size_type __de = __base::size() - __pos;
1463 size_type __de = size() - __pos;
21201464 if (__de == 0)
21211465 {
2122 __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), _VSTD::forward<_Args>(__args)...);
2123 ++__base::size();
1466 __alloc_traits::construct(__a, _VSTD::addressof(*end()), _VSTD::forward<_Args>(__args)...);
1467 ++__size();
21241468 }
21251469 else
21261470 {
2127 __temp_value<value_type, _Allocator> __tmp(this->__alloc(), _VSTD::forward<_Args>(__args)...);
2128 iterator __e = __base::end();
1471 __temp_value<value_type, _Allocator> __tmp(__alloc(), _VSTD::forward<_Args>(__args)...);
1472 iterator __e = end();
21291473 iterator __em1 = _VSTD::prev(__e);
21301474 __alloc_traits::construct(__a, _VSTD::addressof(*__e), _VSTD::move(*__em1));
2131 ++__base::size();
1475 ++__size();
21321476 if (__de > 1)
21331477 __e = _VSTD::move_backward(__e - __de, __em1, __e);
21341478 *--__e = _VSTD::move(__tmp.get());
21351479 }
21361480 }
2137 return __base::begin() + __pos;
1481 return begin() + __pos;
21381482}
21391483
21401484#endif // _LIBCPP_CXX03_LANG
......@@ -2144,9 +1488,9 @@ template <class _Tp, class _Allocator>
21441488typename deque<_Tp, _Allocator>::iterator
21451489deque<_Tp, _Allocator>::insert(const_iterator __p, const value_type& __v)
21461490{
2147 size_type __pos = __p - __base::begin();
2148 size_type __to_end = __base::size() - __pos;
2149 allocator_type& __a = __base::__alloc();
1491 size_type __pos = __p - begin();
1492 size_type __to_end = size() - __pos;
1493 allocator_type& __a = __alloc();
21501494 if (__pos < __to_end)
21511495 { // insert by shifting things backward
21521496 if (__front_spare() == 0)
......@@ -2154,20 +1498,20 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, const value_type& __v)
21541498 // __front_spare() >= 1
21551499 if (__pos == 0)
21561500 {
2157 __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), __v);
2158 --__base::__start_;
2159 ++__base::size();
1501 __alloc_traits::construct(__a, _VSTD::addressof(*--begin()), __v);
1502 --__start_;
1503 ++__size();
21601504 }
21611505 else
21621506 {
21631507 const_pointer __vt = pointer_traits<const_pointer>::pointer_to(__v);
2164 iterator __b = __base::begin();
1508 iterator __b = begin();
21651509 iterator __bm1 = _VSTD::prev(__b);
21661510 if (__vt == pointer_traits<const_pointer>::pointer_to(*__b))
21671511 __vt = pointer_traits<const_pointer>::pointer_to(*__bm1);
21681512 __alloc_traits::construct(__a, _VSTD::addressof(*__bm1), _VSTD::move(*__b));
2169 --__base::__start_;
2170 ++__base::size();
1513 --__start_;
1514 ++__size();
21711515 if (__pos > 1)
21721516 __b = __move_and_check(_VSTD::next(__b), __b + __pos, __b, __vt);
21731517 *__b = *__vt;
......@@ -2178,46 +1522,46 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, const value_type& __v)
21781522 if (__back_spare() == 0)
21791523 __add_back_capacity();
21801524 // __back_capacity >= 1
2181 size_type __de = __base::size() - __pos;
1525 size_type __de = size() - __pos;
21821526 if (__de == 0)
21831527 {
2184 __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), __v);
2185 ++__base::size();
1528 __alloc_traits::construct(__a, _VSTD::addressof(*end()), __v);
1529 ++__size();
21861530 }
21871531 else
21881532 {
21891533 const_pointer __vt = pointer_traits<const_pointer>::pointer_to(__v);
2190 iterator __e = __base::end();
1534 iterator __e = end();
21911535 iterator __em1 = _VSTD::prev(__e);
21921536 if (__vt == pointer_traits<const_pointer>::pointer_to(*__em1))
21931537 __vt = pointer_traits<const_pointer>::pointer_to(*__e);
21941538 __alloc_traits::construct(__a, _VSTD::addressof(*__e), _VSTD::move(*__em1));
2195 ++__base::size();
1539 ++__size();
21961540 if (__de > 1)
21971541 __e = __move_backward_and_check(__e - __de, __em1, __e, __vt);
21981542 *--__e = *__vt;
21991543 }
22001544 }
2201 return __base::begin() + __pos;
1545 return begin() + __pos;
22021546}
22031547
22041548template <class _Tp, class _Allocator>
22051549typename deque<_Tp, _Allocator>::iterator
22061550deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_type& __v)
22071551{
2208 size_type __pos = __p - __base::begin();
2209 size_type __to_end = __base::size() - __pos;
2210 allocator_type& __a = __base::__alloc();
1552 size_type __pos = __p - begin();
1553 size_type __to_end = __size() - __pos;
1554 allocator_type& __a = __alloc();
22111555 if (__pos < __to_end)
22121556 { // insert by shifting things backward
22131557 if (__n > __front_spare())
22141558 __add_front_capacity(__n - __front_spare());
22151559 // __n <= __front_spare()
2216 iterator __old_begin = __base::begin();
1560 iterator __old_begin = begin();
22171561 iterator __i = __old_begin;
22181562 if (__n > __pos)
22191563 {
2220 for (size_type __m = __n - __pos; __m; --__m, --__base::__start_, ++__base::size())
1564 for (size_type __m = __n - __pos; __m; --__m, --__start_, ++__size())
22211565 __alloc_traits::construct(__a, _VSTD::addressof(*--__i), __v);
22221566 __n = __pos;
22231567 }
......@@ -2237,12 +1581,12 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_ty
22371581 if (__n > __back_capacity)
22381582 __add_back_capacity(__n - __back_capacity);
22391583 // __n <= __back_capacity
2240 iterator __old_end = __base::end();
1584 iterator __old_end = end();
22411585 iterator __i = __old_end;
2242 size_type __de = __base::size() - __pos;
1586 size_type __de = size() - __pos;
22431587 if (__n > __de)
22441588 {
2245 for (size_type __m = __n - __de; __m; --__m, (void) ++__i, ++__base::size())
1589 for (size_type __m = __n - __de; __m; --__m, (void) ++__i, ++__size())
22461590 __alloc_traits::construct(__a, _VSTD::addressof(*__i), __v);
22471591 __n = __de;
22481592 }
......@@ -2256,7 +1600,7 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_ty
22561600 _VSTD::fill_n(__old_end - __n, __n, *__vt);
22571601 }
22581602 }
2259 return __base::begin() + __pos;
1603 return begin() + __pos;
22601604}
22611605
22621606template <class _Tp, class _Allocator>
......@@ -2265,7 +1609,7 @@ typename deque<_Tp, _Allocator>::iterator
22651609deque<_Tp, _Allocator>::insert(const_iterator __p, _InputIter __f, _InputIter __l,
22661610 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIter>::value>::type*)
22671611{
2268 __split_buffer<value_type, allocator_type&> __buf(__base::__alloc());
1612 __split_buffer<value_type, allocator_type&> __buf(__alloc());
22691613 __buf.__construct_at_end(__f, __l);
22701614 typedef typename __split_buffer<value_type, allocator_type&>::iterator __bi;
22711615 return insert(__p, move_iterator<__bi>(__buf.begin()), move_iterator<__bi>(__buf.end()));
......@@ -2278,7 +1622,7 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _ForwardIterator __f, _Forwar
22781622 typename enable_if<__is_exactly_cpp17_forward_iterator<_ForwardIterator>::value>::type*)
22791623{
22801624 size_type __n = _VSTD::distance(__f, __l);
2281 __split_buffer<value_type, allocator_type&> __buf(__n, 0, __base::__alloc());
1625 __split_buffer<value_type, allocator_type&> __buf(__n, 0, __alloc());
22821626 __buf.__construct_at_end(__f, __l);
22831627 typedef typename __split_buffer<value_type, allocator_type&>::iterator __fwd;
22841628 return insert(__p, move_iterator<__fwd>(__buf.begin()), move_iterator<__fwd>(__buf.end()));
......@@ -2291,21 +1635,21 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l,
22911635 typename enable_if<__is_cpp17_bidirectional_iterator<_BiIter>::value>::type*)
22921636{
22931637 size_type __n = _VSTD::distance(__f, __l);
2294 size_type __pos = __p - __base::begin();
2295 size_type __to_end = __base::size() - __pos;
2296 allocator_type& __a = __base::__alloc();
1638 size_type __pos = __p - begin();
1639 size_type __to_end = size() - __pos;
1640 allocator_type& __a = __alloc();
22971641 if (__pos < __to_end)
22981642 { // insert by shifting things backward
22991643 if (__n > __front_spare())
23001644 __add_front_capacity(__n - __front_spare());
23011645 // __n <= __front_spare()
2302 iterator __old_begin = __base::begin();
1646 iterator __old_begin = begin();
23031647 iterator __i = __old_begin;
23041648 _BiIter __m = __f;
23051649 if (__n > __pos)
23061650 {
23071651 __m = __pos < __n / 2 ? _VSTD::prev(__l, __pos) : _VSTD::next(__f, __n - __pos);
2308 for (_BiIter __j = __m; __j != __f; --__base::__start_, ++__base::size())
1652 for (_BiIter __j = __m; __j != __f; --__start_, ++__size())
23091653 __alloc_traits::construct(__a, _VSTD::addressof(*--__i), *--__j);
23101654 __n = __pos;
23111655 }
......@@ -2315,8 +1659,8 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l,
23151659 for (iterator __j = __obn; __j != __old_begin;)
23161660 {
23171661 __alloc_traits::construct(__a, _VSTD::addressof(*--__i), _VSTD::move(*--__j));
2318 --__base::__start_;
2319 ++__base::size();
1662 --__start_;
1663 ++__size();
23201664 }
23211665 if (__n < __pos)
23221666 __old_begin = _VSTD::move(__obn, __old_begin + __pos, __old_begin);
......@@ -2329,28 +1673,28 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l,
23291673 if (__n > __back_capacity)
23301674 __add_back_capacity(__n - __back_capacity);
23311675 // __n <= __back_capacity
2332 iterator __old_end = __base::end();
1676 iterator __old_end = end();
23331677 iterator __i = __old_end;
23341678 _BiIter __m = __l;
2335 size_type __de = __base::size() - __pos;
1679 size_type __de = size() - __pos;
23361680 if (__n > __de)
23371681 {
23381682 __m = __de < __n / 2 ? _VSTD::next(__f, __de) : _VSTD::prev(__l, __n - __de);
2339 for (_BiIter __j = __m; __j != __l; ++__i, (void) ++__j, ++__base::size())
1683 for (_BiIter __j = __m; __j != __l; ++__i, (void) ++__j, ++__size())
23401684 __alloc_traits::construct(__a, _VSTD::addressof(*__i), *__j);
23411685 __n = __de;
23421686 }
23431687 if (__n > 0)
23441688 {
23451689 iterator __oen = __old_end - __n;
2346 for (iterator __j = __oen; __j != __old_end; ++__i, (void) ++__j, ++__base::size())
1690 for (iterator __j = __oen; __j != __old_end; ++__i, (void) ++__j, ++__size())
23471691 __alloc_traits::construct(__a, _VSTD::addressof(*__i), _VSTD::move(*__j));
23481692 if (__n < __de)
23491693 __old_end = _VSTD::move_backward(__old_end - __de, __oen, __old_end);
23501694 _VSTD::copy_backward(__f, __m, __old_end);
23511695 }
23521696 }
2353 return __base::begin() + __pos;
1697 return begin() + __pos;
23541698}
23551699
23561700template <class _Tp, class _Allocator>
......@@ -2374,12 +1718,12 @@ deque<_Tp, _Allocator>::__append(_ForIter __f, _ForIter __l,
23741718 typename enable_if<__is_cpp17_forward_iterator<_ForIter>::value>::type*)
23751719{
23761720 size_type __n = _VSTD::distance(__f, __l);
2377 allocator_type& __a = __base::__alloc();
1721 allocator_type& __a = __alloc();
23781722 size_type __back_capacity = __back_spare();
23791723 if (__n > __back_capacity)
23801724 __add_back_capacity(__n - __back_capacity);
23811725 // __n <= __back_capacity
2382 for (__deque_block_range __br : __deque_range(__base::end(), __base::end() + __n)) {
1726 for (__deque_block_range __br : __deque_range(end(), end() + __n)) {
23831727 _ConstructTransaction __tx(this, __br);
23841728 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void)++__f) {
23851729 __alloc_traits::construct(__a, _VSTD::__to_address(__tx.__pos_), *__f);
......@@ -2391,12 +1735,12 @@ template <class _Tp, class _Allocator>
23911735void
23921736deque<_Tp, _Allocator>::__append(size_type __n)
23931737{
2394 allocator_type& __a = __base::__alloc();
1738 allocator_type& __a = __alloc();
23951739 size_type __back_capacity = __back_spare();
23961740 if (__n > __back_capacity)
23971741 __add_back_capacity(__n - __back_capacity);
23981742 // __n <= __back_capacity
2399 for (__deque_block_range __br : __deque_range(__base::end(), __base::end() + __n)) {
1743 for (__deque_block_range __br : __deque_range(end(), end() + __n)) {
24001744 _ConstructTransaction __tx(this, __br);
24011745 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
24021746 __alloc_traits::construct(__a, _VSTD::__to_address(__tx.__pos_));
......@@ -2408,12 +1752,12 @@ template <class _Tp, class _Allocator>
24081752void
24091753deque<_Tp, _Allocator>::__append(size_type __n, const value_type& __v)
24101754{
2411 allocator_type& __a = __base::__alloc();
1755 allocator_type& __a = __alloc();
24121756 size_type __back_capacity = __back_spare();
24131757 if (__n > __back_capacity)
24141758 __add_back_capacity(__n - __back_capacity);
24151759 // __n <= __back_capacity
2416 for (__deque_block_range __br : __deque_range(__base::end(), __base::end() + __n)) {
1760 for (__deque_block_range __br : __deque_range(end(), end() + __n)) {
24171761 _ConstructTransaction __tx(this, __br);
24181762 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
24191763 __alloc_traits::construct(__a, _VSTD::__to_address(__tx.__pos_), __v);
......@@ -2428,57 +1772,57 @@ template <class _Tp, class _Allocator>
24281772void
24291773deque<_Tp, _Allocator>::__add_front_capacity()
24301774{
2431 allocator_type& __a = __base::__alloc();
2432 if (__back_spare() >= __base::__block_size)
1775 allocator_type& __a = __alloc();
1776 if (__back_spare() >= __block_size)
24331777 {
2434 __base::__start_ += __base::__block_size;
2435 pointer __pt = __base::__map_.back();
2436 __base::__map_.pop_back();
2437 __base::__map_.push_front(__pt);
1778 __start_ += __block_size;
1779 pointer __pt = __map_.back();
1780 __map_.pop_back();
1781 __map_.push_front(__pt);
24381782 }
2439 // Else if __base::__map_.size() < __base::__map_.capacity() then we need to allocate 1 buffer
2440 else if (__base::__map_.size() < __base::__map_.capacity())
1783 // Else if __map_.size() < __map_.capacity() then we need to allocate 1 buffer
1784 else if (__map_.size() < __map_.capacity())
24411785 { // we can put the new buffer into the map, but don't shift things around
24421786 // until all buffers are allocated. If we throw, we don't need to fix
24431787 // anything up (any added buffers are undetectible)
2444 if (__base::__map_.__front_spare() > 0)
2445 __base::__map_.push_front(__alloc_traits::allocate(__a, __base::__block_size));
1788 if (__map_.__front_spare() > 0)
1789 __map_.push_front(__alloc_traits::allocate(__a, __block_size));
24461790 else
24471791 {
2448 __base::__map_.push_back(__alloc_traits::allocate(__a, __base::__block_size));
1792 __map_.push_back(__alloc_traits::allocate(__a, __block_size));
24491793 // Done allocating, reorder capacity
2450 pointer __pt = __base::__map_.back();
2451 __base::__map_.pop_back();
2452 __base::__map_.push_front(__pt);
1794 pointer __pt = __map_.back();
1795 __map_.pop_back();
1796 __map_.push_front(__pt);
24531797 }
2454 __base::__start_ = __base::__map_.size() == 1 ?
2455 __base::__block_size / 2 :
2456 __base::__start_ + __base::__block_size;
1798 __start_ = __map_.size() == 1 ?
1799 __block_size / 2 :
1800 __start_ + __block_size;
24571801 }
24581802 // Else need to allocate 1 buffer, *and* we need to reallocate __map_.
24591803 else
24601804 {
2461 __split_buffer<pointer, typename __base::__pointer_allocator&>
2462 __buf(max<size_type>(2 * __base::__map_.capacity(), 1),
2463 0, __base::__map_.__alloc());
1805 __split_buffer<pointer, __pointer_allocator&>
1806 __buf(std::max<size_type>(2 * __map_.capacity(), 1),
1807 0, __map_.__alloc());
24641808
24651809 typedef __allocator_destructor<_Allocator> _Dp;
24661810 unique_ptr<pointer, _Dp> __hold(
2467 __alloc_traits::allocate(__a, __base::__block_size),
2468 _Dp(__a, __base::__block_size));
1811 __alloc_traits::allocate(__a, __block_size),
1812 _Dp(__a, __block_size));
24691813 __buf.push_back(__hold.get());
24701814 __hold.release();
24711815
2472 for (typename __base::__map_pointer __i = __base::__map_.begin();
2473 __i != __base::__map_.end(); ++__i)
1816 for (__map_pointer __i = __map_.begin();
1817 __i != __map_.end(); ++__i)
24741818 __buf.push_back(*__i);
2475 _VSTD::swap(__base::__map_.__first_, __buf.__first_);
2476 _VSTD::swap(__base::__map_.__begin_, __buf.__begin_);
2477 _VSTD::swap(__base::__map_.__end_, __buf.__end_);
2478 _VSTD::swap(__base::__map_.__end_cap(), __buf.__end_cap());
2479 __base::__start_ = __base::__map_.size() == 1 ?
2480 __base::__block_size / 2 :
2481 __base::__start_ + __base::__block_size;
1819 _VSTD::swap(__map_.__first_, __buf.__first_);
1820 _VSTD::swap(__map_.__begin_, __buf.__begin_);
1821 _VSTD::swap(__map_.__end_, __buf.__end_);
1822 _VSTD::swap(__map_.__end_cap(), __buf.__end_cap());
1823 __start_ = __map_.size() == 1 ?
1824 __block_size / 2 :
1825 __start_ + __block_size;
24821826 }
24831827}
24841828
......@@ -2488,82 +1832,82 @@ template <class _Tp, class _Allocator>
24881832void
24891833deque<_Tp, _Allocator>::__add_front_capacity(size_type __n)
24901834{
2491 allocator_type& __a = __base::__alloc();
2492 size_type __nb = __recommend_blocks(__n + __base::__map_.empty());
1835 allocator_type& __a = __alloc();
1836 size_type __nb = __recommend_blocks(__n + __map_.empty());
24931837 // Number of unused blocks at back:
2494 size_type __back_capacity = __back_spare() / __base::__block_size;
1838 size_type __back_capacity = __back_spare() / __block_size;
24951839 __back_capacity = _VSTD::min(__back_capacity, __nb); // don't take more than you need
24961840 __nb -= __back_capacity; // number of blocks need to allocate
24971841 // If __nb == 0, then we have sufficient capacity.
24981842 if (__nb == 0)
24991843 {
2500 __base::__start_ += __base::__block_size * __back_capacity;
1844 __start_ += __block_size * __back_capacity;
25011845 for (; __back_capacity > 0; --__back_capacity)
25021846 {
2503 pointer __pt = __base::__map_.back();
2504 __base::__map_.pop_back();
2505 __base::__map_.push_front(__pt);
1847 pointer __pt = __map_.back();
1848 __map_.pop_back();
1849 __map_.push_front(__pt);
25061850 }
25071851 }
25081852 // Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers
2509 else if (__nb <= __base::__map_.capacity() - __base::__map_.size())
1853 else if (__nb <= __map_.capacity() - __map_.size())
25101854 { // we can put the new buffers into the map, but don't shift things around
25111855 // until all buffers are allocated. If we throw, we don't need to fix
25121856 // anything up (any added buffers are undetectible)
2513 for (; __nb > 0; --__nb, __base::__start_ += __base::__block_size - (__base::__map_.size() == 1))
1857 for (; __nb > 0; --__nb, __start_ += __block_size - (__map_.size() == 1))
25141858 {
2515 if (__base::__map_.__front_spare() == 0)
1859 if (__map_.__front_spare() == 0)
25161860 break;
2517 __base::__map_.push_front(__alloc_traits::allocate(__a, __base::__block_size));
1861 __map_.push_front(__alloc_traits::allocate(__a, __block_size));
25181862 }
25191863 for (; __nb > 0; --__nb, ++__back_capacity)
2520 __base::__map_.push_back(__alloc_traits::allocate(__a, __base::__block_size));
1864 __map_.push_back(__alloc_traits::allocate(__a, __block_size));
25211865 // Done allocating, reorder capacity
2522 __base::__start_ += __back_capacity * __base::__block_size;
1866 __start_ += __back_capacity * __block_size;
25231867 for (; __back_capacity > 0; --__back_capacity)
25241868 {
2525 pointer __pt = __base::__map_.back();
2526 __base::__map_.pop_back();
2527 __base::__map_.push_front(__pt);
1869 pointer __pt = __map_.back();
1870 __map_.pop_back();
1871 __map_.push_front(__pt);
25281872 }
25291873 }
25301874 // Else need to allocate __nb buffers, *and* we need to reallocate __map_.
25311875 else
25321876 {
2533 size_type __ds = (__nb + __back_capacity) * __base::__block_size - __base::__map_.empty();
2534 __split_buffer<pointer, typename __base::__pointer_allocator&>
2535 __buf(max<size_type>(2* __base::__map_.capacity(),
2536 __nb + __base::__map_.size()),
2537 0, __base::__map_.__alloc());
1877 size_type __ds = (__nb + __back_capacity) * __block_size - __map_.empty();
1878 __split_buffer<pointer, __pointer_allocator&>
1879 __buf(std::max<size_type>(2* __map_.capacity(),
1880 __nb + __map_.size()),
1881 0, __map_.__alloc());
25381882#ifndef _LIBCPP_NO_EXCEPTIONS
25391883 try
25401884 {
25411885#endif // _LIBCPP_NO_EXCEPTIONS
25421886 for (; __nb > 0; --__nb)
2543 __buf.push_back(__alloc_traits::allocate(__a, __base::__block_size));
1887 __buf.push_back(__alloc_traits::allocate(__a, __block_size));
25441888#ifndef _LIBCPP_NO_EXCEPTIONS
25451889 }
25461890 catch (...)
25471891 {
2548 for (typename __base::__map_pointer __i = __buf.begin();
1892 for (__map_pointer __i = __buf.begin();
25491893 __i != __buf.end(); ++__i)
2550 __alloc_traits::deallocate(__a, *__i, __base::__block_size);
1894 __alloc_traits::deallocate(__a, *__i, __block_size);
25511895 throw;
25521896 }
25531897#endif // _LIBCPP_NO_EXCEPTIONS
25541898 for (; __back_capacity > 0; --__back_capacity)
25551899 {
2556 __buf.push_back(__base::__map_.back());
2557 __base::__map_.pop_back();
1900 __buf.push_back(__map_.back());
1901 __map_.pop_back();
25581902 }
2559 for (typename __base::__map_pointer __i = __base::__map_.begin();
2560 __i != __base::__map_.end(); ++__i)
1903 for (__map_pointer __i = __map_.begin();
1904 __i != __map_.end(); ++__i)
25611905 __buf.push_back(*__i);
2562 _VSTD::swap(__base::__map_.__first_, __buf.__first_);
2563 _VSTD::swap(__base::__map_.__begin_, __buf.__begin_);
2564 _VSTD::swap(__base::__map_.__end_, __buf.__end_);
2565 _VSTD::swap(__base::__map_.__end_cap(), __buf.__end_cap());
2566 __base::__start_ += __ds;
1906 _VSTD::swap(__map_.__first_, __buf.__first_);
1907 _VSTD::swap(__map_.__begin_, __buf.__begin_);
1908 _VSTD::swap(__map_.__end_, __buf.__end_);
1909 _VSTD::swap(__map_.__end_cap(), __buf.__end_cap());
1910 __start_ += __ds;
25671911 }
25681912}
25691913
......@@ -2573,52 +1917,52 @@ template <class _Tp, class _Allocator>
25731917void
25741918deque<_Tp, _Allocator>::__add_back_capacity()
25751919{
2576 allocator_type& __a = __base::__alloc();
2577 if (__front_spare() >= __base::__block_size)
1920 allocator_type& __a = __alloc();
1921 if (__front_spare() >= __block_size)
25781922 {
2579 __base::__start_ -= __base::__block_size;
2580 pointer __pt = __base::__map_.front();
2581 __base::__map_.pop_front();
2582 __base::__map_.push_back(__pt);
1923 __start_ -= __block_size;
1924 pointer __pt = __map_.front();
1925 __map_.pop_front();
1926 __map_.push_back(__pt);
25831927 }
25841928 // Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers
2585 else if (__base::__map_.size() < __base::__map_.capacity())
1929 else if (__map_.size() < __map_.capacity())
25861930 { // we can put the new buffer into the map, but don't shift things around
25871931 // until it is allocated. If we throw, we don't need to fix
25881932 // anything up (any added buffers are undetectible)
2589 if (__base::__map_.__back_spare() != 0)
2590 __base::__map_.push_back(__alloc_traits::allocate(__a, __base::__block_size));
1933 if (__map_.__back_spare() != 0)
1934 __map_.push_back(__alloc_traits::allocate(__a, __block_size));
25911935 else
25921936 {
2593 __base::__map_.push_front(__alloc_traits::allocate(__a, __base::__block_size));
1937 __map_.push_front(__alloc_traits::allocate(__a, __block_size));
25941938 // Done allocating, reorder capacity
2595 pointer __pt = __base::__map_.front();
2596 __base::__map_.pop_front();
2597 __base::__map_.push_back(__pt);
1939 pointer __pt = __map_.front();
1940 __map_.pop_front();
1941 __map_.push_back(__pt);
25981942 }
25991943 }
26001944 // Else need to allocate 1 buffer, *and* we need to reallocate __map_.
26011945 else
26021946 {
2603 __split_buffer<pointer, typename __base::__pointer_allocator&>
2604 __buf(max<size_type>(2* __base::__map_.capacity(), 1),
2605 __base::__map_.size(),
2606 __base::__map_.__alloc());
1947 __split_buffer<pointer, __pointer_allocator&>
1948 __buf(std::max<size_type>(2* __map_.capacity(), 1),
1949 __map_.size(),
1950 __map_.__alloc());
26071951
26081952 typedef __allocator_destructor<_Allocator> _Dp;
26091953 unique_ptr<pointer, _Dp> __hold(
2610 __alloc_traits::allocate(__a, __base::__block_size),
2611 _Dp(__a, __base::__block_size));
1954 __alloc_traits::allocate(__a, __block_size),
1955 _Dp(__a, __block_size));
26121956 __buf.push_back(__hold.get());
26131957 __hold.release();
26141958
2615 for (typename __base::__map_pointer __i = __base::__map_.end();
2616 __i != __base::__map_.begin();)
1959 for (__map_pointer __i = __map_.end();
1960 __i != __map_.begin();)
26171961 __buf.push_front(*--__i);
2618 _VSTD::swap(__base::__map_.__first_, __buf.__first_);
2619 _VSTD::swap(__base::__map_.__begin_, __buf.__begin_);
2620 _VSTD::swap(__base::__map_.__end_, __buf.__end_);
2621 _VSTD::swap(__base::__map_.__end_cap(), __buf.__end_cap());
1962 _VSTD::swap(__map_.__first_, __buf.__first_);
1963 _VSTD::swap(__map_.__begin_, __buf.__begin_);
1964 _VSTD::swap(__map_.__end_, __buf.__end_);
1965 _VSTD::swap(__map_.__end_cap(), __buf.__end_cap());
26221966 }
26231967}
26241968
......@@ -2628,84 +1972,84 @@ template <class _Tp, class _Allocator>
26281972void
26291973deque<_Tp, _Allocator>::__add_back_capacity(size_type __n)
26301974{
2631 allocator_type& __a = __base::__alloc();
2632 size_type __nb = __recommend_blocks(__n + __base::__map_.empty());
1975 allocator_type& __a = __alloc();
1976 size_type __nb = __recommend_blocks(__n + __map_.empty());
26331977 // Number of unused blocks at front:
2634 size_type __front_capacity = __front_spare() / __base::__block_size;
1978 size_type __front_capacity = __front_spare() / __block_size;
26351979 __front_capacity = _VSTD::min(__front_capacity, __nb); // don't take more than you need
26361980 __nb -= __front_capacity; // number of blocks need to allocate
26371981 // If __nb == 0, then we have sufficient capacity.
26381982 if (__nb == 0)
26391983 {
2640 __base::__start_ -= __base::__block_size * __front_capacity;
1984 __start_ -= __block_size * __front_capacity;
26411985 for (; __front_capacity > 0; --__front_capacity)
26421986 {
2643 pointer __pt = __base::__map_.front();
2644 __base::__map_.pop_front();
2645 __base::__map_.push_back(__pt);
1987 pointer __pt = __map_.front();
1988 __map_.pop_front();
1989 __map_.push_back(__pt);
26461990 }
26471991 }
26481992 // Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers
2649 else if (__nb <= __base::__map_.capacity() - __base::__map_.size())
1993 else if (__nb <= __map_.capacity() - __map_.size())
26501994 { // we can put the new buffers into the map, but don't shift things around
26511995 // until all buffers are allocated. If we throw, we don't need to fix
26521996 // anything up (any added buffers are undetectible)
26531997 for (; __nb > 0; --__nb)
26541998 {
2655 if (__base::__map_.__back_spare() == 0)
1999 if (__map_.__back_spare() == 0)
26562000 break;
2657 __base::__map_.push_back(__alloc_traits::allocate(__a, __base::__block_size));
2001 __map_.push_back(__alloc_traits::allocate(__a, __block_size));
26582002 }
2659 for (; __nb > 0; --__nb, ++__front_capacity, __base::__start_ +=
2660 __base::__block_size - (__base::__map_.size() == 1))
2661 __base::__map_.push_front(__alloc_traits::allocate(__a, __base::__block_size));
2003 for (; __nb > 0; --__nb, ++__front_capacity, __start_ +=
2004 __block_size - (__map_.size() == 1))
2005 __map_.push_front(__alloc_traits::allocate(__a, __block_size));
26622006 // Done allocating, reorder capacity
2663 __base::__start_ -= __base::__block_size * __front_capacity;
2007 __start_ -= __block_size * __front_capacity;
26642008 for (; __front_capacity > 0; --__front_capacity)
26652009 {
2666 pointer __pt = __base::__map_.front();
2667 __base::__map_.pop_front();
2668 __base::__map_.push_back(__pt);
2010 pointer __pt = __map_.front();
2011 __map_.pop_front();
2012 __map_.push_back(__pt);
26692013 }
26702014 }
26712015 // Else need to allocate __nb buffers, *and* we need to reallocate __map_.
26722016 else
26732017 {
2674 size_type __ds = __front_capacity * __base::__block_size;
2675 __split_buffer<pointer, typename __base::__pointer_allocator&>
2676 __buf(max<size_type>(2* __base::__map_.capacity(),
2677 __nb + __base::__map_.size()),
2678 __base::__map_.size() - __front_capacity,
2679 __base::__map_.__alloc());
2018 size_type __ds = __front_capacity * __block_size;
2019 __split_buffer<pointer, __pointer_allocator&>
2020 __buf(std::max<size_type>(2* __map_.capacity(),
2021 __nb + __map_.size()),
2022 __map_.size() - __front_capacity,
2023 __map_.__alloc());
26802024#ifndef _LIBCPP_NO_EXCEPTIONS
26812025 try
26822026 {
26832027#endif // _LIBCPP_NO_EXCEPTIONS
26842028 for (; __nb > 0; --__nb)
2685 __buf.push_back(__alloc_traits::allocate(__a, __base::__block_size));
2029 __buf.push_back(__alloc_traits::allocate(__a, __block_size));
26862030#ifndef _LIBCPP_NO_EXCEPTIONS
26872031 }
26882032 catch (...)
26892033 {
2690 for (typename __base::__map_pointer __i = __buf.begin();
2034 for (__map_pointer __i = __buf.begin();
26912035 __i != __buf.end(); ++__i)
2692 __alloc_traits::deallocate(__a, *__i, __base::__block_size);
2036 __alloc_traits::deallocate(__a, *__i, __block_size);
26932037 throw;
26942038 }
26952039#endif // _LIBCPP_NO_EXCEPTIONS
26962040 for (; __front_capacity > 0; --__front_capacity)
26972041 {
2698 __buf.push_back(__base::__map_.front());
2699 __base::__map_.pop_front();
2042 __buf.push_back(__map_.front());
2043 __map_.pop_front();
27002044 }
2701 for (typename __base::__map_pointer __i = __base::__map_.end();
2702 __i != __base::__map_.begin();)
2045 for (__map_pointer __i = __map_.end();
2046 __i != __map_.begin();)
27032047 __buf.push_front(*--__i);
2704 _VSTD::swap(__base::__map_.__first_, __buf.__first_);
2705 _VSTD::swap(__base::__map_.__begin_, __buf.__begin_);
2706 _VSTD::swap(__base::__map_.__end_, __buf.__end_);
2707 _VSTD::swap(__base::__map_.__end_cap(), __buf.__end_cap());
2708 __base::__start_ -= __ds;
2048 _VSTD::swap(__map_.__first_, __buf.__first_);
2049 _VSTD::swap(__map_.__begin_, __buf.__begin_);
2050 _VSTD::swap(__map_.__end_, __buf.__end_);
2051 _VSTD::swap(__map_.__end_cap(), __buf.__end_cap());
2052 __start_ -= __ds;
27092053 }
27102054}
27112055
......@@ -2713,12 +2057,12 @@ template <class _Tp, class _Allocator>
27132057void
27142058deque<_Tp, _Allocator>::pop_front()
27152059{
2716 allocator_type& __a = __base::__alloc();
2717 __alloc_traits::destroy(__a, _VSTD::__to_address(*(__base::__map_.begin() +
2718 __base::__start_ / __base::__block_size) +
2719 __base::__start_ % __base::__block_size));
2720 --__base::size();
2721 ++__base::__start_;
2060 allocator_type& __a = __alloc();
2061 __alloc_traits::destroy(__a, _VSTD::__to_address(*(__map_.begin() +
2062 __start_ / __block_size) +
2063 __start_ % __block_size));
2064 --__size();
2065 ++__start_;
27222066 __maybe_remove_front_spare();
27232067}
27242068
......@@ -2727,12 +2071,12 @@ void
27272071deque<_Tp, _Allocator>::pop_back()
27282072{
27292073 _LIBCPP_ASSERT(!empty(), "deque::pop_back called on an empty deque");
2730 allocator_type& __a = __base::__alloc();
2731 size_type __p = __base::size() + __base::__start_ - 1;
2732 __alloc_traits::destroy(__a, _VSTD::__to_address(*(__base::__map_.begin() +
2733 __p / __base::__block_size) +
2734 __p % __base::__block_size));
2735 --__base::size();
2074 allocator_type& __a = __alloc();
2075 size_type __p = size() + __start_ - 1;
2076 __alloc_traits::destroy(__a, _VSTD::__to_address(*(__map_.begin() +
2077 __p / __block_size) +
2078 __p % __block_size));
2079 --__size();
27362080 __maybe_remove_back_spare();
27372081}
27382082
......@@ -2750,7 +2094,7 @@ deque<_Tp, _Allocator>::__move_and_check(iterator __f, iterator __l, iterator __
27502094 while (__n > 0)
27512095 {
27522096 pointer __fb = __f.__ptr_;
2753 pointer __fe = *__f.__m_iter_ + __base::__block_size;
2097 pointer __fe = *__f.__m_iter_ + __block_size;
27542098 difference_type __bs = __fe - __fb;
27552099 if (__bs > __n)
27562100 {
......@@ -2804,15 +2148,15 @@ void
28042148deque<_Tp, _Allocator>::__move_construct_and_check(iterator __f, iterator __l,
28052149 iterator __r, const_pointer& __vt)
28062150{
2807 allocator_type& __a = __base::__alloc();
2151 allocator_type& __a = __alloc();
28082152 // as if
2809 // for (; __f != __l; ++__r, ++__f, ++__base::size())
2153 // for (; __f != __l; ++__r, ++__f, ++__size())
28102154 // __alloc_traits::construct(__a, _VSTD::addressof(*__r), _VSTD::move(*__f));
28112155 difference_type __n = __l - __f;
28122156 while (__n > 0)
28132157 {
28142158 pointer __fb = __f.__ptr_;
2815 pointer __fe = *__f.__m_iter_ + __base::__block_size;
2159 pointer __fe = *__f.__m_iter_ + __block_size;
28162160 difference_type __bs = __fe - __fb;
28172161 if (__bs > __n)
28182162 {
......@@ -2821,7 +2165,7 @@ deque<_Tp, _Allocator>::__move_construct_and_check(iterator __f, iterator __l,
28212165 }
28222166 if (__fb <= __vt && __vt < __fe)
28232167 __vt = (const_iterator(static_cast<__map_const_pointer>(__f.__m_iter_), __vt) += __r - __f).__ptr_;
2824 for (; __fb != __fe; ++__fb, ++__r, ++__base::size())
2168 for (; __fb != __fe; ++__fb, ++__r, ++__size())
28252169 __alloc_traits::construct(__a, _VSTD::addressof(*__r), _VSTD::move(*__fb));
28262170 __n -= __bs;
28272171 __f += __bs;
......@@ -2835,13 +2179,13 @@ void
28352179deque<_Tp, _Allocator>::__move_construct_backward_and_check(iterator __f, iterator __l,
28362180 iterator __r, const_pointer& __vt)
28372181{
2838 allocator_type& __a = __base::__alloc();
2182 allocator_type& __a = __alloc();
28392183 // as if
28402184 // for (iterator __j = __l; __j != __f;)
28412185 // {
28422186 // __alloc_traitsconstruct(__a, _VSTD::addressof(*--__r), _VSTD::move(*--__j));
2843 // --__base::__start_;
2844 // ++__base::size();
2187 // --__start_;
2188 // ++__size();
28452189 // }
28462190 difference_type __n = __l - __f;
28472191 while (__n > 0)
......@@ -2860,8 +2204,8 @@ deque<_Tp, _Allocator>::__move_construct_backward_and_check(iterator __f, iterat
28602204 while (__le != __lb)
28612205 {
28622206 __alloc_traits::construct(__a, _VSTD::addressof(*--__r), _VSTD::move(*--__le));
2863 --__base::__start_;
2864 ++__base::size();
2207 --__start_;
2208 ++__size();
28652209 }
28662210 __n -= __bs;
28672211 __l -= __bs - 1;
......@@ -2872,26 +2216,26 @@ template <class _Tp, class _Allocator>
28722216typename deque<_Tp, _Allocator>::iterator
28732217deque<_Tp, _Allocator>::erase(const_iterator __f)
28742218{
2875 iterator __b = __base::begin();
2219 iterator __b = begin();
28762220 difference_type __pos = __f - __b;
28772221 iterator __p = __b + __pos;
2878 allocator_type& __a = __base::__alloc();
2879 if (static_cast<size_t>(__pos) <= (__base::size() - 1) / 2)
2222 allocator_type& __a = __alloc();
2223 if (static_cast<size_t>(__pos) <= (size() - 1) / 2)
28802224 { // erase from front
28812225 _VSTD::move_backward(__b, __p, _VSTD::next(__p));
28822226 __alloc_traits::destroy(__a, _VSTD::addressof(*__b));
2883 --__base::size();
2884 ++__base::__start_;
2227 --__size();
2228 ++__start_;
28852229 __maybe_remove_front_spare();
28862230 }
28872231 else
28882232 { // erase from back
2889 iterator __i = _VSTD::move(_VSTD::next(__p), __base::end(), __p);
2233 iterator __i = _VSTD::move(_VSTD::next(__p), end(), __p);
28902234 __alloc_traits::destroy(__a, _VSTD::addressof(*__i));
2891 --__base::size();
2235 --__size();
28922236 __maybe_remove_back_spare();
28932237 }
2894 return __base::begin() + __pos;
2238 return begin() + __pos;
28952239}
28962240
28972241template <class _Tp, class _Allocator>
......@@ -2899,49 +2243,49 @@ typename deque<_Tp, _Allocator>::iterator
28992243deque<_Tp, _Allocator>::erase(const_iterator __f, const_iterator __l)
29002244{
29012245 difference_type __n = __l - __f;
2902 iterator __b = __base::begin();
2246 iterator __b = begin();
29032247 difference_type __pos = __f - __b;
29042248 iterator __p = __b + __pos;
29052249 if (__n > 0)
29062250 {
2907 allocator_type& __a = __base::__alloc();
2908 if (static_cast<size_t>(__pos) <= (__base::size() - __n) / 2)
2251 allocator_type& __a = __alloc();
2252 if (static_cast<size_t>(__pos) <= (size() - __n) / 2)
29092253 { // erase from front
29102254 iterator __i = _VSTD::move_backward(__b, __p, __p + __n);
29112255 for (; __b != __i; ++__b)
29122256 __alloc_traits::destroy(__a, _VSTD::addressof(*__b));
2913 __base::size() -= __n;
2914 __base::__start_ += __n;
2257 __size() -= __n;
2258 __start_ += __n;
29152259 while (__maybe_remove_front_spare()) {
29162260 }
29172261 }
29182262 else
29192263 { // erase from back
2920 iterator __i = _VSTD::move(__p + __n, __base::end(), __p);
2921 for (iterator __e = __base::end(); __i != __e; ++__i)
2264 iterator __i = _VSTD::move(__p + __n, end(), __p);
2265 for (iterator __e = end(); __i != __e; ++__i)
29222266 __alloc_traits::destroy(__a, _VSTD::addressof(*__i));
2923 __base::size() -= __n;
2267 __size() -= __n;
29242268 while (__maybe_remove_back_spare()) {
29252269 }
29262270 }
29272271 }
2928 return __base::begin() + __pos;
2272 return begin() + __pos;
29292273}
29302274
29312275template <class _Tp, class _Allocator>
29322276void
29332277deque<_Tp, _Allocator>::__erase_to_end(const_iterator __f)
29342278{
2935 iterator __e = __base::end();
2279 iterator __e = end();
29362280 difference_type __n = __e - __f;
29372281 if (__n > 0)
29382282 {
2939 allocator_type& __a = __base::__alloc();
2940 iterator __b = __base::begin();
2283 allocator_type& __a = __alloc();
2284 iterator __b = begin();
29412285 difference_type __pos = __f - __b;
29422286 for (iterator __p = __b + __pos; __p != __e; ++__p)
29432287 __alloc_traits::destroy(__a, _VSTD::addressof(*__p));
2944 __base::size() -= __n;
2288 __size() -= __n;
29452289 while (__maybe_remove_back_spare()) {
29462290 }
29472291 }
......@@ -2958,7 +2302,10 @@ deque<_Tp, _Allocator>::swap(deque& __c)
29582302 __is_nothrow_swappable<allocator_type>::value)
29592303#endif
29602304{
2961 __base::swap(__c);
2305 __map_.swap(__c.__map_);
2306 _VSTD::swap(__start_, __c.__start_);
2307 _VSTD::swap(__size(), __c.__size());
2308 _VSTD::__swap_allocator(__alloc(), __c.__alloc());
29622309}
29632310
29642311template <class _Tp, class _Allocator>
......@@ -2966,11 +2313,28 @@ inline
29662313void
29672314deque<_Tp, _Allocator>::clear() _NOEXCEPT
29682315{
2969 __base::clear();
2316 allocator_type& __a = __alloc();
2317 for (iterator __i = begin(), __e = end(); __i != __e; ++__i)
2318 __alloc_traits::destroy(__a, _VSTD::addressof(*__i));
2319 __size() = 0;
2320 while (__map_.size() > 2)
2321 {
2322 __alloc_traits::deallocate(__a, __map_.front(), __block_size);
2323 __map_.pop_front();
2324 }
2325 switch (__map_.size())
2326 {
2327 case 1:
2328 __start_ = __block_size / 2;
2329 break;
2330 case 2:
2331 __start_ = __block_size;
2332 break;
2333 }
29702334}
29712335
29722336template <class _Tp, class _Allocator>
2973inline _LIBCPP_INLINE_VISIBILITY
2337inline _LIBCPP_HIDE_FROM_ABI
29742338bool
29752339operator==(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
29762340{
......@@ -2979,7 +2343,7 @@ operator==(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
29792343}
29802344
29812345template <class _Tp, class _Allocator>
2982inline _LIBCPP_INLINE_VISIBILITY
2346inline _LIBCPP_HIDE_FROM_ABI
29832347bool
29842348operator!=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
29852349{
......@@ -2987,7 +2351,7 @@ operator!=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
29872351}
29882352
29892353template <class _Tp, class _Allocator>
2990inline _LIBCPP_INLINE_VISIBILITY
2354inline _LIBCPP_HIDE_FROM_ABI
29912355bool
29922356operator< (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
29932357{
......@@ -2995,7 +2359,7 @@ operator< (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
29952359}
29962360
29972361template <class _Tp, class _Allocator>
2998inline _LIBCPP_INLINE_VISIBILITY
2362inline _LIBCPP_HIDE_FROM_ABI
29992363bool
30002364operator> (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
30012365{
......@@ -3003,7 +2367,7 @@ operator> (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
30032367}
30042368
30052369template <class _Tp, class _Allocator>
3006inline _LIBCPP_INLINE_VISIBILITY
2370inline _LIBCPP_HIDE_FROM_ABI
30072371bool
30082372operator>=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
30092373{
......@@ -3011,7 +2375,7 @@ operator>=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
30112375}
30122376
30132377template <class _Tp, class _Allocator>
3014inline _LIBCPP_INLINE_VISIBILITY
2378inline _LIBCPP_HIDE_FROM_ABI
30152379bool
30162380operator<=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
30172381{
......@@ -3019,7 +2383,7 @@ operator<=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
30192383}
30202384
30212385template <class _Tp, class _Allocator>
3022inline _LIBCPP_INLINE_VISIBILITY
2386inline _LIBCPP_HIDE_FROM_ABI
30232387void
30242388swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y)
30252389 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
......@@ -3029,7 +2393,7 @@ swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y)
30292393
30302394#if _LIBCPP_STD_VER > 17
30312395template <class _Tp, class _Allocator, class _Up>
3032inline _LIBCPP_INLINE_VISIBILITY typename deque<_Tp, _Allocator>::size_type
2396inline _LIBCPP_HIDE_FROM_ABI typename deque<_Tp, _Allocator>::size_type
30332397erase(deque<_Tp, _Allocator>& __c, const _Up& __v) {
30342398 auto __old_size = __c.size();
30352399 __c.erase(_VSTD::remove(__c.begin(), __c.end(), __v), __c.end());
......@@ -3037,7 +2401,7 @@ erase(deque<_Tp, _Allocator>& __c, const _Up& __v) {
30372401}
30382402
30392403template <class _Tp, class _Allocator, class _Predicate>
3040inline _LIBCPP_INLINE_VISIBILITY typename deque<_Tp, _Allocator>::size_type
2404inline _LIBCPP_HIDE_FROM_ABI typename deque<_Tp, _Allocator>::size_type
30412405erase_if(deque<_Tp, _Allocator>& __c, _Predicate __pred) {
30422406 auto __old_size = __c.size();
30432407 __c.erase(_VSTD::remove_if(__c.begin(), __c.end(), __pred), __c.end());
......@@ -3055,6 +2419,25 @@ inline constexpr bool __format::__enable_insertable<std::deque<wchar_t>> = true;
30552419
30562420_LIBCPP_END_NAMESPACE_STD
30572421
2422#if _LIBCPP_STD_VER > 14
2423_LIBCPP_BEGIN_NAMESPACE_STD
2424namespace pmr {
2425template <class _ValueT>
2426using deque = std::deque<_ValueT, polymorphic_allocator<_ValueT>>;
2427} // namespace pmr
2428_LIBCPP_END_NAMESPACE_STD
2429#endif
2430
30582431_LIBCPP_POP_MACROS
30592432
2433#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
2434# include <algorithm>
2435# include <atomic>
2436# include <concepts>
2437# include <functional>
2438# include <iosfwd>
2439# include <iterator>
2440# include <typeinfo>
2441#endif
2442
30602443#endif // _LIBCPP_DEQUE
lib/libcxx/include/errno.h+3-1
......@@ -28,7 +28,9 @@ Macros:
2828# pragma GCC system_header
2929#endif
3030
31#include_next <errno.h>
31#if __has_include_next(<errno.h>)
32# include_next <errno.h>
33#endif
3234
3335#ifdef __cplusplus
3436
lib/libcxx/include/exception+70-16
......@@ -80,13 +80,21 @@ template <class E> void rethrow_if_nested(const E& e);
8080#include <__availability>
8181#include <__config>
8282#include <__memory/addressof.h>
83#include <__type_traits/decay.h>
84#include <__type_traits/is_base_of.h>
85#include <__type_traits/is_class.h>
86#include <__type_traits/is_convertible.h>
87#include <__type_traits/is_copy_constructible.h>
88#include <__type_traits/is_final.h>
89#include <__type_traits/is_polymorphic.h>
8390#include <cstddef>
8491#include <cstdlib>
85#include <type_traits>
8692#include <version>
8793
94// <vcruntime_exception.h> defines its own std::exception and std::bad_exception types,
95// which we use in order to be ABI-compatible with other STLs on Windows.
8896#if defined(_LIBCPP_ABI_VCRUNTIME)
89#include <vcruntime_exception.h>
97# include <vcruntime_exception.h>
9098#endif
9199
92100#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -96,24 +104,66 @@ template <class E> void rethrow_if_nested(const E& e);
96104namespace std // purposefully not using versioning namespace
97105{
98106
99#if !defined(_LIBCPP_ABI_VCRUNTIME)
100class _LIBCPP_EXCEPTION_ABI exception
101{
107#if defined(_LIBCPP_ABI_VCRUNTIME) && (!defined(_HAS_EXCEPTIONS) || _HAS_EXCEPTIONS != 0)
108// The std::exception class was already included above, but we're explicit about this condition here for clarity.
109
110#elif defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0
111// However, <vcruntime_exception.h> does not define std::exception and std::bad_exception
112// when _HAS_EXCEPTIONS == 0.
113//
114// Since libc++ still wants to provide the std::exception hierarchy even when _HAS_EXCEPTIONS == 0
115// (after all those are simply types like any other), we define an ABI-compatible version
116// of the VCRuntime std::exception and std::bad_exception types in that mode.
117
118struct __std_exception_data {
119 char const* _What;
120 bool _DoFree;
121};
122
123class exception { // base of all library exceptions
102124public:
103 _LIBCPP_INLINE_VISIBILITY exception() _NOEXCEPT {}
104 _LIBCPP_INLINE_VISIBILITY exception(const exception&) _NOEXCEPT = default;
125 exception() _NOEXCEPT : __data_() {}
105126
106 virtual ~exception() _NOEXCEPT;
107 virtual const char* what() const _NOEXCEPT;
127 explicit exception(char const* __message) _NOEXCEPT : __data_() {
128 __data_._What = __message;
129 __data_._DoFree = true;
130 }
131
132 exception(exception const&) _NOEXCEPT {}
133
134 exception& operator=(exception const&) _NOEXCEPT { return *this; }
135
136 virtual ~exception() _NOEXCEPT {}
137
138 virtual char const* what() const _NOEXCEPT { return __data_._What ? __data_._What : "Unknown exception"; }
139
140private:
141 __std_exception_data __data_;
108142};
109143
110class _LIBCPP_EXCEPTION_ABI bad_exception
111 : public exception
112{
144class bad_exception : public exception {
145public:
146 bad_exception() _NOEXCEPT : exception("bad exception") {}
147};
148
149#else // !defined(_LIBCPP_ABI_VCRUNTIME)
150// On all other platforms, we define our own std::exception and std::bad_exception types
151// regardless of whether exceptions are turned on as a language feature.
152
153class _LIBCPP_EXCEPTION_ABI exception {
113154public:
114 _LIBCPP_INLINE_VISIBILITY bad_exception() _NOEXCEPT {}
115 virtual ~bad_exception() _NOEXCEPT;
116 virtual const char* what() const _NOEXCEPT;
155 _LIBCPP_INLINE_VISIBILITY exception() _NOEXCEPT {}
156 _LIBCPP_INLINE_VISIBILITY exception(const exception&) _NOEXCEPT = default;
157
158 virtual ~exception() _NOEXCEPT;
159 virtual const char* what() const _NOEXCEPT;
160};
161
162class _LIBCPP_EXCEPTION_ABI bad_exception : public exception {
163public:
164 _LIBCPP_INLINE_VISIBILITY bad_exception() _NOEXCEPT {}
165 ~bad_exception() _NOEXCEPT override;
166 const char* what() const _NOEXCEPT override;
117167};
118168#endif // !_LIBCPP_ABI_VCRUNTIME
119169
......@@ -282,7 +332,7 @@ struct __throw_with_nested<_Tp, _Up, false> {
282332#endif
283333
284334template <class _Tp>
285_LIBCPP_NORETURN
335_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
286336void
287337throw_with_nested(_Tp&& __t)
288338{
......@@ -327,4 +377,8 @@ rethrow_if_nested(const _Ep&,
327377
328378} // namespace std
329379
380#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
381# include <type_traits>
382#endif
383
330384#endif // _LIBCPP_EXCEPTION
lib/libcxx/include/expected created+54
......@@ -0,0 +1,54 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_EXPECTED
11#define _LIBCPP_EXPECTED
12
13/*
14 Header <expected> synopsis
15
16namespace std {
17 // [expected.unexpected], class template unexpected
18 template<class E> class unexpected;
19
20 // [expected.bad], class template bad_expected_access
21 template<class E> class bad_expected_access;
22
23 // [expected.bad.void], specialization for void
24 template<> class bad_expected_access<void>;
25
26 // in-place construction of unexpected values
27 struct unexpect_t {
28 explicit unexpect_t() = default;
29 };
30 inline constexpr unexpect_t unexpect{};
31
32 // [expected.expected], class template expected
33 template<class T, class E> class expected;
34
35 // [expected.void], partial specialization of expected for void types
36 template<class T, class E> requires is_void_v<T> class expected<T, E>;
37}
38
39*/
40
41#include <__assert> // all public C++ headers provide the assertion handler
42#include <__config>
43#include <__expected/bad_expected_access.h>
44#include <__expected/expected.h>
45#include <__expected/unexpect.h>
46#include <__expected/unexpected.h>
47#include <version>
48
49#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
50# pragma GCC system_header
51#endif
52
53#endif // _LIBCPP_EXPECTED
54
lib/libcxx/include/experimental/__memory+2-2
......@@ -56,11 +56,11 @@ struct __lfts_uses_alloc_ctor_imp<true, _Tp, _Alloc, _Args...>
5656 = is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
5757
5858 static const bool __ic_second =
59 conditional<
59 __conditional_t<
6060 __ic_first,
6161 false_type,
6262 is_constructible<_Tp, _Args..., _Alloc>
63 >::type::value;
63 >::value;
6464
6565 static_assert(__ic_first || __ic_second,
6666 "Request for uses allocator construction is ill-formed");
lib/libcxx/include/experimental/coroutine+24-7
......@@ -50,10 +50,28 @@ template <class P> struct hash<coroutine_handle<P>>;
5050#include <__functional/operations.h>
5151#include <cstddef>
5252#include <experimental/__config>
53#include <memory> // for hash<T*>
5453#include <new>
5554#include <type_traits>
5655
56#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
57# include <atomic>
58# include <climits>
59# include <cmath>
60# include <compare>
61# include <concepts>
62# include <ctime>
63# include <initializer_list>
64# include <iosfwd>
65# include <iterator>
66# include <memory>
67# include <ratio>
68# include <stdexcept>
69# include <tuple>
70# include <typeinfo>
71# include <utility>
72# include <variant>
73#endif
74
5775#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
5876# pragma GCC system_header
5977#endif
......@@ -66,8 +84,7 @@ template <class _Tp, class = void>
6684struct __coroutine_traits_sfinae {};
6785
6886template <class _Tp>
69struct __coroutine_traits_sfinae<
70 _Tp, typename __void_t<typename _Tp::promise_type>::type>
87struct __coroutine_traits_sfinae<_Tp, __void_t<typename _Tp::promise_type> >
7188{
7289 using promise_type = typename _Tp::promise_type;
7390};
......@@ -241,7 +258,7 @@ public:
241258
242259 _LIBCPP_INLINE_VISIBILITY
243260 static coroutine_handle from_promise(_Promise& __promise) _NOEXCEPT {
244 typedef typename remove_cv<_Promise>::type _RawPromise;
261 typedef __remove_cv_t<_Promise> _RawPromise;
245262 coroutine_handle __tmp;
246263 __tmp.__handle_ = __builtin_coro_promise(
247264 _VSTD::addressof(const_cast<_RawPromise&>(__promise)),
......@@ -269,9 +286,9 @@ public:
269286 _LIBCPP_CONSTEXPR explicit operator bool() const _NOEXCEPT { return true; }
270287 _LIBCPP_CONSTEXPR bool done() const _NOEXCEPT { return false; }
271288
272 _LIBCPP_CONSTEXPR_AFTER_CXX17 void operator()() const _NOEXCEPT {}
273 _LIBCPP_CONSTEXPR_AFTER_CXX17 void resume() const _NOEXCEPT {}
274 _LIBCPP_CONSTEXPR_AFTER_CXX17 void destroy() const _NOEXCEPT {}
289 _LIBCPP_CONSTEXPR_SINCE_CXX20 void operator()() const _NOEXCEPT {}
290 _LIBCPP_CONSTEXPR_SINCE_CXX20 void resume() const _NOEXCEPT {}
291 _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy() const _NOEXCEPT {}
275292
276293private:
277294 _LIBCPP_INLINE_VISIBILITY
lib/libcxx/include/experimental/deque+4
......@@ -40,9 +40,13 @@ namespace pmr {
4040
4141_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
4242
43#ifndef _LIBCPP_CXX03_LANG
44
4345template <class _ValueT>
4446using deque = _VSTD::deque<_ValueT, polymorphic_allocator<_ValueT>>;
4547
48#endif // _LIBCPP_CXX03_LANG
49
4650_LIBCPP_END_NAMESPACE_LFTS_PMR
4751
4852#endif /* _LIBCPP_EXPERIMENTAL_DEQUE */
lib/libcxx/include/experimental/forward_list+4
......@@ -40,9 +40,13 @@ namespace pmr {
4040
4141_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
4242
43#ifndef _LIBCPP_CXX03_LANG
44
4345template <class _ValueT>
4446using forward_list = _VSTD::forward_list<_ValueT, polymorphic_allocator<_ValueT>>;
4547
48#endif // _LIBCPP_CXX03_LANG
49
4650_LIBCPP_END_NAMESPACE_LFTS_PMR
4751
4852#endif /* _LIBCPP_EXPERIMENTAL_FORWARD_LIST */
lib/libcxx/include/experimental/functional+25-25
......@@ -85,9 +85,9 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
8585# define _LIBCPP_DEPRECATED_BOYER_MOORE_SEARCHER
8686# define _LIBCPP_DEPRECATED_BOYER_MOORE_HORSPOOL_SEARCHER
8787#else
88# define _LIBCPP_DEPRECATED_DEFAULT_SEARCHER _LIBCPP_DEPRECATED_("std::exprerimental::default_searcher will be removed in LLVM 17. Use std::default_searcher instead")
89# define _LIBCPP_DEPRECATED_BOYER_MOORE_SEARCHER _LIBCPP_DEPRECATED_("std::exprerimental::boyer_moore_searcher will be removed in LLVM 17. Use std::boyer_moore_searcher instead")
90# define _LIBCPP_DEPRECATED_BOYER_MOORE_HORSPOOL_SEARCHER _LIBCPP_DEPRECATED_("std::exprerimental::boyer_moore_horspool_searcher will be removed in LLVM 17. Use std::boyer_moore_horspool_searcher instead")
88# define _LIBCPP_DEPRECATED_DEFAULT_SEARCHER _LIBCPP_DEPRECATED_("std::experimental::default_searcher will be removed in LLVM 17. Use std::default_searcher instead")
89# define _LIBCPP_DEPRECATED_BOYER_MOORE_SEARCHER _LIBCPP_DEPRECATED_("std::experimental::boyer_moore_searcher will be removed in LLVM 17. Use std::boyer_moore_searcher instead")
90# define _LIBCPP_DEPRECATED_BOYER_MOORE_HORSPOOL_SEARCHER _LIBCPP_DEPRECATED_("std::experimental::boyer_moore_horspool_searcher will be removed in LLVM 17. Use std::boyer_moore_horspool_searcher instead")
9191#endif
9292
9393#if _LIBCPP_STD_VER > 11
......@@ -132,24 +132,24 @@ class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, false> {
132132 typedef _Key key_type;
133133
134134 const _Value __default_value_;
135 std::unordered_map<_Key, _Value, _Hash, _BinaryPredicate> __table;
135 std::unordered_map<_Key, _Value, _Hash, _BinaryPredicate> __table_;
136136
137137public:
138138 _LIBCPP_INLINE_VISIBILITY
139139 _BMSkipTable(size_t __sz, _Value __default, _Hash __hf, _BinaryPredicate __pred)
140 : __default_value_(__default), __table(__sz, __hf, __pred) {}
140 : __default_value_(__default), __table_(__sz, __hf, __pred) {}
141141
142142 _LIBCPP_INLINE_VISIBILITY
143143 void insert(const key_type &__key, value_type __val)
144144 {
145 __table [__key] = __val; // Would skip_.insert (val) be better here?
145 __table_ [__key] = __val; // Would skip_.insert (val) be better here?
146146 }
147147
148148 _LIBCPP_INLINE_VISIBILITY
149149 value_type operator [](const key_type & __key) const
150150 {
151 auto __it = __table.find (__key);
152 return __it == __table.end() ? __default_value_ : __it->second;
151 auto __it = __table_.find (__key);
152 return __it == __table_.end() ? __default_value_ : __it->second;
153153 }
154154};
155155
......@@ -161,27 +161,27 @@ private:
161161 typedef _Value value_type;
162162 typedef _Key key_type;
163163
164 typedef typename make_unsigned<key_type>::type unsigned_key_type;
164 typedef __make_unsigned_t<key_type> unsigned_key_type;
165165 typedef std::array<value_type, 256> skip_map;
166 skip_map __table;
166 skip_map __table_;
167167
168168public:
169169 _LIBCPP_INLINE_VISIBILITY
170170 _BMSkipTable(size_t /*__sz*/, _Value __default, _Hash /*__hf*/, _BinaryPredicate /*__pred*/)
171171 {
172 std::fill_n(__table.begin(), __table.size(), __default);
172 std::fill_n(__table_.begin(), __table_.size(), __default);
173173 }
174174
175175 _LIBCPP_INLINE_VISIBILITY
176176 void insert(key_type __key, value_type __val)
177177 {
178 __table[static_cast<unsigned_key_type>(__key)] = __val;
178 __table_[static_cast<unsigned_key_type>(__key)] = __val;
179179 }
180180
181181 _LIBCPP_INLINE_VISIBILITY
182182 value_type operator [](key_type __key) const
183183 {
184 return __table[static_cast<unsigned_key_type>(__key)];
184 return __table_[static_cast<unsigned_key_type>(__key)];
185185 }
186186};
187187
......@@ -205,8 +205,8 @@ public:
205205 _Hash __hf = _Hash(), _BinaryPredicate __pred = _BinaryPredicate())
206206 : __first_(__f), __last_(__l), __pred_(__pred),
207207 __pattern_length_(_VSTD::distance(__first_, __last_)),
208 __skip_{make_shared<skip_table_type>(__pattern_length_, -1, __hf, __pred_)},
209 __suffix_{make_shared<vector<difference_type>>(__pattern_length_ + 1)}
208 __skip_{std::make_shared<skip_table_type>(__pattern_length_, -1, __hf, __pred_)},
209 __suffix_{std::make_shared<vector<difference_type>>(__pattern_length_ + 1)}
210210 {
211211 // build the skip table
212212 for ( difference_type __i = 0; __f != __l; ++__f, (void) ++__i )
......@@ -223,12 +223,12 @@ public:
223223 typename iterator_traits<_RandomAccessIterator2>::value_type>::value,
224224 "Corpus and Pattern iterators must point to the same type");
225225
226 if (__f == __l ) return make_pair(__l, __l); // empty corpus
227 if (__first_ == __last_) return make_pair(__f, __f); // empty pattern
226 if (__f == __l ) return std::make_pair(__l, __l); // empty corpus
227 if (__first_ == __last_) return std::make_pair(__f, __f); // empty pattern
228228
229229 // If the pattern is larger than the corpus, we can't find it!
230230 if ( __pattern_length_ > _VSTD::distance(__f, __l))
231 return make_pair(__l, __l);
231 return std::make_pair(__l, __l);
232232
233233 // Do the search
234234 return this->__search(__f, __l);
......@@ -260,7 +260,7 @@ private:
260260 __j--;
261261 // We matched - we're done!
262262 if ( __j == 0 )
263 return make_pair(__cur, __cur + __pattern_length_);
263 return std::make_pair(__cur, __cur + __pattern_length_);
264264 }
265265
266266 // Since we didn't match, figure out how far to skip forward
......@@ -272,7 +272,7 @@ private:
272272 __cur += __suffix[ __j ];
273273 }
274274
275 return make_pair(__l, __l); // We didn't find anything
275 return std::make_pair(__l, __l); // We didn't find anything
276276 }
277277
278278
......@@ -373,12 +373,12 @@ public:
373373 typename std::iterator_traits<_RandomAccessIterator2>::value_type>::value,
374374 "Corpus and Pattern iterators must point to the same type");
375375
376 if (__f == __l ) return make_pair(__l, __l); // empty corpus
377 if (__first_ == __last_) return make_pair(__f, __f); // empty pattern
376 if (__f == __l ) return std::make_pair(__l, __l); // empty corpus
377 if (__first_ == __last_) return std::make_pair(__f, __f); // empty pattern
378378
379379 // If the pattern is larger than the corpus, we can't find it!
380380 if ( __pattern_length_ > _VSTD::distance(__f, __l))
381 return make_pair(__l, __l);
381 return std::make_pair(__l, __l);
382382
383383 // Do the search
384384 return this->__search(__f, __l);
......@@ -407,12 +407,12 @@ private:
407407 __j--;
408408 // We matched - we're done!
409409 if ( __j == 0 )
410 return make_pair(__cur, __cur + __pattern_length_);
410 return std::make_pair(__cur, __cur + __pattern_length_);
411411 }
412412 __cur += __skip[__cur[__pattern_length_-1]];
413413 }
414414
415 return make_pair(__l, __l);
415 return std::make_pair(__l, __l);
416416 }
417417};
418418
lib/libcxx/include/experimental/iterator+15-10
......@@ -54,6 +54,7 @@ namespace std {
5454
5555#include <__assert> // all public C++ headers provide the assertion handler
5656#include <__memory/addressof.h>
57#include <__type_traits/decay.h>
5758#include <__utility/forward.h>
5859#include <__utility/move.h>
5960#include <experimental/__config>
......@@ -82,19 +83,19 @@ public:
8283 typedef void reference;
8384
8485 ostream_joiner(ostream_type& __os, _Delim&& __d)
85 : __output_iter(_VSTD::addressof(__os)), __delim(_VSTD::move(__d)), __first(true) {}
86 : __output_iter_(_VSTD::addressof(__os)), __delim_(_VSTD::move(__d)), __first_(true) {}
8687
8788 ostream_joiner(ostream_type& __os, const _Delim& __d)
88 : __output_iter(_VSTD::addressof(__os)), __delim(__d), __first(true) {}
89 : __output_iter_(_VSTD::addressof(__os)), __delim_(__d), __first_(true) {}
8990
9091
9192 template<typename _Tp>
9293 ostream_joiner& operator=(const _Tp& __v)
9394 {
94 if (!__first)
95 *__output_iter << __delim;
96 __first = false;
97 *__output_iter << __v;
95 if (!__first_)
96 *__output_iter_ << __delim_;
97 __first_ = false;
98 *__output_iter_ << __v;
9899 return *this;
99100 }
100101
......@@ -103,14 +104,14 @@ public:
103104 ostream_joiner& operator++(int) _NOEXCEPT { return *this; }
104105
105106private:
106 ostream_type* __output_iter;
107 _Delim __delim;
108 bool __first;
107 ostream_type* __output_iter_;
108 _Delim __delim_;
109 bool __first_;
109110};
110111
111112
112113template <class _CharT, class _Traits, class _Delim>
113ostream_joiner<typename decay<_Delim>::type, _CharT, _Traits>
114_LIBCPP_HIDE_FROM_ABI ostream_joiner<typename decay<_Delim>::type, _CharT, _Traits>
114115make_ostream_joiner(basic_ostream<_CharT, _Traits>& __os, _Delim && __d)
115116{ return ostream_joiner<typename decay<_Delim>::type, _CharT, _Traits>(__os, _VSTD::forward<_Delim>(__d)); }
116117
......@@ -118,4 +119,8 @@ _LIBCPP_END_NAMESPACE_LFTS
118119
119120#endif // _LIBCPP_STD_VER > 11
120121
122#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
123# include <type_traits>
124#endif
125
121126#endif // _LIBCPP_EXPERIMENTAL_ITERATOR
lib/libcxx/include/experimental/list+4
......@@ -40,9 +40,13 @@ namespace pmr {
4040
4141_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
4242
43#ifndef _LIBCPP_CXX03_LANG
44
4345template <class _ValueT>
4446using list = _VSTD::list<_ValueT, polymorphic_allocator<_ValueT>>;
4547
48#endif // _LIBCPP_CXX03_LANG
49
4650_LIBCPP_END_NAMESPACE_LFTS_PMR
4751
4852#endif /* _LIBCPP_EXPERIMENTAL_LIST */
lib/libcxx/include/experimental/map+4
......@@ -45,6 +45,8 @@ namespace pmr {
4545
4646_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
4747
48#ifndef _LIBCPP_CXX03_LANG
49
4850template <class _Key, class _Value, class _Compare = less<_Key>>
4951using map = _VSTD::map<_Key, _Value, _Compare,
5052 polymorphic_allocator<pair<const _Key, _Value>>>;
......@@ -53,6 +55,8 @@ template <class _Key, class _Value, class _Compare = less<_Key>>
5355using multimap = _VSTD::multimap<_Key, _Value, _Compare,
5456 polymorphic_allocator<pair<const _Key, _Value>>>;
5557
58#endif // _LIBCPP_CXX03_LANG
59
5660_LIBCPP_END_NAMESPACE_LFTS_PMR
5761
5862#endif /* _LIBCPP_EXPERIMENTAL_MAP */
lib/libcxx/include/experimental/memory_resource+37-13
......@@ -65,16 +65,16 @@ namespace pmr {
6565 */
6666
6767#include <__assert> // all public C++ headers provide the assertion handler
68#include <__tuple>
68#include <__memory/allocator_traits.h>
6969#include <__utility/move.h>
7070#include <cstddef>
7171#include <cstdlib>
7272#include <experimental/__config>
7373#include <experimental/__memory>
7474#include <limits>
75#include <memory>
7675#include <new>
7776#include <stdexcept>
77#include <tuple>
7878#include <type_traits>
7979
8080#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -86,6 +86,12 @@ _LIBCPP_PUSH_MACROS
8686
8787_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
8888
89#define _LIBCPP_DEPCREATED_MEMORY_RESOURCE(name) \
90 _LIBCPP_DEPRECATED_("'std::experimental::pmr::" name \
91 "' is deprecated and will be removed in LLVM 18. Use 'std::pmr::" name "' instead.")
92
93#ifndef _LIBCPP_CXX03_LANG
94
8995// Round __s up to next multiple of __a.
9096inline _LIBCPP_INLINE_VISIBILITY
9197size_t __aligned_allocation_size(size_t __s, size_t __a) _NOEXCEPT
......@@ -95,7 +101,7 @@ size_t __aligned_allocation_size(size_t __s, size_t __a) _NOEXCEPT
95101}
96102
97103// 8.5, memory.resource
98class _LIBCPP_TYPE_VIS memory_resource
104class _LIBCPP_DEPCREATED_MEMORY_RESOURCE("memory_resource") _LIBCPP_TYPE_VIS memory_resource
99105{
100106 static const size_t __max_align = _LIBCPP_ALIGNOF(max_align_t);
101107
......@@ -123,37 +129,37 @@ private:
123129};
124130
125131// 8.5.4, memory.resource.eq
126inline _LIBCPP_INLINE_VISIBILITY
132_LIBCPP_DEPCREATED_MEMORY_RESOURCE("operator==(memory_resource, memory_resource)") inline _LIBCPP_INLINE_VISIBILITY
127133bool operator==(memory_resource const & __lhs,
128134 memory_resource const & __rhs) _NOEXCEPT
129135{
130136 return &__lhs == &__rhs || __lhs.is_equal(__rhs);
131137}
132138
133inline _LIBCPP_INLINE_VISIBILITY
139_LIBCPP_DEPCREATED_MEMORY_RESOURCE("operator!=(memory_resource, memory_resource)") inline _LIBCPP_INLINE_VISIBILITY
134140bool operator!=(memory_resource const & __lhs,
135141 memory_resource const & __rhs) _NOEXCEPT
136142{
137143 return !(__lhs == __rhs);
138144}
139145
140_LIBCPP_FUNC_VIS
146_LIBCPP_DEPCREATED_MEMORY_RESOURCE("new_delete_resource()") _LIBCPP_FUNC_VIS
141147memory_resource * new_delete_resource() _NOEXCEPT;
142148
143_LIBCPP_FUNC_VIS
149_LIBCPP_DEPCREATED_MEMORY_RESOURCE("null_memory_resource()") _LIBCPP_FUNC_VIS
144150memory_resource * null_memory_resource() _NOEXCEPT;
145151
146_LIBCPP_FUNC_VIS
152_LIBCPP_DEPCREATED_MEMORY_RESOURCE("get_default_resource()") _LIBCPP_FUNC_VIS
147153memory_resource * get_default_resource() _NOEXCEPT;
148154
149_LIBCPP_FUNC_VIS
155_LIBCPP_DEPCREATED_MEMORY_RESOURCE("set_default_resource()") _LIBCPP_FUNC_VIS
150156memory_resource * set_default_resource(memory_resource * __new_res) _NOEXCEPT;
151157
152158// 8.6, memory.polymorphic.allocator.class
153159
154160// 8.6.1, memory.polymorphic.allocator.overview
155161template <class _ValueType>
156class _LIBCPP_TEMPLATE_VIS polymorphic_allocator
162class _LIBCPP_DEPCREATED_MEMORY_RESOURCE("polymorphic_allocator") _LIBCPP_TEMPLATE_VIS polymorphic_allocator
157163{
158164public:
159165 typedef _ValueType value_type;
......@@ -314,6 +320,7 @@ private:
314320// 8.6.4, memory.polymorphic.allocator.eq
315321
316322template <class _Tp, class _Up>
323_LIBCPP_DEPCREATED_MEMORY_RESOURCE("operator==(const polymorphic_allocator&, const polymorphic_allocator&)")
317324inline _LIBCPP_INLINE_VISIBILITY
318325bool operator==(polymorphic_allocator<_Tp> const & __lhs,
319326 polymorphic_allocator<_Up> const & __rhs) _NOEXCEPT
......@@ -322,6 +329,7 @@ bool operator==(polymorphic_allocator<_Tp> const & __lhs,
322329}
323330
324331template <class _Tp, class _Up>
332_LIBCPP_DEPCREATED_MEMORY_RESOURCE("operator!=(const polymorphic_allocator&, const polymorphic_allocator&)")
325333inline _LIBCPP_INLINE_VISIBILITY
326334bool operator!=(polymorphic_allocator<_Tp> const & __lhs,
327335 polymorphic_allocator<_Up> const & __rhs) _NOEXCEPT
......@@ -331,6 +339,7 @@ bool operator!=(polymorphic_allocator<_Tp> const & __lhs,
331339
332340// 8.7, memory.resource.adaptor
333341
342_LIBCPP_SUPPRESS_DEPRECATED_PUSH
334343// 8.7.1, memory.resource.adaptor.overview
335344template <class _CharAlloc>
336345class _LIBCPP_TEMPLATE_VIS __resource_adaptor_imp
......@@ -379,7 +388,7 @@ public:
379388
380389// 8.7.3, memory.resource.adaptor.mem
381390private:
382 virtual void * do_allocate(size_t __bytes, size_t)
391 void * do_allocate(size_t __bytes, size_t) override
383392 {
384393 if (__bytes > __max_size())
385394 __throw_bad_array_new_length();
......@@ -387,7 +396,7 @@ private:
387396 return __alloc_.allocate(__s);
388397 }
389398
390 virtual void do_deallocate(void * __p, size_t __bytes, size_t)
399 void do_deallocate(void * __p, size_t __bytes, size_t) override
391400 {
392401 _LIBCPP_ASSERT(__bytes <= __max_size(),
393402 "do_deallocate called for size which exceeds the maximum allocation size");
......@@ -395,7 +404,7 @@ private:
395404 __alloc_.deallocate((_ValueType*)__p, __s);
396405 }
397406
398 virtual bool do_is_equal(memory_resource const & __other) const _NOEXCEPT {
407 bool do_is_equal(memory_resource const & __other) const _NOEXCEPT override {
399408 __resource_adaptor_imp const * __p
400409 = dynamic_cast<__resource_adaptor_imp const *>(&__other);
401410 return __p ? __alloc_ == __p->__alloc_ : false;
......@@ -411,9 +420,24 @@ template <class _Alloc>
411420using resource_adaptor = __resource_adaptor_imp<
412421 typename allocator_traits<_Alloc>::template rebind_alloc<char>
413422 >;
423_LIBCPP_SUPPRESS_DEPRECATED_POP
424
425#endif // _LIBCPP_CXX03_LANG
414426
415427_LIBCPP_END_NAMESPACE_LFTS_PMR
416428
417429_LIBCPP_POP_MACROS
418430
431#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
432# include <atomic>
433# include <climits>
434# include <concepts>
435# include <cstring>
436# include <ctime>
437# include <iterator>
438# include <memory>
439# include <ratio>
440# include <variant>
441#endif
442
419443#endif /* _LIBCPP_EXPERIMENTAL_MEMORY_RESOURCE */
lib/libcxx/include/experimental/propagate_const+4-3
......@@ -109,6 +109,7 @@
109109
110110#include <__assert> // all public C++ headers provide the assertion handler
111111#include <__functional/operations.h>
112#include <__fwd/hash.h>
112113#include <__utility/forward.h>
113114#include <__utility/move.h>
114115#include <__utility/swap.h>
......@@ -138,15 +139,15 @@ template <class _Tp>
138139class propagate_const
139140{
140141public:
141 typedef remove_reference_t<decltype(*declval<_Tp&>())> element_type;
142 typedef remove_reference_t<decltype(*std::declval<_Tp&>())> element_type;
142143
143144 static_assert(!is_array<_Tp>::value,
144145 "Instantiation of propagate_const with an array type is ill-formed.");
145146 static_assert(!is_reference<_Tp>::value,
146147 "Instantiation of propagate_const with a reference type is ill-formed.");
147 static_assert(!(is_pointer<_Tp>::value && is_function<typename remove_pointer<_Tp>::type>::value),
148 static_assert(!(is_pointer<_Tp>::value && is_function<__remove_pointer_t<_Tp> >::value),
148149 "Instantiation of propagate_const with a function-pointer type is ill-formed.");
149 static_assert(!(is_pointer<_Tp>::value && is_same<typename remove_cv<typename remove_pointer<_Tp>::type>::type, void>::value),
150 static_assert(!(is_pointer<_Tp>::value && is_same<__remove_cv_t<__remove_pointer_t<_Tp> >, void>::value),
150151 "Instantiation of propagate_const with a pointer to (possibly cv-qualified) void is ill-formed.");
151152
152153private:
lib/libcxx/include/experimental/regex+8-4
......@@ -48,18 +48,22 @@ namespace pmr {
4848
4949_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
5050
51#ifndef _LIBCPP_CXX03_LANG
52
5153template <class _BiDirIter>
5254using match_results =
5355 _VSTD::match_results<_BiDirIter,
5456 polymorphic_allocator<_VSTD::sub_match<_BiDirIter>>>;
5557
56typedef match_results<const char*> cmatch;
57typedef match_results<_VSTD_LFTS_PMR::string::const_iterator> smatch;
58_LIBCPP_DEPCREATED_MEMORY_RESOURCE("cmatch") typedef match_results<const char*> cmatch;
59_LIBCPP_DEPCREATED_MEMORY_RESOURCE("smatch") typedef match_results<_VSTD_LFTS_PMR::string::const_iterator> smatch;
5860#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
59typedef match_results<const wchar_t*> wcmatch;
60typedef match_results<_VSTD_LFTS_PMR::wstring::const_iterator> wsmatch;
61_LIBCPP_DEPCREATED_MEMORY_RESOURCE("wcmatch") typedef match_results<const wchar_t*> wcmatch;
62_LIBCPP_DEPCREATED_MEMORY_RESOURCE("wsmatch") typedef match_results<_VSTD_LFTS_PMR::wstring::const_iterator> wsmatch;
6163#endif
6264
65#endif // _LIBCPP_CXX03_LANG
66
6367_LIBCPP_END_NAMESPACE_LFTS_PMR
6468
6569#endif /* _LIBCPP_EXPERIMENTAL_REGEX */
lib/libcxx/include/experimental/set+4
......@@ -45,6 +45,8 @@ namespace pmr {
4545
4646_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
4747
48#ifndef _LIBCPP_CXX03_LANG
49
4850template <class _Value, class _Compare = less<_Value>>
4951using set = _VSTD::set<_Value, _Compare,
5052 polymorphic_allocator<_Value>>;
......@@ -53,6 +55,8 @@ template <class _Value, class _Compare = less<_Value>>
5355using multiset = _VSTD::multiset<_Value, _Compare,
5456 polymorphic_allocator<_Value>>;
5557
58#endif // _LIBCPP_CXX03_LANG
59
5660_LIBCPP_END_NAMESPACE_LFTS_PMR
5761
5862#endif /* _LIBCPP_EXPERIMENTAL_SET */
lib/libcxx/include/experimental/simd+26-23
......@@ -6,6 +6,7 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP_EXPERIMENTAL_SIMD
1011#define _LIBCPP_EXPERIMENTAL_SIMD
1112
......@@ -656,11 +657,6 @@ public:
656657#include <experimental/__config>
657658#include <tuple>
658659
659#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
660# include <algorithm>
661# include <functional>
662#endif
663
664660#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
665661# pragma GCC system_header
666662#endif
......@@ -720,12 +716,12 @@ public:
720716
721717#ifndef _LIBCPP_HAS_NO_VECTOR_EXTENSION
722718
723constexpr size_t __floor_pow_of_2(size_t __val) {
719_LIBCPP_HIDE_FROM_ABI constexpr size_t __floor_pow_of_2(size_t __val) {
724720 return ((__val - 1) & __val) == 0 ? __val
725721 : __floor_pow_of_2((__val - 1) & __val);
726722}
727723
728constexpr size_t __ceil_pow_of_2(size_t __val) {
724_LIBCPP_HIDE_FROM_ABI constexpr size_t __ceil_pow_of_2(size_t __val) {
729725 return __val == 1 ? 1 : __floor_pow_of_2(__val - 1) << 1;
730726}
731727
......@@ -913,25 +909,27 @@ public:
913909};
914910
915911template <class _To, class _From>
916constexpr decltype(_To{std::declval<_From>()}, true)
912_LIBCPP_HIDE_FROM_ABI constexpr decltype(_To{std::declval<_From>()}, true)
917913__is_non_narrowing_convertible_impl(_From) {
918914 return true;
919915}
920916
921917template <class _To>
922constexpr bool __is_non_narrowing_convertible_impl(...) {
918_LIBCPP_HIDE_FROM_ABI constexpr bool __is_non_narrowing_convertible_impl(...) {
923919 return false;
924920}
925921
926922template <class _From, class _To>
923_LIBCPP_HIDE_FROM_ABI
927924constexpr typename std::enable_if<std::is_arithmetic<_To>::value &&
928925 std::is_arithmetic<_From>::value,
929926 bool>::type
930927__is_non_narrowing_arithmetic_convertible() {
931 return __is_non_narrowing_convertible_impl<_To>(_From{});
928 return experimental::__is_non_narrowing_convertible_impl<_To>(_From{});
932929}
933930
934931template <class _From, class _To>
932_LIBCPP_HIDE_FROM_ABI
935933constexpr typename std::enable_if<!(std::is_arithmetic<_To>::value &&
936934 std::is_arithmetic<_From>::value),
937935 bool>::type
......@@ -940,13 +938,13 @@ __is_non_narrowing_arithmetic_convertible() {
940938}
941939
942940template <class _Tp>
943constexpr _Tp __variadic_sum() {
941_LIBCPP_HIDE_FROM_ABI constexpr _Tp __variadic_sum() {
944942 return _Tp{};
945943}
946944
947945template <class _Tp, class _Up, class... _Args>
948constexpr _Tp __variadic_sum(_Up __first, _Args... __rest) {
949 return static_cast<_Tp>(__first) + __variadic_sum<_Tp>(__rest...);
946_LIBCPP_HIDE_FROM_ABI constexpr _Tp __variadic_sum(_Up __first, _Args... __rest) {
947 return static_cast<_Tp>(__first) + experimental::__variadic_sum<_Tp>(__rest...);
950948}
951949
952950template <class _Tp>
......@@ -955,7 +953,7 @@ struct __nodeduce {
955953};
956954
957955template <class _Tp>
958constexpr bool __vectorizable() {
956_LIBCPP_HIDE_FROM_ABI constexpr bool __vectorizable() {
959957 return std::is_arithmetic<_Tp>::value && !std::is_const<_Tp>::value &&
960958 !std::is_volatile<_Tp>::value && !std::is_same<_Tp, bool>::value;
961959}
......@@ -1060,7 +1058,7 @@ struct simd_size<_Tp, __simd_abi<__kind, _Np>>
10601058 : std::integral_constant<size_t, _Np> {
10611059 static_assert(
10621060 std::is_arithmetic<_Tp>::value &&
1063 !std::is_same<typename std::remove_const<_Tp>::type, bool>::value,
1061 !std::is_same<__remove_const_t<_Tp>, bool>::value,
10641062 "Element type should be vectorizable");
10651063};
10661064
......@@ -1123,13 +1121,13 @@ struct __simd_cast_traits<simd<_Tp, _NewAbi>> {
11231121};
11241122
11251123template <class _Tp, class _Up, class _Abi>
1126auto simd_cast(const simd<_Up, _Abi>& __v)
1124_LIBCPP_HIDE_FROM_ABI auto simd_cast(const simd<_Up, _Abi>& __v)
11271125 -> decltype(__simd_cast_traits<_Tp>::__apply(__v)) {
11281126 return __simd_cast_traits<_Tp>::__apply(__v);
11291127}
11301128
11311129template <class _Tp, class _Up, class _Abi>
1132auto static_simd_cast(const simd<_Up, _Abi>& __v)
1130_LIBCPP_HIDE_FROM_ABI auto static_simd_cast(const simd<_Up, _Abi>& __v)
11331131 -> decltype(__static_simd_cast_traits<_Tp>::__apply(__v)) {
11341132 return __static_simd_cast_traits<_Tp>::__apply(__v);
11351133}
......@@ -1172,12 +1170,12 @@ array<_SimdType, simd_size<typename _SimdType::value_type, _Abi>::value /
11721170split(const simd_mask<typename _SimdType::value_type, _Abi>&);
11731171
11741172template <class _Tp, class... _Abis>
1175simd<_Tp, abi_for_size_t<_Tp, __variadic_sum(simd_size<_Tp, _Abis>::value...)>>
1173simd<_Tp, abi_for_size_t<_Tp, experimental::__variadic_sum(simd_size<_Tp, _Abis>::value...)>>
11761174concat(const simd<_Tp, _Abis>&...);
11771175
11781176template <class _Tp, class... _Abis>
11791177simd_mask<_Tp,
1180 abi_for_size_t<_Tp, __variadic_sum(simd_size<_Tp, _Abis>::value...)>>
1178 abi_for_size_t<_Tp, experimental::__variadic_sum(simd_size<_Tp, _Abis>::value...)>>
11811179concat(const simd_mask<_Tp, _Abis>&...);
11821180
11831181// reductions [simd.mask.reductions]
......@@ -1302,7 +1300,7 @@ class const_where_expression {
13021300public:
13031301 const_where_expression(const const_where_expression&) = delete;
13041302 const_where_expression& operator=(const const_where_expression&) = delete;
1305 typename remove_const<_Tp>::type operator-() const&&;
1303 __remove_const_t<_Tp> operator-() const&&;
13061304 template <class _Up, class _Flags>
13071305 void copy_to(_Up*, _Flags) const&&;
13081306};
......@@ -1369,8 +1367,8 @@ private:
13691367 __is_non_narrowing_arithmetic_convertible<_Up, _Tp>()) ||
13701368 (!std::is_arithmetic<_Up>::value &&
13711369 std::is_convertible<_Up, _Tp>::value) ||
1372 std::is_same<typename std::remove_const<_Up>::type, int>::value ||
1373 (std::is_same<typename std::remove_const<_Up>::type,
1370 std::is_same<__remove_const_t<_Up>, int>::value ||
1371 (std::is_same<__remove_const_t<_Up>,
13741372 unsigned int>::value &&
13751373 std::is_unsigned<_Tp>::value);
13761374 }
......@@ -1381,7 +1379,7 @@ private:
13811379 std::integral_constant<size_t, __indicies>())...),
13821380 bool())
13831381 __can_generate(std::index_sequence<__indicies...>) {
1384 return !__variadic_sum<bool>(
1382 return !experimental::__variadic_sum<bool>(
13851383 !__can_broadcast<decltype(std::declval<_Generator>()(
13861384 std::integral_constant<size_t, __indicies>()))>()...);
13871385 }
......@@ -1579,4 +1577,9 @@ _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
15791577
15801578_LIBCPP_POP_MACROS
15811579
1580#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1581# include <algorithm>
1582# include <functional>
1583#endif
1584
15821585#endif /* _LIBCPP_EXPERIMENTAL_SIMD */
lib/libcxx/include/experimental/string+12-4
......@@ -49,17 +49,25 @@ namespace pmr {
4949
5050_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
5151
52#ifndef _LIBCPP_CXX03_LANG
53
54_LIBCPP_SUPPRESS_DEPRECATED_PUSH
55
5256template <class _CharT, class _Traits = char_traits<_CharT>>
5357using basic_string =
5458 _VSTD::basic_string<_CharT, _Traits, polymorphic_allocator<_CharT>>;
5559
56typedef basic_string<char> string;
57typedef basic_string<char16_t> u16string;
58typedef basic_string<char32_t> u32string;
60_LIBCPP_DEPCREATED_MEMORY_RESOURCE("string") typedef basic_string<char> string;
61_LIBCPP_DEPCREATED_MEMORY_RESOURCE("u16string") typedef basic_string<char16_t> u16string;
62_LIBCPP_DEPCREATED_MEMORY_RESOURCE("u32string") typedef basic_string<char32_t> u32string;
5963#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
60typedef basic_string<wchar_t> wstring;
64_LIBCPP_DEPCREATED_MEMORY_RESOURCE("wstring") typedef basic_string<wchar_t> wstring;
6165#endif
6266
67_LIBCPP_SUPPRESS_DEPRECATED_POP
68
69#endif // _LIBCPP_CXX03_LANG
70
6371_LIBCPP_END_NAMESPACE_LFTS_PMR
6472
6573#endif /* _LIBCPP_EXPERIMENTAL_STRING */
lib/libcxx/include/experimental/unordered_map+12-8
......@@ -45,20 +45,14 @@ namespace pmr {
4545#include <experimental/memory_resource>
4646#include <unordered_map>
4747
48#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
49# include <algorithm>
50# include <array>
51# include <bit>
52# include <functional>
53# include <vector>
54#endif
55
5648#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
5749# pragma GCC system_header
5850#endif
5951
6052_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
6153
54#ifndef _LIBCPP_CXX03_LANG
55
6256template <class _Key, class _Value,
6357 class _Hash = hash<_Key>, class _Pred = equal_to<_Key>>
6458using unordered_map = _VSTD::unordered_map<_Key, _Value, _Hash, _Pred,
......@@ -69,6 +63,16 @@ template <class _Key, class _Value,
6963using unordered_multimap = _VSTD::unordered_multimap<_Key, _Value, _Hash, _Pred,
7064 polymorphic_allocator<pair<const _Key, _Value>>>;
7165
66#endif // _LIBCPP_CXX03_LANG
67
7268_LIBCPP_END_NAMESPACE_LFTS_PMR
7369
70#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
71# include <algorithm>
72# include <array>
73# include <bit>
74# include <functional>
75# include <vector>
76#endif
77
7478#endif /* _LIBCPP_EXPERIMENTAL_UNORDERED_MAP */
lib/libcxx/include/experimental/unordered_set+4
......@@ -45,6 +45,8 @@ namespace pmr {
4545
4646_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
4747
48#ifndef _LIBCPP_CXX03_LANG
49
4850template <class _Value,
4951 class _Hash = hash<_Value>, class _Pred = equal_to<_Value>>
5052using unordered_set = _VSTD::unordered_set<_Value, _Hash, _Pred,
......@@ -55,6 +57,8 @@ template <class _Value,
5557using unordered_multiset = _VSTD::unordered_multiset<_Value, _Hash, _Pred,
5658 polymorphic_allocator<_Value>>;
5759
60#endif // _LIBCPP_CXX03_LANG
61
5862_LIBCPP_END_NAMESPACE_LFTS_PMR
5963
6064#endif /* _LIBCPP_EXPERIMENTAL_UNORDERED_SET */
lib/libcxx/include/experimental/vector+4
......@@ -40,9 +40,13 @@ namespace pmr {
4040
4141_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
4242
43#ifndef _LIBCPP_CXX03_LANG
44
4345template <class _ValueT>
4446using vector = _VSTD::vector<_ValueT, polymorphic_allocator<_ValueT>>;
4547
48#endif // _LIBCPP_CXX03_LANG
49
4650_LIBCPP_END_NAMESPACE_LFTS_PMR
4751
4852#endif /* _LIBCPP_EXPERIMENTAL_VECTOR */
lib/libcxx/include/ext/__hash+1
......@@ -14,6 +14,7 @@
1414
1515#include <__config>
1616#include <cstring>
17#include <stddef.h>
1718#include <string>
1819
1920namespace __gnu_cxx {
lib/libcxx/include/ext/hash_map+11-11
......@@ -210,10 +210,6 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
210210#include <stdexcept>
211211#include <type_traits>
212212
213#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
214# include <iterator>
215#endif
216
217213#if defined(__DEPRECATED) && __DEPRECATED
218214#if defined(_LIBCPP_WARNING)
219215 _LIBCPP_WARNING("Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>")
......@@ -382,7 +378,7 @@ public:
382378 typedef std::pair<key_type, mapped_type> value_type;
383379 typedef typename _HashIterator::difference_type difference_type;
384380 typedef value_type& reference;
385 typedef typename std::__rebind_pointer<typename _HashIterator::pointer, value_type>::type
381 typedef std::__rebind_pointer_t<typename _HashIterator::pointer, value_type>
386382 pointer;
387383
388384 _LIBCPP_INLINE_VISIBILITY __hash_map_iterator() {}
......@@ -427,7 +423,7 @@ public:
427423 typedef std::pair<key_type, mapped_type> value_type;
428424 typedef typename _HashIterator::difference_type difference_type;
429425 typedef const value_type& reference;
430 typedef typename std::__rebind_pointer<typename _HashIterator::pointer, const value_type>::type
426 typedef std::__rebind_pointer_t<typename _HashIterator::pointer, const value_type>
431427 pointer;
432428
433429 _LIBCPP_INLINE_VISIBILITY __hash_map_const_iterator() {}
......@@ -487,8 +483,7 @@ private:
487483 typedef std::pair<key_type, mapped_type> __value_type;
488484 typedef __hash_map_hasher<__value_type, hasher> __hasher;
489485 typedef __hash_map_equal<__value_type, key_equal> __key_equal;
490 typedef typename std::__rebind_alloc_helper<
491 std::allocator_traits<allocator_type>, __value_type>::type __allocator_type;
486 typedef std::__rebind_alloc<std::allocator_traits<allocator_type>, __value_type> __allocator_type;
492487
493488 typedef std::__hash_table<__value_type, __hasher,
494489 __key_equal, __allocator_type> __table;
......@@ -714,7 +709,7 @@ swap(hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
714709}
715710
716711template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
717bool
712_LIBCPP_HIDE_FROM_ABI bool
718713operator==(const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
719714 const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
720715{
......@@ -761,7 +756,7 @@ private:
761756 typedef std::pair<key_type, mapped_type> __value_type;
762757 typedef __hash_map_hasher<__value_type, hasher> __hasher;
763758 typedef __hash_map_equal<__value_type, key_equal> __key_equal;
764 typedef typename std::__rebind_alloc_helper<std::allocator_traits<allocator_type>, __value_type>::type __allocator_type;
759 typedef std::__rebind_alloc<std::allocator_traits<allocator_type>, __value_type> __allocator_type;
765760
766761 typedef std::__hash_table<__value_type, __hasher,
767762 __key_equal, __allocator_type> __table;
......@@ -954,7 +949,7 @@ swap(hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
954949}
955950
956951template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
957bool
952_LIBCPP_HIDE_FROM_ABI bool
958953operator==(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
959954 const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
960955{
......@@ -987,4 +982,9 @@ operator!=(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
987982
988983} // namespace __gnu_cxx
989984
985#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
986# include <concepts>
987# include <iterator>
988#endif
989
990990#endif // _LIBCPP_HASH_MAP
lib/libcxx/include/ext/hash_set+7-6
......@@ -199,10 +199,6 @@ template <class Value, class Hash, class Pred, class Alloc>
199199#include <ext/__hash>
200200#include <functional>
201201
202#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
203# include <iterator>
204#endif
205
206202#if defined(__DEPRECATED) && __DEPRECATED
207203#if defined(_LIBCPP_WARNING)
208204 _LIBCPP_WARNING("Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set>")
......@@ -412,7 +408,7 @@ swap(hash_set<_Value, _Hash, _Pred, _Alloc>& __x,
412408}
413409
414410template <class _Value, class _Hash, class _Pred, class _Alloc>
415bool
411_LIBCPP_HIDE_FROM_ABI bool
416412operator==(const hash_set<_Value, _Hash, _Pred, _Alloc>& __x,
417413 const hash_set<_Value, _Hash, _Pred, _Alloc>& __y)
418414{
......@@ -633,7 +629,7 @@ swap(hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
633629}
634630
635631template <class _Value, class _Hash, class _Pred, class _Alloc>
636bool
632_LIBCPP_HIDE_FROM_ABI bool
637633operator==(const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
638634 const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
639635{
......@@ -666,4 +662,9 @@ operator!=(const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
666662
667663} // namespace __gnu_cxx
668664
665#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
666# include <concepts>
667# include <iterator>
668#endif
669
669670#endif // _LIBCPP_HASH_SET
lib/libcxx/include/fenv.h+3-1
......@@ -56,7 +56,9 @@ int feupdateenv(const fenv_t* envp);
5656# pragma GCC system_header
5757#endif
5858
59#include_next <fenv.h>
59#if __has_include_next(<fenv.h>)
60# include_next <fenv.h>
61#endif
6062
6163#ifdef __cplusplus
6264
lib/libcxx/include/filesystem+216-20
......@@ -6,6 +6,7 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP_FILESYSTEM
1011#define _LIBCPP_FILESYSTEM
1112
......@@ -14,36 +15,223 @@
1415
1516 namespace std::filesystem {
1617
17 class path;
18 // `class path` from http://eel.is/c++draft/fs.class.path.general#6
19 class path {
20 public:
21 using value_type = see below;
22 using string_type = basic_string<value_type>;
23 static constexpr value_type preferred_separator = see below;
24
25 enum format;
26
27 path() noexcept;
28 path(const path& p);
29 path(path&& p) noexcept;
30 path(string_type&& source, format fmt = auto_format);
31 template<class Source>
32 path(const Source& source, format fmt = auto_format);
33 template<class InputIterator>
34 path(InputIterator first, InputIterator last, format fmt = auto_format);
35 template<class Source>
36 path(const Source& source, const locale& loc, format fmt = auto_format);
37 template<class InputIterator>
38 path(InputIterator first, InputIterator last, const locale& loc, format fmt = auto_format);
39 ~path();
40
41 path& operator=(const path& p);
42 path& operator=(path&& p) noexcept;
43 path& operator=(string_type&& source);
44 path& assign(string_type&& source);
45 template<class Source>
46 path& operator=(const Source& source);
47 template<class Source>
48 path& assign(const Source& source);
49 template<class InputIterator>
50 path& assign(InputIterator first, InputIterator last);
51
52 path& operator/=(const path& p);
53 template<class Source>
54 path& operator/=(const Source& source);
55 template<class Source>
56 path& append(const Source& source);
57 template<class InputIterator>
58 path& append(InputIterator first, InputIterator last);
59
60 path& operator+=(const path& x);
61 path& operator+=(const string_type& x);
62 path& operator+=(basic_string_view<value_type> x);
63 path& operator+=(const value_type* x);
64 path& operator+=(value_type x);
65 template<class Source>
66 path& operator+=(const Source& x);
67 template<class EcharT>
68 path& operator+=(EcharT x);
69 template<class Source>
70 path& concat(const Source& x);
71 template<class InputIterator>
72 path& concat(InputIterator first, InputIterator last);
73
74 void clear() noexcept;
75 path& make_preferred();
76 path& remove_filename();
77 path& replace_filename(const path& replacement);
78 path& replace_extension(const path& replacement = path());
79 void swap(path& rhs) noexcept;
80
81 friend bool operator==(const path& lhs, const path& rhs) noexcept;
82 friend bool operator!=(const path& lhs, const path& rhs) noexcept; // removed in C++20
83 friend bool operator< (const path& lhs, const path& rhs) noexcept; // removed in C++20
84 friend bool operator<=(const path& lhs, const path& rhs) noexcept; // removed in C++20
85 friend bool operator> (const path& lhs, const path& rhs) noexcept; // removed in C++20
86 friend bool operator>=(const path& lhs, const path& rhs) noexcept; // removed in C++20
87 friend strong_ordering operator<=>(const path& lhs, const path& rhs) noexcept; // C++20
88
89 friend path operator/(const path& lhs, const path& rhs);
90
91 const string_type& native() const noexcept;
92 const value_type* c_str() const noexcept;
93 operator string_type() const;
94
95 template<class EcharT, class traits = char_traits<EcharT>,
96 class Allocator = allocator<EcharT>>
97 basic_string<EcharT, traits, Allocator>
98 string(const Allocator& a = Allocator()) const;
99 std::string string() const;
100 std::wstring wstring() const;
101 std::u8string u8string() const;
102 std::u16string u16string() const;
103 std::u32string u32string() const;
104
105 template<class EcharT, class traits = char_traits<EcharT>,
106 class Allocator = allocator<EcharT>>
107 basic_string<EcharT, traits, Allocator>
108 generic_string(const Allocator& a = Allocator()) const;
109 std::string generic_string() const;
110 std::wstring generic_wstring() const;
111 std::u8string generic_u8string() const;
112 std::u16string generic_u16string() const;
113 std::u32string generic_u32string() const;
114
115 int compare(const path& p) const noexcept;
116 int compare(const string_type& s) const;
117 int compare(basic_string_view<value_type> s) const;
118 int compare(const value_type* s) const;
119
120 path root_name() const;
121 path root_directory() const;
122 path root_path() const;
123 path relative_path() const;
124 path parent_path() const;
125 path filename() const;
126 path stem() const;
127 path extension() const;
128
129 [[nodiscard]] bool empty() const noexcept;
130 bool has_root_name() const;
131 bool has_root_directory() const;
132 bool has_root_path() const;
133 bool has_relative_path() const;
134 bool has_parent_path() const;
135 bool has_filename() const;
136 bool has_stem() const;
137 bool has_extension() const;
138 bool is_absolute() const;
139 bool is_relative() const;
140
141 path lexically_normal() const;
142 path lexically_relative(const path& base) const;
143 path lexically_proximate(const path& base) const;
144
145 class iterator;
146 using const_iterator = iterator;
147
148 iterator begin() const;
149 iterator end() const;
150
151 template<class charT, class traits>
152 friend basic_ostream<charT, traits>&
153 operator<<(basic_ostream<charT, traits>& os, const path& p);
154 template<class charT, class traits>
155 friend basic_istream<charT, traits>&
156 operator>>(basic_istream<charT, traits>& is, path& p);
157 };
18158
19159 void swap(path& lhs, path& rhs) noexcept;
20160 size_t hash_value(const path& p) noexcept;
21161
22 bool operator==(const path& lhs, const path& rhs) noexcept;
23 bool operator!=(const path& lhs, const path& rhs) noexcept;
24 bool operator< (const path& lhs, const path& rhs) noexcept;
25 bool operator<=(const path& lhs, const path& rhs) noexcept;
26 bool operator> (const path& lhs, const path& rhs) noexcept;
27 bool operator>=(const path& lhs, const path& rhs) noexcept;
28
29 path operator/ (const path& lhs, const path& rhs);
30
31 // fs.path.io operators are friends of path.
32 template <class charT, class traits>
33 friend basic_ostream<charT, traits>&
34 operator<<(basic_ostream<charT, traits>& os, const path& p);
35
36 template <class charT, class traits>
37 friend basic_istream<charT, traits>&
38 operator>>(basic_istream<charT, traits>& is, path& p);
39
40162 template <class Source>
41163 path u8path(const Source& source);
42164 template <class InputIterator>
43165 path u8path(InputIterator first, InputIterator last);
44166
45167 class filesystem_error;
46 class directory_entry;
168
169 class directory_entry {
170 public:
171 directory_entry() noexcept = default;
172 directory_entry(const directory_entry&) = default;
173 directory_entry(directory_entry&&) noexcept = default;
174 explicit directory_entry(const filesystem::path& p);
175 directory_entry(const filesystem::path& p, error_code& ec);
176 ~directory_entry();
177
178 directory_entry& operator=(const directory_entry&) = default;
179 directory_entry& operator=(directory_entry&&) noexcept = default;
180
181 void assign(const filesystem::path& p);
182 void assign(const filesystem::path& p, error_code& ec);
183 void replace_filename(const filesystem::path& p);
184 void replace_filename(const filesystem::path& p, error_code& ec);
185 void refresh();
186 void refresh(error_code& ec) noexcept;
187
188 const filesystem::path& path() const noexcept;
189 operator const filesystem::path&() const noexcept;
190 bool exists() const;
191 bool exists(error_code& ec) const noexcept;
192 bool is_block_file() const;
193 bool is_block_file(error_code& ec) const noexcept;
194 bool is_character_file() const;
195 bool is_character_file(error_code& ec) const noexcept;
196 bool is_directory() const;
197 bool is_directory(error_code& ec) const noexcept;
198 bool is_fifo() const;
199 bool is_fifo(error_code& ec) const noexcept;
200 bool is_other() const;
201 bool is_other(error_code& ec) const noexcept;
202 bool is_regular_file() const;
203 bool is_regular_file(error_code& ec) const noexcept;
204 bool is_socket() const;
205 bool is_socket(error_code& ec) const noexcept;
206 bool is_symlink() const;
207 bool is_symlink(error_code& ec) const noexcept;
208 uintmax_t file_size() const;
209 uintmax_t file_size(error_code& ec) const noexcept;
210 uintmax_t hard_link_count() const;
211 uintmax_t hard_link_count(error_code& ec) const noexcept;
212 file_time_type last_write_time() const;
213 file_time_type last_write_time(error_code& ec) const noexcept;
214 file_status status() const;
215 file_status status(error_code& ec) const noexcept;
216 file_status symlink_status() const;
217 file_status symlink_status(error_code& ec) const noexcept;
218
219 bool operator==(const directory_entry& rhs) const noexcept;
220 bool operator!=(const directory_entry& rhs) const noexcept; // removed in C++20
221 bool operator< (const directory_entry& rhs) const noexcept; // removed in C++20
222 bool operator<=(const directory_entry& rhs) const noexcept; // removed in C++20
223 bool operator> (const directory_entry& rhs) const noexcept; // removed in C++20
224 bool operator>=(const directory_entry& rhs) const noexcept; // removed in C++20
225 strong_ordering operator<=>(const directory_entry& rhs) const noexcept; // since C++20
226
227 template<class charT, class traits>
228 friend basic_ostream<charT, traits>&
229 operator<<(basic_ostream<charT, traits>& os, const directory_entry& d);
230
231 private:
232 filesystem::path pathobject; // exposition only
233 friend class directory_iterator; // exposition only
234 };
47235
48236 class directory_iterator;
49237
......@@ -64,6 +252,8 @@
64252 uintmax_t capacity;
65253 uintmax_t free;
66254 uintmax_t available;
255
256 friend bool operator==(const space_info&, const space_info&) = default; // C++20
67257 };
68258
69259 enum class file_type;
......@@ -260,6 +450,8 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct
260450#include <version>
261451
262452// standard-mandated includes
453
454// [fs.filesystem.syn]
263455#include <compare>
264456
265457#if defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
......@@ -270,4 +462,8 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct
270462# pragma GCC system_header
271463#endif
272464
465#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
466# include <concepts>
467#endif
468
273469#endif // _LIBCPP_FILESYSTEM
lib/libcxx/include/float.h+3-1
......@@ -76,7 +76,9 @@ Macros:
7676# pragma GCC system_header
7777#endif
7878
79#include_next <float.h>
79#if __has_include_next(<float.h>)
80# include_next <float.h>
81#endif
8082
8183#ifdef __cplusplus
8284
lib/libcxx/include/format+39-636
......@@ -112,6 +112,40 @@ namespace std {
112112 using format_parse_context = basic_format_parse_context<char>;
113113 using wformat_parse_context = basic_format_parse_context<wchar_t>;
114114
115 // [format.range], formatting of ranges
116 // [format.range.fmtkind], variable template format_kind
117 enum class range_format { // since C++23
118 disabled,
119 map,
120 set,
121 sequence,
122 string,
123 debug_string
124 };
125
126 template<class R>
127 constexpr unspecified format_kind = unspecified; // since C++23
128
129 template<ranges::input_range R>
130 requires same_as<R, remove_cvref_t<R>>
131 constexpr range_format format_kind<R> = see below; // since C++23
132
133 // [format.range.formatter], class template range_formatter
134 template<class T, class charT = char>
135 requires same_as<remove_cvref_t<T>, T> && formattable<T, charT>
136 class range_formatter; // since C++23
137
138 // [format.range.fmtdef], class template range-default-formatter
139 template<range_format K, ranges::input_range R, class charT>
140 struct range-default-formatter; // exposition only, since C++23
141
142 // [format.range.fmtmap], [format.range.fmtset], [format.range.fmtstr],
143 // specializations for maps, sets, and strings
144 template<ranges::input_range R, class charT>
145 requires (format_kind<R> != range_format::disabled) &&
146 formattable<ranges::range_reference_t<R>, charT>
147 struct formatter<R, charT> : range-default-formatter<format_kind<R>, R, charT> { }; // since C++23
148
115149 // [format.arguments], arguments
116150 // [format.arg], class template basic_format_arg
117151 template<class Context> class basic_format_arg;
......@@ -141,17 +175,17 @@ namespace std {
141175// Enable the contents of the header only when libc++ was built with experimental features enabled.
142176#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
143177
144#include <__algorithm/clamp.h>
145178#include <__config>
146#include <__debug>
147179#include <__format/buffer.h>
148180#include <__format/concepts.h>
181#include <__format/container_adaptor.h>
149182#include <__format/enable_insertable.h>
150183#include <__format/format_arg.h>
151184#include <__format/format_arg_store.h>
152185#include <__format/format_args.h>
153186#include <__format/format_context.h>
154187#include <__format/format_error.h>
188#include <__format/format_functions.h>
155189#include <__format/format_fwd.h>
156190#include <__format/format_parse_context.h>
157191#include <__format/format_string.h>
......@@ -163,647 +197,16 @@ namespace std {
163197#include <__format/formatter_integer.h>
164198#include <__format/formatter_pointer.h>
165199#include <__format/formatter_string.h>
200#include <__format/formatter_tuple.h>
166201#include <__format/parser_std_format_spec.h>
202#include <__format/range_default_formatter.h>
203#include <__format/range_formatter.h>
167204#include <__format/unicode.h>
168#include <__iterator/back_insert_iterator.h>
169#include <__iterator/incrementable_traits.h>
170#include <__variant/monostate.h>
171#include <array>
172#include <concepts>
173#include <string>
174#include <string_view>
175#include <type_traits>
176
177#ifndef _LIBCPP_HAS_NO_LOCALIZATION
178#include <locale>
179#endif
180205
181206#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
182207# pragma GCC system_header
183208#endif
184209
185_LIBCPP_BEGIN_NAMESPACE_STD
186
187#if _LIBCPP_STD_VER > 17
188
189// TODO FMT Move the implementation in this file to its own granular headers.
190
191// TODO FMT Evaluate which templates should be external templates. This
192// improves the efficiency of the header. However since the header is still
193// under heavy development and not all classes are stable it makes no sense
194// to do this optimization now.
195
196using format_args = basic_format_args<format_context>;
197#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
198using wformat_args = basic_format_args<wformat_context>;
199#endif
200
201template <class _Context = format_context, class... _Args>
202_LIBCPP_HIDE_FROM_ABI __format_arg_store<_Context, _Args...> make_format_args(_Args&&... __args) {
203 return _VSTD::__format_arg_store<_Context, _Args...>(__args...);
204}
205
206#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
207template <class... _Args>
208_LIBCPP_HIDE_FROM_ABI __format_arg_store<wformat_context, _Args...> make_wformat_args(_Args&&... __args) {
209 return _VSTD::__format_arg_store<wformat_context, _Args...>(__args...);
210}
211#endif
212
213namespace __format {
214
215/// Helper class parse and handle argument.
216///
217/// When parsing a handle which is not enabled the code is ill-formed.
218/// This helper uses the parser of the appropriate formatter for the stored type.
219template <class _CharT>
220class _LIBCPP_TEMPLATE_VIS __compile_time_handle {
221public:
222 _LIBCPP_HIDE_FROM_ABI
223 constexpr void __parse(basic_format_parse_context<_CharT>& __parse_ctx) const { __parse_(__parse_ctx); }
224
225 template <class _Tp>
226 _LIBCPP_HIDE_FROM_ABI constexpr void __enable() {
227 __parse_ = [](basic_format_parse_context<_CharT>& __parse_ctx) {
228 formatter<_Tp, _CharT> __f;
229 __parse_ctx.advance_to(__f.parse(__parse_ctx));
230 };
231 }
232
233 // Before calling __parse the proper handler needs to be set with __enable.
234 // The default handler isn't a core constant expression.
235 _LIBCPP_HIDE_FROM_ABI constexpr __compile_time_handle()
236 : __parse_([](basic_format_parse_context<_CharT>&) { __throw_format_error("Not a handle"); }) {}
237
238private:
239 void (*__parse_)(basic_format_parse_context<_CharT>&);
240};
241
242// Dummy format_context only providing the parts used during constant
243// validation of the basic_format_string.
244template <class _CharT>
245struct _LIBCPP_TEMPLATE_VIS __compile_time_basic_format_context {
246public:
247 using char_type = _CharT;
248
249 _LIBCPP_HIDE_FROM_ABI constexpr explicit __compile_time_basic_format_context(
250 const __arg_t* __args, const __compile_time_handle<_CharT>* __handles, size_t __size)
251 : __args_(__args), __handles_(__handles), __size_(__size) {}
252
253 // During the compile-time validation nothing needs to be written.
254 // Therefore all operations of this iterator are a NOP.
255 struct iterator {
256 _LIBCPP_HIDE_FROM_ABI constexpr iterator& operator=(_CharT) { return *this; }
257 _LIBCPP_HIDE_FROM_ABI constexpr iterator& operator*() { return *this; }
258 _LIBCPP_HIDE_FROM_ABI constexpr iterator operator++(int) { return *this; }
259 };
260
261 _LIBCPP_HIDE_FROM_ABI constexpr __arg_t arg(size_t __id) const {
262 if (__id >= __size_)
263 __throw_format_error("Argument index out of bounds");
264 return __args_[__id];
265 }
266
267 _LIBCPP_HIDE_FROM_ABI constexpr const __compile_time_handle<_CharT>& __handle(size_t __id) const {
268 if (__id >= __size_)
269 __throw_format_error("Argument index out of bounds");
270 return __handles_[__id];
271 }
272
273 _LIBCPP_HIDE_FROM_ABI constexpr iterator out() { return {}; }
274 _LIBCPP_HIDE_FROM_ABI constexpr void advance_to(iterator) {}
275
276private:
277 const __arg_t* __args_;
278 const __compile_time_handle<_CharT>* __handles_;
279 size_t __size_;
280};
281
282_LIBCPP_HIDE_FROM_ABI
283constexpr void __compile_time_validate_integral(__arg_t __type) {
284 switch (__type) {
285 case __arg_t::__int:
286 case __arg_t::__long_long:
287 case __arg_t::__i128:
288 case __arg_t::__unsigned:
289 case __arg_t::__unsigned_long_long:
290 case __arg_t::__u128:
291 return;
292
293 default:
294 __throw_format_error("Argument isn't an integral type");
295 }
296}
297
298// _HasPrecision does the formatter have a precision?
299template <class _CharT, class _Tp, bool _HasPrecision = false>
300_LIBCPP_HIDE_FROM_ABI constexpr void
301__compile_time_validate_argument(basic_format_parse_context<_CharT>& __parse_ctx,
302 __compile_time_basic_format_context<_CharT>& __ctx) {
303 formatter<_Tp, _CharT> __formatter;
304 __parse_ctx.advance_to(__formatter.parse(__parse_ctx));
305 // [format.string.std]/7
306 // ... If the corresponding formatting argument is not of integral type, or
307 // its value is negative for precision or non-positive for width, an
308 // exception of type format_error is thrown.
309 //
310 // Validate whether the arguments are integrals.
311 if constexpr (requires(formatter<_Tp, _CharT> __f) { __f.__width_needs_substitution(); }) {
312 // TODO FMT Remove this when parser v1 has been phased out.
313 if (__formatter.__width_needs_substitution())
314 __format::__compile_time_validate_integral(__ctx.arg(__formatter.__width));
315
316 if constexpr (_HasPrecision)
317 if (__formatter.__precision_needs_substitution())
318 __format::__compile_time_validate_integral(__ctx.arg(__formatter.__precision));
319 } else {
320 if (__formatter.__parser_.__width_as_arg_)
321 __format::__compile_time_validate_integral(__ctx.arg(__formatter.__parser_.__width_));
322
323 if constexpr (_HasPrecision)
324 if (__formatter.__parser_.__precision_as_arg_)
325 __format::__compile_time_validate_integral(__ctx.arg(__formatter.__parser_.__precision_));
326 }
327}
328
329template <class _CharT>
330_LIBCPP_HIDE_FROM_ABI constexpr void __compile_time_visit_format_arg(basic_format_parse_context<_CharT>& __parse_ctx,
331 __compile_time_basic_format_context<_CharT>& __ctx,
332 __arg_t __type) {
333 switch (__type) {
334 case __arg_t::__none:
335 __throw_format_error("Invalid argument");
336 case __arg_t::__boolean:
337 return __format::__compile_time_validate_argument<_CharT, bool>(__parse_ctx, __ctx);
338 case __arg_t::__char_type:
339 return __format::__compile_time_validate_argument<_CharT, _CharT>(__parse_ctx, __ctx);
340 case __arg_t::__int:
341 return __format::__compile_time_validate_argument<_CharT, int>(__parse_ctx, __ctx);
342 case __arg_t::__long_long:
343 return __format::__compile_time_validate_argument<_CharT, long long>(__parse_ctx, __ctx);
344 case __arg_t::__i128:
345# ifndef _LIBCPP_HAS_NO_INT128
346 return __format::__compile_time_validate_argument<_CharT, __int128_t>(__parse_ctx, __ctx);
347# else
348 __throw_format_error("Invalid argument");
349# endif
350 return;
351 case __arg_t::__unsigned:
352 return __format::__compile_time_validate_argument<_CharT, unsigned>(__parse_ctx, __ctx);
353 case __arg_t::__unsigned_long_long:
354 return __format::__compile_time_validate_argument<_CharT, unsigned long long>(__parse_ctx, __ctx);
355 case __arg_t::__u128:
356# ifndef _LIBCPP_HAS_NO_INT128
357 return __format::__compile_time_validate_argument<_CharT, __uint128_t>(__parse_ctx, __ctx);
358# else
359 __throw_format_error("Invalid argument");
360# endif
361 return;
362 case __arg_t::__float:
363 return __format::__compile_time_validate_argument<_CharT, float, true>(__parse_ctx, __ctx);
364 case __arg_t::__double:
365 return __format::__compile_time_validate_argument<_CharT, double, true>(__parse_ctx, __ctx);
366 case __arg_t::__long_double:
367 return __format::__compile_time_validate_argument<_CharT, long double, true>(__parse_ctx, __ctx);
368 case __arg_t::__const_char_type_ptr:
369 return __format::__compile_time_validate_argument<_CharT, const _CharT*, true>(__parse_ctx, __ctx);
370 case __arg_t::__string_view:
371 return __format::__compile_time_validate_argument<_CharT, basic_string_view<_CharT>, true>(__parse_ctx, __ctx);
372 case __arg_t::__ptr:
373 return __format::__compile_time_validate_argument<_CharT, const void*>(__parse_ctx, __ctx);
374 case __arg_t::__handle:
375 __throw_format_error("Handle should use __compile_time_validate_handle_argument");
376 }
377 __throw_format_error("Invalid argument");
378}
379
380template <class _CharT, class _ParseCtx, class _Ctx>
381_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
382__handle_replacement_field(const _CharT* __begin, const _CharT* __end,
383 _ParseCtx& __parse_ctx, _Ctx& __ctx) {
384 __format::__parse_number_result __r =
385 __format::__parse_arg_id(__begin, __end, __parse_ctx);
386
387 bool __parse = *__r.__ptr == _CharT(':');
388 switch (*__r.__ptr) {
389 case _CharT(':'):
390 // The arg-id has a format-specifier, advance the input to the format-spec.
391 __parse_ctx.advance_to(__r.__ptr + 1);
392 break;
393 case _CharT('}'):
394 // The arg-id has no format-specifier.
395 __parse_ctx.advance_to(__r.__ptr);
396 break;
397 default:
398 __throw_format_error(
399 "The replacement field arg-id should terminate at a ':' or '}'");
400 }
401
402 if constexpr (same_as<_Ctx, __compile_time_basic_format_context<_CharT>>) {
403 __arg_t __type = __ctx.arg(__r.__value);
404 if (__type == __arg_t::__handle)
405 __ctx.__handle(__r.__value).__parse(__parse_ctx);
406 else
407 __format::__compile_time_visit_format_arg(__parse_ctx, __ctx, __type);
408 } else
409 _VSTD::visit_format_arg(
410 [&](auto __arg) {
411 if constexpr (same_as<decltype(__arg), monostate>)
412 __throw_format_error("Argument index out of bounds");
413 else if constexpr (same_as<decltype(__arg), typename basic_format_arg<_Ctx>::handle>)
414 __arg.format(__parse_ctx, __ctx);
415 else {
416 formatter<decltype(__arg), _CharT> __formatter;
417 if (__parse)
418 __parse_ctx.advance_to(__formatter.parse(__parse_ctx));
419 __ctx.advance_to(__formatter.format(__arg, __ctx));
420 }
421 },
422 __ctx.arg(__r.__value));
423
424 __begin = __parse_ctx.begin();
425 if (__begin == __end || *__begin != _CharT('}'))
426 __throw_format_error("The replacement field misses a terminating '}'");
427
428 return ++__begin;
429}
430
431template <class _ParseCtx, class _Ctx>
432_LIBCPP_HIDE_FROM_ABI constexpr typename _Ctx::iterator
433__vformat_to(_ParseCtx&& __parse_ctx, _Ctx&& __ctx) {
434 using _CharT = typename _ParseCtx::char_type;
435 static_assert(same_as<typename _Ctx::char_type, _CharT>);
436
437 const _CharT* __begin = __parse_ctx.begin();
438 const _CharT* __end = __parse_ctx.end();
439 typename _Ctx::iterator __out_it = __ctx.out();
440 while (__begin != __end) {
441 switch (*__begin) {
442 case _CharT('{'):
443 ++__begin;
444 if (__begin == __end)
445 __throw_format_error("The format string terminates at a '{'");
446
447 if (*__begin != _CharT('{')) [[likely]] {
448 __ctx.advance_to(_VSTD::move(__out_it));
449 __begin =
450 __handle_replacement_field(__begin, __end, __parse_ctx, __ctx);
451 __out_it = __ctx.out();
452
453 // The output is written and __begin points to the next character. So
454 // start the next iteration.
455 continue;
456 }
457 // The string is an escape character.
458 break;
459
460 case _CharT('}'):
461 ++__begin;
462 if (__begin == __end || *__begin != _CharT('}'))
463 __throw_format_error(
464 "The format string contains an invalid escape sequence");
465
466 break;
467 }
468
469 // Copy the character to the output verbatim.
470 *__out_it++ = *__begin++;
471 }
472 return __out_it;
473}
474
475} // namespace __format
476
477template <class _CharT, class... _Args>
478struct _LIBCPP_TEMPLATE_VIS basic_format_string {
479 template <class _Tp>
480 requires convertible_to<const _Tp&, basic_string_view<_CharT>>
481 consteval basic_format_string(const _Tp& __str) : __str_{__str} {
482 __format::__vformat_to(basic_format_parse_context<_CharT>{__str_, sizeof...(_Args)},
483 _Context{__types_.data(), __handles_.data(), sizeof...(_Args)});
484 }
485
486 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT constexpr basic_string_view<_CharT> get() const noexcept {
487 return __str_;
488 }
489
490private:
491 basic_string_view<_CharT> __str_;
492
493 using _Context = __format::__compile_time_basic_format_context<_CharT>;
494
495 static constexpr array<__format::__arg_t, sizeof...(_Args)> __types_{
496 __format::__determine_arg_t<_Context, remove_cvref_t<_Args>>()...};
497
498 // TODO FMT remove this work-around when the AIX ICE has been resolved.
499# if defined(_AIX) && defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1400
500 template <class _Tp>
501 static constexpr __format::__compile_time_handle<_CharT> __get_handle() {
502 __format::__compile_time_handle<_CharT> __handle;
503 if (__format::__determine_arg_t<_Context, _Tp>() == __format::__arg_t::__handle)
504 __handle.template __enable<_Tp>();
505
506 return __handle;
507 }
508
509 static constexpr array<__format::__compile_time_handle<_CharT>, sizeof...(_Args)> __handles_{
510 __get_handle<_Args>()...};
511# else
512 static constexpr array<__format::__compile_time_handle<_CharT>, sizeof...(_Args)> __handles_{[] {
513 using _Tp = remove_cvref_t<_Args>;
514 __format::__compile_time_handle<_CharT> __handle;
515 if (__format::__determine_arg_t<_Context, _Tp>() == __format::__arg_t::__handle)
516 __handle.template __enable<_Tp>();
517
518 return __handle;
519 }()...};
520# endif
521};
522
523template <class... _Args>
524using format_string = basic_format_string<char, type_identity_t<_Args>...>;
525
526#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
527template <class... _Args>
528using wformat_string = basic_format_string<wchar_t, type_identity_t<_Args>...>;
529#endif
530
531template <class _OutIt, class _CharT, class _FormatOutIt>
532requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt
533 __vformat_to(
534 _OutIt __out_it, basic_string_view<_CharT> __fmt,
535 basic_format_args<basic_format_context<_FormatOutIt, _CharT>> __args) {
536 if constexpr (same_as<_OutIt, _FormatOutIt>)
537 return _VSTD::__format::__vformat_to(
538 basic_format_parse_context{__fmt, __args.__size()},
539 _VSTD::__format_context_create(_VSTD::move(__out_it), __args));
540 else {
541 __format::__format_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it)};
542 _VSTD::__format::__vformat_to(
543 basic_format_parse_context{__fmt, __args.__size()},
544 _VSTD::__format_context_create(__buffer.make_output_iterator(),
545 __args));
546 return _VSTD::move(__buffer).out();
547 }
548}
549
550// The function is _LIBCPP_ALWAYS_INLINE since the compiler is bad at inlining
551// https://reviews.llvm.org/D110499#inline-1180704
552// TODO FMT Evaluate whether we want to file a Clang bug report regarding this.
553template <output_iterator<const char&> _OutIt>
554_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
555vformat_to(_OutIt __out_it, string_view __fmt, format_args __args) {
556 return _VSTD::__vformat_to(_VSTD::move(__out_it), __fmt, __args);
557}
558
559#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
560template <output_iterator<const wchar_t&> _OutIt>
561_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
562vformat_to(_OutIt __out_it, wstring_view __fmt, wformat_args __args) {
563 return _VSTD::__vformat_to(_VSTD::move(__out_it), __fmt, __args);
564}
565#endif
566
567template <output_iterator<const char&> _OutIt, class... _Args>
568_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
569format_to(_OutIt __out_it, format_string<_Args...> __fmt, _Args&&... __args) {
570 return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.get(),
571 _VSTD::make_format_args(__args...));
572}
573
574#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
575template <output_iterator<const wchar_t&> _OutIt, class... _Args>
576_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
577format_to(_OutIt __out_it, wformat_string<_Args...> __fmt, _Args&&... __args) {
578 return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.get(),
579 _VSTD::make_wformat_args(__args...));
580}
581#endif
582
583_LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string
584vformat(string_view __fmt, format_args __args) {
585 string __res;
586 _VSTD::vformat_to(_VSTD::back_inserter(__res), __fmt, __args);
587 return __res;
588}
589
590#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
591_LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring
592vformat(wstring_view __fmt, wformat_args __args) {
593 wstring __res;
594 _VSTD::vformat_to(_VSTD::back_inserter(__res), __fmt, __args);
595 return __res;
596}
597#endif
598
599template <class... _Args>
600_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string format(format_string<_Args...> __fmt,
601 _Args&&... __args) {
602 return _VSTD::vformat(__fmt.get(), _VSTD::make_format_args(__args...));
603}
604
605#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
606template <class... _Args>
607_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring
608format(wformat_string<_Args...> __fmt, _Args&&... __args) {
609 return _VSTD::vformat(__fmt.get(), _VSTD::make_wformat_args(__args...));
610}
611#endif
612
613template <class _Context, class _OutIt, class _CharT>
614_LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n,
615 basic_string_view<_CharT> __fmt,
616 basic_format_args<_Context> __args) {
617 __format::__format_to_n_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it), __n};
618 _VSTD::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()},
619 _VSTD::__format_context_create(__buffer.make_output_iterator(), __args));
620 return _VSTD::move(__buffer).result();
621}
622
623template <output_iterator<const char&> _OutIt, class... _Args>
624_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
625format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, format_string<_Args...> __fmt, _Args&&... __args) {
626 return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, __fmt.get(), _VSTD::make_format_args(__args...));
627}
628
629#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
630template <output_iterator<const wchar_t&> _OutIt, class... _Args>
631_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
632format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, wformat_string<_Args...> __fmt,
633 _Args&&... __args) {
634 return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, __fmt.get(), _VSTD::make_wformat_args(__args...));
635}
636#endif
637
638template <class _CharT>
639_LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(basic_string_view<_CharT> __fmt, auto __args) {
640 __format::__formatted_size_buffer<_CharT> __buffer;
641 _VSTD::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()},
642 _VSTD::__format_context_create(__buffer.make_output_iterator(), __args));
643 return _VSTD::move(__buffer).result();
644}
645
646template <class... _Args>
647_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
648formatted_size(format_string<_Args...> __fmt, _Args&&... __args) {
649 return _VSTD::__vformatted_size(__fmt.get(), basic_format_args{_VSTD::make_format_args(__args...)});
650}
651
652#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
653template <class... _Args>
654_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
655formatted_size(wformat_string<_Args...> __fmt, _Args&&... __args) {
656 return _VSTD::__vformatted_size(__fmt.get(), basic_format_args{_VSTD::make_wformat_args(__args...)});
657}
658#endif
659
660#ifndef _LIBCPP_HAS_NO_LOCALIZATION
661
662template <class _OutIt, class _CharT, class _FormatOutIt>
663requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt
664 __vformat_to(
665 _OutIt __out_it, locale __loc, basic_string_view<_CharT> __fmt,
666 basic_format_args<basic_format_context<_FormatOutIt, _CharT>> __args) {
667 if constexpr (same_as<_OutIt, _FormatOutIt>)
668 return _VSTD::__format::__vformat_to(
669 basic_format_parse_context{__fmt, __args.__size()},
670 _VSTD::__format_context_create(_VSTD::move(__out_it), __args,
671 _VSTD::move(__loc)));
672 else {
673 __format::__format_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it)};
674 _VSTD::__format::__vformat_to(
675 basic_format_parse_context{__fmt, __args.__size()},
676 _VSTD::__format_context_create(__buffer.make_output_iterator(),
677 __args, _VSTD::move(__loc)));
678 return _VSTD::move(__buffer).out();
679 }
680}
681
682template <output_iterator<const char&> _OutIt>
683_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt vformat_to(
684 _OutIt __out_it, locale __loc, string_view __fmt, format_args __args) {
685 return _VSTD::__vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt,
686 __args);
687}
688
689#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
690template <output_iterator<const wchar_t&> _OutIt>
691_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt vformat_to(
692 _OutIt __out_it, locale __loc, wstring_view __fmt, wformat_args __args) {
693 return _VSTD::__vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt,
694 __args);
695}
696#endif
697
698template <output_iterator<const char&> _OutIt, class... _Args>
699_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
700format_to(_OutIt __out_it, locale __loc, format_string<_Args...> __fmt, _Args&&... __args) {
701 return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.get(),
702 _VSTD::make_format_args(__args...));
703}
704
705#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
706template <output_iterator<const wchar_t&> _OutIt, class... _Args>
707_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
708format_to(_OutIt __out_it, locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
709 return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.get(),
710 _VSTD::make_wformat_args(__args...));
711}
712#endif
713
714_LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string
715vformat(locale __loc, string_view __fmt, format_args __args) {
716 string __res;
717 _VSTD::vformat_to(_VSTD::back_inserter(__res), _VSTD::move(__loc), __fmt,
718 __args);
719 return __res;
720}
721
722#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
723_LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring
724vformat(locale __loc, wstring_view __fmt, wformat_args __args) {
725 wstring __res;
726 _VSTD::vformat_to(_VSTD::back_inserter(__res), _VSTD::move(__loc), __fmt,
727 __args);
728 return __res;
729}
730#endif
731
732template <class... _Args>
733_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string format(locale __loc,
734 format_string<_Args...> __fmt,
735 _Args&&... __args) {
736 return _VSTD::vformat(_VSTD::move(__loc), __fmt.get(),
737 _VSTD::make_format_args(__args...));
738}
739
740#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
741template <class... _Args>
742_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring
743format(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
744 return _VSTD::vformat(_VSTD::move(__loc), __fmt.get(),
745 _VSTD::make_wformat_args(__args...));
746}
747#endif
748
749template <class _Context, class _OutIt, class _CharT>
750_LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n,
751 locale __loc, basic_string_view<_CharT> __fmt,
752 basic_format_args<_Context> __args) {
753 __format::__format_to_n_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it), __n};
754 _VSTD::__format::__vformat_to(
755 basic_format_parse_context{__fmt, __args.__size()},
756 _VSTD::__format_context_create(__buffer.make_output_iterator(), __args, _VSTD::move(__loc)));
757 return _VSTD::move(__buffer).result();
758}
759
760template <output_iterator<const char&> _OutIt, class... _Args>
761_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
762format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, format_string<_Args...> __fmt,
763 _Args&&... __args) {
764 return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.get(),
765 _VSTD::make_format_args(__args...));
766}
767
768#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
769template <output_iterator<const wchar_t&> _OutIt, class... _Args>
770_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
771format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, wformat_string<_Args...> __fmt,
772 _Args&&... __args) {
773 return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.get(),
774 _VSTD::make_wformat_args(__args...));
775}
776#endif
777
778template <class _CharT>
779_LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(locale __loc, basic_string_view<_CharT> __fmt, auto __args) {
780 __format::__formatted_size_buffer<_CharT> __buffer;
781 _VSTD::__format::__vformat_to(
782 basic_format_parse_context{__fmt, __args.__size()},
783 _VSTD::__format_context_create(__buffer.make_output_iterator(), __args, _VSTD::move(__loc)));
784 return _VSTD::move(__buffer).result();
785}
786
787template <class... _Args>
788_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
789formatted_size(locale __loc, format_string<_Args...> __fmt, _Args&&... __args) {
790 return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.get(), basic_format_args{_VSTD::make_format_args(__args...)});
791}
792
793#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
794template <class... _Args>
795_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
796formatted_size(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
797 return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.get(), basic_format_args{_VSTD::make_wformat_args(__args...)});
798}
799#endif
800
801#endif // _LIBCPP_HAS_NO_LOCALIZATION
802
803#endif //_LIBCPP_STD_VER > 17
804
805_LIBCPP_END_NAMESPACE_STD
806
807210#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
808211
809212#endif // _LIBCPP_FORMAT
lib/libcxx/include/forward_list+51-38
......@@ -188,19 +188,22 @@ template <class T, class Allocator, class Predicate>
188188#include <__iterator/iterator_traits.h>
189189#include <__iterator/move_iterator.h>
190190#include <__iterator/next.h>
191#include <__memory/addressof.h>
192#include <__memory/allocator.h>
193#include <__memory/allocator_destructor.h>
194#include <__memory/allocator_traits.h>
195#include <__memory/compressed_pair.h>
196#include <__memory/pointer_traits.h>
191197#include <__memory/swap_allocator.h>
198#include <__memory/unique_ptr.h>
199#include <__memory_resource/polymorphic_allocator.h>
200#include <__type_traits/is_allocator.h>
192201#include <__utility/forward.h>
202#include <__utility/move.h>
193203#include <limits>
194#include <memory>
195204#include <type_traits>
196205#include <version>
197206
198#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
199# include <algorithm>
200# include <functional>
201# include <iterator>
202#endif
203
204207// standard-mandated includes
205208
206209// [iterator.range]
......@@ -239,30 +242,23 @@ struct __forward_list_node_value_type<__forward_list_node<_Tp, _VoidPtr> > {
239242template <class _NodePtr>
240243struct __forward_node_traits {
241244
242 typedef typename remove_cv<
243 typename pointer_traits<_NodePtr>::element_type>::type __node;
245 typedef __remove_cv_t<
246 typename pointer_traits<_NodePtr>::element_type> __node;
244247 typedef typename __forward_list_node_value_type<__node>::type __node_value_type;
245248 typedef _NodePtr __node_pointer;
246249 typedef __forward_begin_node<_NodePtr> __begin_node;
247 typedef typename __rebind_pointer<_NodePtr, __begin_node>::type
248 __begin_node_pointer;
249 typedef typename __rebind_pointer<_NodePtr, void>::type __void_pointer;
250 typedef __rebind_pointer_t<_NodePtr, __begin_node> __begin_node_pointer;
251 typedef __rebind_pointer_t<_NodePtr, void> __void_pointer;
250252
251253#if defined(_LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB)
252254 typedef __begin_node_pointer __iter_node_pointer;
253255#else
254 typedef typename conditional<
255 is_pointer<__void_pointer>::value,
256 __begin_node_pointer,
257 __node_pointer
258 >::type __iter_node_pointer;
256 typedef __conditional_t<is_pointer<__void_pointer>::value, __begin_node_pointer, __node_pointer>
257 __iter_node_pointer;
259258#endif
260259
261 typedef typename conditional<
262 is_same<__iter_node_pointer, __node_pointer>::value,
263 __begin_node_pointer,
264 __node_pointer
265 >::type __non_iter_node_pointer;
260 typedef __conditional_t<is_same<__iter_node_pointer, __node_pointer>::value, __begin_node_pointer, __node_pointer>
261 __non_iter_node_pointer;
266262
267263 _LIBCPP_INLINE_VISIBILITY
268264 static __iter_node_pointer __as_iter_node(__iter_node_pointer __p) {
......@@ -278,7 +274,7 @@ template <class _NodePtr>
278274struct __forward_begin_node
279275{
280276 typedef _NodePtr pointer;
281 typedef typename __rebind_pointer<_NodePtr, __forward_begin_node>::type __begin_node_pointer;
277 typedef __rebind_pointer_t<_NodePtr, __forward_begin_node> __begin_node_pointer;
282278
283279 pointer __next_;
284280
......@@ -291,16 +287,11 @@ struct __forward_begin_node
291287};
292288
293289template <class _Tp, class _VoidPtr>
294struct _LIBCPP_HIDDEN __begin_node_of
295{
296 typedef __forward_begin_node<
297 typename __rebind_pointer<_VoidPtr, __forward_list_node<_Tp, _VoidPtr> >::type
298 > type;
299};
290using __begin_node_of = __forward_begin_node<__rebind_pointer_t<_VoidPtr, __forward_list_node<_Tp, _VoidPtr> > >;
300291
301292template <class _Tp, class _VoidPtr>
302293struct _LIBCPP_STANDALONE_DEBUG __forward_list_node
303 : public __begin_node_of<_Tp, _VoidPtr>::type
294 : public __begin_node_of<_Tp, _VoidPtr>
304295{
305296 typedef _Tp value_type;
306297
......@@ -353,7 +344,7 @@ public:
353344 typedef value_type& reference;
354345 typedef typename pointer_traits<__node_pointer>::difference_type
355346 difference_type;
356 typedef typename __rebind_pointer<__node_pointer, value_type>::type pointer;
347 typedef __rebind_pointer_t<__node_pointer, value_type> pointer;
357348
358349 _LIBCPP_INLINE_VISIBILITY
359350 __forward_list_iterator() _NOEXCEPT : __ptr_(nullptr) {}
......@@ -434,7 +425,7 @@ public:
434425 typedef const value_type& reference;
435426 typedef typename pointer_traits<__node_pointer>::difference_type
436427 difference_type;
437 typedef typename __rebind_pointer<__node_pointer, const value_type>::type
428 typedef __rebind_pointer_t<__node_pointer, const value_type>
438429 pointer;
439430
440431 _LIBCPP_INLINE_VISIBILITY
......@@ -482,14 +473,12 @@ protected:
482473
483474 typedef typename allocator_traits<allocator_type>::void_pointer void_pointer;
484475 typedef __forward_list_node<value_type, void_pointer> __node;
485 typedef typename __begin_node_of<value_type, void_pointer>::type __begin_node;
486 typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __node>::type __node_allocator;
476 typedef __begin_node_of<value_type, void_pointer> __begin_node;
477 typedef __rebind_alloc<allocator_traits<allocator_type>, __node> __node_allocator;
487478 typedef allocator_traits<__node_allocator> __node_traits;
488479 typedef typename __node_traits::pointer __node_pointer;
489480
490 typedef typename __rebind_alloc_helper<
491 allocator_traits<allocator_type>, __begin_node
492 >::type __begin_node_allocator;
481 typedef __rebind_alloc<allocator_traits<allocator_type>, __begin_node> __begin_node_allocator;
493482 typedef typename allocator_traits<__begin_node_allocator>::pointer
494483 __begin_node_pointer;
495484
......@@ -497,6 +486,10 @@ protected:
497486 "internal allocator type must differ from user-specified "
498487 "type; otherwise overload resolution breaks");
499488
489 static_assert(is_same<allocator_type, __rebind_alloc<__node_traits, value_type> >::value,
490 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
491 "original allocator");
492
500493 __compressed_pair<__begin_node, __node_allocator> __before_begin_;
501494
502495 _LIBCPP_INLINE_VISIBILITY
......@@ -852,7 +845,7 @@ public:
852845 __remove_return_type remove(const value_type& __v);
853846 template <class _Predicate> __remove_return_type remove_if(_Predicate __pred);
854847 _LIBCPP_INLINE_VISIBILITY
855 __remove_return_type unique() {return unique(__equal_to<value_type>());}
848 __remove_return_type unique() { return unique(__equal_to()); }
856849 template <class _BinaryPredicate> __remove_return_type unique(_BinaryPredicate __binary_pred);
857850#ifndef _LIBCPP_CXX03_LANG
858851 _LIBCPP_INLINE_VISIBILITY
......@@ -1702,6 +1695,7 @@ forward_list<_Tp, _Alloc>::reverse() _NOEXCEPT
17021695}
17031696
17041697template <class _Tp, class _Alloc>
1698_LIBCPP_HIDE_FROM_ABI
17051699bool operator==(const forward_list<_Tp, _Alloc>& __x,
17061700 const forward_list<_Tp, _Alloc>& __y)
17071701{
......@@ -1785,6 +1779,25 @@ inline _LIBCPP_INLINE_VISIBILITY
17851779
17861780_LIBCPP_END_NAMESPACE_STD
17871781
1782#if _LIBCPP_STD_VER > 14
1783_LIBCPP_BEGIN_NAMESPACE_STD
1784namespace pmr {
1785template <class _ValueT>
1786using forward_list = std::forward_list<_ValueT, polymorphic_allocator<_ValueT>>;
1787} // namespace pmr
1788_LIBCPP_END_NAMESPACE_STD
1789#endif
1790
17881791_LIBCPP_POP_MACROS
17891792
1793#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1794# include <algorithm>
1795# include <atomic>
1796# include <concepts>
1797# include <functional>
1798# include <iosfwd>
1799# include <iterator>
1800# include <typeinfo>
1801#endif
1802
17901803#endif // _LIBCPP_FORWARD_LIST
lib/libcxx/include/fstream+40-23
......@@ -192,6 +192,7 @@ typedef basic_fstream<wchar_t> wfstream;
192192#include <cstring>
193193#include <istream>
194194#include <ostream>
195#include <typeinfo>
195196#include <version>
196197
197198#if !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
......@@ -209,6 +210,8 @@ _LIBCPP_PUSH_MACROS
209210# define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
210211#endif
211212
213#if !defined(_LIBCPP_HAS_NO_FSTREAM)
214
212215_LIBCPP_BEGIN_NAMESPACE_STD
213216
214217template <class _CharT, class _Traits>
......@@ -226,7 +229,7 @@ public:
226229 // 27.9.1.2 Constructors/destructor:
227230 basic_filebuf();
228231 basic_filebuf(basic_filebuf&& __rhs);
229 virtual ~basic_filebuf();
232 ~basic_filebuf() override;
230233
231234 // 27.9.1.3 Assign/swap:
232235 _LIBCPP_INLINE_VISIBILITY
......@@ -259,16 +262,16 @@ public:
259262
260263 protected:
261264 // 27.9.1.5 Overridden virtual functions:
262 virtual int_type underflow();
263 virtual int_type pbackfail(int_type __c = traits_type::eof());
264 virtual int_type overflow (int_type __c = traits_type::eof());
265 virtual basic_streambuf<char_type, traits_type>* setbuf(char_type* __s, streamsize __n);
266 virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
267 ios_base::openmode __wch = ios_base::in | ios_base::out);
268 virtual pos_type seekpos(pos_type __sp,
269 ios_base::openmode __wch = ios_base::in | ios_base::out);
270 virtual int sync();
271 virtual void imbue(const locale& __loc);
265 int_type underflow() override;
266 int_type pbackfail(int_type __c = traits_type::eof()) override;
267 int_type overflow (int_type __c = traits_type::eof()) override;
268 basic_streambuf<char_type, traits_type>* setbuf(char_type* __s, streamsize __n) override;
269 pos_type seekoff(off_type __off, ios_base::seekdir __way,
270 ios_base::openmode __wch = ios_base::in | ios_base::out) override;
271 pos_type seekpos(pos_type __sp,
272 ios_base::openmode __wch = ios_base::in | ios_base::out) override;
273 int sync() override;
274 void imbue(const locale& __loc) override;
272275
273276private:
274277 char* __extbuf_;
......@@ -310,9 +313,9 @@ basic_filebuf<_CharT, _Traits>::basic_filebuf()
310313 __owns_ib_(false),
311314 __always_noconv_(false)
312315{
313 if (has_facet<codecvt<char_type, char, state_type> >(this->getloc()))
316 if (std::has_facet<codecvt<char_type, char, state_type> >(this->getloc()))
314317 {
315 __cv_ = &use_facet<codecvt<char_type, char, state_type> >(this->getloc());
318 __cv_ = &std::use_facet<codecvt<char_type, char, state_type> >(this->getloc());
316319 __always_noconv_ = __cv_->always_noconv();
317320 }
318321 setbuf(nullptr, 4096);
......@@ -731,7 +734,7 @@ basic_filebuf<_CharT, _Traits>::underflow()
731734 char_type __1buf;
732735 if (this->gptr() == nullptr)
733736 this->setg(&__1buf, &__1buf+1, &__1buf+1);
734 const size_t __unget_sz = __initial ? 0 : min<size_t>((this->egptr() - this->eback()) / 2, 4);
737 const size_t __unget_sz = __initial ? 0 : std::min<size_t>((this->egptr() - this->eback()) / 2, 4);
735738 int_type __c = traits_type::eof();
736739 if (this->gptr() == this->egptr())
737740 {
......@@ -739,7 +742,7 @@ basic_filebuf<_CharT, _Traits>::underflow()
739742 if (__always_noconv_)
740743 {
741744 size_t __nmemb = static_cast<size_t>(this->egptr() - this->eback() - __unget_sz);
742 __nmemb = fread(this->eback() + __unget_sz, 1, __nmemb, __file_);
745 __nmemb = ::fread(this->eback() + __unget_sz, 1, __nmemb, __file_);
743746 if (__nmemb != 0)
744747 {
745748 this->setg(this->eback(),
......@@ -750,9 +753,11 @@ basic_filebuf<_CharT, _Traits>::underflow()
750753 }
751754 else
752755 {
753 _LIBCPP_ASSERT ( !(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" );
754 if (__extbufend_ != __extbufnext_)
756 if (__extbufend_ != __extbufnext_) {
757 _LIBCPP_ASSERT(__extbufnext_ != nullptr, "underflow moving from nullptr");
758 _LIBCPP_ASSERT(__extbuf_ != nullptr, "underflow moving into nullptr");
755759 _VSTD::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
760 }
756761 __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
757762 __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);
758763 size_t __nmemb = _VSTD::min(static_cast<size_t>(__ibs_ - __unget_sz),
......@@ -835,7 +840,7 @@ basic_filebuf<_CharT, _Traits>::overflow(int_type __c)
835840 if (__always_noconv_)
836841 {
837842 size_t __nmemb = static_cast<size_t>(this->pptr() - this->pbase());
838 if (fwrite(this->pbase(), sizeof(char_type), __nmemb, __file_) != __nmemb)
843 if (std::fwrite(this->pbase(), sizeof(char_type), __nmemb, __file_) != __nmemb)
839844 return traits_type::eof();
840845 }
841846 else
......@@ -855,7 +860,7 @@ basic_filebuf<_CharT, _Traits>::overflow(int_type __c)
855860 if (__r == codecvt_base::noconv)
856861 {
857862 size_t __nmemb = static_cast<size_t>(this->pptr() - this->pbase());
858 if (fwrite(this->pbase(), 1, __nmemb, __file_) != __nmemb)
863 if (std::fwrite(this->pbase(), 1, __nmemb, __file_) != __nmemb)
859864 return traits_type::eof();
860865 }
861866 else if (__r == codecvt_base::ok || __r == codecvt_base::partial)
......@@ -963,7 +968,7 @@ basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way,
963968 return pos_type(off_type(-1));
964969 pos_type __r = ftell(__file_);
965970#else
966 if (fseeko(__file_, __width > 0 ? __width * __off : 0, __whence))
971 if (::fseeko(__file_, __width > 0 ? __width * __off : 0, __whence))
967972 return pos_type(off_type(-1));
968973 pos_type __r = ftello(__file_);
969974#endif
......@@ -981,7 +986,7 @@ basic_filebuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode)
981986 if (fseek(__file_, __sp, SEEK_SET))
982987 return pos_type(off_type(-1));
983988#else
984 if (fseeko(__file_, __sp, SEEK_SET))
989 if (::fseeko(__file_, __sp, SEEK_SET))
985990 return pos_type(off_type(-1));
986991#endif
987992 __st_ = __sp.state();
......@@ -1045,7 +1050,7 @@ basic_filebuf<_CharT, _Traits>::sync()
10451050 if (fseek(__file_, -__c, SEEK_CUR))
10461051 return -1;
10471052#else
1048 if (fseeko(__file_, -__c, SEEK_CUR))
1053 if (::fseeko(__file_, -__c, SEEK_CUR))
10491054 return -1;
10501055#endif
10511056 if (__update_st)
......@@ -1062,7 +1067,7 @@ void
10621067basic_filebuf<_CharT, _Traits>::imbue(const locale& __loc)
10631068{
10641069 sync();
1065 __cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
1070 __cv_ = &std::use_facet<codecvt<char_type, char, state_type> >(__loc);
10661071 bool __old_anc = __always_noconv_;
10671072 __always_noconv_ = __cv_->always_noconv();
10681073 if (__old_anc != __always_noconv_)
......@@ -1741,6 +1746,18 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>;
17411746
17421747_LIBCPP_END_NAMESPACE_STD
17431748
1749#endif // _LIBCPP_HAS_NO_FSTREAM
1750
17441751_LIBCPP_POP_MACROS
17451752
1753#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1754# include <atomic>
1755# include <concepts>
1756# include <iosfwd>
1757# include <limits>
1758# include <new>
1759# include <stdexcept>
1760# include <type_traits>
1761#endif
1762
17461763#endif // _LIBCPP_FSTREAM
lib/libcxx/include/functional+7-7
......@@ -531,20 +531,20 @@ POLICY: For non-variadic implementations, the number of arguments is limited
531531#include <__functional/unary_negate.h>
532532#include <__functional/unwrap_ref.h>
533533#include <__utility/forward.h>
534#include <concepts>
535534#include <exception>
536#include <memory>
537#include <tuple>
535#include <memory> // TODO: find out why removing this breaks the modules build
538536#include <type_traits>
539537#include <typeinfo>
540538#include <version>
541539
542#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
543# include <utility>
544#endif
545
546540#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
547541# pragma GCC system_header
548542#endif
549543
544#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
545# include <concepts>
546# include <tuple>
547# include <utility>
548#endif
549
550550#endif // _LIBCPP_FUNCTIONAL
lib/libcxx/include/future+44-26
......@@ -367,21 +367,19 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
367367#include <__chrono/time_point.h>
368368#include <__config>
369369#include <__memory/allocator_arg_t.h>
370#include <__memory/allocator_destructor.h>
370371#include <__memory/uses_allocator.h>
372#include <__type_traits/strip_signature.h>
371373#include <__utility/auto_cast.h>
372374#include <__utility/forward.h>
373375#include <__utility/move.h>
374376#include <exception>
375#include <memory>
376377#include <mutex>
378#include <new>
377379#include <system_error>
378380#include <thread>
379381#include <version>
380382
381#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
382# include <chrono>
383#endif
384
385383#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
386384# pragma GCC system_header
387385#endif
......@@ -518,7 +516,7 @@ public:
518516 const error_code& code() const _NOEXCEPT {return __ec_;}
519517
520518 future_error(const future_error&) _NOEXCEPT = default;
521 virtual ~future_error() _NOEXCEPT;
519 ~future_error() _NOEXCEPT override;
522520};
523521
524522_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
......@@ -544,7 +542,7 @@ protected:
544542 mutable condition_variable __cv_;
545543 unsigned __state_;
546544
547 virtual void __on_zero_shared() _NOEXCEPT;
545 void __on_zero_shared() _NOEXCEPT override;
548546 void __sub_wait(unique_lock<mutex>& __lk);
549547public:
550548 enum
......@@ -627,11 +625,13 @@ class _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_HIDDEN __assoc_state
627625 : public __assoc_sub_state
628626{
629627 typedef __assoc_sub_state base;
628_LIBCPP_SUPPRESS_DEPRECATED_PUSH
630629 typedef typename aligned_storage<sizeof(_Rp), alignment_of<_Rp>::value>::type _Up;
630_LIBCPP_SUPPRESS_DEPRECATED_POP
631631protected:
632632 _Up __value_;
633633
634 virtual void __on_zero_shared() _NOEXCEPT;
634 void __on_zero_shared() _NOEXCEPT override;
635635public:
636636
637637 template <class _Arg>
......@@ -641,7 +641,7 @@ public:
641641 void set_value_at_thread_exit(_Arg&& __arg);
642642
643643 _Rp move();
644 typename add_lvalue_reference<_Rp>::type copy();
644 __add_lvalue_reference_t<_Rp> copy();
645645};
646646
647647template <class _Rp>
......@@ -687,18 +687,18 @@ __assoc_state<_Rp>::move()
687687 unique_lock<mutex> __lk(this->__mut_);
688688 this->__sub_wait(__lk);
689689 if (this->__exception_ != nullptr)
690 rethrow_exception(this->__exception_);
690 std::rethrow_exception(this->__exception_);
691691 return _VSTD::move(*reinterpret_cast<_Rp*>(&__value_));
692692}
693693
694694template <class _Rp>
695typename add_lvalue_reference<_Rp>::type
695__add_lvalue_reference_t<_Rp>
696696__assoc_state<_Rp>::copy()
697697{
698698 unique_lock<mutex> __lk(this->__mut_);
699699 this->__sub_wait(__lk);
700700 if (this->__exception_ != nullptr)
701 rethrow_exception(this->__exception_);
701 std::rethrow_exception(this->__exception_);
702702 return *reinterpret_cast<_Rp*>(&__value_);
703703}
704704
......@@ -711,7 +711,7 @@ class _LIBCPP_AVAILABILITY_FUTURE __assoc_state<_Rp&>
711711protected:
712712 _Up __value_;
713713
714 virtual void __on_zero_shared() _NOEXCEPT;
714 void __on_zero_shared() _NOEXCEPT override;
715715public:
716716
717717 void set_value(_Rp& __arg);
......@@ -758,7 +758,7 @@ __assoc_state<_Rp&>::copy()
758758 unique_lock<mutex> __lk(this->__mut_);
759759 this->__sub_wait(__lk);
760760 if (this->__exception_ != nullptr)
761 rethrow_exception(this->__exception_);
761 std::rethrow_exception(this->__exception_);
762762 return *__value_;
763763}
764764
......@@ -823,7 +823,7 @@ class _LIBCPP_AVAILABILITY_FUTURE __assoc_sub_state_alloc
823823 typedef __assoc_sub_state base;
824824 _Alloc __alloc_;
825825
826 virtual void __on_zero_shared() _NOEXCEPT;
826 void __on_zero_shared() _NOEXCEPT override;
827827public:
828828 _LIBCPP_INLINE_VISIBILITY
829829 explicit __assoc_sub_state_alloc(const _Alloc& __a)
......@@ -895,7 +895,7 @@ public:
895895 _LIBCPP_INLINE_VISIBILITY
896896 explicit __deferred_assoc_state(_Fp&& __f);
897897
898 virtual void __execute();
898 void __execute() override;
899899};
900900
901901template <class _Fp>
......@@ -982,12 +982,12 @@ class _LIBCPP_AVAILABILITY_FUTURE __async_assoc_state<void, _Fp>
982982
983983 _Fp __func_;
984984
985 virtual void __on_zero_shared() _NOEXCEPT;
985 void __on_zero_shared() _NOEXCEPT override;
986986public:
987987 _LIBCPP_INLINE_VISIBILITY
988988 explicit __async_assoc_state(_Fp&& __f);
989989
990 virtual void __execute();
990 void __execute() override;
991991};
992992
993993template <class _Fp>
......@@ -1628,7 +1628,7 @@ class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_base<_Rp(_ArgTypes...)>
16281628public:
16291629 _LIBCPP_INLINE_VISIBILITY
16301630 __packaged_task_base() {}
1631 _LIBCPP_INLINE_VISIBILITY
1631 _LIBCPP_HIDE_FROM_ABI_VIRTUAL
16321632 virtual ~__packaged_task_base() {}
16331633 virtual void __move_to(__packaged_task_base*) _NOEXCEPT = 0;
16341634 virtual void destroy() = 0;
......@@ -1704,7 +1704,9 @@ class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_function<_Rp(_ArgTypes...)>
17041704 _LIBCPP_INLINE_VISIBILITY _LIBCPP_NO_CFI
17051705 __base* __get_buf() { return (__base*)&__buf_; }
17061706
1707 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
17071708 typename aligned_storage<3*sizeof(void*)>::type __buf_;
1709 _LIBCPP_SUPPRESS_DEPRECATED_POP
17081710 __base* __f_;
17091711
17101712public:
......@@ -1754,7 +1756,7 @@ template <class _Fp>
17541756__packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(_Fp&& __f)
17551757 : __f_(nullptr)
17561758{
1757 typedef typename remove_reference<typename decay<_Fp>::type>::type _FR;
1759 typedef __libcpp_remove_reference_t<typename decay<_Fp>::type> _FR;
17581760 typedef __packaged_task_func<_FR, allocator<_FR>, _Rp(_ArgTypes...)> _FF;
17591761 if (sizeof(_FF) <= sizeof(__buf_))
17601762 {
......@@ -1778,7 +1780,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(
17781780 allocator_arg_t, const _Alloc& __a0, _Fp&& __f)
17791781 : __f_(nullptr)
17801782{
1781 typedef typename remove_reference<typename decay<_Fp>::type>::type _FR;
1783 typedef __libcpp_remove_reference_t<typename decay<_Fp>::type> _FR;
17821784 typedef __packaged_task_func<_FR, _Alloc, _Rp(_ArgTypes...)> _FF;
17831785 if (sizeof(_FF) <= sizeof(__buf_))
17841786 {
......@@ -1837,7 +1839,9 @@ __packaged_task_function<_Rp(_ArgTypes...)>::swap(__packaged_task_function& __f)
18371839{
18381840 if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
18391841 {
1842 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
18401843 typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
1844 _LIBCPP_SUPPRESS_DEPRECATED_POP
18411845 __base* __t = (__base*)&__tempbuf;
18421846 __f_->__move_to(__t);
18431847 __f_->destroy();
......@@ -1891,11 +1895,11 @@ public:
18911895 _LIBCPP_INLINE_VISIBILITY
18921896 packaged_task() _NOEXCEPT : __p_(nullptr) {}
18931897 template <class _Fp,
1894 class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
1898 class = __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value> >
18951899 _LIBCPP_INLINE_VISIBILITY
18961900 explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}
18971901 template <class _Fp, class _Allocator,
1898 class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
1902 class = __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value> >
18991903 _LIBCPP_INLINE_VISIBILITY
19001904 packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
19011905 : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
......@@ -2006,11 +2010,11 @@ public:
20062010 _LIBCPP_INLINE_VISIBILITY
20072011 packaged_task() _NOEXCEPT : __p_(nullptr) {}
20082012 template <class _Fp,
2009 class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
2013 class = __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value> >
20102014 _LIBCPP_INLINE_VISIBILITY
20112015 explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}
20122016 template <class _Fp, class _Allocator,
2013 class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
2017 class = __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value> >
20142018 _LIBCPP_INLINE_VISIBILITY
20152019 packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
20162020 : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
......@@ -2053,6 +2057,16 @@ public:
20532057 void reset();
20542058};
20552059
2060#if _LIBCPP_STD_VER >= 17
2061
2062template <class _Rp, class... _Args>
2063packaged_task(_Rp(*)(_Args...)) -> packaged_task<_Rp(_Args...)>;
2064
2065template <class _Fp, class _Stripped = typename __strip_signature<decltype(&_Fp::operator())>::type>
2066packaged_task(_Fp) -> packaged_task<_Stripped>;
2067
2068#endif
2069
20562070template<class ..._ArgTypes>
20572071void
20582072packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args)
......@@ -2174,7 +2188,7 @@ inline _LIBCPP_INLINE_VISIBILITY bool __does_policy_contain(launch __policy, lau
21742188{ return (int(__policy) & int(__value)) != 0; }
21752189
21762190template <class _Fp, class... _Args>
2177_LIBCPP_NODISCARD_AFTER_CXX17
2191_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
21782192future<typename __invoke_of<typename decay<_Fp>::type, typename decay<_Args>::type...>::type>
21792193async(launch __policy, _Fp&& __f, _Args&&... __args)
21802194{
......@@ -2436,4 +2450,8 @@ future<void>::share() _NOEXCEPT
24362450
24372451_LIBCPP_END_NAMESPACE_STD
24382452
2453#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
2454# include <chrono>
2455#endif
2456
24392457#endif // _LIBCPP_FUTURE
lib/libcxx/include/initializer_list+7-7
......@@ -62,7 +62,7 @@ class _LIBCPP_TEMPLATE_VIS initializer_list
6262 size_t __size_;
6363
6464 _LIBCPP_INLINE_VISIBILITY
65 _LIBCPP_CONSTEXPR_AFTER_CXX11
65 _LIBCPP_CONSTEXPR_SINCE_CXX14
6666 initializer_list(const _Ep* __b, size_t __s) _NOEXCEPT
6767 : __begin_(__b),
6868 __size_(__s)
......@@ -77,25 +77,25 @@ public:
7777 typedef const _Ep* const_iterator;
7878
7979 _LIBCPP_INLINE_VISIBILITY
80 _LIBCPP_CONSTEXPR_AFTER_CXX11
80 _LIBCPP_CONSTEXPR_SINCE_CXX14
8181 initializer_list() _NOEXCEPT : __begin_(nullptr), __size_(0) {}
8282
8383 _LIBCPP_INLINE_VISIBILITY
84 _LIBCPP_CONSTEXPR_AFTER_CXX11
84 _LIBCPP_CONSTEXPR_SINCE_CXX14
8585 size_t size() const _NOEXCEPT {return __size_;}
8686
8787 _LIBCPP_INLINE_VISIBILITY
88 _LIBCPP_CONSTEXPR_AFTER_CXX11
88 _LIBCPP_CONSTEXPR_SINCE_CXX14
8989 const _Ep* begin() const _NOEXCEPT {return __begin_;}
9090
9191 _LIBCPP_INLINE_VISIBILITY
92 _LIBCPP_CONSTEXPR_AFTER_CXX11
92 _LIBCPP_CONSTEXPR_SINCE_CXX14
9393 const _Ep* end() const _NOEXCEPT {return __begin_ + __size_;}
9494};
9595
9696template<class _Ep>
9797inline _LIBCPP_INLINE_VISIBILITY
98_LIBCPP_CONSTEXPR_AFTER_CXX11
98_LIBCPP_CONSTEXPR_SINCE_CXX14
9999const _Ep*
100100begin(initializer_list<_Ep> __il) _NOEXCEPT
101101{
......@@ -104,7 +104,7 @@ begin(initializer_list<_Ep> __il) _NOEXCEPT
104104
105105template<class _Ep>
106106inline _LIBCPP_INLINE_VISIBILITY
107_LIBCPP_CONSTEXPR_AFTER_CXX11
107_LIBCPP_CONSTEXPR_SINCE_CXX14
108108const _Ep*
109109end(initializer_list<_Ep> __il) _NOEXCEPT
110110{
lib/libcxx/include/inttypes.h+3-1
......@@ -248,7 +248,9 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int
248248# define __STDC_FORMAT_MACROS
249249#endif
250250
251#include_next <inttypes.h>
251#if __has_include_next(<inttypes.h>)
252# include_next <inttypes.h>
253#endif
252254
253255#ifdef __cplusplus
254256
lib/libcxx/include/iomanip+12-12
......@@ -278,7 +278,7 @@ setw(int __n)
278278template <class _MoneyT> class __iom_t7;
279279
280280template <class _CharT, class _Traits, class _MoneyT>
281basic_istream<_CharT, _Traits>&
281_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
282282operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x);
283283
284284template <class _MoneyT>
......@@ -298,7 +298,7 @@ public:
298298};
299299
300300template <class _CharT, class _Traits, class _MoneyT>
301basic_istream<_CharT, _Traits>&
301_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
302302operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x)
303303{
304304#ifndef _LIBCPP_NO_EXCEPTIONS
......@@ -311,7 +311,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x)
311311 typedef istreambuf_iterator<_CharT, _Traits> _Ip;
312312 typedef money_get<_CharT, _Ip> _Fp;
313313 ios_base::iostate __err = ios_base::goodbit;
314 const _Fp& __mf = use_facet<_Fp>(__is.getloc());
314 const _Fp& __mf = std::use_facet<_Fp>(__is.getloc());
315315 __mf.get(_Ip(__is), _Ip(), __x.__intl_, __is, __err, __x.__mon_);
316316 __is.setstate(__err);
317317 }
......@@ -338,7 +338,7 @@ get_money(_MoneyT& __mon, bool __intl = false)
338338template <class _MoneyT> class __iom_t8;
339339
340340template <class _CharT, class _Traits, class _MoneyT>
341basic_ostream<_CharT, _Traits>&
341_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
342342operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x);
343343
344344template <class _MoneyT>
......@@ -358,7 +358,7 @@ public:
358358};
359359
360360template <class _CharT, class _Traits, class _MoneyT>
361basic_ostream<_CharT, _Traits>&
361_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
362362operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x)
363363{
364364#ifndef _LIBCPP_NO_EXCEPTIONS
......@@ -370,7 +370,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x)
370370 {
371371 typedef ostreambuf_iterator<_CharT, _Traits> _Op;
372372 typedef money_put<_CharT, _Op> _Fp;
373 const _Fp& __mf = use_facet<_Fp>(__os.getloc());
373 const _Fp& __mf = std::use_facet<_Fp>(__os.getloc());
374374 if (__mf.put(_Op(__os), __x.__intl_, __os, __os.fill(), __x.__mon_).failed())
375375 __os.setstate(ios_base::badbit);
376376 }
......@@ -397,7 +397,7 @@ put_money(const _MoneyT& __mon, bool __intl = false)
397397template <class _CharT> class __iom_t9;
398398
399399template <class _CharT, class _Traits>
400basic_istream<_CharT, _Traits>&
400_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
401401operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x);
402402
403403template <class _CharT>
......@@ -417,7 +417,7 @@ public:
417417};
418418
419419template <class _CharT, class _Traits>
420basic_istream<_CharT, _Traits>&
420_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
421421operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x)
422422{
423423#ifndef _LIBCPP_NO_EXCEPTIONS
......@@ -430,7 +430,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x)
430430 typedef istreambuf_iterator<_CharT, _Traits> _Ip;
431431 typedef time_get<_CharT, _Ip> _Fp;
432432 ios_base::iostate __err = ios_base::goodbit;
433 const _Fp& __tf = use_facet<_Fp>(__is.getloc());
433 const _Fp& __tf = std::use_facet<_Fp>(__is.getloc());
434434 __tf.get(_Ip(__is), _Ip(), __is, __err, __x.__tm_,
435435 __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_));
436436 __is.setstate(__err);
......@@ -458,7 +458,7 @@ get_time(tm* __tm, const _CharT* __fmt)
458458template <class _CharT> class __iom_t10;
459459
460460template <class _CharT, class _Traits>
461basic_ostream<_CharT, _Traits>&
461_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
462462operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x);
463463
464464template <class _CharT>
......@@ -478,7 +478,7 @@ public:
478478};
479479
480480template <class _CharT, class _Traits>
481basic_ostream<_CharT, _Traits>&
481_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
482482operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x)
483483{
484484#ifndef _LIBCPP_NO_EXCEPTIONS
......@@ -490,7 +490,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x)
490490 {
491491 typedef ostreambuf_iterator<_CharT, _Traits> _Op;
492492 typedef time_put<_CharT, _Op> _Fp;
493 const _Fp& __tf = use_facet<_Fp>(__os.getloc());
493 const _Fp& __tf = std::use_facet<_Fp>(__os.getloc());
494494 if (__tf.put(_Op(__os), __os, __os.fill(), __x.__tm_,
495495 __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_)).failed())
496496 __os.setstate(ios_base::badbit);
lib/libcxx/include/ios+43-28
......@@ -224,6 +224,8 @@ storage-class-specifier const error_category& iostream_category() noexcept;
224224#include <version>
225225
226226// standard-mandated includes
227
228// [ios.syn]
227229#include <iosfwd>
228230
229231#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
......@@ -441,7 +443,7 @@ public:
441443 explicit failure(const string& __msg, const error_code& __ec = io_errc::stream);
442444 explicit failure(const char* __msg, const error_code& __ec = io_errc::stream);
443445 failure(const failure&) _NOEXCEPT = default;
444 virtual ~failure() _NOEXCEPT;
446 ~failure() _NOEXCEPT override;
445447};
446448
447449_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
......@@ -641,7 +643,7 @@ public:
641643 // 27.5.4.1 Constructor/destructor:
642644 _LIBCPP_INLINE_VISIBILITY
643645 explicit basic_ios(basic_streambuf<char_type,traits_type>* __sb);
644 virtual ~basic_ios();
646 ~basic_ios() override;
645647
646648 // 27.5.4.2 Members:
647649 _LIBCPP_INLINE_VISIBILITY
......@@ -764,7 +766,7 @@ inline _LIBCPP_INLINE_VISIBILITY
764766char
765767basic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const
766768{
767 return use_facet<ctype<char_type> >(getloc()).narrow(__c, __dfault);
769 return std::use_facet<ctype<char_type> >(getloc()).narrow(__c, __dfault);
768770}
769771
770772template <class _CharT, class _Traits>
......@@ -772,7 +774,7 @@ inline _LIBCPP_INLINE_VISIBILITY
772774_CharT
773775basic_ios<_CharT, _Traits>::widen(char __c) const
774776{
775 return use_facet<ctype<char_type> >(getloc()).widen(__c);
777 return std::use_facet<ctype<char_type> >(getloc()).widen(__c);
776778}
777779
778780template <class _CharT, class _Traits>
......@@ -842,7 +844,7 @@ basic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* _
842844 ios_base::set_rdbuf(__sb);
843845}
844846
845inline
847_LIBCPP_HIDE_FROM_ABI inline
846848ios_base&
847849boolalpha(ios_base& __str)
848850{
......@@ -850,7 +852,7 @@ boolalpha(ios_base& __str)
850852 return __str;
851853}
852854
853inline
855_LIBCPP_HIDE_FROM_ABI inline
854856ios_base&
855857noboolalpha(ios_base& __str)
856858{
......@@ -858,7 +860,7 @@ noboolalpha(ios_base& __str)
858860 return __str;
859861}
860862
861inline
863_LIBCPP_HIDE_FROM_ABI inline
862864ios_base&
863865showbase(ios_base& __str)
864866{
......@@ -866,7 +868,7 @@ showbase(ios_base& __str)
866868 return __str;
867869}
868870
869inline
871_LIBCPP_HIDE_FROM_ABI inline
870872ios_base&
871873noshowbase(ios_base& __str)
872874{
......@@ -874,7 +876,7 @@ noshowbase(ios_base& __str)
874876 return __str;
875877}
876878
877inline
879_LIBCPP_HIDE_FROM_ABI inline
878880ios_base&
879881showpoint(ios_base& __str)
880882{
......@@ -882,7 +884,7 @@ showpoint(ios_base& __str)
882884 return __str;
883885}
884886
885inline
887_LIBCPP_HIDE_FROM_ABI inline
886888ios_base&
887889noshowpoint(ios_base& __str)
888890{
......@@ -890,7 +892,7 @@ noshowpoint(ios_base& __str)
890892 return __str;
891893}
892894
893inline
895_LIBCPP_HIDE_FROM_ABI inline
894896ios_base&
895897showpos(ios_base& __str)
896898{
......@@ -898,7 +900,7 @@ showpos(ios_base& __str)
898900 return __str;
899901}
900902
901inline
903_LIBCPP_HIDE_FROM_ABI inline
902904ios_base&
903905noshowpos(ios_base& __str)
904906{
......@@ -906,7 +908,7 @@ noshowpos(ios_base& __str)
906908 return __str;
907909}
908910
909inline
911_LIBCPP_HIDE_FROM_ABI inline
910912ios_base&
911913skipws(ios_base& __str)
912914{
......@@ -914,7 +916,7 @@ skipws(ios_base& __str)
914916 return __str;
915917}
916918
917inline
919_LIBCPP_HIDE_FROM_ABI inline
918920ios_base&
919921noskipws(ios_base& __str)
920922{
......@@ -922,7 +924,7 @@ noskipws(ios_base& __str)
922924 return __str;
923925}
924926
925inline
927_LIBCPP_HIDE_FROM_ABI inline
926928ios_base&
927929uppercase(ios_base& __str)
928930{
......@@ -930,7 +932,7 @@ uppercase(ios_base& __str)
930932 return __str;
931933}
932934
933inline
935_LIBCPP_HIDE_FROM_ABI inline
934936ios_base&
935937nouppercase(ios_base& __str)
936938{
......@@ -938,7 +940,7 @@ nouppercase(ios_base& __str)
938940 return __str;
939941}
940942
941inline
943_LIBCPP_HIDE_FROM_ABI inline
942944ios_base&
943945unitbuf(ios_base& __str)
944946{
......@@ -946,7 +948,7 @@ unitbuf(ios_base& __str)
946948 return __str;
947949}
948950
949inline
951_LIBCPP_HIDE_FROM_ABI inline
950952ios_base&
951953nounitbuf(ios_base& __str)
952954{
......@@ -954,7 +956,7 @@ nounitbuf(ios_base& __str)
954956 return __str;
955957}
956958
957inline
959_LIBCPP_HIDE_FROM_ABI inline
958960ios_base&
959961internal(ios_base& __str)
960962{
......@@ -962,7 +964,7 @@ internal(ios_base& __str)
962964 return __str;
963965}
964966
965inline
967_LIBCPP_HIDE_FROM_ABI inline
966968ios_base&
967969left(ios_base& __str)
968970{
......@@ -970,7 +972,7 @@ left(ios_base& __str)
970972 return __str;
971973}
972974
973inline
975_LIBCPP_HIDE_FROM_ABI inline
974976ios_base&
975977right(ios_base& __str)
976978{
......@@ -978,7 +980,7 @@ right(ios_base& __str)
978980 return __str;
979981}
980982
981inline
983_LIBCPP_HIDE_FROM_ABI inline
982984ios_base&
983985dec(ios_base& __str)
984986{
......@@ -986,7 +988,7 @@ dec(ios_base& __str)
986988 return __str;
987989}
988990
989inline
991_LIBCPP_HIDE_FROM_ABI inline
990992ios_base&
991993hex(ios_base& __str)
992994{
......@@ -994,7 +996,7 @@ hex(ios_base& __str)
994996 return __str;
995997}
996998
997inline
999_LIBCPP_HIDE_FROM_ABI inline
9981000ios_base&
9991001oct(ios_base& __str)
10001002{
......@@ -1002,7 +1004,7 @@ oct(ios_base& __str)
10021004 return __str;
10031005}
10041006
1005inline
1007_LIBCPP_HIDE_FROM_ABI inline
10061008ios_base&
10071009fixed(ios_base& __str)
10081010{
......@@ -1010,7 +1012,7 @@ fixed(ios_base& __str)
10101012 return __str;
10111013}
10121014
1013inline
1015_LIBCPP_HIDE_FROM_ABI inline
10141016ios_base&
10151017scientific(ios_base& __str)
10161018{
......@@ -1018,7 +1020,7 @@ scientific(ios_base& __str)
10181020 return __str;
10191021}
10201022
1021inline
1023_LIBCPP_HIDE_FROM_ABI inline
10221024ios_base&
10231025hexfloat(ios_base& __str)
10241026{
......@@ -1026,7 +1028,7 @@ hexfloat(ios_base& __str)
10261028 return __str;
10271029}
10281030
1029inline
1031_LIBCPP_HIDE_FROM_ABI inline
10301032ios_base&
10311033defaultfloat(ios_base& __str)
10321034{
......@@ -1036,4 +1038,17 @@ defaultfloat(ios_base& __str)
10361038
10371039_LIBCPP_END_NAMESPACE_STD
10381040
1041#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1042# include <concepts>
1043# include <cstddef>
1044# include <cstdlib>
1045# include <cstring>
1046# include <initializer_list>
1047# include <limits>
1048# include <new>
1049# include <stdexcept>
1050# include <type_traits>
1051# include <typeinfo>
1052#endif
1053
10391054#endif // _LIBCPP_IOS
lib/libcxx/include/iosfwd+1-25
......@@ -96,6 +96,7 @@ using u32streampos = fpos<char_traits<char32_t>::state_type>;
9696
9797#include <__assert> // all public C++ headers provide the assertion handler
9898#include <__config>
99#include <__fwd/string.h>
99100#include <__mbstate_t.h>
100101#include <version>
101102
......@@ -107,19 +108,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
107108
108109class _LIBCPP_TYPE_VIS ios_base;
109110
110template<class _CharT> struct _LIBCPP_TEMPLATE_VIS char_traits;
111template<> struct char_traits<char>;
112#ifndef _LIBCPP_HAS_NO_CHAR8_T
113template<> struct char_traits<char8_t>;
114#endif
115template<> struct char_traits<char16_t>;
116template<> struct char_traits<char32_t>;
117#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
118template<> struct char_traits<wchar_t>;
119#endif
120
121template<class _Tp> class _LIBCPP_TEMPLATE_VIS allocator;
122
123111template <class _CharT, class _Traits = char_traits<_CharT> >
124112 class _LIBCPP_TEMPLATE_VIS basic_ios;
125113
......@@ -242,18 +230,6 @@ typedef long int streamoff; // for char_traits in <string>
242230typedef long long streamoff; // for char_traits in <string>
243231#endif
244232
245template <class _CharT, // for <stdexcept>
246 class _Traits = char_traits<_CharT>,
247 class _Allocator = allocator<_CharT> >
248 class _LIBCPP_TEMPLATE_VIS basic_string;
249typedef basic_string<char, char_traits<char>, allocator<char> > string;
250#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
251typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring;
252#endif
253
254template <class _CharT, class _Traits, class _Allocator>
255 class _LIBCPP_PREFERRED_NAME(string) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstring)) basic_string;
256
257233// Include other forward declarations here
258234template <class _Tp, class _Alloc = allocator<_Tp> >
259235class _LIBCPP_TEMPLATE_VIS vector;
lib/libcxx/include/iostream+2
......@@ -38,6 +38,8 @@ extern wostream wclog;
3838#include <version>
3939
4040// standard-mandated includes
41
42// [iostream.syn]
4143#include <ios>
4244#include <istream>
4345#include <ostream>
lib/libcxx/include/istream+23-18
......@@ -192,7 +192,7 @@ public:
192192 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
193193 explicit basic_istream(basic_streambuf<char_type, traits_type>* __sb) : __gc_(0)
194194 { this->init(__sb); }
195 virtual ~basic_istream();
195 ~basic_istream() override;
196196protected:
197197 inline _LIBCPP_INLINE_VISIBILITY
198198 basic_istream(basic_istream&& __rhs);
......@@ -316,7 +316,7 @@ basic_istream<_CharT, _Traits>::sentry::sentry(basic_istream<_CharT, _Traits>& _
316316 if (!__noskipws && (__is.flags() & ios_base::skipws))
317317 {
318318 typedef istreambuf_iterator<_CharT, _Traits> _Ip;
319 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
319 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
320320 _Ip __i(__is);
321321 _Ip __eof;
322322 for (; __i != __eof; ++__i)
......@@ -366,7 +366,7 @@ __input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {
366366#endif // _LIBCPP_NO_EXCEPTIONS
367367 typedef istreambuf_iterator<_CharT, _Traits> _Ip;
368368 typedef num_get<_CharT, _Ip> _Fp;
369 use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __state, __n);
369 std::use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __state, __n);
370370#ifndef _LIBCPP_NO_EXCEPTIONS
371371 }
372372 catch (...)
......@@ -476,7 +476,7 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp
476476 typedef istreambuf_iterator<_CharT, _Traits> _Ip;
477477 typedef num_get<_CharT, _Ip> _Fp;
478478 long __temp;
479 use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __state, __temp);
479 std::use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __state, __temp);
480480 if (__temp < numeric_limits<_Tp>::min())
481481 {
482482 __state |= ios_base::failbit;
......@@ -536,7 +536,7 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n)
536536 {
537537#endif
538538 _CharT* __s = __p;
539 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
539 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
540540 while (__s != __p + (__n-1))
541541 {
542542 typename _Traits::int_type __i = __is.rdbuf()->sgetc();
......@@ -633,7 +633,7 @@ operator>>(basic_istream<char, _Traits>& __is, signed char* __s)
633633#endif // _LIBCPP_STD_VER > 17
634634
635635template<class _CharT, class _Traits>
636basic_istream<_CharT, _Traits>&
636_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
637637operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c)
638638{
639639 ios_base::iostate __state = ios_base::goodbit;
......@@ -1329,7 +1329,7 @@ basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir)
13291329}
13301330
13311331template <class _CharT, class _Traits>
1332basic_istream<_CharT, _Traits>&
1332_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
13331333ws(basic_istream<_CharT, _Traits>& __is)
13341334{
13351335 ios_base::iostate __state = ios_base::goodbit;
......@@ -1340,7 +1340,7 @@ ws(basic_istream<_CharT, _Traits>& __is)
13401340 try
13411341 {
13421342#endif // _LIBCPP_NO_EXCEPTIONS
1343 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
1343 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
13441344 while (true)
13451345 {
13461346 typename _Traits::int_type __i = __is.rdbuf()->sgetc();
......@@ -1375,7 +1375,7 @@ struct __is_istreamable : false_type { };
13751375
13761376template <class _Stream, class _Tp>
13771377struct __is_istreamable<_Stream, _Tp, decltype(
1378 declval<_Stream>() >> declval<_Tp>(), void()
1378 std::declval<_Stream>() >> std::declval<_Tp>(), void()
13791379)> : true_type { };
13801380
13811381template <class _Stream, class _Tp, class = typename enable_if<
......@@ -1408,7 +1408,7 @@ public:
14081408 : basic_istream<_CharT, _Traits>(__sb)
14091409 {}
14101410
1411 virtual ~basic_iostream();
1411 ~basic_iostream() override;
14121412protected:
14131413 inline _LIBCPP_INLINE_VISIBILITY
14141414 basic_iostream(basic_iostream&& __rhs);
......@@ -1442,7 +1442,7 @@ basic_iostream<_CharT, _Traits>::~basic_iostream()
14421442}
14431443
14441444template<class _CharT, class _Traits, class _Allocator>
1445basic_istream<_CharT, _Traits>&
1445_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
14461446operator>>(basic_istream<_CharT, _Traits>& __is,
14471447 basic_string<_CharT, _Traits, _Allocator>& __str)
14481448{
......@@ -1461,7 +1461,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
14611461 if (__n <= 0)
14621462 __n = numeric_limits<streamsize>::max();
14631463 streamsize __c = 0;
1464 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
1464 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
14651465 while (__c < __n)
14661466 {
14671467 typename _Traits::int_type __i = __is.rdbuf()->sgetc();
......@@ -1498,7 +1498,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
14981498}
14991499
15001500template<class _CharT, class _Traits, class _Allocator>
1501basic_istream<_CharT, _Traits>&
1501_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
15021502getline(basic_istream<_CharT, _Traits>& __is,
15031503 basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm)
15041504{
......@@ -1556,7 +1556,7 @@ basic_istream<_CharT, _Traits>&
15561556getline(basic_istream<_CharT, _Traits>& __is,
15571557 basic_string<_CharT, _Traits, _Allocator>& __str)
15581558{
1559 return getline(__is, __str, __is.widen('\n'));
1559 return std::getline(__is, __str, __is.widen('\n'));
15601560}
15611561
15621562template<class _CharT, class _Traits, class _Allocator>
......@@ -1565,7 +1565,7 @@ basic_istream<_CharT, _Traits>&
15651565getline(basic_istream<_CharT, _Traits>&& __is,
15661566 basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm)
15671567{
1568 return getline(__is, __str, __dlm);
1568 return std::getline(__is, __str, __dlm);
15691569}
15701570
15711571template<class _CharT, class _Traits, class _Allocator>
......@@ -1574,11 +1574,11 @@ basic_istream<_CharT, _Traits>&
15741574getline(basic_istream<_CharT, _Traits>&& __is,
15751575 basic_string<_CharT, _Traits, _Allocator>& __str)
15761576{
1577 return getline(__is, __str, __is.widen('\n'));
1577 return std::getline(__is, __str, __is.widen('\n'));
15781578}
15791579
15801580template <class _CharT, class _Traits, size_t _Size>
1581basic_istream<_CharT, _Traits>&
1581_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
15821582operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
15831583{
15841584 ios_base::iostate __state = ios_base::goodbit;
......@@ -1590,7 +1590,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
15901590 {
15911591#endif
15921592 basic_string<_CharT, _Traits> __str;
1593 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
1593 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
15941594 size_t __c = 0;
15951595 _CharT __zero = __ct.widen('0');
15961596 _CharT __one = __ct.widen('1');
......@@ -1637,6 +1637,11 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>;
16371637
16381638_LIBCPP_END_NAMESPACE_STD
16391639
1640#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1641# include <concepts>
1642# include <type_traits>
1643#endif
1644
16401645_LIBCPP_POP_MACROS
16411646
16421647#endif // _LIBCPP_ISTREAM
lib/libcxx/include/iterator+12-8
......@@ -717,22 +717,26 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;
717717#include <__iterator/wrap_iter.h>
718718#include <__memory/addressof.h>
719719#include <__memory/pointer_traits.h>
720#include <compare>
721#include <concepts> // Mandated by the Standard.
722720#include <cstddef>
723721#include <initializer_list>
724#include <type_traits>
725722#include <version>
726723
727#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
724// standard-mandated includes
725
726// [iterator.synopsis]
727#include <compare>
728#include <concepts>
729
730#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
731# pragma GCC system_header
732#endif
733
734#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
728735# include <exception>
729736# include <new>
737# include <type_traits>
730738# include <typeinfo>
731739# include <utility>
732740#endif
733741
734#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
735# pragma GCC system_header
736#endif
737
738742#endif // _LIBCPP_ITERATOR
lib/libcxx/include/latch+6-6
......@@ -64,7 +64,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
6464
6565class latch
6666{
67 __atomic_base<ptrdiff_t> __a;
67 __atomic_base<ptrdiff_t> __a_;
6868
6969public:
7070 static constexpr ptrdiff_t max() noexcept {
......@@ -72,7 +72,7 @@ public:
7272 }
7373
7474 inline _LIBCPP_INLINE_VISIBILITY
75 constexpr explicit latch(ptrdiff_t __expected) : __a(__expected) { }
75 constexpr explicit latch(ptrdiff_t __expected) : __a_(__expected) { }
7676
7777 ~latch() = default;
7878 latch(const latch&) = delete;
......@@ -81,19 +81,19 @@ public:
8181 inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
8282 void count_down(ptrdiff_t __update = 1)
8383 {
84 auto const __old = __a.fetch_sub(__update, memory_order_release);
84 auto const __old = __a_.fetch_sub(__update, memory_order_release);
8585 if(__old == __update)
86 __a.notify_all();
86 __a_.notify_all();
8787 }
8888 inline _LIBCPP_INLINE_VISIBILITY
8989 bool try_wait() const noexcept
9090 {
91 return 0 == __a.load(memory_order_acquire);
91 return 0 == __a_.load(memory_order_acquire);
9292 }
9393 inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
9494 void wait() const
9595 {
96 __cxx_atomic_wait(&__a.__a_, [&]() -> bool {
96 __cxx_atomic_wait(&__a_.__a_, [&]() -> bool {
9797 return try_wait();
9898 });
9999 }
lib/libcxx/include/limits+10-8
......@@ -104,11 +104,9 @@ template<> class numeric_limits<cv long double>;
104104
105105#include <__assert> // all public C++ headers provide the assertion handler
106106#include <__config>
107#include <type_traits>
108
109#if defined(_LIBCPP_COMPILER_MSVC)
110#include "__support/win32/limits_msvc_win32.h"
111#endif // _LIBCPP_MSVCRT
107#include <__type_traits/is_arithmetic.h>
108#include <__type_traits/is_signed.h>
109#include <__type_traits/remove_cv.h>
112110
113111#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
114112# pragma GCC system_header
......@@ -432,7 +430,7 @@ protected:
432430 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __builtin_nansl("");}
433431 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __LDBL_DENORM_MIN__;}
434432
435#if (defined(__ppc__) || defined(__ppc64__))
433#if defined(__powerpc__) && defined(__LONG_DOUBLE_IBM128__)
436434 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
437435#else
438436 static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
......@@ -451,9 +449,9 @@ protected:
451449
452450template <class _Tp>
453451class _LIBCPP_TEMPLATE_VIS numeric_limits
454 : private __libcpp_numeric_limits<typename remove_cv<_Tp>::type>
452 : private __libcpp_numeric_limits<__remove_cv_t<_Tp> >
455453{
456 typedef __libcpp_numeric_limits<typename remove_cv<_Tp>::type> __base;
454 typedef __libcpp_numeric_limits<__remove_cv_t<_Tp> > __base;
457455 typedef typename __base::type type;
458456public:
459457 static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
......@@ -825,4 +823,8 @@ _LIBCPP_END_NAMESPACE_STD
825823
826824_LIBCPP_POP_MACROS
827825
826#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
827# include <type_traits>
828#endif
829
828830#endif // _LIBCPP_LIMITS
lib/libcxx/include/limits.h+13-6
......@@ -43,13 +43,13 @@ Macros:
4343# pragma GCC system_header
4444#endif
4545
46#ifndef __GNUC__
47#include_next <limits.h>
48#else
46#ifdef _LIBCPP_COMPILER_GCC
47
4948// GCC header limits.h recursively includes itself through another header called
5049// syslimits.h for some reason. This setup breaks down if we directly
51// #include_next GCC's limits.h (reasons not entirely clear to me). Therefore,
52// we manually re-create the necessary include sequence below:
50// #include_next GCC's limits.h (reasons not entirely clear to me).
51// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107795 for more details.
52// Therefore, we manually re-create the necessary include sequence below:
5353
5454// Get the system limits.h defines (force recurse into the next level)
5555#define _GCC_LIMITS_H_
......@@ -59,6 +59,13 @@ Macros:
5959// Get the ISO C defines
6060#undef _GCC_LIMITS_H_
6161#include_next <limits.h>
62#endif // __GNUC__
62
63#else
64
65# if __has_include_next(<limits.h>)
66# include_next <limits.h>
67# endif
68
69#endif // _LIBCPP_COMPILER_GCC
6370
6471#endif // _LIBCPP_LIMITS_H
lib/libcxx/include/list+43-24
......@@ -194,21 +194,24 @@ template <class T, class Allocator, class Predicate>
194194#include <__iterator/next.h>
195195#include <__iterator/prev.h>
196196#include <__iterator/reverse_iterator.h>
197#include <__memory/addressof.h>
198#include <__memory/allocator.h>
199#include <__memory/allocator_destructor.h>
200#include <__memory/allocator_traits.h>
201#include <__memory/compressed_pair.h>
202#include <__memory/pointer_traits.h>
197203#include <__memory/swap_allocator.h>
204#include <__memory/unique_ptr.h>
205#include <__memory_resource/polymorphic_allocator.h>
206#include <__type_traits/is_allocator.h>
198207#include <__utility/forward.h>
199208#include <__utility/move.h>
200209#include <__utility/swap.h>
210#include <cstring>
201211#include <limits>
202#include <memory>
203212#include <type_traits>
204213#include <version>
205214
206#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
207# include <algorithm>
208# include <functional>
209# include <iterator>
210#endif
211
212215// standard-mandated includes
213216
214217// [iterator.range]
......@@ -237,26 +240,19 @@ template <class _Tp, class _VoidPtr> struct __list_node_base;
237240
238241template <class _Tp, class _VoidPtr>
239242struct __list_node_pointer_traits {
240 typedef typename __rebind_pointer<_VoidPtr, __list_node<_Tp, _VoidPtr> >::type
243 typedef __rebind_pointer_t<_VoidPtr, __list_node<_Tp, _VoidPtr> >
241244 __node_pointer;
242 typedef typename __rebind_pointer<_VoidPtr, __list_node_base<_Tp, _VoidPtr> >::type
245 typedef __rebind_pointer_t<_VoidPtr, __list_node_base<_Tp, _VoidPtr> >
243246 __base_pointer;
244247
245248#if defined(_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB)
246249 typedef __base_pointer __link_pointer;
247250#else
248 typedef typename conditional<
249 is_pointer<_VoidPtr>::value,
250 __base_pointer,
251 __node_pointer
252 >::type __link_pointer;
251 typedef __conditional_t<is_pointer<_VoidPtr>::value, __base_pointer, __node_pointer> __link_pointer;
253252#endif
254253
255 typedef typename conditional<
256 is_same<__link_pointer, __node_pointer>::value,
257 __base_pointer,
258 __node_pointer
259 >::type __non_link_pointer;
254 typedef __conditional_t<is_same<__link_pointer, __node_pointer>::value, __base_pointer, __node_pointer>
255 __non_link_pointer;
260256
261257 static _LIBCPP_INLINE_VISIBILITY
262258 __link_pointer __unsafe_link_pointer_cast(__link_pointer __p) {
......@@ -340,7 +336,7 @@ public:
340336 typedef bidirectional_iterator_tag iterator_category;
341337 typedef _Tp value_type;
342338 typedef value_type& reference;
343 typedef typename __rebind_pointer<_VoidPtr, value_type>::type pointer;
339 typedef __rebind_pointer_t<_VoidPtr, value_type> pointer;
344340 typedef typename pointer_traits<pointer>::difference_type difference_type;
345341
346342 _LIBCPP_INLINE_VISIBILITY
......@@ -448,7 +444,7 @@ public:
448444 typedef bidirectional_iterator_tag iterator_category;
449445 typedef _Tp value_type;
450446 typedef const value_type& reference;
451 typedef typename __rebind_pointer<_VoidPtr, const value_type>::type pointer;
447 typedef __rebind_pointer_t<_VoidPtr, const value_type> pointer;
452448 typedef typename pointer_traits<pointer>::difference_type difference_type;
453449
454450 _LIBCPP_INLINE_VISIBILITY
......@@ -555,7 +551,7 @@ protected:
555551 typedef __list_const_iterator<value_type, __void_pointer> const_iterator;
556552 typedef __list_node_base<value_type, __void_pointer> __node_base;
557553 typedef __list_node<value_type, __void_pointer> __node;
558 typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator;
554 typedef __rebind_alloc<__alloc_traits, __node> __node_allocator;
559555 typedef allocator_traits<__node_allocator> __node_alloc_traits;
560556 typedef typename __node_alloc_traits::pointer __node_pointer;
561557 typedef typename __node_alloc_traits::pointer __node_const_pointer;
......@@ -566,7 +562,7 @@ protected:
566562 typedef typename __alloc_traits::const_pointer const_pointer;
567563 typedef typename __alloc_traits::difference_type difference_type;
568564
569 typedef typename __rebind_alloc_helper<__alloc_traits, __node_base>::type __node_base_allocator;
565 typedef __rebind_alloc<__alloc_traits, __node_base> __node_base_allocator;
570566 typedef typename allocator_traits<__node_base_allocator>::pointer __node_base_pointer;
571567 static_assert((!is_same<allocator_type, __node_allocator>::value),
572568 "internal allocator type must differ from user-specified "
......@@ -845,6 +841,10 @@ public:
845841 typedef void __remove_return_type;
846842#endif
847843
844 static_assert(is_same<allocator_type, __rebind_alloc<allocator_traits<allocator_type>, value_type> >::value,
845 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
846 "original allocator");
847
848848 _LIBCPP_INLINE_VISIBILITY
849849 list()
850850 _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
......@@ -1063,7 +1063,7 @@ public:
10631063 __remove_return_type remove(const value_type& __x);
10641064 template <class _Pred> __remove_return_type remove_if(_Pred __pred);
10651065 _LIBCPP_INLINE_VISIBILITY
1066 __remove_return_type unique() { return unique(__equal_to<value_type>()); }
1066 __remove_return_type unique() { return unique(__equal_to()); }
10671067 template <class _BinaryPred>
10681068 __remove_return_type unique(_BinaryPred __binary_pred);
10691069 _LIBCPP_INLINE_VISIBILITY
......@@ -2362,6 +2362,25 @@ inline constexpr bool __format::__enable_insertable<std::list<wchar_t>> = true;
23622362
23632363_LIBCPP_END_NAMESPACE_STD
23642364
2365#if _LIBCPP_STD_VER > 14
2366_LIBCPP_BEGIN_NAMESPACE_STD
2367namespace pmr {
2368template <class _ValueT>
2369using list = std::list<_ValueT, polymorphic_allocator<_ValueT>>;
2370} // namespace pmr
2371_LIBCPP_END_NAMESPACE_STD
2372#endif
2373
23652374_LIBCPP_POP_MACROS
23662375
2376#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
2377# include <algorithm>
2378# include <atomic>
2379# include <concepts>
2380# include <functional>
2381# include <iosfwd>
2382# include <iterator>
2383# include <typeinfo>
2384#endif
2385
23672386#endif // _LIBCPP_LIST
lib/libcxx/include/locale+136-140
......@@ -201,19 +201,18 @@ template <class charT> class messages_byname;
201201#include <__iterator/istreambuf_iterator.h>
202202#include <__iterator/ostreambuf_iterator.h>
203203#include <__locale>
204#include <cstdarg> // TODO: Remove this include
204#include <__memory/unique_ptr.h>
205205#include <cstdio>
206206#include <cstdlib>
207207#include <ctime>
208208#include <ios>
209209#include <limits>
210#include <memory>
210#include <new>
211211#include <streambuf>
212212#include <version>
213213
214#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
215# include <iterator>
216#endif
214// TODO: Fix __bsd_locale_defaults.h
215// NOLINTBEGIN(libcpp-robust-against-adl)
217216
218217#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
219218// Most unix variants have catopen. These are the specific ones that don't.
......@@ -239,7 +238,7 @@ _LIBCPP_PUSH_MACROS
239238
240239_LIBCPP_BEGIN_NAMESPACE_STD
241240
242#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__)
241#if defined(__APPLE__) || defined(__FreeBSD__)
243242# define _LIBCPP_GET_C_LOCALE 0
244243#elif defined(__NetBSD__)
245244# define _LIBCPP_GET_C_LOCALE LC_C_LOCALE
......@@ -269,7 +268,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
269268// If the input is "a", the first keyword matches and eofbit is set.
270269// If the input is "abc", no match is found and "ab" are consumed.
271270template <class _InputIterator, class _ForwardIterator, class _Ctype>
272_LIBCPP_HIDDEN
271_LIBCPP_HIDE_FROM_ABI
273272_ForwardIterator
274273__scan_keyword(_InputIterator& __b, _InputIterator __e,
275274 _ForwardIterator __kb, _ForwardIterator __ke,
......@@ -450,8 +449,8 @@ string
450449__num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep)
451450{
452451 locale __loc = __iob.getloc();
453 use_facet<ctype<_CharT> >(__loc).widen(__src, __src + 26, __atoms);
454 const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
452 std::use_facet<ctype<_CharT> >(__loc).widen(__src, __src + 26, __atoms);
453 const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__loc);
455454 __thousands_sep = __np.thousands_sep();
456455 return __np.grouping();
457456}
......@@ -463,8 +462,8 @@ __num_get<_CharT>::__stage2_float_prep(ios_base& __iob, _CharT* __atoms, _CharT&
463462 _CharT& __thousands_sep)
464463{
465464 locale __loc = __iob.getloc();
466 use_facet<ctype<_CharT> >(__loc).widen(__src, __src + 32, __atoms);
467 const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
465 std::use_facet<ctype<_CharT> >(__loc).widen(__src, __src + 32, __atoms);
466 const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__loc);
468467 __decimal_point = __np.decimal_point();
469468 __thousands_sep = __np.thousands_sep();
470469 return __np.grouping();
......@@ -498,7 +497,7 @@ __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*&
498497 }
499498 return 0;
500499 }
501 ptrdiff_t __f = find(__atoms, __atoms + 26, __ct) - __atoms;
500 ptrdiff_t __f = std::find(__atoms, __atoms + 26, __ct) - __atoms;
502501 if (__f >= 24)
503502 return -1;
504503 switch (__base)
......@@ -551,13 +550,13 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex
551550 }
552551 return 0;
553552 }
554 ptrdiff_t __f = find(__atoms, __atoms + 32, __ct) - __atoms;
553 ptrdiff_t __f = std::find(__atoms, __atoms + 32, __ct) - __atoms;
555554 if (__f >= 32)
556555 return -1;
557556 char __x = __src[__f];
558557 if (__x == '-' || __x == '+')
559558 {
560 if (__a_end == __a || (__a_end[-1] & 0x5F) == (__exp & 0x7F))
559 if (__a_end == __a || (std::toupper(__a_end[-1]) == std::toupper(__exp)))
561560 {
562561 *__a_end++ = __x;
563562 return 0;
......@@ -566,9 +565,9 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex
566565 }
567566 if (__x == 'x' || __x == 'X')
568567 __exp = 'P';
569 else if ((__x & 0x5F) == __exp)
568 else if (std::toupper(__x) == __exp)
570569 {
571 __exp |= (char) 0x80;
570 __exp = std::tolower(__exp);
572571 if (__in_units)
573572 {
574573 __in_units = false;
......@@ -681,8 +680,7 @@ public:
681680 static locale::id id;
682681
683682protected:
684 _LIBCPP_INLINE_VISIBILITY
685 ~num_get() {}
683 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~num_get() override {}
686684
687685 template <class _Fp>
688686 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
......@@ -751,17 +749,17 @@ locale::id
751749num_get<_CharT, _InputIterator>::id;
752750
753751template <class _Tp>
754_LIBCPP_HIDDEN _Tp
752_LIBCPP_HIDE_FROM_ABI _Tp
755753__num_get_signed_integral(const char* __a, const char* __a_end,
756754 ios_base::iostate& __err, int __base)
757755{
758756 if (__a != __a_end)
759757 {
760 typename remove_reference<decltype(errno)>::type __save_errno = errno;
758 __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno;
761759 errno = 0;
762760 char *__p2;
763761 long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
764 typename remove_reference<decltype(errno)>::type __current_errno = errno;
762 __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno;
765763 if (__current_errno == 0)
766764 errno = __save_errno;
767765 if (__p2 != __a_end)
......@@ -786,7 +784,7 @@ __num_get_signed_integral(const char* __a, const char* __a_end,
786784}
787785
788786template <class _Tp>
789_LIBCPP_HIDDEN _Tp
787_LIBCPP_HIDE_FROM_ABI _Tp
790788__num_get_unsigned_integral(const char* __a, const char* __a_end,
791789 ios_base::iostate& __err, int __base)
792790{
......@@ -797,11 +795,11 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end,
797795 __err = ios_base::failbit;
798796 return 0;
799797 }
800 typename remove_reference<decltype(errno)>::type __save_errno = errno;
798 __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno;
801799 errno = 0;
802800 char *__p2;
803801 unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
804 typename remove_reference<decltype(errno)>::type __current_errno = errno;
802 __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno;
805803 if (__current_errno == 0)
806804 errno = __save_errno;
807805 if (__p2 != __a_end)
......@@ -845,17 +843,17 @@ long double __do_strtod<long double>(const char* __a, char** __p2) {
845843}
846844
847845template <class _Tp>
848_LIBCPP_HIDDEN
846_LIBCPP_HIDE_FROM_ABI
849847_Tp
850848__num_get_float(const char* __a, const char* __a_end, ios_base::iostate& __err)
851849{
852850 if (__a != __a_end)
853851 {
854 typename remove_reference<decltype(errno)>::type __save_errno = errno;
852 __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno;
855853 errno = 0;
856854 char *__p2;
857 _Tp __ld = __do_strtod<_Tp>(__a, &__p2);
858 typename remove_reference<decltype(errno)>::type __current_errno = errno;
855 _Tp __ld = std::__do_strtod<_Tp>(__a, &__p2);
856 __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno;
859857 if (__current_errno == 0)
860858 errno = __save_errno;
861859 if (__p2 != __a_end)
......@@ -897,8 +895,8 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
897895 }
898896 return __b;
899897 }
900 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__iob.getloc());
901 const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__iob.getloc());
898 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__iob.getloc());
899 const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__iob.getloc());
902900 typedef typename numpunct<_CharT>::string_type string_type;
903901 const string_type __names[2] = {__np.truename(), __np.falsename()};
904902 const string_type* __i = _VSTD::__scan_keyword(__b, __e, __names, __names+2,
......@@ -955,7 +953,7 @@ num_get<_CharT, _InputIterator>::__do_get_signed(iter_type __b, iter_type __e,
955953 if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz)
956954 *__g_end++ = __dc;
957955 // Stage 3
958 __v = __num_get_signed_integral<_Signed>(__a, __a_end, __err, __base);
956 __v = std::__num_get_signed_integral<_Signed>(__a, __a_end, __err, __base);
959957 // Digit grouping checked
960958 __check_grouping(__grouping, __g, __g_end, __err);
961959 // EOF checked
......@@ -1012,7 +1010,7 @@ num_get<_CharT, _InputIterator>::__do_get_unsigned(iter_type __b, iter_type __e,
10121010 if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz)
10131011 *__g_end++ = __dc;
10141012 // Stage 3
1015 __v = __num_get_unsigned_integral<_Unsigned>(__a, __a_end, __err, __base);
1013 __v = std::__num_get_unsigned_integral<_Unsigned>(__a, __a_end, __err, __base);
10161014 // Digit grouping checked
10171015 __check_grouping(__grouping, __g, __g_end, __err);
10181016 // EOF checked
......@@ -1067,7 +1065,7 @@ num_get<_CharT, _InputIterator>::__do_get_floating_point(iter_type __b, iter_typ
10671065 if (__grouping.size() != 0 && __in_units && __g_end-__g < __num_get_base::__num_get_buf_sz)
10681066 *__g_end++ = __dc;
10691067 // Stage 3
1070 __v = __num_get_float<_Fp>(__a, __a_end, __err);
1068 __v = std::__num_get_float<_Fp>(__a, __a_end, __err);
10711069 // Digit grouping checked
10721070 __check_grouping(__grouping, __g, __g_end, __err);
10731071 // EOF checked
......@@ -1089,8 +1087,8 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
10891087 char_type __atoms[26];
10901088 char_type __thousands_sep = 0;
10911089 string __grouping;
1092 use_facet<ctype<_CharT> >(__iob.getloc()).widen(__num_get_base::__src,
1093 __num_get_base::__src + 26, __atoms);
1090 std::use_facet<ctype<_CharT> >(__iob.getloc()).widen(__num_get_base::__src,
1091 __num_get_base::__src + 26, __atoms);
10941092 string __buf;
10951093 __buf.resize(__buf.capacity());
10961094 char* __a = &__buf[0];
......@@ -1157,8 +1155,8 @@ __num_put<_CharT>::__widen_and_group_int(char* __nb, char* __np, char* __ne,
11571155 _CharT* __ob, _CharT*& __op, _CharT*& __oe,
11581156 const locale& __loc)
11591157{
1160 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> > (__loc);
1161 const numpunct<_CharT>& __npt = use_facet<numpunct<_CharT> >(__loc);
1158 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> > (__loc);
1159 const numpunct<_CharT>& __npt = std::use_facet<numpunct<_CharT> >(__loc);
11621160 string __grouping = __npt.grouping();
11631161 if (__grouping.empty())
11641162 {
......@@ -1177,7 +1175,7 @@ __num_put<_CharT>::__widen_and_group_int(char* __nb, char* __np, char* __ne,
11771175 *__oe++ = __ct.widen(*__nf++);
11781176 *__oe++ = __ct.widen(*__nf++);
11791177 }
1180 reverse(__nf, __ne);
1178 std::reverse(__nf, __ne);
11811179 _CharT __thousands_sep = __npt.thousands_sep();
11821180 unsigned __dc = 0;
11831181 unsigned __dg = 0;
......@@ -1194,7 +1192,7 @@ __num_put<_CharT>::__widen_and_group_int(char* __nb, char* __np, char* __ne,
11941192 *__oe++ = __ct.widen(*__p);
11951193 ++__dc;
11961194 }
1197 reverse(__ob + (__nf - __nb), __oe);
1195 std::reverse(__ob + (__nf - __nb), __oe);
11981196 }
11991197 if (__np == __ne)
12001198 __op = __oe;
......@@ -1208,8 +1206,8 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,
12081206 _CharT* __ob, _CharT*& __op, _CharT*& __oe,
12091207 const locale& __loc)
12101208{
1211 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> > (__loc);
1212 const numpunct<_CharT>& __npt = use_facet<numpunct<_CharT> >(__loc);
1209 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> > (__loc);
1210 const numpunct<_CharT>& __npt = std::use_facet<numpunct<_CharT> >(__loc);
12131211 string __grouping = __npt.grouping();
12141212 __oe = __ob;
12151213 char* __nf = __nb;
......@@ -1238,7 +1236,7 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,
12381236 }
12391237 else
12401238 {
1241 reverse(__nf, __ns);
1239 std::reverse(__nf, __ns);
12421240 _CharT __thousands_sep = __npt.thousands_sep();
12431241 unsigned __dc = 0;
12441242 unsigned __dg = 0;
......@@ -1254,7 +1252,7 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,
12541252 *__oe++ = __ct.widen(*__p);
12551253 ++__dc;
12561254 }
1257 reverse(__ob + (__nf - __nb), __oe);
1255 std::reverse(__ob + (__nf - __nb), __oe);
12581256 }
12591257 for (__nf = __ns; __nf < __ne; ++__nf)
12601258 {
......@@ -1352,8 +1350,7 @@ public:
13521350 static locale::id id;
13531351
13541352protected:
1355 _LIBCPP_INLINE_VISIBILITY
1356 ~num_put() {}
1353 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~num_put() override {}
13571354
13581355 virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl,
13591356 bool __v) const;
......@@ -1390,7 +1387,7 @@ locale::id
13901387num_put<_CharT, _OutputIterator>::id;
13911388
13921389template <class _CharT, class _OutputIterator>
1393_LIBCPP_HIDDEN
1390_LIBCPP_HIDE_FROM_ABI
13941391_OutputIterator
13951392__pad_and_output(_OutputIterator __s,
13961393 const _CharT* __ob, const _CharT* __op, const _CharT* __oe,
......@@ -1413,7 +1410,7 @@ __pad_and_output(_OutputIterator __s,
14131410}
14141411
14151412template <class _CharT, class _Traits>
1416_LIBCPP_HIDDEN
1413_LIBCPP_HIDE_FROM_ABI
14171414ostreambuf_iterator<_CharT, _Traits>
14181415__pad_and_output(ostreambuf_iterator<_CharT, _Traits> __s,
14191416 const _CharT* __ob, const _CharT* __op, const _CharT* __oe,
......@@ -1465,7 +1462,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
14651462{
14661463 if ((__iob.flags() & ios_base::boolalpha) == 0)
14671464 return do_put(__s, __iob, __fl, (unsigned long)__v);
1468 const numpunct<char_type>& __np = use_facet<numpunct<char_type> >(__iob.getloc());
1465 const numpunct<char_type>& __np = std::use_facet<numpunct<char_type> >(__iob.getloc());
14691466 typedef typename numpunct<char_type>::string_type string_type;
14701467#ifdef _LIBCPP_ENABLE_DEBUG_MODE
14711468 string_type __tmp(__v ? __np.truename() : __np.falsename());
......@@ -1511,7 +1508,7 @@ num_put<_CharT, _OutputIterator>::__do_put_integral(iter_type __s, ios_base& __i
15111508 this->__widen_and_group_int(__nar, __np, __ne, __o, __op, __oe, __iob.getloc());
15121509 // [__o, __oe) contains thousands_sep'd wide number
15131510 // Stage 3 & 4
1514 return __pad_and_output(__s, __o, __op, __oe, __iob, __fl);
1511 return std::__pad_and_output(__s, __o, __op, __oe, __iob, __fl);
15151512}
15161513
15171514template <class _CharT, class _OutputIterator>
......@@ -1599,7 +1596,7 @@ num_put<_CharT, _OutputIterator>::__do_put_floating_point(iter_type __s, ios_bas
15991596 this->__widen_and_group_float(__nb, __np, __ne, __ob, __op, __oe, __iob.getloc());
16001597 // [__o, __oe) contains thousands_sep'd wide number
16011598 // Stage 3 & 4
1602 __s = __pad_and_output(__s, __ob, __op, __oe, __iob, __fl);
1599 __s = std::__pad_and_output(__s, __ob, __op, __oe, __iob, __fl);
16031600 return __s;
16041601}
16051602
......@@ -1634,7 +1631,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
16341631 char_type __o[2*(__nbuf-1) - 1];
16351632 char_type* __op; // pad here
16361633 char_type* __oe; // end of output
1637 const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
1634 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
16381635 __ct.widen(__nar, __ne, __o);
16391636 __oe = __o + (__ne - __nar);
16401637 if (__np == __ne)
......@@ -1643,7 +1640,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
16431640 __op = __o + (__np - __nar);
16441641 // [__o, __oe) contains wide number
16451642 // Stage 3 & 4
1646 return __pad_and_output(__s, __o, __op, __oe, __iob, __fl);
1643 return std::__pad_and_output(__s, __o, __op, __oe, __iob, __fl);
16471644}
16481645
16491646extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>;
......@@ -1652,7 +1649,7 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>;
16521649#endif
16531650
16541651template <class _CharT, class _InputIterator>
1655_LIBCPP_HIDDEN
1652_LIBCPP_HIDE_FROM_ABI
16561653int
16571654__get_up_to_n_digits(_InputIterator& __b, _InputIterator __e,
16581655 ios_base::iostate& __err, const ctype<_CharT>& __ct, int __n)
......@@ -1798,8 +1795,7 @@ public:
17981795 static locale::id id;
17991796
18001797protected:
1801 _LIBCPP_INLINE_VISIBILITY
1802 ~time_get() {}
1798 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_get() override {}
18031799
18041800 virtual dateorder do_date_order() const;
18051801 virtual iter_type do_get_time(iter_type __b, iter_type __e, ios_base& __iob,
......@@ -1930,7 +1926,7 @@ time_get<_CharT, _InputIterator>::__get_month(int& __m,
19301926 ios_base::iostate& __err,
19311927 const ctype<char_type>& __ct) const
19321928{
1933 int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2) - 1;
1929 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2) - 1;
19341930 if (!(__err & ios_base::failbit) && 0 <= __t && __t <= 11)
19351931 __m = __t;
19361932 else
......@@ -1944,7 +1940,7 @@ time_get<_CharT, _InputIterator>::__get_year(int& __y,
19441940 ios_base::iostate& __err,
19451941 const ctype<char_type>& __ct) const
19461942{
1947 int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 4);
1943 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 4);
19481944 if (!(__err & ios_base::failbit))
19491945 {
19501946 if (__t < 69)
......@@ -1962,7 +1958,7 @@ time_get<_CharT, _InputIterator>::__get_year4(int& __y,
19621958 ios_base::iostate& __err,
19631959 const ctype<char_type>& __ct) const
19641960{
1965 int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 4);
1961 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 4);
19661962 if (!(__err & ios_base::failbit))
19671963 __y = __t - 1900;
19681964}
......@@ -1974,7 +1970,7 @@ time_get<_CharT, _InputIterator>::__get_hour(int& __h,
19741970 ios_base::iostate& __err,
19751971 const ctype<char_type>& __ct) const
19761972{
1977 int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2);
1973 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2);
19781974 if (!(__err & ios_base::failbit) && __t <= 23)
19791975 __h = __t;
19801976 else
......@@ -1988,7 +1984,7 @@ time_get<_CharT, _InputIterator>::__get_12_hour(int& __h,
19881984 ios_base::iostate& __err,
19891985 const ctype<char_type>& __ct) const
19901986{
1991 int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2);
1987 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2);
19921988 if (!(__err & ios_base::failbit) && 1 <= __t && __t <= 12)
19931989 __h = __t;
19941990 else
......@@ -2002,7 +1998,7 @@ time_get<_CharT, _InputIterator>::__get_minute(int& __m,
20021998 ios_base::iostate& __err,
20031999 const ctype<char_type>& __ct) const
20042000{
2005 int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2);
2001 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2);
20062002 if (!(__err & ios_base::failbit) && __t <= 59)
20072003 __m = __t;
20082004 else
......@@ -2016,7 +2012,7 @@ time_get<_CharT, _InputIterator>::__get_second(int& __s,
20162012 ios_base::iostate& __err,
20172013 const ctype<char_type>& __ct) const
20182014{
2019 int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2);
2015 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2);
20202016 if (!(__err & ios_base::failbit) && __t <= 60)
20212017 __s = __t;
20222018 else
......@@ -2030,7 +2026,7 @@ time_get<_CharT, _InputIterator>::__get_weekday(int& __w,
20302026 ios_base::iostate& __err,
20312027 const ctype<char_type>& __ct) const
20322028{
2033 int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 1);
2029 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 1);
20342030 if (!(__err & ios_base::failbit) && __t <= 6)
20352031 __w = __t;
20362032 else
......@@ -2044,7 +2040,7 @@ time_get<_CharT, _InputIterator>::__get_day_year_num(int& __d,
20442040 ios_base::iostate& __err,
20452041 const ctype<char_type>& __ct) const
20462042{
2047 int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 3);
2043 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 3);
20482044 if (!(__err & ios_base::failbit) && __t <= 365)
20492045 __d = __t;
20502046 else
......@@ -2109,7 +2105,7 @@ time_get<_CharT, _InputIterator>::get(iter_type __b, iter_type __e,
21092105 ios_base::iostate& __err, tm* __tm,
21102106 const char_type* __fmtb, const char_type* __fmte) const
21112107{
2112 const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
2108 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
21132109 __err = ios_base::goodbit;
21142110 while (__fmtb != __fmte && __err == ios_base::goodbit)
21152111 {
......@@ -2196,7 +2192,7 @@ time_get<_CharT, _InputIterator>::do_get_weekday(iter_type __b, iter_type __e,
21962192 ios_base::iostate& __err,
21972193 tm* __tm) const
21982194{
2199 const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
2195 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
22002196 __get_weekdayname(__tm->tm_wday, __b, __e, __err, __ct);
22012197 return __b;
22022198}
......@@ -2208,7 +2204,7 @@ time_get<_CharT, _InputIterator>::do_get_monthname(iter_type __b, iter_type __e,
22082204 ios_base::iostate& __err,
22092205 tm* __tm) const
22102206{
2211 const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
2207 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
22122208 __get_monthname(__tm->tm_mon, __b, __e, __err, __ct);
22132209 return __b;
22142210}
......@@ -2220,7 +2216,7 @@ time_get<_CharT, _InputIterator>::do_get_year(iter_type __b, iter_type __e,
22202216 ios_base::iostate& __err,
22212217 tm* __tm) const
22222218{
2223 const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
2219 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
22242220 __get_year(__tm->tm_year, __b, __e, __err, __ct);
22252221 return __b;
22262222}
......@@ -2233,7 +2229,7 @@ time_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
22332229 char __fmt, char) const
22342230{
22352231 __err = ios_base::goodbit;
2236 const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
2232 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
22372233 switch (__fmt)
22382234 {
22392235 case 'a':
......@@ -2392,7 +2388,9 @@ extern template _LIBCPP_FUNC_VIS __time_get_storage<_CharT>::string_type __time_
23922388/**/
23932389
23942390_LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(char)
2391#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
23952392_LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(wchar_t)
2393#endif
23962394#undef _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION
23972395
23982396template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
......@@ -2416,26 +2414,17 @@ public:
24162414 __time_get_storage<_CharT>(__nm) {}
24172415
24182416protected:
2419 _LIBCPP_INLINE_VISIBILITY
2420 ~time_get_byname() {}
2417 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_get_byname() override {}
24212418
2422 _LIBCPP_INLINE_VISIBILITY
2423 virtual dateorder do_date_order() const {return this->__do_date_order();}
2419 _LIBCPP_HIDE_FROM_ABI_VIRTUAL dateorder do_date_order() const override {return this->__do_date_order();}
24242420private:
2425 _LIBCPP_INLINE_VISIBILITY
2426 virtual const string_type* __weeks() const {return this->__weeks_;}
2427 _LIBCPP_INLINE_VISIBILITY
2428 virtual const string_type* __months() const {return this->__months_;}
2429 _LIBCPP_INLINE_VISIBILITY
2430 virtual const string_type* __am_pm() const {return this->__am_pm_;}
2431 _LIBCPP_INLINE_VISIBILITY
2432 virtual const string_type& __c() const {return this->__c_;}
2433 _LIBCPP_INLINE_VISIBILITY
2434 virtual const string_type& __r() const {return this->__r_;}
2435 _LIBCPP_INLINE_VISIBILITY
2436 virtual const string_type& __x() const {return this->__x_;}
2437 _LIBCPP_INLINE_VISIBILITY
2438 virtual const string_type& __X() const {return this->__X_;}
2421 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type* __weeks() const override {return this->__weeks_;}
2422 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type* __months() const override {return this->__months_;}
2423 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type* __am_pm() const override {return this->__am_pm_;}
2424 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __c() const override {return this->__c_;}
2425 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __r() const override {return this->__r_;}
2426 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __x() const override {return this->__x_;}
2427 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __X() const override {return this->__X_;}
24392428};
24402429
24412430extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>;
......@@ -2453,8 +2442,10 @@ protected:
24532442 ~__time_put();
24542443 void __do_put(char* __nb, char*& __ne, const tm* __tm,
24552444 char __fmt, char __mod) const;
2445#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
24562446 void __do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm,
24572447 char __fmt, char __mod) const;
2448#endif
24582449};
24592450
24602451template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
......@@ -2483,8 +2474,7 @@ public:
24832474 static locale::id id;
24842475
24852476protected:
2486 _LIBCPP_INLINE_VISIBILITY
2487 ~time_put() {}
2477 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_put() override {}
24882478 virtual iter_type do_put(iter_type __s, ios_base&, char_type, const tm* __tm,
24892479 char __fmt, char __mod) const;
24902480
......@@ -2509,7 +2499,7 @@ time_put<_CharT, _OutputIterator>::put(iter_type __s, ios_base& __iob,
25092499 const char_type* __pb,
25102500 const char_type* __pe) const
25112501{
2512 const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
2502 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
25132503 for (; __pb != __pe; ++__pb)
25142504 {
25152505 if (__ct.narrow(*__pb, 0) == '%')
......@@ -2572,8 +2562,7 @@ public:
25722562 : time_put<_CharT, _OutputIterator>(__nm, __refs) {}
25732563
25742564protected:
2575 _LIBCPP_INLINE_VISIBILITY
2576 ~time_put_byname() {}
2565 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_put_byname() override {}
25772566};
25782567
25792568extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>;
......@@ -2621,8 +2610,7 @@ public:
26212610 static const bool intl = _International;
26222611
26232612protected:
2624 _LIBCPP_INLINE_VISIBILITY
2625 ~moneypunct() {}
2613 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~moneypunct() override {}
26262614
26272615 virtual char_type do_decimal_point() const {return numeric_limits<char_type>::max();}
26282616 virtual char_type do_thousands_sep() const {return numeric_limits<char_type>::max();}
......@@ -2672,18 +2660,17 @@ public:
26722660 : moneypunct<_CharT, _International>(__refs) {init(__nm.c_str());}
26732661
26742662protected:
2675 _LIBCPP_INLINE_VISIBILITY
2676 ~moneypunct_byname() {}
2677
2678 virtual char_type do_decimal_point() const {return __decimal_point_;}
2679 virtual char_type do_thousands_sep() const {return __thousands_sep_;}
2680 virtual string do_grouping() const {return __grouping_;}
2681 virtual string_type do_curr_symbol() const {return __curr_symbol_;}
2682 virtual string_type do_positive_sign() const {return __positive_sign_;}
2683 virtual string_type do_negative_sign() const {return __negative_sign_;}
2684 virtual int do_frac_digits() const {return __frac_digits_;}
2685 virtual pattern do_pos_format() const {return __pos_format_;}
2686 virtual pattern do_neg_format() const {return __neg_format_;}
2663 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~moneypunct_byname() override {}
2664
2665 char_type do_decimal_point() const override {return __decimal_point_;}
2666 char_type do_thousands_sep() const override {return __thousands_sep_;}
2667 string do_grouping() const override {return __grouping_;}
2668 string_type do_curr_symbol() const override {return __curr_symbol_;}
2669 string_type do_positive_sign() const override {return __positive_sign_;}
2670 string_type do_negative_sign() const override {return __negative_sign_;}
2671 int do_frac_digits() const override {return __frac_digits_;}
2672 pattern do_pos_format() const override {return __pos_format_;}
2673 pattern do_neg_format() const override {return __neg_format_;}
26872674
26882675private:
26892676 char_type __decimal_point_;
......@@ -2740,7 +2727,7 @@ __money_get<_CharT>::__gather_info(bool __intl, const locale& __loc,
27402727 if (__intl)
27412728 {
27422729 const moneypunct<char_type, true>& __mp =
2743 use_facet<moneypunct<char_type, true> >(__loc);
2730 std::use_facet<moneypunct<char_type, true> >(__loc);
27442731 __pat = __mp.neg_format();
27452732 __nsn = __mp.negative_sign();
27462733 __psn = __mp.positive_sign();
......@@ -2753,7 +2740,7 @@ __money_get<_CharT>::__gather_info(bool __intl, const locale& __loc,
27532740 else
27542741 {
27552742 const moneypunct<char_type, false>& __mp =
2756 use_facet<moneypunct<char_type, false> >(__loc);
2743 std::use_facet<moneypunct<char_type, false> >(__loc);
27572744 __pat = __mp.neg_format();
27582745 __nsn = __mp.negative_sign();
27592746 __psn = __mp.positive_sign();
......@@ -2801,9 +2788,7 @@ public:
28012788 static locale::id id;
28022789
28032790protected:
2804
2805 _LIBCPP_INLINE_VISIBILITY
2806 ~money_get() {}
2791 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~money_get() override {}
28072792
28082793 virtual iter_type do_get(iter_type __b, iter_type __e, bool __intl,
28092794 ios_base& __iob, ios_base::iostate& __err,
......@@ -2828,7 +2813,7 @@ money_get<_CharT, _InputIterator>::id;
28282813_LIBCPP_FUNC_VIS void __do_nothing(void*);
28292814
28302815template <class _Tp>
2831_LIBCPP_HIDDEN
2816_LIBCPP_HIDE_FROM_ABI
28322817void
28332818__double_or_nothing(unique_ptr<_Tp, void(*)(void*)>& __b, _Tp*& __n, _Tp*& __e)
28342819{
......@@ -2839,7 +2824,7 @@ __double_or_nothing(unique_ptr<_Tp, void(*)(void*)>& __b, _Tp*& __n, _Tp*& __e)
28392824 if (__new_cap == 0)
28402825 __new_cap = sizeof(_Tp);
28412826 size_t __n_off = static_cast<size_t>(__n - __b.get());
2842 _Tp* __t = (_Tp*)realloc(__owns ? __b.get() : 0, __new_cap);
2827 _Tp* __t = (_Tp*)std::realloc(__owns ? __b.get() : 0, __new_cap);
28432828 if (__t == 0)
28442829 __throw_bad_alloc();
28452830 if (__owns)
......@@ -2954,7 +2939,7 @@ money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e,
29542939 ++__sym_space_end;
29552940 const size_t __num_spaces = __sym_space_end - __sym.begin();
29562941 if (__num_spaces > __spaces.size() ||
2957 !equal(__spaces.end() - __num_spaces, __spaces.end(),
2942 !std::equal(__spaces.end() - __num_spaces, __spaces.end(),
29582943 __sym.begin())) {
29592944 // No match. Put __sym_space_end back at the
29602945 // beginning of __sym, which will prevent a
......@@ -2985,14 +2970,14 @@ money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e,
29852970 if (__ct.is(ctype_base::digit, __c))
29862971 {
29872972 if (__wn == __we)
2988 __double_or_nothing(__wb, __wn, __we);
2973 std::__double_or_nothing(__wb, __wn, __we);
29892974 *__wn++ = __c;
29902975 ++__ng;
29912976 }
29922977 else if (__grp.size() > 0 && __ng > 0 && __c == __ts)
29932978 {
29942979 if (__gn == __ge)
2995 __double_or_nothing(__gb, __gn, __ge);
2980 std::__double_or_nothing(__gb, __gn, __ge);
29962981 *__gn++ = __ng;
29972982 __ng = 0;
29982983 }
......@@ -3002,7 +2987,7 @@ money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e,
30022987 if (__gb.get() != __gn && __ng > 0)
30032988 {
30042989 if (__gn == __ge)
3005 __double_or_nothing(__gb, __gn, __ge);
2990 std::__double_or_nothing(__gb, __gn, __ge);
30062991 *__gn++ = __ng;
30072992 }
30082993 if (__fd > 0)
......@@ -3020,7 +3005,7 @@ money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e,
30203005 return false;
30213006 }
30223007 if (__wn == __we)
3023 __double_or_nothing(__wb, __wn, __we);
3008 std::__double_or_nothing(__wb, __wn, __we);
30243009 *__wn++ = *__b;
30253010 }
30263011 }
......@@ -3070,7 +3055,7 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
30703055 char_type* __wn;
30713056 char_type* __we = __wbuf + __bz;
30723057 locale __loc = __iob.getloc();
3073 const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__loc);
3058 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc);
30743059 bool __neg = false;
30753060 if (__do_get(__b, __e, __intl, __loc, __iob.flags(), __err, __neg, __ct,
30763061 __wb, __wn, __we))
......@@ -3091,7 +3076,7 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
30913076 if (__neg)
30923077 *__nc++ = '-';
30933078 for (const char_type* __w = __wb.get(); __w < __wn; ++__w, ++__nc)
3094 *__nc = __src[find(__atoms, _VSTD::end(__atoms), *__w) - __atoms];
3079 *__nc = __src[std::find(__atoms, _VSTD::end(__atoms), *__w) - __atoms];
30953080 *__nc = char();
30963081 if (sscanf(__nbuf, "%Lf", &__v) != 1)
30973082 __throw_runtime_error("money_get error");
......@@ -3114,7 +3099,7 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
31143099 char_type* __wn;
31153100 char_type* __we = __wbuf + __bz;
31163101 locale __loc = __iob.getloc();
3117 const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__loc);
3102 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc);
31183103 bool __neg = false;
31193104 if (__do_get(__b, __e, __intl, __loc, __iob.flags(), __err, __neg, __ct,
31203105 __wb, __wn, __we))
......@@ -3176,7 +3161,7 @@ __money_put<_CharT>::__gather_info(bool __intl, bool __neg, const locale& __loc,
31763161 if (__intl)
31773162 {
31783163 const moneypunct<char_type, true>& __mp =
3179 use_facet<moneypunct<char_type, true> >(__loc);
3164 std::use_facet<moneypunct<char_type, true> >(__loc);
31803165 if (__neg)
31813166 {
31823167 __pat = __mp.neg_format();
......@@ -3196,7 +3181,7 @@ __money_put<_CharT>::__gather_info(bool __intl, bool __neg, const locale& __loc,
31963181 else
31973182 {
31983183 const moneypunct<char_type, false>& __mp =
3199 use_facet<moneypunct<char_type, false> >(__loc);
3184 std::use_facet<moneypunct<char_type, false> >(__loc);
32003185 if (__neg)
32013186 {
32023187 __pat = __mp.neg_format();
......@@ -3296,7 +3281,7 @@ __money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __m
32963281 }
32973282 }
32983283 // reverse it
3299 reverse(__t, __me);
3284 std::reverse(__t, __me);
33003285 }
33013286 break;
33023287 }
......@@ -3347,8 +3332,7 @@ public:
33473332 static locale::id id;
33483333
33493334protected:
3350 _LIBCPP_INLINE_VISIBILITY
3351 ~money_put() {}
3335 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~money_put() override {}
33523336
33533337 virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __iob,
33543338 char_type __fl, long double __units) const;
......@@ -3389,7 +3373,7 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
33893373 }
33903374 // gather info
33913375 locale __loc = __iob.getloc();
3392 const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__loc);
3376 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc);
33933377 __ct.widen(__bb, __bb + __n, __db);
33943378 bool __neg = __n > 0 && __bb[0] == '-';
33953379 money_base::pattern __pat;
......@@ -3421,7 +3405,7 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
34213405 this->__format(__mb, __mi, __me, __iob.flags(),
34223406 __db, __db + __n, __ct,
34233407 __neg, __pat, __dp, __ts, __grp, __sym, __sn, __fd);
3424 return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl);
3408 return std::__pad_and_output(__s, __mb, __mi, __me, __iob, __fl);
34253409}
34263410
34273411template <class _CharT, class _OutputIterator>
......@@ -3432,7 +3416,7 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
34323416{
34333417 // gather info
34343418 locale __loc = __iob.getloc();
3435 const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__loc);
3419 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc);
34363420 bool __neg = __digits.size() > 0 && __digits[0] == __ct.widen('-');
34373421 money_base::pattern __pat;
34383422 char_type __dp;
......@@ -3463,7 +3447,7 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
34633447 this->__format(__mb, __mi, __me, __iob.flags(),
34643448 __digits.data(), __digits.data() + __digits.size(), __ct,
34653449 __neg, __pat, __dp, __ts, __grp, __sym, __sn, __fd);
3466 return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl);
3450 return std::__pad_and_output(__s, __mb, __mi, __me, __iob, __fl);
34673451}
34683452
34693453extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>;
......@@ -3516,8 +3500,7 @@ public:
35163500 static locale::id id;
35173501
35183502protected:
3519 _LIBCPP_INLINE_VISIBILITY
3520 ~messages() {}
3503 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~messages() override {}
35213504
35223505 virtual catalog do_open(const basic_string<char>&, const locale&) const;
35233506 virtual string_type do_get(catalog, int __set, int __msgid,
......@@ -3551,7 +3534,7 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid,
35513534{
35523535#ifdef _LIBCPP_HAS_CATOPEN
35533536 string __ndflt;
3554 __narrow_to_utf8<sizeof(char_type)*__CHAR_BIT__>()(back_inserter(__ndflt),
3537 __narrow_to_utf8<sizeof(char_type)*__CHAR_BIT__>()(std::back_inserter(__ndflt),
35553538 __dflt.c_str(),
35563539 __dflt.c_str() + __dflt.size());
35573540 if (__c != -1)
......@@ -3559,7 +3542,7 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid,
35593542 nl_catd __cat = (nl_catd)__c;
35603543 char* __n = catgets(__cat, __set, __msgid, __ndflt.c_str());
35613544 string_type __w;
3562 __widen_from_utf8<sizeof(char_type)*__CHAR_BIT__>()(back_inserter(__w),
3545 __widen_from_utf8<sizeof(char_type)*__CHAR_BIT__>()(std::back_inserter(__w),
35633546 __n, __n + _VSTD::strlen(__n));
35643547 return __w;
35653548#else // !_LIBCPP_HAS_CATOPEN
......@@ -3606,8 +3589,7 @@ public:
36063589 : messages<_CharT>(__refs) {}
36073590
36083591protected:
3609 _LIBCPP_INLINE_VISIBILITY
3610 ~messages_byname() {}
3592 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~messages_byname() override {}
36113593};
36123594
36133595extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>;
......@@ -4007,7 +3989,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
40073989 char_type __1buf;
40083990 if (this->gptr() == 0)
40093991 this->setg(&__1buf, &__1buf+1, &__1buf+1);
4010 const size_t __unget_sz = __initial ? 0 : min<size_t>((this->egptr() - this->eback()) / 2, 4);
3992 const size_t __unget_sz = __initial ? 0 : std::min<size_t>((this->egptr() - this->eback()) / 2, 4);
40113993 int_type __c = traits_type::eof();
40123994 if (this->gptr() == this->egptr())
40133995 {
......@@ -4026,9 +4008,11 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
40264008 }
40274009 else
40284010 {
4029 _LIBCPP_ASSERT(!(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" );
4030 if (__extbufend_ != __extbufnext_)
4011 if (__extbufend_ != __extbufnext_) {
4012 _LIBCPP_ASSERT(__extbufnext_ != nullptr, "underflow moving from nullptr");
4013 _LIBCPP_ASSERT(__extbuf_ != nullptr, "underflow moving into nullptr");
40314014 _VSTD::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
4015 }
40324016 __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
40334017 __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);
40344018 streamsize __nmemb = _VSTD::min(static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz),
......@@ -4276,7 +4260,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
42764260 {
42774261 if (this->gptr() != this->egptr())
42784262 {
4279 reverse(this->gptr(), this->egptr());
4263 std::reverse(this->gptr(), this->egptr());
42804264 codecvt_base::result __r;
42814265 const char_type* __e = this->gptr();
42824266 char* __extbe;
......@@ -4369,4 +4353,16 @@ _LIBCPP_END_NAMESPACE_STD
43694353
43704354_LIBCPP_POP_MACROS
43714355
4356// NOLINTEND(libcpp-robust-against-adl)
4357
4358#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
4359# include <atomic>
4360# include <concepts>
4361# include <cstdarg>
4362# include <iterator>
4363# include <stdexcept>
4364# include <type_traits>
4365# include <typeinfo>
4366#endif
4367
43724368#endif // _LIBCPP_LOCALE
lib/libcxx/include/locale.h+3-1
......@@ -43,6 +43,8 @@ Functions:
4343# pragma GCC system_header
4444#endif
4545
46#include_next <locale.h>
46#if __has_include_next(<locale.h>)
47# include_next <locale.h>
48#endif
4749
4850#endif // _LIBCPP_LOCALE_H
lib/libcxx/include/map+52-29
......@@ -538,20 +538,18 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
538538#include <__iterator/erase_if_container.h>
539539#include <__iterator/iterator_traits.h>
540540#include <__iterator/reverse_iterator.h>
541#include <__memory/allocator.h>
542#include <__memory_resource/polymorphic_allocator.h>
541543#include <__node_handle>
542544#include <__tree>
545#include <__type_traits/is_allocator.h>
543546#include <__utility/forward.h>
547#include <__utility/piecewise_construct.h>
544548#include <__utility/swap.h>
545#include <memory>
549#include <tuple>
546550#include <type_traits>
547551#include <version>
548552
549#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
550# include <functional>
551# include <iterator>
552# include <utility>
553#endif
554
555553// standard-mandated includes
556554
557555// [iterator.range]
......@@ -619,46 +617,46 @@ public:
619617template <class _Key, class _CP, class _Compare>
620618class __map_value_compare<_Key, _CP, _Compare, false>
621619{
622 _Compare comp;
620 _Compare __comp_;
623621
624622public:
625623 _LIBCPP_INLINE_VISIBILITY
626624 __map_value_compare()
627625 _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)
628 : comp() {}
626 : __comp_() {}
629627 _LIBCPP_INLINE_VISIBILITY
630628 __map_value_compare(_Compare __c)
631629 _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)
632 : comp(__c) {}
630 : __comp_(__c) {}
633631 _LIBCPP_INLINE_VISIBILITY
634 const _Compare& key_comp() const _NOEXCEPT {return comp;}
632 const _Compare& key_comp() const _NOEXCEPT {return __comp_;}
635633
636634 _LIBCPP_INLINE_VISIBILITY
637635 bool operator()(const _CP& __x, const _CP& __y) const
638 {return comp(__x.__get_value().first, __y.__get_value().first);}
636 {return __comp_(__x.__get_value().first, __y.__get_value().first);}
639637 _LIBCPP_INLINE_VISIBILITY
640638 bool operator()(const _CP& __x, const _Key& __y) const
641 {return comp(__x.__get_value().first, __y);}
639 {return __comp_(__x.__get_value().first, __y);}
642640 _LIBCPP_INLINE_VISIBILITY
643641 bool operator()(const _Key& __x, const _CP& __y) const
644 {return comp(__x, __y.__get_value().first);}
642 {return __comp_(__x, __y.__get_value().first);}
645643 void swap(__map_value_compare& __y)
646644 _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value)
647645 {
648646 using _VSTD::swap;
649 swap(comp, __y.comp);
647 swap(__comp_, __y.__comp_);
650648 }
651649
652650#if _LIBCPP_STD_VER > 11
653651 template <typename _K2>
654652 _LIBCPP_INLINE_VISIBILITY
655653 bool operator()(const _K2& __x, const _CP& __y) const
656 {return comp(__x, __y.__get_value().first);}
654 {return __comp_(__x, __y.__get_value().first);}
657655
658656 template <typename _K2>
659657 _LIBCPP_INLINE_VISIBILITY
660658 bool operator()(const _CP& __x, const _K2& __y) const
661 {return comp(__x.__get_value().first, __y);}
659 {return __comp_(__x.__get_value().first, __y);}
662660#endif
663661};
664662
......@@ -738,16 +736,16 @@ struct _LIBCPP_STANDALONE_DEBUG __value_type
738736 typedef pair<key_type&&, mapped_type&&> __nc_rref_pair_type;
739737
740738private:
741 value_type __cc;
739 value_type __cc_;
742740
743741public:
744742 _LIBCPP_INLINE_VISIBILITY
745743 value_type& __get_value()
746744 {
747745#if _LIBCPP_STD_VER > 14
748 return *_VSTD::launder(_VSTD::addressof(__cc));
746 return *_VSTD::launder(_VSTD::addressof(__cc_));
749747#else
750 return __cc;
748 return __cc_;
751749#endif
752750 }
753751
......@@ -755,9 +753,9 @@ public:
755753 const value_type& __get_value() const
756754 {
757755#if _LIBCPP_STD_VER > 14
758 return *_VSTD::launder(_VSTD::addressof(__cc));
756 return *_VSTD::launder(_VSTD::addressof(__cc_));
759757#else
760 return __cc;
758 return __cc_;
761759#endif
762760 }
763761
......@@ -818,13 +816,13 @@ struct __value_type
818816 typedef pair<const key_type, mapped_type> value_type;
819817
820818private:
821 value_type __cc;
819 value_type __cc_;
822820
823821public:
824822 _LIBCPP_INLINE_VISIBILITY
825 value_type& __get_value() { return __cc; }
823 value_type& __get_value() { return __cc_; }
826824 _LIBCPP_INLINE_VISIBILITY
827 const value_type& __get_value() const { return __cc; }
825 const value_type& __get_value() const { return __cc_; }
828826
829827private:
830828 __value_type();
......@@ -1001,12 +999,15 @@ private:
1001999
10021000 typedef _VSTD::__value_type<key_type, mapped_type> __value_type;
10031001 typedef __map_value_compare<key_type, __value_type, key_compare> __vc;
1004 typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
1005 __value_type>::type __allocator_type;
1002 typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type;
10061003 typedef __tree<__value_type, __vc, __allocator_type> __base;
10071004 typedef typename __base::__node_traits __node_traits;
10081005 typedef allocator_traits<allocator_type> __alloc_traits;
10091006
1007 static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
1008 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
1009 "original allocator");
1010
10101011 __base __tree_;
10111012
10121013public:
......@@ -1778,12 +1779,15 @@ private:
17781779
17791780 typedef _VSTD::__value_type<key_type, mapped_type> __value_type;
17801781 typedef __map_value_compare<key_type, __value_type, key_compare> __vc;
1781 typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
1782 __value_type>::type __allocator_type;
1782 typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type;
17831783 typedef __tree<__value_type, __vc, __allocator_type> __base;
17841784 typedef typename __base::__node_traits __node_traits;
17851785 typedef allocator_traits<allocator_type> __alloc_traits;
17861786
1787 static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
1788 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
1789 "original allocator");
1790
17871791 __base __tree_;
17881792
17891793public:
......@@ -2335,4 +2339,23 @@ inline _LIBCPP_INLINE_VISIBILITY
23352339
23362340_LIBCPP_END_NAMESPACE_STD
23372341
2342#if _LIBCPP_STD_VER > 14
2343_LIBCPP_BEGIN_NAMESPACE_STD
2344namespace pmr {
2345template <class _KeyT, class _ValueT, class _CompareT = std::less<_KeyT>>
2346using map = std::map<_KeyT, _ValueT, _CompareT, polymorphic_allocator<std::pair<const _KeyT, _ValueT>>>;
2347
2348template <class _KeyT, class _ValueT, class _CompareT = std::less<_KeyT>>
2349using multimap = std::multimap<_KeyT, _ValueT, _CompareT, polymorphic_allocator<std::pair<const _KeyT, _ValueT>>>;
2350} // namespace pmr
2351_LIBCPP_END_NAMESPACE_STD
2352#endif
2353
2354#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
2355# include <concepts>
2356# include <functional>
2357# include <iterator>
2358# include <utility>
2359#endif
2360
23382361#endif // _LIBCPP_MAP
lib/libcxx/include/math.h+747-801
......@@ -297,7 +297,9 @@ long double truncl(long double x);
297297# pragma GCC system_header
298298#endif
299299
300#include_next <math.h>
300# if __has_include_next(<math.h>)
301# include_next <math.h>
302# endif
301303
302304#ifdef __cplusplus
303305
......@@ -305,479 +307,237 @@ long double truncl(long double x);
305307// back to C++ linkage before including these C++ headers.
306308extern "C++" {
307309
310#include <__type_traits/enable_if.h>
311#include <__type_traits/is_floating_point.h>
312#include <__type_traits/is_integral.h>
313#include <__type_traits/is_same.h>
308314#include <__type_traits/promote.h>
309315#include <limits>
310316#include <stdlib.h>
311#include <type_traits>
312317
313// signbit
314318
315#ifdef signbit
319# ifdef fpclassify
320# undef fpclassify
321# endif
316322
317template <class _A1>
318_LIBCPP_INLINE_VISIBILITY
319bool
320__libcpp_signbit(_A1 __lcpp_x) _NOEXCEPT
321{
322#if __has_builtin(__builtin_signbit)
323 return __builtin_signbit(__lcpp_x);
324#else
325 return signbit(__lcpp_x);
326#endif
327}
323# ifdef signbit
324# undef signbit
325# endif
328326
329#undef signbit
327# ifdef isfinite
328# undef isfinite
329# endif
330330
331template <class _A1>
332inline _LIBCPP_INLINE_VISIBILITY
333typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
334signbit(_A1 __lcpp_x) _NOEXCEPT
335{
336 return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x);
337}
331# ifdef isinf
332# undef isinf
333# endif
338334
339template <class _A1>
340inline _LIBCPP_INLINE_VISIBILITY
341typename std::enable_if<
342 std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
343signbit(_A1 __lcpp_x) _NOEXCEPT
344{ return __lcpp_x < 0; }
335# ifdef isnan
336# undef isnan
337# endif
345338
346template <class _A1>
347inline _LIBCPP_INLINE_VISIBILITY
348typename std::enable_if<
349 std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type
350signbit(_A1) _NOEXCEPT
351{ return false; }
352
353#elif defined(_LIBCPP_MSVCRT)
354
355template <typename _A1>
356inline _LIBCPP_INLINE_VISIBILITY
357typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
358signbit(_A1 __lcpp_x) _NOEXCEPT
359{
360 return ::signbit(static_cast<typename std::__promote<_A1>::type>(__lcpp_x));
361}
339# ifdef isnormal
340# undef isnormal
341# endif
362342
363template <class _A1>
364inline _LIBCPP_INLINE_VISIBILITY
365typename std::enable_if<
366 std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
367signbit(_A1 __lcpp_x) _NOEXCEPT
368{ return __lcpp_x < 0; }
343# ifdef isgreater
344# undef isgreater
345# endif
369346
370template <class _A1>
371inline _LIBCPP_INLINE_VISIBILITY
372typename std::enable_if<
373 std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type
374signbit(_A1) _NOEXCEPT
375{ return false; }
347# ifdef isgreaterequal
348# undef isgreaterequal
349# endif
350
351# ifdef isless
352# undef isless
353# endif
376354
377#endif // signbit
355# ifdef islessequal
356# undef islessequal
357# endif
378358
379// fpclassify
359# ifdef islessgreater
360# undef islessgreater
361# endif
380362
381#ifdef fpclassify
363# ifdef isunordered
364# undef isunordered
365# endif
382366
383template <class _A1>
384_LIBCPP_INLINE_VISIBILITY
385int
386__libcpp_fpclassify(_A1 __lcpp_x) _NOEXCEPT
387{
388#if __has_builtin(__builtin_fpclassify)
389 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
390 FP_ZERO, __lcpp_x);
391#else
392 return fpclassify(__lcpp_x);
393#endif
394}
367// signbit
395368
396#undef fpclassify
369template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
370_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
371 return __builtin_signbit(__x);
372}
397373
398template <class _A1>
399inline _LIBCPP_INLINE_VISIBILITY
400typename std::enable_if<std::is_floating_point<_A1>::value, int>::type
401fpclassify(_A1 __lcpp_x) _NOEXCEPT
402{
403 return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x);
374template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value && std::is_signed<_A1>::value, int> = 0>
375_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
376 return __x < 0;
404377}
405378
406template <class _A1>
407inline _LIBCPP_INLINE_VISIBILITY
408typename std::enable_if<std::is_integral<_A1>::value, int>::type
409fpclassify(_A1 __lcpp_x) _NOEXCEPT
410{ return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; }
379template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value && !std::is_signed<_A1>::value, int> = 0>
380_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT {
381 return false;
382}
411383
412#elif defined(_LIBCPP_MSVCRT)
384// fpclassify
413385
414template <typename _A1>
415inline _LIBCPP_INLINE_VISIBILITY
416typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
417fpclassify(_A1 __lcpp_x) _NOEXCEPT
418{
419 return ::fpclassify(static_cast<typename std::__promote<_A1>::type>(__lcpp_x));
386template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
387_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {
388 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
420389}
421390
422template <class _A1>
423inline _LIBCPP_INLINE_VISIBILITY
424typename std::enable_if<std::is_integral<_A1>::value, int>::type
425fpclassify(_A1 __lcpp_x) _NOEXCEPT
426{ return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; }
391template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
392_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {
393 return __x == 0 ? FP_ZERO : FP_NORMAL;
394}
427395
428#endif // fpclassify
396// The MSVC runtime already provides these functions as templates
397#ifndef _LIBCPP_MSVCRT
429398
430399// isfinite
431400
432#ifdef isfinite
433
434template <class _A1>
435_LIBCPP_INLINE_VISIBILITY
436bool
437__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
438{
439#if __has_builtin(__builtin_isfinite)
440 return __builtin_isfinite(__lcpp_x);
441#else
442 return isfinite(__lcpp_x);
443#endif
401template <class _A1,
402 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0>
403_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1 __x) _NOEXCEPT {
404 return __builtin_isfinite((typename std::__promote<_A1>::type)__x);
444405}
445406
446#undef isfinite
447
448template <class _A1>
449inline _LIBCPP_INLINE_VISIBILITY
450typename std::enable_if<
451 std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity,
452 bool>::type
453isfinite(_A1 __lcpp_x) _NOEXCEPT
454{
455 return __libcpp_isfinite((typename std::__promote<_A1>::type)__lcpp_x);
407template <class _A1,
408 std::__enable_if_t<std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, int> = 0>
409_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT {
410 return true;
456411}
457412
458template <class _A1>
459inline _LIBCPP_INLINE_VISIBILITY
460typename std::enable_if<
461 std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity,
462 bool>::type
463isfinite(_A1) _NOEXCEPT
464{ return true; }
465
466#endif // isfinite
467
468413// isinf
469414
470#ifdef isinf
415template <class _A1,
416 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0>
417_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1 __x) _NOEXCEPT {
418 return __builtin_isinf((typename std::__promote<_A1>::type)__x);
419}
471420
472421template <class _A1>
473_LIBCPP_INLINE_VISIBILITY
474bool
475__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
476{
477#if __has_builtin(__builtin_isinf)
478 return __builtin_isinf(__lcpp_x);
479#else
480 return isinf(__lcpp_x);
481#endif
422_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI
423 typename std::enable_if< std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, bool>::type
424 isinf(_A1) _NOEXCEPT {
425 return false;
482426}
483427
484#undef isinf
485
486template <class _A1>
487inline _LIBCPP_INLINE_VISIBILITY
488typename std::enable_if<
489 std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity,
490 bool>::type
491isinf(_A1 __lcpp_x) _NOEXCEPT
492{
493 return __libcpp_isinf((typename std::__promote<_A1>::type)__lcpp_x);
428# ifdef _LIBCPP_PREFERRED_OVERLOAD
429_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT {
430 return __builtin_isinf(__x);
494431}
495432
496template <class _A1>
497inline _LIBCPP_INLINE_VISIBILITY
498typename std::enable_if<
499 std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity,
500 bool>::type
501isinf(_A1) _NOEXCEPT
502{ return false; }
503
504#ifdef _LIBCPP_PREFERRED_OVERLOAD
505inline _LIBCPP_INLINE_VISIBILITY
506bool
507isinf(float __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); }
508
509inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
510bool
511isinf(double __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); }
512
513inline _LIBCPP_INLINE_VISIBILITY
514bool
515isinf(long double __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); }
516#endif
433_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isinf(double __x) _NOEXCEPT {
434 return __builtin_isinf(__x);
435}
517436
518#endif // isinf
437_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT {
438 return __builtin_isinf(__x);
439}
440# endif
519441
520442// isnan
521443
522#ifdef isnan
523
524template <class _A1>
525_LIBCPP_INLINE_VISIBILITY
526bool
527__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
528{
529#if __has_builtin(__builtin_isnan)
530 return __builtin_isnan(__lcpp_x);
531#else
532 return isnan(__lcpp_x);
533#endif
444template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
445_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT {
446 return __builtin_isnan(__x);
534447}
535448
536#undef isnan
449template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
450_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT {
451 return false;
452}
537453
538template <class _A1>
539inline _LIBCPP_INLINE_VISIBILITY
540typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
541isnan(_A1 __lcpp_x) _NOEXCEPT
542{
543 return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x);
454# ifdef _LIBCPP_PREFERRED_OVERLOAD
455_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT {
456 return __builtin_isnan(__x);
544457}
545458
546template <class _A1>
547inline _LIBCPP_INLINE_VISIBILITY
548typename std::enable_if<std::is_integral<_A1>::value, bool>::type
549isnan(_A1) _NOEXCEPT
550{ return false; }
551
552#ifdef _LIBCPP_PREFERRED_OVERLOAD
553inline _LIBCPP_INLINE_VISIBILITY
554bool
555isnan(float __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
556
557inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
558bool
559isnan(double __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
560
561inline _LIBCPP_INLINE_VISIBILITY
562bool
563isnan(long double __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
564#endif
459_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isnan(double __x) _NOEXCEPT {
460 return __builtin_isnan(__x);
461}
565462
566#endif // isnan
463_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT {
464 return __builtin_isnan(__x);
465}
466# endif
567467
568468// isnormal
569469
570#ifdef isnormal
571
572template <class _A1>
573_LIBCPP_INLINE_VISIBILITY
574bool
575__libcpp_isnormal(_A1 __lcpp_x) _NOEXCEPT
576{
577#if __has_builtin(__builtin_isnormal)
578 return __builtin_isnormal(__lcpp_x);
579#else
580 return isnormal(__lcpp_x);
581#endif
470template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
471_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
472 return __builtin_isnormal(__x);
582473}
583474
584#undef isnormal
585
586template <class _A1>
587inline _LIBCPP_INLINE_VISIBILITY
588typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
589isnormal(_A1 __lcpp_x) _NOEXCEPT
590{
591 return __libcpp_isnormal((typename std::__promote<_A1>::type)__lcpp_x);
475template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
476_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
477 return __x != 0;
592478}
593479
594template <class _A1>
595inline _LIBCPP_INLINE_VISIBILITY
596typename std::enable_if<std::is_integral<_A1>::value, bool>::type
597isnormal(_A1 __lcpp_x) _NOEXCEPT
598{ return __lcpp_x != 0; }
599
600#endif // isnormal
601
602480// isgreater
603481
604#ifdef isgreater
605
606template <class _A1, class _A2>
607_LIBCPP_INLINE_VISIBILITY
608bool
609__libcpp_isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
610{
611 return isgreater(__lcpp_x, __lcpp_y);
482template <class _A1,
483 class _A2,
484 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
485_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT {
486 typedef typename std::__promote<_A1, _A2>::type type;
487 return __builtin_isgreater((type)__x, (type)__y);
612488}
613489
614#undef isgreater
615
616template <class _A1, class _A2>
617inline _LIBCPP_INLINE_VISIBILITY
618typename std::enable_if
619<
620 std::is_arithmetic<_A1>::value &&
621 std::is_arithmetic<_A2>::value,
622 bool
623>::type
624isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
625{
626 typedef typename std::__promote<_A1, _A2>::type type;
627 return __libcpp_isgreater((type)__lcpp_x, (type)__lcpp_y);
628}
629
630#endif // isgreater
631
632490// isgreaterequal
633491
634#ifdef isgreaterequal
635
636template <class _A1, class _A2>
637_LIBCPP_INLINE_VISIBILITY
638bool
639__libcpp_isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
640{
641 return isgreaterequal(__lcpp_x, __lcpp_y);
642}
643
644#undef isgreaterequal
645
646template <class _A1, class _A2>
647inline _LIBCPP_INLINE_VISIBILITY
648typename std::enable_if
649<
650 std::is_arithmetic<_A1>::value &&
651 std::is_arithmetic<_A2>::value,
652 bool
653>::type
654isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
655{
656 typedef typename std::__promote<_A1, _A2>::type type;
657 return __libcpp_isgreaterequal((type)__lcpp_x, (type)__lcpp_y);
492template <class _A1,
493 class _A2,
494 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
495_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT {
496 typedef typename std::__promote<_A1, _A2>::type type;
497 return __builtin_isgreaterequal((type)__x, (type)__y);
658498}
659499
660#endif // isgreaterequal
661
662500// isless
663501
664#ifdef isless
665
666template <class _A1, class _A2>
667_LIBCPP_INLINE_VISIBILITY
668bool
669__libcpp_isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
670{
671 return isless(__lcpp_x, __lcpp_y);
502template <class _A1,
503 class _A2,
504 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
505_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT {
506 typedef typename std::__promote<_A1, _A2>::type type;
507 return __builtin_isless((type)__x, (type)__y);
672508}
673509
674#undef isless
675
676template <class _A1, class _A2>
677inline _LIBCPP_INLINE_VISIBILITY
678typename std::enable_if
679<
680 std::is_arithmetic<_A1>::value &&
681 std::is_arithmetic<_A2>::value,
682 bool
683>::type
684isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
685{
686 typedef typename std::__promote<_A1, _A2>::type type;
687 return __libcpp_isless((type)__lcpp_x, (type)__lcpp_y);
688}
689
690#endif // isless
691
692510// islessequal
693511
694#ifdef islessequal
695
696template <class _A1, class _A2>
697_LIBCPP_INLINE_VISIBILITY
698bool
699__libcpp_islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
700{
701 return islessequal(__lcpp_x, __lcpp_y);
512template <class _A1,
513 class _A2,
514 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
515_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT {
516 typedef typename std::__promote<_A1, _A2>::type type;
517 return __builtin_islessequal((type)__x, (type)__y);
702518}
703519
704#undef islessequal
705
706template <class _A1, class _A2>
707inline _LIBCPP_INLINE_VISIBILITY
708typename std::enable_if
709<
710 std::is_arithmetic<_A1>::value &&
711 std::is_arithmetic<_A2>::value,
712 bool
713>::type
714islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
715{
716 typedef typename std::__promote<_A1, _A2>::type type;
717 return __libcpp_islessequal((type)__lcpp_x, (type)__lcpp_y);
718}
719
720#endif // islessequal
721
722520// islessgreater
723521
724#ifdef islessgreater
725
726template <class _A1, class _A2>
727_LIBCPP_INLINE_VISIBILITY
728bool
729__libcpp_islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
730{
731 return islessgreater(__lcpp_x, __lcpp_y);
732}
733
734#undef islessgreater
735
736template <class _A1, class _A2>
737inline _LIBCPP_INLINE_VISIBILITY
738typename std::enable_if
739<
740 std::is_arithmetic<_A1>::value &&
741 std::is_arithmetic<_A2>::value,
742 bool
743>::type
744islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
745{
746 typedef typename std::__promote<_A1, _A2>::type type;
747 return __libcpp_islessgreater((type)__lcpp_x, (type)__lcpp_y);
522template <class _A1,
523 class _A2,
524 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
525_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT {
526 typedef typename std::__promote<_A1, _A2>::type type;
527 return __builtin_islessgreater((type)__x, (type)__y);
748528}
749529
750#endif // islessgreater
751
752530// isunordered
753531
754#ifdef isunordered
755
756template <class _A1, class _A2>
757_LIBCPP_INLINE_VISIBILITY
758bool
759__libcpp_isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
760{
761 return isunordered(__lcpp_x, __lcpp_y);
762}
763
764#undef isunordered
765
766template <class _A1, class _A2>
767inline _LIBCPP_INLINE_VISIBILITY
768typename std::enable_if
769<
770 std::is_arithmetic<_A1>::value &&
771 std::is_arithmetic<_A2>::value,
772 bool
773>::type
774isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
775{
776 typedef typename std::__promote<_A1, _A2>::type type;
777 return __libcpp_isunordered((type)__lcpp_x, (type)__lcpp_y);
532template <class _A1,
533 class _A2,
534 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
535_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT {
536 typedef typename std::__promote<_A1, _A2>::type type;
537 return __builtin_isunordered((type)__x, (type)__y);
778538}
779539
780#endif // isunordered
540#endif // _LIBCPP_MSVCRT
781541
782542// abs
783543//
......@@ -787,497 +547,633 @@ isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
787547//
788548// handled in stdlib.h
789549
550// We have to provide double overloads for <math.h> to work on platforms that don't provide the full set of math
551// functions. To make the overload set work with multiple functions that take the same arguments, we make our overloads
552// templates. Functions are preferred over function templates during overload resolution, which means that our overload
553// will only be selected when the C library doesn't provide one.
554
790555// acos
791556
792557# if !defined(__sun__)
793inline _LIBCPP_INLINE_VISIBILITY float acos(float __lcpp_x) _NOEXCEPT {return ::acosf(__lcpp_x);}
794inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return ::acosl(__lcpp_x);}
558inline _LIBCPP_HIDE_FROM_ABI float acos(float __x) _NOEXCEPT {return __builtin_acosf(__x);}
559
560template <class = int>
561_LIBCPP_HIDE_FROM_ABI double acos(double __x) _NOEXCEPT {
562 return __builtin_acos(__x);
563}
564
565inline _LIBCPP_HIDE_FROM_ABI long double acos(long double __x) _NOEXCEPT {return __builtin_acosl(__x);}
795566# endif
796567
797568template <class _A1>
798inline _LIBCPP_INLINE_VISIBILITY
569inline _LIBCPP_HIDE_FROM_ABI
799570typename std::enable_if<std::is_integral<_A1>::value, double>::type
800acos(_A1 __lcpp_x) _NOEXCEPT {return ::acos((double)__lcpp_x);}
571acos(_A1 __x) _NOEXCEPT {return __builtin_acos((double)__x);}
801572
802573// asin
803574
804575# if !defined(__sun__)
805inline _LIBCPP_INLINE_VISIBILITY float asin(float __lcpp_x) _NOEXCEPT {return ::asinf(__lcpp_x);}
806inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return ::asinl(__lcpp_x);}
576inline _LIBCPP_HIDE_FROM_ABI float asin(float __x) _NOEXCEPT {return __builtin_asinf(__x);}
577
578template <class = int>
579_LIBCPP_HIDE_FROM_ABI double asin(double __x) _NOEXCEPT {
580 return __builtin_asin(__x);
581}
582
583inline _LIBCPP_HIDE_FROM_ABI long double asin(long double __x) _NOEXCEPT {return __builtin_asinl(__x);}
807584# endif
808585
809586template <class _A1>
810inline _LIBCPP_INLINE_VISIBILITY
587inline _LIBCPP_HIDE_FROM_ABI
811588typename std::enable_if<std::is_integral<_A1>::value, double>::type
812asin(_A1 __lcpp_x) _NOEXCEPT {return ::asin((double)__lcpp_x);}
589asin(_A1 __x) _NOEXCEPT {return __builtin_asin((double)__x);}
813590
814591// atan
815592
816593# if !defined(__sun__)
817inline _LIBCPP_INLINE_VISIBILITY float atan(float __lcpp_x) _NOEXCEPT {return ::atanf(__lcpp_x);}
818inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return ::atanl(__lcpp_x);}
594inline _LIBCPP_HIDE_FROM_ABI float atan(float __x) _NOEXCEPT {return __builtin_atanf(__x);}
595
596template <class = int>
597_LIBCPP_HIDE_FROM_ABI double atan(double __x) _NOEXCEPT {
598 return __builtin_atan(__x);
599}
600
601inline _LIBCPP_HIDE_FROM_ABI long double atan(long double __x) _NOEXCEPT {return __builtin_atanl(__x);}
819602# endif
820603
821604template <class _A1>
822inline _LIBCPP_INLINE_VISIBILITY
605inline _LIBCPP_HIDE_FROM_ABI
823606typename std::enable_if<std::is_integral<_A1>::value, double>::type
824atan(_A1 __lcpp_x) _NOEXCEPT {return ::atan((double)__lcpp_x);}
607atan(_A1 __x) _NOEXCEPT {return __builtin_atan((double)__x);}
825608
826609// atan2
827610
828611# if !defined(__sun__)
829inline _LIBCPP_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return ::atan2f(__lcpp_y, __lcpp_x);}
830inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return ::atan2l(__lcpp_y, __lcpp_x);}
612inline _LIBCPP_HIDE_FROM_ABI float atan2(float __y, float __x) _NOEXCEPT {return __builtin_atan2f(__y, __x);}
613
614template <class = int>
615_LIBCPP_HIDE_FROM_ABI double atan2(double __x, double __y) _NOEXCEPT {
616 return __builtin_atan2(__x, __y);
617}
618
619inline _LIBCPP_HIDE_FROM_ABI long double atan2(long double __y, long double __x) _NOEXCEPT {return __builtin_atan2l(__y, __x);}
831620# endif
832621
833622template <class _A1, class _A2>
834inline _LIBCPP_INLINE_VISIBILITY
623inline _LIBCPP_HIDE_FROM_ABI
835624typename std::__enable_if_t
836625<
837626 std::is_arithmetic<_A1>::value &&
838627 std::is_arithmetic<_A2>::value,
839628 std::__promote<_A1, _A2>
840629>::type
841atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT
630atan2(_A1 __y, _A2 __x) _NOEXCEPT
842631{
843632 typedef typename std::__promote<_A1, _A2>::type __result_type;
844633 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
845634 std::_IsSame<_A2, __result_type>::value)), "");
846 return ::atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x);
635 return ::atan2((__result_type)__y, (__result_type)__x);
847636}
848637
849638// ceil
850639
851640# if !defined(__sun__)
852inline _LIBCPP_INLINE_VISIBILITY float ceil(float __lcpp_x) _NOEXCEPT {return ::ceilf(__lcpp_x);}
853inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ::ceill(__lcpp_x);}
641_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT {return __builtin_ceilf(__x);}
642
643template <class = int>
644_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double ceil(double __x) _NOEXCEPT {
645 return __builtin_ceil(__x);
646}
647
648_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT {return __builtin_ceill(__x);}
854649# endif
855650
856651template <class _A1>
857inline _LIBCPP_INLINE_VISIBILITY
652_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
858653typename std::enable_if<std::is_integral<_A1>::value, double>::type
859ceil(_A1 __lcpp_x) _NOEXCEPT {return ::ceil((double)__lcpp_x);}
654ceil(_A1 __x) _NOEXCEPT {return __builtin_ceil((double)__x);}
860655
861656// cos
862657
863658# if !defined(__sun__)
864inline _LIBCPP_INLINE_VISIBILITY float cos(float __lcpp_x) _NOEXCEPT {return ::cosf(__lcpp_x);}
865inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return ::cosl(__lcpp_x);}
659inline _LIBCPP_HIDE_FROM_ABI float cos(float __x) _NOEXCEPT {return __builtin_cosf(__x);}
660
661template <class = int>
662_LIBCPP_HIDE_FROM_ABI double cos(double __x) _NOEXCEPT {
663 return __builtin_cos(__x);
664}
665
666inline _LIBCPP_HIDE_FROM_ABI long double cos(long double __x) _NOEXCEPT {return __builtin_cosl(__x);}
866667# endif
867668
868669template <class _A1>
869inline _LIBCPP_INLINE_VISIBILITY
670inline _LIBCPP_HIDE_FROM_ABI
870671typename std::enable_if<std::is_integral<_A1>::value, double>::type
871cos(_A1 __lcpp_x) _NOEXCEPT {return ::cos((double)__lcpp_x);}
672cos(_A1 __x) _NOEXCEPT {return __builtin_cos((double)__x);}
872673
873674// cosh
874675
875676# if !defined(__sun__)
876inline _LIBCPP_INLINE_VISIBILITY float cosh(float __lcpp_x) _NOEXCEPT {return ::coshf(__lcpp_x);}
877inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return ::coshl(__lcpp_x);}
677inline _LIBCPP_HIDE_FROM_ABI float cosh(float __x) _NOEXCEPT {return __builtin_coshf(__x);}
678
679template <class = int>
680_LIBCPP_HIDE_FROM_ABI double cosh(double __x) _NOEXCEPT {
681 return __builtin_cosh(__x);
682}
683
684inline _LIBCPP_HIDE_FROM_ABI long double cosh(long double __x) _NOEXCEPT {return __builtin_coshl(__x);}
878685# endif
879686
880687template <class _A1>
881inline _LIBCPP_INLINE_VISIBILITY
688inline _LIBCPP_HIDE_FROM_ABI
882689typename std::enable_if<std::is_integral<_A1>::value, double>::type
883cosh(_A1 __lcpp_x) _NOEXCEPT {return ::cosh((double)__lcpp_x);}
690cosh(_A1 __x) _NOEXCEPT {return __builtin_cosh((double)__x);}
884691
885692// exp
886693
887694# if !defined(__sun__)
888inline _LIBCPP_INLINE_VISIBILITY float exp(float __lcpp_x) _NOEXCEPT {return ::expf(__lcpp_x);}
889inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return ::expl(__lcpp_x);}
695inline _LIBCPP_HIDE_FROM_ABI float exp(float __x) _NOEXCEPT {return __builtin_expf(__x);}
696
697template <class = int>
698_LIBCPP_HIDE_FROM_ABI double exp(double __x) _NOEXCEPT {
699 return __builtin_exp(__x);
700}
701
702inline _LIBCPP_HIDE_FROM_ABI long double exp(long double __x) _NOEXCEPT {return __builtin_expl(__x);}
890703# endif
891704
892705template <class _A1>
893inline _LIBCPP_INLINE_VISIBILITY
706inline _LIBCPP_HIDE_FROM_ABI
894707typename std::enable_if<std::is_integral<_A1>::value, double>::type
895exp(_A1 __lcpp_x) _NOEXCEPT {return ::exp((double)__lcpp_x);}
708exp(_A1 __x) _NOEXCEPT {return __builtin_exp((double)__x);}
896709
897710// fabs
898711
899712# if !defined(__sun__)
900inline _LIBCPP_INLINE_VISIBILITY float fabs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);}
901inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_x);}
713_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT {return __builtin_fabsf(__x);}
714
715template <class = int>
716_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fabs(double __x) _NOEXCEPT {
717 return __builtin_fabs(__x);
718}
719
720_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT {return __builtin_fabsl(__x);}
902721# endif
903722
904723template <class _A1>
905inline _LIBCPP_INLINE_VISIBILITY
724_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
906725typename std::enable_if<std::is_integral<_A1>::value, double>::type
907fabs(_A1 __lcpp_x) _NOEXCEPT {return ::fabs((double)__lcpp_x);}
726fabs(_A1 __x) _NOEXCEPT {return __builtin_fabs((double)__x);}
908727
909728// floor
910729
911730# if !defined(__sun__)
912inline _LIBCPP_INLINE_VISIBILITY float floor(float __lcpp_x) _NOEXCEPT {return ::floorf(__lcpp_x);}
913inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return ::floorl(__lcpp_x);}
731_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT {return __builtin_floorf(__x);}
732
733template <class = int>
734_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double floor(double __x) _NOEXCEPT {
735 return __builtin_floor(__x);
736}
737
738_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT {return __builtin_floorl(__x);}
914739# endif
915740
916741template <class _A1>
917inline _LIBCPP_INLINE_VISIBILITY
742_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
918743typename std::enable_if<std::is_integral<_A1>::value, double>::type
919floor(_A1 __lcpp_x) _NOEXCEPT {return ::floor((double)__lcpp_x);}
744floor(_A1 __x) _NOEXCEPT {return __builtin_floor((double)__x);}
920745
921746// fmod
922747
923748# if !defined(__sun__)
924inline _LIBCPP_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmodf(__lcpp_x, __lcpp_y);}
925inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fmodl(__lcpp_x, __lcpp_y);}
749inline _LIBCPP_HIDE_FROM_ABI float fmod(float __x, float __y) _NOEXCEPT {return __builtin_fmodf(__x, __y);}
750
751template <class = int>
752_LIBCPP_HIDE_FROM_ABI double fmod(double __x, double __y) _NOEXCEPT {
753 return __builtin_fmod(__x, __y);
754}
755
756inline _LIBCPP_HIDE_FROM_ABI long double fmod(long double __x, long double __y) _NOEXCEPT {return __builtin_fmodl(__x, __y);}
926757# endif
927758
928759template <class _A1, class _A2>
929inline _LIBCPP_INLINE_VISIBILITY
760inline _LIBCPP_HIDE_FROM_ABI
930761typename std::__enable_if_t
931762<
932763 std::is_arithmetic<_A1>::value &&
933764 std::is_arithmetic<_A2>::value,
934765 std::__promote<_A1, _A2>
935766>::type
936fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
767fmod(_A1 __x, _A2 __y) _NOEXCEPT
937768{
938769 typedef typename std::__promote<_A1, _A2>::type __result_type;
939770 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
940771 std::_IsSame<_A2, __result_type>::value)), "");
941 return ::fmod((__result_type)__lcpp_x, (__result_type)__lcpp_y);
772 return ::fmod((__result_type)__x, (__result_type)__y);
942773}
943774
944775// frexp
945776
946777# if !defined(__sun__)
947inline _LIBCPP_INLINE_VISIBILITY float frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpf(__lcpp_x, __lcpp_e);}
948inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpl(__lcpp_x, __lcpp_e);}
778inline _LIBCPP_HIDE_FROM_ABI float frexp(float __x, int* __e) _NOEXCEPT {return __builtin_frexpf(__x, __e);}
779
780template <class = int>
781_LIBCPP_HIDE_FROM_ABI double frexp(double __x, int* __e) _NOEXCEPT {
782 return __builtin_frexp(__x, __e);
783}
784
785inline _LIBCPP_HIDE_FROM_ABI long double frexp(long double __x, int* __e) _NOEXCEPT {return __builtin_frexpl(__x, __e);}
949786# endif
950787
951788template <class _A1>
952inline _LIBCPP_INLINE_VISIBILITY
789inline _LIBCPP_HIDE_FROM_ABI
953790typename std::enable_if<std::is_integral<_A1>::value, double>::type
954frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexp((double)__lcpp_x, __lcpp_e);}
791frexp(_A1 __x, int* __e) _NOEXCEPT {return __builtin_frexp((double)__x, __e);}
955792
956793// ldexp
957794
958795# if !defined(__sun__)
959inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpf(__lcpp_x, __lcpp_e);}
960inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpl(__lcpp_x, __lcpp_e);}
796inline _LIBCPP_HIDE_FROM_ABI float ldexp(float __x, int __e) _NOEXCEPT {return __builtin_ldexpf(__x, __e);}
797
798template <class = int>
799_LIBCPP_HIDE_FROM_ABI double ldexp(double __x, int __e) _NOEXCEPT {
800 return __builtin_ldexp(__x, __e);
801}
802
803inline _LIBCPP_HIDE_FROM_ABI long double ldexp(long double __x, int __e) _NOEXCEPT {return __builtin_ldexpl(__x, __e);}
961804# endif
962805
963806template <class _A1>
964inline _LIBCPP_INLINE_VISIBILITY
807inline _LIBCPP_HIDE_FROM_ABI
965808typename std::enable_if<std::is_integral<_A1>::value, double>::type
966ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexp((double)__lcpp_x, __lcpp_e);}
809ldexp(_A1 __x, int __e) _NOEXCEPT {return __builtin_ldexp((double)__x, __e);}
967810
968811// log
969812
970813# if !defined(__sun__)
971inline _LIBCPP_INLINE_VISIBILITY float log(float __lcpp_x) _NOEXCEPT {return ::logf(__lcpp_x);}
972inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return ::logl(__lcpp_x);}
814inline _LIBCPP_HIDE_FROM_ABI float log(float __x) _NOEXCEPT {return __builtin_logf(__x);}
815
816template <class = int>
817_LIBCPP_HIDE_FROM_ABI double log(double __x) _NOEXCEPT {
818 return __builtin_log(__x);
819}
820
821inline _LIBCPP_HIDE_FROM_ABI long double log(long double __x) _NOEXCEPT {return __builtin_logl(__x);}
973822# endif
974823
975824template <class _A1>
976inline _LIBCPP_INLINE_VISIBILITY
825inline _LIBCPP_HIDE_FROM_ABI
977826typename std::enable_if<std::is_integral<_A1>::value, double>::type
978log(_A1 __lcpp_x) _NOEXCEPT {return ::log((double)__lcpp_x);}
827log(_A1 __x) _NOEXCEPT {return __builtin_log((double)__x);}
979828
980829// log10
981830
982831# if !defined(__sun__)
983inline _LIBCPP_INLINE_VISIBILITY float log10(float __lcpp_x) _NOEXCEPT {return ::log10f(__lcpp_x);}
984inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return ::log10l(__lcpp_x);}
832inline _LIBCPP_HIDE_FROM_ABI float log10(float __x) _NOEXCEPT {return __builtin_log10f(__x);}
833
834
835template <class = int>
836_LIBCPP_HIDE_FROM_ABI double log10(double __x) _NOEXCEPT {
837 return __builtin_log10(__x);
838}
839
840inline _LIBCPP_HIDE_FROM_ABI long double log10(long double __x) _NOEXCEPT {return __builtin_log10l(__x);}
985841# endif
986842
987843template <class _A1>
988inline _LIBCPP_INLINE_VISIBILITY
844inline _LIBCPP_HIDE_FROM_ABI
989845typename std::enable_if<std::is_integral<_A1>::value, double>::type
990log10(_A1 __lcpp_x) _NOEXCEPT {return ::log10((double)__lcpp_x);}
846log10(_A1 __x) _NOEXCEPT {return __builtin_log10((double)__x);}
991847
992848// modf
993849
994850# if !defined(__sun__)
995inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return ::modff(__lcpp_x, __lcpp_y);}
996inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return ::modfl(__lcpp_x, __lcpp_y);}
851inline _LIBCPP_HIDE_FROM_ABI float modf(float __x, float* __y) _NOEXCEPT {return __builtin_modff(__x, __y);}
852
853template <class = int>
854_LIBCPP_HIDE_FROM_ABI double modf(double __x, double* __y) _NOEXCEPT {
855 return __builtin_modf(__x, __y);
856}
857
858inline _LIBCPP_HIDE_FROM_ABI long double modf(long double __x, long double* __y) _NOEXCEPT {return __builtin_modfl(__x, __y);}
997859# endif
998860
999861// pow
1000862
1001863# if !defined(__sun__)
1002inline _LIBCPP_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::powf(__lcpp_x, __lcpp_y);}
1003inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::powl(__lcpp_x, __lcpp_y);}
864inline _LIBCPP_HIDE_FROM_ABI float pow(float __x, float __y) _NOEXCEPT {return __builtin_powf(__x, __y);}
865
866template <class = int>
867_LIBCPP_HIDE_FROM_ABI double pow(double __x, double __y) _NOEXCEPT {
868 return __builtin_pow(__x, __y);
869}
870
871inline _LIBCPP_HIDE_FROM_ABI long double pow(long double __x, long double __y) _NOEXCEPT {return __builtin_powl(__x, __y);}
1004872# endif
1005873
1006874template <class _A1, class _A2>
1007inline _LIBCPP_INLINE_VISIBILITY
875inline _LIBCPP_HIDE_FROM_ABI
1008876typename std::__enable_if_t
1009877<
1010878 std::is_arithmetic<_A1>::value &&
1011879 std::is_arithmetic<_A2>::value,
1012880 std::__promote<_A1, _A2>
1013881>::type
1014pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
882pow(_A1 __x, _A2 __y) _NOEXCEPT
1015883{
1016884 typedef typename std::__promote<_A1, _A2>::type __result_type;
1017885 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1018886 std::_IsSame<_A2, __result_type>::value)), "");
1019 return ::pow((__result_type)__lcpp_x, (__result_type)__lcpp_y);
887 return ::pow((__result_type)__x, (__result_type)__y);
1020888}
1021889
1022890// sin
1023891
1024892# if !defined(__sun__)
1025inline _LIBCPP_INLINE_VISIBILITY float sin(float __lcpp_x) _NOEXCEPT {return ::sinf(__lcpp_x);}
1026inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return ::sinl(__lcpp_x);}
893inline _LIBCPP_HIDE_FROM_ABI float sin(float __x) _NOEXCEPT {return __builtin_sinf(__x);}
894
895template <class = int>
896_LIBCPP_HIDE_FROM_ABI double sin(double __x) _NOEXCEPT {
897 return __builtin_sin(__x);
898}
899
900inline _LIBCPP_HIDE_FROM_ABI long double sin(long double __x) _NOEXCEPT {return __builtin_sinl(__x);}
1027901#endif
1028902
1029903template <class _A1>
1030inline _LIBCPP_INLINE_VISIBILITY
904inline _LIBCPP_HIDE_FROM_ABI
1031905typename std::enable_if<std::is_integral<_A1>::value, double>::type
1032sin(_A1 __lcpp_x) _NOEXCEPT {return ::sin((double)__lcpp_x);}
906sin(_A1 __x) _NOEXCEPT {return __builtin_sin((double)__x);}
1033907
1034908// sinh
1035909
1036910# if !defined(__sun__)
1037inline _LIBCPP_INLINE_VISIBILITY float sinh(float __lcpp_x) _NOEXCEPT {return ::sinhf(__lcpp_x);}
1038inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return ::sinhl(__lcpp_x);}
911inline _LIBCPP_HIDE_FROM_ABI float sinh(float __x) _NOEXCEPT {return __builtin_sinhf(__x);}
912
913template <class = int>
914_LIBCPP_HIDE_FROM_ABI double sinh(double __x) _NOEXCEPT {
915 return __builtin_sinh(__x);
916}
917
918inline _LIBCPP_HIDE_FROM_ABI long double sinh(long double __x) _NOEXCEPT {return __builtin_sinhl(__x);}
1039919# endif
1040920
1041921template <class _A1>
1042inline _LIBCPP_INLINE_VISIBILITY
922inline _LIBCPP_HIDE_FROM_ABI
1043923typename std::enable_if<std::is_integral<_A1>::value, double>::type
1044sinh(_A1 __lcpp_x) _NOEXCEPT {return ::sinh((double)__lcpp_x);}
924sinh(_A1 __x) _NOEXCEPT {return __builtin_sinh((double)__x);}
1045925
1046926// sqrt
1047927
1048928# if !defined(__sun__)
1049inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __lcpp_x) _NOEXCEPT {return ::sqrtf(__lcpp_x);}
1050inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return ::sqrtl(__lcpp_x);}
929inline _LIBCPP_HIDE_FROM_ABI float sqrt(float __x) _NOEXCEPT {return __builtin_sqrtf(__x);}
930
931template <class = int>
932_LIBCPP_HIDE_FROM_ABI double sqrt(double __x) _NOEXCEPT {
933 return __builtin_sqrt(__x);
934}
935
936inline _LIBCPP_HIDE_FROM_ABI long double sqrt(long double __x) _NOEXCEPT {return __builtin_sqrtl(__x);}
1051937# endif
1052938
1053939template <class _A1>
1054inline _LIBCPP_INLINE_VISIBILITY
940inline _LIBCPP_HIDE_FROM_ABI
1055941typename std::enable_if<std::is_integral<_A1>::value, double>::type
1056sqrt(_A1 __lcpp_x) _NOEXCEPT {return ::sqrt((double)__lcpp_x);}
942sqrt(_A1 __x) _NOEXCEPT {return __builtin_sqrt((double)__x);}
1057943
1058944// tan
1059945
1060946# if !defined(__sun__)
1061inline _LIBCPP_INLINE_VISIBILITY float tan(float __lcpp_x) _NOEXCEPT {return ::tanf(__lcpp_x);}
1062inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return ::tanl(__lcpp_x);}
947inline _LIBCPP_HIDE_FROM_ABI float tan(float __x) _NOEXCEPT {return __builtin_tanf(__x);}
948
949template <class = int>
950_LIBCPP_HIDE_FROM_ABI double tan(double __x) _NOEXCEPT {
951 return __builtin_tan(__x);
952}
953
954inline _LIBCPP_HIDE_FROM_ABI long double tan(long double __x) _NOEXCEPT {return __builtin_tanl(__x);}
1063955# endif
1064956
1065957template <class _A1>
1066inline _LIBCPP_INLINE_VISIBILITY
958inline _LIBCPP_HIDE_FROM_ABI
1067959typename std::enable_if<std::is_integral<_A1>::value, double>::type
1068tan(_A1 __lcpp_x) _NOEXCEPT {return ::tan((double)__lcpp_x);}
960tan(_A1 __x) _NOEXCEPT {return __builtin_tan((double)__x);}
1069961
1070962// tanh
1071963
1072964# if !defined(__sun__)
1073inline _LIBCPP_INLINE_VISIBILITY float tanh(float __lcpp_x) _NOEXCEPT {return ::tanhf(__lcpp_x);}
1074inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return ::tanhl(__lcpp_x);}
965inline _LIBCPP_HIDE_FROM_ABI float tanh(float __x) _NOEXCEPT {return __builtin_tanhf(__x);}
966
967template <class = int>
968_LIBCPP_HIDE_FROM_ABI double tanh(double __x) _NOEXCEPT {
969 return __builtin_tanh(__x);
970}
971
972inline _LIBCPP_HIDE_FROM_ABI long double tanh(long double __x) _NOEXCEPT {return __builtin_tanhl(__x);}
1075973# endif
1076974
1077975template <class _A1>
1078inline _LIBCPP_INLINE_VISIBILITY
976inline _LIBCPP_HIDE_FROM_ABI
1079977typename std::enable_if<std::is_integral<_A1>::value, double>::type
1080tanh(_A1 __lcpp_x) _NOEXCEPT {return ::tanh((double)__lcpp_x);}
978tanh(_A1 __x) _NOEXCEPT {return __builtin_tanh((double)__x);}
1081979
1082980// acosh
1083981
1084inline _LIBCPP_INLINE_VISIBILITY float acosh(float __lcpp_x) _NOEXCEPT {return ::acoshf(__lcpp_x);}
1085inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __lcpp_x) _NOEXCEPT {return ::acoshl(__lcpp_x);}
982inline _LIBCPP_HIDE_FROM_ABI float acosh(float __x) _NOEXCEPT {return __builtin_acoshf(__x);}
983
984template <class = int>
985_LIBCPP_HIDE_FROM_ABI double acosh(double __x) _NOEXCEPT {
986 return __builtin_acosh(__x);
987}
988
989inline _LIBCPP_HIDE_FROM_ABI long double acosh(long double __x) _NOEXCEPT {return __builtin_acoshl(__x);}
1086990
1087991template <class _A1>
1088inline _LIBCPP_INLINE_VISIBILITY
992inline _LIBCPP_HIDE_FROM_ABI
1089993typename std::enable_if<std::is_integral<_A1>::value, double>::type
1090acosh(_A1 __lcpp_x) _NOEXCEPT {return ::acosh((double)__lcpp_x);}
994acosh(_A1 __x) _NOEXCEPT {return __builtin_acosh((double)__x);}
1091995
1092996// asinh
1093997
1094inline _LIBCPP_INLINE_VISIBILITY float asinh(float __lcpp_x) _NOEXCEPT {return ::asinhf(__lcpp_x);}
1095inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __lcpp_x) _NOEXCEPT {return ::asinhl(__lcpp_x);}
998inline _LIBCPP_HIDE_FROM_ABI float asinh(float __x) _NOEXCEPT {return __builtin_asinhf(__x);}
999
1000template <class = int>
1001_LIBCPP_HIDE_FROM_ABI double asinh(double __x) _NOEXCEPT {
1002 return __builtin_asinh(__x);
1003}
1004
1005inline _LIBCPP_HIDE_FROM_ABI long double asinh(long double __x) _NOEXCEPT {return __builtin_asinhl(__x);}
10961006
10971007template <class _A1>
1098inline _LIBCPP_INLINE_VISIBILITY
1008inline _LIBCPP_HIDE_FROM_ABI
10991009typename std::enable_if<std::is_integral<_A1>::value, double>::type
1100asinh(_A1 __lcpp_x) _NOEXCEPT {return ::asinh((double)__lcpp_x);}
1010asinh(_A1 __x) _NOEXCEPT {return __builtin_asinh((double)__x);}
11011011
11021012// atanh
11031013
1104inline _LIBCPP_INLINE_VISIBILITY float atanh(float __lcpp_x) _NOEXCEPT {return ::atanhf(__lcpp_x);}
1105inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __lcpp_x) _NOEXCEPT {return ::atanhl(__lcpp_x);}
1014inline _LIBCPP_HIDE_FROM_ABI float atanh(float __x) _NOEXCEPT {return __builtin_atanhf(__x);}
1015
1016template <class = int>
1017_LIBCPP_HIDE_FROM_ABI double atanh(double __x) _NOEXCEPT {
1018 return __builtin_atanh(__x);
1019}
1020
1021inline _LIBCPP_HIDE_FROM_ABI long double atanh(long double __x) _NOEXCEPT {return __builtin_atanhl(__x);}
11061022
11071023template <class _A1>
1108inline _LIBCPP_INLINE_VISIBILITY
1024inline _LIBCPP_HIDE_FROM_ABI
11091025typename std::enable_if<std::is_integral<_A1>::value, double>::type
1110atanh(_A1 __lcpp_x) _NOEXCEPT {return ::atanh((double)__lcpp_x);}
1026atanh(_A1 __x) _NOEXCEPT {return __builtin_atanh((double)__x);}
11111027
11121028// cbrt
11131029
1114inline _LIBCPP_INLINE_VISIBILITY float cbrt(float __lcpp_x) _NOEXCEPT {return ::cbrtf(__lcpp_x);}
1115inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __lcpp_x) _NOEXCEPT {return ::cbrtl(__lcpp_x);}
1030_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT {return __builtin_cbrtf(__x);}
1031
1032template <class = int>
1033_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double cbrt(double __x) _NOEXCEPT {
1034 return __builtin_cbrt(__x);
1035}
1036
1037_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT {return __builtin_cbrtl(__x);}
11161038
11171039template <class _A1>
1118inline _LIBCPP_INLINE_VISIBILITY
1040_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
11191041typename std::enable_if<std::is_integral<_A1>::value, double>::type
1120cbrt(_A1 __lcpp_x) _NOEXCEPT {return ::cbrt((double)__lcpp_x);}
1042cbrt(_A1 __x) _NOEXCEPT {return __builtin_cbrt((double)__x);}
11211043
11221044// copysign
11231045
1124#if __has_builtin(__builtin_copysignf)
1125_LIBCPP_CONSTEXPR
1126#endif
1127inline _LIBCPP_INLINE_VISIBILITY float __libcpp_copysign(float __lcpp_x, float __lcpp_y) _NOEXCEPT {
1128#if __has_builtin(__builtin_copysignf)
1129 return __builtin_copysignf(__lcpp_x, __lcpp_y);
1130#else
1131 return ::copysignf(__lcpp_x, __lcpp_y);
1132#endif
1133}
1134
1135#if __has_builtin(__builtin_copysign)
1136_LIBCPP_CONSTEXPR
1137#endif
1138inline _LIBCPP_INLINE_VISIBILITY double __libcpp_copysign(double __lcpp_x, double __lcpp_y) _NOEXCEPT {
1139#if __has_builtin(__builtin_copysign)
1140 return __builtin_copysign(__lcpp_x, __lcpp_y);
1141#else
1142 return ::copysign(__lcpp_x, __lcpp_y);
1143#endif
1046_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT {
1047 return ::__builtin_copysignf(__x, __y);
11441048}
11451049
1146#if __has_builtin(__builtin_copysignl)
1147_LIBCPP_CONSTEXPR
1148#endif
1149inline _LIBCPP_INLINE_VISIBILITY long double __libcpp_copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {
1150#if __has_builtin(__builtin_copysignl)
1151 return __builtin_copysignl(__lcpp_x, __lcpp_y);
1152#else
1153 return ::copysignl(__lcpp_x, __lcpp_y);
1154#endif
1050_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT {
1051 return ::__builtin_copysignl(__x, __y);
11551052}
11561053
11571054template <class _A1, class _A2>
1158#if __has_builtin(__builtin_copysign)
1159_LIBCPP_CONSTEXPR
1160#endif
1161inline _LIBCPP_INLINE_VISIBILITY
1055_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
11621056typename std::__enable_if_t
11631057<
11641058 std::is_arithmetic<_A1>::value &&
11651059 std::is_arithmetic<_A2>::value,
11661060 std::__promote<_A1, _A2>
11671061>::type
1168__libcpp_copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT {
1169 typedef typename std::__promote<_A1, _A2>::type __result_type;
1170 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1171 std::_IsSame<_A2, __result_type>::value)), "");
1172#if __has_builtin(__builtin_copysign)
1173 return __builtin_copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1174#else
1175 return ::copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1176#endif
1062 copysign(_A1 __x, _A2 __y) _NOEXCEPT {
1063 return ::__builtin_copysign(__x, __y);
11771064}
11781065
1179inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x, float __lcpp_y) _NOEXCEPT {
1180 return ::__libcpp_copysign(__lcpp_x, __lcpp_y);
1181}
1066// erf
11821067
1183inline _LIBCPP_INLINE_VISIBILITY long double copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {
1184 return ::__libcpp_copysign(__lcpp_x, __lcpp_y);
1185}
1068inline _LIBCPP_HIDE_FROM_ABI float erf(float __x) _NOEXCEPT {return __builtin_erff(__x);}
11861069
1187template <class _A1, class _A2>
1188inline _LIBCPP_INLINE_VISIBILITY
1189typename std::__enable_if_t
1190<
1191 std::is_arithmetic<_A1>::value &&
1192 std::is_arithmetic<_A2>::value,
1193 std::__promote<_A1, _A2>
1194>::type
1195 copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT {
1196 return ::__libcpp_copysign(__lcpp_x, __lcpp_y);
1070template <class = int>
1071_LIBCPP_HIDE_FROM_ABI double erf(double __x) _NOEXCEPT {
1072 return __builtin_erf(__x);
11971073}
11981074
1199// erf
1200
1201inline _LIBCPP_INLINE_VISIBILITY float erf(float __lcpp_x) _NOEXCEPT {return ::erff(__lcpp_x);}
1202inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __lcpp_x) _NOEXCEPT {return ::erfl(__lcpp_x);}
1075inline _LIBCPP_HIDE_FROM_ABI long double erf(long double __x) _NOEXCEPT {return __builtin_erfl(__x);}
12031076
12041077template <class _A1>
1205inline _LIBCPP_INLINE_VISIBILITY
1078inline _LIBCPP_HIDE_FROM_ABI
12061079typename std::enable_if<std::is_integral<_A1>::value, double>::type
1207erf(_A1 __lcpp_x) _NOEXCEPT {return ::erf((double)__lcpp_x);}
1080erf(_A1 __x) _NOEXCEPT {return __builtin_erf((double)__x);}
12081081
12091082// erfc
12101083
1211inline _LIBCPP_INLINE_VISIBILITY float erfc(float __lcpp_x) _NOEXCEPT {return ::erfcf(__lcpp_x);}
1212inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __lcpp_x) _NOEXCEPT {return ::erfcl(__lcpp_x);}
1084inline _LIBCPP_HIDE_FROM_ABI float erfc(float __x) _NOEXCEPT {return __builtin_erfcf(__x);}
1085
1086template <class = int>
1087_LIBCPP_HIDE_FROM_ABI double erfc(double __x) _NOEXCEPT {
1088 return __builtin_erfc(__x);
1089}
1090
1091inline _LIBCPP_HIDE_FROM_ABI long double erfc(long double __x) _NOEXCEPT {return __builtin_erfcl(__x);}
12131092
12141093template <class _A1>
1215inline _LIBCPP_INLINE_VISIBILITY
1094inline _LIBCPP_HIDE_FROM_ABI
12161095typename std::enable_if<std::is_integral<_A1>::value, double>::type
1217erfc(_A1 __lcpp_x) _NOEXCEPT {return ::erfc((double)__lcpp_x);}
1096erfc(_A1 __x) _NOEXCEPT {return __builtin_erfc((double)__x);}
12181097
12191098// exp2
12201099
1221inline _LIBCPP_INLINE_VISIBILITY float exp2(float __lcpp_x) _NOEXCEPT {return ::exp2f(__lcpp_x);}
1222inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __lcpp_x) _NOEXCEPT {return ::exp2l(__lcpp_x);}
1100inline _LIBCPP_HIDE_FROM_ABI float exp2(float __x) _NOEXCEPT {return __builtin_exp2f(__x);}
1101
1102template <class = int>
1103_LIBCPP_HIDE_FROM_ABI double exp2(double __x) _NOEXCEPT {
1104 return __builtin_exp2(__x);
1105}
1106
1107inline _LIBCPP_HIDE_FROM_ABI long double exp2(long double __x) _NOEXCEPT {return __builtin_exp2l(__x);}
12231108
12241109template <class _A1>
1225inline _LIBCPP_INLINE_VISIBILITY
1110inline _LIBCPP_HIDE_FROM_ABI
12261111typename std::enable_if<std::is_integral<_A1>::value, double>::type
1227exp2(_A1 __lcpp_x) _NOEXCEPT {return ::exp2((double)__lcpp_x);}
1112exp2(_A1 __x) _NOEXCEPT {return __builtin_exp2((double)__x);}
12281113
12291114// expm1
12301115
1231inline _LIBCPP_INLINE_VISIBILITY float expm1(float __lcpp_x) _NOEXCEPT {return ::expm1f(__lcpp_x);}
1232inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __lcpp_x) _NOEXCEPT {return ::expm1l(__lcpp_x);}
1116inline _LIBCPP_HIDE_FROM_ABI float expm1(float __x) _NOEXCEPT {return __builtin_expm1f(__x);}
1117
1118template <class = int>
1119_LIBCPP_HIDE_FROM_ABI double expm1(double __x) _NOEXCEPT {
1120 return __builtin_expm1(__x);
1121}
1122
1123inline _LIBCPP_HIDE_FROM_ABI long double expm1(long double __x) _NOEXCEPT {return __builtin_expm1l(__x);}
12331124
12341125template <class _A1>
1235inline _LIBCPP_INLINE_VISIBILITY
1126inline _LIBCPP_HIDE_FROM_ABI
12361127typename std::enable_if<std::is_integral<_A1>::value, double>::type
1237expm1(_A1 __lcpp_x) _NOEXCEPT {return ::expm1((double)__lcpp_x);}
1128expm1(_A1 __x) _NOEXCEPT {return __builtin_expm1((double)__x);}
12381129
12391130// fdim
12401131
1241inline _LIBCPP_INLINE_VISIBILITY float fdim(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fdimf(__lcpp_x, __lcpp_y);}
1242inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fdiml(__lcpp_x, __lcpp_y);}
1132inline _LIBCPP_HIDE_FROM_ABI float fdim(float __x, float __y) _NOEXCEPT {return __builtin_fdimf(__x, __y);}
1133
1134template <class = int>
1135_LIBCPP_HIDE_FROM_ABI double fdim(double __x, double __y) _NOEXCEPT {
1136 return __builtin_fdim(__x, __y);
1137}
1138
1139inline _LIBCPP_HIDE_FROM_ABI long double fdim(long double __x, long double __y) _NOEXCEPT {return __builtin_fdiml(__x, __y);}
12431140
12441141template <class _A1, class _A2>
1245inline _LIBCPP_INLINE_VISIBILITY
1142inline _LIBCPP_HIDE_FROM_ABI
12461143typename std::__enable_if_t
12471144<
12481145 std::is_arithmetic<_A1>::value &&
12491146 std::is_arithmetic<_A2>::value,
12501147 std::__promote<_A1, _A2>
12511148>::type
1252fdim(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1149fdim(_A1 __x, _A2 __y) _NOEXCEPT
12531150{
12541151 typedef typename std::__promote<_A1, _A2>::type __result_type;
12551152 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
12561153 std::_IsSame<_A2, __result_type>::value)), "");
1257 return ::fdim((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1154 return ::fdim((__result_type)__x, (__result_type)__y);
12581155}
12591156
12601157// fma
12611158
1262inline _LIBCPP_INLINE_VISIBILITY float fma(float __lcpp_x, float __lcpp_y, float __lcpp_z) _NOEXCEPT
1159inline _LIBCPP_HIDE_FROM_ABI float fma(float __x, float __y, float __z) _NOEXCEPT
12631160{
1264#if __has_builtin(__builtin_fmaf)
1265 return __builtin_fmaf(__lcpp_x, __lcpp_y, __lcpp_z);
1266#else
1267 return ::fmaf(__lcpp_x, __lcpp_y, __lcpp_z);
1268#endif
1161 return __builtin_fmaf(__x, __y, __z);
1162}
1163
1164
1165template <class = int>
1166_LIBCPP_HIDE_FROM_ABI double fma(double __x, double __y, double __z) _NOEXCEPT {
1167 return __builtin_fma(__x, __y, __z);
12691168}
1270inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __lcpp_x, long double __lcpp_y, long double __lcpp_z) _NOEXCEPT
1169
1170inline _LIBCPP_HIDE_FROM_ABI long double fma(long double __x, long double __y, long double __z) _NOEXCEPT
12711171{
1272#if __has_builtin(__builtin_fmal)
1273 return __builtin_fmal(__lcpp_x, __lcpp_y, __lcpp_z);
1274#else
1275 return ::fmal(__lcpp_x, __lcpp_y, __lcpp_z);
1276#endif
1172 return __builtin_fmal(__x, __y, __z);
12771173}
12781174
12791175template <class _A1, class _A2, class _A3>
1280inline _LIBCPP_INLINE_VISIBILITY
1176inline _LIBCPP_HIDE_FROM_ABI
12811177typename std::__enable_if_t
12821178<
12831179 std::is_arithmetic<_A1>::value &&
......@@ -1285,462 +1181,512 @@ typename std::__enable_if_t
12851181 std::is_arithmetic<_A3>::value,
12861182 std::__promote<_A1, _A2, _A3>
12871183>::type
1288fma(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
1184fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT
12891185{
12901186 typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;
12911187 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
12921188 std::_IsSame<_A2, __result_type>::value &&
12931189 std::_IsSame<_A3, __result_type>::value)), "");
1294#if __has_builtin(__builtin_fma)
1295 return __builtin_fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
1296#else
1297 return ::fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
1298#endif
1190 return __builtin_fma((__result_type)__x, (__result_type)__y, (__result_type)__z);
12991191}
13001192
13011193// fmax
13021194
1303inline _LIBCPP_INLINE_VISIBILITY float fmax(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmaxf(__lcpp_x, __lcpp_y);}
1304inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fmaxl(__lcpp_x, __lcpp_y);}
1195_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT {return __builtin_fmaxf(__x, __y);}
1196
1197template <class = int>
1198_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fmax(double __x, double __y) _NOEXCEPT {
1199 return __builtin_fmax(__x, __y);
1200}
1201
1202_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT {return __builtin_fmaxl(__x, __y);}
13051203
13061204template <class _A1, class _A2>
1307inline _LIBCPP_INLINE_VISIBILITY
1205_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
13081206typename std::__enable_if_t
13091207<
13101208 std::is_arithmetic<_A1>::value &&
13111209 std::is_arithmetic<_A2>::value,
13121210 std::__promote<_A1, _A2>
13131211>::type
1314fmax(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1212fmax(_A1 __x, _A2 __y) _NOEXCEPT
13151213{
13161214 typedef typename std::__promote<_A1, _A2>::type __result_type;
13171215 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
13181216 std::_IsSame<_A2, __result_type>::value)), "");
1319 return ::fmax((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1217 return ::fmax((__result_type)__x, (__result_type)__y);
13201218}
13211219
13221220// fmin
13231221
1324inline _LIBCPP_INLINE_VISIBILITY float fmin(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fminf(__lcpp_x, __lcpp_y);}
1325inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fminl(__lcpp_x, __lcpp_y);}
1222_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT {return __builtin_fminf(__x, __y);}
1223
1224template <class = int>
1225_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fmin(double __x, double __y) _NOEXCEPT {
1226 return __builtin_fmin(__x, __y);
1227}
1228
1229_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT {return __builtin_fminl(__x, __y);}
13261230
13271231template <class _A1, class _A2>
1328inline _LIBCPP_INLINE_VISIBILITY
1232_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
13291233typename std::__enable_if_t
13301234<
13311235 std::is_arithmetic<_A1>::value &&
13321236 std::is_arithmetic<_A2>::value,
13331237 std::__promote<_A1, _A2>
13341238>::type
1335fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1239fmin(_A1 __x, _A2 __y) _NOEXCEPT
13361240{
13371241 typedef typename std::__promote<_A1, _A2>::type __result_type;
13381242 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
13391243 std::_IsSame<_A2, __result_type>::value)), "");
1340 return ::fmin((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1244 return ::fmin((__result_type)__x, (__result_type)__y);
13411245}
13421246
13431247// hypot
13441248
1345inline _LIBCPP_INLINE_VISIBILITY float hypot(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::hypotf(__lcpp_x, __lcpp_y);}
1346inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::hypotl(__lcpp_x, __lcpp_y);}
1249inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y) _NOEXCEPT {return __builtin_hypotf(__x, __y);}
1250
1251template <class = int>
1252_LIBCPP_HIDE_FROM_ABI double hypot(double __x, double __y) _NOEXCEPT {
1253 return __builtin_hypot(__x, __y);
1254}
1255
1256inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y) _NOEXCEPT {return __builtin_hypotl(__x, __y);}
13471257
13481258template <class _A1, class _A2>
1349inline _LIBCPP_INLINE_VISIBILITY
1259inline _LIBCPP_HIDE_FROM_ABI
13501260typename std::__enable_if_t
13511261<
13521262 std::is_arithmetic<_A1>::value &&
13531263 std::is_arithmetic<_A2>::value,
13541264 std::__promote<_A1, _A2>
13551265>::type
1356hypot(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1266hypot(_A1 __x, _A2 __y) _NOEXCEPT
13571267{
13581268 typedef typename std::__promote<_A1, _A2>::type __result_type;
13591269 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
13601270 std::_IsSame<_A2, __result_type>::value)), "");
1361 return ::hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1271 return ::hypot((__result_type)__x, (__result_type)__y);
13621272}
13631273
13641274// ilogb
13651275
1366inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __lcpp_x) _NOEXCEPT {return ::ilogbf(__lcpp_x);}
1367inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __lcpp_x) _NOEXCEPT {return ::ilogbl(__lcpp_x);}
1276inline _LIBCPP_HIDE_FROM_ABI int ilogb(float __x) _NOEXCEPT {return __builtin_ilogbf(__x);}
1277
1278template <class = int>
1279_LIBCPP_HIDE_FROM_ABI double ilogb(double __x) _NOEXCEPT {
1280 return __builtin_ilogb(__x);
1281}
1282
1283inline _LIBCPP_HIDE_FROM_ABI int ilogb(long double __x) _NOEXCEPT {return __builtin_ilogbl(__x);}
13681284
13691285template <class _A1>
1370inline _LIBCPP_INLINE_VISIBILITY
1286inline _LIBCPP_HIDE_FROM_ABI
13711287typename std::enable_if<std::is_integral<_A1>::value, int>::type
1372ilogb(_A1 __lcpp_x) _NOEXCEPT {return ::ilogb((double)__lcpp_x);}
1288ilogb(_A1 __x) _NOEXCEPT {return __builtin_ilogb((double)__x);}
13731289
13741290// lgamma
13751291
1376inline _LIBCPP_INLINE_VISIBILITY float lgamma(float __lcpp_x) _NOEXCEPT {return ::lgammaf(__lcpp_x);}
1377inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __lcpp_x) _NOEXCEPT {return ::lgammal(__lcpp_x);}
1292inline _LIBCPP_HIDE_FROM_ABI float lgamma(float __x) _NOEXCEPT {return __builtin_lgammaf(__x);}
1293
1294template <class = int>
1295_LIBCPP_HIDE_FROM_ABI double lgamma(double __x) _NOEXCEPT {
1296 return __builtin_lgamma(__x);
1297}
1298
1299inline _LIBCPP_HIDE_FROM_ABI long double lgamma(long double __x) _NOEXCEPT {return __builtin_lgammal(__x);}
13781300
13791301template <class _A1>
1380inline _LIBCPP_INLINE_VISIBILITY
1302inline _LIBCPP_HIDE_FROM_ABI
13811303typename std::enable_if<std::is_integral<_A1>::value, double>::type
1382lgamma(_A1 __lcpp_x) _NOEXCEPT {return ::lgamma((double)__lcpp_x);}
1304lgamma(_A1 __x) _NOEXCEPT {return __builtin_lgamma((double)__x);}
13831305
13841306// llrint
13851307
1386inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __lcpp_x) _NOEXCEPT
1308inline _LIBCPP_HIDE_FROM_ABI long long llrint(float __x) _NOEXCEPT
13871309{
1388#if __has_builtin(__builtin_llrintf)
1389 return __builtin_llrintf(__lcpp_x);
1390#else
1391 return ::llrintf(__lcpp_x);
1392#endif
1310 return __builtin_llrintf(__x);
1311}
1312
1313template <class = int>
1314_LIBCPP_HIDE_FROM_ABI long long llrint(double __x) _NOEXCEPT {
1315 return __builtin_llrint(__x);
13931316}
1394inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __lcpp_x) _NOEXCEPT
1317
1318inline _LIBCPP_HIDE_FROM_ABI long long llrint(long double __x) _NOEXCEPT
13951319{
1396#if __has_builtin(__builtin_llrintl)
1397 return __builtin_llrintl(__lcpp_x);
1398#else
1399 return ::llrintl(__lcpp_x);
1400#endif
1320 return __builtin_llrintl(__x);
14011321}
14021322
14031323template <class _A1>
1404inline _LIBCPP_INLINE_VISIBILITY
1324inline _LIBCPP_HIDE_FROM_ABI
14051325typename std::enable_if<std::is_integral<_A1>::value, long long>::type
1406llrint(_A1 __lcpp_x) _NOEXCEPT
1326llrint(_A1 __x) _NOEXCEPT
14071327{
1408#if __has_builtin(__builtin_llrint)
1409 return __builtin_llrint((double)__lcpp_x);
1410#else
1411 return ::llrint((double)__lcpp_x);
1412#endif
1328 return __builtin_llrint((double)__x);
14131329}
14141330
14151331// llround
14161332
1417inline _LIBCPP_INLINE_VISIBILITY long long llround(float __lcpp_x) _NOEXCEPT
1333inline _LIBCPP_HIDE_FROM_ABI long long llround(float __x) _NOEXCEPT
14181334{
1419#if __has_builtin(__builtin_llroundf)
1420 return __builtin_llroundf(__lcpp_x);
1421#else
1422 return ::llroundf(__lcpp_x);
1423#endif
1335 return __builtin_llroundf(__x);
1336}
1337
1338template <class = int>
1339_LIBCPP_HIDE_FROM_ABI long long llround(double __x) _NOEXCEPT {
1340 return __builtin_llround(__x);
14241341}
1425inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __lcpp_x) _NOEXCEPT
1342
1343inline _LIBCPP_HIDE_FROM_ABI long long llround(long double __x) _NOEXCEPT
14261344{
1427#if __has_builtin(__builtin_llroundl)
1428 return __builtin_llroundl(__lcpp_x);
1429#else
1430 return ::llroundl(__lcpp_x);
1431#endif
1345 return __builtin_llroundl(__x);
14321346}
14331347
14341348template <class _A1>
1435inline _LIBCPP_INLINE_VISIBILITY
1349inline _LIBCPP_HIDE_FROM_ABI
14361350typename std::enable_if<std::is_integral<_A1>::value, long long>::type
1437llround(_A1 __lcpp_x) _NOEXCEPT
1351llround(_A1 __x) _NOEXCEPT
14381352{
1439#if __has_builtin(__builtin_llround)
1440 return __builtin_llround((double)__lcpp_x);
1441#else
1442 return ::llround((double)__lcpp_x);
1443#endif
1353 return __builtin_llround((double)__x);
14441354}
14451355
14461356// log1p
14471357
1448inline _LIBCPP_INLINE_VISIBILITY float log1p(float __lcpp_x) _NOEXCEPT {return ::log1pf(__lcpp_x);}
1449inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __lcpp_x) _NOEXCEPT {return ::log1pl(__lcpp_x);}
1358inline _LIBCPP_HIDE_FROM_ABI float log1p(float __x) _NOEXCEPT {return __builtin_log1pf(__x);}
1359
1360template <class = int>
1361_LIBCPP_HIDE_FROM_ABI double log1p(double __x) _NOEXCEPT {
1362 return __builtin_log1p(__x);
1363}
1364
1365inline _LIBCPP_HIDE_FROM_ABI long double log1p(long double __x) _NOEXCEPT {return __builtin_log1pl(__x);}
14501366
14511367template <class _A1>
1452inline _LIBCPP_INLINE_VISIBILITY
1368inline _LIBCPP_HIDE_FROM_ABI
14531369typename std::enable_if<std::is_integral<_A1>::value, double>::type
1454log1p(_A1 __lcpp_x) _NOEXCEPT {return ::log1p((double)__lcpp_x);}
1370log1p(_A1 __x) _NOEXCEPT {return __builtin_log1p((double)__x);}
14551371
14561372// log2
14571373
1458inline _LIBCPP_INLINE_VISIBILITY float log2(float __lcpp_x) _NOEXCEPT {return ::log2f(__lcpp_x);}
1459inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __lcpp_x) _NOEXCEPT {return ::log2l(__lcpp_x);}
1374inline _LIBCPP_HIDE_FROM_ABI float log2(float __x) _NOEXCEPT {return __builtin_log2f(__x);}
1375
1376template <class = int>
1377_LIBCPP_HIDE_FROM_ABI double log2(double __x) _NOEXCEPT {
1378 return __builtin_log2(__x);
1379}
1380
1381inline _LIBCPP_HIDE_FROM_ABI long double log2(long double __x) _NOEXCEPT {return __builtin_log2l(__x);}
14601382
14611383template <class _A1>
1462inline _LIBCPP_INLINE_VISIBILITY
1384inline _LIBCPP_HIDE_FROM_ABI
14631385typename std::enable_if<std::is_integral<_A1>::value, double>::type
1464log2(_A1 __lcpp_x) _NOEXCEPT {return ::log2((double)__lcpp_x);}
1386log2(_A1 __x) _NOEXCEPT {return __builtin_log2((double)__x);}
14651387
14661388// logb
14671389
1468inline _LIBCPP_INLINE_VISIBILITY float logb(float __lcpp_x) _NOEXCEPT {return ::logbf(__lcpp_x);}
1469inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __lcpp_x) _NOEXCEPT {return ::logbl(__lcpp_x);}
1390inline _LIBCPP_HIDE_FROM_ABI float logb(float __x) _NOEXCEPT {return __builtin_logbf(__x);}
1391
1392template <class = int>
1393_LIBCPP_HIDE_FROM_ABI double logb(double __x) _NOEXCEPT {
1394 return __builtin_logb(__x);
1395}
1396
1397inline _LIBCPP_HIDE_FROM_ABI long double logb(long double __x) _NOEXCEPT {return __builtin_logbl(__x);}
14701398
14711399template <class _A1>
1472inline _LIBCPP_INLINE_VISIBILITY
1400inline _LIBCPP_HIDE_FROM_ABI
14731401typename std::enable_if<std::is_integral<_A1>::value, double>::type
1474logb(_A1 __lcpp_x) _NOEXCEPT {return ::logb((double)__lcpp_x);}
1402logb(_A1 __x) _NOEXCEPT {return __builtin_logb((double)__x);}
14751403
14761404// lrint
14771405
1478inline _LIBCPP_INLINE_VISIBILITY long lrint(float __lcpp_x) _NOEXCEPT
1406inline _LIBCPP_HIDE_FROM_ABI long lrint(float __x) _NOEXCEPT
14791407{
1480#if __has_builtin(__builtin_lrintf)
1481 return __builtin_lrintf(__lcpp_x);
1482#else
1483 return ::lrintf(__lcpp_x);
1484#endif
1408 return __builtin_lrintf(__x);
14851409}
1486inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __lcpp_x) _NOEXCEPT
1410
1411template <class = int>
1412_LIBCPP_HIDE_FROM_ABI long lrint(double __x) _NOEXCEPT {
1413 return __builtin_lrint(__x);
1414}
1415
1416inline _LIBCPP_HIDE_FROM_ABI long lrint(long double __x) _NOEXCEPT
14871417{
1488#if __has_builtin(__builtin_lrintl)
1489 return __builtin_lrintl(__lcpp_x);
1490#else
1491 return ::lrintl(__lcpp_x);
1492#endif
1418 return __builtin_lrintl(__x);
14931419}
14941420
14951421template <class _A1>
1496inline _LIBCPP_INLINE_VISIBILITY
1422inline _LIBCPP_HIDE_FROM_ABI
14971423typename std::enable_if<std::is_integral<_A1>::value, long>::type
1498lrint(_A1 __lcpp_x) _NOEXCEPT
1424lrint(_A1 __x) _NOEXCEPT
14991425{
1500#if __has_builtin(__builtin_lrint)
1501 return __builtin_lrint((double)__lcpp_x);
1502#else
1503 return ::lrint((double)__lcpp_x);
1504#endif
1426 return __builtin_lrint((double)__x);
15051427}
15061428
15071429// lround
15081430
1509inline _LIBCPP_INLINE_VISIBILITY long lround(float __lcpp_x) _NOEXCEPT
1431inline _LIBCPP_HIDE_FROM_ABI long lround(float __x) _NOEXCEPT
15101432{
1511#if __has_builtin(__builtin_lroundf)
1512 return __builtin_lroundf(__lcpp_x);
1513#else
1514 return ::lroundf(__lcpp_x);
1515#endif
1433 return __builtin_lroundf(__x);
15161434}
1517inline _LIBCPP_INLINE_VISIBILITY long lround(long double __lcpp_x) _NOEXCEPT
1435
1436template <class = int>
1437_LIBCPP_HIDE_FROM_ABI long lround(double __x) _NOEXCEPT {
1438 return __builtin_lround(__x);
1439}
1440
1441inline _LIBCPP_HIDE_FROM_ABI long lround(long double __x) _NOEXCEPT
15181442{
1519#if __has_builtin(__builtin_lroundl)
1520 return __builtin_lroundl(__lcpp_x);
1521#else
1522 return ::lroundl(__lcpp_x);
1523#endif
1443 return __builtin_lroundl(__x);
15241444}
15251445
15261446template <class _A1>
1527inline _LIBCPP_INLINE_VISIBILITY
1447inline _LIBCPP_HIDE_FROM_ABI
15281448typename std::enable_if<std::is_integral<_A1>::value, long>::type
1529lround(_A1 __lcpp_x) _NOEXCEPT
1449lround(_A1 __x) _NOEXCEPT
15301450{
1531#if __has_builtin(__builtin_lround)
1532 return __builtin_lround((double)__lcpp_x);
1533#else
1534 return ::lround((double)__lcpp_x);
1535#endif
1451 return __builtin_lround((double)__x);
15361452}
15371453
15381454// nan
15391455
15401456// nearbyint
15411457
1542inline _LIBCPP_INLINE_VISIBILITY float nearbyint(float __lcpp_x) _NOEXCEPT {return ::nearbyintf(__lcpp_x);}
1543inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __lcpp_x) _NOEXCEPT {return ::nearbyintl(__lcpp_x);}
1458_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT {return __builtin_nearbyintf(__x);}
1459
1460template <class = int>
1461_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double nearbyint(double __x) _NOEXCEPT {
1462 return __builtin_nearbyint(__x);
1463}
1464
1465_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT {return __builtin_nearbyintl(__x);}
15441466
15451467template <class _A1>
1546inline _LIBCPP_INLINE_VISIBILITY
1468_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
15471469typename std::enable_if<std::is_integral<_A1>::value, double>::type
1548nearbyint(_A1 __lcpp_x) _NOEXCEPT {return ::nearbyint((double)__lcpp_x);}
1470nearbyint(_A1 __x) _NOEXCEPT {return __builtin_nearbyint((double)__x);}
15491471
15501472// nextafter
15511473
1552inline _LIBCPP_INLINE_VISIBILITY float nextafter(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::nextafterf(__lcpp_x, __lcpp_y);}
1553inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nextafterl(__lcpp_x, __lcpp_y);}
1474inline _LIBCPP_HIDE_FROM_ABI float nextafter(float __x, float __y) _NOEXCEPT {return __builtin_nextafterf(__x, __y);}
1475
1476template <class = int>
1477_LIBCPP_HIDE_FROM_ABI double nextafter(double __x, double __y) _NOEXCEPT {
1478 return __builtin_nextafter(__x, __y);
1479}
1480
1481inline _LIBCPP_HIDE_FROM_ABI long double nextafter(long double __x, long double __y) _NOEXCEPT {return __builtin_nextafterl(__x, __y);}
15541482
15551483template <class _A1, class _A2>
1556inline _LIBCPP_INLINE_VISIBILITY
1484inline _LIBCPP_HIDE_FROM_ABI
15571485typename std::__enable_if_t
15581486<
15591487 std::is_arithmetic<_A1>::value &&
15601488 std::is_arithmetic<_A2>::value,
15611489 std::__promote<_A1, _A2>
15621490>::type
1563nextafter(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1491nextafter(_A1 __x, _A2 __y) _NOEXCEPT
15641492{
15651493 typedef typename std::__promote<_A1, _A2>::type __result_type;
15661494 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
15671495 std::_IsSame<_A2, __result_type>::value)), "");
1568 return ::nextafter((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1496 return ::nextafter((__result_type)__x, (__result_type)__y);
15691497}
15701498
15711499// nexttoward
15721500
1573inline _LIBCPP_INLINE_VISIBILITY float nexttoward(float __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttowardf(__lcpp_x, __lcpp_y);}
1574inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttowardl(__lcpp_x, __lcpp_y);}
1501inline _LIBCPP_HIDE_FROM_ABI float nexttoward(float __x, long double __y) _NOEXCEPT {return __builtin_nexttowardf(__x, __y);}
1502
1503template <class = int>
1504_LIBCPP_HIDE_FROM_ABI double nexttoward(double __x, long double __y) _NOEXCEPT {
1505 return __builtin_nexttoward(__x, __y);
1506}
1507
1508inline _LIBCPP_HIDE_FROM_ABI long double nexttoward(long double __x, long double __y) _NOEXCEPT {return __builtin_nexttowardl(__x, __y);}
15751509
15761510template <class _A1>
1577inline _LIBCPP_INLINE_VISIBILITY
1511inline _LIBCPP_HIDE_FROM_ABI
15781512typename std::enable_if<std::is_integral<_A1>::value, double>::type
1579nexttoward(_A1 __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttoward((double)__lcpp_x, __lcpp_y);}
1513nexttoward(_A1 __x, long double __y) _NOEXCEPT {return __builtin_nexttoward((double)__x, __y);}
15801514
15811515// remainder
15821516
1583inline _LIBCPP_INLINE_VISIBILITY float remainder(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::remainderf(__lcpp_x, __lcpp_y);}
1584inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::remainderl(__lcpp_x, __lcpp_y);}
1517inline _LIBCPP_HIDE_FROM_ABI float remainder(float __x, float __y) _NOEXCEPT {return __builtin_remainderf(__x, __y);}
1518
1519template <class = int>
1520_LIBCPP_HIDE_FROM_ABI double remainder(double __x, double __y) _NOEXCEPT {
1521 return __builtin_remainder(__x, __y);
1522}
1523
1524inline _LIBCPP_HIDE_FROM_ABI long double remainder(long double __x, long double __y) _NOEXCEPT {return __builtin_remainderl(__x, __y);}
15851525
15861526template <class _A1, class _A2>
1587inline _LIBCPP_INLINE_VISIBILITY
1527inline _LIBCPP_HIDE_FROM_ABI
15881528typename std::__enable_if_t
15891529<
15901530 std::is_arithmetic<_A1>::value &&
15911531 std::is_arithmetic<_A2>::value,
15921532 std::__promote<_A1, _A2>
15931533>::type
1594remainder(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1534remainder(_A1 __x, _A2 __y) _NOEXCEPT
15951535{
15961536 typedef typename std::__promote<_A1, _A2>::type __result_type;
15971537 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
15981538 std::_IsSame<_A2, __result_type>::value)), "");
1599 return ::remainder((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1539 return ::remainder((__result_type)__x, (__result_type)__y);
16001540}
16011541
16021542// remquo
16031543
1604inline _LIBCPP_INLINE_VISIBILITY float remquo(float __lcpp_x, float __lcpp_y, int* __lcpp_z) _NOEXCEPT {return ::remquof(__lcpp_x, __lcpp_y, __lcpp_z);}
1605inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __lcpp_x, long double __lcpp_y, int* __lcpp_z) _NOEXCEPT {return ::remquol(__lcpp_x, __lcpp_y, __lcpp_z);}
1544inline _LIBCPP_HIDE_FROM_ABI float remquo(float __x, float __y, int* __z) _NOEXCEPT {return __builtin_remquof(__x, __y, __z);}
1545
1546template <class = int>
1547_LIBCPP_HIDE_FROM_ABI double remquo(double __x, double __y, int* __z) _NOEXCEPT {
1548 return __builtin_remquo(__x, __y, __z);
1549}
1550
1551inline _LIBCPP_HIDE_FROM_ABI long double remquo(long double __x, long double __y, int* __z) _NOEXCEPT {return __builtin_remquol(__x, __y, __z);}
16061552
16071553template <class _A1, class _A2>
1608inline _LIBCPP_INLINE_VISIBILITY
1554inline _LIBCPP_HIDE_FROM_ABI
16091555typename std::__enable_if_t
16101556<
16111557 std::is_arithmetic<_A1>::value &&
16121558 std::is_arithmetic<_A2>::value,
16131559 std::__promote<_A1, _A2>
16141560>::type
1615remquo(_A1 __lcpp_x, _A2 __lcpp_y, int* __lcpp_z) _NOEXCEPT
1561remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT
16161562{
16171563 typedef typename std::__promote<_A1, _A2>::type __result_type;
16181564 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
16191565 std::_IsSame<_A2, __result_type>::value)), "");
1620 return ::remquo((__result_type)__lcpp_x, (__result_type)__lcpp_y, __lcpp_z);
1566 return ::remquo((__result_type)__x, (__result_type)__y, __z);
16211567}
16221568
16231569// rint
16241570
1625inline _LIBCPP_INLINE_VISIBILITY float rint(float __lcpp_x) _NOEXCEPT
1571_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT
16261572{
1627#if __has_builtin(__builtin_rintf)
1628 return __builtin_rintf(__lcpp_x);
1629#else
1630 return ::rintf(__lcpp_x);
1631#endif
1573 return __builtin_rintf(__x);
16321574}
1633inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __lcpp_x) _NOEXCEPT
1575
1576template <class = int>
1577_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double rint(double __x) _NOEXCEPT {
1578 return __builtin_rint(__x);
1579}
1580
1581_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT
16341582{
1635#if __has_builtin(__builtin_rintl)
1636 return __builtin_rintl(__lcpp_x);
1637#else
1638 return ::rintl(__lcpp_x);
1639#endif
1583 return __builtin_rintl(__x);
16401584}
16411585
16421586template <class _A1>
1643inline _LIBCPP_INLINE_VISIBILITY
1587_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
16441588typename std::enable_if<std::is_integral<_A1>::value, double>::type
1645rint(_A1 __lcpp_x) _NOEXCEPT
1589rint(_A1 __x) _NOEXCEPT
16461590{
1647#if __has_builtin(__builtin_rint)
1648 return __builtin_rint((double)__lcpp_x);
1649#else
1650 return ::rint((double)__lcpp_x);
1651#endif
1591 return __builtin_rint((double)__x);
16521592}
16531593
16541594// round
16551595
1656inline _LIBCPP_INLINE_VISIBILITY float round(float __lcpp_x) _NOEXCEPT
1596_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT
16571597{
1658#if __has_builtin(__builtin_round)
1659 return __builtin_round(__lcpp_x);
1660#else
1661 return ::round(__lcpp_x);
1662#endif
1598 return __builtin_round(__x);
16631599}
1664inline _LIBCPP_INLINE_VISIBILITY long double round(long double __lcpp_x) _NOEXCEPT
1600
1601template <class = int>
1602_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double round(double __x) _NOEXCEPT {
1603 return __builtin_round(__x);
1604}
1605
1606_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT
16651607{
1666#if __has_builtin(__builtin_roundl)
1667 return __builtin_roundl(__lcpp_x);
1668#else
1669 return ::roundl(__lcpp_x);
1670#endif
1608 return __builtin_roundl(__x);
16711609}
16721610
16731611template <class _A1>
1674inline _LIBCPP_INLINE_VISIBILITY
1612_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
16751613typename std::enable_if<std::is_integral<_A1>::value, double>::type
1676round(_A1 __lcpp_x) _NOEXCEPT
1614round(_A1 __x) _NOEXCEPT
16771615{
1678#if __has_builtin(__builtin_round)
1679 return __builtin_round((double)__lcpp_x);
1680#else
1681 return ::round((double)__lcpp_x);
1682#endif
1616 return __builtin_round((double)__x);
16831617}
16841618
16851619// scalbln
16861620
1687inline _LIBCPP_INLINE_VISIBILITY float scalbln(float __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalblnf(__lcpp_x, __lcpp_y);}
1688inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalblnl(__lcpp_x, __lcpp_y);}
1621inline _LIBCPP_HIDE_FROM_ABI float scalbln(float __x, long __y) _NOEXCEPT {return __builtin_scalblnf(__x, __y);}
1622
1623template <class = int>
1624_LIBCPP_HIDE_FROM_ABI double scalbln(double __x, long __y) _NOEXCEPT {
1625 return __builtin_scalbln(__x, __y);
1626}
1627
1628inline _LIBCPP_HIDE_FROM_ABI long double scalbln(long double __x, long __y) _NOEXCEPT {return __builtin_scalblnl(__x, __y);}
16891629
16901630template <class _A1>
1691inline _LIBCPP_INLINE_VISIBILITY
1631inline _LIBCPP_HIDE_FROM_ABI
16921632typename std::enable_if<std::is_integral<_A1>::value, double>::type
1693scalbln(_A1 __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalbln((double)__lcpp_x, __lcpp_y);}
1633scalbln(_A1 __x, long __y) _NOEXCEPT {return __builtin_scalbln((double)__x, __y);}
16941634
16951635// scalbn
16961636
1697inline _LIBCPP_INLINE_VISIBILITY float scalbn(float __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbnf(__lcpp_x, __lcpp_y);}
1698inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbnl(__lcpp_x, __lcpp_y);}
1637inline _LIBCPP_HIDE_FROM_ABI float scalbn(float __x, int __y) _NOEXCEPT {return __builtin_scalbnf(__x, __y);}
1638
1639template <class = int>
1640_LIBCPP_HIDE_FROM_ABI double scalbn(double __x, int __y) _NOEXCEPT {
1641 return __builtin_scalbn(__x, __y);
1642}
1643
1644inline _LIBCPP_HIDE_FROM_ABI long double scalbn(long double __x, int __y) _NOEXCEPT {return __builtin_scalbnl(__x, __y);}
16991645
17001646template <class _A1>
1701inline _LIBCPP_INLINE_VISIBILITY
1647inline _LIBCPP_HIDE_FROM_ABI
17021648typename std::enable_if<std::is_integral<_A1>::value, double>::type
1703scalbn(_A1 __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbn((double)__lcpp_x, __lcpp_y);}
1649scalbn(_A1 __x, int __y) _NOEXCEPT {return __builtin_scalbn((double)__x, __y);}
17041650
17051651// tgamma
17061652
1707inline _LIBCPP_INLINE_VISIBILITY float tgamma(float __lcpp_x) _NOEXCEPT {return ::tgammaf(__lcpp_x);}
1708inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __lcpp_x) _NOEXCEPT {return ::tgammal(__lcpp_x);}
1653inline _LIBCPP_HIDE_FROM_ABI float tgamma(float __x) _NOEXCEPT {return __builtin_tgammaf(__x);}
1654
1655template <class = int>
1656_LIBCPP_HIDE_FROM_ABI double tgamma(double __x) _NOEXCEPT {
1657 return __builtin_tgamma(__x);
1658}
1659
1660inline _LIBCPP_HIDE_FROM_ABI long double tgamma(long double __x) _NOEXCEPT {return __builtin_tgammal(__x);}
17091661
17101662template <class _A1>
1711inline _LIBCPP_INLINE_VISIBILITY
1663inline _LIBCPP_HIDE_FROM_ABI
17121664typename std::enable_if<std::is_integral<_A1>::value, double>::type
1713tgamma(_A1 __lcpp_x) _NOEXCEPT {return ::tgamma((double)__lcpp_x);}
1665tgamma(_A1 __x) _NOEXCEPT {return __builtin_tgamma((double)__x);}
17141666
17151667// trunc
17161668
1717inline _LIBCPP_INLINE_VISIBILITY float trunc(float __lcpp_x) _NOEXCEPT
1669_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT
17181670{
1719#if __has_builtin(__builtin_trunc)
1720 return __builtin_trunc(__lcpp_x);
1721#else
1722 return ::trunc(__lcpp_x);
1723#endif
1671 return __builtin_trunc(__x);
17241672}
1725inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __lcpp_x) _NOEXCEPT
1673
1674template <class = int>
1675_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double trunc(double __x) _NOEXCEPT {
1676 return __builtin_trunc(__x);
1677}
1678
1679_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT
17261680{
1727#if __has_builtin(__builtin_truncl)
1728 return __builtin_truncl(__lcpp_x);
1729#else
1730 return ::truncl(__lcpp_x);
1731#endif
1681 return __builtin_truncl(__x);
17321682}
17331683
17341684template <class _A1>
1735inline _LIBCPP_INLINE_VISIBILITY
1685_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
17361686typename std::enable_if<std::is_integral<_A1>::value, double>::type
1737trunc(_A1 __lcpp_x) _NOEXCEPT
1687trunc(_A1 __x) _NOEXCEPT
17381688{
1739#if __has_builtin(__builtin_trunc)
1740 return __builtin_trunc((double)__lcpp_x);
1741#else
1742 return ::trunc((double)__lcpp_x);
1743#endif
1689 return __builtin_trunc((double)__x);
17441690}
17451691
17461692} // extern "C++"
lib/libcxx/include/memory+131-230
......@@ -406,16 +406,17 @@ template <class T>
406406struct default_delete
407407{
408408 constexpr default_delete() noexcept = default;
409 template <class U> default_delete(const default_delete<U>&) noexcept;
409 template <class U> constexpr default_delete(const default_delete<U>&) noexcept; // constexpr since C++23
410410
411 void operator()(T*) const noexcept;
411 constexpr void operator()(T*) const noexcept; // constexpr since C++23
412412};
413413
414414template <class T>
415415struct default_delete<T[]>
416416{
417417 constexpr default_delete() noexcept = default;
418 void operator()(T*) const noexcept;
418 template <class U> constexpr default_delete(const default_delete <U[]>&) noexcept; // constexpr since C++23
419 constexpr void operator()(T*) const noexcept; // constexpr since C++23
419420 template <class U> void operator()(U*) const = delete;
420421};
421422
......@@ -429,36 +430,37 @@ public:
429430
430431 // constructors
431432 constexpr unique_ptr() noexcept;
432 explicit unique_ptr(pointer p) noexcept;
433 unique_ptr(pointer p, see below d1) noexcept;
434 unique_ptr(pointer p, see below d2) noexcept;
435 unique_ptr(unique_ptr&& u) noexcept;
436 unique_ptr(nullptr_t) noexcept : unique_ptr() { }
433 constexpr explicit unique_ptr(pointer p) noexcept; // constexpr since C++23
434 constexpr unique_ptr(pointer p, see below d1) noexcept; // constexpr since C++23
435 constexpr unique_ptr(pointer p, see below d2) noexcept; // constexpr since C++23
436 constexpr unique_ptr(unique_ptr&& u) noexcept; // constexpr since C++23
437 constexpr unique_ptr(nullptr_t) noexcept : unique_ptr() { }
437438 template <class U, class E>
438 unique_ptr(unique_ptr<U, E>&& u) noexcept;
439 constexpr unique_ptr(unique_ptr<U, E>&& u) noexcept; // constexpr since C++23
439440 template <class U>
440 unique_ptr(auto_ptr<U>&& u) noexcept; // removed in C++17
441 unique_ptr(auto_ptr<U>&& u) noexcept; // removed in C++17
441442
442443 // destructor
443 ~unique_ptr();
444 constexpr ~unique_ptr(); // constexpr since C++23
444445
445446 // assignment
446 unique_ptr& operator=(unique_ptr&& u) noexcept;
447 template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;
448 unique_ptr& operator=(nullptr_t) noexcept;
447 constexpr unique_ptr& operator=(unique_ptr&& u) noexcept; // constexpr since C++23
448 template <class U, class E>
449 constexpr unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept; // constexpr since C++23
450 constexpr unique_ptr& operator=(nullptr_t) noexcept; // constexpr since C++23
449451
450452 // observers
451 typename add_lvalue_reference<T>::type operator*() const;
452 pointer operator->() const noexcept;
453 pointer get() const noexcept;
454 deleter_type& get_deleter() noexcept;
455 const deleter_type& get_deleter() const noexcept;
456 explicit operator bool() const noexcept;
453 typename constexpr add_lvalue_reference<T>::type operator*() const; // constexpr since C++23
454 constexpr pointer operator->() const noexcept; // constexpr since C++23
455 constexpr pointer get() const noexcept; // constexpr since C++23
456 constexpr deleter_type& get_deleter() noexcept; // constexpr since C++23
457 constexpr const deleter_type& get_deleter() const noexcept; // constexpr since C++23
458 constexpr explicit operator bool() const noexcept; // constexpr since C++23
457459
458460 // modifiers
459 pointer release() noexcept;
460 void reset(pointer p = pointer()) noexcept;
461 void swap(unique_ptr& u) noexcept;
461 constexpr pointer release() noexcept; // constexpr since C++23
462 constexpr void reset(pointer p = pointer()) noexcept; // constexpr since C++23
463 constexpr void swap(unique_ptr& u) noexcept; // constexpr since C++23
462464};
463465
464466template <class T, class D>
......@@ -471,41 +473,45 @@ public:
471473
472474 // constructors
473475 constexpr unique_ptr() noexcept;
474 explicit unique_ptr(pointer p) noexcept;
475 unique_ptr(pointer p, see below d) noexcept;
476 unique_ptr(pointer p, see below d) noexcept;
477 unique_ptr(unique_ptr&& u) noexcept;
478 unique_ptr(nullptr_t) noexcept : unique_ptr() { }
476 constexpr explicit unique_ptr(pointer p) noexcept; // constexpr since C++23
477 constexpr unique_ptr(pointer p, see below d) noexcept; // constexpr since C++23
478 constexpr unique_ptr(pointer p, see below d) noexcept; // constexpr since C++23
479 constexpr unique_ptr(unique_ptr&& u) noexcept; // constexpr since C++23
480 template <class U, class E>
481 constexpr unique_ptr(unique_ptr <U, E>&& u) noexcept; // constexpr since C++23
482 constexpr unique_ptr(nullptr_t) noexcept : unique_ptr() { }
479483
480484 // destructor
481 ~unique_ptr();
485 constexpr ~unique_ptr(); // constexpr since C++23
482486
483487 // assignment
484 unique_ptr& operator=(unique_ptr&& u) noexcept;
485 unique_ptr& operator=(nullptr_t) noexcept;
488 constexpr unique_ptr& operator=(unique_ptr&& u) noexcept; // constexpr since C++23
489 template <class U, class E>
490 constexpr unique_ptr& operator=(unique_ptr <U, E>&& u) noexcept; // constexpr since C++23
491 constexpr unique_ptr& operator=(nullptr_t) noexcept; // constexpr since C++23
486492
487493 // observers
488 T& operator[](size_t i) const;
489 pointer get() const noexcept;
490 deleter_type& get_deleter() noexcept;
491 const deleter_type& get_deleter() const noexcept;
492 explicit operator bool() const noexcept;
494 constexpr T& operator[](size_t i) const; // constexpr since C++23
495 constexpr pointer get() const noexcept; // constexpr since C++23
496 constexpr deleter_type& get_deleter() noexcept; // constexpr since C++23
497 constexpr const deleter_type& get_deleter() const noexcept; // constexpr since C++23
498 constexpr explicit operator bool() const noexcept; // constexpr since C++23
493499
494500 // modifiers
495 pointer release() noexcept;
496 void reset(pointer p = pointer()) noexcept;
497 void reset(nullptr_t) noexcept;
501 constexpr pointer release() noexcept; // constexpr since C++23
502 constexpr void reset(pointer p = pointer()) noexcept; // constexpr since C++23
503 constexpr void reset(nullptr_t) noexcept; // constexpr since C++23
498504 template <class U> void reset(U) = delete;
499 void swap(unique_ptr& u) noexcept;
505 constexpr void swap(unique_ptr& u) noexcept; // constexpr since C++23
500506};
501507
502508template <class T, class D>
503 void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept;
509 constexpr void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept; // constexpr since C++23
504510
505511template <class T1, class D1, class T2, class D2>
506 bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
512 constexpr bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); // constexpr since C++23
507513template <class T1, class D1, class T2, class D2>
508 bool operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
514 bool operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); // removed in C++20
509515template <class T1, class D1, class T2, class D2>
510516 bool operator<(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
511517template <class T1, class D1, class T2, class D2>
......@@ -514,32 +520,42 @@ template <class T1, class D1, class T2, class D2>
514520 bool operator>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
515521template <class T1, class D1, class T2, class D2>
516522 bool operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
523template<class T1, class D1, class T2, class D2>
524 requires three_way_comparable_with<typename unique_ptr<T1, D1>::pointer,
525 typename unique_ptr<T2, D2>::pointer>
526 compare_three_way_result_t<typename unique_ptr<T1, D1>::pointer,
527 typename unique_ptr<T2, D2>::pointer>
528 operator<=>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); // C++20
517529
518530template <class T, class D>
519 bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept;
531 constexpr bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept; // constexpr since C++23
520532template <class T, class D>
521 bool operator==(nullptr_t, const unique_ptr<T, D>& y) noexcept;
533 bool operator==(nullptr_t, const unique_ptr<T, D>& y) noexcept; // removed in C++20
522534template <class T, class D>
523 bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept;
535 bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept; // removed in C++20
524536template <class T, class D>
525 bool operator!=(nullptr_t, const unique_ptr<T, D>& y) noexcept;
537 bool operator!=(nullptr_t, const unique_ptr<T, D>& y) noexcept; // removed in C++20
526538
527539template <class T, class D>
528 bool operator<(const unique_ptr<T, D>& x, nullptr_t);
540 constexpr bool operator<(const unique_ptr<T, D>& x, nullptr_t); // constexpr since C++23
529541template <class T, class D>
530 bool operator<(nullptr_t, const unique_ptr<T, D>& y);
542 constexpr bool operator<(nullptr_t, const unique_ptr<T, D>& y); // constexpr since C++23
531543template <class T, class D>
532 bool operator<=(const unique_ptr<T, D>& x, nullptr_t);
544 constexpr bool operator<=(const unique_ptr<T, D>& x, nullptr_t); // constexpr since C++23
533545template <class T, class D>
534 bool operator<=(nullptr_t, const unique_ptr<T, D>& y);
546 constexpr bool operator<=(nullptr_t, const unique_ptr<T, D>& y); // constexpr since C++23
535547template <class T, class D>
536 bool operator>(const unique_ptr<T, D>& x, nullptr_t);
548 constexpr bool operator>(const unique_ptr<T, D>& x, nullptr_t); // constexpr since C++23
537549template <class T, class D>
538 bool operator>(nullptr_t, const unique_ptr<T, D>& y);
550 constexpr bool operator>(nullptr_t, const unique_ptr<T, D>& y); // constexpr since C++23
539551template <class T, class D>
540 bool operator>=(const unique_ptr<T, D>& x, nullptr_t);
552 constexpr bool operator>=(const unique_ptr<T, D>& x, nullptr_t); // constexpr since C++23
541553template <class T, class D>
542 bool operator>=(nullptr_t, const unique_ptr<T, D>& y);
554 constexpr bool operator>=(nullptr_t, const unique_ptr<T, D>& y); // constexpr since C++23
555template<class T, class D>
556 requires three_way_comparable<typename unique_ptr<T, D>::pointer>
557 compare_three_way_result_t<typename unique_ptr<T, D>::pointer>
558 constexpr operator<=>(const unique_ptr<T, D>& x, nullptr_t); // C++20, constexpr since C++23
543559
544560class bad_weak_ptr
545561 : public std::exception
......@@ -547,10 +563,19 @@ class bad_weak_ptr
547563 bad_weak_ptr() noexcept;
548564};
549565
550template<class T, class... Args> unique_ptr<T> make_unique(Args&&... args); // C++14
551template<class T> unique_ptr<T> make_unique(size_t n); // C++14
566template<class T, class... Args>
567constexpr unique_ptr<T> make_unique(Args&&... args); // C++14, constexpr since C++23
568template<class T>
569constexpr unique_ptr<T> make_unique(size_t n); // C++14, constexpr since C++23
552570template<class T, class... Args> unspecified make_unique(Args&&...) = delete; // C++14, T == U[N]
553571
572template<class T>
573 constexpr unique_ptr<T> make_unique_for_overwrite(); // T is not array, C++20, constexpr since C++23
574template<class T>
575 constexpr unique_ptr<T> make_unique_for_overwrite(size_t n); // T is U[], C++20, constexpr since C++23
576template<class T, class... Args>
577 unspecified make_unique_for_overwrite(Args&&...) = delete; // T is U[N], C++20
578
554579template<class E, class T, class Y, class D>
555580 basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, unique_ptr<Y, D> const& p);
556581
......@@ -617,40 +642,44 @@ shared_ptr(unique_ptr<T, D>) -> shared_ptr<T>;
617642template<class T, class U>
618643 bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
619644template<class T, class U>
620 bool operator!=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
645 bool operator!=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; // removed in C++20
646template<class T, class U>
647 bool operator<(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; // removed in C++20
621648template<class T, class U>
622 bool operator<(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
649 bool operator>(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; // removed in C++20
623650template<class T, class U>
624 bool operator>(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
651 bool operator<=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; // removed in C++20
625652template<class T, class U>
626 bool operator<=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
653 bool operator>=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; // removed in C++20
627654template<class T, class U>
628 bool operator>=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
655 strong_ordering operator<=>(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept; // C++20
629656
630657template <class T>
631658 bool operator==(const shared_ptr<T>& x, nullptr_t) noexcept;
632659template <class T>
633 bool operator==(nullptr_t, const shared_ptr<T>& y) noexcept;
660 bool operator==(nullptr_t, const shared_ptr<T>& y) noexcept; // removed in C++20
634661template <class T>
635 bool operator!=(const shared_ptr<T>& x, nullptr_t) noexcept;
662 bool operator!=(const shared_ptr<T>& x, nullptr_t) noexcept; // removed in C++20
636663template <class T>
637 bool operator!=(nullptr_t, const shared_ptr<T>& y) noexcept;
664 bool operator!=(nullptr_t, const shared_ptr<T>& y) noexcept; // removed in C++20
638665template <class T>
639 bool operator<(const shared_ptr<T>& x, nullptr_t) noexcept;
666 bool operator<(const shared_ptr<T>& x, nullptr_t) noexcept; // removed in C++20
640667template <class T>
641bool operator<(nullptr_t, const shared_ptr<T>& y) noexcept;
668 bool operator<(nullptr_t, const shared_ptr<T>& y) noexcept; // removed in C++20
642669template <class T>
643 bool operator<=(const shared_ptr<T>& x, nullptr_t) noexcept;
670 bool operator<=(const shared_ptr<T>& x, nullptr_t) noexcept; // removed in C++20
644671template <class T>
645 bool operator<=(nullptr_t, const shared_ptr<T>& y) noexcept;
672 bool operator<=(nullptr_t, const shared_ptr<T>& y) noexcept; // removed in C++20
646673template <class T>
647 bool operator>(const shared_ptr<T>& x, nullptr_t) noexcept;
674 bool operator>(const shared_ptr<T>& x, nullptr_t) noexcept; // removed in C++20
648675template <class T>
649 bool operator>(nullptr_t, const shared_ptr<T>& y) noexcept;
676 bool operator>(nullptr_t, const shared_ptr<T>& y) noexcept; // removed in C++20
650677template <class T>
651 bool operator>=(const shared_ptr<T>& x, nullptr_t) noexcept;
678 bool operator>=(const shared_ptr<T>& x, nullptr_t) noexcept; // removed in C++20
652679template <class T>
653 bool operator>=(nullptr_t, const shared_ptr<T>& y) noexcept;
680 bool operator>=(nullptr_t, const shared_ptr<T>& y) noexcept; // removed in C++20
681template<class T>
682 strong_ordering operator<=>(shared_ptr<T> const& x, nullptr_t) noexcept; // C++20
654683
655684// shared_ptr specialized algorithms:
656685template<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b) noexcept;
......@@ -695,6 +724,16 @@ template<class T> shared_ptr<T>
695724template<class T, class A>
696725 shared_ptr<T> allocate_shared(const A& a, const remove_extent_t<T>& u); // T is U[N] (since C++20)
697726
727template<class T>
728 shared_ptr<T> make_shared_for_overwrite(); // T is not U[], C++20
729template<class T, class A>
730 shared_ptr<T> allocate_shared_for_overwrite(const A& a); // T is not U[], C++20
731
732template<class T>
733 shared_ptr<T> make_shared_for_overwrite(size_t N); // T is U[], C++20
734template<class T, class A>
735 shared_ptr<T> allocate_shared_for_overwrite(const A& a, size_t N); // T is U[], C++20
736
698737template<class T>
699738class weak_ptr
700739{
......@@ -838,11 +877,10 @@ template<size_t N, class T>
838877
839878*/
840879
841#include <__algorithm/copy.h>
842#include <__algorithm/move.h>
843880#include <__assert> // all public C++ headers provide the assertion handler
844881#include <__config>
845882#include <__memory/addressof.h>
883#include <__memory/align.h>
846884#include <__memory/allocate_at_least.h>
847885#include <__memory/allocation_guard.h>
848886#include <__memory/allocator.h>
......@@ -862,172 +900,35 @@ template<size_t N, class T>
862900#include <__memory/uninitialized_algorithms.h>
863901#include <__memory/unique_ptr.h>
864902#include <__memory/uses_allocator.h>
865#include <cstddef>
866#include <cstdint>
867#include <cstring>
868#include <iosfwd>
869#include <new>
870#include <stdexcept>
871#include <tuple>
872#include <type_traits>
873#include <typeinfo>
903#include <__memory/uses_allocator_construction.h>
874904#include <version>
875905
876#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
877# include <iterator>
878# include <utility>
879#endif
880
881906// standard-mandated includes
907
908// [memory.syn]
882909#include <compare>
883910
884911#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
885912# pragma GCC system_header
886913#endif
887914
888_LIBCPP_BEGIN_NAMESPACE_STD
889
890struct __destruct_n
891{
892private:
893 size_t __size_;
894
895 template <class _Tp>
896 _LIBCPP_INLINE_VISIBILITY void __process(_Tp* __p, false_type) _NOEXCEPT
897 {for (size_t __i = 0; __i < __size_; ++__i, ++__p) __p->~_Tp();}
898
899 template <class _Tp>
900 _LIBCPP_INLINE_VISIBILITY void __process(_Tp*, true_type) _NOEXCEPT
901 {}
902
903 _LIBCPP_INLINE_VISIBILITY void __incr(false_type) _NOEXCEPT
904 {++__size_;}
905 _LIBCPP_INLINE_VISIBILITY void __incr(true_type) _NOEXCEPT
906 {}
907
908 _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, false_type) _NOEXCEPT
909 {__size_ = __s;}
910 _LIBCPP_INLINE_VISIBILITY void __set(size_t, true_type) _NOEXCEPT
911 {}
912public:
913 _LIBCPP_INLINE_VISIBILITY explicit __destruct_n(size_t __s) _NOEXCEPT
914 : __size_(__s) {}
915
916 template <class _Tp>
917 _LIBCPP_INLINE_VISIBILITY void __incr() _NOEXCEPT
918 {__incr(integral_constant<bool, is_trivially_destructible<_Tp>::value>());}
919
920 template <class _Tp>
921 _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, _Tp*) _NOEXCEPT
922 {__set(__s, integral_constant<bool, is_trivially_destructible<_Tp>::value>());}
923
924 template <class _Tp>
925 _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __p) _NOEXCEPT
926 {__process(__p, integral_constant<bool, is_trivially_destructible<_Tp>::value>());}
927};
928
929_LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space);
930
931template <typename _Alloc, typename _Traits=allocator_traits<_Alloc> >
932struct __noexcept_move_assign_container : public integral_constant<bool,
933 _Traits::propagate_on_container_move_assignment::value
934#if _LIBCPP_STD_VER > 14
935 || _Traits::is_always_equal::value
936#else
937 && is_nothrow_move_assignable<_Alloc>::value
938#endif
939 > {};
940
941
942template <class _Tp, class _Alloc>
943struct __temp_value {
944 typedef allocator_traits<_Alloc> _Traits;
945
946#ifdef _LIBCPP_CXX03_LANG
947 typename aligned_storage<sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)>::type __v;
948#else
949 union { _Tp __v; };
950#endif
951 _Alloc &__a;
952
953 _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp *__addr() {
954#ifdef _LIBCPP_CXX03_LANG
955 return reinterpret_cast<_Tp*>(std::addressof(__v));
956#else
957 return std::addressof(__v);
958#endif
959 }
960
961 _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp & get() { return *__addr(); }
962
963 template<class... _Args>
964 _LIBCPP_NO_CFI
965 _LIBCPP_CONSTEXPR_AFTER_CXX17 __temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) {
966 _Traits::construct(__a, __addr(), std::forward<_Args>(__args)...);
967 }
968
969 _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__temp_value() { _Traits::destroy(__a, __addr()); }
970};
971
972template<typename _Alloc, typename = void, typename = void>
973struct __is_allocator : false_type {};
974
975template<typename _Alloc>
976struct __is_allocator<_Alloc,
977 typename __void_t<typename _Alloc::value_type>::type,
978 typename __void_t<decltype(declval<_Alloc&>().allocate(size_t(0)))>::type
979 >
980 : true_type {};
981
982// __builtin_new_allocator -- A non-templated helper for allocating and
983// deallocating memory using __builtin_operator_new and
984// __builtin_operator_delete. It should be used in preference to
985// `std::allocator<T>` to avoid additional instantiations.
986struct __builtin_new_allocator {
987 struct __builtin_new_deleter {
988 typedef void* pointer_type;
989
990 _LIBCPP_CONSTEXPR explicit __builtin_new_deleter(size_t __size, size_t __align)
991 : __size_(__size), __align_(__align) {}
992
993 void operator()(void* __p) const _NOEXCEPT {
994 _VSTD::__libcpp_deallocate(__p, __size_, __align_);
995 }
996
997 private:
998 size_t __size_;
999 size_t __align_;
1000 };
1001
1002 typedef unique_ptr<void, __builtin_new_deleter> __holder_t;
1003
1004 static __holder_t __allocate_bytes(size_t __s, size_t __align) {
1005 return __holder_t(_VSTD::__libcpp_allocate(__s, __align),
1006 __builtin_new_deleter(__s, __align));
1007 }
1008
1009 static void __deallocate_bytes(void* __p, size_t __s,
1010 size_t __align) _NOEXCEPT {
1011 _VSTD::__libcpp_deallocate(__p, __s, __align);
1012 }
1013
1014 template <class _Tp>
1015 _LIBCPP_NODEBUG _LIBCPP_ALWAYS_INLINE
1016 static __holder_t __allocate_type(size_t __n) {
1017 return __allocate_bytes(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
1018 }
1019
1020 template <class _Tp>
1021 _LIBCPP_NODEBUG _LIBCPP_ALWAYS_INLINE
1022 static void __deallocate_type(void* __p, size_t __n) _NOEXCEPT {
1023 __deallocate_bytes(__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
1024 }
1025};
1026
1027_LIBCPP_END_NAMESPACE_STD
1028
1029915#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
1030916# include <__pstl_memory>
1031917#endif
1032918
919#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
920# include <concepts>
921# include <cstddef>
922# include <cstdint>
923# include <cstring>
924# include <iosfwd>
925# include <iterator>
926# include <new>
927# include <stdexcept>
928# include <tuple>
929# include <type_traits>
930# include <typeinfo>
931# include <utility>
932#endif
933
1033934#endif // _LIBCPP_MEMORY
lib/libcxx/include/memory_resource created+65
......@@ -0,0 +1,65 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_MEMORY_RESOURCE
11#define _LIBCPP_MEMORY_RESOURCE
12
13/**
14 memory_resource synopsis
15
16// C++17
17
18namespace std::pmr {
19
20 class memory_resource;
21
22 bool operator==(const memory_resource& a,
23 const memory_resource& b) noexcept;
24 bool operator!=(const memory_resource& a,
25 const memory_resource& b) noexcept;
26
27 template <class Tp> class polymorphic_allocator;
28
29 template <class T1, class T2>
30 bool operator==(const polymorphic_allocator<T1>& a,
31 const polymorphic_allocator<T2>& b) noexcept;
32 template <class T1, class T2>
33 bool operator!=(const polymorphic_allocator<T1>& a,
34 const polymorphic_allocator<T2>& b) noexcept;
35
36 // Global memory resources
37 memory_resource* set_default_resource(memory_resource* r) noexcept;
38 memory_resource* get_default_resource() noexcept;
39 memory_resource* new_delete_resource() noexcept;
40 memory_resource* null_memory_resource() noexcept;
41
42 // Pool resource classes
43 struct pool_options;
44 class synchronized_pool_resource;
45 class unsynchronized_pool_resource;
46 class monotonic_buffer_resource;
47
48} // namespace std::pmr
49
50 */
51
52#include <__config>
53#include <__memory_resource/memory_resource.h>
54#include <__memory_resource/monotonic_buffer_resource.h>
55#include <__memory_resource/polymorphic_allocator.h>
56#include <__memory_resource/pool_options.h>
57#include <__memory_resource/synchronized_pool_resource.h>
58#include <__memory_resource/unsynchronized_pool_resource.h>
59#include <version>
60
61#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
62# pragma GCC system_header
63#endif
64
65#endif /* _LIBCPP_MEMORY_RESOURCE */
lib/libcxx/include/mutex+19-16
......@@ -188,20 +188,16 @@ template<class Callable, class ...Args>
188188
189189#include <__assert> // all public C++ headers provide the assertion handler
190190#include <__config>
191#include <__memory/shared_ptr.h>
191192#include <__mutex_base>
192193#include <__threading_support>
193194#include <__utility/forward.h>
194195#include <cstdint>
195#include <memory>
196196#ifndef _LIBCPP_CXX03_LANG
197197# include <tuple>
198198#endif
199199#include <version>
200200
201#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
202# include <functional>
203#endif
204
205201#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
206202# pragma GCC system_header
207203#endif
......@@ -329,7 +325,7 @@ recursive_timed_mutex::try_lock_until(const chrono::time_point<_Clock, _Duration
329325}
330326
331327template <class _L0, class _L1>
332int
328_LIBCPP_HIDE_FROM_ABI int
333329try_lock(_L0& __l0, _L1& __l1)
334330{
335331 unique_lock<_L0> __u0(__l0, try_to_lock);
......@@ -349,14 +345,14 @@ try_lock(_L0& __l0, _L1& __l1)
349345#ifndef _LIBCPP_CXX03_LANG
350346
351347template <class _L0, class _L1, class _L2, class... _L3>
352int
348_LIBCPP_HIDE_FROM_ABI int
353349try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3)
354350{
355351 int __r = 0;
356352 unique_lock<_L0> __u0(__l0, try_to_lock);
357353 if (__u0.owns_lock())
358354 {
359 __r = try_lock(__l1, __l2, __l3...);
355 __r = std::try_lock(__l1, __l2, __l3...);
360356 if (__r == -1)
361357 __u0.release();
362358 else
......@@ -368,7 +364,7 @@ try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3)
368364#endif // _LIBCPP_CXX03_LANG
369365
370366template <class _L0, class _L1>
371void
367_LIBCPP_HIDE_FROM_ABI void
372368lock(_L0& __l0, _L1& __l1)
373369{
374370 while (true)
......@@ -407,7 +403,7 @@ __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
407403 case 0:
408404 {
409405 unique_lock<_L0> __u0(__l0);
410 __i = try_lock(__l1, __l2, __l3...);
406 __i = std::try_lock(__l1, __l2, __l3...);
411407 if (__i == -1)
412408 {
413409 __u0.release();
......@@ -420,7 +416,7 @@ __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
420416 case 1:
421417 {
422418 unique_lock<_L1> __u1(__l1);
423 __i = try_lock(__l2, __l3..., __l0);
419 __i = std::try_lock(__l2, __l3..., __l0);
424420 if (__i == -1)
425421 {
426422 __u1.release();
......@@ -434,7 +430,7 @@ __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
434430 __libcpp_thread_yield();
435431 break;
436432 default:
437 __lock_first(__i - 2, __l2, __l3..., __l0, __l1);
433 std::__lock_first(__i - 2, __l2, __l3..., __l0, __l1);
438434 return;
439435 }
440436 }
......@@ -445,7 +441,7 @@ inline _LIBCPP_INLINE_VISIBILITY
445441void
446442lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
447443{
448 __lock_first(0, __l0, __l1, __l2, __l3...);
444 std::__lock_first(0, __l0, __l1, __l2, __l3...);
449445}
450446
451447template <class _L0>
......@@ -546,6 +542,7 @@ private:
546542
547543 _MutexTuple __t_;
548544};
545_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(scoped_lock);
549546
550547#endif // _LIBCPP_STD_VER > 14
551548#endif // !_LIBCPP_HAS_NO_THREADS
......@@ -670,7 +667,7 @@ call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args)
670667 typedef tuple<_Callable&&, _Args&&...> _Gp;
671668 _Gp __f(_VSTD::forward<_Callable>(__func), _VSTD::forward<_Args>(__args)...);
672669 __call_once_param<_Gp> __p(__f);
673 __call_once(__flag.__state_, &__p, &__call_once_proxy<_Gp>);
670 std::__call_once(__flag.__state_, &__p, &__call_once_proxy<_Gp>);
674671 }
675672}
676673
......@@ -684,7 +681,7 @@ call_once(once_flag& __flag, _Callable& __func)
684681 if (__libcpp_acquire_load(&__flag.__state_) != ~once_flag::_State_type(0))
685682 {
686683 __call_once_param<_Callable> __p(__func);
687 __call_once(__flag.__state_, &__p, &__call_once_proxy<_Callable>);
684 std::__call_once(__flag.__state_, &__p, &__call_once_proxy<_Callable>);
688685 }
689686}
690687
......@@ -696,7 +693,7 @@ call_once(once_flag& __flag, const _Callable& __func)
696693 if (__libcpp_acquire_load(&__flag.__state_) != ~once_flag::_State_type(0))
697694 {
698695 __call_once_param<const _Callable> __p(__func);
699 __call_once(__flag.__state_, &__p, &__call_once_proxy<const _Callable>);
696 std::__call_once(__flag.__state_, &__p, &__call_once_proxy<const _Callable>);
700697 }
701698}
702699
......@@ -706,4 +703,10 @@ _LIBCPP_END_NAMESPACE_STD
706703
707704_LIBCPP_POP_MACROS
708705
706#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
707# include <concepts>
708# include <functional>
709# include <type_traits>
710#endif
711
709712#endif // _LIBCPP_MUTEX
lib/libcxx/include/new+53-19
......@@ -89,10 +89,12 @@ void operator delete[](void* ptr, void*) noexcept;
8989#include <__assert> // all public C++ headers provide the assertion handler
9090#include <__availability>
9191#include <__config>
92#include <__type_traits/is_function.h>
93#include <__type_traits/is_same.h>
94#include <__type_traits/remove_cv.h>
9295#include <cstddef>
9396#include <cstdlib>
9497#include <exception>
95#include <type_traits>
9698#include <version>
9799
98100#if defined(_LIBCPP_ABI_VCRUNTIME)
......@@ -129,8 +131,8 @@ class _LIBCPP_EXCEPTION_ABI bad_alloc
129131{
130132public:
131133 bad_alloc() _NOEXCEPT;
132 virtual ~bad_alloc() _NOEXCEPT;
133 virtual const char* what() const _NOEXCEPT;
134 ~bad_alloc() _NOEXCEPT override;
135 const char* what() const _NOEXCEPT override;
134136};
135137
136138class _LIBCPP_EXCEPTION_ABI bad_array_new_length
......@@ -138,15 +140,33 @@ class _LIBCPP_EXCEPTION_ABI bad_array_new_length
138140{
139141public:
140142 bad_array_new_length() _NOEXCEPT;
141 virtual ~bad_array_new_length() _NOEXCEPT;
142 virtual const char* what() const _NOEXCEPT;
143 ~bad_array_new_length() _NOEXCEPT override;
144 const char* what() const _NOEXCEPT override;
143145};
144146
145147typedef void (*new_handler)();
146148_LIBCPP_FUNC_VIS new_handler set_new_handler(new_handler) _NOEXCEPT;
147149_LIBCPP_FUNC_VIS new_handler get_new_handler() _NOEXCEPT;
148150
149#endif // !_LIBCPP_ABI_VCRUNTIME
151#elif defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0 // !_LIBCPP_ABI_VCRUNTIME
152
153// When _HAS_EXCEPTIONS == 0, these complete definitions are needed,
154// since they would normally be provided in vcruntime_exception.h
155class bad_alloc : public exception {
156public:
157 bad_alloc() noexcept : exception("bad allocation") {}
158
159private:
160 friend class bad_array_new_length;
161
162 bad_alloc(char const* const __message) noexcept : exception(__message) {}
163};
164
165class bad_array_new_length : public bad_alloc {
166public:
167 bad_array_new_length() noexcept : bad_alloc("bad array new length") {}
168};
169#endif // defined(_LIBCPP_ABI_VCRUNTIME) && defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0
150170
151171_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_bad_alloc(); // not in C++ spec
152172
......@@ -277,9 +297,9 @@ _LIBCPP_INLINE_VISIBILITY
277297void __do_deallocate_handle_size(void *__ptr, size_t __size, _Args ...__args) {
278298#ifdef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
279299 (void)__size;
280 return __libcpp_operator_delete(__ptr, __args...);
300 return std::__libcpp_operator_delete(__ptr, __args...);
281301#else
282 return __libcpp_operator_delete(__ptr, __size, __args...);
302 return std::__libcpp_operator_delete(__ptr, __size, __args...);
283303#endif
284304}
285305
......@@ -319,16 +339,26 @@ inline _LIBCPP_INLINE_VISIBILITY void __libcpp_deallocate_unsized(void* __ptr, s
319339// chances are that you want to use `__libcpp_allocate` instead.
320340//
321341// Returns the allocated memory, or `nullptr` on failure.
322inline _LIBCPP_INLINE_VISIBILITY
323void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) {
324#if defined(_LIBCPP_MSVCRT_LIKE)
325 return ::_aligned_malloc(__size, __alignment);
326#else
327 void* __result = nullptr;
328 (void)::posix_memalign(&__result, __alignment, __size);
329 // If posix_memalign fails, __result is unmodified so we still return `nullptr`.
330 return __result;
331#endif
342inline _LIBCPP_INLINE_VISIBILITY void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) {
343# if defined(_LIBCPP_MSVCRT_LIKE)
344 return ::_aligned_malloc(__size, __alignment);
345# elif _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_C11_ALIGNED_ALLOC)
346 // aligned_alloc() requires that __size is a multiple of __alignment,
347 // but for C++ [new.delete.general], only states "if the value of an
348 // alignment argument passed to any of these functions is not a valid
349 // alignment value, the behavior is undefined".
350 // To handle calls such as ::operator new(1, std::align_val_t(128)), we
351 // round __size up to the next multiple of __alignment.
352 size_t __rounded_size = (__size + __alignment - 1) & ~(__alignment - 1);
353 // Rounding up could have wrapped around to zero, so we have to add another
354 // max() ternary to the actual call site to avoid succeeded in that case.
355 return ::aligned_alloc(__alignment, __size > __rounded_size ? __size : __rounded_size);
356# else
357 void* __result = nullptr;
358 (void)::posix_memalign(&__result, __alignment, __size);
359 // If posix_memalign fails, __result is unmodified so we still return `nullptr`.
360 return __result;
361# endif
332362}
333363
334364inline _LIBCPP_INLINE_VISIBILITY
......@@ -347,7 +377,7 @@ _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_HIDE_FROM_ABI
347377_LIBCPP_CONSTEXPR _Tp* __launder(_Tp* __p) _NOEXCEPT
348378{
349379 static_assert (!(is_function<_Tp>::value), "can't launder functions" );
350 static_assert (!(is_same<void, typename remove_cv<_Tp>::type>::value), "can't launder cv-void" );
380 static_assert (!(is_same<void, __remove_cv_t<_Tp> >::value), "can't launder cv-void" );
351381 return __builtin_launder(__p);
352382}
353383
......@@ -373,4 +403,8 @@ inline constexpr size_t hardware_constructive_interference_size = __GCC_CONSTRUC
373403
374404_LIBCPP_END_NAMESPACE_STD
375405
406#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
407# include <type_traits>
408#endif
409
376410#endif // _LIBCPP_NEW
lib/libcxx/include/numbers+6-2
......@@ -59,9 +59,8 @@ namespace std::numbers {
5959*/
6060
6161#include <__assert> // all public C++ headers provide the assertion handler
62#include <__concepts/arithmetic.h>
6263#include <__config>
63#include <concepts>
64#include <type_traits>
6564#include <version>
6665
6766#if _LIBCPP_STD_VER > 17
......@@ -131,4 +130,9 @@ _LIBCPP_END_NAMESPACE_STD
131130
132131#endif // _LIBCPP_STD_VER > 17
133132
133#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
134# include <concepts>
135# include <type_traits>
136#endif
137
134138#endif // _LIBCPP_NUMBERS
lib/libcxx/include/numeric+7-5
......@@ -163,11 +163,6 @@ template<class T>
163163#include <__numeric/transform_inclusive_scan.h>
164164#include <__numeric/transform_reduce.h>
165165
166#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
167# include <functional>
168# include <iterator>
169#endif
170
171166#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
172167# pragma GCC system_header
173168#endif
......@@ -176,4 +171,11 @@ template<class T>
176171# include <__pstl_numeric>
177172#endif
178173
174#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
175# include <concepts>
176# include <functional>
177# include <iterator>
178# include <type_traits>
179#endif
180
179181#endif // _LIBCPP_NUMERIC
lib/libcxx/include/optional+96-95
......@@ -87,8 +87,8 @@ namespace std {
8787 // 23.6.3.1, constructors
8888 constexpr optional() noexcept;
8989 constexpr optional(nullopt_t) noexcept;
90 optional(const optional &);
91 optional(optional &&) noexcept(see below);
90 constexpr optional(const optional &);
91 constexpr optional(optional &&) noexcept(see below);
9292 template <class... Args> constexpr explicit optional(in_place_t, Args &&...);
9393 template <class U, class... Args>
9494 constexpr explicit optional(in_place_t, initializer_list<U>, Args &&...);
......@@ -104,8 +104,8 @@ namespace std {
104104
105105 // 23.6.3.3, assignment
106106 optional &operator=(nullopt_t) noexcept; // constexpr in C++20
107 optional &operator=(const optional &); // constexpr in C++20
108 optional &operator=(optional &&) noexcept(see below); // constexpr in C++20
107 constexpr optional &operator=(const optional &);
108 constexpr optional &operator=(optional &&) noexcept(see below);
109109 template <class U = T> optional &operator=(U &&); // constexpr in C++20
110110 template <class U> optional &operator=(const optional<U> &); // constexpr in C++20
111111 template <class U> optional &operator=(optional<U> &&); // constexpr in C++20
......@@ -166,7 +166,7 @@ template<class T>
166166#include <__functional/invoke.h>
167167#include <__functional/unary_function.h>
168168#include <__memory/construct_at.h>
169#include <__tuple>
169#include <__tuple_dir/sfinae_helpers.h>
170170#include <__utility/forward.h>
171171#include <__utility/in_place.h>
172172#include <__utility/move.h>
......@@ -177,22 +177,9 @@ template<class T>
177177#include <type_traits>
178178#include <version>
179179
180#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
181# include <atomic>
182# include <chrono>
183# include <climits>
184# include <concepts>
185# include <ctime>
186# include <iterator>
187# include <memory>
188# include <ratio>
189# include <tuple>
190# include <typeinfo>
191# include <utility>
192# include <variant>
193#endif
194
195180// standard-mandated includes
181
182// [optional.syn]
196183#include <compare>
197184
198185#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -207,8 +194,8 @@ class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optiona
207194{
208195public:
209196 // Get the key function ~bad_optional_access() into the dylib
210 virtual ~bad_optional_access() _NOEXCEPT;
211 virtual const char* what() const _NOEXCEPT;
197 ~bad_optional_access() _NOEXCEPT override;
198 const char* what() const _NOEXCEPT override;
212199};
213200
214201} // namespace std
......@@ -255,7 +242,7 @@ struct __optional_destruct_base<_Tp, false>
255242 bool __engaged_;
256243
257244 _LIBCPP_INLINE_VISIBILITY
258 _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__optional_destruct_base()
245 _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__optional_destruct_base()
259246 {
260247 if (__engaged_)
261248 __val_.~value_type();
......@@ -280,7 +267,7 @@ struct __optional_destruct_base<_Tp, false>
280267#endif
281268
282269 _LIBCPP_INLINE_VISIBILITY
283 _LIBCPP_CONSTEXPR_AFTER_CXX17 void reset() noexcept
270 _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept
284271 {
285272 if (__engaged_)
286273 {
......@@ -322,7 +309,7 @@ struct __optional_destruct_base<_Tp, true>
322309#endif
323310
324311 _LIBCPP_INLINE_VISIBILITY
325 _LIBCPP_CONSTEXPR_AFTER_CXX17 void reset() noexcept
312 _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept
326313 {
327314 if (__engaged_)
328315 {
......@@ -367,7 +354,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp>
367354
368355 template <class... _Args>
369356 _LIBCPP_INLINE_VISIBILITY
370 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct(_Args&&... __args)
357 _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct(_Args&&... __args)
371358 {
372359 _LIBCPP_ASSERT(!has_value(), "__construct called for engaged __optional_storage");
373360#if _LIBCPP_STD_VER > 17
......@@ -380,7 +367,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp>
380367
381368 template <class _That>
382369 _LIBCPP_INLINE_VISIBILITY
383 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_from(_That&& __opt)
370 _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct_from(_That&& __opt)
384371 {
385372 if (__opt.has_value())
386373 __construct(_VSTD::forward<_That>(__opt).__get());
......@@ -388,7 +375,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp>
388375
389376 template <class _That>
390377 _LIBCPP_INLINE_VISIBILITY
391 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __assign_from(_That&& __opt)
378 _LIBCPP_CONSTEXPR_SINCE_CXX20 void __assign_from(_That&& __opt)
392379 {
393380 if (this->__engaged_ == __opt.has_value())
394381 {
......@@ -417,14 +404,14 @@ struct __optional_storage_base<_Tp, true>
417404
418405 template <class _Up>
419406 static constexpr bool __can_bind_reference() {
420 using _RawUp = typename remove_reference<_Up>::type;
407 using _RawUp = __libcpp_remove_reference_t<_Up>;
421408 using _UpPtr = _RawUp*;
422 using _RawTp = typename remove_reference<_Tp>::type;
409 using _RawTp = __libcpp_remove_reference_t<_Tp>;
423410 using _TpPtr = _RawTp*;
424411 using _CheckLValueArg = integral_constant<bool,
425412 (is_lvalue_reference<_Up>::value && is_convertible<_UpPtr, _TpPtr>::value)
426413 || is_same<_RawUp, reference_wrapper<_RawTp>>::value
427 || is_same<_RawUp, reference_wrapper<typename remove_const<_RawTp>::type>>::value
414 || is_same<_RawUp, reference_wrapper<__remove_const_t<_RawTp>>>::value
428415 >;
429416 return (is_lvalue_reference<_Tp>::value && _CheckLValueArg::value)
430417 || (is_rvalue_reference<_Tp>::value && !is_lvalue_reference<_Up>::value &&
......@@ -446,7 +433,7 @@ struct __optional_storage_base<_Tp, true>
446433 }
447434
448435 _LIBCPP_INLINE_VISIBILITY
449 _LIBCPP_CONSTEXPR_AFTER_CXX17 void reset() noexcept { __value_ = nullptr; }
436 _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept { __value_ = nullptr; }
450437
451438 _LIBCPP_INLINE_VISIBILITY
452439 constexpr bool has_value() const noexcept
......@@ -462,7 +449,7 @@ struct __optional_storage_base<_Tp, true>
462449
463450 template <class _UArg>
464451 _LIBCPP_INLINE_VISIBILITY
465 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct(_UArg&& __val)
452 _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct(_UArg&& __val)
466453 {
467454 _LIBCPP_ASSERT(!has_value(), "__construct called for engaged __optional_storage");
468455 static_assert(__can_bind_reference<_UArg>(),
......@@ -473,7 +460,7 @@ struct __optional_storage_base<_Tp, true>
473460
474461 template <class _That>
475462 _LIBCPP_INLINE_VISIBILITY
476 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_from(_That&& __opt)
463 _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct_from(_That&& __opt)
477464 {
478465 if (__opt.has_value())
479466 __construct(_VSTD::forward<_That>(__opt).__get());
......@@ -481,7 +468,7 @@ struct __optional_storage_base<_Tp, true>
481468
482469 template <class _That>
483470 _LIBCPP_INLINE_VISIBILITY
484 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __assign_from(_That&& __opt)
471 _LIBCPP_CONSTEXPR_SINCE_CXX20 void __assign_from(_That&& __opt)
485472 {
486473 if (has_value() == __opt.has_value())
487474 {
......@@ -513,7 +500,7 @@ struct __optional_copy_base<_Tp, false> : __optional_storage_base<_Tp>
513500 __optional_copy_base() = default;
514501
515502 _LIBCPP_INLINE_VISIBILITY
516 _LIBCPP_CONSTEXPR_AFTER_CXX17 __optional_copy_base(const __optional_copy_base& __opt)
503 _LIBCPP_CONSTEXPR_SINCE_CXX20 __optional_copy_base(const __optional_copy_base& __opt)
517504 {
518505 this->__construct_from(__opt);
519506 }
......@@ -544,7 +531,7 @@ struct __optional_move_base<_Tp, false> : __optional_copy_base<_Tp>
544531 __optional_move_base(const __optional_move_base&) = default;
545532
546533 _LIBCPP_INLINE_VISIBILITY
547 _LIBCPP_CONSTEXPR_AFTER_CXX17 __optional_move_base(__optional_move_base&& __opt)
534 _LIBCPP_CONSTEXPR_SINCE_CXX20 __optional_move_base(__optional_move_base&& __opt)
548535 noexcept(is_nothrow_move_constructible_v<value_type>)
549536 {
550537 this->__construct_from(_VSTD::move(__opt));
......@@ -578,7 +565,7 @@ struct __optional_copy_assign_base<_Tp, false> : __optional_move_base<_Tp>
578565 __optional_copy_assign_base(__optional_copy_assign_base&&) = default;
579566
580567 _LIBCPP_INLINE_VISIBILITY
581 _LIBCPP_CONSTEXPR_AFTER_CXX17 __optional_copy_assign_base& operator=(const __optional_copy_assign_base& __opt)
568 _LIBCPP_CONSTEXPR_SINCE_CXX20 __optional_copy_assign_base& operator=(const __optional_copy_assign_base& __opt)
582569 {
583570 this->__assign_from(__opt);
584571 return *this;
......@@ -613,7 +600,7 @@ struct __optional_move_assign_base<_Tp, false> : __optional_copy_assign_base<_Tp
613600 __optional_move_assign_base& operator=(const __optional_move_assign_base&) = default;
614601
615602 _LIBCPP_INLINE_VISIBILITY
616 _LIBCPP_CONSTEXPR_AFTER_CXX17 __optional_move_assign_base& operator=(__optional_move_assign_base&& __opt)
603 _LIBCPP_CONSTEXPR_SINCE_CXX20 __optional_move_assign_base& operator=(__optional_move_assign_base&& __opt)
617604 noexcept(is_nothrow_move_assignable_v<value_type> &&
618605 is_nothrow_move_constructible_v<value_type>)
619606 {
......@@ -652,9 +639,9 @@ public:
652639
653640private:
654641 // Disable the reference extension using this static assert.
655 static_assert(!is_same_v<__uncvref_t<value_type>, in_place_t>,
642 static_assert(!is_same_v<__remove_cvref_t<value_type>, in_place_t>,
656643 "instantiation of optional with in_place_t is ill-formed");
657 static_assert(!is_same_v<__uncvref_t<value_type>, nullopt_t>,
644 static_assert(!is_same_v<__remove_cvref_t<value_type>, nullopt_t>,
658645 "instantiation of optional with nullopt_t is ill-formed");
659646 static_assert(!is_reference_v<value_type>,
660647 "instantiation of optional with a reference type is ill-formed");
......@@ -679,8 +666,8 @@ private:
679666 };
680667 template <class _Up>
681668 using _CheckOptionalArgsCtor = _If<
682 _IsNotSame<__uncvref_t<_Up>, in_place_t>::value &&
683 _IsNotSame<__uncvref_t<_Up>, optional>::value,
669 _IsNotSame<__remove_cvref_t<_Up>, in_place_t>::value &&
670 _IsNotSame<__remove_cvref_t<_Up>, optional>::value,
684671 _CheckOptionalArgsConstructor,
685672 __check_tuple_constructor_fail
686673 >;
......@@ -787,7 +774,7 @@ public:
787774 _CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>()
788775 , int> = 0>
789776 _LIBCPP_INLINE_VISIBILITY
790 _LIBCPP_CONSTEXPR_AFTER_CXX17 optional(const optional<_Up>& __v)
777 _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(const optional<_Up>& __v)
791778 {
792779 this->__construct_from(__v);
793780 }
......@@ -795,7 +782,7 @@ public:
795782 _CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>()
796783 , int> = 0>
797784 _LIBCPP_INLINE_VISIBILITY
798 _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit optional(const optional<_Up>& __v)
785 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(const optional<_Up>& __v)
799786 {
800787 this->__construct_from(__v);
801788 }
......@@ -805,7 +792,7 @@ public:
805792 _CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_implicit<_Up>()
806793 , int> = 0>
807794 _LIBCPP_INLINE_VISIBILITY
808 _LIBCPP_CONSTEXPR_AFTER_CXX17 optional(optional<_Up>&& __v)
795 _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(optional<_Up>&& __v)
809796 {
810797 this->__construct_from(_VSTD::move(__v));
811798 }
......@@ -813,7 +800,7 @@ public:
813800 _CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_explicit<_Up>()
814801 , int> = 0>
815802 _LIBCPP_INLINE_VISIBILITY
816 _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit optional(optional<_Up>&& __v)
803 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(optional<_Up>&& __v)
817804 {
818805 this->__construct_from(_VSTD::move(__v));
819806 }
......@@ -827,22 +814,22 @@ public:
827814#endif
828815
829816 _LIBCPP_INLINE_VISIBILITY
830 _LIBCPP_CONSTEXPR_AFTER_CXX17 optional& operator=(nullopt_t) noexcept
817 _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(nullopt_t) noexcept
831818 {
832819 reset();
833820 return *this;
834821 }
835822
836 _LIBCPP_INLINE_VISIBILITY optional& operator=(const optional&) = default;
837 _LIBCPP_INLINE_VISIBILITY optional& operator=(optional&&) = default;
823 constexpr optional& operator=(const optional&) = default;
824 constexpr optional& operator=(optional&&) = default;
838825
839826 // LWG2756
840827 template <class _Up = value_type,
841828 class = enable_if_t<
842829 _And<
843 _IsNotSame<__uncvref_t<_Up>, optional>,
830 _IsNotSame<__remove_cvref_t<_Up>, optional>,
844831 _Or<
845 _IsNotSame<__uncvref_t<_Up>, value_type>,
832 _IsNotSame<__remove_cvref_t<_Up>, value_type>,
846833 _Not<is_scalar<value_type>>
847834 >,
848835 is_constructible<value_type, _Up>,
......@@ -850,7 +837,7 @@ public:
850837 >::value>
851838 >
852839 _LIBCPP_INLINE_VISIBILITY
853 _LIBCPP_CONSTEXPR_AFTER_CXX17 optional&
840 _LIBCPP_CONSTEXPR_SINCE_CXX20 optional&
854841 operator=(_Up&& __v)
855842 {
856843 if (this->has_value())
......@@ -865,7 +852,7 @@ public:
865852 _CheckOptionalLikeAssign<_Up, _Up const&>::template __enable_assign<_Up>()
866853 , int> = 0>
867854 _LIBCPP_INLINE_VISIBILITY
868 _LIBCPP_CONSTEXPR_AFTER_CXX17 optional&
855 _LIBCPP_CONSTEXPR_SINCE_CXX20 optional&
869856 operator=(const optional<_Up>& __v)
870857 {
871858 this->__assign_from(__v);
......@@ -877,7 +864,7 @@ public:
877864 _CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_assign<_Up>()
878865 , int> = 0>
879866 _LIBCPP_INLINE_VISIBILITY
880 _LIBCPP_CONSTEXPR_AFTER_CXX17 optional&
867 _LIBCPP_CONSTEXPR_SINCE_CXX20 optional&
881868 operator=(optional<_Up>&& __v)
882869 {
883870 this->__assign_from(_VSTD::move(__v));
......@@ -891,7 +878,7 @@ public:
891878 >
892879 >
893880 _LIBCPP_INLINE_VISIBILITY
894 _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp &
881 _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp &
895882 emplace(_Args&&... __args)
896883 {
897884 reset();
......@@ -906,7 +893,7 @@ public:
906893 >
907894 >
908895 _LIBCPP_INLINE_VISIBILITY
909 _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp &
896 _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp &
910897 emplace(initializer_list<_Up> __il, _Args&&... __args)
911898 {
912899 reset();
......@@ -915,7 +902,7 @@ public:
915902 }
916903
917904 _LIBCPP_INLINE_VISIBILITY
918 _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(optional& __opt)
905 _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(optional& __opt)
919906 noexcept(is_nothrow_move_constructible_v<value_type> &&
920907 is_nothrow_swappable_v<value_type>)
921908 {
......@@ -1198,8 +1185,8 @@ template<class _Tp>
11981185template <class _Tp, class _Up>
11991186_LIBCPP_INLINE_VISIBILITY constexpr
12001187enable_if_t<
1201 is_convertible_v<decltype(declval<const _Tp&>() ==
1202 declval<const _Up&>()), bool>,
1188 is_convertible_v<decltype(std::declval<const _Tp&>() ==
1189 std::declval<const _Up&>()), bool>,
12031190 bool
12041191>
12051192operator==(const optional<_Tp>& __x, const optional<_Up>& __y)
......@@ -1214,8 +1201,8 @@ operator==(const optional<_Tp>& __x, const optional<_Up>& __y)
12141201template <class _Tp, class _Up>
12151202_LIBCPP_INLINE_VISIBILITY constexpr
12161203enable_if_t<
1217 is_convertible_v<decltype(declval<const _Tp&>() !=
1218 declval<const _Up&>()), bool>,
1204 is_convertible_v<decltype(std::declval<const _Tp&>() !=
1205 std::declval<const _Up&>()), bool>,
12191206 bool
12201207>
12211208operator!=(const optional<_Tp>& __x, const optional<_Up>& __y)
......@@ -1230,8 +1217,8 @@ operator!=(const optional<_Tp>& __x, const optional<_Up>& __y)
12301217template <class _Tp, class _Up>
12311218_LIBCPP_INLINE_VISIBILITY constexpr
12321219enable_if_t<
1233 is_convertible_v<decltype(declval<const _Tp&>() <
1234 declval<const _Up&>()), bool>,
1220 is_convertible_v<decltype(std::declval<const _Tp&>() <
1221 std::declval<const _Up&>()), bool>,
12351222 bool
12361223>
12371224operator<(const optional<_Tp>& __x, const optional<_Up>& __y)
......@@ -1246,8 +1233,8 @@ operator<(const optional<_Tp>& __x, const optional<_Up>& __y)
12461233template <class _Tp, class _Up>
12471234_LIBCPP_INLINE_VISIBILITY constexpr
12481235enable_if_t<
1249 is_convertible_v<decltype(declval<const _Tp&>() >
1250 declval<const _Up&>()), bool>,
1236 is_convertible_v<decltype(std::declval<const _Tp&>() >
1237 std::declval<const _Up&>()), bool>,
12511238 bool
12521239>
12531240operator>(const optional<_Tp>& __x, const optional<_Up>& __y)
......@@ -1262,8 +1249,8 @@ operator>(const optional<_Tp>& __x, const optional<_Up>& __y)
12621249template <class _Tp, class _Up>
12631250_LIBCPP_INLINE_VISIBILITY constexpr
12641251enable_if_t<
1265 is_convertible_v<decltype(declval<const _Tp&>() <=
1266 declval<const _Up&>()), bool>,
1252 is_convertible_v<decltype(std::declval<const _Tp&>() <=
1253 std::declval<const _Up&>()), bool>,
12671254 bool
12681255>
12691256operator<=(const optional<_Tp>& __x, const optional<_Up>& __y)
......@@ -1278,8 +1265,8 @@ operator<=(const optional<_Tp>& __x, const optional<_Up>& __y)
12781265template <class _Tp, class _Up>
12791266_LIBCPP_INLINE_VISIBILITY constexpr
12801267enable_if_t<
1281 is_convertible_v<decltype(declval<const _Tp&>() >=
1282 declval<const _Up&>()), bool>,
1268 is_convertible_v<decltype(std::declval<const _Tp&>() >=
1269 std::declval<const _Up&>()), bool>,
12831270 bool
12841271>
12851272operator>=(const optional<_Tp>& __x, const optional<_Up>& __y)
......@@ -1392,8 +1379,8 @@ operator>=(nullopt_t, const optional<_Tp>& __x) noexcept
13921379template <class _Tp, class _Up>
13931380_LIBCPP_INLINE_VISIBILITY constexpr
13941381enable_if_t<
1395 is_convertible_v<decltype(declval<const _Tp&>() ==
1396 declval<const _Up&>()), bool>,
1382 is_convertible_v<decltype(std::declval<const _Tp&>() ==
1383 std::declval<const _Up&>()), bool>,
13971384 bool
13981385>
13991386operator==(const optional<_Tp>& __x, const _Up& __v)
......@@ -1404,8 +1391,8 @@ operator==(const optional<_Tp>& __x, const _Up& __v)
14041391template <class _Tp, class _Up>
14051392_LIBCPP_INLINE_VISIBILITY constexpr
14061393enable_if_t<
1407 is_convertible_v<decltype(declval<const _Tp&>() ==
1408 declval<const _Up&>()), bool>,
1394 is_convertible_v<decltype(std::declval<const _Tp&>() ==
1395 std::declval<const _Up&>()), bool>,
14091396 bool
14101397>
14111398operator==(const _Tp& __v, const optional<_Up>& __x)
......@@ -1416,8 +1403,8 @@ operator==(const _Tp& __v, const optional<_Up>& __x)
14161403template <class _Tp, class _Up>
14171404_LIBCPP_INLINE_VISIBILITY constexpr
14181405enable_if_t<
1419 is_convertible_v<decltype(declval<const _Tp&>() !=
1420 declval<const _Up&>()), bool>,
1406 is_convertible_v<decltype(std::declval<const _Tp&>() !=
1407 std::declval<const _Up&>()), bool>,
14211408 bool
14221409>
14231410operator!=(const optional<_Tp>& __x, const _Up& __v)
......@@ -1428,8 +1415,8 @@ operator!=(const optional<_Tp>& __x, const _Up& __v)
14281415template <class _Tp, class _Up>
14291416_LIBCPP_INLINE_VISIBILITY constexpr
14301417enable_if_t<
1431 is_convertible_v<decltype(declval<const _Tp&>() !=
1432 declval<const _Up&>()), bool>,
1418 is_convertible_v<decltype(std::declval<const _Tp&>() !=
1419 std::declval<const _Up&>()), bool>,
14331420 bool
14341421>
14351422operator!=(const _Tp& __v, const optional<_Up>& __x)
......@@ -1440,8 +1427,8 @@ operator!=(const _Tp& __v, const optional<_Up>& __x)
14401427template <class _Tp, class _Up>
14411428_LIBCPP_INLINE_VISIBILITY constexpr
14421429enable_if_t<
1443 is_convertible_v<decltype(declval<const _Tp&>() <
1444 declval<const _Up&>()), bool>,
1430 is_convertible_v<decltype(std::declval<const _Tp&>() <
1431 std::declval<const _Up&>()), bool>,
14451432 bool
14461433>
14471434operator<(const optional<_Tp>& __x, const _Up& __v)
......@@ -1452,8 +1439,8 @@ operator<(const optional<_Tp>& __x, const _Up& __v)
14521439template <class _Tp, class _Up>
14531440_LIBCPP_INLINE_VISIBILITY constexpr
14541441enable_if_t<
1455 is_convertible_v<decltype(declval<const _Tp&>() <
1456 declval<const _Up&>()), bool>,
1442 is_convertible_v<decltype(std::declval<const _Tp&>() <
1443 std::declval<const _Up&>()), bool>,
14571444 bool
14581445>
14591446operator<(const _Tp& __v, const optional<_Up>& __x)
......@@ -1464,8 +1451,8 @@ operator<(const _Tp& __v, const optional<_Up>& __x)
14641451template <class _Tp, class _Up>
14651452_LIBCPP_INLINE_VISIBILITY constexpr
14661453enable_if_t<
1467 is_convertible_v<decltype(declval<const _Tp&>() <=
1468 declval<const _Up&>()), bool>,
1454 is_convertible_v<decltype(std::declval<const _Tp&>() <=
1455 std::declval<const _Up&>()), bool>,
14691456 bool
14701457>
14711458operator<=(const optional<_Tp>& __x, const _Up& __v)
......@@ -1476,8 +1463,8 @@ operator<=(const optional<_Tp>& __x, const _Up& __v)
14761463template <class _Tp, class _Up>
14771464_LIBCPP_INLINE_VISIBILITY constexpr
14781465enable_if_t<
1479 is_convertible_v<decltype(declval<const _Tp&>() <=
1480 declval<const _Up&>()), bool>,
1466 is_convertible_v<decltype(std::declval<const _Tp&>() <=
1467 std::declval<const _Up&>()), bool>,
14811468 bool
14821469>
14831470operator<=(const _Tp& __v, const optional<_Up>& __x)
......@@ -1488,8 +1475,8 @@ operator<=(const _Tp& __v, const optional<_Up>& __x)
14881475template <class _Tp, class _Up>
14891476_LIBCPP_INLINE_VISIBILITY constexpr
14901477enable_if_t<
1491 is_convertible_v<decltype(declval<const _Tp&>() >
1492 declval<const _Up&>()), bool>,
1478 is_convertible_v<decltype(std::declval<const _Tp&>() >
1479 std::declval<const _Up&>()), bool>,
14931480 bool
14941481>
14951482operator>(const optional<_Tp>& __x, const _Up& __v)
......@@ -1500,8 +1487,8 @@ operator>(const optional<_Tp>& __x, const _Up& __v)
15001487template <class _Tp, class _Up>
15011488_LIBCPP_INLINE_VISIBILITY constexpr
15021489enable_if_t<
1503 is_convertible_v<decltype(declval<const _Tp&>() >
1504 declval<const _Up&>()), bool>,
1490 is_convertible_v<decltype(std::declval<const _Tp&>() >
1491 std::declval<const _Up&>()), bool>,
15051492 bool
15061493>
15071494operator>(const _Tp& __v, const optional<_Up>& __x)
......@@ -1512,8 +1499,8 @@ operator>(const _Tp& __v, const optional<_Up>& __x)
15121499template <class _Tp, class _Up>
15131500_LIBCPP_INLINE_VISIBILITY constexpr
15141501enable_if_t<
1515 is_convertible_v<decltype(declval<const _Tp&>() >=
1516 declval<const _Up&>()), bool>,
1502 is_convertible_v<decltype(std::declval<const _Tp&>() >=
1503 std::declval<const _Up&>()), bool>,
15171504 bool
15181505>
15191506operator>=(const optional<_Tp>& __x, const _Up& __v)
......@@ -1524,8 +1511,8 @@ operator>=(const optional<_Tp>& __x, const _Up& __v)
15241511template <class _Tp, class _Up>
15251512_LIBCPP_INLINE_VISIBILITY constexpr
15261513enable_if_t<
1527 is_convertible_v<decltype(declval<const _Tp&>() >=
1528 declval<const _Up&>()), bool>,
1514 is_convertible_v<decltype(std::declval<const _Tp&>() >=
1515 std::declval<const _Up&>()), bool>,
15291516 bool
15301517>
15311518operator>=(const _Tp& __v, const optional<_Up>& __x)
......@@ -1535,7 +1522,7 @@ operator>=(const _Tp& __v, const optional<_Up>& __x)
15351522
15361523
15371524template <class _Tp>
1538inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1525inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
15391526enable_if_t<
15401527 is_move_constructible_v<_Tp> && is_swappable_v<_Tp>,
15411528 void
......@@ -1587,4 +1574,18 @@ _LIBCPP_END_NAMESPACE_STD
15871574
15881575#endif // _LIBCPP_STD_VER > 14
15891576
1577#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1578# include <atomic>
1579# include <climits>
1580# include <concepts>
1581# include <ctime>
1582# include <iterator>
1583# include <memory>
1584# include <ratio>
1585# include <tuple>
1586# include <typeinfo>
1587# include <utility>
1588# include <variant>
1589#endif
1590
15901591#endif // _LIBCPP_OPTIONAL
lib/libcxx/include/ostream+67-62
......@@ -165,16 +165,15 @@ basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, cons
165165
166166#include <__assert> // all public C++ headers provide the assertion handler
167167#include <__config>
168#include <__memory/shared_ptr.h>
169#include <__memory/unique_ptr.h>
168170#include <bitset>
169171#include <ios>
170172#include <locale>
173#include <new>
171174#include <streambuf>
172175#include <version>
173176
174#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
175# include <iterator>
176#endif
177
178177#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
179178# pragma GCC system_header
180179#endif
......@@ -197,7 +196,7 @@ public:
197196 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
198197 explicit basic_ostream(basic_streambuf<char_type, traits_type>* __sb)
199198 { this->init(__sb); }
200 virtual ~basic_ostream();
199 ~basic_ostream() override;
201200protected:
202201 inline _LIBCPP_INLINE_VISIBILITY
203202 basic_ostream(basic_ostream&& __rhs);
......@@ -413,7 +412,7 @@ basic_ostream<_CharT, _Traits>::operator<<(bool __n)
413412 if (__s)
414413 {
415414 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
416 const _Fp& __f = use_facet<_Fp>(this->getloc());
415 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
417416 if (__f.put(*this, *this, this->fill(), __n).failed())
418417 this->setstate(ios_base::badbit | ios_base::failbit);
419418 }
......@@ -440,7 +439,7 @@ basic_ostream<_CharT, _Traits>::operator<<(short __n)
440439 {
441440 ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
442441 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
443 const _Fp& __f = use_facet<_Fp>(this->getloc());
442 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
444443 if (__f.put(*this, *this, this->fill(),
445444 __flags == ios_base::oct || __flags == ios_base::hex ?
446445 static_cast<long>(static_cast<unsigned short>(__n)) :
......@@ -469,7 +468,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned short __n)
469468 if (__s)
470469 {
471470 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
472 const _Fp& __f = use_facet<_Fp>(this->getloc());
471 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
473472 if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())
474473 this->setstate(ios_base::badbit | ios_base::failbit);
475474 }
......@@ -496,7 +495,7 @@ basic_ostream<_CharT, _Traits>::operator<<(int __n)
496495 {
497496 ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
498497 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
499 const _Fp& __f = use_facet<_Fp>(this->getloc());
498 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
500499 if (__f.put(*this, *this, this->fill(),
501500 __flags == ios_base::oct || __flags == ios_base::hex ?
502501 static_cast<long>(static_cast<unsigned int>(__n)) :
......@@ -525,7 +524,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned int __n)
525524 if (__s)
526525 {
527526 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
528 const _Fp& __f = use_facet<_Fp>(this->getloc());
527 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
529528 if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())
530529 this->setstate(ios_base::badbit | ios_base::failbit);
531530 }
......@@ -551,7 +550,7 @@ basic_ostream<_CharT, _Traits>::operator<<(long __n)
551550 if (__s)
552551 {
553552 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
554 const _Fp& __f = use_facet<_Fp>(this->getloc());
553 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
555554 if (__f.put(*this, *this, this->fill(), __n).failed())
556555 this->setstate(ios_base::badbit | ios_base::failbit);
557556 }
......@@ -577,7 +576,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n)
577576 if (__s)
578577 {
579578 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
580 const _Fp& __f = use_facet<_Fp>(this->getloc());
579 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
581580 if (__f.put(*this, *this, this->fill(), __n).failed())
582581 this->setstate(ios_base::badbit | ios_base::failbit);
583582 }
......@@ -603,7 +602,7 @@ basic_ostream<_CharT, _Traits>::operator<<(long long __n)
603602 if (__s)
604603 {
605604 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
606 const _Fp& __f = use_facet<_Fp>(this->getloc());
605 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
607606 if (__f.put(*this, *this, this->fill(), __n).failed())
608607 this->setstate(ios_base::badbit | ios_base::failbit);
609608 }
......@@ -629,7 +628,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n)
629628 if (__s)
630629 {
631630 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
632 const _Fp& __f = use_facet<_Fp>(this->getloc());
631 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
633632 if (__f.put(*this, *this, this->fill(), __n).failed())
634633 this->setstate(ios_base::badbit | ios_base::failbit);
635634 }
......@@ -655,7 +654,7 @@ basic_ostream<_CharT, _Traits>::operator<<(float __n)
655654 if (__s)
656655 {
657656 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
658 const _Fp& __f = use_facet<_Fp>(this->getloc());
657 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
659658 if (__f.put(*this, *this, this->fill(), static_cast<double>(__n)).failed())
660659 this->setstate(ios_base::badbit | ios_base::failbit);
661660 }
......@@ -681,7 +680,7 @@ basic_ostream<_CharT, _Traits>::operator<<(double __n)
681680 if (__s)
682681 {
683682 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
684 const _Fp& __f = use_facet<_Fp>(this->getloc());
683 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
685684 if (__f.put(*this, *this, this->fill(), __n).failed())
686685 this->setstate(ios_base::badbit | ios_base::failbit);
687686 }
......@@ -707,7 +706,7 @@ basic_ostream<_CharT, _Traits>::operator<<(long double __n)
707706 if (__s)
708707 {
709708 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
710 const _Fp& __f = use_facet<_Fp>(this->getloc());
709 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
711710 if (__f.put(*this, *this, this->fill(), __n).failed())
712711 this->setstate(ios_base::badbit | ios_base::failbit);
713712 }
......@@ -733,7 +732,7 @@ basic_ostream<_CharT, _Traits>::operator<<(const void* __n)
733732 if (__s)
734733 {
735734 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
736 const _Fp& __f = use_facet<_Fp>(this->getloc());
735 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
737736 if (__f.put(*this, *this, this->fill(), __n).failed())
738737 this->setstate(ios_base::badbit | ios_base::failbit);
739738 }
......@@ -748,7 +747,7 @@ basic_ostream<_CharT, _Traits>::operator<<(const void* __n)
748747}
749748
750749template<class _CharT, class _Traits>
751basic_ostream<_CharT, _Traits>&
750_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
752751__put_character_sequence(basic_ostream<_CharT, _Traits>& __os,
753752 const _CharT* __str, size_t __len)
754753{
......@@ -760,14 +759,14 @@ __put_character_sequence(basic_ostream<_CharT, _Traits>& __os,
760759 if (__s)
761760 {
762761 typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
763 if (__pad_and_output(_Ip(__os),
764 __str,
765 (__os.flags() & ios_base::adjustfield) == ios_base::left ?
766 __str + __len :
767 __str,
768 __str + __len,
769 __os,
770 __os.fill()).failed())
762 if (std::__pad_and_output(_Ip(__os),
763 __str,
764 (__os.flags() & ios_base::adjustfield) == ios_base::left ?
765 __str + __len :
766 __str,
767 __str + __len,
768 __os,
769 __os.fill()).failed())
771770 __os.setstate(ios_base::badbit | ios_base::failbit);
772771 }
773772#ifndef _LIBCPP_NO_EXCEPTIONS
......@@ -782,14 +781,14 @@ __put_character_sequence(basic_ostream<_CharT, _Traits>& __os,
782781
783782
784783template<class _CharT, class _Traits>
785basic_ostream<_CharT, _Traits>&
784_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
786785operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c)
787786{
788787 return _VSTD::__put_character_sequence(__os, &__c, 1);
789788}
790789
791790template<class _CharT, class _Traits>
792basic_ostream<_CharT, _Traits>&
791_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
793792operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)
794793{
795794#ifndef _LIBCPP_NO_EXCEPTIONS
......@@ -801,14 +800,14 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)
801800 {
802801 _CharT __c = __os.widen(__cn);
803802 typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
804 if (__pad_and_output(_Ip(__os),
805 &__c,
806 (__os.flags() & ios_base::adjustfield) == ios_base::left ?
807 &__c + 1 :
808 &__c,
809 &__c + 1,
810 __os,
811 __os.fill()).failed())
803 if (std::__pad_and_output(_Ip(__os),
804 &__c,
805 (__os.flags() & ios_base::adjustfield) == ios_base::left ?
806 &__c + 1 :
807 &__c,
808 &__c + 1,
809 __os,
810 __os.fill()).failed())
812811 __os.setstate(ios_base::badbit | ios_base::failbit);
813812 }
814813#ifndef _LIBCPP_NO_EXCEPTIONS
......@@ -822,35 +821,35 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)
822821}
823822
824823template<class _Traits>
825basic_ostream<char, _Traits>&
824_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
826825operator<<(basic_ostream<char, _Traits>& __os, char __c)
827826{
828827 return _VSTD::__put_character_sequence(__os, &__c, 1);
829828}
830829
831830template<class _Traits>
832basic_ostream<char, _Traits>&
831_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
833832operator<<(basic_ostream<char, _Traits>& __os, signed char __c)
834833{
835834 return _VSTD::__put_character_sequence(__os, (char *) &__c, 1);
836835}
837836
838837template<class _Traits>
839basic_ostream<char, _Traits>&
838_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
840839operator<<(basic_ostream<char, _Traits>& __os, unsigned char __c)
841840{
842841 return _VSTD::__put_character_sequence(__os, (char *) &__c, 1);
843842}
844843
845844template<class _CharT, class _Traits>
846basic_ostream<_CharT, _Traits>&
845_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
847846operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str)
848847{
849848 return _VSTD::__put_character_sequence(__os, __str, _Traits::length(__str));
850849}
851850
852851template<class _CharT, class _Traits>
853basic_ostream<_CharT, _Traits>&
852_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
854853operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn)
855854{
856855#ifndef _LIBCPP_NO_EXCEPTIONS
......@@ -875,14 +874,14 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn)
875874 }
876875 for (_CharT* __p = __wb; *__strn != '\0'; ++__strn, ++__p)
877876 *__p = __os.widen(*__strn);
878 if (__pad_and_output(_Ip(__os),
879 __wb,
880 (__os.flags() & ios_base::adjustfield) == ios_base::left ?
881 __wb + __len :
882 __wb,
883 __wb + __len,
884 __os,
885 __os.fill()).failed())
877 if (std::__pad_and_output(_Ip(__os),
878 __wb,
879 (__os.flags() & ios_base::adjustfield) == ios_base::left ?
880 __wb + __len :
881 __wb,
882 __wb + __len,
883 __os,
884 __os.fill()).failed())
886885 __os.setstate(ios_base::badbit | ios_base::failbit);
887886 }
888887#ifndef _LIBCPP_NO_EXCEPTIONS
......@@ -896,14 +895,14 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn)
896895}
897896
898897template<class _Traits>
899basic_ostream<char, _Traits>&
898_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
900899operator<<(basic_ostream<char, _Traits>& __os, const char* __str)
901900{
902901 return _VSTD::__put_character_sequence(__os, __str, _Traits::length(__str));
903902}
904903
905904template<class _Traits>
906basic_ostream<char, _Traits>&
905_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
907906operator<<(basic_ostream<char, _Traits>& __os, const signed char* __str)
908907{
909908 const char *__s = (const char *) __str;
......@@ -911,7 +910,7 @@ operator<<(basic_ostream<char, _Traits>& __os, const signed char* __str)
911910}
912911
913912template<class _Traits>
914basic_ostream<char, _Traits>&
913_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
915914operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str)
916915{
917916 const char *__s = (const char *) __str;
......@@ -1032,7 +1031,7 @@ basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir)
10321031}
10331032
10341033template <class _CharT, class _Traits>
1035inline
1034_LIBCPP_HIDE_FROM_ABI inline
10361035basic_ostream<_CharT, _Traits>&
10371036endl(basic_ostream<_CharT, _Traits>& __os)
10381037{
......@@ -1042,7 +1041,7 @@ endl(basic_ostream<_CharT, _Traits>& __os)
10421041}
10431042
10441043template <class _CharT, class _Traits>
1045inline
1044_LIBCPP_HIDE_FROM_ABI inline
10461045basic_ostream<_CharT, _Traits>&
10471046ends(basic_ostream<_CharT, _Traits>& __os)
10481047{
......@@ -1051,7 +1050,7 @@ ends(basic_ostream<_CharT, _Traits>& __os)
10511050}
10521051
10531052template <class _CharT, class _Traits>
1054inline
1053_LIBCPP_HIDE_FROM_ABI inline
10551054basic_ostream<_CharT, _Traits>&
10561055flush(basic_ostream<_CharT, _Traits>& __os)
10571056{
......@@ -1064,7 +1063,7 @@ struct __is_ostreamable : false_type { };
10641063
10651064template <class _Stream, class _Tp>
10661065struct __is_ostreamable<_Stream, _Tp, decltype(
1067 declval<_Stream>() << declval<_Tp>(), void()
1066 std::declval<_Stream>() << std::declval<_Tp>(), void()
10681067)> : true_type { };
10691068
10701069template <class _Stream, class _Tp, class = typename enable_if<
......@@ -1087,7 +1086,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
10871086}
10881087
10891088template<class _CharT, class _Traits>
1090basic_ostream<_CharT, _Traits>&
1089_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
10911090operator<<(basic_ostream<_CharT, _Traits>& __os,
10921091 basic_string_view<_CharT, _Traits> __sv)
10931092{
......@@ -1114,7 +1113,7 @@ template<class _CharT, class _Traits, class _Yp, class _Dp>
11141113inline _LIBCPP_INLINE_VISIBILITY
11151114typename enable_if
11161115<
1117 is_same<void, typename __void_t<decltype((declval<basic_ostream<_CharT, _Traits>&>() << declval<typename unique_ptr<_Yp, _Dp>::pointer>()))>::type>::value,
1116 is_same<void, __void_t<decltype((std::declval<basic_ostream<_CharT, _Traits>&>() << std::declval<typename unique_ptr<_Yp, _Dp>::pointer>()))> >::value,
11181117 basic_ostream<_CharT, _Traits>&
11191118>::type
11201119operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p)
......@@ -1123,12 +1122,12 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p
11231122}
11241123
11251124template <class _CharT, class _Traits, size_t _Size>
1126basic_ostream<_CharT, _Traits>&
1125_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
11271126operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x)
11281127{
11291128 return __os << __x.template to_string<_CharT, _Traits>
1130 (use_facet<ctype<_CharT> >(__os.getloc()).widen('0'),
1131 use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));
1129 (std::use_facet<ctype<_CharT> >(__os.getloc()).widen('0'),
1130 std::use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));
11321131}
11331132
11341133#if _LIBCPP_STD_VER > 17
......@@ -1189,4 +1188,10 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>;
11891188
11901189_LIBCPP_END_NAMESPACE_STD
11911190
1191#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1192# include <concepts>
1193# include <iterator>
1194# include <type_traits>
1195#endif
1196
11921197#endif // _LIBCPP_OSTREAM
lib/libcxx/include/queue+11-4
......@@ -231,11 +231,9 @@ template <class T, class Container, class Compare>
231231#include <vector>
232232#include <version>
233233
234#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
235# include <functional>
236#endif
237
238234// standard-mandated includes
235
236// [queue.syn]
239237#include <compare>
240238#include <initializer_list>
241239
......@@ -384,6 +382,8 @@ public:
384382 swap(c, __q.c);
385383 }
386384
385 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
386
387387 template <class _T1, class _C1>
388388 friend
389389 _LIBCPP_INLINE_VISIBILITY
......@@ -635,6 +635,8 @@ public:
635635 void swap(priority_queue& __q)
636636 _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
637637 __is_nothrow_swappable<value_compare>::value);
638
639 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
638640};
639641
640642#if _LIBCPP_STD_VER >= 17
......@@ -960,4 +962,9 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Comp
960962
961963_LIBCPP_END_NAMESPACE_STD
962964
965#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
966# include <concepts>
967# include <functional>
968#endif
969
963970#endif // _LIBCPP_QUEUE
lib/libcxx/include/random+17-14
......@@ -1718,25 +1718,28 @@ class piecewise_linear_distribution
17181718#include <__random/weibull_distribution.h>
17191719#include <version>
17201720
1721#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
1722# include <algorithm>
1723#endif
1724
17251721// standard-mandated includes
1726#include <initializer_list>
17271722
1728#include <cmath> // for backward compatibility; TODO remove it
1729#include <cstddef> // for backward compatibility; TODO remove it
1730#include <cstdint> // for backward compatibility; TODO remove it
1731#include <iosfwd> // for backward compatibility; TODO remove it
1732#include <limits> // for backward compatibility; TODO remove it
1733#include <numeric> // for backward compatibility; TODO remove it
1734#include <string> // for backward compatibility; TODO remove it
1735#include <type_traits> // for backward compatibility; TODO remove it
1736#include <vector> // for backward compatibility; TODO remove it
1723// [rand.synopsis]
1724#include <initializer_list>
17371725
17381726#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17391727# pragma GCC system_header
17401728#endif
17411729
1730#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1731# include <algorithm>
1732# include <climits>
1733# include <cmath>
1734# include <concepts>
1735# include <cstddef>
1736# include <cstdint>
1737# include <iosfwd>
1738# include <limits>
1739# include <numeric>
1740# include <string>
1741# include <type_traits>
1742# include <vector>
1743#endif
1744
17421745#endif // _LIBCPP_RANDOM
lib/libcxx/include/ranges+88-4
......@@ -115,6 +115,27 @@ namespace std::ranges {
115115 template<range R>
116116 using borrowed_subrange_t = see below;
117117
118 // [range.elements], elements view
119 template<input_range V, size_t N>
120 requires see below
121 class elements_view;
122
123 template<class T, size_t N>
124 inline constexpr bool enable_borrowed_range<elements_view<T, N>> =
125 enable_borrowed_range<T>;
126
127 template<class R>
128 using keys_view = elements_view<R, 0>;
129 template<class R>
130 using values_view = elements_view<R, 1>;
131
132 namespace views {
133 template<size_t N>
134 inline constexpr unspecified elements = unspecified;
135 inline constexpr auto keys = elements<0>;
136 inline constexpr auto values = elements<1>;
137 }
138
118139 // [range.empty], empty view
119140 template<class T>
120141 requires is_object_v<T>
......@@ -166,6 +187,18 @@ namespace std::ranges {
166187 template<class T>
167188 inline constexpr bool enable_borrowed_range<drop_view<T>> = enable_borrowed_range<T>;
168189
190 // [range.drop.while], drop while view
191 template<view V, class Pred>
192 requires input_range<V> && is_object_v<Pred> &&
193 indirect_unary_predicate<const Pred, iterator_t<V>>
194 class drop_while_view;
195
196 template<class T, class Pred>
197 inline constexpr bool enable_borrowed_range<drop_while_view<T, Pred>> =
198 enable_borrowed_range<T>;
199
200 namespace views { inline constexpr unspecified drop_while = unspecified; }
201
169202 // [range.transform], transform view
170203 template<input_range V, copy_constructible F>
171204 requires view<V> && is_object_v<F> &&
......@@ -198,6 +231,14 @@ namespace std::ranges {
198231 template<class T>
199232 inline constexpr bool enable_borrowed_range<take_view<T>> = enable_borrowed_range<T>;
200233
234 // [range.take.while], take while view
235 template<view V, class Pred>
236 requires input_range<V> && is_object_v<Pred> &&
237 indirect_unary_predicate<const Pred, iterator_t<V>>
238 class take_while_view;
239
240 namespace views { inline constexpr unspecified take_while = unspecified; }
241
201242 template<copy_constructible T>
202243 requires is_object_v<T>
203244 class single_view;
......@@ -224,10 +265,30 @@ namespace std::ranges {
224265 (forward_range<V> || tiny-range<Pattern>)
225266 class lazy_split_view;
226267
268 // [range.split], split view
269 template<forward_range V, forward_range Pattern>
270 requires view<V> && view<Pattern> &&
271 indirectly_comparable<iterator_t<V>, iterator_t<Pattern>, ranges::equal_to>
272 class split_view;
273
227274 namespace views {
228275 inline constexpr unspecified lazy_split = unspecified;
276 inline constexpr unspecified split = unspecified;
229277 }
230278
279 // [range.istream], istream view
280 template<movable Val, class CharT, class Traits = char_traits<CharT>>
281 requires see below
282 class basic_istream_view;
283
284 template<class Val>
285 using istream_view = basic_istream_view<Val, char>;
286
287 template<class Val>
288 using wistream_view = basic_istream_view<Val, wchar_t>;
289
290 namespace views { template<class T> inline constexpr unspecified istream = unspecified; }
291
231292 // [range.zip], zip view
232293 template<input_range... Views>
233294 requires (view<Views> && ...) && (sizeof...(Views) > 0)
......@@ -238,6 +299,13 @@ namespace std::ranges {
238299 (enable_borrowed_range<Views> && ...);
239300
240301 namespace views { inline constexpr unspecified zip = unspecified; } // C++2b
302
303 // [range.as.rvalue]
304 template <view V>
305 requires input_range<V>
306 class as_rvalue_view; // since C++23
307
308 namespace views { inline constexpr unspecified as_rvalue ) unspecified; } // since C++23
241309}
242310
243311namespace std {
......@@ -276,12 +344,15 @@ namespace std {
276344#include <__config>
277345#include <__ranges/access.h>
278346#include <__ranges/all.h>
347#include <__ranges/as_rvalue_view.h>
279348#include <__ranges/common_view.h>
280349#include <__ranges/concepts.h>
281350#include <__ranges/counted.h>
282351#include <__ranges/dangling.h>
283352#include <__ranges/data.h>
284353#include <__ranges/drop_view.h>
354#include <__ranges/drop_while_view.h>
355#include <__ranges/elements_view.h>
285356#include <__ranges/empty.h>
286357#include <__ranges/empty_view.h>
287358#include <__ranges/enable_borrowed_range.h>
......@@ -296,19 +367,32 @@ namespace std {
296367#include <__ranges/reverse_view.h>
297368#include <__ranges/single_view.h>
298369#include <__ranges/size.h>
370#include <__ranges/split_view.h>
299371#include <__ranges/subrange.h>
300372#include <__ranges/take_view.h>
373#include <__ranges/take_while_view.h>
301374#include <__ranges/transform_view.h>
302375#include <__ranges/view_interface.h>
303376#include <__ranges/views.h>
304377#include <__ranges/zip_view.h>
305#include <__tuple> // TODO: <ranges> has to export std::tuple_size. Replace this, once <tuple> is granularized.
306#include <compare> // Required by the standard.
307#include <initializer_list> // Required by the standard.
308#include <iterator> // Required by the standard.
309378#include <type_traits>
310379#include <version>
311380
381#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
382#include <__ranges/istream_view.h>
383#endif
384
385// standard-mandated includes
386
387// [ranges.syn]
388#include <compare>
389#include <initializer_list>
390#include <iterator>
391
392// [tuple.helper]
393#include <__tuple_dir/tuple_element.h>
394#include <__tuple_dir/tuple_size.h>
395
312396#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
313397# pragma GCC system_header
314398#endif
lib/libcxx/include/ratio+5-1
......@@ -79,9 +79,9 @@ typedef ratio<1000000000000000000000000, 1> yotta; // not supported
7979
8080#include <__assert> // all public C++ headers provide the assertion handler
8181#include <__config>
82#include <__type_traits/integral_constant.h>
8283#include <climits>
8384#include <cstdint>
84#include <type_traits>
8585#include <version>
8686
8787#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -525,4 +525,8 @@ _LIBCPP_END_NAMESPACE_STD
525525
526526_LIBCPP_POP_MACROS
527527
528#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
529# include <type_traits>
530#endif
531
528532#endif // _LIBCPP_RATIO
lib/libcxx/include/regex+66-37
......@@ -769,20 +769,17 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
769769#include <__iterator/back_insert_iterator.h>
770770#include <__iterator/wrap_iter.h>
771771#include <__locale>
772#include <__memory_resource/polymorphic_allocator.h>
772773#include <__utility/move.h>
774#include <__utility/pair.h>
773775#include <__utility/swap.h>
776#include <cstring>
774777#include <deque>
775#include <memory>
776778#include <stdexcept>
777779#include <string>
778780#include <vector>
779781#include <version>
780782
781#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
782# include <iterator>
783# include <utility>
784#endif
785
786783// standard-mandated includes
787784
788785// [iterator.range]
......@@ -833,7 +830,7 @@ enum syntax_option_type
833830 multiline = 1 << 10
834831};
835832
836inline _LIBCPP_CONSTEXPR
833_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR
837834syntax_option_type __get_grammar(syntax_option_type __g)
838835{
839836#ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
......@@ -1006,8 +1003,8 @@ class _LIBCPP_EXCEPTION_ABI regex_error
10061003public:
10071004 explicit regex_error(regex_constants::error_type __ecode);
10081005 regex_error(const regex_error&) _NOEXCEPT = default;
1009 virtual ~regex_error() _NOEXCEPT;
1010 _LIBCPP_INLINE_VISIBILITY
1006 ~regex_error() _NOEXCEPT override;
1007 _LIBCPP_INLINE_VISIBILITY
10111008 regex_constants::error_type code() const {return __code_;}
10121009};
10131010
......@@ -1029,7 +1026,7 @@ public:
10291026 typedef _CharT char_type;
10301027 typedef basic_string<char_type> string_type;
10311028 typedef locale locale_type;
1032#ifdef __BIONIC__
1029#if defined(__BIONIC__) || defined(_NEWLIB_VERSION)
10331030 // Originally bionic's ctype_base used its own ctype masks because the
10341031 // builtin ctype implementation wasn't in libc++ yet. Bionic's ctype mask
10351032 // was only 8 bits wide and already saturated, so it used a wider type here
......@@ -1038,6 +1035,11 @@ public:
10381035 // implementation, but this was not updated to match. Since then Android has
10391036 // needed to maintain a stable libc++ ABI, and this can't be changed without
10401037 // an ABI break.
1038 // We also need this workaround for newlib since _NEWLIB_VERSION is not
1039 // defined yet inside __config, so we can't set the
1040 // _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE macro. Additionally, newlib is
1041 // often used for space constrained environments, so it makes sense not to
1042 // duplicate the ctype table.
10411043 typedef uint16_t char_class_type;
10421044#else
10431045 typedef ctype_base::mask char_class_type;
......@@ -1155,8 +1157,8 @@ template <class _CharT>
11551157void
11561158regex_traits<_CharT>::__init()
11571159{
1158 __ct_ = &use_facet<ctype<char_type> >(__loc_);
1159 __col_ = &use_facet<collate<char_type> >(__loc_);
1160 __ct_ = &std::use_facet<ctype<char_type> >(__loc_);
1161 __col_ = &std::use_facet<collate<char_type> >(__loc_);
11601162}
11611163
11621164template <class _CharT>
......@@ -1231,7 +1233,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f,
12311233 string_type __r;
12321234 if (!__s.empty())
12331235 {
1234 __r = __get_collation_name(__s.c_str());
1236 __r = std::__get_collation_name(__s.c_str());
12351237 if (__r.empty() && __s.size() <= 2)
12361238 {
12371239 __r = __col_->transform(__s.data(), __s.data() + __s.size());
......@@ -1294,7 +1296,7 @@ regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f,
12941296{
12951297 string_type __s(__f, __l);
12961298 __ct_->tolower(&__s[0], &__s[0] + __s.size());
1297 return __get_classname(__s.c_str(), __icase);
1299 return std::__get_classname(__s.c_str(), __icase);
12981300}
12991301
13001302#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
......@@ -1444,12 +1446,12 @@ public:
14441446
14451447 _LIBCPP_INLINE_VISIBILITY
14461448 __node() {}
1447 _LIBCPP_INLINE_VISIBILITY
1449 _LIBCPP_HIDE_FROM_ABI_VIRTUAL
14481450 virtual ~__node() {}
14491451
1450 _LIBCPP_INLINE_VISIBILITY
1452 _LIBCPP_HIDE_FROM_ABI_VIRTUAL
14511453 virtual void __exec(__state&) const {}
1452 _LIBCPP_INLINE_VISIBILITY
1454 _LIBCPP_HIDE_FROM_ABI_VIRTUAL
14531455 virtual void __exec_split(bool, __state&) const {}
14541456};
14551457
......@@ -1507,7 +1509,7 @@ public:
15071509 explicit __owns_one_state(__node<_CharT>* __s)
15081510 : base(__s) {}
15091511
1510 virtual ~__owns_one_state();
1512 ~__owns_one_state() override;
15111513};
15121514
15131515template <class _CharT>
......@@ -2092,7 +2094,7 @@ __l_anchor_multiline<_CharT>::__exec(__state& __s) const
20922094 }
20932095 else if (__multiline_ &&
20942096 !__s.__at_first_ &&
2095 __is_eol(*_VSTD::prev(__s.__current_)))
2097 std::__is_eol(*_VSTD::prev(__s.__current_)))
20962098 {
20972099 __s.__do_ = __state::__accept_but_not_consume;
20982100 __s.__node_ = this->first();
......@@ -2134,7 +2136,7 @@ __r_anchor_multiline<_CharT>::__exec(__state& __s) const
21342136 __s.__do_ = __state::__accept_but_not_consume;
21352137 __s.__node_ = this->first();
21362138 }
2137 else if (__multiline_ && __is_eol(*__s.__current_))
2139 else if (__multiline_ && std::__is_eol(*__s.__current_))
21382140 {
21392141 __s.__do_ = __state::__accept_but_not_consume;
21402142 __s.__node_ = this->first();
......@@ -2196,7 +2198,7 @@ public:
21962198 __match_any_but_newline(__node<_CharT>* __s)
21972199 : base(__s) {}
21982200
2199 virtual void __exec(__state&) const;
2201 void __exec(__state&) const override;
22002202};
22012203
22022204template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<char>::__exec(__state&) const;
......@@ -2403,7 +2405,7 @@ public:
24032405 for (size_t __i = 0; __i < __e.size(); ++__i)
24042406 __e[__i] = __traits_.translate(__e[__i]);
24052407 }
2406 __ranges_.push_back(make_pair(
2408 __ranges_.push_back(std::make_pair(
24072409 __traits_.transform(__b.begin(), __b.end()),
24082410 __traits_.transform(__e.begin(), __e.end())));
24092411 }
......@@ -2416,20 +2418,20 @@ public:
24162418 __b[0] = __traits_.translate_nocase(__b[0]);
24172419 __e[0] = __traits_.translate_nocase(__e[0]);
24182420 }
2419 __ranges_.push_back(make_pair(_VSTD::move(__b), _VSTD::move(__e)));
2421 __ranges_.push_back(std::make_pair(_VSTD::move(__b), _VSTD::move(__e)));
24202422 }
24212423 }
24222424 _LIBCPP_INLINE_VISIBILITY
24232425 void __add_digraph(_CharT __c1, _CharT __c2)
24242426 {
24252427 if (__icase_)
2426 __digraphs_.push_back(make_pair(__traits_.translate_nocase(__c1),
2427 __traits_.translate_nocase(__c2)));
2428 __digraphs_.push_back(std::make_pair(__traits_.translate_nocase(__c1),
2429 __traits_.translate_nocase(__c2)));
24282430 else if (__collate_)
2429 __digraphs_.push_back(make_pair(__traits_.translate(__c1),
2430 __traits_.translate(__c2)));
2431 __digraphs_.push_back(std::make_pair(__traits_.translate(__c1),
2432 __traits_.translate(__c2)));
24312433 else
2432 __digraphs_.push_back(make_pair(__c1, __c2));
2434 __digraphs_.push_back(std::make_pair(__c1, __c2));
24332435 }
24342436 _LIBCPP_INLINE_VISIBILITY
24352437 void __add_equivalence(const string_type& __s)
......@@ -5521,7 +5523,7 @@ public:
55215523 regex_constants::match_flag_type __flags = regex_constants::format_default) const
55225524 {
55235525 basic_string<char_type, _ST, _SA> __r;
5524 format(back_inserter(__r), __fmt.data(), __fmt.data() + __fmt.size(),
5526 format(std::back_inserter(__r), __fmt.data(), __fmt.data() + __fmt.size(),
55255527 __flags);
55265528 return __r;
55275529 }
......@@ -5531,7 +5533,7 @@ public:
55315533 regex_constants::match_flag_type __flags = regex_constants::format_default) const
55325534 {
55335535 string_type __r;
5534 format(back_inserter(__r), __fmt,
5536 format(std::back_inserter(__r), __fmt,
55355537 __fmt + char_traits<char_type>::length(__fmt), __flags);
55365538 return __r;
55375539 }
......@@ -5732,7 +5734,7 @@ match_results<_BidirectionalIterator, _Allocator>::swap(match_results& __m)
57325734}
57335735
57345736template <class _BidirectionalIterator, class _Allocator>
5735bool
5737_LIBCPP_HIDE_FROM_ABI bool
57365738operator==(const match_results<_BidirectionalIterator, _Allocator>& __x,
57375739 const match_results<_BidirectionalIterator, _Allocator>& __y)
57385740{
......@@ -6224,7 +6226,7 @@ regex_search(const basic_string<_Cp, _ST, _SA>&& __s,
62246226// regex_match
62256227
62266228template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits>
6227bool
6229_LIBCPP_HIDE_FROM_ABI bool
62286230regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last,
62296231 match_results<_BidirectionalIterator, _Allocator>& __m,
62306232 const basic_regex<_CharT, _Traits>& __e,
......@@ -6737,7 +6739,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
67376739
67386740template <class _OutputIterator, class _BidirectionalIterator,
67396741 class _Traits, class _CharT>
6740_OutputIterator
6742_LIBCPP_HIDE_FROM_ABI _OutputIterator
67416743regex_replace(_OutputIterator __output_iter,
67426744 _BidirectionalIterator __first, _BidirectionalIterator __last,
67436745 const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt,
......@@ -6792,7 +6794,7 @@ regex_replace(const basic_string<_CharT, _ST, _SA>& __s,
67926794 regex_constants::match_flag_type __flags = regex_constants::match_default)
67936795{
67946796 basic_string<_CharT, _ST, _SA> __r;
6795 _VSTD::regex_replace(back_inserter(__r), __s.begin(), __s.end(), __e,
6797 _VSTD::regex_replace(std::back_inserter(__r), __s.begin(), __s.end(), __e,
67966798 __fmt.c_str(), __flags);
67976799 return __r;
67986800}
......@@ -6805,7 +6807,7 @@ regex_replace(const basic_string<_CharT, _ST, _SA>& __s,
68056807 regex_constants::match_flag_type __flags = regex_constants::match_default)
68066808{
68076809 basic_string<_CharT, _ST, _SA> __r;
6808 _VSTD::regex_replace(back_inserter(__r), __s.begin(), __s.end(), __e,
6810 _VSTD::regex_replace(std::back_inserter(__r), __s.begin(), __s.end(), __e,
68096811 __fmt, __flags);
68106812 return __r;
68116813}
......@@ -6819,7 +6821,7 @@ regex_replace(const _CharT* __s,
68196821 regex_constants::match_flag_type __flags = regex_constants::match_default)
68206822{
68216823 basic_string<_CharT> __r;
6822 _VSTD::regex_replace(back_inserter(__r), __s,
6824 _VSTD::regex_replace(std::back_inserter(__r), __s,
68236825 __s + char_traits<_CharT>::length(__s), __e,
68246826 __fmt.c_str(), __flags);
68256827 return __r;
......@@ -6834,7 +6836,7 @@ regex_replace(const _CharT* __s,
68346836 regex_constants::match_flag_type __flags = regex_constants::match_default)
68356837{
68366838 basic_string<_CharT> __r;
6837 _VSTD::regex_replace(back_inserter(__r), __s,
6839 _VSTD::regex_replace(std::back_inserter(__r), __s,
68386840 __s + char_traits<_CharT>::length(__s), __e,
68396841 __fmt, __flags);
68406842 return __r;
......@@ -6842,6 +6844,33 @@ regex_replace(const _CharT* __s,
68426844
68436845_LIBCPP_END_NAMESPACE_STD
68446846
6847#if _LIBCPP_STD_VER > 14
6848_LIBCPP_BEGIN_NAMESPACE_STD
6849namespace pmr {
6850template <class _BidirT>
6851using match_results = std::match_results<_BidirT, polymorphic_allocator<std::sub_match<_BidirT>>>;
6852
6853using cmatch = match_results<const char*>;
6854using smatch = match_results<std::pmr::string::const_iterator>;
6855
6856#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
6857using wcmatch = match_results<const wchar_t*>;
6858using wsmatch = match_results<std::pmr::wstring::const_iterator>;
6859#endif
6860} // namespace pmr
6861_LIBCPP_END_NAMESPACE_STD
6862#endif
6863
68456864_LIBCPP_POP_MACROS
68466865
6866#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
6867# include <atomic>
6868# include <concepts>
6869# include <iosfwd>
6870# include <iterator>
6871# include <new>
6872# include <typeinfo>
6873# include <utility>
6874#endif
6875
68476876#endif // _LIBCPP_REGEX
lib/libcxx/include/scoped_allocator+44-6
......@@ -111,8 +111,19 @@ template <class OuterA1, class OuterA2, class... InnerAllocs>
111111
112112#include <__assert> // all public C++ headers provide the assertion handler
113113#include <__config>
114#include <__memory/allocator_traits.h>
115#include <__memory/uses_allocator_construction.h>
116#include <__type_traits/common_type.h>
117#include <__type_traits/enable_if.h>
118#include <__type_traits/integral_constant.h>
119#include <__type_traits/is_constructible.h>
120#include <__type_traits/remove_reference.h>
121#include <__utility/declval.h>
114122#include <__utility/forward.h>
115#include <memory>
123#include <__utility/move.h>
124#include <__utility/pair.h>
125#include <__utility/piecewise_construct.h>
126#include <tuple>
116127#include <version>
117128
118129#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -352,7 +363,7 @@ protected:
352363// __outermost
353364
354365template <class _Alloc>
355decltype(declval<_Alloc>().outer_allocator(), true_type())
366decltype(std::declval<_Alloc>().outer_allocator(), true_type())
356367__has_outer_allocator_test(_Alloc&& __a);
357368
358369template <class _Alloc>
......@@ -363,7 +374,7 @@ template <class _Alloc>
363374struct __has_outer_allocator
364375 : public common_type
365376 <
366 decltype(__has_outer_allocator_test(declval<_Alloc&>()))
377 decltype(std::__has_outer_allocator_test(std::declval<_Alloc&>()))
367378 >::type
368379{
369380};
......@@ -379,10 +390,10 @@ struct __outermost
379390template <class _Alloc>
380391struct __outermost<_Alloc, true>
381392{
382 typedef typename remove_reference
393 typedef __libcpp_remove_reference_t
383394 <
384 decltype(declval<_Alloc>().outer_allocator())
385 >::type _OuterAlloc;
395 decltype(std::declval<_Alloc>().outer_allocator())
396 > _OuterAlloc;
386397 typedef typename __outermost<_OuterAlloc>::type type;
387398 _LIBCPP_INLINE_VISIBILITY
388399 type& operator()(_Alloc& __a) const _NOEXCEPT
......@@ -501,6 +512,18 @@ public:
501512 size_type max_size() const
502513 {return allocator_traits<outer_allocator_type>::max_size(outer_allocator());}
503514
515#if _LIBCPP_STD_VER >= 20
516 template <class _Type, class... _Args>
517 _LIBCPP_HIDE_FROM_ABI void construct(_Type* __ptr, _Args&&... __args) {
518 using _OM = __outermost<outer_allocator_type>;
519 std::apply(
520 [__ptr, this](auto&&... __newargs) {
521 allocator_traits<typename _OM::type>::construct(
522 _OM()(outer_allocator()), __ptr, std::forward<decltype(__newargs)>(__newargs)...);
523 },
524 std::uses_allocator_construction_args<_Type>(inner_allocator(), std::forward<_Args>(__args)...));
525 }
526#else
504527 template <class _Tp, class... _Args>
505528 _LIBCPP_INLINE_VISIBILITY
506529 void construct(_Tp* __p, _Args&& ...__args)
......@@ -555,6 +578,7 @@ public:
555578 _VSTD::forward_as_tuple(_VSTD::forward<_Up>(__x.first)),
556579 _VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__x.second)));
557580 }
581#endif
558582
559583 template <class _Tp>
560584 _LIBCPP_INLINE_VISIBILITY
......@@ -692,4 +716,18 @@ operator!=(const scoped_allocator_adaptor<_OuterA1, _InnerAllocs...>& __a,
692716
693717_LIBCPP_END_NAMESPACE_STD
694718
719#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
720# include <atomic>
721# include <climits>
722# include <concepts>
723# include <cstring>
724# include <ctime>
725# include <iterator>
726# include <memory>
727# include <ratio>
728# include <stdexcept>
729# include <type_traits>
730# include <variant>
731#endif
732
695733#endif // _LIBCPP_SCOPED_ALLOCATOR
lib/libcxx/include/semaphore+17-17
......@@ -80,31 +80,31 @@ functions. It avoids contention against users' own use of those facilities.
8080
8181class __atomic_semaphore_base
8282{
83 __atomic_base<ptrdiff_t> __a;
83 __atomic_base<ptrdiff_t> __a_;
8484
8585public:
8686 _LIBCPP_INLINE_VISIBILITY
87 constexpr explicit __atomic_semaphore_base(ptrdiff_t __count) : __a(__count)
87 constexpr explicit __atomic_semaphore_base(ptrdiff_t __count) : __a_(__count)
8888 {
8989 }
9090 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
9191 void release(ptrdiff_t __update = 1)
9292 {
93 if(0 < __a.fetch_add(__update, memory_order_release))
93 if(0 < __a_.fetch_add(__update, memory_order_release))
9494 ;
9595 else if(__update > 1)
96 __a.notify_all();
96 __a_.notify_all();
9797 else
98 __a.notify_one();
98 __a_.notify_one();
9999 }
100100 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
101101 void acquire()
102102 {
103103 auto const __test_fn = [this]() -> bool {
104 auto __old = __a.load(memory_order_relaxed);
105 return (__old != 0) && __a.compare_exchange_strong(__old, __old - 1, memory_order_acquire, memory_order_relaxed);
104 auto __old = __a_.load(memory_order_relaxed);
105 return (__old != 0) && __a_.compare_exchange_strong(__old, __old - 1, memory_order_acquire, memory_order_relaxed);
106106 };
107 __cxx_atomic_wait(&__a.__a_, __test_fn);
107 __cxx_atomic_wait(&__a_.__a_, __test_fn);
108108 }
109109 template <class Rep, class Period>
110110 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
......@@ -113,16 +113,16 @@ public:
113113 if (__rel_time == chrono::duration<Rep, Period>::zero())
114114 return try_acquire();
115115 auto const __test_fn = [this]() { return try_acquire(); };
116 return __libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy(), __rel_time);
116 return std::__libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy(), __rel_time);
117117 }
118118 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
119119 bool try_acquire()
120120 {
121 auto __old = __a.load(memory_order_acquire);
121 auto __old = __a_.load(memory_order_acquire);
122122 while (true) {
123123 if (__old == 0)
124124 return false;
125 if (__a.compare_exchange_strong(__old, __old - 1, memory_order_acquire, memory_order_relaxed))
125 if (__a_.compare_exchange_strong(__old, __old - 1, memory_order_acquire, memory_order_relaxed))
126126 return true;
127127 }
128128 }
......@@ -133,7 +133,7 @@ public:
133133template<ptrdiff_t __least_max_value = _LIBCPP_SEMAPHORE_MAX>
134134class counting_semaphore
135135{
136 __atomic_semaphore_base __semaphore;
136 __atomic_semaphore_base __semaphore_;
137137
138138public:
139139 static constexpr ptrdiff_t max() noexcept {
......@@ -141,7 +141,7 @@ public:
141141 }
142142
143143 _LIBCPP_INLINE_VISIBILITY
144 constexpr explicit counting_semaphore(ptrdiff_t __count) : __semaphore(__count) { }
144 constexpr explicit counting_semaphore(ptrdiff_t __count) : __semaphore_(__count) { }
145145 ~counting_semaphore() = default;
146146
147147 counting_semaphore(const counting_semaphore&) = delete;
......@@ -150,23 +150,23 @@ public:
150150 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
151151 void release(ptrdiff_t __update = 1)
152152 {
153 __semaphore.release(__update);
153 __semaphore_.release(__update);
154154 }
155155 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
156156 void acquire()
157157 {
158 __semaphore.acquire();
158 __semaphore_.acquire();
159159 }
160160 template<class Rep, class Period>
161161 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
162162 bool try_acquire_for(chrono::duration<Rep, Period> const& __rel_time)
163163 {
164 return __semaphore.try_acquire_for(chrono::duration_cast<chrono::nanoseconds>(__rel_time));
164 return __semaphore_.try_acquire_for(chrono::duration_cast<chrono::nanoseconds>(__rel_time));
165165 }
166166 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
167167 bool try_acquire()
168168 {
169 return __semaphore.try_acquire();
169 return __semaphore_.try_acquire();
170170 }
171171 template <class Clock, class Duration>
172172 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
lib/libcxx/include/set+29-5
......@@ -480,16 +480,14 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20
480480#include <__iterator/erase_if_container.h>
481481#include <__iterator/iterator_traits.h>
482482#include <__iterator/reverse_iterator.h>
483#include <__memory/allocator.h>
484#include <__memory_resource/polymorphic_allocator.h>
483485#include <__node_handle>
484486#include <__tree>
487#include <__type_traits/is_allocator.h>
485488#include <__utility/forward.h>
486489#include <version>
487490
488#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
489# include <functional>
490# include <iterator>
491#endif
492
493491// standard-mandated includes
494492
495493// [iterator.range]
......@@ -533,6 +531,10 @@ private:
533531 typedef __tree<value_type, value_compare, allocator_type> __base;
534532 typedef allocator_traits<allocator_type> __alloc_traits;
535533
534 static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
535 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
536 "original allocator");
537
536538 __base __tree_;
537539
538540public:
......@@ -1066,6 +1068,10 @@ private:
10661068 typedef __tree<value_type, value_compare, allocator_type> __base;
10671069 typedef allocator_traits<allocator_type> __alloc_traits;
10681070
1071 static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
1072 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
1073 "original allocator");
1074
10691075 __base __tree_;
10701076
10711077public:
......@@ -1578,4 +1584,22 @@ inline _LIBCPP_INLINE_VISIBILITY
15781584
15791585_LIBCPP_END_NAMESPACE_STD
15801586
1587#if _LIBCPP_STD_VER > 14
1588_LIBCPP_BEGIN_NAMESPACE_STD
1589namespace pmr {
1590template <class _KeyT, class _CompareT = std::less<_KeyT>>
1591using set = std::set<_KeyT, _CompareT, polymorphic_allocator<_KeyT>>;
1592
1593template <class _KeyT, class _CompareT = std::less<_KeyT>>
1594using multiset = std::multiset<_KeyT, _CompareT, polymorphic_allocator<_KeyT>>;
1595} // namespace pmr
1596_LIBCPP_END_NAMESPACE_STD
1597#endif
1598
1599#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1600# include <concepts>
1601# include <functional>
1602# include <iterator>
1603#endif
1604
15811605#endif // _LIBCPP_SET
lib/libcxx/include/setjmp.h+3-1
......@@ -31,7 +31,9 @@ void longjmp(jmp_buf env, int val);
3131# pragma GCC system_header
3232#endif
3333
34#include_next <setjmp.h>
34#if __has_include_next(<setjmp.h>)
35# include_next <setjmp.h>
36#endif
3537
3638#ifdef __cplusplus
3739
lib/libcxx/include/shared_mutex+28-27
......@@ -180,23 +180,23 @@ __shared_mutex_base
180180#if _LIBCPP_STD_VER > 14
181181class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_SHARED_MUTEX shared_mutex
182182{
183 __shared_mutex_base __base;
183 __shared_mutex_base __base_;
184184public:
185 _LIBCPP_INLINE_VISIBILITY shared_mutex() : __base() {}
185 _LIBCPP_INLINE_VISIBILITY shared_mutex() : __base_() {}
186186 _LIBCPP_INLINE_VISIBILITY ~shared_mutex() = default;
187187
188188 shared_mutex(const shared_mutex&) = delete;
189189 shared_mutex& operator=(const shared_mutex&) = delete;
190190
191191 // Exclusive ownership
192 _LIBCPP_INLINE_VISIBILITY void lock() { return __base.lock(); }
193 _LIBCPP_INLINE_VISIBILITY bool try_lock() { return __base.try_lock(); }
194 _LIBCPP_INLINE_VISIBILITY void unlock() { return __base.unlock(); }
192 _LIBCPP_INLINE_VISIBILITY void lock() { return __base_.lock(); }
193 _LIBCPP_INLINE_VISIBILITY bool try_lock() { return __base_.try_lock(); }
194 _LIBCPP_INLINE_VISIBILITY void unlock() { return __base_.unlock(); }
195195
196196 // Shared ownership
197 _LIBCPP_INLINE_VISIBILITY void lock_shared() { return __base.lock_shared(); }
198 _LIBCPP_INLINE_VISIBILITY bool try_lock_shared() { return __base.try_lock_shared(); }
199 _LIBCPP_INLINE_VISIBILITY void unlock_shared() { return __base.unlock_shared(); }
197 _LIBCPP_INLINE_VISIBILITY void lock_shared() { return __base_.lock_shared(); }
198 _LIBCPP_INLINE_VISIBILITY bool try_lock_shared() { return __base_.try_lock_shared(); }
199 _LIBCPP_INLINE_VISIBILITY void unlock_shared() { return __base_.unlock_shared(); }
200200
201201// typedef __shared_mutex_base::native_handle_type native_handle_type;
202202// _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() { return __base::unlock_shared(); }
......@@ -206,7 +206,7 @@ public:
206206
207207class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_SHARED_MUTEX shared_timed_mutex
208208{
209 __shared_mutex_base __base;
209 __shared_mutex_base __base_;
210210public:
211211 shared_timed_mutex();
212212 _LIBCPP_INLINE_VISIBILITY ~shared_timed_mutex() = default;
......@@ -252,30 +252,30 @@ bool
252252shared_timed_mutex::try_lock_until(
253253 const chrono::time_point<_Clock, _Duration>& __abs_time)
254254{
255 unique_lock<mutex> __lk(__base.__mut_);
256 if (__base.__state_ & __base.__write_entered_)
255 unique_lock<mutex> __lk(__base_.__mut_);
256 if (__base_.__state_ & __base_.__write_entered_)
257257 {
258258 while (true)
259259 {
260 cv_status __status = __base.__gate1_.wait_until(__lk, __abs_time);
261 if ((__base.__state_ & __base.__write_entered_) == 0)
260 cv_status __status = __base_.__gate1_.wait_until(__lk, __abs_time);
261 if ((__base_.__state_ & __base_.__write_entered_) == 0)
262262 break;
263263 if (__status == cv_status::timeout)
264264 return false;
265265 }
266266 }
267 __base.__state_ |= __base.__write_entered_;
268 if (__base.__state_ & __base.__n_readers_)
267 __base_.__state_ |= __base_.__write_entered_;
268 if (__base_.__state_ & __base_.__n_readers_)
269269 {
270270 while (true)
271271 {
272 cv_status __status = __base.__gate2_.wait_until(__lk, __abs_time);
273 if ((__base.__state_ & __base.__n_readers_) == 0)
272 cv_status __status = __base_.__gate2_.wait_until(__lk, __abs_time);
273 if ((__base_.__state_ & __base_.__n_readers_) == 0)
274274 break;
275275 if (__status == cv_status::timeout)
276276 {
277 __base.__state_ &= ~__base.__write_entered_;
278 __base.__gate1_.notify_all();
277 __base_.__state_ &= ~__base_.__write_entered_;
278 __base_.__gate1_.notify_all();
279279 return false;
280280 }
281281 }
......@@ -288,22 +288,22 @@ bool
288288shared_timed_mutex::try_lock_shared_until(
289289 const chrono::time_point<_Clock, _Duration>& __abs_time)
290290{
291 unique_lock<mutex> __lk(__base.__mut_);
292 if ((__base.__state_ & __base.__write_entered_) || (__base.__state_ & __base.__n_readers_) == __base.__n_readers_)
291 unique_lock<mutex> __lk(__base_.__mut_);
292 if ((__base_.__state_ & __base_.__write_entered_) || (__base_.__state_ & __base_.__n_readers_) == __base_.__n_readers_)
293293 {
294294 while (true)
295295 {
296 cv_status status = __base.__gate1_.wait_until(__lk, __abs_time);
297 if ((__base.__state_ & __base.__write_entered_) == 0 &&
298 (__base.__state_ & __base.__n_readers_) < __base.__n_readers_)
296 cv_status status = __base_.__gate1_.wait_until(__lk, __abs_time);
297 if ((__base_.__state_ & __base_.__write_entered_) == 0 &&
298 (__base_.__state_ & __base_.__n_readers_) < __base_.__n_readers_)
299299 break;
300300 if (status == cv_status::timeout)
301301 return false;
302302 }
303303 }
304 unsigned __num_readers = (__base.__state_ & __base.__n_readers_) + 1;
305 __base.__state_ &= ~__base.__n_readers_;
306 __base.__state_ |= __num_readers;
304 unsigned __num_readers = (__base_.__state_ & __base_.__n_readers_) + 1;
305 __base_.__state_ &= ~__base_.__n_readers_;
306 __base_.__state_ |= __num_readers;
307307 return true;
308308}
309309
......@@ -432,6 +432,7 @@ public:
432432 _LIBCPP_INLINE_VISIBILITY
433433 mutex_type* mutex() const _NOEXCEPT {return __m_;}
434434};
435_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(shared_lock);
435436
436437template <class _Mutex>
437438void
lib/libcxx/include/source_location created+85
......@@ -0,0 +1,85 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_SOURCE_LOCATION
11#define _LIBCPP_SOURCE_LOCATION
12
13/* source_location synopsis
14
15namespace std {
16 struct source_location {
17 static consteval source_location current() noexcept;
18 constexpr source_location() noexcept;
19
20 constexpr uint_least32_t line() const noexcept;
21 constexpr uint_least32_t column() const noexcept;
22 constexpr const char* file_name() const noexcept;
23 constexpr const char* function_name() const noexcept;
24 };
25}
26*/
27
28#include <__config>
29#include <cstdint>
30#include <version>
31
32#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
33# pragma GCC system_header
34#endif
35
36_LIBCPP_BEGIN_NAMESPACE_STD
37
38#if _LIBCPP_STD_VER >= 20 && __has_builtin(__builtin_source_location)
39
40class source_location {
41 // The names source_location::__impl, _M_file_name, _M_function_name, _M_line, and _M_column
42 // are hard-coded in the compiler and must not be changed here.
43 struct __impl {
44 const char* _M_file_name;
45 const char* _M_function_name;
46 unsigned _M_line;
47 unsigned _M_column;
48 };
49 const __impl* __ptr_ = nullptr;
50 // GCC returns the type 'const void*' from the builtin, while clang returns
51 // `const __impl*`. Per C++ [expr.const], casts from void* are not permitted
52 // in constant evaluation, so we don't want to use `void*` as the argument
53 // type unless the builtin returned that, anyhow, and the invalid cast is
54 // unavoidable.
55 using __bsl_ty = decltype(__builtin_source_location());
56
57public:
58 // The defaulted __ptr argument is necessary so that the builtin is evaluated
59 // in the context of the caller. An explicit value should never be provided.
60 static consteval source_location current(__bsl_ty __ptr = __builtin_source_location()) noexcept {
61 source_location __sl;
62 __sl.__ptr_ = static_cast<const __impl*>(__ptr);
63 return __sl;
64 }
65 _LIBCPP_HIDE_FROM_ABI constexpr source_location() noexcept = default;
66
67 _LIBCPP_HIDE_FROM_ABI constexpr uint_least32_t line() const noexcept {
68 return __ptr_ != nullptr ? __ptr_->_M_line : 0;
69 }
70 _LIBCPP_HIDE_FROM_ABI constexpr uint_least32_t column() const noexcept {
71 return __ptr_ != nullptr ? __ptr_->_M_column : 0;
72 }
73 _LIBCPP_HIDE_FROM_ABI constexpr const char* file_name() const noexcept {
74 return __ptr_ != nullptr ? __ptr_->_M_file_name : "";
75 }
76 _LIBCPP_HIDE_FROM_ABI constexpr const char* function_name() const noexcept {
77 return __ptr_ != nullptr ? __ptr_->_M_function_name : "";
78 }
79};
80
81#endif // _LIBCPP_STD_VER >= 20 && __has_builtin(__builtin_source_location)
82
83_LIBCPP_END_NAMESPACE_STD
84
85#endif // _LIBCPP_SOURCE_LOCATION
lib/libcxx/include/span+43-94
......@@ -148,11 +148,6 @@ template<class R>
148148#include <type_traits> // for remove_cv, etc
149149#include <version>
150150
151#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
152# include <functional>
153# include <iterator>
154#endif
155
156151// standard-mandated includes
157152
158153// [iterator.range]
......@@ -185,23 +180,6 @@ struct __is_std_span : false_type {};
185180template <class _Tp, size_t _Sz>
186181struct __is_std_span<span<_Tp, _Sz>> : true_type {};
187182
188#if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
189// This is a temporary workaround until we ship <ranges> -- we've unfortunately been
190// shipping <span> before its API was finalized, and we used to provide a constructor
191// from container types that had the requirements below. To avoid breaking code that
192// has started relying on the range-based constructor until we ship all of <ranges>,
193// we emulate the constructor requirements like this.
194template <class _Range, class _ElementType>
195concept __span_compatible_range =
196 !__is_std_span<remove_cvref_t<_Range>>::value &&
197 !__is_std_array<remove_cvref_t<_Range>>::value &&
198 !is_array_v<remove_cvref_t<_Range>> &&
199 requires (_Range&& __r) {
200 data(std::forward<_Range>(__r));
201 size(std::forward<_Range>(__r));
202 } &&
203 is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>>(*)[], _ElementType(*)[]>;
204#else
205183template <class _Range, class _ElementType>
206184concept __span_compatible_range =
207185 ranges::contiguous_range<_Range> &&
......@@ -211,7 +189,6 @@ concept __span_compatible_range =
211189 !__is_std_array<remove_cvref_t<_Range>>::value &&
212190 !is_array_v<remove_cvref_t<_Range>> &&
213191 is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>>(*)[], _ElementType(*)[]>;
214#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
215192
216193template <class _From, class _To>
217194concept __span_array_convertible = is_convertible_v<_From(*)[], _To(*)[]>;
......@@ -234,7 +211,7 @@ public:
234211 using const_pointer = const _Tp *;
235212 using reference = _Tp &;
236213 using const_reference = const _Tp &;
237#ifdef _LIBCPP_ENABLE_DEBUG_MODE
214#ifdef _LIBCPP_DEBUG_ITERATOR_BOUNDS_CHECKING
238215 using iterator = __bounded_iter<pointer>;
239216#else
240217 using iterator = __wrap_iter<pointer>;
......@@ -245,7 +222,7 @@ public:
245222
246223// [span.cons], span constructors, copy, assignment, and destructor
247224 template <size_t _Sz = _Extent> requires(_Sz == 0)
248 _LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data{nullptr} {}
225 _LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data_{nullptr} {}
249226
250227 constexpr span (const span&) noexcept = default;
251228 constexpr span& operator=(const span&) noexcept = default;
......@@ -253,61 +230,46 @@ public:
253230 template <__span_compatible_iterator<element_type> _It>
254231 _LIBCPP_INLINE_VISIBILITY
255232 constexpr explicit span(_It __first, size_type __count)
256 : __data{_VSTD::to_address(__first)} {
233 : __data_{_VSTD::to_address(__first)} {
257234 (void)__count;
258235 _LIBCPP_ASSERT(_Extent == __count, "size mismatch in span's constructor (iterator, len)");
259236 }
260237
261238 template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End>
262239 _LIBCPP_INLINE_VISIBILITY
263 constexpr explicit span(_It __first, _End __last) : __data{_VSTD::to_address(__first)} {
240 constexpr explicit span(_It __first, _End __last) : __data_{_VSTD::to_address(__first)} {
264241 (void)__last;
265242 _LIBCPP_ASSERT((__last - __first >= 0), "invalid range in span's constructor (iterator, sentinel)");
266243 _LIBCPP_ASSERT(__last - __first == _Extent,
267244 "invalid range in span's constructor (iterator, sentinel): last - first != extent");
268245 }
269246
270 _LIBCPP_INLINE_VISIBILITY constexpr span(type_identity_t<element_type> (&__arr)[_Extent]) noexcept : __data{__arr} {}
247 _LIBCPP_INLINE_VISIBILITY constexpr span(type_identity_t<element_type> (&__arr)[_Extent]) noexcept : __data_{__arr} {}
271248
272249 template <__span_array_convertible<element_type> _OtherElementType>
273250 _LIBCPP_INLINE_VISIBILITY
274 constexpr span(array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {}
251 constexpr span(array<_OtherElementType, _Extent>& __arr) noexcept : __data_{__arr.data()} {}
275252
276253 template <class _OtherElementType>
277254 requires __span_array_convertible<const _OtherElementType, element_type>
278255 _LIBCPP_INLINE_VISIBILITY
279 constexpr span(const array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {}
256 constexpr span(const array<_OtherElementType, _Extent>& __arr) noexcept : __data_{__arr.data()} {}
280257
281#if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
282 template <class _Container>
283 requires __span_compatible_range<_Container, element_type>
284 _LIBCPP_INLINE_VISIBILITY
285 constexpr explicit span(_Container& __c) : __data{std::data(__c)} {
286 _LIBCPP_ASSERT(std::size(__c) == _Extent, "size mismatch in span's constructor (range)");
287 }
288 template <class _Container>
289 requires __span_compatible_range<const _Container, element_type>
290 _LIBCPP_INLINE_VISIBILITY
291 constexpr explicit span(const _Container& __c) : __data{std::data(__c)} {
292 _LIBCPP_ASSERT(std::size(__c) == _Extent, "size mismatch in span's constructor (range)");
293 }
294#else
295258 template <__span_compatible_range<element_type> _Range>
296259 _LIBCPP_INLINE_VISIBILITY
297 constexpr explicit span(_Range&& __r) : __data{ranges::data(__r)} {
260 constexpr explicit span(_Range&& __r) : __data_{ranges::data(__r)} {
298261 _LIBCPP_ASSERT(ranges::size(__r) == _Extent, "size mismatch in span's constructor (range)");
299262 }
300#endif
301263
302264 template <__span_array_convertible<element_type> _OtherElementType>
303265 _LIBCPP_INLINE_VISIBILITY
304266 constexpr span(const span<_OtherElementType, _Extent>& __other)
305 : __data{__other.data()} {}
267 : __data_{__other.data()} {}
306268
307269 template <__span_array_convertible<element_type> _OtherElementType>
308270 _LIBCPP_INLINE_VISIBILITY
309271 constexpr explicit span(const span<_OtherElementType, dynamic_extent>& __other) noexcept
310 : __data{__other.data()} { _LIBCPP_ASSERT(_Extent == __other.size(), "size mismatch in span's constructor (other span)"); }
272 : __data_{__other.data()} { _LIBCPP_ASSERT(_Extent == __other.size(), "size mismatch in span's constructor (other span)"); }
311273
312274
313275// ~span() noexcept = default;
......@@ -374,33 +336,33 @@ public:
374336 _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept
375337 {
376338 _LIBCPP_ASSERT(__idx < size(), "span<T, N>::operator[](index): index out of range");
377 return __data[__idx];
339 return __data_[__idx];
378340 }
379341
380342 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
381343 {
382344 _LIBCPP_ASSERT(!empty(), "span<T, N>::front() on empty span");
383 return __data[0];
345 return __data_[0];
384346 }
385347
386348 _LIBCPP_INLINE_VISIBILITY constexpr reference back() const noexcept
387349 {
388350 _LIBCPP_ASSERT(!empty(), "span<T, N>::back() on empty span");
389 return __data[size()-1];
351 return __data_[size()-1];
390352 }
391353
392 _LIBCPP_INLINE_VISIBILITY constexpr pointer data() const noexcept { return __data; }
354 _LIBCPP_INLINE_VISIBILITY constexpr pointer data() const noexcept { return __data_; }
393355
394356// [span.iter], span iterator support
395357 _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept {
396#ifdef _LIBCPP_ENABLE_DEBUG_MODE
358#ifdef _LIBCPP_DEBUG_ITERATOR_BOUNDS_CHECKING
397359 return std::__make_bounded_iter(data(), data(), data() + size());
398360#else
399361 return iterator(this, data());
400362#endif
401363 }
402364 _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept {
403#ifdef _LIBCPP_ENABLE_DEBUG_MODE
365#ifdef _LIBCPP_DEBUG_ITERATOR_BOUNDS_CHECKING
404366 return std::__make_bounded_iter(data() + size(), data(), data() + size());
405367#else
406368 return iterator(this, data() + size());
......@@ -416,7 +378,7 @@ public:
416378 { return span<byte, _Extent * sizeof(element_type)>{reinterpret_cast<byte *>(data()), size_bytes()}; }
417379
418380private:
419 pointer __data;
381 pointer __data_;
420382};
421383
422384
......@@ -432,7 +394,7 @@ public:
432394 using const_pointer = const _Tp *;
433395 using reference = _Tp &;
434396 using const_reference = const _Tp &;
435#ifdef _LIBCPP_ENABLE_DEBUG_MODE
397#ifdef _LIBCPP_DEBUG_ITERATOR_BOUNDS_CHECKING
436398 using iterator = __bounded_iter<pointer>;
437399#else
438400 using iterator = __wrap_iter<pointer>;
......@@ -442,7 +404,7 @@ public:
442404 static constexpr size_type extent = dynamic_extent;
443405
444406// [span.cons], span constructors, copy, assignment, and destructor
445 _LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data{nullptr}, __size{0} {}
407 _LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data_{nullptr}, __size_{0} {}
446408
447409 constexpr span (const span&) noexcept = default;
448410 constexpr span& operator=(const span&) noexcept = default;
......@@ -450,46 +412,35 @@ public:
450412 template <__span_compatible_iterator<element_type> _It>
451413 _LIBCPP_INLINE_VISIBILITY
452414 constexpr span(_It __first, size_type __count)
453 : __data{_VSTD::to_address(__first)}, __size{__count} {}
415 : __data_{_VSTD::to_address(__first)}, __size_{__count} {}
454416
455417 template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End>
456418 _LIBCPP_INLINE_VISIBILITY constexpr span(_It __first, _End __last)
457 : __data(_VSTD::to_address(__first)), __size(__last - __first) {
419 : __data_(_VSTD::to_address(__first)), __size_(__last - __first) {
458420 _LIBCPP_ASSERT(__last - __first >= 0, "invalid range in span's constructor (iterator, sentinel)");
459421 }
460422
461423 template <size_t _Sz>
462424 _LIBCPP_INLINE_VISIBILITY
463 constexpr span(type_identity_t<element_type> (&__arr)[_Sz]) noexcept : __data{__arr}, __size{_Sz} {}
425 constexpr span(type_identity_t<element_type> (&__arr)[_Sz]) noexcept : __data_{__arr}, __size_{_Sz} {}
464426
465427 template <__span_array_convertible<element_type> _OtherElementType, size_t _Sz>
466428 _LIBCPP_INLINE_VISIBILITY
467 constexpr span(array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}
429 constexpr span(array<_OtherElementType, _Sz>& __arr) noexcept : __data_{__arr.data()}, __size_{_Sz} {}
468430
469431 template <class _OtherElementType, size_t _Sz>
470432 requires __span_array_convertible<const _OtherElementType, element_type>
471433 _LIBCPP_INLINE_VISIBILITY
472 constexpr span(const array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {}
434 constexpr span(const array<_OtherElementType, _Sz>& __arr) noexcept : __data_{__arr.data()}, __size_{_Sz} {}
473435
474#if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
475 template <class _Container>
476 requires __span_compatible_range<_Container, element_type>
477 _LIBCPP_INLINE_VISIBILITY
478 constexpr span(_Container& __c) : __data(std::data(__c)), __size{std::size(__c)} {}
479 template <class _Container>
480 requires __span_compatible_range<const _Container, element_type>
481 _LIBCPP_INLINE_VISIBILITY
482 constexpr span(const _Container& __c) : __data(std::data(__c)), __size{std::size(__c)} {}
483#else
484436 template <__span_compatible_range<element_type> _Range>
485437 _LIBCPP_INLINE_VISIBILITY
486 constexpr span(_Range&& __r) : __data(ranges::data(__r)), __size{ranges::size(__r)} {}
487#endif
438 constexpr span(_Range&& __r) : __data_(ranges::data(__r)), __size_{ranges::size(__r)} {}
488439
489440 template <__span_array_convertible<element_type> _OtherElementType, size_t _OtherExtent>
490441 _LIBCPP_INLINE_VISIBILITY
491442 constexpr span(const span<_OtherElementType, _OtherExtent>& __other) noexcept
492 : __data{__other.data()}, __size{__other.size()} {}
443 : __data_{__other.data()}, __size_{__other.size()} {}
493444
494445// ~span() noexcept = default;
495446
......@@ -544,41 +495,41 @@ public:
544495 return {data() + __offset, __count};
545496 }
546497
547 _LIBCPP_INLINE_VISIBILITY constexpr size_type size() const noexcept { return __size; }
548 _LIBCPP_INLINE_VISIBILITY constexpr size_type size_bytes() const noexcept { return __size * sizeof(element_type); }
549 [[nodiscard]] _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return __size == 0; }
498 _LIBCPP_INLINE_VISIBILITY constexpr size_type size() const noexcept { return __size_; }
499 _LIBCPP_INLINE_VISIBILITY constexpr size_type size_bytes() const noexcept { return __size_ * sizeof(element_type); }
500 [[nodiscard]] _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return __size_ == 0; }
550501
551502 _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept
552503 {
553504 _LIBCPP_ASSERT(__idx < size(), "span<T>::operator[](index): index out of range");
554 return __data[__idx];
505 return __data_[__idx];
555506 }
556507
557508 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
558509 {
559510 _LIBCPP_ASSERT(!empty(), "span<T>::front() on empty span");
560 return __data[0];
511 return __data_[0];
561512 }
562513
563514 _LIBCPP_INLINE_VISIBILITY constexpr reference back() const noexcept
564515 {
565516 _LIBCPP_ASSERT(!empty(), "span<T>::back() on empty span");
566 return __data[size()-1];
517 return __data_[size()-1];
567518 }
568519
569520
570 _LIBCPP_INLINE_VISIBILITY constexpr pointer data() const noexcept { return __data; }
521 _LIBCPP_INLINE_VISIBILITY constexpr pointer data() const noexcept { return __data_; }
571522
572523// [span.iter], span iterator support
573524 _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept {
574#ifdef _LIBCPP_ENABLE_DEBUG_MODE
525#ifdef _LIBCPP_DEBUG_ITERATOR_BOUNDS_CHECKING
575526 return std::__make_bounded_iter(data(), data(), data() + size());
576527#else
577528 return iterator(this, data());
578529#endif
579530 }
580531 _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept {
581#ifdef _LIBCPP_ENABLE_DEBUG_MODE
532#ifdef _LIBCPP_DEBUG_ITERATOR_BOUNDS_CHECKING
582533 return std::__make_bounded_iter(data() + size(), data(), data() + size());
583534#else
584535 return iterator(this, data() + size());
......@@ -594,8 +545,8 @@ public:
594545 { return {reinterpret_cast<byte *>(data()), size_bytes()}; }
595546
596547private:
597 pointer __data;
598 size_type __size;
548 pointer __data_;
549 size_type __size_;
599550};
600551
601552template <class _Tp, size_t _Extent>
......@@ -629,16 +580,8 @@ template<class _Tp, size_t _Sz>
629580template<class _Tp, size_t _Sz>
630581 span(const array<_Tp, _Sz>&) -> span<const _Tp, _Sz>;
631582
632#if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
633template<class _Container>
634 span(_Container&) -> span<typename _Container::value_type>;
635
636template<class _Container>
637 span(const _Container&) -> span<const typename _Container::value_type>;
638#else
639583template<ranges::contiguous_range _Range>
640584 span(_Range&&) -> span<remove_reference_t<ranges::range_reference_t<_Range>>>;
641#endif
642585
643586#endif // _LIBCPP_STD_VER > 17
644587
......@@ -646,4 +589,10 @@ _LIBCPP_END_NAMESPACE_STD
646589
647590_LIBCPP_POP_MACROS
648591
592#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
593# include <concepts>
594# include <functional>
595# include <iterator>
596#endif
597
649598#endif // _LIBCPP_SPAN
lib/libcxx/include/sstream+48-39
......@@ -11,8 +11,9 @@
1111#define _LIBCPP_SSTREAM
1212
1313/*
14 sstream synopsis
14 sstream synopsis [sstream.syn]
1515
16// Class template basic_stringbuf [stringbuf]
1617template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
1718class basic_stringbuf
1819 : public basic_streambuf<charT, traits>
......@@ -25,7 +26,7 @@ public:
2526 typedef typename traits_type::off_type off_type;
2627 typedef Allocator allocator_type;
2728
28 // 27.8.1.1 [stringbuf.cons], constructors:
29 // [stringbuf.cons] constructors:
2930 explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out); // before C++20
3031 basic_stringbuf() : basic_stringbuf(ios_base::in | ios_base::out) {} // C++20
3132 explicit basic_stringbuf(ios_base::openmode which); // C++20
......@@ -33,16 +34,16 @@ public:
3334 ios_base::openmode which = ios_base::in | ios_base::out);
3435 basic_stringbuf(basic_stringbuf&& rhs);
3536
36 // 27.8.1.2 Assign and swap:
37 // [stringbuf.assign] Assign and swap:
3738 basic_stringbuf& operator=(basic_stringbuf&& rhs);
3839 void swap(basic_stringbuf& rhs);
3940
40 // 27.8.1.3 Get and set:
41 // [stringbuf.members] Member functions:
4142 basic_string<char_type, traits_type, allocator_type> str() const;
4243 void str(const basic_string<char_type, traits_type, allocator_type>& s);
4344
4445protected:
45 // 27.8.1.4 Overridden virtual functions:
46 // [stringbuf.virtuals] Overridden virtual functions:
4647 virtual int_type underflow();
4748 virtual int_type pbackfail(int_type c = traits_type::eof());
4849 virtual int_type overflow (int_type c = traits_type::eof());
......@@ -53,6 +54,7 @@ protected:
5354 ios_base::openmode which = ios_base::in | ios_base::out);
5455};
5556
57// [stringbuf.assign] non member swap
5658template <class charT, class traits, class Allocator>
5759 void swap(basic_stringbuf<charT, traits, Allocator>& x,
5860 basic_stringbuf<charT, traits, Allocator>& y);
......@@ -60,6 +62,7 @@ template <class charT, class traits, class Allocator>
6062typedef basic_stringbuf<char> stringbuf;
6163typedef basic_stringbuf<wchar_t> wstringbuf;
6264
65// Class template basic_istringstream [istringstream]
6366template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
6467class basic_istringstream
6568 : public basic_istream<charT, traits>
......@@ -72,7 +75,7 @@ public:
7275 typedef typename traits_type::off_type off_type;
7376 typedef Allocator allocator_type;
7477
75 // 27.8.2.1 Constructors:
78 // [istringstream.cons] Constructors:
7679 explicit basic_istringstream(ios_base::openmode which = ios_base::in); // before C++20
7780 basic_istringstream() : basic_istringstream(ios_base::in) {} // C++20
7881 explicit basic_istringstream(ios_base::openmode which); // C++20
......@@ -81,11 +84,11 @@ public:
8184 ios_base::openmode which = ios_base::in);
8285 basic_istringstream(basic_istringstream&& rhs);
8386
84 // 27.8.2.2 Assign and swap:
87 // [istringstream.assign] Assign and swap:
8588 basic_istringstream& operator=(basic_istringstream&& rhs);
8689 void swap(basic_istringstream& rhs);
8790
88 // 27.8.2.3 Members:
91 // [istringstream.members] Member functions:
8992 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
9093 basic_string<char_type, traits_type, allocator_type> str() const;
9194 void str(const basic_string<char_type, traits_type, allocator_type>& s);
......@@ -98,6 +101,7 @@ template <class charT, class traits, class Allocator>
98101typedef basic_istringstream<char> istringstream;
99102typedef basic_istringstream<wchar_t> wistringstream;
100103
104// Class template basic_ostringstream [ostringstream]
101105template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
102106class basic_ostringstream
103107 : public basic_ostream<charT, traits>
......@@ -111,7 +115,7 @@ public:
111115 typedef typename traits_type::off_type off_type;
112116 typedef Allocator allocator_type;
113117
114 // 27.8.3.1 Constructors/destructor:
118 // [ostringstream.cons] Constructors:
115119 explicit basic_ostringstream(ios_base::openmode which = ios_base::out); // before C++20
116120 basic_ostringstream() : basic_ostringstream(ios_base::out) {} // C++20
117121 explicit basic_ostringstream(ios_base::openmode which); // C++20
......@@ -120,11 +124,11 @@ public:
120124 ios_base::openmode which = ios_base::out);
121125 basic_ostringstream(basic_ostringstream&& rhs);
122126
123 // 27.8.3.2 Assign/swap:
127 // [ostringstream.assign] Assign and swap:
124128 basic_ostringstream& operator=(basic_ostringstream&& rhs);
125129 void swap(basic_ostringstream& rhs);
126130
127 // 27.8.3.3 Members:
131 // [ostringstream.members] Member functions:
128132 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
129133 basic_string<char_type, traits_type, allocator_type> str() const;
130134 void str(const basic_string<char_type, traits_type, allocator_type>& s);
......@@ -137,6 +141,7 @@ template <class charT, class traits, class Allocator>
137141typedef basic_ostringstream<char> ostringstream;
138142typedef basic_ostringstream<wchar_t> wostringstream;
139143
144// Class template basic_stringstream [stringstream]
140145template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
141146class basic_stringstream
142147 : public basic_iostream<charT, traits>
......@@ -150,7 +155,7 @@ public:
150155 typedef typename traits_type::off_type off_type;
151156 typedef Allocator allocator_type;
152157
153 // constructors/destructor
158 // [stringstream.cons] constructors
154159 explicit basic_stringstream(ios_base::openmode which = ios_base::out | ios_base::in); // before C++20
155160 basic_stringstream() : basic_stringstream(ios_base::out | ios_base::in) {} // C++20
156161 explicit basic_stringstream(ios_base::openmode which); // C++20
......@@ -159,11 +164,11 @@ public:
159164 ios_base::openmode which = ios_base::out|ios_base::in);
160165 basic_stringstream(basic_stringstream&& rhs);
161166
162 // 27.8.5.1 Assign/swap:
167 // [stringstream.assign] Assign and swap:
163168 basic_stringstream& operator=(basic_stringstream&& rhs);
164169 void swap(basic_stringstream& rhs);
165170
166 // Members:
171 // [stringstream.members] Member functions:
167172 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
168173 basic_string<char_type, traits_type, allocator_type> str() const;
169174 void str(const basic_string<char_type, traits_type, allocator_type>& str);
......@@ -198,7 +203,7 @@ _LIBCPP_PUSH_MACROS
198203
199204_LIBCPP_BEGIN_NAMESPACE_STD
200205
201// basic_stringbuf
206// Class template basic_stringbuf [stringbuf]
202207
203208template <class _CharT, class _Traits, class _Allocator>
204209class _LIBCPP_TEMPLATE_VIS basic_stringbuf
......@@ -221,7 +226,7 @@ private:
221226 ios_base::openmode __mode_;
222227
223228public:
224 // 30.8.2.1 [stringbuf.cons], constructors
229 // [stringbuf.cons] constructors:
225230 _LIBCPP_INLINE_VISIBILITY
226231 basic_stringbuf()
227232 : __hm_(nullptr), __mode_(ios_base::in | ios_base::out) {}
......@@ -240,24 +245,24 @@ public:
240245
241246 basic_stringbuf(basic_stringbuf&& __rhs);
242247
243 // 27.8.1.2 Assign and swap:
248 // [stringbuf.assign] Assign and swap:
244249 basic_stringbuf& operator=(basic_stringbuf&& __rhs);
245250 void swap(basic_stringbuf& __rhs);
246251
247 // 27.8.1.3 Get and set:
252 // [stringbuf.members] Member functions:
248253 string_type str() const;
249254 void str(const string_type& __s);
250255
251256protected:
252 // 27.8.1.4 Overridden virtual functions:
253 virtual int_type underflow();
254 virtual int_type pbackfail(int_type __c = traits_type::eof());
255 virtual int_type overflow (int_type __c = traits_type::eof());
256 virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
257 ios_base::openmode __wch = ios_base::in | ios_base::out);
258 _LIBCPP_INLINE_VISIBILITY
259 virtual pos_type seekpos(pos_type __sp,
260 ios_base::openmode __wch = ios_base::in | ios_base::out) {
257 // [stringbuf.virtuals] Overridden virtual functions:
258 int_type underflow() override;
259 int_type pbackfail(int_type __c = traits_type::eof()) override;
260 int_type overflow (int_type __c = traits_type::eof()) override;
261 pos_type seekoff(off_type __off, ios_base::seekdir __way,
262 ios_base::openmode __wch = ios_base::in | ios_base::out) override;
263 _LIBCPP_HIDE_FROM_ABI_VIRTUAL
264 pos_type seekpos(pos_type __sp,
265 ios_base::openmode __wch = ios_base::in | ios_base::out) override {
261266 return seekoff(__sp, ios_base::beg, __wch);
262267 }
263268};
......@@ -619,7 +624,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off,
619624 return pos_type(__noff);
620625}
621626
622// basic_istringstream
627// Class template basic_istringstream [istringstream]
623628
624629template <class _CharT, class _Traits, class _Allocator>
625630class _LIBCPP_TEMPLATE_VIS basic_istringstream
......@@ -639,7 +644,7 @@ private:
639644 basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
640645
641646public:
642 // 30.8.3.1 [istringstream.cons], constructors
647 // [istringstream.cons] Constructors:
643648 _LIBCPP_INLINE_VISIBILITY
644649 basic_istringstream()
645650 : basic_istream<_CharT, _Traits>(&__sb_), __sb_(ios_base::in) {}
......@@ -663,7 +668,7 @@ public:
663668 basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
664669 }
665670
666 // 27.8.2.2 Assign and swap:
671 // [istringstream.assign] Assign and swap:
667672 basic_istringstream& operator=(basic_istringstream&& __rhs) {
668673 basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
669674 __sb_ = _VSTD::move(__rhs.__sb_);
......@@ -675,7 +680,7 @@ public:
675680 __sb_.swap(__rhs.__sb_);
676681 }
677682
678 // 27.8.2.3 Members:
683 // [istringstream.members] Member functions:
679684 _LIBCPP_INLINE_VISIBILITY
680685 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
681686 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
......@@ -699,7 +704,7 @@ swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x,
699704 __x.swap(__y);
700705}
701706
702// basic_ostringstream
707// Class template basic_ostringstream [ostringstream]
703708
704709template <class _CharT, class _Traits, class _Allocator>
705710class _LIBCPP_TEMPLATE_VIS basic_ostringstream
......@@ -719,7 +724,7 @@ private:
719724 basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
720725
721726public:
722 // 30.8.4.1 [ostringstream.cons], constructors
727 // [ostringstream.cons] Constructors:
723728 _LIBCPP_INLINE_VISIBILITY
724729 basic_ostringstream()
725730 : basic_ostream<_CharT, _Traits>(&__sb_), __sb_(ios_base::out) {}
......@@ -743,7 +748,7 @@ public:
743748 basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_);
744749 }
745750
746 // 27.8.2.2 Assign and swap:
751 // [ostringstream.assign] Assign and swap:
747752 basic_ostringstream& operator=(basic_ostringstream&& __rhs) {
748753 basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
749754 __sb_ = _VSTD::move(__rhs.__sb_);
......@@ -756,7 +761,7 @@ public:
756761 __sb_.swap(__rhs.__sb_);
757762 }
758763
759 // 27.8.2.3 Members:
764 // [ostringstream.members] Member functions:
760765 _LIBCPP_INLINE_VISIBILITY
761766 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
762767 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
......@@ -780,7 +785,7 @@ swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x,
780785 __x.swap(__y);
781786}
782787
783// basic_stringstream
788// Class template basic_stringstream [stringstream]
784789
785790template <class _CharT, class _Traits, class _Allocator>
786791class _LIBCPP_TEMPLATE_VIS basic_stringstream
......@@ -800,7 +805,7 @@ private:
800805 basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
801806
802807public:
803 // 30.8.5.1 [stringstream.cons], constructors
808 // [stringstream.cons] constructors
804809 _LIBCPP_INLINE_VISIBILITY
805810 basic_stringstream()
806811 : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(ios_base::in | ios_base::out) {}
......@@ -824,7 +829,7 @@ public:
824829 basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
825830 }
826831
827 // 27.8.2.2 Assign and swap:
832 // [stringstream.assign] Assign and swap:
828833 basic_stringstream& operator=(basic_stringstream&& __rhs) {
829834 basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
830835 __sb_ = _VSTD::move(__rhs.__sb_);
......@@ -836,7 +841,7 @@ public:
836841 __sb_.swap(__rhs.__sb_);
837842 }
838843
839 // 27.8.2.3 Members:
844 // [stringstream.members] Member functions:
840845 _LIBCPP_INLINE_VISIBILITY
841846 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
842847 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
......@@ -871,4 +876,8 @@ _LIBCPP_END_NAMESPACE_STD
871876
872877_LIBCPP_POP_MACROS
873878
879#if _LIBCPP_STD_VER <= 20 && !defined(_LIPCPP_REMOVE_TRANSITIVE_INCLUDES)
880# include <type_traits>
881#endif
882
874883#endif // _LIBCPP_SSTREAM
lib/libcxx/include/stack+9-4
......@@ -107,11 +107,9 @@ template <class T, class Container>
107107#include <type_traits>
108108#include <version>
109109
110#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
111# include <functional>
112#endif
113
114110// standard-mandated includes
111
112// [stack.syn]
115113#include <compare>
116114#include <initializer_list>
117115
......@@ -257,6 +255,8 @@ public:
257255 swap(c, __s.c);
258256 }
259257
258 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
259
260260 template <class T1, class _C1>
261261 friend
262262 bool
......@@ -363,4 +363,9 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator<stack<_Tp, _Container>, _Alloc>
363363
364364_LIBCPP_END_NAMESPACE_STD
365365
366#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
367# include <concepts>
368# include <functional>
369#endif
370
366371#endif // _LIBCPP_STACK
lib/libcxx/include/stdbool.h+4-1
......@@ -6,6 +6,7 @@
66// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77//
88//===----------------------------------------------------------------------===//
9
910#ifndef _LIBCPP_STDBOOL_H
1011#define _LIBCPP_STDBOOL_H
1112
......@@ -24,7 +25,9 @@ Macros:
2425# pragma GCC system_header
2526#endif
2627
27#include_next <stdbool.h>
28#if __has_include_next(<stdbool.h>)
29# include_next <stdbool.h>
30#endif
2831
2932#ifdef __cplusplus
3033#undef bool
lib/libcxx/include/stddef.h+3-1
......@@ -42,7 +42,9 @@ Types:
4242# pragma GCC system_header
4343#endif
4444
45#include_next <stddef.h>
45# if __has_include_next(<stddef.h>)
46# include_next <stddef.h>
47# endif
4648
4749#ifdef __cplusplus
4850 typedef decltype(nullptr) nullptr_t;
lib/libcxx/include/stdexcept+11-11
......@@ -87,9 +87,9 @@ public:
8787 logic_error(const logic_error&) _NOEXCEPT;
8888 logic_error& operator=(const logic_error&) _NOEXCEPT;
8989
90 virtual ~logic_error() _NOEXCEPT;
90 ~logic_error() _NOEXCEPT override;
9191
92 virtual const char* what() const _NOEXCEPT;
92 const char* what() const _NOEXCEPT override;
9393#else
9494public:
9595 explicit logic_error(const _VSTD::string&); // Symbol uses versioned std::string
......@@ -110,9 +110,9 @@ public:
110110 runtime_error(const runtime_error&) _NOEXCEPT;
111111 runtime_error& operator=(const runtime_error&) _NOEXCEPT;
112112
113 virtual ~runtime_error() _NOEXCEPT;
113 ~runtime_error() _NOEXCEPT override;
114114
115 virtual const char* what() const _NOEXCEPT;
115 const char* what() const _NOEXCEPT override;
116116#else
117117public:
118118 explicit runtime_error(const _VSTD::string&); // Symbol uses versioned std::string
......@@ -129,7 +129,7 @@ public:
129129
130130#ifndef _LIBCPP_ABI_VCRUNTIME
131131 domain_error(const domain_error&) _NOEXCEPT = default;
132 virtual ~domain_error() _NOEXCEPT;
132 ~domain_error() _NOEXCEPT override;
133133#endif
134134};
135135
......@@ -142,7 +142,7 @@ public:
142142
143143#ifndef _LIBCPP_ABI_VCRUNTIME
144144 invalid_argument(const invalid_argument&) _NOEXCEPT = default;
145 virtual ~invalid_argument() _NOEXCEPT;
145 ~invalid_argument() _NOEXCEPT override;
146146#endif
147147};
148148
......@@ -154,7 +154,7 @@ public:
154154 _LIBCPP_INLINE_VISIBILITY explicit length_error(const char* __s) : logic_error(__s) {}
155155#ifndef _LIBCPP_ABI_VCRUNTIME
156156 length_error(const length_error&) _NOEXCEPT = default;
157 virtual ~length_error() _NOEXCEPT;
157 ~length_error() _NOEXCEPT override;
158158#endif
159159};
160160
......@@ -167,7 +167,7 @@ public:
167167
168168#ifndef _LIBCPP_ABI_VCRUNTIME
169169 out_of_range(const out_of_range&) _NOEXCEPT = default;
170 virtual ~out_of_range() _NOEXCEPT;
170 ~out_of_range() _NOEXCEPT override;
171171#endif
172172};
173173
......@@ -180,7 +180,7 @@ public:
180180
181181#ifndef _LIBCPP_ABI_VCRUNTIME
182182 range_error(const range_error&) _NOEXCEPT = default;
183 virtual ~range_error() _NOEXCEPT;
183 ~range_error() _NOEXCEPT override;
184184#endif
185185};
186186
......@@ -193,7 +193,7 @@ public:
193193
194194#ifndef _LIBCPP_ABI_VCRUNTIME
195195 overflow_error(const overflow_error&) _NOEXCEPT = default;
196 virtual ~overflow_error() _NOEXCEPT;
196 ~overflow_error() _NOEXCEPT override;
197197#endif
198198};
199199
......@@ -206,7 +206,7 @@ public:
206206
207207#ifndef _LIBCPP_ABI_VCRUNTIME
208208 underflow_error(const underflow_error&) _NOEXCEPT = default;
209 virtual ~underflow_error() _NOEXCEPT;
209 ~underflow_error() _NOEXCEPT override;
210210#endif
211211};
212212
lib/libcxx/include/stdint.h+3-1
......@@ -120,6 +120,8 @@ Macros:
120120# define __STDC_CONSTANT_MACROS
121121#endif
122122
123#include_next <stdint.h>
123#if __has_include_next(<stdint.h>)
124# include_next <stdint.h>
125#endif
124126
125127#endif // _LIBCPP_STDINT_H
lib/libcxx/include/stdio.h+3-1
......@@ -104,7 +104,9 @@ void perror(const char* s);
104104# pragma GCC system_header
105105#endif
106106
107#include_next <stdio.h>
107# if __has_include_next(<stdio.h>)
108# include_next <stdio.h>
109# endif
108110
109111#ifdef __cplusplus
110112
lib/libcxx/include/stdlib.h+8-6
......@@ -90,7 +90,9 @@ void *aligned_alloc(size_t alignment, size_t size); // C11
9090# pragma GCC system_header
9191#endif
9292
93#include_next <stdlib.h>
93# if __has_include_next(<stdlib.h>)
94# include_next <stdlib.h>
95# endif
9496
9597#ifdef __cplusplus
9698extern "C++" {
......@@ -108,24 +110,24 @@ extern "C++" {
108110
109111// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
110112#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__)
111inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT {
113_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT {
112114 return __builtin_labs(__x);
113115}
114inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {
116_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {
115117 return __builtin_llabs(__x);
116118}
117119#endif // !defined(_LIBCPP_MSVCRT) && !defined(__sun__)
118120
119121#if !defined(__sun__)
120inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT {
122_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT {
121123 return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h
122124}
123125
124inline _LIBCPP_INLINE_VISIBILITY double abs(double __lcpp_x) _NOEXCEPT {
126_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY double abs(double __lcpp_x) _NOEXCEPT {
125127 return __builtin_fabs(__lcpp_x);
126128}
127129
128inline _LIBCPP_INLINE_VISIBILITY long double
130_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY long double
129131abs(long double __lcpp_x) _NOEXCEPT {
130132 return __builtin_fabsl(__lcpp_x);
131133}
lib/libcxx/include/streambuf+4-2
......@@ -489,10 +489,12 @@ basic_streambuf<_CharT, _Traits>::overflow(int_type)
489489}
490490
491491extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>;
492extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>;
493
494492extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>;
493
494#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
495extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>;
495496extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>;
497#endif
496498
497499_LIBCPP_END_NAMESPACE_STD
498500
lib/libcxx/include/string+777-860
......@@ -13,6 +13,9 @@
1313/*
1414 string synopsis
1515
16#include <compare>
17#include <initializer_list>
18
1619namespace std
1720{
1821
......@@ -43,11 +46,13 @@ template <class stateT> bool operator!=(const fpos<stateT>& x, const fpos<stateT
4346template <class charT>
4447struct char_traits
4548{
46 typedef charT char_type;
47 typedef ... int_type;
48 typedef streamoff off_type;
49 typedef streampos pos_type;
50 typedef mbstate_t state_type;
49 using char_type = charT;
50 using int_type = ...;
51 using off_type = streamoff;
52 using pos_type = streampos;
53 using state_type = mbstate_t;
54 using comparison_category = strong_ordering; // Since C++20 only for the specializations
55 // char, wchar_t, char8_t, char16_t, and char32_t.
5156
5257 static void assign(char_type& c1, const char_type& c2) noexcept;
5358 static constexpr bool eq(char_type c1, char_type c2) noexcept;
......@@ -104,6 +109,10 @@ public:
104109 const allocator_type& a = allocator_type()); // constexpr since C++20
105110 basic_string(const basic_string& str, size_type pos, size_type n,
106111 const Allocator& a = Allocator()); // constexpr since C++20
112 constexpr basic_string(
113 basic_string&& str, size_type pos, const Allocator& a = Allocator()); // since C++23
114 constexpr basic_string(
115 basic_string&& str, size_type pos, size_type n, const Allocator& a = Allocator()); // since C++23
107116 template<class T>
108117 basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator()); // C++17, constexpr since C++20
109118 template <class T>
......@@ -256,8 +265,9 @@ public:
256265 basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<value_type>); // constexpr since C++20
257266
258267 size_type copy(value_type* s, size_type n, size_type pos = 0) const; // constexpr since C++20
259 basic_string substr(size_type pos = 0, size_type n = npos) const; // constexpr since C++20
260
268 basic_string substr(size_type pos = 0, size_type n = npos) const; // constexpr in C++20, removed in C++23
269 basic_string substr(size_type pos = 0, size_type n = npos) const&; // since C++23
270 constexpr basic_string substr(size_type pos = 0, size_type n = npos) &&; // since C++23
261271 void swap(basic_string& str)
262272 noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
263273 allocator_traits<allocator_type>::is_always_equal::value); // C++17, constexpr since C++20
......@@ -370,60 +380,68 @@ bool operator==(const basic_string<charT, traits, Allocator>& lhs,
370380 const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
371381
372382template<class charT, class traits, class Allocator>
373bool operator==(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
383bool operator==(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
374384
375385template<class charT, class traits, class Allocator>
376386bool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
377387
378388template<class charT, class traits, class Allocator>
379389bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
380 const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
390 const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
381391
382392template<class charT, class traits, class Allocator>
383bool operator!=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
393bool operator!=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
384394
385395template<class charT, class traits, class Allocator>
386bool operator!=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
396bool operator!=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // removed in C++20
387397
388398template<class charT, class traits, class Allocator>
389399bool operator< (const basic_string<charT, traits, Allocator>& lhs,
390 const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
400 const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
391401
392402template<class charT, class traits, class Allocator>
393bool operator< (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
403bool operator< (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // removed in C++20
394404
395405template<class charT, class traits, class Allocator>
396bool operator< (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
406bool operator< (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
397407
398408template<class charT, class traits, class Allocator>
399409bool operator> (const basic_string<charT, traits, Allocator>& lhs,
400 const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
410 const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
401411
402412template<class charT, class traits, class Allocator>
403bool operator> (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
413bool operator> (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // removed in C++20
404414
405415template<class charT, class traits, class Allocator>
406bool operator> (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
416bool operator> (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
407417
408418template<class charT, class traits, class Allocator>
409419bool operator<=(const basic_string<charT, traits, Allocator>& lhs,
410 const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
420 const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
411421
412422template<class charT, class traits, class Allocator>
413bool operator<=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
423bool operator<=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // removed in C++20
414424
415425template<class charT, class traits, class Allocator>
416bool operator<=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
426bool operator<=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
417427
418428template<class charT, class traits, class Allocator>
419429bool operator>=(const basic_string<charT, traits, Allocator>& lhs,
420 const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
430 const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
421431
422432template<class charT, class traits, class Allocator>
423bool operator>=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
433bool operator>=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // removed in C++20
424434
425435template<class charT, class traits, class Allocator>
426bool operator>=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
436bool operator>=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
437
438template<class charT, class traits, class Allocator> // since C++20
439constexpr see below operator<=>(const basic_string<charT, traits, Allocator>& lhs,
440 const basic_string<charT, traits, Allocator>& rhs) noexcept;
441
442template<class charT, class traits, class Allocator> // since C++20
443constexpr see below operator<=>(const basic_string<charT, traits, Allocator>& lhs,
444 const charT* rhs) noexcept;
427445
428446template<class charT, class traits, class Allocator>
429447void swap(basic_string<charT, traits, Allocator>& lhs,
......@@ -526,15 +544,24 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len );
526544#include <__format/enable_insertable.h>
527545#include <__functional/hash.h>
528546#include <__functional/unary_function.h>
547#include <__fwd/string.h>
529548#include <__ios/fpos.h>
530549#include <__iterator/distance.h>
531550#include <__iterator/iterator_traits.h>
532551#include <__iterator/reverse_iterator.h>
533552#include <__iterator/wrap_iter.h>
534553#include <__memory/allocate_at_least.h>
554#include <__memory/allocator.h>
555#include <__memory/allocator_traits.h>
556#include <__memory/compressed_pair.h>
557#include <__memory/construct_at.h>
558#include <__memory/pointer_traits.h>
535559#include <__memory/swap_allocator.h>
560#include <__memory_resource/polymorphic_allocator.h>
536561#include <__string/char_traits.h>
537562#include <__string/extern_template_lists.h>
563#include <__type_traits/is_allocator.h>
564#include <__type_traits/noexcept_move_assign_container.h>
538565#include <__utility/auto_cast.h>
539566#include <__utility/move.h>
540567#include <__utility/swap.h>
......@@ -544,9 +571,7 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len );
544571#include <cstdio> // EOF
545572#include <cstdlib>
546573#include <cstring>
547#include <iosfwd>
548574#include <limits>
549#include <memory>
550575#include <stdexcept>
551576#include <string_view>
552577#include <type_traits>
......@@ -556,16 +581,6 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len );
556581# include <cwchar>
557582#endif
558583
559#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
560# include <algorithm>
561# include <functional>
562# include <iterator>
563# include <new>
564# include <typeinfo>
565# include <utility>
566# include <vector>
567#endif
568
569584// standard-mandated includes
570585
571586// [iterator.range]
......@@ -593,27 +608,27 @@ _LIBCPP_BEGIN_NAMESPACE_STD
593608
594609template<class _CharT, class _Traits, class _Allocator>
595610basic_string<_CharT, _Traits, _Allocator>
596_LIBCPP_CONSTEXPR_AFTER_CXX17
611_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
597612operator+(const basic_string<_CharT, _Traits, _Allocator>& __x,
598613 const basic_string<_CharT, _Traits, _Allocator>& __y);
599614
600615template<class _CharT, class _Traits, class _Allocator>
601_LIBCPP_CONSTEXPR_AFTER_CXX17
616_LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX20
602617basic_string<_CharT, _Traits, _Allocator>
603618operator+(const _CharT* __x, const basic_string<_CharT,_Traits,_Allocator>& __y);
604619
605620template<class _CharT, class _Traits, class _Allocator>
606_LIBCPP_CONSTEXPR_AFTER_CXX17
621_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
607622basic_string<_CharT, _Traits, _Allocator>
608623operator+(_CharT __x, const basic_string<_CharT,_Traits,_Allocator>& __y);
609624
610625template<class _CharT, class _Traits, class _Allocator>
611inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
626inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
612627basic_string<_CharT, _Traits, _Allocator>
613628operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const _CharT* __y);
614629
615630template<class _CharT, class _Traits, class _Allocator>
616_LIBCPP_CONSTEXPR_AFTER_CXX17
631_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
617632basic_string<_CharT, _Traits, _Allocator>
618633operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y);
619634
......@@ -636,23 +651,10 @@ struct __can_be_converted_to_string_view : public _BoolConstant<
636651 !is_convertible<const _Tp&, const _CharT*>::value
637652 > {};
638653
639#ifndef _LIBCPP_HAS_NO_CHAR8_T
640typedef basic_string<char8_t> u8string;
641#endif
642typedef basic_string<char16_t> u16string;
643typedef basic_string<char32_t> u32string;
644
645654struct __uninitialized_size_tag {};
646655
647656template<class _CharT, class _Traits, class _Allocator>
648class
649 _LIBCPP_TEMPLATE_VIS
650#ifndef _LIBCPP_HAS_NO_CHAR8_T
651 _LIBCPP_PREFERRED_NAME(u8string)
652#endif
653 _LIBCPP_PREFERRED_NAME(u16string)
654 _LIBCPP_PREFERRED_NAME(u32string)
655 basic_string
657class basic_string
656658{
657659public:
658660 typedef basic_string __self;
......@@ -676,6 +678,11 @@ public:
676678 static_assert(( is_same<typename allocator_type::value_type, value_type>::value),
677679 "Allocator::value_type must be same type as value_type");
678680
681 static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
682 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
683 "original allocator");
684
685 // TODO: Implement iterator bounds checking without requiring the global database.
679686 typedef __wrap_iter<pointer> iterator;
680687 typedef __wrap_iter<const_pointer> const_iterator;
681688 typedef std::reverse_iterator<iterator> reverse_iterator;
......@@ -787,13 +794,13 @@ private:
787794 // Construct a string with the given allocator and enough storage to hold `__size` characters, but
788795 // don't initialize the characters. The contents of the string, including the null terminator, must be
789796 // initialized separately.
790 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
797 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
791798 explicit basic_string(__uninitialized_size_tag, size_type __size, const allocator_type& __a)
792799 : __r_(__default_init_tag(), __a) {
793800 if (__size > max_size())
794801 __throw_length_error();
795802 if (__fits_in_sso(__size)) {
796 __zero();
803 __r_.first() = __rep();
797804 __set_short_size(__size);
798805 } else {
799806 auto __capacity = __recommend(__size) + 1;
......@@ -806,176 +813,289 @@ private:
806813 std::__debug_db_insert_c(this);
807814 }
808815
816 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __make_iterator(pointer __p) {
817 return iterator(this, __p);
818 }
819
820 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator __make_const_iterator(const_pointer __p) const {
821 return const_iterator(this, __p);
822 }
823
809824public:
810 _LIBCPP_TEMPLATE_DATA_VIS
811 static const size_type npos = -1;
825 _LIBCPP_TEMPLATE_DATA_VIS static const size_type npos = -1;
812826
813 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string()
814 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
827 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string()
828 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
829 : __r_(__default_init_tag(), __default_init_tag()) {
830 std::__debug_db_insert_c(this);
831 __default_init();
832 }
815833
816 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit basic_string(const allocator_type& __a)
834 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const allocator_type& __a)
817835#if _LIBCPP_STD_VER <= 14
818 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);
836 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
819837#else
820 _NOEXCEPT;
838 _NOEXCEPT
821839#endif
840 : __r_(__default_init_tag(), __a) {
841 std::__debug_db_insert_c(this);
842 __default_init();
843 }
822844
823 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(const basic_string& __str);
824 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(const basic_string& __str, const allocator_type& __a);
845 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const basic_string& __str);
846 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const basic_string& __str, const allocator_type& __a);
825847
826848#ifndef _LIBCPP_CXX03_LANG
827 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
828 basic_string(basic_string&& __str)
829#if _LIBCPP_STD_VER <= 14
830 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
831#else
832 _NOEXCEPT;
833#endif
849 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(basic_string&& __str)
850# if _LIBCPP_STD_VER <= 14
851 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
852# else
853 _NOEXCEPT
854# endif
855 : __r_(std::move(__str.__r_)) {
856 __str.__default_init();
857 std::__debug_db_insert_c(this);
858 if (__is_long())
859 std::__debug_db_swap(this, &__str);
860 }
834861
835 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
836 basic_string(basic_string&& __str, const allocator_type& __a);
862 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(basic_string&& __str, const allocator_type& __a)
863 : __r_(__default_init_tag(), __a) {
864 if (__str.__is_long() && __a != __str.__alloc()) // copy, not move
865 __init(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size());
866 else {
867 if (__libcpp_is_constant_evaluated())
868 __r_.first() = __rep();
869 __r_.first() = __str.__r_.first();
870 __str.__default_init();
871 }
872 std::__debug_db_insert_c(this);
873 if (__is_long())
874 std::__debug_db_swap(this, &__str);
875 }
837876#endif // _LIBCPP_CXX03_LANG
838877
839 template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >
840 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
841 basic_string(const _CharT* __s) : __r_(__default_init_tag(), __default_init_tag()) {
842 _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr");
843 __init(__s, traits_type::length(__s));
844 std::__debug_db_insert_c(this);
845 }
878 template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >
879 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s)
880 : __r_(__default_init_tag(), __default_init_tag()) {
881 _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr");
882 __init(__s, traits_type::length(__s));
883 std::__debug_db_insert_c(this);
884 }
846885
847 template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >
848 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
849 basic_string(const _CharT* __s, const _Allocator& __a);
886 template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >
887 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, const _Allocator& __a);
850888
851889#if _LIBCPP_STD_VER > 20
852 basic_string(nullptr_t) = delete;
890 basic_string(nullptr_t) = delete;
853891#endif
854892
855 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
856 basic_string(const _CharT* __s, size_type __n);
857 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
858 basic_string(const _CharT* __s, size_type __n, const _Allocator& __a);
859 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
860 basic_string(size_type __n, _CharT __c);
861
862 template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >
863 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
864 basic_string(size_type __n, _CharT __c, const _Allocator& __a);
865
866 _LIBCPP_CONSTEXPR_AFTER_CXX17
867 basic_string(const basic_string& __str, size_type __pos, size_type __n,
868 const _Allocator& __a = _Allocator());
869 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
870 basic_string(const basic_string& __str, size_type __pos,
871 const _Allocator& __a = _Allocator());
872
873 template<class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value> >
874 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
875 basic_string(const _Tp& __t, size_type __pos, size_type __n,
876 const allocator_type& __a = allocator_type());
877
878 template<class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
879 !__is_same_uncvref<_Tp, basic_string>::value> >
880 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
881 explicit basic_string(const _Tp& __t);
882
883 template<class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value> >
884 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
885 explicit basic_string(const _Tp& __t, const allocator_type& __a);
886
887 template<class _InputIterator, class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value> >
888 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
889 basic_string(_InputIterator __first, _InputIterator __last);
890 template<class _InputIterator, class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value> >
891 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
892 basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a);
893 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, size_type __n)
894 : __r_(__default_init_tag(), __default_init_tag()) {
895 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr");
896 __init(__s, __n);
897 std::__debug_db_insert_c(this);
898 }
899
900 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
901 basic_string(const _CharT* __s, size_type __n, const _Allocator& __a)
902 : __r_(__default_init_tag(), __a) {
903 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr");
904 __init(__s, __n);
905 std::__debug_db_insert_c(this);
906 }
907
908 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c)
909 : __r_(__default_init_tag(), __default_init_tag()) {
910 __init(__n, __c);
911 std::__debug_db_insert_c(this);
912 }
913
914#if _LIBCPP_STD_VER > 20
915 _LIBCPP_HIDE_FROM_ABI constexpr
916 basic_string(basic_string&& __str, size_type __pos, const _Allocator& __alloc = _Allocator())
917 : basic_string(std::move(__str), __pos, npos, __alloc) {}
918
919 _LIBCPP_HIDE_FROM_ABI constexpr
920 basic_string(basic_string&& __str, size_type __pos, size_type __n, const _Allocator& __alloc = _Allocator())
921 : __r_(__default_init_tag(), __alloc) {
922 if (__pos > __str.size())
923 __throw_out_of_range();
924
925 auto __len = std::min<size_type>(__n, __str.size() - __pos);
926 if (__alloc_traits::is_always_equal::value || __alloc == __str.__alloc()) {
927 __r_.first() = __str.__r_.first();
928 __str.__default_init();
929
930 _Traits::move(data(), data() + __pos, __len);
931 __set_size(__len);
932 _Traits::assign(data()[__len], value_type());
933 } else {
934 // Perform a copy because the allocators are not compatible.
935 __init(__str.data() + __pos, __len);
936 }
937
938 std::__debug_db_insert_c(this);
939 if (__is_long())
940 std::__debug_db_swap(this, &__str);
941 }
942#endif
943
944 template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >
945 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c, const _Allocator& __a);
946
947 _LIBCPP_CONSTEXPR_SINCE_CXX20
948 basic_string(const basic_string& __str, size_type __pos, size_type __n, const _Allocator& __a = _Allocator());
949
950 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
951 basic_string(const basic_string& __str, size_type __pos, const _Allocator& __a = _Allocator())
952 : __r_(__default_init_tag(), __a) {
953 size_type __str_sz = __str.size();
954 if (__pos > __str_sz)
955 __throw_out_of_range();
956 __init(__str.data() + __pos, __str_sz - __pos);
957 std::__debug_db_insert_c(this);
958 }
959
960 template <class _Tp,
961 class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
962 !__is_same_uncvref<_Tp, basic_string>::value> >
963 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
964 basic_string(const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a = allocator_type());
965
966 template <class _Tp,
967 class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
968 !__is_same_uncvref<_Tp, basic_string>::value> >
969 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(
970 const _Tp& __t);
971
972 template <class _Tp,
973 class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
974 !__is_same_uncvref<_Tp, basic_string>::value> >
975 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(
976 const _Tp& __t, const allocator_type& __a);
977
978 template <class _InputIterator, class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value> >
979 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(_InputIterator __first, _InputIterator __last)
980 : __r_(__default_init_tag(), __default_init_tag()) {
981 __init(__first, __last);
982 std::__debug_db_insert_c(this);
983 }
984
985 template <class _InputIterator, class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value> >
986 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
987 basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a)
988 : __r_(__default_init_tag(), __a) {
989 __init(__first, __last);
990 std::__debug_db_insert_c(this);
991 }
992
893993#ifndef _LIBCPP_CXX03_LANG
894 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
895 basic_string(initializer_list<_CharT> __il);
896 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
897 basic_string(initializer_list<_CharT> __il, const _Allocator& __a);
994 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(initializer_list<_CharT> __il)
995 : __r_(__default_init_tag(), __default_init_tag()) {
996 __init(__il.begin(), __il.end());
997 std::__debug_db_insert_c(this);
998 }
999
1000 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(initializer_list<_CharT> __il, const _Allocator& __a)
1001 : __r_(__default_init_tag(), __a) {
1002 __init(__il.begin(), __il.end());
1003 std::__debug_db_insert_c(this);
1004 }
8981005#endif // _LIBCPP_CXX03_LANG
8991006
900 inline _LIBCPP_CONSTEXPR_AFTER_CXX17 ~basic_string();
1007 inline _LIBCPP_CONSTEXPR_SINCE_CXX20 ~basic_string();
9011008
902 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1009 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
9031010 operator __self_view() const _NOEXCEPT { return __self_view(data(), size()); }
9041011
905 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator=(const basic_string& __str);
1012 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(const basic_string& __str);
9061013
9071014 template <class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
9081015 !__is_same_uncvref<_Tp, basic_string>::value> >
909 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator=(const _Tp& __t) {
1016 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(const _Tp& __t) {
9101017 __self_view __sv = __t;
9111018 return assign(__sv);
9121019 }
9131020
9141021#ifndef _LIBCPP_CXX03_LANG
915 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
916 basic_string& operator=(basic_string&& __str)
917 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
918 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1022 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(basic_string&& __str)
1023 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) {
1024 __move_assign(__str, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());
1025 return *this;
1026 }
1027
1028 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
9191029 basic_string& operator=(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());}
9201030#endif
921 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1031 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
9221032 basic_string& operator=(const value_type* __s) {return assign(__s);}
9231033#if _LIBCPP_STD_VER > 20
9241034 basic_string& operator=(nullptr_t) = delete;
9251035#endif
926 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator=(value_type __c);
1036 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(value_type __c);
9271037
928 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1038 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
9291039 iterator begin() _NOEXCEPT
930 {return iterator(this, __get_pointer());}
931 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1040 {return __make_iterator(__get_pointer());}
1041 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
9321042 const_iterator begin() const _NOEXCEPT
933 {return const_iterator(this, __get_pointer());}
934 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1043 {return __make_const_iterator(__get_pointer());}
1044 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
9351045 iterator end() _NOEXCEPT
936 {return iterator(this, __get_pointer() + size());}
937 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1046 {return __make_iterator(__get_pointer() + size());}
1047 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
9381048 const_iterator end() const _NOEXCEPT
939 {return const_iterator(this, __get_pointer() + size());}
1049 {return __make_const_iterator(__get_pointer() + size());}
9401050
941 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1051 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
9421052 reverse_iterator rbegin() _NOEXCEPT
9431053 {return reverse_iterator(end());}
944 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1054 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
9451055 const_reverse_iterator rbegin() const _NOEXCEPT
9461056 {return const_reverse_iterator(end());}
947 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1057 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
9481058 reverse_iterator rend() _NOEXCEPT
9491059 {return reverse_iterator(begin());}
950 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1060 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
9511061 const_reverse_iterator rend() const _NOEXCEPT
9521062 {return const_reverse_iterator(begin());}
9531063
954 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1064 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
9551065 const_iterator cbegin() const _NOEXCEPT
9561066 {return begin();}
957 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1067 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
9581068 const_iterator cend() const _NOEXCEPT
9591069 {return end();}
960 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1070 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
9611071 const_reverse_iterator crbegin() const _NOEXCEPT
9621072 {return rbegin();}
963 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1073 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
9641074 const_reverse_iterator crend() const _NOEXCEPT
9651075 {return rend();}
9661076
967 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type size() const _NOEXCEPT
1077 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type size() const _NOEXCEPT
9681078 {return __is_long() ? __get_long_size() : __get_short_size();}
969 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type length() const _NOEXCEPT {return size();}
970 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT;
971 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type capacity() const _NOEXCEPT {
1079 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type length() const _NOEXCEPT {return size();}
1080
1081 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT {
1082 size_type __m = __alloc_traits::max_size(__alloc());
1083 if (__m <= std::numeric_limits<size_type>::max() / 2) {
1084 return __m - __alignment;
1085 } else {
1086 bool __uses_lsb = __endian_factor == 2;
1087 return __uses_lsb ? __m - __alignment : (__m / 2) - __alignment;
1088 }
1089 }
1090
1091 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type capacity() const _NOEXCEPT {
9721092 return (__is_long() ? __get_long_cap() : static_cast<size_type>(__min_cap)) - 1;
9731093 }
9741094
975 _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __n, value_type __c);
976 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __n) { resize(__n, value_type()); }
1095 _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __n, value_type __c);
1096 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __n) { resize(__n, value_type()); }
9771097
978 _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __requested_capacity);
1098 _LIBCPP_CONSTEXPR_SINCE_CXX20 void reserve(size_type __requested_capacity);
9791099
9801100#if _LIBCPP_STD_VER > 20
9811101 template <class _Op>
......@@ -986,28 +1106,34 @@ public:
9861106 }
9871107#endif
9881108
989 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __resize_default_init(size_type __n);
1109 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __resize_default_init(size_type __n);
9901110
9911111 _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve() _NOEXCEPT { shrink_to_fit(); }
992 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT;
993 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void clear() _NOEXCEPT;
1112 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT;
1113 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void clear() _NOEXCEPT;
9941114
995 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1115 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
9961116 bool empty() const _NOEXCEPT {return size() == 0;}
9971117
998 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
999 const_reference operator[](size_type __pos) const _NOEXCEPT;
1000 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator[](size_type __pos) _NOEXCEPT;
1118 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference operator[](size_type __pos) const _NOEXCEPT {
1119 _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds");
1120 return *(data() + __pos);
1121 }
1122
1123 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator[](size_type __pos) _NOEXCEPT {
1124 _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds");
1125 return *(__get_pointer() + __pos);
1126 }
10011127
1002 _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference at(size_type __n) const;
1003 _LIBCPP_CONSTEXPR_AFTER_CXX17 reference at(size_type __n);
1128 _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference at(size_type __n) const;
1129 _LIBCPP_CONSTEXPR_SINCE_CXX20 reference at(size_type __n);
10041130
1005 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator+=(const basic_string& __str) {
1131 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(const basic_string& __str) {
10061132 return append(__str);
10071133 }
10081134
10091135 template <class _Tp>
1010 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1136 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
10111137 __enable_if_t
10121138 <
10131139 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
......@@ -1018,35 +1144,36 @@ public:
10181144 __self_view __sv = __t; return append(__sv);
10191145 }
10201146
1021 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator+=(const value_type* __s) {
1147 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(const value_type* __s) {
10221148 return append(__s);
10231149 }
10241150
1025 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator+=(value_type __c) {
1151 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(value_type __c) {
10261152 push_back(__c);
10271153 return *this;
10281154 }
10291155
10301156#ifndef _LIBCPP_CXX03_LANG
1031 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1157 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
10321158 basic_string& operator+=(initializer_list<value_type> __il) { return append(__il); }
10331159#endif // _LIBCPP_CXX03_LANG
10341160
1035 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1036 basic_string& append(const basic_string& __str);
1161 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const basic_string& __str) {
1162 return append(__str.data(), __str.size());
1163 }
10371164
10381165 template <class _Tp>
1039 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1166 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
10401167 __enable_if_t<
10411168 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
10421169 && !__is_same_uncvref<_Tp, basic_string>::value,
10431170 basic_string&
10441171 >
10451172 append(const _Tp& __t) { __self_view __sv = __t; return append(__sv.data(), __sv.size()); }
1046 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos);
1173 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos);
10471174
10481175 template <class _Tp>
1049 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1176 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
10501177 __enable_if_t
10511178 <
10521179 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
......@@ -1054,11 +1181,11 @@ public:
10541181 basic_string&
10551182 >
10561183 append(const _Tp& __t, size_type __pos, size_type __n=npos);
1057 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(const value_type* __s, size_type __n);
1058 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(const value_type* __s);
1059 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(size_type __n, value_type __c);
1184 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s, size_type __n);
1185 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s);
1186 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(size_type __n, value_type __c);
10601187
1061 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1188 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
10621189 void __append_default_init(size_type __n);
10631190
10641191 template<class _InputIterator>
......@@ -1068,7 +1195,7 @@ public:
10681195 __is_exactly_cpp17_input_iterator<_InputIterator>::value,
10691196 basic_string&
10701197 >
1071 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1198 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
10721199 append(_InputIterator __first, _InputIterator __last) {
10731200 const basic_string __temp(__first, __last, __alloc());
10741201 append(__temp.data(), __temp.size());
......@@ -1081,40 +1208,56 @@ public:
10811208 __is_cpp17_forward_iterator<_ForwardIterator>::value,
10821209 basic_string&
10831210 >
1084 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1211 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
10851212 append(_ForwardIterator __first, _ForwardIterator __last);
10861213
10871214#ifndef _LIBCPP_CXX03_LANG
1088 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1215 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
10891216 basic_string& append(initializer_list<value_type> __il) {return append(__il.begin(), __il.size());}
10901217#endif // _LIBCPP_CXX03_LANG
10911218
1092 _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(value_type __c);
1093 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void pop_back();
1094 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference front() _NOEXCEPT;
1095 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference front() const _NOEXCEPT;
1096 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference back() _NOEXCEPT;
1097 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference back() const _NOEXCEPT;
1219 _LIBCPP_CONSTEXPR_SINCE_CXX20 void push_back(value_type __c);
1220 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void pop_back();
1221
1222 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference front() _NOEXCEPT {
1223 _LIBCPP_ASSERT(!empty(), "string::front(): string is empty");
1224 return *__get_pointer();
1225 }
1226
1227 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference front() const _NOEXCEPT {
1228 _LIBCPP_ASSERT(!empty(), "string::front(): string is empty");
1229 return *data();
1230 }
1231
1232 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference back() _NOEXCEPT {
1233 _LIBCPP_ASSERT(!empty(), "string::back(): string is empty");
1234 return *(__get_pointer() + size() - 1);
1235 }
1236
1237 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference back() const _NOEXCEPT {
1238 _LIBCPP_ASSERT(!empty(), "string::back(): string is empty");
1239 return *(data() + size() - 1);
1240 }
10981241
10991242 template <class _Tp>
1100 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1243 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
11011244 __enable_if_t
11021245 <
11031246 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
11041247 basic_string&
11051248 >
11061249 assign(const _Tp & __t) { __self_view __sv = __t; return assign(__sv.data(), __sv.size()); }
1107 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1250 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
11081251 basic_string& assign(const basic_string& __str) { return *this = __str; }
11091252#ifndef _LIBCPP_CXX03_LANG
1110 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1253 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
11111254 basic_string& assign(basic_string&& __str)
11121255 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
11131256 {*this = std::move(__str); return *this;}
11141257#endif
1115 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos);
1258 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos);
11161259 template <class _Tp>
1117 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1260 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
11181261 __enable_if_t
11191262 <
11201263 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
......@@ -1122,11 +1265,11 @@ public:
11221265 basic_string&
11231266 >
11241267 assign(const _Tp & __t, size_type __pos, size_type __n=npos);
1125 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(const value_type* __s, size_type __n);
1126 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(const value_type* __s);
1127 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(size_type __n, value_type __c);
1268 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* __s, size_type __n);
1269 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* __s);
1270 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(size_type __n, value_type __c);
11281271 template<class _InputIterator>
1129 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1272 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
11301273 __enable_if_t
11311274 <
11321275 __is_exactly_cpp17_input_iterator<_InputIterator>::value,
......@@ -1134,7 +1277,7 @@ public:
11341277 >
11351278 assign(_InputIterator __first, _InputIterator __last);
11361279 template<class _ForwardIterator>
1137 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1280 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
11381281 __enable_if_t
11391282 <
11401283 __is_cpp17_forward_iterator<_ForwardIterator>::value,
......@@ -1142,15 +1285,17 @@ public:
11421285 >
11431286 assign(_ForwardIterator __first, _ForwardIterator __last);
11441287#ifndef _LIBCPP_CXX03_LANG
1145 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1288 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
11461289 basic_string& assign(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());}
11471290#endif // _LIBCPP_CXX03_LANG
11481291
1149 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1150 basic_string& insert(size_type __pos1, const basic_string& __str);
1292 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1293 insert(size_type __pos1, const basic_string& __str) {
1294 return insert(__pos1, __str.data(), __str.size());
1295 }
11511296
11521297 template <class _Tp>
1153 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1298 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
11541299 __enable_if_t
11551300 <
11561301 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
......@@ -1160,23 +1305,31 @@ public:
11601305 { __self_view __sv = __t; return insert(__pos1, __sv.data(), __sv.size()); }
11611306
11621307 template <class _Tp>
1163 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1308 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
11641309 __enable_if_t
11651310 <
11661311 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value,
11671312 basic_string&
11681313 >
11691314 insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n=npos);
1170 _LIBCPP_CONSTEXPR_AFTER_CXX17
1315 _LIBCPP_CONSTEXPR_SINCE_CXX20
11711316 basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n=npos);
1172 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& insert(size_type __pos, const value_type* __s, size_type __n);
1173 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& insert(size_type __pos, const value_type* __s);
1174 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& insert(size_type __pos, size_type __n, value_type __c);
1175 _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __pos, value_type __c);
1176 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1177 iterator insert(const_iterator __pos, size_type __n, value_type __c);
1317 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, const value_type* __s, size_type __n);
1318 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, const value_type* __s);
1319 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, size_type __n, value_type __c);
1320 _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __pos, value_type __c);
1321
1322 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator
1323 insert(const_iterator __pos, size_type __n, value_type __c) {
1324 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
1325 "string::insert(iterator, n, value) called with an iterator not referring to this string");
1326 difference_type __p = __pos - begin();
1327 insert(static_cast<size_type>(__p), __n, __c);
1328 return begin() + __p;
1329 }
1330
11781331 template<class _InputIterator>
1179 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1332 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
11801333 __enable_if_t
11811334 <
11821335 __is_exactly_cpp17_input_iterator<_InputIterator>::value,
......@@ -1184,7 +1337,7 @@ public:
11841337 >
11851338 insert(const_iterator __pos, _InputIterator __first, _InputIterator __last);
11861339 template<class _ForwardIterator>
1187 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1340 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
11881341 __enable_if_t
11891342 <
11901343 __is_cpp17_forward_iterator<_ForwardIterator>::value,
......@@ -1192,47 +1345,53 @@ public:
11921345 >
11931346 insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last);
11941347#ifndef _LIBCPP_CXX03_LANG
1195 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1348 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
11961349 iterator insert(const_iterator __pos, initializer_list<value_type> __il)
11971350 {return insert(__pos, __il.begin(), __il.end());}
11981351#endif // _LIBCPP_CXX03_LANG
11991352
1200 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& erase(size_type __pos = 0, size_type __n = npos);
1201 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1353 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& erase(size_type __pos = 0, size_type __n = npos);
1354 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
12021355 iterator erase(const_iterator __pos);
1203 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1356 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
12041357 iterator erase(const_iterator __first, const_iterator __last);
12051358
1206 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1207 basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str);
1359 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1360 replace(size_type __pos1, size_type __n1, const basic_string& __str) {
1361 return replace(__pos1, __n1, __str.data(), __str.size());
1362 }
12081363
12091364 template <class _Tp>
1210 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1365 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
12111366 __enable_if_t
12121367 <
12131368 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
12141369 basic_string&
12151370 >
12161371 replace(size_type __pos1, size_type __n1, const _Tp& __t) { __self_view __sv = __t; return replace(__pos1, __n1, __sv.data(), __sv.size()); }
1217 _LIBCPP_CONSTEXPR_AFTER_CXX17
1372 _LIBCPP_CONSTEXPR_SINCE_CXX20
12181373 basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos);
12191374 template <class _Tp>
1220 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1375 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
12211376 __enable_if_t
12221377 <
12231378 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value,
12241379 basic_string&
12251380 >
12261381 replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos);
1227 _LIBCPP_CONSTEXPR_AFTER_CXX17
1382 _LIBCPP_CONSTEXPR_SINCE_CXX20
12281383 basic_string& replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2);
1229 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& replace(size_type __pos, size_type __n1, const value_type* __s);
1230 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c);
1231 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1232 basic_string& replace(const_iterator __i1, const_iterator __i2, const basic_string& __str);
1384 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& replace(size_type __pos, size_type __n1, const value_type* __s);
1385 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c);
1386
1387 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1388 replace(const_iterator __i1, const_iterator __i2, const basic_string& __str) {
1389 return replace(
1390 static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __str.data(), __str.size());
1391 }
12331392
12341393 template <class _Tp>
1235 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1394 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
12361395 __enable_if_t
12371396 <
12381397 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
......@@ -1240,14 +1399,23 @@ public:
12401399 >
12411400 replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) { __self_view __sv = __t; return replace(__i1 - begin(), __i2 - __i1, __sv); }
12421401
1243 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1244 basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n);
1245 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1246 basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s);
1247 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1248 basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c);
1402 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1403 replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n) {
1404 return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __s, __n);
1405 }
1406
1407 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1408 replace(const_iterator __i1, const_iterator __i2, const value_type* __s) {
1409 return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __s);
1410 }
1411
1412 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1413 replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c) {
1414 return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __n, __c);
1415 }
1416
12491417 template<class _InputIterator>
1250 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1418 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
12511419 __enable_if_t
12521420 <
12531421 __is_cpp17_input_iterator<_InputIterator>::value,
......@@ -1255,16 +1423,31 @@ public:
12551423 >
12561424 replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2);
12571425#ifndef _LIBCPP_CXX03_LANG
1258 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1426 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
12591427 basic_string& replace(const_iterator __i1, const_iterator __i2, initializer_list<value_type> __il)
12601428 {return replace(__i1, __i2, __il.begin(), __il.end());}
12611429#endif // _LIBCPP_CXX03_LANG
12621430
1263 _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const;
1264 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1265 basic_string substr(size_type __pos = 0, size_type __n = npos) const;
1431 _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const;
12661432
1267 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1433#if _LIBCPP_STD_VER <= 20
1434 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1435 basic_string substr(size_type __pos = 0, size_type __n = npos) const {
1436 return basic_string(*this, __pos, __n);
1437 }
1438#else
1439 _LIBCPP_HIDE_FROM_ABI constexpr
1440 basic_string substr(size_type __pos = 0, size_type __n = npos) const& {
1441 return basic_string(*this, __pos, __n);
1442 }
1443
1444 _LIBCPP_HIDE_FROM_ABI constexpr
1445 basic_string substr(size_type __pos = 0, size_type __n = npos) && {
1446 return basic_string(std::move(*this), __pos, __n);
1447 }
1448#endif
1449
1450 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
12681451 void swap(basic_string& __str)
12691452#if _LIBCPP_STD_VER >= 14
12701453 _NOEXCEPT;
......@@ -1273,129 +1456,129 @@ public:
12731456 __is_nothrow_swappable<allocator_type>::value);
12741457#endif
12751458
1276 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1459 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
12771460 const value_type* c_str() const _NOEXCEPT {return data();}
1278 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1461 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
12791462 const value_type* data() const _NOEXCEPT {return std::__to_address(__get_pointer());}
12801463#if _LIBCPP_STD_VER > 14 || defined(_LIBCPP_BUILDING_LIBRARY)
1281 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1464 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
12821465 value_type* data() _NOEXCEPT {return std::__to_address(__get_pointer());}
12831466#endif
12841467
1285 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1468 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
12861469 allocator_type get_allocator() const _NOEXCEPT {return __alloc();}
12871470
1288 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1471 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
12891472 size_type find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
12901473
12911474 template <class _Tp>
1292 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1475 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
12931476 __enable_if_t
12941477 <
12951478 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
12961479 size_type
12971480 >
12981481 find(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT;
1299 _LIBCPP_CONSTEXPR_AFTER_CXX17
1482 _LIBCPP_CONSTEXPR_SINCE_CXX20
13001483 size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
1301 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1484 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
13021485 size_type find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
1303 _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT;
1486 _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT;
13041487
1305 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1488 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
13061489 size_type rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
13071490
13081491 template <class _Tp>
1309 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1492 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
13101493 __enable_if_t
13111494 <
13121495 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
13131496 size_type
13141497 >
13151498 rfind(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;
1316 _LIBCPP_CONSTEXPR_AFTER_CXX17
1499 _LIBCPP_CONSTEXPR_SINCE_CXX20
13171500 size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
1318 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1501 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
13191502 size_type rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
1320 _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT;
1503 _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT;
13211504
1322 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1505 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
13231506 size_type find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
13241507
13251508 template <class _Tp>
1326 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1509 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
13271510 __enable_if_t
13281511 <
13291512 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
13301513 size_type
13311514 >
13321515 find_first_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT;
1333 _LIBCPP_CONSTEXPR_AFTER_CXX17
1516 _LIBCPP_CONSTEXPR_SINCE_CXX20
13341517 size_type find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
1335 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1518 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
13361519 size_type find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
1337 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1520 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
13381521 size_type find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;
13391522
1340 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1523 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
13411524 size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
13421525
13431526 template <class _Tp>
1344 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1527 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
13451528 __enable_if_t
13461529 <
13471530 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
13481531 size_type
13491532 >
13501533 find_last_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;
1351 _LIBCPP_CONSTEXPR_AFTER_CXX17
1534 _LIBCPP_CONSTEXPR_SINCE_CXX20
13521535 size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
1353 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1536 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
13541537 size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
1355 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1538 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
13561539 size_type find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;
13571540
1358 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1541 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
13591542 size_type find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
13601543
13611544 template <class _Tp>
1362 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1545 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
13631546 __enable_if_t
13641547 <
13651548 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
13661549 size_type
13671550 >
13681551 find_first_not_of(const _Tp &__t, size_type __pos = 0) const _NOEXCEPT;
1369 _LIBCPP_CONSTEXPR_AFTER_CXX17
1552 _LIBCPP_CONSTEXPR_SINCE_CXX20
13701553 size_type find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
1371 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1554 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
13721555 size_type find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
1373 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1556 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
13741557 size_type find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;
13751558
1376 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1559 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
13771560 size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
13781561
13791562 template <class _Tp>
1380 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1563 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
13811564 __enable_if_t
13821565 <
13831566 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
13841567 size_type
13851568 >
13861569 find_last_not_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;
1387 _LIBCPP_CONSTEXPR_AFTER_CXX17
1570 _LIBCPP_CONSTEXPR_SINCE_CXX20
13881571 size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
1389 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1572 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
13901573 size_type find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
1391 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1574 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
13921575 size_type find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;
13931576
1394 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1577 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
13951578 int compare(const basic_string& __str) const _NOEXCEPT;
13961579
13971580 template <class _Tp>
1398 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1581 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
13991582 __enable_if_t
14001583 <
14011584 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
......@@ -1404,7 +1587,7 @@ public:
14041587 compare(const _Tp &__t) const _NOEXCEPT;
14051588
14061589 template <class _Tp>
1407 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17
1590 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
14081591 __enable_if_t
14091592 <
14101593 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
......@@ -1412,23 +1595,23 @@ public:
14121595 >
14131596 compare(size_type __pos1, size_type __n1, const _Tp& __t) const;
14141597
1415 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1598 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
14161599 int compare(size_type __pos1, size_type __n1, const basic_string& __str) const;
1417 _LIBCPP_CONSTEXPR_AFTER_CXX17
1600 _LIBCPP_CONSTEXPR_SINCE_CXX20
14181601 int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2,
14191602 size_type __n2 = npos) const;
14201603
14211604 template <class _Tp>
1422 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1605 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
14231606 __enable_if_t
14241607 <
14251608 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value,
14261609 int
14271610 >
14281611 compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos) const;
1429 _LIBCPP_CONSTEXPR_AFTER_CXX17 int compare(const value_type* __s) const _NOEXCEPT;
1430 _LIBCPP_CONSTEXPR_AFTER_CXX17 int compare(size_type __pos1, size_type __n1, const value_type* __s) const;
1431 _LIBCPP_CONSTEXPR_AFTER_CXX17
1612 _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const value_type* __s) const _NOEXCEPT;
1613 _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(size_type __pos1, size_type __n1, const value_type* __s) const;
1614 _LIBCPP_CONSTEXPR_SINCE_CXX20
14321615 int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const;
14331616
14341617#if _LIBCPP_STD_VER > 17
......@@ -1471,9 +1654,9 @@ public:
14711654 { return __self_view(data(), size()).contains(__s); }
14721655#endif
14731656
1474 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const;
1657 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __invariants() const;
14751658
1476 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __clear_and_shrink() _NOEXCEPT;
1659 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __clear_and_shrink() _NOEXCEPT;
14771660
14781661#ifdef _LIBCPP_ENABLE_DEBUG_MODE
14791662
......@@ -1486,20 +1669,20 @@ public:
14861669
14871670private:
14881671 template<class _Alloc>
1489 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1672 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
14901673 bool friend operator==(const basic_string<char, char_traits<char>, _Alloc>& __lhs,
14911674 const basic_string<char, char_traits<char>, _Alloc>& __rhs) _NOEXCEPT;
14921675
1493 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __shrink_or_extend(size_type __target_capacity);
1676 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __shrink_or_extend(size_type __target_capacity);
14941677
1495 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1678 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
14961679 bool __is_long() const _NOEXCEPT {
14971680 if (__libcpp_is_constant_evaluated())
14981681 return true;
14991682 return __r_.first().__s.__is_long_;
15001683 }
15011684
1502 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __begin_lifetime(pointer __begin, size_type __n) {
1685 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __begin_lifetime(pointer __begin, size_type __n) {
15031686#if _LIBCPP_STD_VER > 17
15041687 if (__libcpp_is_constant_evaluated()) {
15051688 for (size_type __i = 0; __i != __n; ++__i)
......@@ -1511,8 +1694,8 @@ private:
15111694#endif // _LIBCPP_STD_VER > 17
15121695 }
15131696
1514 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __default_init() {
1515 __zero();
1697 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __default_init() {
1698 __r_.first() = __rep();
15161699 if (__libcpp_is_constant_evaluated()) {
15171700 size_type __sz = __recommend(0) + 1;
15181701 pointer __ptr = __alloc_traits::allocate(__alloc(), __sz);
......@@ -1523,7 +1706,7 @@ private:
15231706 }
15241707 }
15251708
1526 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __deallocate_constexpr() {
1709 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __deallocate_constexpr() {
15271710 if (__libcpp_is_constant_evaluated() && __get_pointer() != nullptr)
15281711 __alloc_traits::deallocate(__alloc(), __get_pointer(), __get_long_cap());
15291712 }
......@@ -1534,7 +1717,7 @@ private:
15341717 }
15351718
15361719 template <class _ForwardIterator>
1537 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
1720 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
15381721 iterator __insert_from_safe_copy(size_type __n, size_type __ip, _ForwardIterator __first, _ForwardIterator __last) {
15391722 size_type __sz = size();
15401723 size_type __cap = capacity();
......@@ -1560,76 +1743,71 @@ private:
15601743 return begin() + __ip;
15611744 }
15621745
1563 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 allocator_type& __alloc() _NOEXCEPT { return __r_.second(); }
1746 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 allocator_type& __alloc() _NOEXCEPT { return __r_.second(); }
15641747 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const allocator_type& __alloc() const _NOEXCEPT { return __r_.second(); }
15651748
1566 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1749 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
15671750 void __set_short_size(size_type __s) _NOEXCEPT {
15681751 _LIBCPP_ASSERT(__s < __min_cap, "__s should never be greater than or equal to the short string capacity");
15691752 __r_.first().__s.__size_ = __s;
15701753 __r_.first().__s.__is_long_ = false;
15711754 }
15721755
1573 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1756 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
15741757 size_type __get_short_size() const _NOEXCEPT {
15751758 _LIBCPP_ASSERT(!__r_.first().__s.__is_long_, "String has to be short when trying to get the short size");
15761759 return __r_.first().__s.__size_;
15771760 }
15781761
1579 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1762 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
15801763 void __set_long_size(size_type __s) _NOEXCEPT
15811764 {__r_.first().__l.__size_ = __s;}
1582 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1765 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
15831766 size_type __get_long_size() const _NOEXCEPT
15841767 {return __r_.first().__l.__size_;}
1585 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1768 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
15861769 void __set_size(size_type __s) _NOEXCEPT
15871770 {if (__is_long()) __set_long_size(__s); else __set_short_size(__s);}
15881771
1589 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1772 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
15901773 void __set_long_cap(size_type __s) _NOEXCEPT {
15911774 __r_.first().__l.__cap_ = __s / __endian_factor;
15921775 __r_.first().__l.__is_long_ = true;
15931776 }
15941777
1595 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1778 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
15961779 size_type __get_long_cap() const _NOEXCEPT {
15971780 return __r_.first().__l.__cap_ * __endian_factor;
15981781 }
15991782
1600 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1783 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
16011784 void __set_long_pointer(pointer __p) _NOEXCEPT
16021785 {__r_.first().__l.__data_ = __p;}
1603 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1786 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
16041787 pointer __get_long_pointer() _NOEXCEPT
16051788 {return __r_.first().__l.__data_;}
1606 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1789 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
16071790 const_pointer __get_long_pointer() const _NOEXCEPT
16081791 {return __r_.first().__l.__data_;}
1609 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1792 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
16101793 pointer __get_short_pointer() _NOEXCEPT
16111794 {return pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0]);}
1612 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1795 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
16131796 const_pointer __get_short_pointer() const _NOEXCEPT
16141797 {return pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0]);}
1615 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1798 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
16161799 pointer __get_pointer() _NOEXCEPT
16171800 {return __is_long() ? __get_long_pointer() : __get_short_pointer();}
1618 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1801 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
16191802 const_pointer __get_pointer() const _NOEXCEPT
16201803 {return __is_long() ? __get_long_pointer() : __get_short_pointer();}
16211804
1622 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1623 void __zero() _NOEXCEPT {
1624 __r_.first() = __rep();
1625 }
1626
16271805 template <size_type __a> static
1628 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1806 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
16291807 size_type __align_it(size_type __s) _NOEXCEPT
16301808 {return (__s + (__a-1)) & ~(__a-1);}
16311809 enum {__alignment = 16};
1632 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1810 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
16331811 size_type __recommend(size_type __s) _NOEXCEPT
16341812 {
16351813 if (__s < __min_cap) {
......@@ -1644,11 +1822,11 @@ private:
16441822 return __guess;
16451823 }
16461824
1647 inline _LIBCPP_CONSTEXPR_AFTER_CXX17
1825 inline _LIBCPP_CONSTEXPR_SINCE_CXX20
16481826 void __init(const value_type* __s, size_type __sz, size_type __reserve);
1649 inline _LIBCPP_CONSTEXPR_AFTER_CXX17
1827 inline _LIBCPP_CONSTEXPR_SINCE_CXX20
16501828 void __init(const value_type* __s, size_type __sz);
1651 inline _LIBCPP_CONSTEXPR_AFTER_CXX17
1829 inline _LIBCPP_CONSTEXPR_SINCE_CXX20
16521830 void __init(size_type __n, value_type __c);
16531831
16541832 // Slow path for the (inlined) copy constructor for 'long' strings.
......@@ -1659,10 +1837,10 @@ private:
16591837 // to call the __init() functions as those are marked as inline which may
16601838 // result in over-aggressive inlining by the compiler, where our aim is
16611839 // to only inline the fast path code directly in the ctor.
1662 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __init_copy_ctor_external(const value_type* __s, size_type __sz);
1840 _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init_copy_ctor_external(const value_type* __s, size_type __sz);
16631841
16641842 template <class _InputIterator>
1665 inline _LIBCPP_CONSTEXPR_AFTER_CXX17
1843 inline _LIBCPP_CONSTEXPR_SINCE_CXX20
16661844 __enable_if_t
16671845 <
16681846 __is_exactly_cpp17_input_iterator<_InputIterator>::value
......@@ -1670,17 +1848,17 @@ private:
16701848 __init(_InputIterator __first, _InputIterator __last);
16711849
16721850 template <class _ForwardIterator>
1673 inline _LIBCPP_CONSTEXPR_AFTER_CXX17
1851 inline _LIBCPP_CONSTEXPR_SINCE_CXX20
16741852 __enable_if_t
16751853 <
16761854 __is_cpp17_forward_iterator<_ForwardIterator>::value
16771855 >
16781856 __init(_ForwardIterator __first, _ForwardIterator __last);
16791857
1680 _LIBCPP_CONSTEXPR_AFTER_CXX17
1858 _LIBCPP_CONSTEXPR_SINCE_CXX20
16811859 void __grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz,
16821860 size_type __n_copy, size_type __n_del, size_type __n_add = 0);
1683 _LIBCPP_CONSTEXPR_AFTER_CXX17
1861 _LIBCPP_CONSTEXPR_SINCE_CXX20
16841862 void __grow_by_and_replace(size_type __old_cap, size_type __delta_cap, size_type __old_sz,
16851863 size_type __n_copy, size_type __n_del,
16861864 size_type __n_add, const value_type* __p_new_stuff);
......@@ -1689,21 +1867,22 @@ private:
16891867 // have proof that the input does not alias the current instance.
16901868 // For example, operator=(basic_string) performs a 'self' check.
16911869 template <bool __is_short>
1692 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& __assign_no_alias(const value_type* __s, size_type __n);
1870 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& __assign_no_alias(const value_type* __s, size_type __n);
16931871
1694 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1695 void __erase_to_end(size_type __pos);
1872 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __erase_to_end(size_type __pos) {
1873 __null_terminate_at(std::__to_address(__get_pointer()), __pos);
1874 }
16961875
16971876 // __erase_external_with_move is invoked for erase() invocations where
16981877 // `n ~= npos`, likely requiring memory moves on the string data.
1699 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __erase_external_with_move(size_type __pos, size_type __n);
1878 _LIBCPP_CONSTEXPR_SINCE_CXX20 void __erase_external_with_move(size_type __pos, size_type __n);
17001879
1701 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1880 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
17021881 void __copy_assign_alloc(const basic_string& __str)
17031882 {__copy_assign_alloc(__str, integral_constant<bool,
17041883 __alloc_traits::propagate_on_container_copy_assignment::value>());}
17051884
1706 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1885 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
17071886 void __copy_assign_alloc(const basic_string& __str, true_type)
17081887 {
17091888 if (__alloc() == __str.__alloc())
......@@ -1720,7 +1899,7 @@ private:
17201899 allocator_type __a = __str.__alloc();
17211900 auto __allocation = std::__allocate_at_least(__a, __str.__get_long_cap());
17221901 __begin_lifetime(__allocation.ptr, __allocation.count);
1723 __clear_and_shrink();
1902 __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap());
17241903 __alloc() = std::move(__a);
17251904 __set_long_pointer(__allocation.ptr);
17261905 __set_long_cap(__allocation.count);
......@@ -1729,15 +1908,15 @@ private:
17291908 }
17301909 }
17311910
1732 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1911 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
17331912 void __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT
17341913 {}
17351914
17361915#ifndef _LIBCPP_CXX03_LANG
1737 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1916 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
17381917 void __move_assign(basic_string& __str, false_type)
17391918 _NOEXCEPT_(__alloc_traits::is_always_equal::value);
1740 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1919 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
17411920 void __move_assign(basic_string& __str, true_type)
17421921#if _LIBCPP_STD_VER > 14
17431922 _NOEXCEPT;
......@@ -1746,7 +1925,7 @@ private:
17461925#endif
17471926#endif
17481927
1749 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1928 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
17501929 void
17511930 __move_assign_alloc(basic_string& __str)
17521931 _NOEXCEPT_(
......@@ -1755,20 +1934,20 @@ private:
17551934 {__move_assign_alloc(__str, integral_constant<bool,
17561935 __alloc_traits::propagate_on_container_move_assignment::value>());}
17571936
1758 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1937 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
17591938 void __move_assign_alloc(basic_string& __c, true_type)
17601939 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
17611940 {
17621941 __alloc() = std::move(__c.__alloc());
17631942 }
17641943
1765 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1944 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
17661945 void __move_assign_alloc(basic_string&, false_type)
17671946 _NOEXCEPT
17681947 {}
17691948
1770 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& __assign_external(const value_type* __s);
1771 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& __assign_external(const value_type* __s, size_type __n);
1949 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& __assign_external(const value_type* __s);
1950 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& __assign_external(const value_type* __s, size_type __n);
17721951
17731952 // Assigns the value in __s, guaranteed to be __n < __min_cap in length.
17741953 inline basic_string& __assign_short(const value_type* __s, size_type __n) {
......@@ -1780,7 +1959,7 @@ private:
17801959 return *this;
17811960 }
17821961
1783 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1962 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
17841963 basic_string& __null_terminate_at(value_type* __p, size_type __newsz) {
17851964 __set_size(__newsz);
17861965 __invalidate_iterators_past(__newsz);
......@@ -1788,10 +1967,10 @@ private:
17881967 return *this;
17891968 }
17901969
1791 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __invalidate_iterators_past(size_type);
1970 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __invalidate_iterators_past(size_type);
17921971
17931972 template<class _Tp>
1794 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
1973 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
17951974 bool __addr_in_range(_Tp&& __t) const {
17961975 // assume that the ranges overlap, because we can't check during constant evaluation
17971976 if (__libcpp_is_constant_evaluated())
......@@ -1810,11 +1989,11 @@ private:
18101989 std::__throw_out_of_range("basic_string");
18111990 }
18121991
1813 friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, const basic_string&);
1814 friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const value_type*, const basic_string&);
1815 friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(value_type, const basic_string&);
1816 friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, const value_type*);
1817 friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, value_type);
1992 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+<>(const basic_string&, const basic_string&);
1993 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+<>(const value_type*, const basic_string&);
1994 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+<>(value_type, const basic_string&);
1995 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+<>(const basic_string&, const value_type*);
1996 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+<>(const basic_string&, value_type);
18181997};
18191998
18201999// These declarations must appear before any functions are implicitly used
......@@ -1863,7 +2042,7 @@ basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _
18632042#endif
18642043
18652044template <class _CharT, class _Traits, class _Allocator>
1866inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2045inline _LIBCPP_CONSTEXPR_SINCE_CXX20
18672046void
18682047basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type __pos)
18692048{
......@@ -1893,37 +2072,13 @@ basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type
18932072}
18942073
18952074template <class _CharT, class _Traits, class _Allocator>
1896inline _LIBCPP_CONSTEXPR_AFTER_CXX17
1897basic_string<_CharT, _Traits, _Allocator>::basic_string()
1898 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
1899 : __r_(__default_init_tag(), __default_init_tag())
1900{
1901 std::__debug_db_insert_c(this);
1902 __default_init();
1903}
1904
1905template <class _CharT, class _Traits, class _Allocator>
1906inline _LIBCPP_CONSTEXPR_AFTER_CXX17
1907basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a)
1908#if _LIBCPP_STD_VER <= 14
1909 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
1910#else
1911 _NOEXCEPT
1912#endif
1913: __r_(__default_init_tag(), __a)
1914{
1915 std::__debug_db_insert_c(this);
1916 __default_init();
1917}
1918
1919template <class _CharT, class _Traits, class _Allocator>
1920_LIBCPP_CONSTEXPR_AFTER_CXX17
2075_LIBCPP_CONSTEXPR_SINCE_CXX20
19212076void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s,
19222077 size_type __sz,
19232078 size_type __reserve)
19242079{
19252080 if (__libcpp_is_constant_evaluated())
1926 __zero();
2081 __r_.first() = __rep();
19272082 if (__reserve > max_size())
19282083 __throw_length_error();
19292084 pointer __p;
......@@ -1946,12 +2101,12 @@ void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s,
19462101}
19472102
19482103template <class _CharT, class _Traits, class _Allocator>
1949_LIBCPP_CONSTEXPR_AFTER_CXX17
2104_LIBCPP_CONSTEXPR_SINCE_CXX20
19502105void
19512106basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz)
19522107{
19532108 if (__libcpp_is_constant_evaluated())
1954 __zero();
2109 __r_.first() = __rep();
19552110 if (__sz > max_size())
19562111 __throw_length_error();
19572112 pointer __p;
......@@ -1975,7 +2130,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty
19752130
19762131template <class _CharT, class _Traits, class _Allocator>
19772132template <class>
1978_LIBCPP_CONSTEXPR_AFTER_CXX17
2133_LIBCPP_CONSTEXPR_SINCE_CXX20
19792134basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a)
19802135 : __r_(__default_init_tag(), __a)
19812136{
......@@ -1985,32 +2140,12 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const
19852140}
19862141
19872142template <class _CharT, class _Traits, class _Allocator>
1988inline _LIBCPP_CONSTEXPR_AFTER_CXX17
1989basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n)
1990 : __r_(__default_init_tag(), __default_init_tag())
1991{
1992 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr");
1993 __init(__s, __n);
1994 std::__debug_db_insert_c(this);
1995}
1996
1997template <class _CharT, class _Traits, class _Allocator>
1998inline _LIBCPP_CONSTEXPR_AFTER_CXX17
1999basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n, const _Allocator& __a)
2000 : __r_(__default_init_tag(), __a)
2001{
2002 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr");
2003 __init(__s, __n);
2004 std::__debug_db_insert_c(this);
2005}
2006
2007template <class _CharT, class _Traits, class _Allocator>
2008_LIBCPP_CONSTEXPR_AFTER_CXX17
2143_LIBCPP_CONSTEXPR_SINCE_CXX20
20092144basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str)
20102145 : __r_(__default_init_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc()))
20112146{
20122147 if (!__str.__is_long())
2013 __r_.first().__r = __str.__r_.first().__r;
2148 __r_.first() = __str.__r_.first();
20142149 else
20152150 __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()),
20162151 __str.__get_long_size());
......@@ -2018,13 +2153,13 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
20182153}
20192154
20202155template <class _CharT, class _Traits, class _Allocator>
2021_LIBCPP_CONSTEXPR_AFTER_CXX17
2156_LIBCPP_CONSTEXPR_SINCE_CXX20
20222157basic_string<_CharT, _Traits, _Allocator>::basic_string(
20232158 const basic_string& __str, const allocator_type& __a)
20242159 : __r_(__default_init_tag(), __a)
20252160{
20262161 if (!__str.__is_long())
2027 __r_.first().__r = __str.__r_.first().__r;
2162 __r_.first() = __str.__r_.first();
20282163 else
20292164 __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()),
20302165 __str.__get_long_size());
......@@ -2032,11 +2167,12 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
20322167}
20332168
20342169template <class _CharT, class _Traits, class _Allocator>
2035_LIBCPP_CONSTEXPR_AFTER_CXX17
2170_LIBCPP_CONSTEXPR_SINCE_CXX20
20362171void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(
20372172 const value_type* __s, size_type __sz) {
20382173 if (__libcpp_is_constant_evaluated())
2039 __zero();
2174 __r_.first() = __rep();
2175
20402176 pointer __p;
20412177 if (__fits_in_sso(__sz)) {
20422178 __p = __get_short_pointer();
......@@ -2054,55 +2190,14 @@ void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(
20542190 traits_type::copy(std::__to_address(__p), __s, __sz + 1);
20552191}
20562192
2057#ifndef _LIBCPP_CXX03_LANG
2058
2059template <class _CharT, class _Traits, class _Allocator>
2060inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2061basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str)
2062#if _LIBCPP_STD_VER <= 14
2063 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
2064#else
2065 _NOEXCEPT
2066#endif
2067 : __r_(std::move(__str.__r_))
2068{
2069 __str.__default_init();
2070 std::__debug_db_insert_c(this);
2071 if (__is_long())
2072 std::__debug_db_swap(this, &__str);
2073}
2074
20752193template <class _CharT, class _Traits, class _Allocator>
2076inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2077basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a)
2078 : __r_(__default_init_tag(), __a)
2079{
2080 if (__str.__is_long() && __a != __str.__alloc()) // copy, not move
2081 __init(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size());
2082 else
2083 {
2084 if (__libcpp_is_constant_evaluated()) {
2085 __zero();
2086 __r_.first().__l = __str.__r_.first().__l;
2087 } else {
2088 __r_.first().__r = __str.__r_.first().__r;
2089 }
2090 __str.__default_init();
2091 }
2092 std::__debug_db_insert_c(this);
2093 if (__is_long())
2094 std::__debug_db_swap(this, &__str);
2095}
2096
2097#endif // _LIBCPP_CXX03_LANG
2098
2099template <class _CharT, class _Traits, class _Allocator>
2100_LIBCPP_CONSTEXPR_AFTER_CXX17
2194_LIBCPP_CONSTEXPR_SINCE_CXX20
21012195void
21022196basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c)
21032197{
21042198 if (__libcpp_is_constant_evaluated())
2105 __zero();
2199 __r_.first() = __rep();
2200
21062201 if (__n > max_size())
21072202 __throw_length_error();
21082203 pointer __p;
......@@ -2124,18 +2219,9 @@ basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c)
21242219 traits_type::assign(__p[__n], value_type());
21252220}
21262221
2127template <class _CharT, class _Traits, class _Allocator>
2128inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2129basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c)
2130 : __r_(__default_init_tag(), __default_init_tag())
2131{
2132 __init(__n, __c);
2133 std::__debug_db_insert_c(this);
2134}
2135
21362222template <class _CharT, class _Traits, class _Allocator>
21372223template <class>
2138_LIBCPP_CONSTEXPR_AFTER_CXX17
2224_LIBCPP_CONSTEXPR_SINCE_CXX20
21392225basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a)
21402226 : __r_(__default_init_tag(), __a)
21412227{
......@@ -2144,7 +2230,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __
21442230}
21452231
21462232template <class _CharT, class _Traits, class _Allocator>
2147_LIBCPP_CONSTEXPR_AFTER_CXX17
2233_LIBCPP_CONSTEXPR_SINCE_CXX20
21482234basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str,
21492235 size_type __pos, size_type __n,
21502236 const _Allocator& __a)
......@@ -2157,22 +2243,9 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
21572243 std::__debug_db_insert_c(this);
21582244}
21592245
2160template <class _CharT, class _Traits, class _Allocator>
2161inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2162basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos,
2163 const _Allocator& __a)
2164 : __r_(__default_init_tag(), __a)
2165{
2166 size_type __str_sz = __str.size();
2167 if (__pos > __str_sz)
2168 __throw_out_of_range();
2169 __init(__str.data() + __pos, __str_sz - __pos);
2170 std::__debug_db_insert_c(this);
2171}
2172
21732246template <class _CharT, class _Traits, class _Allocator>
21742247template <class _Tp, class>
2175_LIBCPP_CONSTEXPR_AFTER_CXX17
2248_LIBCPP_CONSTEXPR_SINCE_CXX20
21762249basic_string<_CharT, _Traits, _Allocator>::basic_string(
21772250 const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a)
21782251 : __r_(__default_init_tag(), __a)
......@@ -2185,7 +2258,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
21852258
21862259template <class _CharT, class _Traits, class _Allocator>
21872260template <class _Tp, class>
2188_LIBCPP_CONSTEXPR_AFTER_CXX17
2261_LIBCPP_CONSTEXPR_SINCE_CXX20
21892262basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t)
21902263 : __r_(__default_init_tag(), __default_init_tag())
21912264{
......@@ -2196,7 +2269,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t)
21962269
21972270template <class _CharT, class _Traits, class _Allocator>
21982271template <class _Tp, class>
2199_LIBCPP_CONSTEXPR_AFTER_CXX17
2272_LIBCPP_CONSTEXPR_SINCE_CXX20
22002273basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _Allocator& __a)
22012274 : __r_(__default_init_tag(), __a)
22022275{
......@@ -2207,7 +2280,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _
22072280
22082281template <class _CharT, class _Traits, class _Allocator>
22092282template <class _InputIterator>
2210_LIBCPP_CONSTEXPR_AFTER_CXX17
2283_LIBCPP_CONSTEXPR_SINCE_CXX20
22112284__enable_if_t
22122285<
22132286 __is_exactly_cpp17_input_iterator<_InputIterator>::value
......@@ -2234,7 +2307,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _Input
22342307
22352308template <class _CharT, class _Traits, class _Allocator>
22362309template <class _ForwardIterator>
2237_LIBCPP_CONSTEXPR_AFTER_CXX17
2310_LIBCPP_CONSTEXPR_SINCE_CXX20
22382311__enable_if_t
22392312<
22402313 __is_cpp17_forward_iterator<_ForwardIterator>::value
......@@ -2242,7 +2315,7 @@ __enable_if_t
22422315basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _ForwardIterator __last)
22432316{
22442317 if (__libcpp_is_constant_evaluated())
2245 __zero();
2318 __r_.first() = __rep();
22462319 size_type __sz = static_cast<size_type>(std::distance(__first, __last));
22472320 if (__sz > max_size())
22482321 __throw_length_error();
......@@ -2281,52 +2354,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _For
22812354}
22822355
22832356template <class _CharT, class _Traits, class _Allocator>
2284template<class _InputIterator, class>
2285inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2286basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last)
2287 : __r_(__default_init_tag(), __default_init_tag())
2288{
2289 __init(__first, __last);
2290 std::__debug_db_insert_c(this);
2291}
2292
2293template <class _CharT, class _Traits, class _Allocator>
2294template<class _InputIterator, class>
2295inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2296basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last,
2297 const allocator_type& __a)
2298 : __r_(__default_init_tag(), __a)
2299{
2300 __init(__first, __last);
2301 std::__debug_db_insert_c(this);
2302}
2303
2304#ifndef _LIBCPP_CXX03_LANG
2305
2306template <class _CharT, class _Traits, class _Allocator>
2307inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2308basic_string<_CharT, _Traits, _Allocator>::basic_string(
2309 initializer_list<_CharT> __il)
2310 : __r_(__default_init_tag(), __default_init_tag())
2311{
2312 __init(__il.begin(), __il.end());
2313 std::__debug_db_insert_c(this);
2314}
2315
2316template <class _CharT, class _Traits, class _Allocator>
2317inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2318basic_string<_CharT, _Traits, _Allocator>::basic_string(
2319 initializer_list<_CharT> __il, const _Allocator& __a)
2320 : __r_(__default_init_tag(), __a)
2321{
2322 __init(__il.begin(), __il.end());
2323 std::__debug_db_insert_c(this);
2324}
2325
2326#endif // _LIBCPP_CXX03_LANG
2327
2328template <class _CharT, class _Traits, class _Allocator>
2329_LIBCPP_CONSTEXPR_AFTER_CXX17
2357_LIBCPP_CONSTEXPR_SINCE_CXX20
23302358basic_string<_CharT, _Traits, _Allocator>::~basic_string()
23312359{
23322360 std::__debug_db_erase_c(this);
......@@ -2335,7 +2363,7 @@ basic_string<_CharT, _Traits, _Allocator>::~basic_string()
23352363}
23362364
23372365template <class _CharT, class _Traits, class _Allocator>
2338_LIBCPP_CONSTEXPR_AFTER_CXX17
2366_LIBCPP_CONSTEXPR_SINCE_CXX20
23392367void
23402368basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace
23412369 (size_type __old_cap, size_type __delta_cap, size_type __old_sz,
......@@ -2372,7 +2400,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace
23722400
23732401template <class _CharT, class _Traits, class _Allocator>
23742402void
2375_LIBCPP_CONSTEXPR_AFTER_CXX17
2403_LIBCPP_CONSTEXPR_SINCE_CXX20
23762404basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz,
23772405 size_type __n_copy, size_type __n_del, size_type __n_add)
23782406{
......@@ -2405,7 +2433,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_t
24052433
24062434template <class _CharT, class _Traits, class _Allocator>
24072435template <bool __is_short>
2408_LIBCPP_CONSTEXPR_AFTER_CXX17
2436_LIBCPP_CONSTEXPR_SINCE_CXX20
24092437basic_string<_CharT, _Traits, _Allocator>&
24102438basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(
24112439 const value_type* __s, size_type __n) {
......@@ -2424,7 +2452,7 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(
24242452}
24252453
24262454template <class _CharT, class _Traits, class _Allocator>
2427_LIBCPP_CONSTEXPR_AFTER_CXX17
2455_LIBCPP_CONSTEXPR_SINCE_CXX20
24282456basic_string<_CharT, _Traits, _Allocator>&
24292457basic_string<_CharT, _Traits, _Allocator>::__assign_external(
24302458 const value_type* __s, size_type __n) {
......@@ -2441,7 +2469,7 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_external(
24412469}
24422470
24432471template <class _CharT, class _Traits, class _Allocator>
2444_LIBCPP_CONSTEXPR_AFTER_CXX17
2472_LIBCPP_CONSTEXPR_SINCE_CXX20
24452473basic_string<_CharT, _Traits, _Allocator>&
24462474basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n)
24472475{
......@@ -2452,7 +2480,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_ty
24522480}
24532481
24542482template <class _CharT, class _Traits, class _Allocator>
2455_LIBCPP_CONSTEXPR_AFTER_CXX17
2483_LIBCPP_CONSTEXPR_SINCE_CXX20
24562484basic_string<_CharT, _Traits, _Allocator>&
24572485basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)
24582486{
......@@ -2468,7 +2496,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)
24682496}
24692497
24702498template <class _CharT, class _Traits, class _Allocator>
2471_LIBCPP_CONSTEXPR_AFTER_CXX17
2499_LIBCPP_CONSTEXPR_SINCE_CXX20
24722500basic_string<_CharT, _Traits, _Allocator>&
24732501basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c)
24742502{
......@@ -2490,7 +2518,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c)
24902518}
24912519
24922520template <class _CharT, class _Traits, class _Allocator>
2493_LIBCPP_CONSTEXPR_AFTER_CXX17
2521_LIBCPP_CONSTEXPR_SINCE_CXX20
24942522basic_string<_CharT, _Traits, _Allocator>&
24952523basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)
24962524{
......@@ -2498,7 +2526,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)
24982526 __copy_assign_alloc(__str);
24992527 if (!__is_long()) {
25002528 if (!__str.__is_long()) {
2501 __r_.first().__r = __str.__r_.first().__r;
2529 __r_.first() = __str.__r_.first();
25022530 } else {
25032531 return __assign_no_alias<true>(__str.data(), __str.size());
25042532 }
......@@ -2512,7 +2540,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)
25122540#ifndef _LIBCPP_CXX03_LANG
25132541
25142542template <class _CharT, class _Traits, class _Allocator>
2515inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2543inline _LIBCPP_CONSTEXPR_SINCE_CXX20
25162544void
25172545basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type)
25182546 _NOEXCEPT_(__alloc_traits::is_always_equal::value)
......@@ -2524,7 +2552,7 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, fa
25242552}
25252553
25262554template <class _CharT, class _Traits, class _Allocator>
2527inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2555inline _LIBCPP_CONSTEXPR_SINCE_CXX20
25282556void
25292557basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type)
25302558#if _LIBCPP_STD_VER > 14
......@@ -2553,22 +2581,11 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr
25532581 }
25542582}
25552583
2556template <class _CharT, class _Traits, class _Allocator>
2557inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2558basic_string<_CharT, _Traits, _Allocator>&
2559basic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str)
2560 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
2561{
2562 __move_assign(__str, integral_constant<bool,
2563 __alloc_traits::propagate_on_container_move_assignment::value>());
2564 return *this;
2565}
2566
25672584#endif
25682585
25692586template <class _CharT, class _Traits, class _Allocator>
25702587template<class _InputIterator>
2571_LIBCPP_CONSTEXPR_AFTER_CXX17
2588_LIBCPP_CONSTEXPR_SINCE_CXX20
25722589__enable_if_t
25732590<
25742591 __is_exactly_cpp17_input_iterator<_InputIterator>::value,
......@@ -2583,7 +2600,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _Input
25832600
25842601template <class _CharT, class _Traits, class _Allocator>
25852602template<class _ForwardIterator>
2586_LIBCPP_CONSTEXPR_AFTER_CXX17
2603_LIBCPP_CONSTEXPR_SINCE_CXX20
25872604__enable_if_t
25882605<
25892606 __is_cpp17_forward_iterator<_ForwardIterator>::value,
......@@ -2619,7 +2636,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _For
26192636}
26202637
26212638template <class _CharT, class _Traits, class _Allocator>
2622_LIBCPP_CONSTEXPR_AFTER_CXX17
2639_LIBCPP_CONSTEXPR_SINCE_CXX20
26232640basic_string<_CharT, _Traits, _Allocator>&
26242641basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n)
26252642{
......@@ -2631,7 +2648,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, siz
26312648
26322649template <class _CharT, class _Traits, class _Allocator>
26332650template <class _Tp>
2634_LIBCPP_CONSTEXPR_AFTER_CXX17
2651_LIBCPP_CONSTEXPR_SINCE_CXX20
26352652__enable_if_t
26362653<
26372654 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
......@@ -2649,14 +2666,14 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type __p
26492666
26502667
26512668template <class _CharT, class _Traits, class _Allocator>
2652_LIBCPP_CONSTEXPR_AFTER_CXX17
2669_LIBCPP_CONSTEXPR_SINCE_CXX20
26532670basic_string<_CharT, _Traits, _Allocator>&
26542671basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s) {
26552672 return __assign_external(__s, traits_type::length(__s));
26562673}
26572674
26582675template <class _CharT, class _Traits, class _Allocator>
2659_LIBCPP_CONSTEXPR_AFTER_CXX17
2676_LIBCPP_CONSTEXPR_SINCE_CXX20
26602677basic_string<_CharT, _Traits, _Allocator>&
26612678basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s)
26622679{
......@@ -2670,7 +2687,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s)
26702687// append
26712688
26722689template <class _CharT, class _Traits, class _Allocator>
2673_LIBCPP_CONSTEXPR_AFTER_CXX17
2690_LIBCPP_CONSTEXPR_SINCE_CXX20
26742691basic_string<_CharT, _Traits, _Allocator>&
26752692basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n)
26762693{
......@@ -2694,7 +2711,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_ty
26942711}
26952712
26962713template <class _CharT, class _Traits, class _Allocator>
2697_LIBCPP_CONSTEXPR_AFTER_CXX17
2714_LIBCPP_CONSTEXPR_SINCE_CXX20
26982715basic_string<_CharT, _Traits, _Allocator>&
26992716basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c)
27002717{
......@@ -2714,7 +2731,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c)
27142731}
27152732
27162733template <class _CharT, class _Traits, class _Allocator>
2717_LIBCPP_CONSTEXPR_AFTER_CXX17 inline void
2734_LIBCPP_CONSTEXPR_SINCE_CXX20 inline void
27182735basic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n)
27192736{
27202737 if (__n)
......@@ -2731,7 +2748,7 @@ basic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n)
27312748}
27322749
27332750template <class _CharT, class _Traits, class _Allocator>
2734_LIBCPP_CONSTEXPR_AFTER_CXX17
2751_LIBCPP_CONSTEXPR_SINCE_CXX20
27352752void
27362753basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c)
27372754{
......@@ -2770,7 +2787,7 @@ basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c)
27702787
27712788template <class _CharT, class _Traits, class _Allocator>
27722789template<class _ForwardIterator>
2773_LIBCPP_CONSTEXPR_AFTER_CXX17
2790_LIBCPP_CONSTEXPR_SINCE_CXX20
27742791__enable_if_t
27752792<
27762793 __is_cpp17_forward_iterator<_ForwardIterator>::value,
......@@ -2805,15 +2822,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(
28052822}
28062823
28072824template <class _CharT, class _Traits, class _Allocator>
2808inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2809basic_string<_CharT, _Traits, _Allocator>&
2810basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str)
2811{
2812 return append(__str.data(), __str.size());
2813}
2814
2815template <class _CharT, class _Traits, class _Allocator>
2816_LIBCPP_CONSTEXPR_AFTER_CXX17
2825_LIBCPP_CONSTEXPR_SINCE_CXX20
28172826basic_string<_CharT, _Traits, _Allocator>&
28182827basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, size_type __pos, size_type __n)
28192828{
......@@ -2825,7 +2834,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, siz
28252834
28262835template <class _CharT, class _Traits, class _Allocator>
28272836template <class _Tp>
2828_LIBCPP_CONSTEXPR_AFTER_CXX17
2837_LIBCPP_CONSTEXPR_SINCE_CXX20
28292838 __enable_if_t
28302839 <
28312840 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,
......@@ -2841,7 +2850,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const _Tp & __t, size_type __p
28412850}
28422851
28432852template <class _CharT, class _Traits, class _Allocator>
2844_LIBCPP_CONSTEXPR_AFTER_CXX17
2853_LIBCPP_CONSTEXPR_SINCE_CXX20
28452854basic_string<_CharT, _Traits, _Allocator>&
28462855basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s)
28472856{
......@@ -2852,7 +2861,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s)
28522861// insert
28532862
28542863template <class _CharT, class _Traits, class _Allocator>
2855_LIBCPP_CONSTEXPR_AFTER_CXX17
2864_LIBCPP_CONSTEXPR_SINCE_CXX20
28562865basic_string<_CharT, _Traits, _Allocator>&
28572866basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n)
28582867{
......@@ -2892,7 +2901,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t
28922901}
28932902
28942903template <class _CharT, class _Traits, class _Allocator>
2895_LIBCPP_CONSTEXPR_AFTER_CXX17
2904_LIBCPP_CONSTEXPR_SINCE_CXX20
28962905basic_string<_CharT, _Traits, _Allocator>&
28972906basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n, value_type __c)
28982907{
......@@ -2925,7 +2934,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n
29252934
29262935template <class _CharT, class _Traits, class _Allocator>
29272936template<class _InputIterator>
2928_LIBCPP_CONSTEXPR_AFTER_CXX17
2937_LIBCPP_CONSTEXPR_SINCE_CXX20
29292938__enable_if_t
29302939<
29312940 __is_exactly_cpp17_input_iterator<_InputIterator>::value,
......@@ -2942,7 +2951,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIt
29422951
29432952template <class _CharT, class _Traits, class _Allocator>
29442953template<class _ForwardIterator>
2945_LIBCPP_CONSTEXPR_AFTER_CXX17
2954_LIBCPP_CONSTEXPR_SINCE_CXX20
29462955__enable_if_t
29472956<
29482957 __is_cpp17_forward_iterator<_ForwardIterator>::value,
......@@ -2970,15 +2979,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _Forward
29702979}
29712980
29722981template <class _CharT, class _Traits, class _Allocator>
2973inline _LIBCPP_CONSTEXPR_AFTER_CXX17
2974basic_string<_CharT, _Traits, _Allocator>&
2975basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str)
2976{
2977 return insert(__pos1, __str.data(), __str.size());
2978}
2979
2980template <class _CharT, class _Traits, class _Allocator>
2981_LIBCPP_CONSTEXPR_AFTER_CXX17
2982_LIBCPP_CONSTEXPR_SINCE_CXX20
29822983basic_string<_CharT, _Traits, _Allocator>&
29832984basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str,
29842985 size_type __pos2, size_type __n)
......@@ -2991,7 +2992,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_
29912992
29922993template <class _CharT, class _Traits, class _Allocator>
29932994template <class _Tp>
2994_LIBCPP_CONSTEXPR_AFTER_CXX17
2995_LIBCPP_CONSTEXPR_SINCE_CXX20
29952996__enable_if_t
29962997<
29972998 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,
......@@ -3008,7 +3009,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& _
30083009}
30093010
30103011template <class _CharT, class _Traits, class _Allocator>
3011_LIBCPP_CONSTEXPR_AFTER_CXX17
3012_LIBCPP_CONSTEXPR_SINCE_CXX20
30123013basic_string<_CharT, _Traits, _Allocator>&
30133014basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s)
30143015{
......@@ -3017,7 +3018,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t
30173018}
30183019
30193020template <class _CharT, class _Traits, class _Allocator>
3020_LIBCPP_CONSTEXPR_AFTER_CXX17
3021_LIBCPP_CONSTEXPR_SINCE_CXX20
30213022typename basic_string<_CharT, _Traits, _Allocator>::iterator
30223023basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_type __c)
30233024{
......@@ -3047,23 +3048,10 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_ty
30473048 return begin() + static_cast<difference_type>(__ip);
30483049}
30493050
3050template <class _CharT, class _Traits, class _Allocator>
3051inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3052typename basic_string<_CharT, _Traits, _Allocator>::iterator
3053basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_type __n, value_type __c)
3054{
3055 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
3056 "string::insert(iterator, n, value) called with an iterator not"
3057 " referring to this string");
3058 difference_type __p = __pos - begin();
3059 insert(static_cast<size_type>(__p), __n, __c);
3060 return begin() + __p;
3061}
3062
30633051// replace
30643052
30653053template <class _CharT, class _Traits, class _Allocator>
3066_LIBCPP_CONSTEXPR_AFTER_CXX17
3054_LIBCPP_CONSTEXPR_SINCE_CXX20
30673055basic_string<_CharT, _Traits, _Allocator>&
30683056basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2)
30693057 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
......@@ -3117,7 +3105,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
31173105}
31183106
31193107template <class _CharT, class _Traits, class _Allocator>
3120_LIBCPP_CONSTEXPR_AFTER_CXX17
3108_LIBCPP_CONSTEXPR_SINCE_CXX20
31213109basic_string<_CharT, _Traits, _Allocator>&
31223110basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c)
31233111{
......@@ -3148,7 +3136,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
31483136
31493137template <class _CharT, class _Traits, class _Allocator>
31503138template<class _InputIterator>
3151_LIBCPP_CONSTEXPR_AFTER_CXX17
3139_LIBCPP_CONSTEXPR_SINCE_CXX20
31523140__enable_if_t
31533141<
31543142 __is_cpp17_input_iterator<_InputIterator>::value,
......@@ -3162,15 +3150,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it
31623150}
31633151
31643152template <class _CharT, class _Traits, class _Allocator>
3165inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3166basic_string<_CharT, _Traits, _Allocator>&
3167basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str)
3168{
3169 return replace(__pos1, __n1, __str.data(), __str.size());
3170}
3171
3172template <class _CharT, class _Traits, class _Allocator>
3173_LIBCPP_CONSTEXPR_AFTER_CXX17
3153_LIBCPP_CONSTEXPR_SINCE_CXX20
31743154basic_string<_CharT, _Traits, _Allocator>&
31753155basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str,
31763156 size_type __pos2, size_type __n2)
......@@ -3183,7 +3163,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _
31833163
31843164template <class _CharT, class _Traits, class _Allocator>
31853165template <class _Tp>
3186_LIBCPP_CONSTEXPR_AFTER_CXX17
3166_LIBCPP_CONSTEXPR_SINCE_CXX20
31873167__enable_if_t
31883168<
31893169 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,
......@@ -3200,7 +3180,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _
32003180}
32013181
32023182template <class _CharT, class _Traits, class _Allocator>
3203_LIBCPP_CONSTEXPR_AFTER_CXX17
3183_LIBCPP_CONSTEXPR_SINCE_CXX20
32043184basic_string<_CharT, _Traits, _Allocator>&
32053185basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s)
32063186{
......@@ -3208,45 +3188,12 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
32083188 return replace(__pos, __n1, __s, traits_type::length(__s));
32093189}
32103190
3211template <class _CharT, class _Traits, class _Allocator>
3212inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3213basic_string<_CharT, _Traits, _Allocator>&
3214basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const basic_string& __str)
3215{
3216 return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1),
3217 __str.data(), __str.size());
3218}
3219
3220template <class _CharT, class _Traits, class _Allocator>
3221inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3222basic_string<_CharT, _Traits, _Allocator>&
3223basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n)
3224{
3225 return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __s, __n);
3226}
3227
3228template <class _CharT, class _Traits, class _Allocator>
3229inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3230basic_string<_CharT, _Traits, _Allocator>&
3231basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s)
3232{
3233 return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __s);
3234}
3235
3236template <class _CharT, class _Traits, class _Allocator>
3237inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3238basic_string<_CharT, _Traits, _Allocator>&
3239basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c)
3240{
3241 return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __n, __c);
3242}
3243
32443191// erase
32453192
32463193// 'externally instantiated' erase() implementation, called when __n != npos.
32473194// Does not check __pos against size()
32483195template <class _CharT, class _Traits, class _Allocator>
3249_LIBCPP_CONSTEXPR_AFTER_CXX17
3196_LIBCPP_CONSTEXPR_SINCE_CXX20
32503197void
32513198basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(
32523199 size_type __pos, size_type __n)
......@@ -3264,7 +3211,7 @@ basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(
32643211}
32653212
32663213template <class _CharT, class _Traits, class _Allocator>
3267_LIBCPP_CONSTEXPR_AFTER_CXX17
3214_LIBCPP_CONSTEXPR_SINCE_CXX20
32683215basic_string<_CharT, _Traits, _Allocator>&
32693216basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos,
32703217 size_type __n) {
......@@ -3279,7 +3226,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos,
32793226}
32803227
32813228template <class _CharT, class _Traits, class _Allocator>
3282inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3229inline _LIBCPP_CONSTEXPR_SINCE_CXX20
32833230typename basic_string<_CharT, _Traits, _Allocator>::iterator
32843231basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos)
32853232{
......@@ -3295,7 +3242,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos)
32953242}
32963243
32973244template <class _CharT, class _Traits, class _Allocator>
3298inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3245inline _LIBCPP_CONSTEXPR_SINCE_CXX20
32993246typename basic_string<_CharT, _Traits, _Allocator>::iterator
33003247basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last)
33013248{
......@@ -3311,7 +3258,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_i
33113258}
33123259
33133260template <class _CharT, class _Traits, class _Allocator>
3314inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3261inline _LIBCPP_CONSTEXPR_SINCE_CXX20
33153262void
33163263basic_string<_CharT, _Traits, _Allocator>::pop_back()
33173264{
......@@ -3320,7 +3267,7 @@ basic_string<_CharT, _Traits, _Allocator>::pop_back()
33203267}
33213268
33223269template <class _CharT, class _Traits, class _Allocator>
3323inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3270inline _LIBCPP_CONSTEXPR_SINCE_CXX20
33243271void
33253272basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT
33263273{
......@@ -3338,15 +3285,7 @@ basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT
33383285}
33393286
33403287template <class _CharT, class _Traits, class _Allocator>
3341inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3342void
3343basic_string<_CharT, _Traits, _Allocator>::__erase_to_end(size_type __pos)
3344{
3345 __null_terminate_at(std::__to_address(__get_pointer()), __pos);
3346}
3347
3348template <class _CharT, class _Traits, class _Allocator>
3349_LIBCPP_CONSTEXPR_AFTER_CXX17
3288_LIBCPP_CONSTEXPR_SINCE_CXX20
33503289void
33513290basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c)
33523291{
......@@ -3358,7 +3297,7 @@ basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c)
33583297}
33593298
33603299template <class _CharT, class _Traits, class _Allocator>
3361_LIBCPP_CONSTEXPR_AFTER_CXX17 inline void
3300_LIBCPP_CONSTEXPR_SINCE_CXX20 inline void
33623301basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n)
33633302{
33643303 size_type __sz = size();
......@@ -3369,21 +3308,7 @@ basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n)
33693308}
33703309
33713310template <class _CharT, class _Traits, class _Allocator>
3372inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3373typename basic_string<_CharT, _Traits, _Allocator>::size_type
3374basic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT
3375{
3376 size_type __m = __alloc_traits::max_size(__alloc());
3377 if (__m <= std::numeric_limits<size_type>::max() / 2) {
3378 return __m - __alignment;
3379 } else {
3380 bool __uses_lsb = __endian_factor == 2;
3381 return __uses_lsb ? __m - __alignment : (__m / 2) - __alignment;
3382 }
3383}
3384
3385template <class _CharT, class _Traits, class _Allocator>
3386_LIBCPP_CONSTEXPR_AFTER_CXX17
3311_LIBCPP_CONSTEXPR_SINCE_CXX20
33873312void
33883313basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity)
33893314{
......@@ -3404,7 +3329,7 @@ basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacit
34043329}
34053330
34063331template <class _CharT, class _Traits, class _Allocator>
3407inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3332inline _LIBCPP_CONSTEXPR_SINCE_CXX20
34083333void
34093334basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT
34103335{
......@@ -3415,7 +3340,7 @@ basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT
34153340}
34163341
34173342template <class _CharT, class _Traits, class _Allocator>
3418inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3343inline _LIBCPP_CONSTEXPR_SINCE_CXX20
34193344void
34203345basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target_capacity)
34213346{
......@@ -3479,25 +3404,7 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target
34793404}
34803405
34813406template <class _CharT, class _Traits, class _Allocator>
3482inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3483typename basic_string<_CharT, _Traits, _Allocator>::const_reference
3484basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) const _NOEXCEPT
3485{
3486 _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds");
3487 return *(data() + __pos);
3488}
3489
3490template <class _CharT, class _Traits, class _Allocator>
3491inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3492typename basic_string<_CharT, _Traits, _Allocator>::reference
3493basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) _NOEXCEPT
3494{
3495 _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds");
3496 return *(__get_pointer() + __pos);
3497}
3498
3499template <class _CharT, class _Traits, class _Allocator>
3500_LIBCPP_CONSTEXPR_AFTER_CXX17
3407_LIBCPP_CONSTEXPR_SINCE_CXX20
35013408typename basic_string<_CharT, _Traits, _Allocator>::const_reference
35023409basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const
35033410{
......@@ -3507,7 +3414,7 @@ basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const
35073414}
35083415
35093416template <class _CharT, class _Traits, class _Allocator>
3510_LIBCPP_CONSTEXPR_AFTER_CXX17
3417_LIBCPP_CONSTEXPR_SINCE_CXX20
35113418typename basic_string<_CharT, _Traits, _Allocator>::reference
35123419basic_string<_CharT, _Traits, _Allocator>::at(size_type __n)
35133420{
......@@ -3517,43 +3424,7 @@ basic_string<_CharT, _Traits, _Allocator>::at(size_type __n)
35173424}
35183425
35193426template <class _CharT, class _Traits, class _Allocator>
3520inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3521typename basic_string<_CharT, _Traits, _Allocator>::reference
3522basic_string<_CharT, _Traits, _Allocator>::front() _NOEXCEPT
3523{
3524 _LIBCPP_ASSERT(!empty(), "string::front(): string is empty");
3525 return *__get_pointer();
3526}
3527
3528template <class _CharT, class _Traits, class _Allocator>
3529inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3530typename basic_string<_CharT, _Traits, _Allocator>::const_reference
3531basic_string<_CharT, _Traits, _Allocator>::front() const _NOEXCEPT
3532{
3533 _LIBCPP_ASSERT(!empty(), "string::front(): string is empty");
3534 return *data();
3535}
3536
3537template <class _CharT, class _Traits, class _Allocator>
3538inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3539typename basic_string<_CharT, _Traits, _Allocator>::reference
3540basic_string<_CharT, _Traits, _Allocator>::back() _NOEXCEPT
3541{
3542 _LIBCPP_ASSERT(!empty(), "string::back(): string is empty");
3543 return *(__get_pointer() + size() - 1);
3544}
3545
3546template <class _CharT, class _Traits, class _Allocator>
3547inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3548typename basic_string<_CharT, _Traits, _Allocator>::const_reference
3549basic_string<_CharT, _Traits, _Allocator>::back() const _NOEXCEPT
3550{
3551 _LIBCPP_ASSERT(!empty(), "string::back(): string is empty");
3552 return *(data() + size() - 1);
3553}
3554
3555template <class _CharT, class _Traits, class _Allocator>
3556_LIBCPP_CONSTEXPR_AFTER_CXX17
3427_LIBCPP_CONSTEXPR_SINCE_CXX20
35573428typename basic_string<_CharT, _Traits, _Allocator>::size_type
35583429basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const
35593430{
......@@ -3566,15 +3437,7 @@ basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n,
35663437}
35673438
35683439template <class _CharT, class _Traits, class _Allocator>
3569inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3570basic_string<_CharT, _Traits, _Allocator>
3571basic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n) const
3572{
3573 return basic_string(*this, __pos, __n, __alloc());
3574}
3575
3576template <class _CharT, class _Traits, class _Allocator>
3577inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3440inline _LIBCPP_CONSTEXPR_SINCE_CXX20
35783441void
35793442basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)
35803443#if _LIBCPP_STD_VER >= 14
......@@ -3610,30 +3473,30 @@ struct _LIBCPP_HIDDEN __traits_eq
36103473};
36113474
36123475template<class _CharT, class _Traits, class _Allocator>
3613_LIBCPP_CONSTEXPR_AFTER_CXX17
3476_LIBCPP_CONSTEXPR_SINCE_CXX20
36143477typename basic_string<_CharT, _Traits, _Allocator>::size_type
36153478basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,
36163479 size_type __pos,
36173480 size_type __n) const _NOEXCEPT
36183481{
36193482 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find(): received nullptr");
3620 return __str_find<value_type, size_type, traits_type, npos>
3483 return std::__str_find<value_type, size_type, traits_type, npos>
36213484 (data(), size(), __s, __pos, __n);
36223485}
36233486
36243487template<class _CharT, class _Traits, class _Allocator>
3625inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3488inline _LIBCPP_CONSTEXPR_SINCE_CXX20
36263489typename basic_string<_CharT, _Traits, _Allocator>::size_type
36273490basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str,
36283491 size_type __pos) const _NOEXCEPT
36293492{
3630 return __str_find<value_type, size_type, traits_type, npos>
3493 return std::__str_find<value_type, size_type, traits_type, npos>
36313494 (data(), size(), __str.data(), __pos, __str.size());
36323495}
36333496
36343497template<class _CharT, class _Traits, class _Allocator>
36353498template <class _Tp>
3636_LIBCPP_CONSTEXPR_AFTER_CXX17
3499_LIBCPP_CONSTEXPR_SINCE_CXX20
36373500__enable_if_t
36383501<
36393502 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
......@@ -3643,58 +3506,58 @@ basic_string<_CharT, _Traits, _Allocator>::find(const _Tp &__t,
36433506 size_type __pos) const _NOEXCEPT
36443507{
36453508 __self_view __sv = __t;
3646 return __str_find<value_type, size_type, traits_type, npos>
3509 return std::__str_find<value_type, size_type, traits_type, npos>
36473510 (data(), size(), __sv.data(), __pos, __sv.size());
36483511}
36493512
36503513template<class _CharT, class _Traits, class _Allocator>
3651inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3514inline _LIBCPP_CONSTEXPR_SINCE_CXX20
36523515typename basic_string<_CharT, _Traits, _Allocator>::size_type
36533516basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,
36543517 size_type __pos) const _NOEXCEPT
36553518{
36563519 _LIBCPP_ASSERT(__s != nullptr, "string::find(): received nullptr");
3657 return __str_find<value_type, size_type, traits_type, npos>
3520 return std::__str_find<value_type, size_type, traits_type, npos>
36583521 (data(), size(), __s, __pos, traits_type::length(__s));
36593522}
36603523
36613524template<class _CharT, class _Traits, class _Allocator>
3662_LIBCPP_CONSTEXPR_AFTER_CXX17
3525_LIBCPP_CONSTEXPR_SINCE_CXX20
36633526typename basic_string<_CharT, _Traits, _Allocator>::size_type
36643527basic_string<_CharT, _Traits, _Allocator>::find(value_type __c,
36653528 size_type __pos) const _NOEXCEPT
36663529{
3667 return __str_find<value_type, size_type, traits_type, npos>
3530 return std::__str_find<value_type, size_type, traits_type, npos>
36683531 (data(), size(), __c, __pos);
36693532}
36703533
36713534// rfind
36723535
36733536template<class _CharT, class _Traits, class _Allocator>
3674_LIBCPP_CONSTEXPR_AFTER_CXX17
3537_LIBCPP_CONSTEXPR_SINCE_CXX20
36753538typename basic_string<_CharT, _Traits, _Allocator>::size_type
36763539basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,
36773540 size_type __pos,
36783541 size_type __n) const _NOEXCEPT
36793542{
36803543 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::rfind(): received nullptr");
3681 return __str_rfind<value_type, size_type, traits_type, npos>
3544 return std::__str_rfind<value_type, size_type, traits_type, npos>
36823545 (data(), size(), __s, __pos, __n);
36833546}
36843547
36853548template<class _CharT, class _Traits, class _Allocator>
3686inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3549inline _LIBCPP_CONSTEXPR_SINCE_CXX20
36873550typename basic_string<_CharT, _Traits, _Allocator>::size_type
36883551basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str,
36893552 size_type __pos) const _NOEXCEPT
36903553{
3691 return __str_rfind<value_type, size_type, traits_type, npos>
3554 return std::__str_rfind<value_type, size_type, traits_type, npos>
36923555 (data(), size(), __str.data(), __pos, __str.size());
36933556}
36943557
36953558template<class _CharT, class _Traits, class _Allocator>
36963559template <class _Tp>
3697_LIBCPP_CONSTEXPR_AFTER_CXX17
3560_LIBCPP_CONSTEXPR_SINCE_CXX20
36983561__enable_if_t
36993562<
37003563 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
......@@ -3704,58 +3567,58 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t,
37043567 size_type __pos) const _NOEXCEPT
37053568{
37063569 __self_view __sv = __t;
3707 return __str_rfind<value_type, size_type, traits_type, npos>
3570 return std::__str_rfind<value_type, size_type, traits_type, npos>
37083571 (data(), size(), __sv.data(), __pos, __sv.size());
37093572}
37103573
37113574template<class _CharT, class _Traits, class _Allocator>
3712inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3575inline _LIBCPP_CONSTEXPR_SINCE_CXX20
37133576typename basic_string<_CharT, _Traits, _Allocator>::size_type
37143577basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,
37153578 size_type __pos) const _NOEXCEPT
37163579{
37173580 _LIBCPP_ASSERT(__s != nullptr, "string::rfind(): received nullptr");
3718 return __str_rfind<value_type, size_type, traits_type, npos>
3581 return std::__str_rfind<value_type, size_type, traits_type, npos>
37193582 (data(), size(), __s, __pos, traits_type::length(__s));
37203583}
37213584
37223585template<class _CharT, class _Traits, class _Allocator>
3723_LIBCPP_CONSTEXPR_AFTER_CXX17
3586_LIBCPP_CONSTEXPR_SINCE_CXX20
37243587typename basic_string<_CharT, _Traits, _Allocator>::size_type
37253588basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c,
37263589 size_type __pos) const _NOEXCEPT
37273590{
3728 return __str_rfind<value_type, size_type, traits_type, npos>
3591 return std::__str_rfind<value_type, size_type, traits_type, npos>
37293592 (data(), size(), __c, __pos);
37303593}
37313594
37323595// find_first_of
37333596
37343597template<class _CharT, class _Traits, class _Allocator>
3735_LIBCPP_CONSTEXPR_AFTER_CXX17
3598_LIBCPP_CONSTEXPR_SINCE_CXX20
37363599typename basic_string<_CharT, _Traits, _Allocator>::size_type
37373600basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,
37383601 size_type __pos,
37393602 size_type __n) const _NOEXCEPT
37403603{
37413604 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr");
3742 return __str_find_first_of<value_type, size_type, traits_type, npos>
3605 return std::__str_find_first_of<value_type, size_type, traits_type, npos>
37433606 (data(), size(), __s, __pos, __n);
37443607}
37453608
37463609template<class _CharT, class _Traits, class _Allocator>
3747inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3610inline _LIBCPP_CONSTEXPR_SINCE_CXX20
37483611typename basic_string<_CharT, _Traits, _Allocator>::size_type
37493612basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str,
37503613 size_type __pos) const _NOEXCEPT
37513614{
3752 return __str_find_first_of<value_type, size_type, traits_type, npos>
3615 return std::__str_find_first_of<value_type, size_type, traits_type, npos>
37533616 (data(), size(), __str.data(), __pos, __str.size());
37543617}
37553618
37563619template<class _CharT, class _Traits, class _Allocator>
37573620template <class _Tp>
3758_LIBCPP_CONSTEXPR_AFTER_CXX17
3621_LIBCPP_CONSTEXPR_SINCE_CXX20
37593622__enable_if_t
37603623<
37613624 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
......@@ -3765,23 +3628,23 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const _Tp& __t,
37653628 size_type __pos) const _NOEXCEPT
37663629{
37673630 __self_view __sv = __t;
3768 return __str_find_first_of<value_type, size_type, traits_type, npos>
3631 return std::__str_find_first_of<value_type, size_type, traits_type, npos>
37693632 (data(), size(), __sv.data(), __pos, __sv.size());
37703633}
37713634
37723635template<class _CharT, class _Traits, class _Allocator>
3773inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3636inline _LIBCPP_CONSTEXPR_SINCE_CXX20
37743637typename basic_string<_CharT, _Traits, _Allocator>::size_type
37753638basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,
37763639 size_type __pos) const _NOEXCEPT
37773640{
37783641 _LIBCPP_ASSERT(__s != nullptr, "string::find_first_of(): received nullptr");
3779 return __str_find_first_of<value_type, size_type, traits_type, npos>
3642 return std::__str_find_first_of<value_type, size_type, traits_type, npos>
37803643 (data(), size(), __s, __pos, traits_type::length(__s));
37813644}
37823645
37833646template<class _CharT, class _Traits, class _Allocator>
3784inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3647inline _LIBCPP_CONSTEXPR_SINCE_CXX20
37853648typename basic_string<_CharT, _Traits, _Allocator>::size_type
37863649basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c,
37873650 size_type __pos) const _NOEXCEPT
......@@ -3792,30 +3655,30 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c,
37923655// find_last_of
37933656
37943657template<class _CharT, class _Traits, class _Allocator>
3795inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3658inline _LIBCPP_CONSTEXPR_SINCE_CXX20
37963659typename basic_string<_CharT, _Traits, _Allocator>::size_type
37973660basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,
37983661 size_type __pos,
37993662 size_type __n) const _NOEXCEPT
38003663{
38013664 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr");
3802 return __str_find_last_of<value_type, size_type, traits_type, npos>
3665 return std::__str_find_last_of<value_type, size_type, traits_type, npos>
38033666 (data(), size(), __s, __pos, __n);
38043667}
38053668
38063669template<class _CharT, class _Traits, class _Allocator>
3807inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3670inline _LIBCPP_CONSTEXPR_SINCE_CXX20
38083671typename basic_string<_CharT, _Traits, _Allocator>::size_type
38093672basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str,
38103673 size_type __pos) const _NOEXCEPT
38113674{
3812 return __str_find_last_of<value_type, size_type, traits_type, npos>
3675 return std::__str_find_last_of<value_type, size_type, traits_type, npos>
38133676 (data(), size(), __str.data(), __pos, __str.size());
38143677}
38153678
38163679template<class _CharT, class _Traits, class _Allocator>
38173680template <class _Tp>
3818_LIBCPP_CONSTEXPR_AFTER_CXX17
3681_LIBCPP_CONSTEXPR_SINCE_CXX20
38193682__enable_if_t
38203683<
38213684 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
......@@ -3825,23 +3688,23 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const _Tp& __t,
38253688 size_type __pos) const _NOEXCEPT
38263689{
38273690 __self_view __sv = __t;
3828 return __str_find_last_of<value_type, size_type, traits_type, npos>
3691 return std::__str_find_last_of<value_type, size_type, traits_type, npos>
38293692 (data(), size(), __sv.data(), __pos, __sv.size());
38303693}
38313694
38323695template<class _CharT, class _Traits, class _Allocator>
3833inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3696inline _LIBCPP_CONSTEXPR_SINCE_CXX20
38343697typename basic_string<_CharT, _Traits, _Allocator>::size_type
38353698basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,
38363699 size_type __pos) const _NOEXCEPT
38373700{
38383701 _LIBCPP_ASSERT(__s != nullptr, "string::find_last_of(): received nullptr");
3839 return __str_find_last_of<value_type, size_type, traits_type, npos>
3702 return std::__str_find_last_of<value_type, size_type, traits_type, npos>
38403703 (data(), size(), __s, __pos, traits_type::length(__s));
38413704}
38423705
38433706template<class _CharT, class _Traits, class _Allocator>
3844inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3707inline _LIBCPP_CONSTEXPR_SINCE_CXX20
38453708typename basic_string<_CharT, _Traits, _Allocator>::size_type
38463709basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c,
38473710 size_type __pos) const _NOEXCEPT
......@@ -3852,30 +3715,30 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c,
38523715// find_first_not_of
38533716
38543717template<class _CharT, class _Traits, class _Allocator>
3855_LIBCPP_CONSTEXPR_AFTER_CXX17
3718_LIBCPP_CONSTEXPR_SINCE_CXX20
38563719typename basic_string<_CharT, _Traits, _Allocator>::size_type
38573720basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s,
38583721 size_type __pos,
38593722 size_type __n) const _NOEXCEPT
38603723{
38613724 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr");
3862 return __str_find_first_not_of<value_type, size_type, traits_type, npos>
3725 return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>
38633726 (data(), size(), __s, __pos, __n);
38643727}
38653728
38663729template<class _CharT, class _Traits, class _Allocator>
3867inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3730inline _LIBCPP_CONSTEXPR_SINCE_CXX20
38683731typename basic_string<_CharT, _Traits, _Allocator>::size_type
38693732basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& __str,
38703733 size_type __pos) const _NOEXCEPT
38713734{
3872 return __str_find_first_not_of<value_type, size_type, traits_type, npos>
3735 return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>
38733736 (data(), size(), __str.data(), __pos, __str.size());
38743737}
38753738
38763739template<class _CharT, class _Traits, class _Allocator>
38773740template <class _Tp>
3878_LIBCPP_CONSTEXPR_AFTER_CXX17
3741_LIBCPP_CONSTEXPR_SINCE_CXX20
38793742__enable_if_t
38803743<
38813744 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
......@@ -3885,58 +3748,58 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const _Tp& __t,
38853748 size_type __pos) const _NOEXCEPT
38863749{
38873750 __self_view __sv = __t;
3888 return __str_find_first_not_of<value_type, size_type, traits_type, npos>
3751 return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>
38893752 (data(), size(), __sv.data(), __pos, __sv.size());
38903753}
38913754
38923755template<class _CharT, class _Traits, class _Allocator>
3893inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3756inline _LIBCPP_CONSTEXPR_SINCE_CXX20
38943757typename basic_string<_CharT, _Traits, _Allocator>::size_type
38953758basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s,
38963759 size_type __pos) const _NOEXCEPT
38973760{
38983761 _LIBCPP_ASSERT(__s != nullptr, "string::find_first_not_of(): received nullptr");
3899 return __str_find_first_not_of<value_type, size_type, traits_type, npos>
3762 return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>
39003763 (data(), size(), __s, __pos, traits_type::length(__s));
39013764}
39023765
39033766template<class _CharT, class _Traits, class _Allocator>
3904inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3767inline _LIBCPP_CONSTEXPR_SINCE_CXX20
39053768typename basic_string<_CharT, _Traits, _Allocator>::size_type
39063769basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c,
39073770 size_type __pos) const _NOEXCEPT
39083771{
3909 return __str_find_first_not_of<value_type, size_type, traits_type, npos>
3772 return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>
39103773 (data(), size(), __c, __pos);
39113774}
39123775
39133776// find_last_not_of
39143777
39153778template<class _CharT, class _Traits, class _Allocator>
3916_LIBCPP_CONSTEXPR_AFTER_CXX17
3779_LIBCPP_CONSTEXPR_SINCE_CXX20
39173780typename basic_string<_CharT, _Traits, _Allocator>::size_type
39183781basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s,
39193782 size_type __pos,
39203783 size_type __n) const _NOEXCEPT
39213784{
39223785 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr");
3923 return __str_find_last_not_of<value_type, size_type, traits_type, npos>
3786 return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>
39243787 (data(), size(), __s, __pos, __n);
39253788}
39263789
39273790template<class _CharT, class _Traits, class _Allocator>
3928inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3791inline _LIBCPP_CONSTEXPR_SINCE_CXX20
39293792typename basic_string<_CharT, _Traits, _Allocator>::size_type
39303793basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& __str,
39313794 size_type __pos) const _NOEXCEPT
39323795{
3933 return __str_find_last_not_of<value_type, size_type, traits_type, npos>
3796 return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>
39343797 (data(), size(), __str.data(), __pos, __str.size());
39353798}
39363799
39373800template<class _CharT, class _Traits, class _Allocator>
39383801template <class _Tp>
3939_LIBCPP_CONSTEXPR_AFTER_CXX17
3802_LIBCPP_CONSTEXPR_SINCE_CXX20
39403803__enable_if_t
39413804<
39423805 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
......@@ -3946,28 +3809,28 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const _Tp& __t,
39463809 size_type __pos) const _NOEXCEPT
39473810{
39483811 __self_view __sv = __t;
3949 return __str_find_last_not_of<value_type, size_type, traits_type, npos>
3812 return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>
39503813 (data(), size(), __sv.data(), __pos, __sv.size());
39513814}
39523815
39533816template<class _CharT, class _Traits, class _Allocator>
3954inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3817inline _LIBCPP_CONSTEXPR_SINCE_CXX20
39553818typename basic_string<_CharT, _Traits, _Allocator>::size_type
39563819basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s,
39573820 size_type __pos) const _NOEXCEPT
39583821{
39593822 _LIBCPP_ASSERT(__s != nullptr, "string::find_last_not_of(): received nullptr");
3960 return __str_find_last_not_of<value_type, size_type, traits_type, npos>
3823 return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>
39613824 (data(), size(), __s, __pos, traits_type::length(__s));
39623825}
39633826
39643827template<class _CharT, class _Traits, class _Allocator>
3965inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3828inline _LIBCPP_CONSTEXPR_SINCE_CXX20
39663829typename basic_string<_CharT, _Traits, _Allocator>::size_type
39673830basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c,
39683831 size_type __pos) const _NOEXCEPT
39693832{
3970 return __str_find_last_not_of<value_type, size_type, traits_type, npos>
3833 return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>
39713834 (data(), size(), __c, __pos);
39723835}
39733836
......@@ -3975,7 +3838,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c,
39753838
39763839template <class _CharT, class _Traits, class _Allocator>
39773840template <class _Tp>
3978_LIBCPP_CONSTEXPR_AFTER_CXX17
3841_LIBCPP_CONSTEXPR_SINCE_CXX20
39793842__enable_if_t
39803843<
39813844 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
......@@ -3998,7 +3861,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const _NOEXCE
39983861}
39993862
40003863template <class _CharT, class _Traits, class _Allocator>
4001inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3864inline _LIBCPP_CONSTEXPR_SINCE_CXX20
40023865int
40033866basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT
40043867{
......@@ -4006,7 +3869,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) co
40063869}
40073870
40083871template <class _CharT, class _Traits, class _Allocator>
4009inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3872inline _LIBCPP_CONSTEXPR_SINCE_CXX20
40103873int
40113874basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
40123875 size_type __n1,
......@@ -4031,7 +3894,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
40313894
40323895template <class _CharT, class _Traits, class _Allocator>
40333896template <class _Tp>
4034_LIBCPP_CONSTEXPR_AFTER_CXX17
3897_LIBCPP_CONSTEXPR_SINCE_CXX20
40353898__enable_if_t
40363899<
40373900 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
......@@ -4046,7 +3909,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
40463909}
40473910
40483911template <class _CharT, class _Traits, class _Allocator>
4049inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3912inline _LIBCPP_CONSTEXPR_SINCE_CXX20
40503913int
40513914basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
40523915 size_type __n1,
......@@ -4057,7 +3920,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
40573920
40583921template <class _CharT, class _Traits, class _Allocator>
40593922template <class _Tp>
4060_LIBCPP_CONSTEXPR_AFTER_CXX17
3923_LIBCPP_CONSTEXPR_SINCE_CXX20
40613924__enable_if_t
40623925<
40633926 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
......@@ -4075,7 +3938,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
40753938}
40763939
40773940template <class _CharT, class _Traits, class _Allocator>
4078_LIBCPP_CONSTEXPR_AFTER_CXX17
3941_LIBCPP_CONSTEXPR_SINCE_CXX20
40793942int
40803943basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
40813944 size_type __n1,
......@@ -4087,7 +3950,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
40873950}
40883951
40893952template <class _CharT, class _Traits, class _Allocator>
4090_LIBCPP_CONSTEXPR_AFTER_CXX17
3953_LIBCPP_CONSTEXPR_SINCE_CXX20
40913954int
40923955basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT
40933956{
......@@ -4096,7 +3959,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const
40963959}
40973960
40983961template <class _CharT, class _Traits, class _Allocator>
4099_LIBCPP_CONSTEXPR_AFTER_CXX17
3962_LIBCPP_CONSTEXPR_SINCE_CXX20
41003963int
41013964basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
41023965 size_type __n1,
......@@ -4109,7 +3972,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
41093972// __invariants
41103973
41113974template<class _CharT, class _Traits, class _Allocator>
4112inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3975inline _LIBCPP_CONSTEXPR_SINCE_CXX20
41133976bool
41143977basic_string<_CharT, _Traits, _Allocator>::__invariants() const
41153978{
......@@ -4127,7 +3990,7 @@ basic_string<_CharT, _Traits, _Allocator>::__invariants() const
41273990// __clear_and_shrink
41283991
41293992template<class _CharT, class _Traits, class _Allocator>
4130inline _LIBCPP_CONSTEXPR_AFTER_CXX17
3993inline _LIBCPP_CONSTEXPR_SINCE_CXX20
41313994void
41323995basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT
41333996{
......@@ -4135,28 +3998,30 @@ basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT
41353998 if(__is_long())
41363999 {
41374000 __alloc_traits::deallocate(__alloc(), __get_long_pointer(), capacity() + 1);
4138 __set_long_cap(0);
4139 __set_short_size(0);
4140 traits_type::assign(*__get_short_pointer(), value_type());
4001 __default_init();
41414002 }
41424003}
41434004
41444005// operator==
41454006
41464007template<class _CharT, class _Traits, class _Allocator>
4147inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4008inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
41484009bool
41494010operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
41504011 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
41514012{
4013#if _LIBCPP_STD_VER > 17
4014 return basic_string_view<_CharT, _Traits>(__lhs) == basic_string_view<_CharT, _Traits>(__rhs);
4015#else
41524016 size_t __lhs_sz = __lhs.size();
41534017 return __lhs_sz == __rhs.size() && _Traits::compare(__lhs.data(),
41544018 __rhs.data(),
41554019 __lhs_sz) == 0;
4020#endif
41564021}
41574022
41584023template<class _Allocator>
4159inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4024inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
41604025bool
41614026operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs,
41624027 const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT
......@@ -4174,8 +4039,9 @@ operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs,
41744039 return true;
41754040}
41764041
4042#if _LIBCPP_STD_VER <= 17
41774043template<class _CharT, class _Traits, class _Allocator>
4178inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4044inline _LIBCPP_HIDE_FROM_ABI
41794045bool
41804046operator==(const _CharT* __lhs,
41814047 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
......@@ -4186,22 +4052,44 @@ operator==(const _CharT* __lhs,
41864052 if (__lhs_len != __rhs.size()) return false;
41874053 return __rhs.compare(0, _String::npos, __lhs, __lhs_len) == 0;
41884054}
4055#endif // _LIBCPP_STD_VER <= 17
41894056
41904057template<class _CharT, class _Traits, class _Allocator>
4191inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4058inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
41924059bool
41934060operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
41944061 const _CharT* __rhs) _NOEXCEPT
41954062{
4063#if _LIBCPP_STD_VER > 17
4064 return basic_string_view<_CharT, _Traits>(__lhs) == basic_string_view<_CharT, _Traits>(__rhs);
4065#else
41964066 typedef basic_string<_CharT, _Traits, _Allocator> _String;
41974067 _LIBCPP_ASSERT(__rhs != nullptr, "operator==(basic_string, char*): received nullptr");
41984068 size_t __rhs_len = _Traits::length(__rhs);
41994069 if (__rhs_len != __lhs.size()) return false;
42004070 return __lhs.compare(0, _String::npos, __rhs, __rhs_len) == 0;
4071#endif
42014072}
42024073
4074#if _LIBCPP_STD_VER > 17
4075
4076template <class _CharT, class _Traits, class _Allocator>
4077_LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(
4078 const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4079 const basic_string<_CharT, _Traits, _Allocator>& __rhs) noexcept {
4080 return basic_string_view<_CharT, _Traits>(__lhs) <=> basic_string_view<_CharT, _Traits>(__rhs);
4081}
4082
4083template <class _CharT, class _Traits, class _Allocator>
4084_LIBCPP_HIDE_FROM_ABI constexpr auto
4085operator<=>(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) {
4086 return basic_string_view<_CharT, _Traits>(__lhs) <=> basic_string_view<_CharT, _Traits>(__rhs);
4087}
4088
4089#else // _LIBCPP_STD_VER > 17
4090
42034091template<class _CharT, class _Traits, class _Allocator>
4204inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4092inline _LIBCPP_HIDE_FROM_ABI
42054093bool
42064094operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
42074095 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
......@@ -4210,7 +4098,7 @@ operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
42104098}
42114099
42124100template<class _CharT, class _Traits, class _Allocator>
4213inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4101inline _LIBCPP_HIDE_FROM_ABI
42144102bool
42154103operator!=(const _CharT* __lhs,
42164104 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
......@@ -4219,7 +4107,7 @@ operator!=(const _CharT* __lhs,
42194107}
42204108
42214109template<class _CharT, class _Traits, class _Allocator>
4222inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4110inline _LIBCPP_HIDE_FROM_ABI
42234111bool
42244112operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
42254113 const _CharT* __rhs) _NOEXCEPT
......@@ -4230,7 +4118,7 @@ operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
42304118// operator<
42314119
42324120template<class _CharT, class _Traits, class _Allocator>
4233inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4121inline _LIBCPP_HIDE_FROM_ABI
42344122bool
42354123operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
42364124 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
......@@ -4239,7 +4127,7 @@ operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
42394127}
42404128
42414129template<class _CharT, class _Traits, class _Allocator>
4242inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4130inline _LIBCPP_HIDE_FROM_ABI
42434131bool
42444132operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
42454133 const _CharT* __rhs) _NOEXCEPT
......@@ -4248,7 +4136,7 @@ operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
42484136}
42494137
42504138template<class _CharT, class _Traits, class _Allocator>
4251inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4139inline _LIBCPP_HIDE_FROM_ABI
42524140bool
42534141operator< (const _CharT* __lhs,
42544142 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
......@@ -4259,7 +4147,7 @@ operator< (const _CharT* __lhs,
42594147// operator>
42604148
42614149template<class _CharT, class _Traits, class _Allocator>
4262inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4150inline _LIBCPP_HIDE_FROM_ABI
42634151bool
42644152operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
42654153 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
......@@ -4268,7 +4156,7 @@ operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
42684156}
42694157
42704158template<class _CharT, class _Traits, class _Allocator>
4271inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4159inline _LIBCPP_HIDE_FROM_ABI
42724160bool
42734161operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
42744162 const _CharT* __rhs) _NOEXCEPT
......@@ -4277,7 +4165,7 @@ operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
42774165}
42784166
42794167template<class _CharT, class _Traits, class _Allocator>
4280inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4168inline _LIBCPP_HIDE_FROM_ABI
42814169bool
42824170operator> (const _CharT* __lhs,
42834171 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
......@@ -4288,7 +4176,7 @@ operator> (const _CharT* __lhs,
42884176// operator<=
42894177
42904178template<class _CharT, class _Traits, class _Allocator>
4291inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4179inline _LIBCPP_HIDE_FROM_ABI
42924180bool
42934181operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
42944182 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
......@@ -4297,7 +4185,7 @@ operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
42974185}
42984186
42994187template<class _CharT, class _Traits, class _Allocator>
4300inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4188inline _LIBCPP_HIDE_FROM_ABI
43014189bool
43024190operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
43034191 const _CharT* __rhs) _NOEXCEPT
......@@ -4306,7 +4194,7 @@ operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
43064194}
43074195
43084196template<class _CharT, class _Traits, class _Allocator>
4309inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4197inline _LIBCPP_HIDE_FROM_ABI
43104198bool
43114199operator<=(const _CharT* __lhs,
43124200 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
......@@ -4317,7 +4205,7 @@ operator<=(const _CharT* __lhs,
43174205// operator>=
43184206
43194207template<class _CharT, class _Traits, class _Allocator>
4320inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4208inline _LIBCPP_HIDE_FROM_ABI
43214209bool
43224210operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
43234211 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
......@@ -4326,7 +4214,7 @@ operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
43264214}
43274215
43284216template<class _CharT, class _Traits, class _Allocator>
4329inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4217inline _LIBCPP_HIDE_FROM_ABI
43304218bool
43314219operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
43324220 const _CharT* __rhs) _NOEXCEPT
......@@ -4335,18 +4223,19 @@ operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
43354223}
43364224
43374225template<class _CharT, class _Traits, class _Allocator>
4338inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
4226inline _LIBCPP_HIDE_FROM_ABI
43394227bool
43404228operator>=(const _CharT* __lhs,
43414229 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
43424230{
43434231 return !(__lhs < __rhs);
43444232}
4233#endif // _LIBCPP_STD_VER > 17
43454234
43464235// operator +
43474236
43484237template<class _CharT, class _Traits, class _Allocator>
4349_LIBCPP_CONSTEXPR_AFTER_CXX17
4238_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
43504239basic_string<_CharT, _Traits, _Allocator>
43514240operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
43524241 const basic_string<_CharT, _Traits, _Allocator>& __rhs)
......@@ -4365,7 +4254,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
43654254}
43664255
43674256template<class _CharT, class _Traits, class _Allocator>
4368_LIBCPP_CONSTEXPR_AFTER_CXX17
4257_LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX20
43694258basic_string<_CharT, _Traits, _Allocator>
43704259operator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& __rhs)
43714260{
......@@ -4383,7 +4272,7 @@ operator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& _
43834272}
43844273
43854274template<class _CharT, class _Traits, class _Allocator>
4386_LIBCPP_CONSTEXPR_AFTER_CXX17
4275_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
43874276basic_string<_CharT, _Traits, _Allocator>
43884277operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs)
43894278{
......@@ -4400,7 +4289,7 @@ operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs)
44004289}
44014290
44024291template<class _CharT, class _Traits, class _Allocator>
4403inline _LIBCPP_CONSTEXPR_AFTER_CXX17
4292inline _LIBCPP_CONSTEXPR_SINCE_CXX20
44044293basic_string<_CharT, _Traits, _Allocator>
44054294operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs)
44064295{
......@@ -4418,7 +4307,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT*
44184307}
44194308
44204309template<class _CharT, class _Traits, class _Allocator>
4421_LIBCPP_CONSTEXPR_AFTER_CXX17
4310_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
44224311basic_string<_CharT, _Traits, _Allocator>
44234312operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs)
44244313{
......@@ -4437,7 +4326,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs)
44374326#ifndef _LIBCPP_CXX03_LANG
44384327
44394328template<class _CharT, class _Traits, class _Allocator>
4440inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4329inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
44414330basic_string<_CharT, _Traits, _Allocator>
44424331operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs)
44434332{
......@@ -4445,7 +4334,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<
44454334}
44464335
44474336template<class _CharT, class _Traits, class _Allocator>
4448inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4337inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
44494338basic_string<_CharT, _Traits, _Allocator>
44504339operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs)
44514340{
......@@ -4453,7 +4342,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_
44534342}
44544343
44554344template<class _CharT, class _Traits, class _Allocator>
4456inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4345inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
44574346basic_string<_CharT, _Traits, _Allocator>
44584347operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs)
44594348{
......@@ -4461,7 +4350,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT
44614350}
44624351
44634352template<class _CharT, class _Traits, class _Allocator>
4464inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4353inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
44654354basic_string<_CharT, _Traits, _Allocator>
44664355operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs)
44674356{
......@@ -4469,7 +4358,7 @@ operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs)
44694358}
44704359
44714360template<class _CharT, class _Traits, class _Allocator>
4472inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4361inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
44734362basic_string<_CharT, _Traits, _Allocator>
44744363operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs)
44754364{
......@@ -4478,7 +4367,7 @@ operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs)
44784367}
44794368
44804369template<class _CharT, class _Traits, class _Allocator>
4481inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4370inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
44824371basic_string<_CharT, _Traits, _Allocator>
44834372operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs)
44844373{
......@@ -4486,7 +4375,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs
44864375}
44874376
44884377template<class _CharT, class _Traits, class _Allocator>
4489inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4378inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
44904379basic_string<_CharT, _Traits, _Allocator>
44914380operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs)
44924381{
......@@ -4499,7 +4388,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs)
44994388// swap
45004389
45014390template<class _CharT, class _Traits, class _Allocator>
4502inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4391inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
45034392void
45044393swap(basic_string<_CharT, _Traits, _Allocator>& __lhs,
45054394 basic_string<_CharT, _Traits, _Allocator>& __rhs)
......@@ -4556,27 +4445,44 @@ const typename basic_string<_CharT, _Traits, _Allocator>::size_type
45564445 basic_string<_CharT, _Traits, _Allocator>::npos;
45574446
45584447template <class _CharT, class _Allocator>
4559struct _LIBCPP_TEMPLATE_VIS
4560 hash<basic_string<_CharT, char_traits<_CharT>, _Allocator> >
4561 : public __unary_function<basic_string<_CharT, char_traits<_CharT>, _Allocator>, size_t>
4448struct __string_hash : public __unary_function<basic_string<_CharT, char_traits<_CharT>, _Allocator>, size_t>
45624449{
45634450 size_t
45644451 operator()(const basic_string<_CharT, char_traits<_CharT>, _Allocator>& __val) const _NOEXCEPT
4565 { return __do_string_hash(__val.data(), __val.data() + __val.size()); }
4452 { return std::__do_string_hash(__val.data(), __val.data() + __val.size()); }
45664453};
45674454
4455template <class _Allocator>
4456struct hash<basic_string<char, char_traits<char>, _Allocator> > : __string_hash<char, _Allocator> {};
4457
4458#ifndef _LIBCPP_HAS_NO_CHAR8_T
4459template <class _Allocator>
4460struct hash<basic_string<char8_t, char_traits<char8_t>, _Allocator> > : __string_hash<char8_t, _Allocator> {};
4461#endif
4462
4463template <class _Allocator>
4464struct hash<basic_string<char16_t, char_traits<char16_t>, _Allocator> > : __string_hash<char16_t, _Allocator> {};
4465
4466template <class _Allocator>
4467struct hash<basic_string<char32_t, char_traits<char32_t>, _Allocator> > : __string_hash<char32_t, _Allocator> {};
4468
4469#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
4470template <class _Allocator>
4471struct hash<basic_string<wchar_t, char_traits<wchar_t>, _Allocator> > : __string_hash<wchar_t, _Allocator> {};
4472#endif
4473
45684474template<class _CharT, class _Traits, class _Allocator>
4569basic_ostream<_CharT, _Traits>&
4475_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
45704476operator<<(basic_ostream<_CharT, _Traits>& __os,
45714477 const basic_string<_CharT, _Traits, _Allocator>& __str);
45724478
45734479template<class _CharT, class _Traits, class _Allocator>
4574basic_istream<_CharT, _Traits>&
4480_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
45754481operator>>(basic_istream<_CharT, _Traits>& __is,
45764482 basic_string<_CharT, _Traits, _Allocator>& __str);
45774483
45784484template<class _CharT, class _Traits, class _Allocator>
4579basic_istream<_CharT, _Traits>&
4485_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
45804486getline(basic_istream<_CharT, _Traits>& __is,
45814487 basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm);
45824488
......@@ -4662,14 +4568,14 @@ inline namespace literals
46624568{
46634569 inline namespace string_literals
46644570 {
4665 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4571 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
46664572 basic_string<char> operator "" s( const char *__str, size_t __len )
46674573 {
46684574 return basic_string<char> (__str, __len);
46694575 }
46704576
46714577#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
4672 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4578 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
46734579 basic_string<wchar_t> operator "" s( const wchar_t *__str, size_t __len )
46744580 {
46754581 return basic_string<wchar_t> (__str, __len);
......@@ -4678,19 +4584,19 @@ inline namespace literals
46784584
46794585#ifndef _LIBCPP_HAS_NO_CHAR8_T
46804586 inline _LIBCPP_HIDE_FROM_ABI constexpr
4681 basic_string<char8_t> operator "" s(const char8_t *__str, size_t __len) _NOEXCEPT
4587 basic_string<char8_t> operator "" s(const char8_t *__str, size_t __len)
46824588 {
46834589 return basic_string<char8_t> (__str, __len);
46844590 }
46854591#endif
46864592
4687 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4593 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
46884594 basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len )
46894595 {
46904596 return basic_string<char16_t> (__str, __len);
46914597 }
46924598
4693 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
4599 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
46944600 basic_string<char32_t> operator "" s( const char32_t *__str, size_t __len )
46954601 {
46964602 return basic_string<char32_t> (__str, __len);
......@@ -4713,4 +4619,15 @@ _LIBCPP_END_NAMESPACE_STD
47134619
47144620_LIBCPP_POP_MACROS
47154621
4622#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
4623# include <algorithm>
4624# include <concepts>
4625# include <functional>
4626# include <iterator>
4627# include <new>
4628# include <typeinfo>
4629# include <utility>
4630# include <vector>
4631#endif
4632
47164633#endif // _LIBCPP_STRING
lib/libcxx/include/string.h+37-35
......@@ -57,7 +57,9 @@ size_t strlen(const char* s);
5757# pragma GCC system_header
5858#endif
5959
60#include_next <string.h>
60#if __has_include_next(<string.h>)
61# include_next <string.h>
62#endif
6163
6264// MSVCRT, GNU libc and its derivates may already have the correct prototype in
6365// <string.h>. This macro can be defined by users if their C library provides
......@@ -69,41 +71,41 @@ size_t strlen(const char* s);
6971
7072#if defined(__cplusplus) && !defined(_LIBCPP_STRING_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)
7173extern "C++" {
72inline _LIBCPP_INLINE_VISIBILITY
73char* __libcpp_strchr(const char* __s, int __c) {return (char*)strchr(__s, __c);}
74inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
75const char* strchr(const char* __s, int __c) {return __libcpp_strchr(__s, __c);}
76inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
77 char* strchr( char* __s, int __c) {return __libcpp_strchr(__s, __c);}
78
79inline _LIBCPP_INLINE_VISIBILITY
80char* __libcpp_strpbrk(const char* __s1, const char* __s2) {return (char*)strpbrk(__s1, __s2);}
81inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
82const char* strpbrk(const char* __s1, const char* __s2) {return __libcpp_strpbrk(__s1, __s2);}
83inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
84 char* strpbrk( char* __s1, const char* __s2) {return __libcpp_strpbrk(__s1, __s2);}
85
86inline _LIBCPP_INLINE_VISIBILITY
87char* __libcpp_strrchr(const char* __s, int __c) {return (char*)strrchr(__s, __c);}
88inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
89const char* strrchr(const char* __s, int __c) {return __libcpp_strrchr(__s, __c);}
90inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
91 char* strrchr( char* __s, int __c) {return __libcpp_strrchr(__s, __c);}
92
93inline _LIBCPP_INLINE_VISIBILITY
94void* __libcpp_memchr(const void* __s, int __c, size_t __n) {return (void*)memchr(__s, __c, __n);}
95inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
96const void* memchr(const void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
97inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
98 void* memchr( void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
99
100inline _LIBCPP_INLINE_VISIBILITY
101char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
102inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
103const char* strstr(const char* __s1, const char* __s2) {return __libcpp_strstr(__s1, __s2);}
104inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
105 char* strstr( char* __s1, const char* __s2) {return __libcpp_strstr(__s1, __s2);}
74inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strchr(const char* __s, int __c) {
75 return __builtin_strchr(__s, __c);
76}
77inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strchr(char* __s, int __c) {
78 return __builtin_strchr(__s, __c);
79}
80
81inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strpbrk(const char* __s1, const char* __s2) {
82 return __builtin_strpbrk(__s1, __s2);
83}
84inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strpbrk(char* __s1, const char* __s2) {
85 return __builtin_strpbrk(__s1, __s2);
86}
87
88inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strrchr(const char* __s, int __c) {
89 return __builtin_strrchr(__s, __c);
90}
91inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strrchr(char* __s, int __c) {
92 return __builtin_strrchr(__s, __c);
93}
94
95inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const void* memchr(const void* __s, int __c, size_t __n) {
96 return __builtin_memchr(__s, __c, __n);
97}
98inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD void* memchr(void* __s, int __c, size_t __n) {
99 return __builtin_memchr(__s, __c, __n);
100}
101
102inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strstr(const char* __s1, const char* __s2) {
103 return __builtin_strstr(__s1, __s2);
104}
105inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strstr(char* __s1, const char* __s2) {
106 return __builtin_strstr(__s1, __s2);
106107}
108} // extern "C++"
107109#endif
108110
109111#endif // _LIBCPP_STRING_H
lib/libcxx/include/string_view+227-172
......@@ -14,6 +14,8 @@
1414
1515 string_view synopsis
1616
17#include <compare>
18
1719namespace std {
1820
1921 // 7.2, Class template basic_string_view
......@@ -30,21 +32,25 @@ namespace std {
3032 template<class charT, class traits>
3133 constexpr bool operator==(basic_string_view<charT, traits> x,
3234 basic_string_view<charT, traits> y) noexcept;
33 template<class charT, class traits>
35 template<class charT, class traits> // Removed in C++20
3436 constexpr bool operator!=(basic_string_view<charT, traits> x,
3537 basic_string_view<charT, traits> y) noexcept;
36 template<class charT, class traits>
38 template<class charT, class traits> // Removed in C++20
3739 constexpr bool operator< (basic_string_view<charT, traits> x,
3840 basic_string_view<charT, traits> y) noexcept;
39 template<class charT, class traits>
41 template<class charT, class traits> // Removed in C++20
4042 constexpr bool operator> (basic_string_view<charT, traits> x,
4143 basic_string_view<charT, traits> y) noexcept;
42 template<class charT, class traits>
44 template<class charT, class traits> // Removed in C++20
4345 constexpr bool operator<=(basic_string_view<charT, traits> x,
4446 basic_string_view<charT, traits> y) noexcept;
45 template<class charT, class traits>
47 template<class charT, class traits> // Removed in C++20
4648 constexpr bool operator>=(basic_string_view<charT, traits> x,
4749 basic_string_view<charT, traits> y) noexcept;
50 template<class charT, class traits> // Since C++20
51 constexpr see below operator<=>(basic_string_view<charT, traits> x,
52 basic_string_view<charT, traits> y) noexcept;
53
4854 // see below, sufficient additional overloads of comparison functions
4955
5056 // 7.10, Inserters and extractors
......@@ -185,11 +191,11 @@ namespace std {
185191 template <> struct hash<u32string_view>;
186192 template <> struct hash<wstring_view>;
187193
188 constexpr basic_string_view<char> operator "" sv( const char *str, size_t len ) noexcept;
189 constexpr basic_string_view<wchar_t> operator "" sv( const wchar_t *str, size_t len ) noexcept;
190 constexpr basic_string_view<char8_t> operator "" sv( const char8_t *str, size_t len ) noexcept; // C++20
191 constexpr basic_string_view<char16_t> operator "" sv( const char16_t *str, size_t len ) noexcept;
192 constexpr basic_string_view<char32_t> operator "" sv( const char32_t *str, size_t len ) noexcept;
194 constexpr basic_string_view<char> operator "" sv(const char *str, size_t len) noexcept;
195 constexpr basic_string_view<wchar_t> operator "" sv(const wchar_t *str, size_t len) noexcept;
196 constexpr basic_string_view<char8_t> operator "" sv(const char8_t *str, size_t len) noexcept; // C++20
197 constexpr basic_string_view<char16_t> operator "" sv(const char16_t *str, size_t len) noexcept;
198 constexpr basic_string_view<char32_t> operator "" sv(const char32_t *str, size_t len) noexcept;
193199
194200} // namespace std
195201
......@@ -218,12 +224,6 @@ namespace std {
218224#include <type_traits>
219225#include <version>
220226
221#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
222# include <algorithm>
223# include <functional>
224# include <iterator>
225#endif
226
227227// standard-mandated includes
228228
229229// [iterator.range]
......@@ -256,29 +256,21 @@ inline size_t __char_traits_length_checked(const typename _Traits::char_type* __
256256}
257257
258258template<class _CharT, class _Traits>
259class
260 _LIBCPP_PREFERRED_NAME(string_view)
261#ifndef _LIBCPP_HAS_NO_CHAR8_T
262 _LIBCPP_PREFERRED_NAME(u8string_view)
263#endif
264 _LIBCPP_PREFERRED_NAME(u16string_view)
265 _LIBCPP_PREFERRED_NAME(u32string_view)
266 _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstring_view))
267 basic_string_view {
259class basic_string_view {
268260public:
269261 // types
270 typedef _Traits traits_type;
271 typedef _CharT value_type;
272 typedef _CharT* pointer;
273 typedef const _CharT* const_pointer;
274 typedef _CharT& reference;
275 typedef const _CharT& const_reference;
276 typedef const_pointer const_iterator; // See [string.view.iterators]
277 typedef const_iterator iterator;
278 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
279 typedef const_reverse_iterator reverse_iterator;
280 typedef size_t size_type;
281 typedef ptrdiff_t difference_type;
262 using traits_type = _Traits;
263 using value_type = _CharT;
264 using pointer = _CharT*;
265 using const_pointer = const _CharT*;
266 using reference = _CharT&;
267 using const_reference = const _CharT&;
268 using const_iterator = const_pointer; // See [string.view.iterators]
269 using iterator = const_iterator;
270 using const_reverse_iterator = _VSTD::reverse_iterator<const_iterator>;
271 using reverse_iterator = const_reverse_iterator;
272 using size_type = size_t;
273 using difference_type = ptrdiff_t;
282274 static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1);
283275
284276 static_assert((!is_array<value_type>::value), "Character type of basic_string_view must not be an array");
......@@ -289,7 +281,7 @@ public:
289281
290282 // [string.view.cons], construct/copy
291283 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
292 basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {}
284 basic_string_view() _NOEXCEPT : __data_(nullptr), __size_(0) {}
293285
294286 _LIBCPP_INLINE_VISIBILITY
295287 basic_string_view(const basic_string_view&) _NOEXCEPT = default;
......@@ -299,7 +291,7 @@ public:
299291
300292 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
301293 basic_string_view(const _CharT* __s, size_type __len) _NOEXCEPT
302 : __data(__s), __size(__len)
294 : __data_(__s), __size_(__len)
303295 {
304296#if _LIBCPP_STD_VER > 11
305297 _LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr");
......@@ -310,13 +302,13 @@ public:
310302 template <contiguous_iterator _It, sized_sentinel_for<_It> _End>
311303 requires (is_same_v<iter_value_t<_It>, _CharT> && !is_convertible_v<_End, size_type>)
312304 constexpr _LIBCPP_HIDE_FROM_ABI basic_string_view(_It __begin, _End __end)
313 : __data(_VSTD::to_address(__begin)), __size(__end - __begin)
305 : __data_(_VSTD::to_address(__begin)), __size_(__end - __begin)
314306 {
315307 _LIBCPP_ASSERT((__end - __begin) >= 0, "std::string_view::string_view(iterator, sentinel) received invalid range");
316308 }
317309#endif // _LIBCPP_STD_VER > 17
318310
319#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
311#if _LIBCPP_STD_VER > 20
320312 template <class _Range>
321313 requires (
322314 !is_same_v<remove_cvref_t<_Range>, basic_string_view> &&
......@@ -331,13 +323,13 @@ public:
331323 typename remove_reference_t<_Range>::traits_type;
332324 } || is_same_v<typename remove_reference_t<_Range>::traits_type, _Traits>)
333325 )
334 constexpr _LIBCPP_HIDE_FROM_ABI
335 basic_string_view(_Range&& __r) : __data(ranges::data(__r)), __size(ranges::size(__r)) {}
336#endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
326 constexpr explicit _LIBCPP_HIDE_FROM_ABI
327 basic_string_view(_Range&& __r) : __data_(ranges::data(__r)), __size_(ranges::size(__r)) {}
328#endif // _LIBCPP_STD_VER > 20
337329
338330 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
339331 basic_string_view(const _CharT* __s)
340 : __data(__s), __size(_VSTD::__char_traits_length_checked<_Traits>(__s)) {}
332 : __data_(__s), __size_(_VSTD::__char_traits_length_checked<_Traits>(__s)) {}
341333
342334#if _LIBCPP_STD_VER > 20
343335 basic_string_view(nullptr_t) = delete;
......@@ -351,94 +343,94 @@ public:
351343 const_iterator end() const _NOEXCEPT { return cend(); }
352344
353345 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
354 const_iterator cbegin() const _NOEXCEPT { return __data; }
346 const_iterator cbegin() const _NOEXCEPT { return __data_; }
355347
356348 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
357 const_iterator cend() const _NOEXCEPT { return __data + __size; }
349 const_iterator cend() const _NOEXCEPT { return __data_ + __size_; }
358350
359 _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
351 _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_INLINE_VISIBILITY
360352 const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
361353
362 _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
354 _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_INLINE_VISIBILITY
363355 const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
364356
365 _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
357 _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_INLINE_VISIBILITY
366358 const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
367359
368 _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
360 _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_INLINE_VISIBILITY
369361 const_reverse_iterator crend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
370362
371363 // [string.view.capacity], capacity
372364 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
373 size_type size() const _NOEXCEPT { return __size; }
365 size_type size() const _NOEXCEPT { return __size_; }
374366
375367 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
376 size_type length() const _NOEXCEPT { return __size; }
368 size_type length() const _NOEXCEPT { return __size_; }
377369
378370 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
379371 size_type max_size() const _NOEXCEPT { return numeric_limits<size_type>::max() / sizeof(value_type); }
380372
381373 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
382 bool empty() const _NOEXCEPT { return __size == 0; }
374 bool empty() const _NOEXCEPT { return __size_ == 0; }
383375
384376 // [string.view.access], element access
385377 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
386378 const_reference operator[](size_type __pos) const _NOEXCEPT {
387 return _LIBCPP_ASSERT(__pos < size(), "string_view[] index out of bounds"), __data[__pos];
379 return _LIBCPP_ASSERT(__pos < size(), "string_view[] index out of bounds"), __data_[__pos];
388380 }
389381
390382 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
391383 const_reference at(size_type __pos) const
392384 {
393385 return __pos >= size()
394 ? (__throw_out_of_range("string_view::at"), __data[0])
395 : __data[__pos];
386 ? (__throw_out_of_range("string_view::at"), __data_[0])
387 : __data_[__pos];
396388 }
397389
398390 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
399391 const_reference front() const _NOEXCEPT
400392 {
401 return _LIBCPP_ASSERT(!empty(), "string_view::front(): string is empty"), __data[0];
393 return _LIBCPP_ASSERT(!empty(), "string_view::front(): string is empty"), __data_[0];
402394 }
403395
404396 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
405397 const_reference back() const _NOEXCEPT
406398 {
407 return _LIBCPP_ASSERT(!empty(), "string_view::back(): string is empty"), __data[__size-1];
399 return _LIBCPP_ASSERT(!empty(), "string_view::back(): string is empty"), __data_[__size_-1];
408400 }
409401
410402 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
411 const_pointer data() const _NOEXCEPT { return __data; }
403 const_pointer data() const _NOEXCEPT { return __data_; }
412404
413405 // [string.view.modifiers], modifiers:
414 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
406 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
415407 void remove_prefix(size_type __n) _NOEXCEPT
416408 {
417409 _LIBCPP_ASSERT(__n <= size(), "remove_prefix() can't remove more than size()");
418 __data += __n;
419 __size -= __n;
410 __data_ += __n;
411 __size_ -= __n;
420412 }
421413
422 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
414 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
423415 void remove_suffix(size_type __n) _NOEXCEPT
424416 {
425417 _LIBCPP_ASSERT(__n <= size(), "remove_suffix() can't remove more than size()");
426 __size -= __n;
418 __size_ -= __n;
427419 }
428420
429 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
421 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
430422 void swap(basic_string_view& __other) _NOEXCEPT
431423 {
432 const value_type *__p = __data;
433 __data = __other.__data;
434 __other.__data = __p;
424 const value_type *__p = __data_;
425 __data_ = __other.__data_;
426 __other.__data_ = __p;
435427
436 size_type __sz = __size;
437 __size = __other.__size;
438 __other.__size = __sz;
428 size_type __sz = __size_;
429 __size_ = __other.__size_;
430 __other.__size_ = __sz;
439431 }
440432
441 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
433 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
442434 size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
443435 {
444436 if (__pos > size())
......@@ -456,229 +448,229 @@ public:
456448 : basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos));
457449 }
458450
459 _LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT
451 _LIBCPP_CONSTEXPR_SINCE_CXX14 int compare(basic_string_view __sv) const _NOEXCEPT
460452 {
461 size_type __rlen = _VSTD::min( size(), __sv.size());
453 size_type __rlen = _VSTD::min(size(), __sv.size());
462454 int __retval = _Traits::compare(data(), __sv.data(), __rlen);
463 if ( __retval == 0 ) // first __rlen chars matched
464 __retval = size() == __sv.size() ? 0 : ( size() < __sv.size() ? -1 : 1 );
455 if (__retval == 0) // first __rlen chars matched
456 __retval = size() == __sv.size() ? 0 : (size() < __sv.size() ? -1 : 1);
465457 return __retval;
466458 }
467459
468 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
460 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
469461 int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const
470462 {
471463 return substr(__pos1, __n1).compare(__sv);
472464 }
473465
474 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
466 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
475467 int compare( size_type __pos1, size_type __n1,
476468 basic_string_view __sv, size_type __pos2, size_type __n2) const
477469 {
478470 return substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
479471 }
480472
481 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
473 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
482474 int compare(const _CharT* __s) const _NOEXCEPT
483475 {
484476 return compare(basic_string_view(__s));
485477 }
486478
487 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
479 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
488480 int compare(size_type __pos1, size_type __n1, const _CharT* __s) const
489481 {
490482 return substr(__pos1, __n1).compare(basic_string_view(__s));
491483 }
492484
493 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
485 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
494486 int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const
495487 {
496488 return substr(__pos1, __n1).compare(basic_string_view(__s, __n2));
497489 }
498490
499491 // find
500 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
492 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
501493 size_type find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
502494 {
503495 _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
504 return __str_find<value_type, size_type, traits_type, npos>
496 return std::__str_find<value_type, size_type, traits_type, npos>
505497 (data(), size(), __s.data(), __pos, __s.size());
506498 }
507499
508 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
500 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
509501 size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT
510502 {
511 return __str_find<value_type, size_type, traits_type, npos>
503 return std::__str_find<value_type, size_type, traits_type, npos>
512504 (data(), size(), __c, __pos);
513505 }
514506
515 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
507 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
516508 size_type find(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
517509 {
518510 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): received nullptr");
519 return __str_find<value_type, size_type, traits_type, npos>
511 return std::__str_find<value_type, size_type, traits_type, npos>
520512 (data(), size(), __s, __pos, __n);
521513 }
522514
523 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
515 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
524516 size_type find(const _CharT* __s, size_type __pos = 0) const _NOEXCEPT
525517 {
526518 _LIBCPP_ASSERT(__s != nullptr, "string_view::find(): received nullptr");
527 return __str_find<value_type, size_type, traits_type, npos>
519 return std::__str_find<value_type, size_type, traits_type, npos>
528520 (data(), size(), __s, __pos, traits_type::length(__s));
529521 }
530522
531523 // rfind
532 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
524 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
533525 size_type rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT
534526 {
535527 _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
536 return __str_rfind<value_type, size_type, traits_type, npos>
528 return std::__str_rfind<value_type, size_type, traits_type, npos>
537529 (data(), size(), __s.data(), __pos, __s.size());
538530 }
539531
540 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
532 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
541533 size_type rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT
542534 {
543 return __str_rfind<value_type, size_type, traits_type, npos>
535 return std::__str_rfind<value_type, size_type, traits_type, npos>
544536 (data(), size(), __c, __pos);
545537 }
546538
547 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
539 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
548540 size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
549541 {
550542 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): received nullptr");
551 return __str_rfind<value_type, size_type, traits_type, npos>
543 return std::__str_rfind<value_type, size_type, traits_type, npos>
552544 (data(), size(), __s, __pos, __n);
553545 }
554546
555 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
547 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
556548 size_type rfind(const _CharT* __s, size_type __pos=npos) const _NOEXCEPT
557549 {
558550 _LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): received nullptr");
559 return __str_rfind<value_type, size_type, traits_type, npos>
551 return std::__str_rfind<value_type, size_type, traits_type, npos>
560552 (data(), size(), __s, __pos, traits_type::length(__s));
561553 }
562554
563555 // find_first_of
564 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
556 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
565557 size_type find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
566558 {
567559 _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): received nullptr");
568 return __str_find_first_of<value_type, size_type, traits_type, npos>
560 return std::__str_find_first_of<value_type, size_type, traits_type, npos>
569561 (data(), size(), __s.data(), __pos, __s.size());
570562 }
571563
572 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
564 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
573565 size_type find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT
574566 { return find(__c, __pos); }
575567
576 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
568 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
577569 size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
578570 {
579571 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_of(): received nullptr");
580 return __str_find_first_of<value_type, size_type, traits_type, npos>
572 return std::__str_find_first_of<value_type, size_type, traits_type, npos>
581573 (data(), size(), __s, __pos, __n);
582574 }
583575
584 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
576 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
585577 size_type find_first_of(const _CharT* __s, size_type __pos=0) const _NOEXCEPT
586578 {
587579 _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_of(): received nullptr");
588 return __str_find_first_of<value_type, size_type, traits_type, npos>
580 return std::__str_find_first_of<value_type, size_type, traits_type, npos>
589581 (data(), size(), __s, __pos, traits_type::length(__s));
590582 }
591583
592584 // find_last_of
593 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
585 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
594586 size_type find_last_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
595587 {
596588 _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): received nullptr");
597 return __str_find_last_of<value_type, size_type, traits_type, npos>
589 return std::__str_find_last_of<value_type, size_type, traits_type, npos>
598590 (data(), size(), __s.data(), __pos, __s.size());
599591 }
600592
601 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
593 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
602594 size_type find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT
603595 { return rfind(__c, __pos); }
604596
605 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
597 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
606598 size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
607599 {
608600 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_of(): received nullptr");
609 return __str_find_last_of<value_type, size_type, traits_type, npos>
601 return std::__str_find_last_of<value_type, size_type, traits_type, npos>
610602 (data(), size(), __s, __pos, __n);
611603 }
612604
613 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
605 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
614606 size_type find_last_of(const _CharT* __s, size_type __pos=npos) const _NOEXCEPT
615607 {
616608 _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_of(): received nullptr");
617 return __str_find_last_of<value_type, size_type, traits_type, npos>
609 return std::__str_find_last_of<value_type, size_type, traits_type, npos>
618610 (data(), size(), __s, __pos, traits_type::length(__s));
619611 }
620612
621613 // find_first_not_of
622 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
614 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
623615 size_type find_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT
624616 {
625617 _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): received nullptr");
626 return __str_find_first_not_of<value_type, size_type, traits_type, npos>
618 return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>
627619 (data(), size(), __s.data(), __pos, __s.size());
628620 }
629621
630 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
622 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
631623 size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT
632624 {
633 return __str_find_first_not_of<value_type, size_type, traits_type, npos>
625 return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>
634626 (data(), size(), __c, __pos);
635627 }
636628
637 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
629 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
638630 size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
639631 {
640632 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): received nullptr");
641 return __str_find_first_not_of<value_type, size_type, traits_type, npos>
633 return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>
642634 (data(), size(), __s, __pos, __n);
643635 }
644636
645 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
637 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
646638 size_type find_first_not_of(const _CharT* __s, size_type __pos=0) const _NOEXCEPT
647639 {
648640 _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_not_of(): received nullptr");
649 return __str_find_first_not_of<value_type, size_type, traits_type, npos>
641 return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>
650642 (data(), size(), __s, __pos, traits_type::length(__s));
651643 }
652644
653645 // find_last_not_of
654 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
646 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
655647 size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
656648 {
657649 _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): received nullptr");
658 return __str_find_last_not_of<value_type, size_type, traits_type, npos>
650 return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>
659651 (data(), size(), __s.data(), __pos, __s.size());
660652 }
661653
662 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
654 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
663655 size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT
664656 {
665 return __str_find_last_not_of<value_type, size_type, traits_type, npos>
657 return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>
666658 (data(), size(), __c, __pos);
667659 }
668660
669 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
661 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
670662 size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
671663 {
672664 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): received nullptr");
673 return __str_find_last_not_of<value_type, size_type, traits_type, npos>
665 return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>
674666 (data(), size(), __s, __pos, __n);
675667 }
676668
677 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
669 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
678670 size_type find_last_not_of(const _CharT* __s, size_type __pos=npos) const _NOEXCEPT
679671 {
680672 _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_not_of(): received nullptr");
681 return __str_find_last_not_of<value_type, size_type, traits_type, npos>
673 return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>
682674 (data(), size(), __s, __pos, traits_type::length(__s));
683675 }
684676
......@@ -723,9 +715,10 @@ public:
723715#endif
724716
725717private:
726 const value_type* __data;
727 size_type __size;
718 const value_type* __data_;
719 size_type __size_;
728720};
721_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_string_view);
729722
730723#if _LIBCPP_STD_VER > 17
731724template <class _CharT, class _Traits>
......@@ -743,69 +736,105 @@ template <contiguous_iterator _It, sized_sentinel_for<_It> _End>
743736#endif // _LIBCPP_STD_VER > 17
744737
745738
746#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
739#if _LIBCPP_STD_VER > 20
747740template <ranges::contiguous_range _Range>
748741 basic_string_view(_Range) -> basic_string_view<ranges::range_value_t<_Range>>;
749#endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
742#endif
750743
751744// [string.view.comparison]
752745// operator ==
753746template<class _CharT, class _Traits>
754_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
747_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
755748bool operator==(basic_string_view<_CharT, _Traits> __lhs,
756749 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
757750{
758 if ( __lhs.size() != __rhs.size()) return false;
751 if (__lhs.size() != __rhs.size()) return false;
759752 return __lhs.compare(__rhs) == 0;
760753}
761754
762755// The dummy default template parameters are used to work around a MSVC issue with mangling, see VSO-409326 for details.
763756// This applies to the other sufficient overloads below for the other comparison operators.
764757template<class _CharT, class _Traits, int = 1>
765_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
758_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
766759bool operator==(basic_string_view<_CharT, _Traits> __lhs,
767 typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
760 __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT
768761{
769 if ( __lhs.size() != __rhs.size()) return false;
762 if (__lhs.size() != __rhs.size()) return false;
770763 return __lhs.compare(__rhs) == 0;
771764}
772765
766#if _LIBCPP_STD_VER < 20
767// This overload is automatically generated in C++20.
773768template<class _CharT, class _Traits, int = 2>
774_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
775bool operator==(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
769_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
770bool operator==(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
776771 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
777772{
778 if ( __lhs.size() != __rhs.size()) return false;
773 if (__lhs.size() != __rhs.size()) return false;
779774 return __lhs.compare(__rhs) == 0;
780775}
776#endif // _LIBCPP_STD_VER > 17
781777
778// operator <=>
779
780#if _LIBCPP_STD_VER > 17
781
782template <class _CharT, class _Traits>
783_LIBCPP_HIDE_FROM_ABI constexpr auto
784operator<=>(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) noexcept {
785 if constexpr (requires { typename _Traits::comparison_category; }) {
786 // [string.view]/4
787 static_assert(
788 __comparison_category<typename _Traits::comparison_category>,
789 "return type is not a comparison category type");
790 return static_cast<typename _Traits::comparison_category>(__lhs.compare(__rhs) <=> 0);
791 } else {
792 return static_cast<weak_ordering>(__lhs.compare(__rhs) <=> 0);
793 }
794}
795
796template <class _CharT, class _Traits, int = 1>
797_LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(
798 basic_string_view<_CharT, _Traits> __lhs, type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) noexcept {
799 if constexpr (requires { typename _Traits::comparison_category; }) {
800 // [string.view]/4
801 static_assert(
802 __comparison_category<typename _Traits::comparison_category>,
803 "return type is not a comparison category type");
804 return static_cast<typename _Traits::comparison_category>(__lhs.compare(__rhs) <=> 0);
805 } else {
806 return static_cast<weak_ordering>(__lhs.compare(__rhs) <=> 0);
807 }
808}
809
810#else // _LIBCPP_STD_VER > 17
782811
783812// operator !=
784813template<class _CharT, class _Traits>
785_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
814_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
786815bool operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
787816{
788 if ( __lhs.size() != __rhs.size())
817 if (__lhs.size() != __rhs.size())
789818 return true;
790819 return __lhs.compare(__rhs) != 0;
791820}
792821
793822template<class _CharT, class _Traits, int = 1>
794_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
823_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
795824bool operator!=(basic_string_view<_CharT, _Traits> __lhs,
796 typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
825 __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT
797826{
798 if ( __lhs.size() != __rhs.size())
827 if (__lhs.size() != __rhs.size())
799828 return true;
800829 return __lhs.compare(__rhs) != 0;
801830}
802831
803832template<class _CharT, class _Traits, int = 2>
804_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
805bool operator!=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
833_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
834bool operator!=(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
806835 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
807836{
808 if ( __lhs.size() != __rhs.size())
837 if (__lhs.size() != __rhs.size())
809838 return true;
810839 return __lhs.compare(__rhs) != 0;
811840}
......@@ -813,23 +842,23 @@ bool operator!=(typename common_type<basic_string_view<_CharT, _Traits> >::type
813842
814843// operator <
815844template<class _CharT, class _Traits>
816_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
845_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
817846bool operator<(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
818847{
819848 return __lhs.compare(__rhs) < 0;
820849}
821850
822851template<class _CharT, class _Traits, int = 1>
823_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
852_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
824853bool operator<(basic_string_view<_CharT, _Traits> __lhs,
825 typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
854 __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT
826855{
827856 return __lhs.compare(__rhs) < 0;
828857}
829858
830859template<class _CharT, class _Traits, int = 2>
831_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
832bool operator<(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
860_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
861bool operator<(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
833862 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
834863{
835864 return __lhs.compare(__rhs) < 0;
......@@ -838,23 +867,23 @@ bool operator<(typename common_type<basic_string_view<_CharT, _Traits> >::type _
838867
839868// operator >
840869template<class _CharT, class _Traits>
841_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
870_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
842871bool operator> (basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
843872{
844873 return __lhs.compare(__rhs) > 0;
845874}
846875
847876template<class _CharT, class _Traits, int = 1>
848_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
877_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
849878bool operator>(basic_string_view<_CharT, _Traits> __lhs,
850 typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
879 __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT
851880{
852881 return __lhs.compare(__rhs) > 0;
853882}
854883
855884template<class _CharT, class _Traits, int = 2>
856_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
857bool operator>(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
885_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
886bool operator>(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
858887 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
859888{
860889 return __lhs.compare(__rhs) > 0;
......@@ -863,23 +892,23 @@ bool operator>(typename common_type<basic_string_view<_CharT, _Traits> >::type _
863892
864893// operator <=
865894template<class _CharT, class _Traits>
866_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
895_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
867896bool operator<=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
868897{
869898 return __lhs.compare(__rhs) <= 0;
870899}
871900
872901template<class _CharT, class _Traits, int = 1>
873_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
902_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
874903bool operator<=(basic_string_view<_CharT, _Traits> __lhs,
875 typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
904 __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT
876905{
877906 return __lhs.compare(__rhs) <= 0;
878907}
879908
880909template<class _CharT, class _Traits, int = 2>
881_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
882bool operator<=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
910_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
911bool operator<=(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
883912 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
884913{
885914 return __lhs.compare(__rhs) <= 0;
......@@ -888,7 +917,7 @@ bool operator<=(typename common_type<basic_string_view<_CharT, _Traits> >::type
888917
889918// operator >=
890919template<class _CharT, class _Traits>
891_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
920_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
892921bool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
893922{
894923 return __lhs.compare(__rhs) >= 0;
......@@ -896,38 +925,57 @@ bool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_Cha
896925
897926
898927template<class _CharT, class _Traits, int = 1>
899_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
928_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
900929bool operator>=(basic_string_view<_CharT, _Traits> __lhs,
901 typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
930 __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT
902931{
903932 return __lhs.compare(__rhs) >= 0;
904933}
905934
906935template<class _CharT, class _Traits, int = 2>
907_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
908bool operator>=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
936_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
937bool operator>=(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
909938 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
910939{
911940 return __lhs.compare(__rhs) >= 0;
912941}
913942
943#endif // _LIBCPP_STD_VER > 17
914944
915945template<class _CharT, class _Traits>
916basic_ostream<_CharT, _Traits>&
946_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
917947operator<<(basic_ostream<_CharT, _Traits>& __os,
918948 basic_string_view<_CharT, _Traits> __str);
919949
920950// [string.view.hash]
921951template<class _CharT>
922struct _LIBCPP_TEMPLATE_VIS hash<basic_string_view<_CharT, char_traits<_CharT> > >
923 : public __unary_function<basic_string_view<_CharT, char_traits<_CharT> >, size_t>
952struct __string_view_hash : public __unary_function<basic_string_view<_CharT, char_traits<_CharT> >, size_t>
924953{
925954 _LIBCPP_INLINE_VISIBILITY
926955 size_t operator()(const basic_string_view<_CharT, char_traits<_CharT> > __val) const _NOEXCEPT {
927 return __do_string_hash(__val.data(), __val.data() + __val.size());
956 return std::__do_string_hash(__val.data(), __val.data() + __val.size());
928957 }
929958};
930959
960template <>
961struct hash<basic_string_view<char, char_traits<char> > > : __string_view_hash<char> {};
962
963#ifndef _LIBCPP_HAS_NO_CHAR8_T
964template <>
965struct hash<basic_string_view<char8_t, char_traits<char8_t> > > : __string_view_hash<char8_t> {};
966#endif
967
968template <>
969struct hash<basic_string_view<char16_t, char_traits<char16_t> > > : __string_view_hash<char16_t> {};
970
971template <>
972struct hash<basic_string_view<char32_t, char_traits<char32_t> > > : __string_view_hash<char32_t> {};
973
974#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
975template <>
976struct hash<basic_string_view<wchar_t, char_traits<wchar_t> > > : __string_view_hash<wchar_t> {};
977#endif
978
931979#if _LIBCPP_STD_VER > 11
932980inline namespace literals
933981{
......@@ -973,4 +1021,11 @@ _LIBCPP_END_NAMESPACE_STD
9731021
9741022_LIBCPP_POP_MACROS
9751023
1024#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1025# include <algorithm>
1026# include <concepts>
1027# include <functional>
1028# include <iterator>
1029#endif
1030
9761031#endif // _LIBCPP_STRING_VIEW
lib/libcxx/include/strstream+11-11
......@@ -167,7 +167,7 @@ public:
167167 strstreambuf& operator=(strstreambuf&& __rhs);
168168#endif // _LIBCPP_CXX03_LANG
169169
170 virtual ~strstreambuf();
170 ~strstreambuf() override;
171171
172172 void swap(strstreambuf& __rhs);
173173
......@@ -176,13 +176,13 @@ public:
176176 int pcount() const;
177177
178178protected:
179 virtual int_type overflow (int_type __c = EOF);
180 virtual int_type pbackfail(int_type __c = EOF);
181 virtual int_type underflow();
182 virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
183 ios_base::openmode __which = ios_base::in | ios_base::out);
184 virtual pos_type seekpos(pos_type __sp,
185 ios_base::openmode __which = ios_base::in | ios_base::out);
179 int_type overflow (int_type __c = EOF) override;
180 int_type pbackfail(int_type __c = EOF) override;
181 int_type underflow() override;
182 pos_type seekoff(off_type __off, ios_base::seekdir __way,
183 ios_base::openmode __which = ios_base::in | ios_base::out) override;
184 pos_type seekpos(pos_type __sp,
185 ios_base::openmode __which = ios_base::in | ios_base::out) override;
186186
187187private:
188188 typedef unsigned __mode_type;
......@@ -272,7 +272,7 @@ public:
272272 }
273273#endif // _LIBCPP_CXX03_LANG
274274
275 virtual ~istrstream();
275 ~istrstream() override;
276276
277277 _LIBCPP_INLINE_VISIBILITY
278278 void swap(istrstream& __rhs)
......@@ -321,7 +321,7 @@ public:
321321 }
322322#endif // _LIBCPP_CXX03_LANG
323323
324 virtual ~ostrstream();
324 ~ostrstream() override;
325325
326326 _LIBCPP_INLINE_VISIBILITY
327327 void swap(ostrstream& __rhs)
......@@ -381,7 +381,7 @@ public:
381381 }
382382#endif // _LIBCPP_CXX03_LANG
383383
384 virtual ~strstream();
384 ~strstream() override;
385385
386386 _LIBCPP_INLINE_VISIBILITY
387387 void swap(strstream& __rhs)
lib/libcxx/include/system_error+92-33
......@@ -32,8 +32,9 @@ public:
3232 virtual string message(int ev) const = 0;
3333
3434 bool operator==(const error_category& rhs) const noexcept;
35 bool operator!=(const error_category& rhs) const noexcept;
36 bool operator<(const error_category& rhs) const noexcept;
35 bool operator!=(const error_category& rhs) const noexcept; // removed in C++20
36 bool operator<(const error_category& rhs) const noexcept; // removed in C++20
37 strong_ordering operator<=>(const error_category& rhs) const noexcept; // C++20
3738};
3839
3940const error_category& generic_category() noexcept;
......@@ -75,7 +76,6 @@ public:
7576};
7677
7778// non-member functions:
78bool operator<(const error_code& lhs, const error_code& rhs) noexcept;
7979template <class charT, class traits>
8080 basic_ostream<charT,traits>&
8181 operator<<(basic_ostream<charT,traits>& os, const error_code& ec);
......@@ -102,8 +102,6 @@ public:
102102 explicit operator bool() const noexcept;
103103};
104104
105bool operator<(const error_condition& lhs, const error_condition& rhs) noexcept;
106
107105class system_error
108106 : public runtime_error
109107{
......@@ -128,12 +126,16 @@ error_condition make_error_condition(errc e) noexcept;
128126// Comparison operators:
129127bool operator==(const error_code& lhs, const error_code& rhs) noexcept;
130128bool operator==(const error_code& lhs, const error_condition& rhs) noexcept;
131bool operator==(const error_condition& lhs, const error_code& rhs) noexcept;
129bool operator==(const error_condition& lhs, const error_code& rhs) noexcept; // removed in C++20
132130bool operator==(const error_condition& lhs, const error_condition& rhs) noexcept;
133bool operator!=(const error_code& lhs, const error_code& rhs) noexcept;
134bool operator!=(const error_code& lhs, const error_condition& rhs) noexcept;
135bool operator!=(const error_condition& lhs, const error_code& rhs) noexcept;
136bool operator!=(const error_condition& lhs, const error_condition& rhs) noexcept;
131bool operator!=(const error_code& lhs, const error_code& rhs) noexcept; // removed in C++20
132bool operator!=(const error_code& lhs, const error_condition& rhs) noexcept; // removed in C++20
133bool operator!=(const error_condition& lhs, const error_code& rhs) noexcept; // removed in C++20
134bool operator!=(const error_condition& lhs, const error_condition& rhs) noexcept; // removed in C++20
135bool operator<(const error_condition& lhs, const error_condition& rhs) noexcept; // removed in C++20
136bool operator<(const error_code& lhs, const error_code& rhs) noexcept; // removed in C++20
137strong_ordering operator<=>(const error_code& lhs, const error_code& rhs) noexcept; // C++20
138strong_ordering operator<=>(const error_condition& lhs, const error_condition& rhs) noexcept; // C++20
137139
138140template <> struct hash<std::error_code>;
139141template <> struct hash<std::error_condition>;
......@@ -147,12 +149,15 @@ template <> struct hash<std::error_condition>;
147149#include <__errc>
148150#include <__functional/hash.h>
149151#include <__functional/unary_function.h>
152#include <__memory/addressof.h>
150153#include <stdexcept>
151154#include <string>
152155#include <type_traits>
153156#include <version>
154157
155158// standard-mandated includes
159
160// [system.error.syn]
156161#include <compare>
157162
158163#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -209,7 +214,7 @@ public:
209214 error_category() noexcept;
210215#else
211216 _LIBCPP_INLINE_VISIBILITY
212 _LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT = default;
217 _LIBCPP_CONSTEXPR_SINCE_CXX14 error_category() _NOEXCEPT = default;
213218#endif
214219 error_category(const error_category&) = delete;
215220 error_category& operator=(const error_category&) = delete;
......@@ -223,12 +228,21 @@ public:
223228 _LIBCPP_INLINE_VISIBILITY
224229 bool operator==(const error_category& __rhs) const _NOEXCEPT {return this == &__rhs;}
225230
231#if _LIBCPP_STD_VER > 17
232
233 _LIBCPP_HIDE_FROM_ABI
234 strong_ordering operator<=>(const error_category& __rhs) const noexcept {return compare_three_way()(this, std::addressof(__rhs));}
235
236#else // _LIBCPP_STD_VER > 17
237
226238 _LIBCPP_INLINE_VISIBILITY
227239 bool operator!=(const error_category& __rhs) const _NOEXCEPT {return !(*this == __rhs);}
228240
229241 _LIBCPP_INLINE_VISIBILITY
230242 bool operator< (const error_category& __rhs) const _NOEXCEPT {return this < &__rhs;}
231243
244#endif // _LIBCPP_STD_VER > 17
245
232246 friend class _LIBCPP_HIDDEN __do_message;
233247};
234248
......@@ -236,12 +250,19 @@ class _LIBCPP_HIDDEN __do_message
236250 : public error_category
237251{
238252public:
239 virtual string message(int __ev) const;
253 string message(int __ev) const override;
240254};
241255
242256_LIBCPP_FUNC_VIS const error_category& generic_category() _NOEXCEPT;
243257_LIBCPP_FUNC_VIS const error_category& system_category() _NOEXCEPT;
244258
259namespace __adl_only {
260 // Those cause ADL to trigger but they are not viable candidates,
261 // so they are never actually selected.
262 void make_error_condition() = delete;
263 void make_error_code() = delete;
264} // namespace __adl_only
265
245266class _LIBCPP_TYPE_VIS error_condition
246267{
247268 int __val_;
......@@ -259,7 +280,10 @@ public:
259280 error_condition(_Ep __e,
260281 typename enable_if<is_error_condition_enum<_Ep>::value>::type* = nullptr
261282 ) _NOEXCEPT
262 {*this = make_error_condition(__e);}
283 {
284 using __adl_only::make_error_condition;
285 *this = make_error_condition(__e);
286 }
263287
264288 _LIBCPP_INLINE_VISIBILITY
265289 void assign(int __val, const error_category& __cat) _NOEXCEPT
......@@ -276,7 +300,11 @@ public:
276300 error_condition&
277301 >::type
278302 operator=(_Ep __e) _NOEXCEPT
279 {*this = make_error_condition(__e); return *this;}
303 {
304 using __adl_only::make_error_condition;
305 *this = make_error_condition(__e);
306 return *this;
307 }
280308
281309 _LIBCPP_INLINE_VISIBILITY
282310 void clear() _NOEXCEPT
......@@ -303,14 +331,6 @@ make_error_condition(errc __e) _NOEXCEPT
303331 return error_condition(static_cast<int>(__e), generic_category());
304332}
305333
306inline _LIBCPP_INLINE_VISIBILITY
307bool
308operator<(const error_condition& __x, const error_condition& __y) _NOEXCEPT
309{
310 return __x.category() < __y.category()
311 || (__x.category() == __y.category() && __x.value() < __y.value());
312}
313
314334// error_code
315335
316336class _LIBCPP_TYPE_VIS error_code
......@@ -330,7 +350,10 @@ public:
330350 error_code(_Ep __e,
331351 typename enable_if<is_error_code_enum<_Ep>::value>::type* = nullptr
332352 ) _NOEXCEPT
333 {*this = make_error_code(__e);}
353 {
354 using __adl_only::make_error_code;
355 *this = make_error_code(__e);
356 }
334357
335358 _LIBCPP_INLINE_VISIBILITY
336359 void assign(int __val, const error_category& __cat) _NOEXCEPT
......@@ -347,7 +370,11 @@ public:
347370 error_code&
348371 >::type
349372 operator=(_Ep __e) _NOEXCEPT
350 {*this = make_error_code(__e); return *this;}
373 {
374 using __adl_only::make_error_code;
375 *this = make_error_code(__e);
376 return *this;
377 }
351378
352379 _LIBCPP_INLINE_VISIBILITY
353380 void clear() _NOEXCEPT
......@@ -379,14 +406,6 @@ make_error_code(errc __e) _NOEXCEPT
379406 return error_code(static_cast<int>(__e), generic_category());
380407}
381408
382inline _LIBCPP_INLINE_VISIBILITY
383bool
384operator<(const error_code& __x, const error_code& __y) _NOEXCEPT
385{
386 return __x.category() < __y.category()
387 || (__x.category() == __y.category() && __x.value() < __y.value());
388}
389
390409inline _LIBCPP_INLINE_VISIBILITY
391410bool
392411operator==(const error_code& __x, const error_code& __y) _NOEXCEPT
......@@ -402,12 +421,14 @@ operator==(const error_code& __x, const error_condition& __y) _NOEXCEPT
402421 || __y.category().equivalent(__x, __y.value());
403422}
404423
424#if _LIBCPP_STD_VER <= 17
405425inline _LIBCPP_INLINE_VISIBILITY
406426bool
407427operator==(const error_condition& __x, const error_code& __y) _NOEXCEPT
408428{
409429 return __y == __x;
410430}
431#endif
411432
412433inline _LIBCPP_INLINE_VISIBILITY
413434bool
......@@ -416,6 +437,8 @@ operator==(const error_condition& __x, const error_condition& __y) _NOEXCEPT
416437 return __x.category() == __y.category() && __x.value() == __y.value();
417438}
418439
440#if _LIBCPP_STD_VER <= 17
441
419442inline _LIBCPP_INLINE_VISIBILITY
420443bool
421444operator!=(const error_code& __x, const error_code& __y) _NOEXCEPT
......@@ -436,6 +459,42 @@ bool
436459operator!=(const error_condition& __x, const error_condition& __y) _NOEXCEPT
437460{return !(__x == __y);}
438461
462inline _LIBCPP_INLINE_VISIBILITY
463bool
464operator<(const error_condition& __x, const error_condition& __y) _NOEXCEPT
465{
466 return __x.category() < __y.category()
467 || (__x.category() == __y.category() && __x.value() < __y.value());
468}
469
470inline _LIBCPP_INLINE_VISIBILITY
471bool
472operator<(const error_code& __x, const error_code& __y) _NOEXCEPT
473{
474 return __x.category() < __y.category()
475 || (__x.category() == __y.category() && __x.value() < __y.value());
476}
477
478#else // _LIBCPP_STD_VER <= 17
479
480inline _LIBCPP_HIDE_FROM_ABI strong_ordering
481operator<=>(const error_code& __x, const error_code& __y) noexcept
482{
483 if (auto __c = __x.category() <=> __y.category(); __c != 0)
484 return __c;
485 return __x.value() <=> __y.value();
486}
487
488inline _LIBCPP_HIDE_FROM_ABI strong_ordering
489operator<=>(const error_condition& __x, const error_condition& __y) noexcept
490{
491 if (auto __c = __x.category() <=> __y.category(); __c != 0)
492 return __c;
493 return __x.value() <=> __y.value();
494}
495
496#endif // _LIBCPP_STD_VER <= 17
497
439498template <>
440499struct _LIBCPP_TEMPLATE_VIS hash<error_code>
441500 : public __unary_function<error_code, size_t>
......@@ -472,7 +531,7 @@ public:
472531 system_error(int __ev, const error_category& __ecat, const char* __what_arg);
473532 system_error(int __ev, const error_category& __ecat);
474533 system_error(const system_error&) _NOEXCEPT = default;
475 ~system_error() _NOEXCEPT;
534 ~system_error() _NOEXCEPT override;
476535
477536 _LIBCPP_INLINE_VISIBILITY
478537 const error_code& code() const _NOEXCEPT {return __ec_;}
lib/libcxx/include/tgmath.h+6-8
......@@ -24,13 +24,11 @@
2424#endif
2525
2626#ifdef __cplusplus
27
28#include <ctgmath>
29
30#else // __cplusplus
31
32#include_next <tgmath.h>
33
34#endif // __cplusplus
27# include <ctgmath>
28#else
29# if __has_include_next(<tgmath.h>)
30# include_next <tgmath.h>
31# endif
32#endif
3533
3634#endif // _LIBCPP_TGMATH_H
lib/libcxx/include/thread+22-16
......@@ -53,11 +53,12 @@ public:
5353};
5454
5555bool operator==(thread::id x, thread::id y) noexcept;
56bool operator!=(thread::id x, thread::id y) noexcept;
57bool operator< (thread::id x, thread::id y) noexcept;
58bool operator<=(thread::id x, thread::id y) noexcept;
59bool operator> (thread::id x, thread::id y) noexcept;
60bool operator>=(thread::id x, thread::id y) noexcept;
56bool operator!=(thread::id x, thread::id y) noexcept; // removed in C++20
57bool operator< (thread::id x, thread::id y) noexcept; // removed in C++20
58bool operator<=(thread::id x, thread::id y) noexcept; // removed in C++20
59bool operator> (thread::id x, thread::id y) noexcept; // removed in C++20
60bool operator>=(thread::id x, thread::id y) noexcept; // removed in C++20
61strong_ordering operator<=>(thread::id x, thread::id y) noexcept; // C++20
6162
6263template<class charT, class traits>
6364basic_ostream<charT, traits>&
......@@ -85,6 +86,7 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
8586#include <__assert> // all public C++ headers provide the assertion handler
8687#include <__config>
8788#include <__functional/hash.h>
89#include <__memory/unique_ptr.h>
8890#include <__mutex_base>
8991#include <__thread/poll_with_backoff.h>
9092#include <__thread/timed_backoff_policy.h>
......@@ -92,18 +94,14 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
9294#include <__utility/forward.h>
9395#include <cstddef>
9496#include <iosfwd>
95#include <memory>
9697#include <system_error>
9798#include <tuple>
9899#include <type_traits>
99100#include <version>
100101
101#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
102# include <chrono>
103# include <functional>
104#endif
105
106102// standard-mandated includes
103
104// [thread.syn]
107105#include <compare>
108106
109107#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -201,7 +199,7 @@ __thread_specific_ptr<_Tp>::set_pointer(pointer __p)
201199{
202200 _LIBCPP_ASSERT(get() == nullptr,
203201 "Attempting to overwrite thread local data");
204 __libcpp_tls_set(__key_, __p);
202 std::__libcpp_tls_set(__key_, __p);
205203}
206204
207205template<>
......@@ -235,7 +233,7 @@ public:
235233 thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {}
236234#ifndef _LIBCPP_CXX03_LANG
237235 template <class _Fp, class ..._Args,
238 class = __enable_if_t<!is_same<__uncvref_t<_Fp>, thread>::value> >
236 class = __enable_if_t<!is_same<__remove_cvref_t<_Fp>, thread>::value> >
239237 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
240238 explicit thread(_Fp&& __f, _Args&&... __args);
241239#else // _LIBCPP_CXX03_LANG
......@@ -328,7 +326,7 @@ struct __thread_invoke_pair {
328326};
329327
330328template <class _Fp>
331void* __thread_proxy_cxx03(void* __vp)
329_LIBCPP_HIDE_FROM_ABI void* __thread_proxy_cxx03(void* __vp)
332330{
333331 unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
334332 __thread_local_data().set_pointer(__p->__tsp_.release());
......@@ -361,7 +359,7 @@ namespace this_thread
361359_LIBCPP_FUNC_VIS void sleep_for(const chrono::nanoseconds& __ns);
362360
363361template <class _Rep, class _Period>
364void
362_LIBCPP_HIDE_FROM_ABI void
365363sleep_for(const chrono::duration<_Rep, _Period>& __d)
366364{
367365 if (__d > chrono::duration<_Rep, _Period>::zero())
......@@ -385,7 +383,7 @@ sleep_for(const chrono::duration<_Rep, _Period>& __d)
385383}
386384
387385template <class _Clock, class _Duration>
388void
386_LIBCPP_HIDE_FROM_ABI void
389387sleep_until(const chrono::time_point<_Clock, _Duration>& __t)
390388{
391389 mutex __mut;
......@@ -412,4 +410,12 @@ _LIBCPP_END_NAMESPACE_STD
412410
413411_LIBCPP_POP_MACROS
414412
413#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
414# include <chrono>
415#endif
416
417#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
418# include <functional>
419#endif
420
415421#endif // _LIBCPP_THREAD
lib/libcxx/include/tuple+162-126
......@@ -205,10 +205,45 @@ template <class... Types>
205205#include <__compare/common_comparison_category.h>
206206#include <__compare/synth_three_way.h>
207207#include <__config>
208#include <__functional/invoke.h>
208209#include <__functional/unwrap_ref.h>
210#include <__fwd/array.h>
209211#include <__memory/allocator_arg_t.h>
210212#include <__memory/uses_allocator.h>
211#include <__tuple>
213#include <__type_traits/apply_cv.h>
214#include <__type_traits/common_reference.h>
215#include <__type_traits/common_type.h>
216#include <__type_traits/conditional.h>
217#include <__type_traits/conjunction.h>
218#include <__type_traits/copy_cvref.h>
219#include <__type_traits/disjunction.h>
220#include <__type_traits/is_arithmetic.h>
221#include <__type_traits/is_assignable.h>
222#include <__type_traits/is_constructible.h>
223#include <__type_traits/is_convertible.h>
224#include <__type_traits/is_copy_assignable.h>
225#include <__type_traits/is_copy_constructible.h>
226#include <__type_traits/is_default_constructible.h>
227#include <__type_traits/is_empty.h>
228#include <__type_traits/is_final.h>
229#include <__type_traits/is_implicitly_default_constructible.h>
230#include <__type_traits/is_move_assignable.h>
231#include <__type_traits/is_move_constructible.h>
232#include <__type_traits/is_nothrow_assignable.h>
233#include <__type_traits/is_nothrow_constructible.h>
234#include <__type_traits/is_nothrow_copy_assignable.h>
235#include <__type_traits/is_nothrow_copy_constructible.h>
236#include <__type_traits/is_nothrow_default_constructible.h>
237#include <__type_traits/is_nothrow_move_assignable.h>
238#include <__type_traits/is_reference.h>
239#include <__type_traits/is_same.h>
240#include <__type_traits/is_swappable.h>
241#include <__type_traits/lazy.h>
242#include <__type_traits/maybe_const.h>
243#include <__type_traits/nat.h>
244#include <__type_traits/negation.h>
245#include <__type_traits/remove_cvref.h>
246#include <__type_traits/remove_reference.h>
212247#include <__utility/forward.h>
213248#include <__utility/integer_sequence.h>
214249#include <__utility/move.h>
......@@ -216,18 +251,11 @@ template <class... Types>
216251#include <__utility/piecewise_construct.h>
217252#include <__utility/swap.h>
218253#include <cstddef>
219#include <type_traits>
220254#include <version>
221255
222#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
223# include <exception>
224# include <iosfwd>
225# include <new>
226# include <typeinfo>
227# include <utility>
228#endif
229
230256// standard-mandated includes
257
258// [tuple.syn]
231259#include <compare>
232260
233261#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -247,7 +275,7 @@ template <size_t _Ip, class _Hp,
247275class __tuple_leaf;
248276
249277template <size_t _Ip, class _Hp, bool _Ep>
250inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
278inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
251279void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
252280 _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)
253281{
......@@ -255,7 +283,7 @@ void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
255283}
256284
257285template <size_t _Ip, class _Hp, bool _Ep>
258_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
286_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
259287void swap(const __tuple_leaf<_Ip, _Hp, _Ep>& __x, const __tuple_leaf<_Ip, _Hp, _Ep>& __y)
260288 _NOEXCEPT_(__is_nothrow_swappable<const _Hp>::value) {
261289 swap(__x.get(), __y.get());
......@@ -275,7 +303,7 @@ class __tuple_leaf
275303#endif
276304 }
277305
278 _LIBCPP_CONSTEXPR_AFTER_CXX11
306 _LIBCPP_CONSTEXPR_SINCE_CXX14
279307 __tuple_leaf& operator=(const __tuple_leaf&);
280308public:
281309 _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf()
......@@ -307,33 +335,33 @@ public:
307335 template <class _Tp,
308336 class = __enable_if_t<
309337 _And<
310 _IsNotSame<__uncvref_t<_Tp>, __tuple_leaf>,
338 _IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>,
311339 is_constructible<_Hp, _Tp>
312340 >::value
313341 >
314342 >
315 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
343 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
316344 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
317345 : __value_(_VSTD::forward<_Tp>(__t))
318346 {static_assert(__can_bind_reference<_Tp&&>(),
319347 "Attempted construction of reference element binds to a temporary whose lifetime has ended");}
320348
321349 template <class _Tp, class _Alloc>
322 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
350 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
323351 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
324352 : __value_(_VSTD::forward<_Tp>(__t))
325353 {static_assert(__can_bind_reference<_Tp&&>(),
326354 "Attempted construction of reference element binds to a temporary whose lifetime has ended");}
327355
328356 template <class _Tp, class _Alloc>
329 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
357 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
330358 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
331359 : __value_(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))
332360 {static_assert(!is_reference<_Hp>::value,
333361 "Attempted to uses-allocator construct a reference element in a tuple");}
334362
335363 template <class _Tp, class _Alloc>
336 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
364 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
337365 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
338366 : __value_(_VSTD::forward<_Tp>(__t), __a)
339367 {static_assert(!is_reference<_Hp>::value,
......@@ -342,28 +370,28 @@ public:
342370 __tuple_leaf(const __tuple_leaf& __t) = default;
343371 __tuple_leaf(__tuple_leaf&& __t) = default;
344372
345 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
373 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
346374 int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
347375 {
348376 _VSTD::swap(*this, __t);
349377 return 0;
350378 }
351379
352 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
380 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
353381 int swap(const __tuple_leaf& __t) const _NOEXCEPT_(__is_nothrow_swappable<const __tuple_leaf>::value) {
354382 _VSTD::swap(*this, __t);
355383 return 0;
356384 }
357385
358 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return __value_;}
359 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return __value_;}
386 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 _Hp& get() _NOEXCEPT {return __value_;}
387 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Hp& get() const _NOEXCEPT {return __value_;}
360388};
361389
362390template <size_t _Ip, class _Hp>
363391class __tuple_leaf<_Ip, _Hp, true>
364392 : private _Hp
365393{
366 _LIBCPP_CONSTEXPR_AFTER_CXX11
394 _LIBCPP_CONSTEXPR_SINCE_CXX14
367395 __tuple_leaf& operator=(const __tuple_leaf&);
368396public:
369397 _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf()
......@@ -386,12 +414,12 @@ public:
386414 template <class _Tp,
387415 class = __enable_if_t<
388416 _And<
389 _IsNotSame<__uncvref_t<_Tp>, __tuple_leaf>,
417 _IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>,
390418 is_constructible<_Hp, _Tp>
391419 >::value
392420 >
393421 >
394 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
422 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
395423 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
396424 : _Hp(_VSTD::forward<_Tp>(__t)) {}
397425
......@@ -413,7 +441,7 @@ public:
413441 __tuple_leaf(__tuple_leaf const &) = default;
414442 __tuple_leaf(__tuple_leaf &&) = default;
415443
416 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
444 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
417445 int
418446 swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
419447 {
......@@ -421,18 +449,18 @@ public:
421449 return 0;
422450 }
423451
424 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
452 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
425453 int swap(const __tuple_leaf& __rhs) const _NOEXCEPT_(__is_nothrow_swappable<const __tuple_leaf>::value) {
426454 _VSTD::swap(*this, __rhs);
427455 return 0;
428456 }
429457
430 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);}
431 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}
458 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);}
459 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}
432460};
433461
434462template <class ..._Tp>
435_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
463_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
436464void __swallow(_Tp&&...) _NOEXCEPT {}
437465
438466template <class _Tp>
......@@ -457,7 +485,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
457485
458486 template <size_t ..._Uf, class ..._Tf,
459487 size_t ..._Ul, class ..._Tl, class ..._Up>
460 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
488 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
461489 explicit
462490 __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
463491 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
......@@ -470,7 +498,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
470498
471499 template <class _Alloc, size_t ..._Uf, class ..._Tf,
472500 size_t ..._Ul, class ..._Tl, class ..._Up>
473 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
501 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
474502 explicit
475503 __tuple_impl(allocator_arg_t, const _Alloc& __a,
476504 __tuple_indices<_Uf...>, __tuple_types<_Tf...>,
......@@ -484,7 +512,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
484512 template <class _Tuple,
485513 class = __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value>
486514 >
487 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
515 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
488516 __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
489517 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
490518 : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx,
......@@ -494,7 +522,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
494522 template <class _Alloc, class _Tuple,
495523 class = __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value>
496524 >
497 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
525 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
498526 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
499527 : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
500528 typename __make_tuple_types<_Tuple>::type>::type>(), __a,
......@@ -505,14 +533,14 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
505533 __tuple_impl(const __tuple_impl&) = default;
506534 __tuple_impl(__tuple_impl&&) = default;
507535
508 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
536 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
509537 void swap(__tuple_impl& __t)
510538 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
511539 {
512540 _VSTD::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
513541 }
514542
515 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
543 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
516544 void swap(const __tuple_impl& __t) const
517545 _NOEXCEPT_(__all<__is_nothrow_swappable<const _Tp>::value...>::value)
518546 {
......@@ -521,13 +549,13 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
521549};
522550
523551template<class _Dest, class _Source, size_t ..._Np>
524_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
552_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
525553void __memberwise_copy_assign(_Dest& __dest, _Source const& __source, __tuple_indices<_Np...>) {
526554 _VSTD::__swallow(((_VSTD::get<_Np>(__dest) = _VSTD::get<_Np>(__source)), void(), 0)...);
527555}
528556
529557template<class _Dest, class _Source, class ..._Up, size_t ..._Np>
530_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
558_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
531559void __memberwise_forward_assign(_Dest& __dest, _Source&& __source, __tuple_types<_Up...>, __tuple_indices<_Np...>) {
532560 _VSTD::__swallow(((
533561 _VSTD::get<_Np>(__dest) = _VSTD::forward<_Up>(_VSTD::get<_Np>(__source))
......@@ -541,13 +569,13 @@ class _LIBCPP_TEMPLATE_VIS tuple
541569
542570 _BaseT __base_;
543571
544 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
572 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_SINCE_CXX14
545573 typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
546 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
574 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_SINCE_CXX14
547575 const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
548 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
576 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_SINCE_CXX14
549577 typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
550 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
578 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_SINCE_CXX14
551579 const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT;
552580public:
553581 // [tuple.cnstr]
......@@ -580,7 +608,7 @@ public:
580608 _IsImpDefault<_Tp>... // explicit check
581609 >::value
582610 , int> = 0>
583 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
611 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
584612 tuple(allocator_arg_t, _Alloc const& __a)
585613 : __base_(allocator_arg_t(), __a,
586614 __tuple_indices<>(), __tuple_types<>(),
......@@ -595,7 +623,7 @@ public:
595623 _Not<_Lazy<_And, _IsImpDefault<_Tp>...> > // explicit check
596624 >::value
597625 , int> = 0>
598 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
626 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
599627 explicit tuple(allocator_arg_t, _Alloc const& __a)
600628 : __base_(allocator_arg_t(), __a,
601629 __tuple_indices<>(), __tuple_types<>(),
......@@ -610,7 +638,7 @@ public:
610638 is_convertible<const _Tp&, _Tp>... // explicit check
611639 >::value
612640 , int> = 0>
613 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
641 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
614642 tuple(const _Tp& ... __t)
615643 _NOEXCEPT_(_And<is_nothrow_copy_constructible<_Tp>...>::value)
616644 : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
......@@ -627,7 +655,7 @@ public:
627655 _Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> > // explicit check
628656 >::value
629657 , int> = 0>
630 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
658 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
631659 explicit tuple(const _Tp& ... __t)
632660 _NOEXCEPT_(_And<is_nothrow_copy_constructible<_Tp>...>::value)
633661 : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
......@@ -644,7 +672,7 @@ public:
644672 is_convertible<const _Tp&, _Tp>... // explicit check
645673 >::value
646674 , int> = 0>
647 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
675 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
648676 tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
649677 : __base_(allocator_arg_t(), __a,
650678 typename __make_tuple_indices<sizeof...(_Tp)>::type(),
......@@ -661,7 +689,7 @@ public:
661689 _Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> > // explicit check
662690 >::value
663691 , int> = 0>
664 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
692 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
665693 explicit tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
666694 : __base_(allocator_arg_t(), __a,
667695 typename __make_tuple_indices<sizeof...(_Tp)>::type(),
......@@ -673,7 +701,7 @@ public:
673701
674702 // tuple(U&& ...) constructors (including allocator_arg_t variants)
675703 template <class ..._Up> struct _IsThisTuple : false_type { };
676 template <class _Up> struct _IsThisTuple<_Up> : is_same<__uncvref_t<_Up>, tuple> { };
704 template <class _Up> struct _IsThisTuple<_Up> : is_same<__remove_cvref_t<_Up>, tuple> { };
677705
678706 template <class ..._Up>
679707 struct _EnableUTypesCtor : _And<
......@@ -689,7 +717,7 @@ public:
689717 is_convertible<_Up, _Tp>... // explicit check
690718 >::value
691719 , int> = 0>
692 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
720 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
693721 tuple(_Up&&... __u)
694722 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
695723 : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
......@@ -705,7 +733,7 @@ public:
705733 _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
706734 >::value
707735 , int> = 0>
708 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
736 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
709737 explicit tuple(_Up&&... __u)
710738 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
711739 : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
......@@ -721,7 +749,7 @@ public:
721749 is_convertible<_Up, _Tp>... // explicit check
722750 >::value
723751 , int> = 0>
724 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
752 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
725753 tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
726754 : __base_(allocator_arg_t(), __a,
727755 typename __make_tuple_indices<sizeof...(_Up)>::type(),
......@@ -737,7 +765,7 @@ public:
737765 _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
738766 >::value
739767 , int> = 0>
740 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
768 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
741769 explicit tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
742770 : __base_(allocator_arg_t(), __a,
743771 typename __make_tuple_indices<sizeof...(_Up)>::type(),
......@@ -753,7 +781,7 @@ public:
753781 template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
754782 _And<is_copy_constructible<_Tp>...>::value
755783 , int> = 0>
756 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
784 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
757785 tuple(allocator_arg_t, const _Alloc& __alloc, const tuple& __t)
758786 : __base_(allocator_arg_t(), __alloc, __t)
759787 { }
......@@ -761,14 +789,14 @@ public:
761789 template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
762790 _And<is_move_constructible<_Tp>...>::value
763791 , int> = 0>
764 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
792 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
765793 tuple(allocator_arg_t, const _Alloc& __alloc, tuple&& __t)
766794 : __base_(allocator_arg_t(), __alloc, _VSTD::move(__t))
767795 { }
768796
769797 // tuple(const tuple<U...>&) constructors (including allocator_arg_t variants)
770798
771 template <class _OtherTuple, class _DecayedOtherTuple = __uncvref_t<_OtherTuple>, class = void>
799 template <class _OtherTuple, class _DecayedOtherTuple = __remove_cvref_t<_OtherTuple>, class = void>
772800 struct _EnableCtorFromUTypesTuple : false_type {};
773801
774802 template <class _OtherTuple, class... _Up>
......@@ -797,7 +825,7 @@ public:
797825 is_convertible<const _Up&, _Tp>... // explicit check
798826 >::value
799827 , int> = 0>
800 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
828 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
801829 tuple(const tuple<_Up...>& __t)
802830 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, const _Up&>...>::value))
803831 : __base_(__t)
......@@ -809,7 +837,7 @@ public:
809837 _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check
810838 >::value
811839 , int> = 0>
812 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
840 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
813841 explicit tuple(const tuple<_Up...>& __t)
814842 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, const _Up&>...>::value))
815843 : __base_(__t)
......@@ -821,7 +849,7 @@ public:
821849 is_convertible<const _Up&, _Tp>... // explicit check
822850 >::value
823851 , int> = 0>
824 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
852 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
825853 tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t)
826854 : __base_(allocator_arg_t(), __a, __t)
827855 { }
......@@ -832,7 +860,7 @@ public:
832860 _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check
833861 >::value
834862 , int> = 0>
835 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
863 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
836864 explicit tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t)
837865 : __base_(allocator_arg_t(), __a, __t)
838866 { }
......@@ -861,7 +889,7 @@ public:
861889 is_convertible<_Up, _Tp>... // explicit check
862890 >::value
863891 , int> = 0>
864 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
892 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
865893 tuple(tuple<_Up...>&& __t)
866894 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
867895 : __base_(_VSTD::move(__t))
......@@ -873,7 +901,7 @@ public:
873901 _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
874902 >::value
875903 , int> = 0>
876 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
904 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
877905 explicit tuple(tuple<_Up...>&& __t)
878906 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
879907 : __base_(_VSTD::move(__t))
......@@ -885,7 +913,7 @@ public:
885913 is_convertible<_Up, _Tp>... // explicit check
886914 >::value
887915 , int> = 0>
888 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
916 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
889917 tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t)
890918 : __base_(allocator_arg_t(), __a, _VSTD::move(__t))
891919 { }
......@@ -896,7 +924,7 @@ public:
896924 _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
897925 >::value
898926 , int> = 0>
899 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
927 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
900928 explicit tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t)
901929 : __base_(allocator_arg_t(), __a, _VSTD::move(__t))
902930 { }
......@@ -920,7 +948,7 @@ public:
920948
921949 // tuple(const pair<U1, U2>&) constructors (including allocator_arg_t variants)
922950
923 template <template <class...> class Pred, class _Pair, class _DecayedPair = __uncvref_t<_Pair>, class _Tuple = tuple>
951 template <template <class...> class Pred, class _Pair, class _DecayedPair = __remove_cvref_t<_Pair>, class _Tuple = tuple>
924952 struct _CtorPredicateFromPair : false_type{};
925953
926954 template <template <class...> class Pred, class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
......@@ -935,7 +963,7 @@ public:
935963 template <class _Pair>
936964 struct _NothrowConstructibleFromPair : _CtorPredicateFromPair<is_nothrow_constructible, _Pair>{};
937965
938 template <class _Pair, class _DecayedPair = __uncvref_t<_Pair>, class _Tuple = tuple>
966 template <class _Pair, class _DecayedPair = __remove_cvref_t<_Pair>, class _Tuple = tuple>
939967 struct _BothImplicitlyConvertible : false_type{};
940968
941969 template <class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
......@@ -950,7 +978,7 @@ public:
950978 _BothImplicitlyConvertible<const pair<_Up1, _Up2>&> // explicit check
951979 >::value
952980 , int> = 0>
953 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
981 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
954982 tuple(const pair<_Up1, _Up2>& __p)
955983 _NOEXCEPT_((_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value))
956984 : __base_(__p)
......@@ -962,7 +990,7 @@ public:
962990 _Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> > // explicit check
963991 >::value
964992 , int> = 0>
965 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
993 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
966994 explicit tuple(const pair<_Up1, _Up2>& __p)
967995 _NOEXCEPT_((_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value))
968996 : __base_(__p)
......@@ -974,7 +1002,7 @@ public:
9741002 _BothImplicitlyConvertible<const pair<_Up1, _Up2>&> // explicit check
9751003 >::value
9761004 , int> = 0>
977 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1005 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
9781006 tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p)
9791007 : __base_(allocator_arg_t(), __a, __p)
9801008 { }
......@@ -985,7 +1013,7 @@ public:
9851013 _Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> > // explicit check
9861014 >::value
9871015 , int> = 0>
988 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1016 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
9891017 explicit tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p)
9901018 : __base_(allocator_arg_t(), __a, __p)
9911019 { }
......@@ -1014,7 +1042,7 @@ public:
10141042 _BothImplicitlyConvertible<pair<_Up1, _Up2>&&> // explicit check
10151043 >::value
10161044 , int> = 0>
1017 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1045 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
10181046 tuple(pair<_Up1, _Up2>&& __p)
10191047 _NOEXCEPT_((_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value))
10201048 : __base_(_VSTD::move(__p))
......@@ -1026,7 +1054,7 @@ public:
10261054 _Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> > // explicit check
10271055 >::value
10281056 , int> = 0>
1029 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1057 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
10301058 explicit tuple(pair<_Up1, _Up2>&& __p)
10311059 _NOEXCEPT_((_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value))
10321060 : __base_(_VSTD::move(__p))
......@@ -1038,7 +1066,7 @@ public:
10381066 _BothImplicitlyConvertible<pair<_Up1, _Up2>&&> // explicit check
10391067 >::value
10401068 , int> = 0>
1041 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1069 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
10421070 tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p)
10431071 : __base_(allocator_arg_t(), __a, _VSTD::move(__p))
10441072 { }
......@@ -1049,7 +1077,7 @@ public:
10491077 _Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> > // explicit check
10501078 >::value
10511079 , int> = 0>
1052 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1080 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
10531081 explicit tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p)
10541082 : __base_(allocator_arg_t(), __a, _VSTD::move(__p))
10551083 { }
......@@ -1072,7 +1100,7 @@ public:
10721100#endif // _LIBCPP_STD_VER > 20
10731101
10741102 // [tuple.assign]
1075 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1103 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
10761104 tuple& operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple)
10771105 _NOEXCEPT_((_And<is_nothrow_copy_assignable<_Tp>...>::value))
10781106 {
......@@ -1100,7 +1128,7 @@ public:
11001128 }
11011129#endif // _LIBCPP_STD_VER > 20
11021130
1103 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1131 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
11041132 tuple& operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple)
11051133 _NOEXCEPT_((_And<is_nothrow_move_assignable<_Tp>...>::value))
11061134 {
......@@ -1116,7 +1144,7 @@ public:
11161144 is_assignable<_Tp&, _Up const&>...
11171145 >::value
11181146 ,int> = 0>
1119 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1147 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
11201148 tuple& operator=(tuple<_Up...> const& __tuple)
11211149 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value))
11221150 {
......@@ -1131,7 +1159,7 @@ public:
11311159 is_assignable<_Tp&, _Up>...
11321160 >::value
11331161 ,int> = 0>
1134 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1162 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
11351163 tuple& operator=(tuple<_Up...>&& __tuple)
11361164 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up>...>::value))
11371165 {
......@@ -1168,7 +1196,7 @@ public:
11681196#endif // _LIBCPP_STD_VER > 20
11691197
11701198 template <template<class...> class Pred, bool _Const,
1171 class _Pair, class _DecayedPair = __uncvref_t<_Pair>, class _Tuple = tuple>
1199 class _Pair, class _DecayedPair = __remove_cvref_t<_Pair>, class _Tuple = tuple>
11721200 struct _AssignPredicateFromPair : false_type {};
11731201
11741202 template <template<class...> class Pred, bool _Const,
......@@ -1209,7 +1237,7 @@ public:
12091237 template<class _Up1, class _Up2, __enable_if_t<
12101238 _EnableAssignFromPair<false, pair<_Up1, _Up2> const&>::value
12111239 ,int> = 0>
1212 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1240 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
12131241 tuple& operator=(pair<_Up1, _Up2> const& __pair)
12141242 _NOEXCEPT_((_NothrowAssignFromPair<false, pair<_Up1, _Up2> const&>::value))
12151243 {
......@@ -1221,7 +1249,7 @@ public:
12211249 template<class _Up1, class _Up2, __enable_if_t<
12221250 _EnableAssignFromPair<false, pair<_Up1, _Up2>&&>::value
12231251 ,int> = 0>
1224 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1252 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
12251253 tuple& operator=(pair<_Up1, _Up2>&& __pair)
12261254 _NOEXCEPT_((_NothrowAssignFromPair<false, pair<_Up1, _Up2>&&>::value))
12271255 {
......@@ -1237,7 +1265,7 @@ public:
12371265 is_assignable<_Tp&, _Up const&>...
12381266 >::value
12391267 > >
1240 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1268 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
12411269 tuple& operator=(array<_Up, _Np> const& __array)
12421270 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value))
12431271 {
......@@ -1253,7 +1281,7 @@ public:
12531281 is_assignable<_Tp&, _Up>...
12541282 >::value
12551283 > >
1256 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1284 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
12571285 tuple& operator=(array<_Up, _Np>&& __array)
12581286 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up>...>::value))
12591287 {
......@@ -1264,7 +1292,7 @@ public:
12641292 }
12651293
12661294 // [tuple.swap]
1267 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1295 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
12681296 void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
12691297 {__base_.swap(__t.__base_);}
12701298
......@@ -1283,18 +1311,18 @@ public:
12831311 _LIBCPP_INLINE_VISIBILITY constexpr
12841312 tuple() _NOEXCEPT = default;
12851313 template <class _Alloc>
1286 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1314 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
12871315 tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
12881316 template <class _Alloc>
1289 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1317 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
12901318 tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
12911319 template <class _Up>
1292 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1320 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
12931321 tuple(array<_Up, 0>) _NOEXCEPT {}
12941322 template <class _Alloc, class _Up>
1295 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1323 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
12961324 tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
1297 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1325 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
12981326 void swap(tuple&) _NOEXCEPT {}
12991327#if _LIBCPP_STD_VER > 20
13001328 _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple&) const noexcept {}
......@@ -1329,7 +1357,7 @@ tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>;
13291357#endif
13301358
13311359template <class ..._Tp>
1332inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1360inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
13331361__enable_if_t<__all<__is_swappable<_Tp>::value...>::value, void>
13341362swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
13351363 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
......@@ -1348,7 +1376,7 @@ swap(const tuple<_Tp...>& __lhs, const tuple<_Tp...>& __rhs)
13481376// get
13491377
13501378template <size_t _Ip, class ..._Tp>
1351inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1379inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
13521380typename tuple_element<_Ip, tuple<_Tp...> >::type&
13531381get(tuple<_Tp...>& __t) _NOEXCEPT
13541382{
......@@ -1357,7 +1385,7 @@ get(tuple<_Tp...>& __t) _NOEXCEPT
13571385}
13581386
13591387template <size_t _Ip, class ..._Tp>
1360inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1388inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
13611389const typename tuple_element<_Ip, tuple<_Tp...> >::type&
13621390get(const tuple<_Tp...>& __t) _NOEXCEPT
13631391{
......@@ -1366,7 +1394,7 @@ get(const tuple<_Tp...>& __t) _NOEXCEPT
13661394}
13671395
13681396template <size_t _Ip, class ..._Tp>
1369inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1397inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
13701398typename tuple_element<_Ip, tuple<_Tp...> >::type&&
13711399get(tuple<_Tp...>&& __t) _NOEXCEPT
13721400{
......@@ -1376,7 +1404,7 @@ get(tuple<_Tp...>&& __t) _NOEXCEPT
13761404}
13771405
13781406template <size_t _Ip, class ..._Tp>
1379inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1407inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
13801408const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
13811409get(const tuple<_Tp...>&& __t) _NOEXCEPT
13821410{
......@@ -1402,7 +1430,7 @@ template <size_t _Nx>
14021430inline _LIBCPP_INLINE_VISIBILITY
14031431constexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) {
14041432 return __i == _Nx ? __not_found :
1405 __find_idx_return(__i, __find_idx(__i + 1, __matches), __matches[__i]);
1433 __find_detail::__find_idx_return(__i, __find_detail::__find_idx(__i + 1, __matches), __matches[__i]);
14061434}
14071435
14081436template <class _T1, class ..._Args>
......@@ -1458,7 +1486,7 @@ constexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept
14581486// tie
14591487
14601488template <class ..._Tp>
1461inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1489inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
14621490tuple<_Tp&...>
14631491tie(_Tp&... __t) _NOEXCEPT
14641492{
......@@ -1469,7 +1497,7 @@ template <class _Up>
14691497struct __ignore_t
14701498{
14711499 template <class _Tp>
1472 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1500 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
14731501 const __ignore_t& operator=(_Tp&&) const {return *this;}
14741502};
14751503
......@@ -1478,7 +1506,7 @@ namespace {
14781506} // namespace
14791507
14801508template <class... _Tp>
1481inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1509inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
14821510tuple<typename __unwrap_ref_decay<_Tp>::type...>
14831511make_tuple(_Tp&&... __t)
14841512{
......@@ -1486,7 +1514,7 @@ make_tuple(_Tp&&... __t)
14861514}
14871515
14881516template <class... _Tp>
1489inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1517inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
14901518tuple<_Tp&&...>
14911519forward_as_tuple(_Tp&&... __t) _NOEXCEPT
14921520{
......@@ -1497,7 +1525,7 @@ template <size_t _Ip>
14971525struct __tuple_equal
14981526{
14991527 template <class _Tp, class _Up>
1500 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1528 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
15011529 bool operator()(const _Tp& __x, const _Up& __y)
15021530 {
15031531 return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y);
......@@ -1508,7 +1536,7 @@ template <>
15081536struct __tuple_equal<0>
15091537{
15101538 template <class _Tp, class _Up>
1511 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1539 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
15121540 bool operator()(const _Tp&, const _Up&)
15131541 {
15141542 return true;
......@@ -1516,7 +1544,7 @@ struct __tuple_equal<0>
15161544};
15171545
15181546template <class ..._Tp, class ..._Up>
1519inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1547inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
15201548bool
15211549operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
15221550{
......@@ -1549,7 +1577,7 @@ operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
15491577#else // _LIBCPP_STD_VER > 17
15501578
15511579template <class ..._Tp, class ..._Up>
1552inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1580inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
15531581bool
15541582operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
15551583{
......@@ -1560,7 +1588,7 @@ template <size_t _Ip>
15601588struct __tuple_less
15611589{
15621590 template <class _Tp, class _Up>
1563 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1591 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
15641592 bool operator()(const _Tp& __x, const _Up& __y)
15651593 {
15661594 const size_t __idx = tuple_size<_Tp>::value - _Ip;
......@@ -1576,7 +1604,7 @@ template <>
15761604struct __tuple_less<0>
15771605{
15781606 template <class _Tp, class _Up>
1579 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1607 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
15801608 bool operator()(const _Tp&, const _Up&)
15811609 {
15821610 return false;
......@@ -1584,7 +1612,7 @@ struct __tuple_less<0>
15841612};
15851613
15861614template <class ..._Tp, class ..._Up>
1587inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1615inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
15881616bool
15891617operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
15901618{
......@@ -1593,7 +1621,7 @@ operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
15931621}
15941622
15951623template <class ..._Tp, class ..._Up>
1596inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1624inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
15971625bool
15981626operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
15991627{
......@@ -1601,7 +1629,7 @@ operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
16011629}
16021630
16031631template <class ..._Tp, class ..._Up>
1604inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1632inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
16051633bool
16061634operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
16071635{
......@@ -1609,7 +1637,7 @@ operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
16091637}
16101638
16111639template <class ..._Tp, class ..._Up>
1612inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1640inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
16131641bool
16141642operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
16151643{
......@@ -1638,7 +1666,7 @@ struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
16381666{
16391667 using type _LIBCPP_NODEBUG = typename __tuple_cat_type<
16401668 tuple<_Types...>,
1641 typename __make_tuple_types<__uncvref_t<_Tuple0> >::type
1669 typename __make_tuple_types<__remove_cvref_t<_Tuple0> >::type
16421670 >::type;
16431671};
16441672
......@@ -1647,9 +1675,9 @@ struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...
16471675 : public __tuple_cat_return_1<
16481676 typename __tuple_cat_type<
16491677 tuple<_Types...>,
1650 typename __make_tuple_types<__uncvref_t<_Tuple0> >::type
1678 typename __make_tuple_types<__remove_cvref_t<_Tuple0> >::type
16511679 >::type,
1652 __tuple_like<typename remove_reference<_Tuple1>::type>::value,
1680 __tuple_like_ext<__libcpp_remove_reference_t<_Tuple1> >::value,
16531681 _Tuple1, _Tuples...>
16541682{
16551683};
......@@ -1659,7 +1687,7 @@ template <class ..._Tuples> struct __tuple_cat_return;
16591687template <class _Tuple0, class ..._Tuples>
16601688struct __tuple_cat_return<_Tuple0, _Tuples...>
16611689 : public __tuple_cat_return_1<tuple<>,
1662 __tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
1690 __tuple_like_ext<__libcpp_remove_reference_t<_Tuple0> >::value, _Tuple0,
16631691 _Tuples...>
16641692{
16651693};
......@@ -1670,7 +1698,7 @@ struct __tuple_cat_return<>
16701698 typedef _LIBCPP_NODEBUG tuple<> type;
16711699};
16721700
1673inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1701inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
16741702tuple<>
16751703tuple_cat()
16761704{
......@@ -1683,7 +1711,7 @@ struct __tuple_cat_return_ref_imp;
16831711template <class ..._Types, size_t ..._I0, class _Tuple0>
16841712struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
16851713{
1686 typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0;
1714 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0;
16871715 typedef tuple<_Types..., typename __apply_cv<_Tuple0,
16881716 typename tuple_element<_I0, _T0>::type>::type&&...> type;
16891717};
......@@ -1694,9 +1722,8 @@ struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
16941722 : public __tuple_cat_return_ref_imp<
16951723 tuple<_Types..., typename __apply_cv<_Tuple0,
16961724 typename tuple_element<_I0,
1697 typename remove_reference<_Tuple0>::type>::type>::type&&...>,
1698 typename __make_tuple_indices<tuple_size<typename
1699 remove_reference<_Tuple1>::type>::value>::type,
1725 __libcpp_remove_reference_t<_Tuple0> >::type>::type&&...>,
1726 typename __make_tuple_indices<tuple_size<__libcpp_remove_reference_t<_Tuple1> >::value>::type,
17001727 _Tuple1, _Tuples...>
17011728{
17021729};
......@@ -1705,7 +1732,7 @@ template <class _Tuple0, class ..._Tuples>
17051732struct __tuple_cat_return_ref
17061733 : public __tuple_cat_return_ref_imp<tuple<>,
17071734 typename __make_tuple_indices<
1708 tuple_size<typename remove_reference<_Tuple0>::type>::value
1735 tuple_size<__libcpp_remove_reference_t<_Tuple0> >::value
17091736 >::type, _Tuple0, _Tuples...>
17101737{
17111738};
......@@ -1717,7 +1744,7 @@ template <class ..._Types, size_t ..._I0, size_t ..._J0>
17171744struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
17181745{
17191746 template <class _Tuple0>
1720 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1747 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
17211748 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
17221749 operator()(tuple<_Types...> __t, _Tuple0&& __t0)
17231750 {
......@@ -1728,13 +1755,13 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
17281755 }
17291756
17301757 template <class _Tuple0, class _Tuple1, class ..._Tuples>
1731 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1758 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
17321759 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
17331760 operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
17341761 {
17351762 (void)__t; // avoid unused parameter warning on GCC when _I0 is empty
1736 typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0;
1737 typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple1>::type _T1;
1763 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0;
1764 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple1> _T1;
17381765 return __tuple_cat<
17391766 tuple<_Types...,
17401767 typename __apply_cv<_Tuple0, typename tuple_element<
......@@ -1750,11 +1777,11 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
17501777};
17511778
17521779template <class _Tuple0, class... _Tuples>
1753inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
1780inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
17541781typename __tuple_cat_return<_Tuple0, _Tuples...>::type
17551782tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
17561783{
1757 typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0;
1784 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0;
17581785 return __tuple_cat<tuple<>, __tuple_indices<>,
17591786 typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
17601787 (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
......@@ -1767,7 +1794,7 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc>
17671794
17681795template <class _T1, class _T2>
17691796template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
1770inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
1797inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
17711798pair<_T1, _T2>::pair(piecewise_construct_t,
17721799 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
17731800 __tuple_indices<_I1...>, __tuple_indices<_I2...>)
......@@ -1824,4 +1851,13 @@ _LIBCPP_NOEXCEPT_RETURN(
18241851
18251852_LIBCPP_END_NAMESPACE_STD
18261853
1854#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1855# include <exception>
1856# include <iosfwd>
1857# include <new>
1858# include <type_traits>
1859# include <typeinfo>
1860# include <utility>
1861#endif
1862
18271863#endif // _LIBCPP_TUPLE
lib/libcxx/include/type_traits+13-278
......@@ -158,8 +158,8 @@ namespace std
158158 // Alignment properties and transformations:
159159 template <class T> struct alignment_of;
160160 template <size_t Len, size_t Align = most_stringent_alignment_requirement>
161 struct aligned_storage;
162 template <size_t Len, class... Types> struct aligned_union;
161 struct aligned_storage; // deprecated in C++23
162 template <size_t Len, class... Types> struct aligned_union; // deprecated in C++23
163163 template <class T> struct remove_cvref; // C++20
164164
165165 template <class T> struct decay;
......@@ -419,6 +419,7 @@ namespace std
419419#include <__assert> // all public C++ headers provide the assertion handler
420420#include <__config>
421421#include <__functional/invoke.h>
422#include <__fwd/hash.h> // This is https://llvm.org/PR56938
422423#include <__type_traits/add_const.h>
423424#include <__type_traits/add_cv.h>
424425#include <__type_traits/add_lvalue_reference.h>
......@@ -429,11 +430,13 @@ namespace std
429430#include <__type_traits/aligned_union.h>
430431#include <__type_traits/alignment_of.h>
431432#include <__type_traits/apply_cv.h>
433#include <__type_traits/can_extract_key.h>
432434#include <__type_traits/common_reference.h>
433435#include <__type_traits/common_type.h>
434436#include <__type_traits/conditional.h>
435437#include <__type_traits/conjunction.h>
436438#include <__type_traits/decay.h>
439#include <__type_traits/dependent_type.h>
437440#include <__type_traits/disjunction.h>
438441#include <__type_traits/enable_if.h>
439442#include <__type_traits/extent.h>
......@@ -448,6 +451,7 @@ namespace std
448451#include <__type_traits/is_base_of.h>
449452#include <__type_traits/is_bounded_array.h>
450453#include <__type_traits/is_callable.h>
454#include <__type_traits/is_char_like_type.h>
451455#include <__type_traits/is_class.h>
452456#include <__type_traits/is_compound.h>
453457#include <__type_traits/is_const.h>
......@@ -464,6 +468,7 @@ namespace std
464468#include <__type_traits/is_floating_point.h>
465469#include <__type_traits/is_function.h>
466470#include <__type_traits/is_fundamental.h>
471#include <__type_traits/is_implicitly_default_constructible.h>
467472#include <__type_traits/is_integral.h>
468473#include <__type_traits/is_literal_type.h>
469474#include <__type_traits/is_member_function_pointer.h>
......@@ -492,7 +497,9 @@ namespace std
492497#include <__type_traits/is_scalar.h>
493498#include <__type_traits/is_scoped_enum.h>
494499#include <__type_traits/is_signed.h>
500#include <__type_traits/is_specialization.h>
495501#include <__type_traits/is_standard_layout.h>
502#include <__type_traits/is_swappable.h>
496503#include <__type_traits/is_trivial.h>
497504#include <__type_traits/is_trivially_assignable.h>
498505#include <__type_traits/is_trivially_constructible.h>
......@@ -508,17 +515,21 @@ namespace std
508515#include <__type_traits/is_unsigned.h>
509516#include <__type_traits/is_void.h>
510517#include <__type_traits/is_volatile.h>
518#include <__type_traits/make_const_lvalue_ref.h>
511519#include <__type_traits/make_signed.h>
512520#include <__type_traits/make_unsigned.h>
521#include <__type_traits/maybe_const.h>
513522#include <__type_traits/negation.h>
514523#include <__type_traits/rank.h>
515524#include <__type_traits/remove_all_extents.h>
516525#include <__type_traits/remove_const.h>
526#include <__type_traits/remove_const_ref.h>
517527#include <__type_traits/remove_cv.h>
518528#include <__type_traits/remove_extent.h>
519529#include <__type_traits/remove_pointer.h>
520530#include <__type_traits/remove_reference.h>
521531#include <__type_traits/remove_volatile.h>
532#include <__type_traits/result_of.h>
522533#include <__type_traits/type_identity.h>
523534#include <__type_traits/underlying_type.h>
524535#include <__type_traits/void_t.h>
......@@ -531,280 +542,4 @@ namespace std
531542# pragma GCC system_header
532543#endif
533544
534_LIBCPP_BEGIN_NAMESPACE_STD
535
536template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair;
537template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
538
539// Member detector base
540
541template <class _Tp, bool>
542struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};
543
544// is_integral
545
546template <class _Tp>
547struct __unconstref {
548 typedef _LIBCPP_NODEBUG typename remove_const<typename remove_reference<_Tp>::type>::type type;
549};
550
551#ifndef _LIBCPP_CXX03_LANG
552// First of all, we can't implement this check in C++03 mode because the {}
553// default initialization syntax isn't valid.
554// Second, we implement the trait in a funny manner with two defaulted template
555// arguments to workaround Clang's PR43454.
556template <class _Tp>
557void __test_implicit_default_constructible(_Tp);
558
559template <class _Tp, class = void, class = typename is_default_constructible<_Tp>::type>
560struct __is_implicitly_default_constructible
561 : false_type
562{ };
563
564template <class _Tp>
565struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), true_type>
566 : true_type
567{ };
568
569template <class _Tp>
570struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), false_type>
571 : false_type
572{ };
573#endif // !C++03
574
575// result_of
576
577#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
578template <class _Callable> class _LIBCPP_DEPRECATED_IN_CXX17 result_of;
579
580template <class _Fp, class ..._Args>
581class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)>
582 : public __invoke_of<_Fp, _Args...>
583{
584};
585
586#if _LIBCPP_STD_VER > 11
587template <class _Tp> using result_of_t _LIBCPP_DEPRECATED_IN_CXX17 = typename result_of<_Tp>::type;
588#endif // _LIBCPP_STD_VER > 11
589#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
590
591// __swappable
592
593template <class _Tp> struct __is_swappable;
594template <class _Tp> struct __is_nothrow_swappable;
595
596
597#ifndef _LIBCPP_CXX03_LANG
598template <class _Tp>
599using __swap_result_t = typename enable_if<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>::type;
600#else
601template <class>
602using __swap_result_t = void;
603#endif
604
605template <class _Tp>
606inline _LIBCPP_INLINE_VISIBILITY
607_LIBCPP_CONSTEXPR_AFTER_CXX17 __swap_result_t<_Tp>
608swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
609 is_nothrow_move_assignable<_Tp>::value);
610
611template<class _Tp, size_t _Np>
612inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
613typename enable_if<
614 __is_swappable<_Tp>::value
615>::type
616swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
617
618namespace __detail
619{
620// ALL generic swap overloads MUST already have a declaration available at this point.
621
622template <class _Tp, class _Up = _Tp,
623 bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
624struct __swappable_with
625{
626 template <class _LHS, class _RHS>
627 static decltype(swap(declval<_LHS>(), declval<_RHS>()))
628 __test_swap(int);
629 template <class, class>
630 static __nat __test_swap(long);
631
632 // Extra parens are needed for the C++03 definition of decltype.
633 typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
634 typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
635
636 static const bool value = _IsNotSame<__swap1, __nat>::value
637 && _IsNotSame<__swap2, __nat>::value;
638};
639
640template <class _Tp, class _Up>
641struct __swappable_with<_Tp, _Up, false> : false_type {};
642
643template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
644struct __nothrow_swappable_with {
645 static const bool value =
646#ifndef _LIBCPP_HAS_NO_NOEXCEPT
647 noexcept(swap(declval<_Tp>(), declval<_Up>()))
648 && noexcept(swap(declval<_Up>(), declval<_Tp>()));
649#else
650 false;
651#endif
652};
653
654template <class _Tp, class _Up>
655struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
656
657} // namespace __detail
658
659template <class _Tp>
660struct __is_swappable
661 : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
662{
663};
664
665template <class _Tp>
666struct __is_nothrow_swappable
667 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
668{
669};
670
671#if _LIBCPP_STD_VER > 14
672
673template <class _Tp, class _Up>
674struct _LIBCPP_TEMPLATE_VIS is_swappable_with
675 : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value>
676{
677};
678
679template <class _Tp>
680struct _LIBCPP_TEMPLATE_VIS is_swappable
681 : public conditional<
682 __is_referenceable<_Tp>::value,
683 is_swappable_with<
684 typename add_lvalue_reference<_Tp>::type,
685 typename add_lvalue_reference<_Tp>::type>,
686 false_type
687 >::type
688{
689};
690
691template <class _Tp, class _Up>
692struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with
693 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value>
694{
695};
696
697template <class _Tp>
698struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable
699 : public conditional<
700 __is_referenceable<_Tp>::value,
701 is_nothrow_swappable_with<
702 typename add_lvalue_reference<_Tp>::type,
703 typename add_lvalue_reference<_Tp>::type>,
704 false_type
705 >::type
706{
707};
708
709template <class _Tp, class _Up>
710inline constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value;
711
712template <class _Tp>
713inline constexpr bool is_swappable_v = is_swappable<_Tp>::value;
714
715template <class _Tp, class _Up>
716inline constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<_Tp, _Up>::value;
717
718template <class _Tp>
719inline constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value;
720
721#endif // _LIBCPP_STD_VER > 14
722
723template <class _Tp, bool = is_enum<_Tp>::value>
724struct __sfinae_underlying_type
725{
726 typedef typename underlying_type<_Tp>::type type;
727 typedef decltype(((type)1) + 0) __promoted_type;
728};
729
730template <class _Tp>
731struct __sfinae_underlying_type<_Tp, false> {};
732
733inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
734int __convert_to_integral(int __val) { return __val; }
735
736inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
737unsigned __convert_to_integral(unsigned __val) { return __val; }
738
739inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
740long __convert_to_integral(long __val) { return __val; }
741
742inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
743unsigned long __convert_to_integral(unsigned long __val) { return __val; }
744
745inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
746long long __convert_to_integral(long long __val) { return __val; }
747
748inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
749unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
750
751template<typename _Fp>
752inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
753typename enable_if<is_floating_point<_Fp>::value, long long>::type
754 __convert_to_integral(_Fp __val) { return __val; }
755
756#ifndef _LIBCPP_HAS_NO_INT128
757inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
758__int128_t __convert_to_integral(__int128_t __val) { return __val; }
759
760inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
761__uint128_t __convert_to_integral(__uint128_t __val) { return __val; }
762#endif
763
764template <class _Tp>
765inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
766typename __sfinae_underlying_type<_Tp>::__promoted_type
767__convert_to_integral(_Tp __val) { return __val; }
768
769// These traits are used in __tree and __hash_table
770struct __extract_key_fail_tag {};
771struct __extract_key_self_tag {};
772struct __extract_key_first_tag {};
773
774template <class _ValTy, class _Key,
775 class _RawValTy = typename __unconstref<_ValTy>::type>
776struct __can_extract_key
777 : conditional<_IsSame<_RawValTy, _Key>::value, __extract_key_self_tag,
778 __extract_key_fail_tag>::type {};
779
780template <class _Pair, class _Key, class _First, class _Second>
781struct __can_extract_key<_Pair, _Key, pair<_First, _Second> >
782 : conditional<_IsSame<typename remove_const<_First>::type, _Key>::value,
783 __extract_key_first_tag, __extract_key_fail_tag>::type {};
784
785// __can_extract_map_key uses true_type/false_type instead of the tags.
786// It returns true if _Key != _ContainerValueTy (the container is a map not a set)
787// and _ValTy == _Key.
788template <class _ValTy, class _Key, class _ContainerValueTy,
789 class _RawValTy = typename __unconstref<_ValTy>::type>
790struct __can_extract_map_key
791 : integral_constant<bool, _IsSame<_RawValTy, _Key>::value> {};
792
793// This specialization returns __extract_key_fail_tag for non-map containers
794// because _Key == _ContainerValueTy
795template <class _ValTy, class _Key, class _RawValTy>
796struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
797 : false_type {};
798
799template <class _CharT>
800using _IsCharLikeType = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >;
801
802template<class _Tp>
803using __make_const_lvalue_ref = const typename remove_reference<_Tp>::type&;
804
805template<bool _Const, class _Tp>
806using __maybe_const = typename conditional<_Const, const _Tp, _Tp>::type;
807
808_LIBCPP_END_NAMESPACE_STD
809
810545#endif // _LIBCPP_TYPE_TRAITS
lib/libcxx/include/typeindex+20-7
......@@ -23,11 +23,12 @@ public:
2323 type_index(const type_info& rhs) noexcept;
2424
2525 bool operator==(const type_index& rhs) const noexcept;
26 bool operator!=(const type_index& rhs) const noexcept;
26 bool operator!=(const type_index& rhs) const noexcept; // removed in C++20
2727 bool operator< (const type_index& rhs) const noexcept;
2828 bool operator<=(const type_index& rhs) const noexcept;
2929 bool operator> (const type_index& rhs) const noexcept;
3030 bool operator>=(const type_index& rhs) const noexcept;
31 strong_ordering operator<=>(const type_index& rhs) const noexcept; // C++20
3132
3233 size_t hash_code() const noexcept;
3334 const char* name() const noexcept;
......@@ -50,12 +51,6 @@ struct hash<type_index>
5051#include <typeinfo>
5152#include <version>
5253
53#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
54# include <iosfwd>
55# include <new>
56# include <utility>
57#endif
58
5954// standard-mandated includes
6055#include <compare>
6156
......@@ -76,8 +71,10 @@ public:
7671 bool operator==(const type_index& __y) const _NOEXCEPT
7772 {return *__t_ == *__y.__t_;}
7873 _LIBCPP_INLINE_VISIBILITY
74#if _LIBCPP_STD_VER <= 17
7975 bool operator!=(const type_index& __y) const _NOEXCEPT
8076 {return *__t_ != *__y.__t_;}
77#endif
8178 _LIBCPP_INLINE_VISIBILITY
8279 bool operator< (const type_index& __y) const _NOEXCEPT
8380 {return __t_->before(*__y.__t_);}
......@@ -90,6 +87,16 @@ public:
9087 _LIBCPP_INLINE_VISIBILITY
9188 bool operator>=(const type_index& __y) const _NOEXCEPT
9289 {return !__t_->before(*__y.__t_);}
90#if _LIBCPP_STD_VER > 17
91 _LIBCPP_HIDE_FROM_ABI
92 strong_ordering operator<=>(const type_index& __y) const noexcept {
93 if (*__t_ == *__y.__t_)
94 return strong_ordering::equal;
95 if (__t_->before(*__y.__t_))
96 return strong_ordering::less;
97 return strong_ordering::greater;
98 }
99#endif
93100
94101 _LIBCPP_INLINE_VISIBILITY
95102 size_t hash_code() const _NOEXCEPT {return __t_->hash_code();}
......@@ -110,4 +117,10 @@ struct _LIBCPP_TEMPLATE_VIS hash<type_index>
110117
111118_LIBCPP_END_NAMESPACE_STD
112119
120#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
121# include <iosfwd>
122# include <new>
123# include <utility>
124#endif
125
113126#endif // _LIBCPP_TYPEINDEX
lib/libcxx/include/typeinfo+36-11
......@@ -22,7 +22,7 @@ public:
2222 virtual ~type_info();
2323
2424 bool operator==(const type_info& rhs) const noexcept;
25 bool operator!=(const type_info& rhs) const noexcept;
25 bool operator!=(const type_info& rhs) const noexcept; // removed in C++20
2626
2727 bool before(const type_info& rhs) const noexcept;
2828 size_t hash_code() const noexcept;
......@@ -61,13 +61,10 @@ public:
6161#include <__config>
6262#include <cstddef>
6363#include <cstdint>
64#include <cstdlib>
6465#include <exception>
6566#include <type_traits>
6667
67#ifdef _LIBCPP_NO_EXCEPTIONS
68#include <cstdlib>
69#endif
70
7168#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
7269# pragma GCC system_header
7370#endif
......@@ -112,9 +109,11 @@ public:
112109 return __compare(__arg) == 0;
113110 }
114111
112#if _LIBCPP_STD_VER <= 17
115113 _LIBCPP_INLINE_VISIBILITY
116114 bool operator!=(const type_info& __arg) const _NOEXCEPT
117115 { return !operator==(__arg); }
116#endif
118117};
119118
120119#else // !defined(_LIBCPP_ABI_MICROSOFT)
......@@ -174,8 +173,8 @@ public:
174173// we pick a default implementation based on the platform here.
175174#ifndef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION
176175
177 // Windows binaries can't merge typeinfos, so use the NonUnique implementation.
178# ifdef _LIBCPP_OBJECT_FORMAT_COFF
176 // Windows and AIX binaries can't merge typeinfos, so use the NonUnique implementation.
177# if defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)
179178# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 2
180179
181180 // On arm64 on Apple platforms, use the special NonUniqueARMRTTIBit implementation.
......@@ -337,9 +336,11 @@ public:
337336 return __impl::__eq(__type_name, __arg.__type_name);
338337 }
339338
339#if _LIBCPP_STD_VER <= 17
340340 _LIBCPP_INLINE_VISIBILITY
341341 bool operator!=(const type_info& __arg) const _NOEXCEPT
342342 { return !operator==(__arg); }
343#endif
343344};
344345#endif // defined(_LIBCPP_ABI_MICROSOFT)
345346
......@@ -349,8 +350,8 @@ class _LIBCPP_EXCEPTION_ABI bad_cast
349350 public:
350351 bad_cast() _NOEXCEPT;
351352 bad_cast(const bad_cast&) _NOEXCEPT = default;
352 virtual ~bad_cast() _NOEXCEPT;
353 virtual const char* what() const _NOEXCEPT;
353 ~bad_cast() _NOEXCEPT override;
354 const char* what() const _NOEXCEPT override;
354355};
355356
356357class _LIBCPP_EXCEPTION_ABI bad_typeid
......@@ -358,14 +359,38 @@ class _LIBCPP_EXCEPTION_ABI bad_typeid
358359{
359360 public:
360361 bad_typeid() _NOEXCEPT;
361 virtual ~bad_typeid() _NOEXCEPT;
362 virtual const char* what() const _NOEXCEPT;
362 ~bad_typeid() _NOEXCEPT override;
363 const char* what() const _NOEXCEPT override;
363364};
364365
365366} // namespace std
366367
367368#endif // defined(_LIBCPP_ABI_VCRUNTIME)
368369
370#if defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0
371
372namespace std {
373
374class bad_cast : public exception {
375public:
376 bad_cast() _NOEXCEPT : exception("bad cast") {}
377
378private:
379 bad_cast(const char* const __message) _NOEXCEPT : exception(__message) {}
380};
381
382class bad_typeid : public exception {
383public:
384 bad_typeid() _NOEXCEPT : exception("bad typeid") {}
385
386private:
387 bad_typeid(const char* const __message) _NOEXCEPT : exception(__message) {}
388};
389
390} // namespace std
391
392#endif // defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0
393
369394_LIBCPP_BEGIN_NAMESPACE_STD
370395_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
371396void __throw_bad_cast()
lib/libcxx/include/uchar.h+2
......@@ -23,6 +23,8 @@ Types:
2323 mbstate_t
2424 size_t
2525
26size_t mbrtoc8(char8_t* pc8, const char* s, size_t n, mbstate_t* ps); // since C++20
27size_t c8rtomb(char* s, char8_t c8, mbstate_t* ps); // since C++20
2628size_t mbrtoc16(char16_t* pc16, const char* s, size_t n, mbstate_t* ps);
2729size_t c16rtomb(char* s, char16_t c16, mbstate_t* ps);
2830size_t mbrtoc32(char32_t* pc32, const char* s, size_t n, mbstate_t* ps);
lib/libcxx/include/unordered_map+48-23
......@@ -525,18 +525,15 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
525525#include <__iterator/erase_if_container.h>
526526#include <__iterator/iterator_traits.h>
527527#include <__memory/addressof.h>
528#include <__memory/allocator.h>
529#include <__memory_resource/polymorphic_allocator.h>
528530#include <__node_handle>
531#include <__type_traits/is_allocator.h>
529532#include <__utility/forward.h>
530533#include <stdexcept>
531534#include <tuple>
532535#include <version>
533536
534#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
535# include <algorithm>
536# include <bit>
537# include <iterator>
538#endif
539
540537// standard-mandated includes
541538
542539// [iterator.range]
......@@ -822,16 +819,16 @@ struct _LIBCPP_STANDALONE_DEBUG __hash_value_type
822819 typedef pair<key_type&&, mapped_type&&> __nc_rref_pair_type;
823820
824821private:
825 value_type __cc;
822 value_type __cc_;
826823
827824public:
828825 _LIBCPP_INLINE_VISIBILITY
829826 value_type& __get_value()
830827 {
831828#if _LIBCPP_STD_VER > 14
832 return *_VSTD::launder(_VSTD::addressof(__cc));
829 return *_VSTD::launder(_VSTD::addressof(__cc_));
833830#else
834 return __cc;
831 return __cc_;
835832#endif
836833 }
837834
......@@ -839,9 +836,9 @@ public:
839836 const value_type& __get_value() const
840837 {
841838#if _LIBCPP_STD_VER > 14
842 return *_VSTD::launder(_VSTD::addressof(__cc));
839 return *_VSTD::launder(_VSTD::addressof(__cc_));
843840#else
844 return __cc;
841 return __cc_;
845842#endif
846843 }
847844
......@@ -904,13 +901,13 @@ struct __hash_value_type
904901 typedef pair<const key_type, mapped_type> value_type;
905902
906903private:
907 value_type __cc;
904 value_type __cc_;
908905
909906public:
910907 _LIBCPP_INLINE_VISIBILITY
911 value_type& __get_value() { return __cc; }
908 value_type& __get_value() { return __cc_; }
912909 _LIBCPP_INLINE_VISIBILITY
913 const value_type& __get_value() const { return __cc; }
910 const value_type& __get_value() const { return __cc_; }
914911
915912private:
916913 ~__hash_value_type();
......@@ -1044,8 +1041,7 @@ private:
10441041 typedef __hash_value_type<key_type, mapped_type> __value_type;
10451042 typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;
10461043 typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal;
1047 typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
1048 __value_type>::type __allocator_type;
1044 typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type;
10491045
10501046 typedef __hash_table<__value_type, __hasher,
10511047 __key_equal, __allocator_type> __table;
......@@ -1062,6 +1058,10 @@ private:
10621058 typedef unique_ptr<__node, _Dp> __node_holder;
10631059 typedef allocator_traits<allocator_type> __alloc_traits;
10641060
1061 static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
1062 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
1063 "original allocator");
1064
10651065 static_assert((is_same<typename __table::__container_value_type, value_type>::value), "");
10661066 static_assert((is_same<typename __table::__node_value_type, __value_type>::value), "");
10671067public:
......@@ -1149,7 +1149,7 @@ public:
11491149#endif
11501150 _LIBCPP_INLINE_VISIBILITY
11511151 ~unordered_map() {
1152 static_assert(sizeof(__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
1152 static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
11531153 }
11541154
11551155 _LIBCPP_INLINE_VISIBILITY
......@@ -1886,7 +1886,7 @@ inline _LIBCPP_INLINE_VISIBILITY
18861886#endif
18871887
18881888template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1889bool
1889_LIBCPP_HIDE_FROM_ABI bool
18901890operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
18911891 const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
18921892{
......@@ -1934,8 +1934,7 @@ private:
19341934 typedef __hash_value_type<key_type, mapped_type> __value_type;
19351935 typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;
19361936 typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal;
1937 typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
1938 __value_type>::type __allocator_type;
1937 typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type;
19391938
19401939 typedef __hash_table<__value_type, __hasher,
19411940 __key_equal, __allocator_type> __table;
......@@ -1952,7 +1951,12 @@ private:
19521951 static_assert((is_same<typename __node_traits::size_type,
19531952 typename __alloc_traits::size_type>::value),
19541953 "Allocator uses different size_type for different types");
1955public:
1954
1955 static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
1956 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
1957 "original allocator");
1958
1959 public:
19561960 typedef typename __alloc_traits::pointer pointer;
19571961 typedef typename __alloc_traits::const_pointer const_pointer;
19581962 typedef typename __table::size_type size_type;
......@@ -2037,7 +2041,7 @@ public:
20372041#endif
20382042 _LIBCPP_INLINE_VISIBILITY
20392043 ~unordered_multimap() {
2040 static_assert(sizeof(__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
2044 static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
20412045 }
20422046
20432047 _LIBCPP_INLINE_VISIBILITY
......@@ -2592,7 +2596,7 @@ inline _LIBCPP_INLINE_VISIBILITY
25922596#endif
25932597
25942598template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2595bool
2599_LIBCPP_HIDE_FROM_ABI bool
25962600operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
25972601 const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
25982602{
......@@ -2625,4 +2629,25 @@ operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
26252629
26262630_LIBCPP_END_NAMESPACE_STD
26272631
2632#if _LIBCPP_STD_VER > 14
2633_LIBCPP_BEGIN_NAMESPACE_STD
2634namespace pmr {
2635template <class _KeyT, class _ValueT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>>
2636using unordered_map =
2637 std::unordered_map<_KeyT, _ValueT, _HashT, _PredT, polymorphic_allocator<std::pair<const _KeyT, _ValueT>>>;
2638
2639template <class _KeyT, class _ValueT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>>
2640using unordered_multimap =
2641 std::unordered_multimap<_KeyT, _ValueT, _HashT, _PredT, polymorphic_allocator<std::pair<const _KeyT, _ValueT>>>;
2642} // namespace pmr
2643_LIBCPP_END_NAMESPACE_STD
2644#endif
2645
2646#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
2647# include <algorithm>
2648# include <bit>
2649# include <concepts>
2650# include <iterator>
2651#endif
2652
26282653#endif // _LIBCPP_UNORDERED_MAP
lib/libcxx/include/unordered_set+30-10
......@@ -470,15 +470,13 @@ template <class Value, class Hash, class Pred, class Alloc>
470470#include <__iterator/erase_if_container.h>
471471#include <__iterator/iterator_traits.h>
472472#include <__memory/addressof.h>
473#include <__memory/allocator.h>
474#include <__memory_resource/polymorphic_allocator.h>
473475#include <__node_handle>
476#include <__type_traits/is_allocator.h>
474477#include <__utility/forward.h>
475478#include <version>
476479
477#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
478# include <functional>
479# include <iterator>
480#endif
481
482480// standard-mandated includes
483481
484482// [iterator.range]
......@@ -517,7 +515,11 @@ public:
517515 static_assert((is_same<value_type, typename allocator_type::value_type>::value),
518516 "Invalid allocator::value_type");
519517
520private:
518 static_assert(is_same<allocator_type, __rebind_alloc<allocator_traits<allocator_type>, value_type> >::value,
519 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
520 "original allocator");
521
522 private:
521523 typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
522524
523525 __table __table_;
......@@ -611,7 +613,7 @@ public:
611613#endif // _LIBCPP_CXX03_LANG
612614 _LIBCPP_INLINE_VISIBILITY
613615 ~unordered_set() {
614 static_assert(sizeof(__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
616 static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
615617 }
616618
617619 _LIBCPP_INLINE_VISIBILITY
......@@ -1130,7 +1132,7 @@ inline _LIBCPP_INLINE_VISIBILITY
11301132#endif
11311133
11321134template <class _Value, class _Hash, class _Pred, class _Alloc>
1133bool
1135_LIBCPP_HIDE_FROM_ABI bool
11341136operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
11351137 const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
11361138{
......@@ -1265,7 +1267,7 @@ public:
12651267#endif // _LIBCPP_CXX03_LANG
12661268 _LIBCPP_INLINE_VISIBILITY
12671269 ~unordered_multiset() {
1268 static_assert(sizeof(__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
1270 static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
12691271 }
12701272
12711273 _LIBCPP_INLINE_VISIBILITY
......@@ -1768,7 +1770,7 @@ inline _LIBCPP_INLINE_VISIBILITY
17681770#endif
17691771
17701772template <class _Value, class _Hash, class _Pred, class _Alloc>
1771bool
1773_LIBCPP_HIDE_FROM_ABI bool
17721774operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
17731775 const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
17741776{
......@@ -1801,4 +1803,22 @@ operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
18011803
18021804_LIBCPP_END_NAMESPACE_STD
18031805
1806#if _LIBCPP_STD_VER > 14
1807_LIBCPP_BEGIN_NAMESPACE_STD
1808namespace pmr {
1809template <class _KeyT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>>
1810using unordered_set = std::unordered_set<_KeyT, _HashT, _PredT, polymorphic_allocator<_KeyT>>;
1811
1812template <class _KeyT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>>
1813using unordered_multiset = std::unordered_multiset<_KeyT, _HashT, _PredT, polymorphic_allocator<_KeyT>>;
1814} // namespace pmr
1815_LIBCPP_END_NAMESPACE_STD
1816#endif
1817
1818#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1819# include <concepts>
1820# include <functional>
1821# include <iterator>
1822#endif
1823
18041824#endif // _LIBCPP_UNORDERED_SET
lib/libcxx/include/utility+31-7
......@@ -42,6 +42,10 @@ swap(T (&a)[N], T (&b)[N]) noexcept(noexcept(swap(*a, *b)));
4242template <class T> T&& forward(typename remove_reference<T>::type& t) noexcept; // constexpr in C++14
4343template <class T> T&& forward(typename remove_reference<T>::type&& t) noexcept; // constexpr in C++14
4444
45template <typename T>
46[[nodiscard]] constexpr
47auto forward_like(auto&& x) noexcept -> see below; // since C++23
48
4549template <class T> typename remove_reference<T>::type&& move(T&&) noexcept; // constexpr in C++14
4650
4751template <class T>
......@@ -80,19 +84,29 @@ struct pair
8084 explicit(see-below) constexpr pair();
8185 explicit(see-below) pair(const T1& x, const T2& y); // constexpr in C++14
8286 template <class U = T1, class V = T2> explicit(see-below) pair(U&&, V&&); // constexpr in C++14
87 template <class U, class V> constexpr explicit(see below) pair(pair<U, V>&); // since C++23
8388 template <class U, class V> explicit(see-below) pair(const pair<U, V>& p); // constexpr in C++14
8489 template <class U, class V> explicit(see-below) pair(pair<U, V>&& p); // constexpr in C++14
90 template <class U, class V>
91 constexpr explicit(see below) pair(const pair<U, V>&&); // since C++23
8592 template <class... Args1, class... Args2>
8693 pair(piecewise_construct_t, tuple<Args1...> first_args,
8794 tuple<Args2...> second_args); // constexpr in C++20
8895
96 constexpr const pair& operator=(const pair& p) const; // since C++23
8997 template <class U, class V> pair& operator=(const pair<U, V>& p); // constexpr in C++20
98 template <class U, class V>
99 constexpr const pair& operator=(const pair<U, V>& p) const; // since C++23
90100 pair& operator=(pair&& p) noexcept(is_nothrow_move_assignable<T1>::value &&
91101 is_nothrow_move_assignable<T2>::value); // constexpr in C++20
102 constexpr const pair& operator=(pair&& p) const; // since C++23
92103 template <class U, class V> pair& operator=(pair<U, V>&& p); // constexpr in C++20
104 template <class U, class V>
105 constexpr const pair& operator=(pair<U, V>&& p) const; // since C++23
93106
94107 void swap(pair& p) noexcept(is_nothrow_swappable_v<T1> &&
95108 is_nothrow_swappable_v<T2>); // constexpr in C++20
109 constexpr void swap(const pair& p) const noexcept(see below); // since C++23
96110};
97111
98112template<class T1, class T2, class U1, class U2, template<class> class TQual, template<class> class UQual>
......@@ -119,6 +133,9 @@ template <class T1, class T2>
119133void
120134swap(pair<T1, T2>& x, pair<T1, T2>& y) noexcept(noexcept(x.swap(y))); // constexpr in C++20
121135
136template<class T1, class T2>
137constexpr void swap(const pair<T1, T2>& x, const pair<T1, T2>& y) noexcept(noexcept(x.swap(y))); // since C++23
138
122139struct piecewise_construct_t { explicit piecewise_construct_t() = default; };
123140inline constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
124141
......@@ -222,13 +239,14 @@ template <class T>
222239
223240#include <__assert> // all public C++ headers provide the assertion handler
224241#include <__config>
225#include <__tuple>
226242#include <__utility/as_const.h>
227243#include <__utility/auto_cast.h>
228244#include <__utility/cmp.h>
229245#include <__utility/declval.h>
246#include <__utility/exception_guard.h>
230247#include <__utility/exchange.h>
231248#include <__utility/forward.h>
249#include <__utility/forward_like.h>
232250#include <__utility/in_place.h>
233251#include <__utility/integer_sequence.h>
234252#include <__utility/move.h>
......@@ -238,21 +256,27 @@ template <class T>
238256#include <__utility/rel_ops.h>
239257#include <__utility/swap.h>
240258#include <__utility/to_underlying.h>
241#include <__utility/transaction.h>
242259#include <__utility/unreachable.h>
243#include <type_traits>
244260#include <version>
245261
246#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
247# include <iosfwd>
248#endif
249
250262// standard-mandated includes
263
264// [utility.syn]
251265#include <compare>
252266#include <initializer_list>
253267
268// [tuple.helper]
269#include <__tuple_dir/tuple_element.h>
270#include <__tuple_dir/tuple_size.h>
271
254272#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
255273# pragma GCC system_header
256274#endif
257275
276#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
277# include <cstdlib>
278# include <iosfwd>
279# include <type_traits>
280#endif
281
258282#endif // _LIBCPP_UTILITY
lib/libcxx/include/valarray+32-27
......@@ -353,6 +353,7 @@ template <class T> unspecified2 end(const valarray<T>& v);
353353#include <__functional/operations.h>
354354#include <__memory/allocator.h>
355355#include <__memory/uninitialized_algorithms.h>
356#include <__type_traits/remove_reference.h>
356357#include <__utility/move.h>
357358#include <__utility/swap.h>
358359#include <cmath>
......@@ -360,12 +361,9 @@ template <class T> unspecified2 end(const valarray<T>& v);
360361#include <new>
361362#include <version>
362363
363#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
364# include <algorithm>
365# include <functional>
366#endif
367
368364// standard-mandated includes
365
366// [valarray.syn]
369367#include <initializer_list>
370368
371369#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -548,7 +546,7 @@ struct __abs_expr
548546 typedef _Tp __result_type;
549547 _LIBCPP_INLINE_VISIBILITY
550548 _Tp operator()(const _Tp& __x) const
551 {return abs(__x);}
549 {return std::abs(__x);}
552550};
553551
554552template <class _Tp>
......@@ -557,7 +555,7 @@ struct __acos_expr
557555 typedef _Tp __result_type;
558556 _LIBCPP_INLINE_VISIBILITY
559557 _Tp operator()(const _Tp& __x) const
560 {return acos(__x);}
558 {return std::acos(__x);}
561559};
562560
563561template <class _Tp>
......@@ -566,7 +564,7 @@ struct __asin_expr
566564 typedef _Tp __result_type;
567565 _LIBCPP_INLINE_VISIBILITY
568566 _Tp operator()(const _Tp& __x) const
569 {return asin(__x);}
567 {return std::asin(__x);}
570568};
571569
572570template <class _Tp>
......@@ -575,7 +573,7 @@ struct __atan_expr
575573 typedef _Tp __result_type;
576574 _LIBCPP_INLINE_VISIBILITY
577575 _Tp operator()(const _Tp& __x) const
578 {return atan(__x);}
576 {return std::atan(__x);}
579577};
580578
581579template <class _Tp>
......@@ -584,7 +582,7 @@ struct __atan2_expr
584582 typedef _Tp __result_type;
585583 _LIBCPP_INLINE_VISIBILITY
586584 _Tp operator()(const _Tp& __x, const _Tp& __y) const
587 {return atan2(__x, __y);}
585 {return std::atan2(__x, __y);}
588586};
589587
590588template <class _Tp>
......@@ -593,7 +591,7 @@ struct __cos_expr
593591 typedef _Tp __result_type;
594592 _LIBCPP_INLINE_VISIBILITY
595593 _Tp operator()(const _Tp& __x) const
596 {return cos(__x);}
594 {return std::cos(__x);}
597595};
598596
599597template <class _Tp>
......@@ -602,7 +600,7 @@ struct __cosh_expr
602600 typedef _Tp __result_type;
603601 _LIBCPP_INLINE_VISIBILITY
604602 _Tp operator()(const _Tp& __x) const
605 {return cosh(__x);}
603 {return std::cosh(__x);}
606604};
607605
608606template <class _Tp>
......@@ -611,7 +609,7 @@ struct __exp_expr
611609 typedef _Tp __result_type;
612610 _LIBCPP_INLINE_VISIBILITY
613611 _Tp operator()(const _Tp& __x) const
614 {return exp(__x);}
612 {return std::exp(__x);}
615613};
616614
617615template <class _Tp>
......@@ -620,7 +618,7 @@ struct __log_expr
620618 typedef _Tp __result_type;
621619 _LIBCPP_INLINE_VISIBILITY
622620 _Tp operator()(const _Tp& __x) const
623 {return log(__x);}
621 {return std::log(__x);}
624622};
625623
626624template <class _Tp>
......@@ -629,7 +627,7 @@ struct __log10_expr
629627 typedef _Tp __result_type;
630628 _LIBCPP_INLINE_VISIBILITY
631629 _Tp operator()(const _Tp& __x) const
632 {return log10(__x);}
630 {return std::log10(__x);}
633631};
634632
635633template <class _Tp>
......@@ -638,7 +636,7 @@ struct __pow_expr
638636 typedef _Tp __result_type;
639637 _LIBCPP_INLINE_VISIBILITY
640638 _Tp operator()(const _Tp& __x, const _Tp& __y) const
641 {return pow(__x, __y);}
639 {return std::pow(__x, __y);}
642640};
643641
644642template <class _Tp>
......@@ -647,7 +645,7 @@ struct __sin_expr
647645 typedef _Tp __result_type;
648646 _LIBCPP_INLINE_VISIBILITY
649647 _Tp operator()(const _Tp& __x) const
650 {return sin(__x);}
648 {return std::sin(__x);}
651649};
652650
653651template <class _Tp>
......@@ -656,7 +654,7 @@ struct __sinh_expr
656654 typedef _Tp __result_type;
657655 _LIBCPP_INLINE_VISIBILITY
658656 _Tp operator()(const _Tp& __x) const
659 {return sinh(__x);}
657 {return std::sinh(__x);}
660658};
661659
662660template <class _Tp>
......@@ -665,7 +663,7 @@ struct __sqrt_expr
665663 typedef _Tp __result_type;
666664 _LIBCPP_INLINE_VISIBILITY
667665 _Tp operator()(const _Tp& __x) const
668 {return sqrt(__x);}
666 {return std::sqrt(__x);}
669667};
670668
671669template <class _Tp>
......@@ -674,7 +672,7 @@ struct __tan_expr
674672 typedef _Tp __result_type;
675673 _LIBCPP_INLINE_VISIBILITY
676674 _Tp operator()(const _Tp& __x) const
677 {return tan(__x);}
675 {return std::tan(__x);}
678676};
679677
680678template <class _Tp>
......@@ -683,13 +681,13 @@ struct __tanh_expr
683681 typedef _Tp __result_type;
684682 _LIBCPP_INLINE_VISIBILITY
685683 _Tp operator()(const _Tp& __x) const
686 {return tanh(__x);}
684 {return std::tanh(__x);}
687685};
688686
689687template <class _ValExpr>
690688class __slice_expr
691689{
692 typedef typename remove_reference<_ValExpr>::type _RmExpr;
690 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
693691public:
694692 typedef typename _RmExpr::value_type value_type;
695693 typedef value_type __result_type;
......@@ -729,7 +727,7 @@ class __indirect_expr;
729727template <class _ValExpr>
730728class __shift_expr
731729{
732 typedef typename remove_reference<_ValExpr>::type _RmExpr;
730 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
733731public:
734732 typedef typename _RmExpr::value_type value_type;
735733 typedef value_type __result_type;
......@@ -772,7 +770,7 @@ public:
772770template <class _ValExpr>
773771class __cshift_expr
774772{
775 typedef typename remove_reference<_ValExpr>::type _RmExpr;
773 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
776774public:
777775 typedef typename _RmExpr::value_type value_type;
778776 typedef value_type __result_type;
......@@ -2247,7 +2245,7 @@ mask_array<_Tp>::operator=(const value_type& __x) const
22472245template <class _ValExpr>
22482246class __mask_expr
22492247{
2250 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2248 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
22512249public:
22522250 typedef typename _RmExpr::value_type value_type;
22532251 typedef value_type __result_type;
......@@ -2610,7 +2608,7 @@ indirect_array<_Tp>::operator=(const value_type& __x) const
26102608template <class _ValExpr>
26112609class __indirect_expr
26122610{
2613 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2611 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
26142612public:
26152613 typedef typename _RmExpr::value_type value_type;
26162614 typedef value_type __result_type;
......@@ -2650,7 +2648,7 @@ public:
26502648template<class _ValExpr>
26512649class __val_expr
26522650{
2653 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2651 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
26542652
26552653 _ValExpr __expr_;
26562654public:
......@@ -4932,4 +4930,11 @@ _LIBCPP_END_NAMESPACE_STD
49324930
49334931_LIBCPP_POP_MACROS
49344932
4933#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
4934# include <algorithm>
4935# include <concepts>
4936# include <cstring>
4937# include <functional>
4938#endif
4939
49354940#endif // _LIBCPP_VALARRAY
lib/libcxx/include/variant+227-178
......@@ -22,8 +22,8 @@ namespace std {
2222
2323 // 20.7.2.1, constructors
2424 constexpr variant() noexcept(see below);
25 variant(const variant&); // constexpr in C++20
26 variant(variant&&) noexcept(see below); // constexpr in C++20
25 constexpr variant(const variant&);
26 constexpr variant(variant&&) noexcept(see below);
2727
2828 template <class T> constexpr variant(T&&) noexcept(see below);
2929
......@@ -45,8 +45,8 @@ namespace std {
4545 ~variant();
4646
4747 // 20.7.2.3, assignment
48 variant& operator=(const variant&); // constexpr in C++20
49 variant& operator=(variant&&) noexcept(see below); // constexpr in C++20
48 constexpr variant& operator=(const variant&);
49 constexpr variant& operator=(variant&&) noexcept(see below);
5050
5151 template <class T> variant& operator=(T&&) noexcept(see below);
5252
......@@ -165,6 +165,10 @@ namespace std {
165165 template <class... Types>
166166 constexpr bool operator>=(const variant<Types...>&, const variant<Types...>&);
167167
168 template <class... Types> requires (three_way_comparable<Types> && ...)
169 constexpr common_comparison_category_t<compare_three_way_result_t<Types>...>
170 operator<=>(const variant<Types...>&, const variant<Types...>&); // since C++20
171
168172 // 20.7.6, visitation
169173 template <class Visitor, class... Variants>
170174 constexpr see below visit(Visitor&&, Variants&&...);
......@@ -176,12 +180,13 @@ namespace std {
176180 struct monostate;
177181
178182 // 20.7.8, monostate relational operators
179 constexpr bool operator<(monostate, monostate) noexcept;
180 constexpr bool operator>(monostate, monostate) noexcept;
181 constexpr bool operator<=(monostate, monostate) noexcept;
182 constexpr bool operator>=(monostate, monostate) noexcept;
183183 constexpr bool operator==(monostate, monostate) noexcept;
184 constexpr bool operator!=(monostate, monostate) noexcept;
184 constexpr bool operator!=(monostate, monostate) noexcept; // until C++20
185 constexpr bool operator<(monostate, monostate) noexcept; // until C++20
186 constexpr bool operator>(monostate, monostate) noexcept; // until C++20
187 constexpr bool operator<=(monostate, monostate) noexcept; // until C++20
188 constexpr bool operator>=(monostate, monostate) noexcept; // until C++20
189 constexpr strong_ordering operator<=>(monostate, monostate) noexcept; // since C++20
185190
186191 // 20.7.9, specialized algorithms
187192 template <class... Types>
......@@ -201,11 +206,31 @@ namespace std {
201206
202207#include <__assert> // all public C++ headers provide the assertion handler
203208#include <__availability>
209#include <__compare/common_comparison_category.h>
210#include <__compare/compare_three_way_result.h>
211#include <__compare/three_way_comparable.h>
204212#include <__config>
205213#include <__functional/hash.h>
214#include <__functional/invoke.h>
206215#include <__functional/operations.h>
207216#include <__functional/unary_function.h>
208#include <__tuple>
217#include <__type_traits/add_const.h>
218#include <__type_traits/add_cv.h>
219#include <__type_traits/add_pointer.h>
220#include <__type_traits/add_volatile.h>
221#include <__type_traits/dependent_type.h>
222#include <__type_traits/is_array.h>
223#include <__type_traits/is_destructible.h>
224#include <__type_traits/is_nothrow_move_constructible.h>
225#include <__type_traits/is_trivially_copy_assignable.h>
226#include <__type_traits/is_trivially_copy_constructible.h>
227#include <__type_traits/is_trivially_destructible.h>
228#include <__type_traits/is_trivially_move_assignable.h>
229#include <__type_traits/is_trivially_move_constructible.h>
230#include <__type_traits/is_void.h>
231#include <__type_traits/remove_const.h>
232#include <__type_traits/type_identity.h>
233#include <__type_traits/void_t.h>
209234#include <__utility/forward.h>
210235#include <__utility/in_place.h>
211236#include <__utility/move.h>
......@@ -216,15 +241,11 @@ namespace std {
216241#include <limits>
217242#include <new>
218243#include <tuple>
219#include <type_traits>
220244#include <version>
221245
222#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
223# include <typeinfo>
224# include <utility>
225#endif
226
227246// standard-mandated includes
247
248// [variant.syn]
228249#include <compare>
229250
230251#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -238,7 +259,7 @@ namespace std { // explicitly not using versioning namespace
238259
239260class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS bad_variant_access : public exception {
240261public:
241 virtual const char* what() const _NOEXCEPT;
262 const char* what() const _NOEXCEPT override;
242263};
243264
244265} // namespace std
......@@ -261,7 +282,7 @@ struct __farray {
261282};
262283
263284_LIBCPP_NORETURN
264inline _LIBCPP_INLINE_VISIBILITY
285inline _LIBCPP_HIDE_FROM_ABI
265286_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
266287void __throw_bad_variant_access() {
267288#ifndef _LIBCPP_NO_EXCEPTIONS
......@@ -320,7 +341,7 @@ struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, variant<_Types...>> {
320341
321342inline constexpr size_t variant_npos = static_cast<size_t>(-1);
322343
323constexpr int __choose_index_type(unsigned int __num_elem) {
344_LIBCPP_HIDE_FROM_ABI constexpr int __choose_index_type(unsigned int __num_elem) {
324345 if (__num_elem < numeric_limits<unsigned char>::max())
325346 return 0;
326347 if (__num_elem < numeric_limits<unsigned short>::max())
......@@ -372,7 +393,7 @@ __as_variant(const variant<_Types...>&& __vs) noexcept {
372393namespace __find_detail {
373394
374395template <class _Tp, class... _Types>
375inline _LIBCPP_INLINE_VISIBILITY
396_LIBCPP_HIDE_FROM_ABI
376397constexpr size_t __find_index() {
377398 constexpr bool __matches[] = {is_same_v<_Tp, _Types>...};
378399 size_t __result = __not_found;
......@@ -417,7 +438,7 @@ constexpr _Trait __trait =
417438 ? _Trait::_TriviallyAvailable
418439 : _IsAvailable<_Tp>::value ? _Trait::_Available : _Trait::_Unavailable;
419440
420inline _LIBCPP_INLINE_VISIBILITY
441_LIBCPP_HIDE_FROM_ABI
421442constexpr _Trait __common_trait(initializer_list<_Trait> __traits) {
422443 _Trait __result = _Trait::_TriviallyAvailable;
423444 for (_Trait __t : __traits) {
......@@ -431,24 +452,24 @@ constexpr _Trait __common_trait(initializer_list<_Trait> __traits) {
431452template <typename... _Types>
432453struct __traits {
433454 static constexpr _Trait __copy_constructible_trait =
434 __common_trait({__trait<_Types,
455 __variant_detail::__common_trait({__trait<_Types,
435456 is_trivially_copy_constructible,
436457 is_copy_constructible>...});
437458
438459 static constexpr _Trait __move_constructible_trait =
439 __common_trait({__trait<_Types,
460 __variant_detail::__common_trait({__trait<_Types,
440461 is_trivially_move_constructible,
441462 is_move_constructible>...});
442463
443 static constexpr _Trait __copy_assignable_trait = __common_trait(
464 static constexpr _Trait __copy_assignable_trait = __variant_detail::__common_trait(
444465 {__copy_constructible_trait,
445466 __trait<_Types, is_trivially_copy_assignable, is_copy_assignable>...});
446467
447 static constexpr _Trait __move_assignable_trait = __common_trait(
468 static constexpr _Trait __move_assignable_trait = __variant_detail::__common_trait(
448469 {__move_constructible_trait,
449470 __trait<_Types, is_trivially_move_assignable, is_move_assignable>...});
450471
451 static constexpr _Trait __destructible_trait = __common_trait(
472 static constexpr _Trait __destructible_trait = __variant_detail::__common_trait(
452473 {__trait<_Types, is_trivially_destructible, is_destructible>...});
453474};
454475
......@@ -456,13 +477,13 @@ namespace __access {
456477
457478struct __union {
458479 template <class _Vp>
459 inline _LIBCPP_INLINE_VISIBILITY
480 _LIBCPP_HIDE_FROM_ABI
460481 static constexpr auto&& __get_alt(_Vp&& __v, in_place_index_t<0>) {
461482 return _VSTD::forward<_Vp>(__v).__head;
462483 }
463484
464485 template <class _Vp, size_t _Ip>
465 inline _LIBCPP_INLINE_VISIBILITY
486 _LIBCPP_HIDE_FROM_ABI
466487 static constexpr auto&& __get_alt(_Vp&& __v, in_place_index_t<_Ip>) {
467488 return __get_alt(_VSTD::forward<_Vp>(__v).__tail, in_place_index<_Ip - 1>);
468489 }
......@@ -470,7 +491,7 @@ struct __union {
470491
471492struct __base {
472493 template <size_t _Ip, class _Vp>
473 inline _LIBCPP_INLINE_VISIBILITY
494 _LIBCPP_HIDE_FROM_ABI
474495 static constexpr auto&& __get_alt(_Vp&& __v) {
475496 return __union::__get_alt(_VSTD::forward<_Vp>(__v).__data,
476497 in_place_index<_Ip>);
......@@ -479,9 +500,9 @@ struct __base {
479500
480501struct __variant {
481502 template <size_t _Ip, class _Vp>
482 inline _LIBCPP_INLINE_VISIBILITY
503 _LIBCPP_HIDE_FROM_ABI
483504 static constexpr auto&& __get_alt(_Vp&& __v) {
484 return __base::__get_alt<_Ip>(_VSTD::forward<_Vp>(__v).__impl);
505 return __base::__get_alt<_Ip>(_VSTD::forward<_Vp>(__v).__impl_);
485506 }
486507};
487508
......@@ -491,7 +512,7 @@ namespace __visitation {
491512
492513struct __base {
493514 template <class _Visitor, class... _Vs>
494 inline _LIBCPP_INLINE_VISIBILITY
515 _LIBCPP_HIDE_FROM_ABI
495516 static constexpr decltype(auto)
496517 __visit_alt_at(size_t __index, _Visitor&& __visitor, _Vs&&... __vs) {
497518 constexpr auto __fdiagonal =
......@@ -502,7 +523,7 @@ struct __base {
502523 }
503524
504525 template <class _Visitor, class... _Vs>
505 inline _LIBCPP_INLINE_VISIBILITY
526 _LIBCPP_HIDE_FROM_ABI
506527 static constexpr decltype(auto) __visit_alt(_Visitor&& __visitor,
507528 _Vs&&... __vs) {
508529 constexpr auto __fmatrix =
......@@ -515,11 +536,11 @@ struct __base {
515536
516537private:
517538 template <class _Tp>
518 inline _LIBCPP_INLINE_VISIBILITY
539 _LIBCPP_HIDE_FROM_ABI
519540 static constexpr const _Tp& __at(const _Tp& __elem) { return __elem; }
520541
521542 template <class _Tp, size_t _Np, typename... _Indices>
522 inline _LIBCPP_INLINE_VISIBILITY
543 _LIBCPP_HIDE_FROM_ABI
523544 static constexpr auto&& __at(const __farray<_Tp, _Np>& __elems,
524545 size_t __index, _Indices... __indices) {
525546 return __at(__elems[__index], __indices...);
......@@ -533,17 +554,17 @@ private:
533554 }
534555
535556 template <class... _Fs>
536 inline _LIBCPP_INLINE_VISIBILITY
557 _LIBCPP_HIDE_FROM_ABI
537558 static constexpr auto __make_farray(_Fs&&... __fs) {
538 __std_visit_visitor_return_type_check<__uncvref_t<_Fs>...>();
539 using __result = __farray<common_type_t<__uncvref_t<_Fs>...>, sizeof...(_Fs)>;
559 __std_visit_visitor_return_type_check<__remove_cvref_t<_Fs>...>();
560 using __result = __farray<common_type_t<__remove_cvref_t<_Fs>...>, sizeof...(_Fs)>;
540561 return __result{{_VSTD::forward<_Fs>(__fs)...}};
541562 }
542563
543564 template <size_t... _Is>
544565 struct __dispatcher {
545566 template <class _Fp, class... _Vs>
546 inline _LIBCPP_INLINE_VISIBILITY
567 _LIBCPP_HIDE_FROM_ABI
547568 static constexpr decltype(auto) __dispatch(_Fp __f, _Vs... __vs) {
548569 return _VSTD::__invoke(
549570 static_cast<_Fp>(__f),
......@@ -552,40 +573,40 @@ private:
552573 };
553574
554575 template <class _Fp, class... _Vs, size_t... _Is>
555 inline _LIBCPP_INLINE_VISIBILITY
576 _LIBCPP_HIDE_FROM_ABI
556577 static constexpr auto __make_dispatch(index_sequence<_Is...>) {
557578 return __dispatcher<_Is...>::template __dispatch<_Fp, _Vs...>;
558579 }
559580
560581 template <size_t _Ip, class _Fp, class... _Vs>
561 inline _LIBCPP_INLINE_VISIBILITY
582 _LIBCPP_HIDE_FROM_ABI
562583 static constexpr auto __make_fdiagonal_impl() {
563584 return __make_dispatch<_Fp, _Vs...>(
564585 index_sequence<((void)__type_identity<_Vs>{}, _Ip)...>{});
565586 }
566587
567588 template <class _Fp, class... _Vs, size_t... _Is>
568 inline _LIBCPP_INLINE_VISIBILITY
589 _LIBCPP_HIDE_FROM_ABI
569590 static constexpr auto __make_fdiagonal_impl(index_sequence<_Is...>) {
570591 return __base::__make_farray(__make_fdiagonal_impl<_Is, _Fp, _Vs...>()...);
571592 }
572593
573594 template <class _Fp, class _Vp, class... _Vs>
574 inline _LIBCPP_INLINE_VISIBILITY
595 _LIBCPP_HIDE_FROM_ABI
575596 static constexpr auto __make_fdiagonal() {
576 constexpr size_t _Np = __uncvref_t<_Vp>::__size();
577 static_assert(__all<(_Np == __uncvref_t<_Vs>::__size())...>::value);
597 constexpr size_t _Np = __remove_cvref_t<_Vp>::__size();
598 static_assert(__all<(_Np == __remove_cvref_t<_Vs>::__size())...>::value);
578599 return __make_fdiagonal_impl<_Fp, _Vp, _Vs...>(make_index_sequence<_Np>{});
579600 }
580601
581602 template <class _Fp, class... _Vs, size_t... _Is>
582 inline _LIBCPP_INLINE_VISIBILITY
603 _LIBCPP_HIDE_FROM_ABI
583604 static constexpr auto __make_fmatrix_impl(index_sequence<_Is...> __is) {
584605 return __make_dispatch<_Fp, _Vs...>(__is);
585606 }
586607
587608 template <class _Fp, class... _Vs, size_t... _Is, size_t... _Js, class... _Ls>
588 inline _LIBCPP_INLINE_VISIBILITY
609 _LIBCPP_HIDE_FROM_ABI
589610 static constexpr auto __make_fmatrix_impl(index_sequence<_Is...>,
590611 index_sequence<_Js...>,
591612 _Ls... __ls) {
......@@ -594,34 +615,34 @@ private:
594615 }
595616
596617 template <class _Fp, class... _Vs>
597 inline _LIBCPP_INLINE_VISIBILITY
618 _LIBCPP_HIDE_FROM_ABI
598619 static constexpr auto __make_fmatrix() {
599620 return __make_fmatrix_impl<_Fp, _Vs...>(
600 index_sequence<>{}, make_index_sequence<__uncvref_t<_Vs>::__size()>{}...);
621 index_sequence<>{}, make_index_sequence<__remove_cvref_t<_Vs>::__size()>{}...);
601622 }
602623};
603624
604625struct __variant {
605626 template <class _Visitor, class... _Vs>
606 inline _LIBCPP_INLINE_VISIBILITY
627 _LIBCPP_HIDE_FROM_ABI
607628 static constexpr decltype(auto)
608629 __visit_alt_at(size_t __index, _Visitor&& __visitor, _Vs&&... __vs) {
609630 return __base::__visit_alt_at(__index,
610631 _VSTD::forward<_Visitor>(__visitor),
611 _VSTD::forward<_Vs>(__vs).__impl...);
632 _VSTD::forward<_Vs>(__vs).__impl_...);
612633 }
613634
614635 template <class _Visitor, class... _Vs>
615 inline _LIBCPP_INLINE_VISIBILITY
636 _LIBCPP_HIDE_FROM_ABI
616637 static constexpr decltype(auto) __visit_alt(_Visitor&& __visitor,
617638 _Vs&&... __vs) {
618639 return __base::__visit_alt(
619640 _VSTD::forward<_Visitor>(__visitor),
620 _VSTD::__as_variant(_VSTD::forward<_Vs>(__vs)).__impl...);
641 _VSTD::__as_variant(_VSTD::forward<_Vs>(__vs)).__impl_...);
621642 }
622643
623644 template <class _Visitor, class... _Vs>
624 inline _LIBCPP_INLINE_VISIBILITY
645 _LIBCPP_HIDE_FROM_ABI
625646 static constexpr decltype(auto)
626647 __visit_value_at(size_t __index, _Visitor&& __visitor, _Vs&&... __vs) {
627648 return __visit_alt_at(
......@@ -631,7 +652,7 @@ struct __variant {
631652 }
632653
633654 template <class _Visitor, class... _Vs>
634 inline _LIBCPP_INLINE_VISIBILITY
655 _LIBCPP_HIDE_FROM_ABI
635656 static constexpr decltype(auto) __visit_value(_Visitor&& __visitor,
636657 _Vs&&... __vs) {
637658 return __visit_alt(
......@@ -641,7 +662,7 @@ struct __variant {
641662
642663#if _LIBCPP_STD_VER > 17
643664 template <class _Rp, class _Visitor, class... _Vs>
644 inline _LIBCPP_INLINE_VISIBILITY
665 _LIBCPP_HIDE_FROM_ABI
645666 static constexpr _Rp __visit_value(_Visitor&& __visitor,
646667 _Vs&&... __vs) {
647668 return __visit_alt(
......@@ -660,7 +681,7 @@ private:
660681 template <class _Visitor>
661682 struct __value_visitor {
662683 template <class... _Alts>
663 inline _LIBCPP_INLINE_VISIBILITY
684 _LIBCPP_HIDE_FROM_ABI
664685 constexpr decltype(auto) operator()(_Alts&&... __alts) const {
665686 __std_visit_exhaustive_visitor_check<
666687 _Visitor,
......@@ -675,7 +696,7 @@ private:
675696 template <class _Rp, class _Visitor>
676697 struct __value_visitor_return_type {
677698 template <class... _Alts>
678 inline _LIBCPP_INLINE_VISIBILITY
699 _LIBCPP_HIDE_FROM_ABI
679700 constexpr _Rp operator()(_Alts&&... __alts) const {
680701 __std_visit_exhaustive_visitor_check<
681702 _Visitor,
......@@ -695,14 +716,14 @@ private:
695716#endif
696717
697718 template <class _Visitor>
698 inline _LIBCPP_INLINE_VISIBILITY
719 _LIBCPP_HIDE_FROM_ABI
699720 static constexpr auto __make_value_visitor(_Visitor&& __visitor) {
700721 return __value_visitor<_Visitor>{_VSTD::forward<_Visitor>(__visitor)};
701722 }
702723
703724#if _LIBCPP_STD_VER > 17
704725 template <class _Rp, class _Visitor>
705 inline _LIBCPP_INLINE_VISIBILITY
726 _LIBCPP_HIDE_FROM_ABI
706727 static constexpr auto __make_value_visitor(_Visitor&& __visitor) {
707728 return __value_visitor_return_type<_Rp, _Visitor>{_VSTD::forward<_Visitor>(__visitor)};
708729 }
......@@ -716,7 +737,7 @@ struct _LIBCPP_TEMPLATE_VIS __alt {
716737 using __value_type = _Tp;
717738
718739 template <class... _Args>
719 inline _LIBCPP_INLINE_VISIBILITY
740 _LIBCPP_HIDE_FROM_ABI
720741 explicit constexpr __alt(in_place_t, _Args&&... __args)
721742 : __value(_VSTD::forward<_Args>(__args)...) {}
722743
......@@ -731,21 +752,21 @@ union _LIBCPP_TEMPLATE_VIS __union<_DestructibleTrait, _Index> {};
731752
732753#define _LIBCPP_VARIANT_UNION(destructible_trait, destructor) \
733754 template <size_t _Index, class _Tp, class... _Types> \
734 union _LIBCPP_TEMPLATE_VIS __union<destructible_trait, \
755 union _LIBCPP_TEMPLATE_VIS __union<destructible_trait, \
735756 _Index, \
736757 _Tp, \
737758 _Types...> { \
738759 public: \
739 inline _LIBCPP_INLINE_VISIBILITY \
760 _LIBCPP_HIDE_FROM_ABI \
740761 explicit constexpr __union(__valueless_t) noexcept : __dummy{} {} \
741762 \
742763 template <class... _Args> \
743 inline _LIBCPP_INLINE_VISIBILITY \
764 _LIBCPP_HIDE_FROM_ABI \
744765 explicit constexpr __union(in_place_index_t<0>, _Args&&... __args) \
745766 : __head(in_place, _VSTD::forward<_Args>(__args)...) {} \
746767 \
747768 template <size_t _Ip, class... _Args> \
748 inline _LIBCPP_INLINE_VISIBILITY \
769 _LIBCPP_HIDE_FROM_ABI \
749770 explicit constexpr __union(in_place_index_t<_Ip>, _Args&&... __args) \
750771 : __tail(in_place_index<_Ip - 1>, _VSTD::forward<_Args>(__args)...) {} \
751772 \
......@@ -776,41 +797,41 @@ class _LIBCPP_TEMPLATE_VIS __base {
776797public:
777798 using __index_t = __variant_index_t<sizeof...(_Types)>;
778799
779 inline _LIBCPP_INLINE_VISIBILITY
800 _LIBCPP_HIDE_FROM_ABI
780801 explicit constexpr __base(__valueless_t __tag) noexcept
781802 : __data(__tag), __index(__variant_npos<__index_t>) {}
782803
783804 template <size_t _Ip, class... _Args>
784 inline _LIBCPP_INLINE_VISIBILITY
805 _LIBCPP_HIDE_FROM_ABI
785806 explicit constexpr __base(in_place_index_t<_Ip>, _Args&&... __args)
786807 :
787808 __data(in_place_index<_Ip>, _VSTD::forward<_Args>(__args)...),
788809 __index(_Ip) {}
789810
790 inline _LIBCPP_INLINE_VISIBILITY
811 _LIBCPP_HIDE_FROM_ABI
791812 constexpr bool valueless_by_exception() const noexcept {
792813 return index() == variant_npos;
793814 }
794815
795 inline _LIBCPP_INLINE_VISIBILITY
816 _LIBCPP_HIDE_FROM_ABI
796817 constexpr size_t index() const noexcept {
797818 return __index == __variant_npos<__index_t> ? variant_npos : __index;
798819 }
799820
800821protected:
801 inline _LIBCPP_INLINE_VISIBILITY
822 _LIBCPP_HIDE_FROM_ABI
802823 constexpr auto&& __as_base() & { return *this; }
803824
804 inline _LIBCPP_INLINE_VISIBILITY
825 _LIBCPP_HIDE_FROM_ABI
805826 constexpr auto&& __as_base() && { return _VSTD::move(*this); }
806827
807 inline _LIBCPP_INLINE_VISIBILITY
828 _LIBCPP_HIDE_FROM_ABI
808829 constexpr auto&& __as_base() const & { return *this; }
809830
810 inline _LIBCPP_INLINE_VISIBILITY
831 _LIBCPP_HIDE_FROM_ABI
811832 constexpr auto&& __as_base() const && { return _VSTD::move(*this); }
812833
813 inline _LIBCPP_INLINE_VISIBILITY
834 _LIBCPP_HIDE_FROM_ABI
814835 static constexpr size_t __size() { return sizeof...(_Types); }
815836
816837 __union<_DestructibleTrait, 0, _Types...> __data;
......@@ -842,7 +863,7 @@ class _LIBCPP_TEMPLATE_VIS __dtor;
842863 __dtor& operator=(__dtor&&) = default; \
843864 \
844865 protected: \
845 inline _LIBCPP_INLINE_VISIBILITY \
866 inline _LIBCPP_HIDE_FROM_ABI \
846867 destroy \
847868 }
848869
......@@ -858,7 +879,7 @@ _LIBCPP_VARIANT_DESTRUCTOR(
858879 if (!this->valueless_by_exception()) {
859880 __visitation::__base::__visit_alt(
860881 [](auto& __alt) noexcept {
861 using __alt_type = __uncvref_t<decltype(__alt)>;
882 using __alt_type = __remove_cvref_t<decltype(__alt)>;
862883 __alt.~__alt_type();
863884 },
864885 *this);
......@@ -883,7 +904,7 @@ public:
883904
884905protected:
885906 template <size_t _Ip, class _Tp, class... _Args>
886 inline _LIBCPP_INLINE_VISIBILITY
907 _LIBCPP_HIDE_FROM_ABI
887908 static _Tp& __construct_alt(__alt<_Ip, _Tp>& __a, _Args&&... __args) {
888909 ::new ((void*)_VSTD::addressof(__a))
889910 __alt<_Ip, _Tp>(in_place, _VSTD::forward<_Args>(__args)...);
......@@ -891,7 +912,7 @@ protected:
891912 }
892913
893914 template <class _Rhs>
894 inline _LIBCPP_INLINE_VISIBILITY
915 _LIBCPP_HIDE_FROM_ABI
895916 static void __generic_construct(__ctor& __lhs, _Rhs&& __rhs) {
896917 __lhs.__destroy();
897918 if (!__rhs.valueless_by_exception()) {
......@@ -954,7 +975,7 @@ class _LIBCPP_TEMPLATE_VIS __copy_constructor;
954975#define _LIBCPP_VARIANT_COPY_CONSTRUCTOR(copy_constructible_trait, \
955976 copy_constructor) \
956977 template <class... _Types> \
957 class _LIBCPP_TEMPLATE_VIS __copy_constructor<__traits<_Types...>, \
978 class _LIBCPP_TEMPLATE_VIS __copy_constructor<__traits<_Types...>, \
958979 copy_constructible_trait> \
959980 : public __move_constructor<__traits<_Types...>> { \
960981 using __base_type = __move_constructor<__traits<_Types...>>; \
......@@ -996,7 +1017,7 @@ public:
9961017 using __base_type::operator=;
9971018
9981019 template <size_t _Ip, class... _Args>
999 inline _LIBCPP_INLINE_VISIBILITY
1020 _LIBCPP_HIDE_FROM_ABI
10001021 auto& __emplace(_Args&&... __args) {
10011022 this->__destroy();
10021023 auto& __res = this->__construct_alt(__access::__base::__get_alt<_Ip>(*this),
......@@ -1007,7 +1028,7 @@ public:
10071028
10081029protected:
10091030 template <size_t _Ip, class _Tp, class _Arg>
1010 inline _LIBCPP_INLINE_VISIBILITY
1031 _LIBCPP_HIDE_FROM_ABI
10111032 void __assign_alt(__alt<_Ip, _Tp>& __a, _Arg&& __arg) {
10121033 if (this->index() == _Ip) {
10131034 __a.__value = _VSTD::forward<_Arg>(__arg);
......@@ -1028,7 +1049,7 @@ protected:
10281049 }
10291050
10301051 template <class _That>
1031 inline _LIBCPP_INLINE_VISIBILITY
1052 _LIBCPP_HIDE_FROM_ABI
10321053 void __generic_assign(_That&& __that) {
10331054 if (this->valueless_by_exception() && __that.valueless_by_exception()) {
10341055 // do nothing.
......@@ -1053,7 +1074,7 @@ class _LIBCPP_TEMPLATE_VIS __move_assignment;
10531074#define _LIBCPP_VARIANT_MOVE_ASSIGNMENT(move_assignable_trait, \
10541075 move_assignment) \
10551076 template <class... _Types> \
1056 class _LIBCPP_TEMPLATE_VIS __move_assignment<__traits<_Types...>, \
1077 class _LIBCPP_TEMPLATE_VIS __move_assignment<__traits<_Types...>, \
10571078 move_assignable_trait> \
10581079 : public __assignment<__traits<_Types...>> { \
10591080 using __base_type = __assignment<__traits<_Types...>>; \
......@@ -1094,7 +1115,7 @@ class _LIBCPP_TEMPLATE_VIS __copy_assignment;
10941115#define _LIBCPP_VARIANT_COPY_ASSIGNMENT(copy_assignable_trait, \
10951116 copy_assignment) \
10961117 template <class... _Types> \
1097 class _LIBCPP_TEMPLATE_VIS __copy_assignment<__traits<_Types...>, \
1118 class _LIBCPP_TEMPLATE_VIS __copy_assignment<__traits<_Types...>, \
10981119 copy_assignable_trait> \
10991120 : public __move_assignment<__traits<_Types...>> { \
11001121 using __base_type = __move_assignment<__traits<_Types...>>; \
......@@ -1140,13 +1161,13 @@ public:
11401161 __impl& operator=(__impl&&) = default;
11411162
11421163 template <size_t _Ip, class _Arg>
1143 inline _LIBCPP_INLINE_VISIBILITY
1164 _LIBCPP_HIDE_FROM_ABI
11441165 void __assign(_Arg&& __arg) {
11451166 this->__assign_alt(__access::__base::__get_alt<_Ip>(*this),
11461167 _VSTD::forward<_Arg>(__arg));
11471168 }
11481169
1149 inline _LIBCPP_INLINE_VISIBILITY
1170 inline _LIBCPP_HIDE_FROM_ABI
11501171 void __swap(__impl& __that) {
11511172 if (this->valueless_by_exception() && __that.valueless_by_exception()) {
11521173 // do nothing.
......@@ -1192,7 +1213,7 @@ public:
11921213 }
11931214
11941215private:
1195 inline _LIBCPP_INLINE_VISIBILITY
1216 inline _LIBCPP_HIDE_FROM_ABI
11961217 bool __move_nothrow() const {
11971218 constexpr bool __results[] = {is_nothrow_move_constructible_v<_Types>...};
11981219 return this->valueless_by_exception() || __results[this->index()];
......@@ -1208,7 +1229,7 @@ struct __narrowing_check {
12081229 template <class _Dest>
12091230 static auto __test_impl(_Dest (&&)[1]) -> __type_identity<_Dest>;
12101231 template <class _Dest, class _Source>
1211 using _Apply _LIBCPP_NODEBUG = decltype(__test_impl<_Dest>({declval<_Source>()}));
1232 using _Apply _LIBCPP_NODEBUG = decltype(__test_impl<_Dest>({std::declval<_Source>()}));
12121233};
12131234
12141235template <class _Dest, class _Source>
......@@ -1230,7 +1251,7 @@ struct __overload {
12301251
12311252template <class _Tp, size_t>
12321253struct __overload_bool {
1233 template <class _Up, class _Ap = __uncvref_t<_Up>>
1254 template <class _Up, class _Ap = __remove_cvref_t<_Up>>
12341255 auto operator()(bool, _Up&&) const
12351256 -> enable_if_t<is_same_v<_Ap, bool>, __type_identity<_Tp>>;
12361257};
......@@ -1298,36 +1319,36 @@ public:
12981319 enable_if_t<__dependent_type<is_default_constructible<__first_type>,
12991320 _Dummy>::value,
13001321 int> = 0>
1301 inline _LIBCPP_INLINE_VISIBILITY
1322 _LIBCPP_HIDE_FROM_ABI
13021323 constexpr variant() noexcept(is_nothrow_default_constructible_v<__first_type>)
1303 : __impl(in_place_index<0>) {}
1324 : __impl_(in_place_index<0>) {}
13041325
1305 variant(const variant&) = default;
1306 variant(variant&&) = default;
1326 constexpr variant(const variant&) = default;
1327 constexpr variant(variant&&) = default;
13071328
13081329 template <
13091330 class _Arg,
1310 enable_if_t<!is_same_v<__uncvref_t<_Arg>, variant>, int> = 0,
1311 enable_if_t<!__is_inplace_type<__uncvref_t<_Arg>>::value, int> = 0,
1312 enable_if_t<!__is_inplace_index<__uncvref_t<_Arg>>::value, int> = 0,
1331 enable_if_t<!is_same_v<__remove_cvref_t<_Arg>, variant>, int> = 0,
1332 enable_if_t<!__is_inplace_type<__remove_cvref_t<_Arg>>::value, int> = 0,
1333 enable_if_t<!__is_inplace_index<__remove_cvref_t<_Arg>>::value, int> = 0,
13131334 class _Tp = __variant_detail::__best_match_t<_Arg, _Types...>,
13141335 size_t _Ip =
13151336 __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,
13161337 enable_if_t<is_constructible_v<_Tp, _Arg>, int> = 0>
1317 inline _LIBCPP_INLINE_VISIBILITY
1338 _LIBCPP_HIDE_FROM_ABI
13181339 constexpr variant(_Arg&& __arg) noexcept(
13191340 is_nothrow_constructible_v<_Tp, _Arg>)
1320 : __impl(in_place_index<_Ip>, _VSTD::forward<_Arg>(__arg)) {}
1341 : __impl_(in_place_index<_Ip>, _VSTD::forward<_Arg>(__arg)) {}
13211342
13221343 template <size_t _Ip, class... _Args,
13231344 class = enable_if_t<(_Ip < sizeof...(_Types)), int>,
13241345 class _Tp = variant_alternative_t<_Ip, variant<_Types...>>,
13251346 enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0>
1326 inline _LIBCPP_INLINE_VISIBILITY
1347 _LIBCPP_HIDE_FROM_ABI
13271348 explicit constexpr variant(
13281349 in_place_index_t<_Ip>,
13291350 _Args&&... __args) noexcept(is_nothrow_constructible_v<_Tp, _Args...>)
1330 : __impl(in_place_index<_Ip>, _VSTD::forward<_Args>(__args)...) {}
1351 : __impl_(in_place_index<_Ip>, _VSTD::forward<_Args>(__args)...) {}
13311352
13321353 template <
13331354 size_t _Ip,
......@@ -1337,13 +1358,13 @@ public:
13371358 class _Tp = variant_alternative_t<_Ip, variant<_Types...>>,
13381359 enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>,
13391360 int> = 0>
1340 inline _LIBCPP_INLINE_VISIBILITY
1361 _LIBCPP_HIDE_FROM_ABI
13411362 explicit constexpr variant(
13421363 in_place_index_t<_Ip>,
13431364 initializer_list<_Up> __il,
13441365 _Args&&... __args) noexcept(
13451366 is_nothrow_constructible_v<_Tp, initializer_list<_Up>&, _Args...>)
1346 : __impl(in_place_index<_Ip>, __il, _VSTD::forward<_Args>(__args)...) {}
1367 : __impl_(in_place_index<_Ip>, __il, _VSTD::forward<_Args>(__args)...) {}
13471368
13481369 template <
13491370 class _Tp,
......@@ -1351,10 +1372,10 @@ public:
13511372 size_t _Ip =
13521373 __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,
13531374 enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0>
1354 inline _LIBCPP_INLINE_VISIBILITY
1375 _LIBCPP_HIDE_FROM_ABI
13551376 explicit constexpr variant(in_place_type_t<_Tp>, _Args&&... __args) noexcept(
13561377 is_nothrow_constructible_v<_Tp, _Args...>)
1357 : __impl(in_place_index<_Ip>, _VSTD::forward<_Args>(__args)...) {}
1378 : __impl_(in_place_index<_Ip>, _VSTD::forward<_Args>(__args)...) {}
13581379
13591380 template <
13601381 class _Tp,
......@@ -1364,32 +1385,32 @@ public:
13641385 __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,
13651386 enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>,
13661387 int> = 0>
1367 inline _LIBCPP_INLINE_VISIBILITY
1388 _LIBCPP_HIDE_FROM_ABI
13681389 explicit constexpr variant(
13691390 in_place_type_t<_Tp>,
13701391 initializer_list<_Up> __il,
13711392 _Args&&... __args) noexcept(
13721393 is_nothrow_constructible_v<_Tp, initializer_list< _Up>&, _Args...>)
1373 : __impl(in_place_index<_Ip>, __il, _VSTD::forward<_Args>(__args)...) {}
1394 : __impl_(in_place_index<_Ip>, __il, _VSTD::forward<_Args>(__args)...) {}
13741395
13751396 ~variant() = default;
13761397
1377 variant& operator=(const variant&) = default;
1378 variant& operator=(variant&&) = default;
1398 constexpr variant& operator=(const variant&) = default;
1399 constexpr variant& operator=(variant&&) = default;
13791400
13801401 template <
13811402 class _Arg,
1382 enable_if_t<!is_same_v<__uncvref_t<_Arg>, variant>, int> = 0,
1403 enable_if_t<!is_same_v<__remove_cvref_t<_Arg>, variant>, int> = 0,
13831404 class _Tp = __variant_detail::__best_match_t<_Arg, _Types...>,
13841405 size_t _Ip =
13851406 __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,
13861407 enable_if_t<is_assignable_v<_Tp&, _Arg> && is_constructible_v<_Tp, _Arg>,
13871408 int> = 0>
1388 inline _LIBCPP_INLINE_VISIBILITY
1409 _LIBCPP_HIDE_FROM_ABI
13891410 variant& operator=(_Arg&& __arg) noexcept(
13901411 is_nothrow_assignable_v<_Tp&, _Arg> &&
13911412 is_nothrow_constructible_v<_Tp, _Arg>) {
1392 __impl.template __assign<_Ip>(_VSTD::forward<_Arg>(__arg));
1413 __impl_.template __assign<_Ip>(_VSTD::forward<_Arg>(__arg));
13931414 return *this;
13941415 }
13951416
......@@ -1399,9 +1420,9 @@ public:
13991420 enable_if_t<(_Ip < sizeof...(_Types)), int> = 0,
14001421 class _Tp = variant_alternative_t<_Ip, variant<_Types...>>,
14011422 enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0>
1402 inline _LIBCPP_INLINE_VISIBILITY
1423 _LIBCPP_HIDE_FROM_ABI
14031424 _Tp& emplace(_Args&&... __args) {
1404 return __impl.template __emplace<_Ip>(_VSTD::forward<_Args>(__args)...);
1425 return __impl_.template __emplace<_Ip>(_VSTD::forward<_Args>(__args)...);
14051426 }
14061427
14071428 template <
......@@ -1412,9 +1433,9 @@ public:
14121433 class _Tp = variant_alternative_t<_Ip, variant<_Types...>>,
14131434 enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>,
14141435 int> = 0>
1415 inline _LIBCPP_INLINE_VISIBILITY
1436 _LIBCPP_HIDE_FROM_ABI
14161437 _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) {
1417 return __impl.template __emplace<_Ip>(__il, _VSTD::forward<_Args>(__args)...);
1438 return __impl_.template __emplace<_Ip>(__il, _VSTD::forward<_Args>(__args)...);
14181439 }
14191440
14201441 template <
......@@ -1423,9 +1444,9 @@ public:
14231444 size_t _Ip =
14241445 __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,
14251446 enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0>
1426 inline _LIBCPP_INLINE_VISIBILITY
1447 _LIBCPP_HIDE_FROM_ABI
14271448 _Tp& emplace(_Args&&... __args) {
1428 return __impl.template __emplace<_Ip>(_VSTD::forward<_Args>(__args)...);
1449 return __impl_.template __emplace<_Ip>(_VSTD::forward<_Args>(__args)...);
14291450 }
14301451
14311452 template <
......@@ -1436,18 +1457,18 @@ public:
14361457 __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,
14371458 enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>,
14381459 int> = 0>
1439 inline _LIBCPP_INLINE_VISIBILITY
1460 _LIBCPP_HIDE_FROM_ABI
14401461 _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) {
1441 return __impl.template __emplace<_Ip>(__il, _VSTD::forward<_Args>(__args)...);
1462 return __impl_.template __emplace<_Ip>(__il, _VSTD::forward<_Args>(__args)...);
14421463 }
14431464
1444 inline _LIBCPP_INLINE_VISIBILITY
1465 _LIBCPP_HIDE_FROM_ABI
14451466 constexpr bool valueless_by_exception() const noexcept {
1446 return __impl.valueless_by_exception();
1467 return __impl_.valueless_by_exception();
14471468 }
14481469
1449 inline _LIBCPP_INLINE_VISIBILITY
1450 constexpr size_t index() const noexcept { return __impl.index(); }
1470 _LIBCPP_HIDE_FROM_ABI
1471 constexpr size_t index() const noexcept { return __impl_.index(); }
14511472
14521473 template <
14531474 bool _Dummy = true,
......@@ -1456,85 +1477,85 @@ public:
14561477 __dependent_type<is_move_constructible<_Types>, _Dummy>::value &&
14571478 __dependent_type<is_swappable<_Types>, _Dummy>::value)...>::value,
14581479 int> = 0>
1459 inline _LIBCPP_INLINE_VISIBILITY
1480 _LIBCPP_HIDE_FROM_ABI
14601481 void swap(variant& __that) noexcept(
14611482 __all<(is_nothrow_move_constructible_v<_Types> &&
14621483 is_nothrow_swappable_v<_Types>)...>::value) {
1463 __impl.__swap(__that.__impl);
1484 __impl_.__swap(__that.__impl_);
14641485 }
14651486
14661487private:
1467 __variant_detail::__impl<_Types...> __impl;
1488 __variant_detail::__impl<_Types...> __impl_;
14681489
14691490 friend struct __variant_detail::__access::__variant;
14701491 friend struct __variant_detail::__visitation::__variant;
14711492};
14721493
14731494template <size_t _Ip, class... _Types>
1474inline _LIBCPP_INLINE_VISIBILITY
1495_LIBCPP_HIDE_FROM_ABI
14751496constexpr bool __holds_alternative(const variant<_Types...>& __v) noexcept {
14761497 return __v.index() == _Ip;
14771498}
14781499
14791500template <class _Tp, class... _Types>
1480inline _LIBCPP_INLINE_VISIBILITY
1501_LIBCPP_HIDE_FROM_ABI
14811502constexpr bool holds_alternative(const variant<_Types...>& __v) noexcept {
1482 return __holds_alternative<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
1503 return std::__holds_alternative<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
14831504}
14841505
14851506template <size_t _Ip, class _Vp>
1486inline _LIBCPP_INLINE_VISIBILITY
1507_LIBCPP_HIDE_FROM_ABI
14871508_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
14881509constexpr auto&& __generic_get(_Vp&& __v) {
14891510 using __variant_detail::__access::__variant;
1490 if (!__holds_alternative<_Ip>(__v)) {
1511 if (!std::__holds_alternative<_Ip>(__v)) {
14911512 __throw_bad_variant_access();
14921513 }
14931514 return __variant::__get_alt<_Ip>(_VSTD::forward<_Vp>(__v)).__value;
14941515}
14951516
14961517template <size_t _Ip, class... _Types>
1497inline _LIBCPP_INLINE_VISIBILITY
1518_LIBCPP_HIDE_FROM_ABI
14981519_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
14991520constexpr variant_alternative_t<_Ip, variant<_Types...>>& get(
15001521 variant<_Types...>& __v) {
15011522 static_assert(_Ip < sizeof...(_Types));
15021523 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
1503 return __generic_get<_Ip>(__v);
1524 return std::__generic_get<_Ip>(__v);
15041525}
15051526
15061527template <size_t _Ip, class... _Types>
1507inline _LIBCPP_INLINE_VISIBILITY
1528_LIBCPP_HIDE_FROM_ABI
15081529_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
15091530constexpr variant_alternative_t<_Ip, variant<_Types...>>&& get(
15101531 variant<_Types...>&& __v) {
15111532 static_assert(_Ip < sizeof...(_Types));
15121533 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
1513 return __generic_get<_Ip>(_VSTD::move(__v));
1534 return std::__generic_get<_Ip>(_VSTD::move(__v));
15141535}
15151536
15161537template <size_t _Ip, class... _Types>
1517inline _LIBCPP_INLINE_VISIBILITY
1538_LIBCPP_HIDE_FROM_ABI
15181539_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
15191540constexpr const variant_alternative_t<_Ip, variant<_Types...>>& get(
15201541 const variant<_Types...>& __v) {
15211542 static_assert(_Ip < sizeof...(_Types));
15221543 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
1523 return __generic_get<_Ip>(__v);
1544 return std::__generic_get<_Ip>(__v);
15241545}
15251546
15261547template <size_t _Ip, class... _Types>
1527inline _LIBCPP_INLINE_VISIBILITY
1548_LIBCPP_HIDE_FROM_ABI
15281549_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
15291550constexpr const variant_alternative_t<_Ip, variant<_Types...>>&& get(
15301551 const variant<_Types...>&& __v) {
15311552 static_assert(_Ip < sizeof...(_Types));
15321553 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
1533 return __generic_get<_Ip>(_VSTD::move(__v));
1554 return std::__generic_get<_Ip>(_VSTD::move(__v));
15341555}
15351556
15361557template <class _Tp, class... _Types>
1537inline _LIBCPP_INLINE_VISIBILITY
1558_LIBCPP_HIDE_FROM_ABI
15381559_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
15391560constexpr _Tp& get(variant<_Types...>& __v) {
15401561 static_assert(!is_void_v<_Tp>);
......@@ -1542,7 +1563,7 @@ constexpr _Tp& get(variant<_Types...>& __v) {
15421563}
15431564
15441565template <class _Tp, class... _Types>
1545inline _LIBCPP_INLINE_VISIBILITY
1566_LIBCPP_HIDE_FROM_ABI
15461567_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
15471568constexpr _Tp&& get(variant<_Types...>&& __v) {
15481569 static_assert(!is_void_v<_Tp>);
......@@ -1551,7 +1572,7 @@ constexpr _Tp&& get(variant<_Types...>&& __v) {
15511572}
15521573
15531574template <class _Tp, class... _Types>
1554inline _LIBCPP_INLINE_VISIBILITY
1575_LIBCPP_HIDE_FROM_ABI
15551576_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
15561577constexpr const _Tp& get(const variant<_Types...>& __v) {
15571578 static_assert(!is_void_v<_Tp>);
......@@ -1559,7 +1580,7 @@ constexpr const _Tp& get(const variant<_Types...>& __v) {
15591580}
15601581
15611582template <class _Tp, class... _Types>
1562inline _LIBCPP_INLINE_VISIBILITY
1583_LIBCPP_HIDE_FROM_ABI
15631584_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
15641585constexpr const _Tp&& get(const variant<_Types...>&& __v) {
15651586 static_assert(!is_void_v<_Tp>);
......@@ -1568,34 +1589,34 @@ constexpr const _Tp&& get(const variant<_Types...>&& __v) {
15681589}
15691590
15701591template <size_t _Ip, class _Vp>
1571inline _LIBCPP_INLINE_VISIBILITY
1592_LIBCPP_HIDE_FROM_ABI
15721593constexpr auto* __generic_get_if(_Vp* __v) noexcept {
15731594 using __variant_detail::__access::__variant;
1574 return __v && __holds_alternative<_Ip>(*__v)
1595 return __v && std::__holds_alternative<_Ip>(*__v)
15751596 ? _VSTD::addressof(__variant::__get_alt<_Ip>(*__v).__value)
15761597 : nullptr;
15771598}
15781599
15791600template <size_t _Ip, class... _Types>
1580inline _LIBCPP_INLINE_VISIBILITY
1601_LIBCPP_HIDE_FROM_ABI
15811602constexpr add_pointer_t<variant_alternative_t<_Ip, variant<_Types...>>>
15821603get_if(variant<_Types...>* __v) noexcept {
15831604 static_assert(_Ip < sizeof...(_Types));
15841605 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
1585 return __generic_get_if<_Ip>(__v);
1606 return std::__generic_get_if<_Ip>(__v);
15861607}
15871608
15881609template <size_t _Ip, class... _Types>
1589inline _LIBCPP_INLINE_VISIBILITY
1610_LIBCPP_HIDE_FROM_ABI
15901611constexpr add_pointer_t<const variant_alternative_t<_Ip, variant<_Types...>>>
15911612get_if(const variant<_Types...>* __v) noexcept {
15921613 static_assert(_Ip < sizeof...(_Types));
15931614 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
1594 return __generic_get_if<_Ip>(__v);
1615 return std::__generic_get_if<_Ip>(__v);
15951616}
15961617
15971618template <class _Tp, class... _Types>
1598inline _LIBCPP_INLINE_VISIBILITY
1619_LIBCPP_HIDE_FROM_ABI
15991620constexpr add_pointer_t<_Tp>
16001621get_if(variant<_Types...>* __v) noexcept {
16011622 static_assert(!is_void_v<_Tp>);
......@@ -1603,7 +1624,7 @@ get_if(variant<_Types...>* __v) noexcept {
16031624}
16041625
16051626template <class _Tp, class... _Types>
1606inline _LIBCPP_INLINE_VISIBILITY
1627_LIBCPP_HIDE_FROM_ABI
16071628constexpr add_pointer_t<const _Tp>
16081629get_if(const variant<_Types...>* __v) noexcept {
16091630 static_assert(!is_void_v<_Tp>);
......@@ -1613,7 +1634,8 @@ get_if(const variant<_Types...>* __v) noexcept {
16131634template <class _Operator>
16141635struct __convert_to_bool {
16151636 template <class _T1, class _T2>
1616 _LIBCPP_INLINE_VISIBILITY constexpr bool operator()(_T1 && __t1, _T2&& __t2) const {
1637 _LIBCPP_HIDE_FROM_ABI
1638 constexpr bool operator()(_T1 && __t1, _T2&& __t2) const {
16171639 static_assert(is_convertible<decltype(_Operator{}(_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2))), bool>::value,
16181640 "the relational operator does not return a type which is implicitly convertible to bool");
16191641 return _Operator{}(_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2));
......@@ -1621,7 +1643,7 @@ struct __convert_to_bool {
16211643};
16221644
16231645template <class... _Types>
1624inline _LIBCPP_INLINE_VISIBILITY
1646_LIBCPP_HIDE_FROM_ABI
16251647constexpr bool operator==(const variant<_Types...>& __lhs,
16261648 const variant<_Types...>& __rhs) {
16271649 using __variant_detail::__visitation::__variant;
......@@ -1630,8 +1652,29 @@ constexpr bool operator==(const variant<_Types...>& __lhs,
16301652 return __variant::__visit_value_at(__lhs.index(), __convert_to_bool<equal_to<>>{}, __lhs, __rhs);
16311653}
16321654
1655# if _LIBCPP_STD_VER > 17
1656
1657template <class... _Types> requires (three_way_comparable<_Types> && ...)
1658_LIBCPP_HIDE_FROM_ABI constexpr common_comparison_category_t<compare_three_way_result_t<_Types>...>
1659operator<=>(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) {
1660 using __variant_detail::__visitation::__variant;
1661 using __result_t = common_comparison_category_t<compare_three_way_result_t<_Types>...>;
1662 if (__lhs.valueless_by_exception() && __rhs.valueless_by_exception())
1663 return strong_ordering::equal;
1664 if (__lhs.valueless_by_exception())
1665 return strong_ordering::less;
1666 if (__rhs.valueless_by_exception())
1667 return strong_ordering::greater;
1668 if (auto __c = __lhs.index() <=> __rhs.index(); __c != 0)
1669 return __c;
1670 auto __three_way = []<class _Type>(const _Type& __v, const _Type& __w) -> __result_t { return __v <=> __w; };
1671 return __variant::__visit_value_at(__lhs.index(), __three_way, __lhs, __rhs);
1672}
1673
1674# endif // _LIBCPP_STD_VER > 17
1675
16331676template <class... _Types>
1634inline _LIBCPP_INLINE_VISIBILITY
1677_LIBCPP_HIDE_FROM_ABI
16351678constexpr bool operator!=(const variant<_Types...>& __lhs,
16361679 const variant<_Types...>& __rhs) {
16371680 using __variant_detail::__visitation::__variant;
......@@ -1642,7 +1685,7 @@ constexpr bool operator!=(const variant<_Types...>& __lhs,
16421685}
16431686
16441687template <class... _Types>
1645inline _LIBCPP_INLINE_VISIBILITY
1688_LIBCPP_HIDE_FROM_ABI
16461689constexpr bool operator<(const variant<_Types...>& __lhs,
16471690 const variant<_Types...>& __rhs) {
16481691 using __variant_detail::__visitation::__variant;
......@@ -1654,7 +1697,7 @@ constexpr bool operator<(const variant<_Types...>& __lhs,
16541697}
16551698
16561699template <class... _Types>
1657inline _LIBCPP_INLINE_VISIBILITY
1700_LIBCPP_HIDE_FROM_ABI
16581701constexpr bool operator>(const variant<_Types...>& __lhs,
16591702 const variant<_Types...>& __rhs) {
16601703 using __variant_detail::__visitation::__variant;
......@@ -1666,7 +1709,7 @@ constexpr bool operator>(const variant<_Types...>& __lhs,
16661709}
16671710
16681711template <class... _Types>
1669inline _LIBCPP_INLINE_VISIBILITY
1712_LIBCPP_HIDE_FROM_ABI
16701713constexpr bool operator<=(const variant<_Types...>& __lhs,
16711714 const variant<_Types...>& __rhs) {
16721715 using __variant_detail::__visitation::__variant;
......@@ -1679,7 +1722,7 @@ constexpr bool operator<=(const variant<_Types...>& __lhs,
16791722}
16801723
16811724template <class... _Types>
1682inline _LIBCPP_INLINE_VISIBILITY
1725_LIBCPP_HIDE_FROM_ABI
16831726constexpr bool operator>=(const variant<_Types...>& __lhs,
16841727 const variant<_Types...>& __rhs) {
16851728 using __variant_detail::__visitation::__variant;
......@@ -1692,9 +1735,9 @@ constexpr bool operator>=(const variant<_Types...>& __lhs,
16921735}
16931736
16941737template <class... _Vs>
1695inline _LIBCPP_INLINE_VISIBILITY
1696 _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr void
1697 __throw_if_valueless(_Vs&&... __vs) {
1738_LIBCPP_HIDE_FROM_ABI
1739_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
1740constexpr void __throw_if_valueless(_Vs&&... __vs) {
16981741 const bool __valueless =
16991742 (... || _VSTD::__as_variant(__vs).valueless_by_exception());
17001743 if (__valueless) {
......@@ -1704,10 +1747,10 @@ inline _LIBCPP_INLINE_VISIBILITY
17041747
17051748template <
17061749 class _Visitor, class... _Vs,
1707 typename = void_t<decltype(_VSTD::__as_variant(declval<_Vs>()))...> >
1708inline _LIBCPP_INLINE_VISIBILITY
1709 _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr
1710 decltype(auto) visit(_Visitor&& __visitor, _Vs&&... __vs) {
1750 typename = void_t<decltype(_VSTD::__as_variant(std::declval<_Vs>()))...> >
1751_LIBCPP_HIDE_FROM_ABI
1752_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
1753constexpr decltype(auto) visit(_Visitor&& __visitor, _Vs&&... __vs) {
17111754 using __variant_detail::__visitation::__variant;
17121755 _VSTD::__throw_if_valueless(_VSTD::forward<_Vs>(__vs)...);
17131756 return __variant::__visit_value(_VSTD::forward<_Visitor>(__visitor),
......@@ -1717,10 +1760,10 @@ inline _LIBCPP_INLINE_VISIBILITY
17171760#if _LIBCPP_STD_VER > 17
17181761template <
17191762 class _Rp, class _Visitor, class... _Vs,
1720 typename = void_t<decltype(_VSTD::__as_variant(declval<_Vs>()))...> >
1721inline _LIBCPP_INLINE_VISIBILITY
1722 _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Rp
1723 visit(_Visitor&& __visitor, _Vs&&... __vs) {
1763 typename = void_t<decltype(_VSTD::__as_variant(std::declval<_Vs>()))...> >
1764_LIBCPP_HIDE_FROM_ABI
1765_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
1766constexpr _Rp visit(_Visitor&& __visitor, _Vs&&... __vs) {
17241767 using __variant_detail::__visitation::__variant;
17251768 _VSTD::__throw_if_valueless(_VSTD::forward<_Vs>(__vs)...);
17261769 return __variant::__visit_value<_Rp>(_VSTD::forward<_Visitor>(__visitor),
......@@ -1729,7 +1772,7 @@ inline _LIBCPP_INLINE_VISIBILITY
17291772#endif
17301773
17311774template <class... _Types>
1732inline _LIBCPP_INLINE_VISIBILITY
1775_LIBCPP_HIDE_FROM_ABI
17331776auto swap(variant<_Types...>& __lhs, variant<_Types...>& __rhs)
17341777 noexcept(noexcept(__lhs.swap(__rhs)))
17351778 -> decltype( __lhs.swap(__rhs))
......@@ -1741,7 +1784,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<
17411784 using argument_type = variant<_Types...>;
17421785 using result_type = size_t;
17431786
1744 inline _LIBCPP_INLINE_VISIBILITY
1787 _LIBCPP_HIDE_FROM_ABI
17451788 result_type operator()(const argument_type& __v) const {
17461789 using __variant_detail::__visitation::__variant;
17471790 size_t __res =
......@@ -1749,13 +1792,13 @@ struct _LIBCPP_TEMPLATE_VIS hash<
17491792 ? 299792458 // Random value chosen by the universe upon creation
17501793 : __variant::__visit_alt(
17511794 [](const auto& __alt) {
1752 using __alt_type = __uncvref_t<decltype(__alt)>;
1795 using __alt_type = __remove_cvref_t<decltype(__alt)>;
17531796 using __value_type = remove_const_t<
17541797 typename __alt_type::__value_type>;
17551798 return hash<__value_type>{}(__alt.__value);
17561799 },
17571800 __v);
1758 return __hash_combine(__res, hash<size_t>{}(__v.index()));
1801 return std::__hash_combine(__res, hash<size_t>{}(__v.index()));
17591802 }
17601803};
17611804
......@@ -1763,22 +1806,22 @@ struct _LIBCPP_TEMPLATE_VIS hash<
17631806// type whereas std::get will throw or returning nullptr. This makes it faster than
17641807// std::get.
17651808template <size_t _Ip, class _Vp>
1766inline _LIBCPP_INLINE_VISIBILITY
1809_LIBCPP_HIDE_FROM_ABI
17671810constexpr auto&& __unchecked_get(_Vp&& __v) noexcept {
17681811 using __variant_detail::__access::__variant;
17691812 return __variant::__get_alt<_Ip>(_VSTD::forward<_Vp>(__v)).__value;
17701813}
17711814
17721815template <class _Tp, class... _Types>
1773inline _LIBCPP_INLINE_VISIBILITY
1816_LIBCPP_HIDE_FROM_ABI
17741817constexpr auto&& __unchecked_get(const variant<_Types...>& __v) noexcept {
1775 return __unchecked_get<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
1818 return std::__unchecked_get<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
17761819}
17771820
17781821template <class _Tp, class... _Types>
1779inline _LIBCPP_INLINE_VISIBILITY
1822_LIBCPP_HIDE_FROM_ABI
17801823constexpr auto&& __unchecked_get(variant<_Types...>& __v) noexcept {
1781 return __unchecked_get<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
1824 return std::__unchecked_get<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
17821825}
17831826
17841827#endif // _LIBCPP_STD_VER > 14
......@@ -1787,4 +1830,10 @@ _LIBCPP_END_NAMESPACE_STD
17871830
17881831_LIBCPP_POP_MACROS
17891832
1833#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1834# include <type_traits>
1835# include <typeinfo>
1836# include <utility>
1837#endif
1838
17901839#endif // _LIBCPP_VARIANT
lib/libcxx/include/vector+691-648
......@@ -267,6 +267,13 @@ template <class T, class Allocator, class Predicate>
267267typename vector<T, Allocator>::size_type
268268erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
269269
270
271template<class T>
272 inline constexpr bool is-vector-bool-reference = see below; // exposition only, since C++23
273
274template<class T, class charT> requires is-vector-bool-reference<T> // Since C++23
275 struct formatter<T, charT>;
276
270277} // std
271278
272279*/
......@@ -281,9 +288,11 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
281288#include <__algorithm/unwrap_iter.h>
282289#include <__assert> // all public C++ headers provide the assertion handler
283290#include <__bit_reference>
291#include <__concepts/same_as.h>
284292#include <__config>
285293#include <__debug>
286294#include <__format/enable_insertable.h>
295#include <__format/formatter.h>
287296#include <__functional/hash.h>
288297#include <__functional/unary_function.h>
289298#include <__iterator/advance.h>
......@@ -293,7 +302,13 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
293302#include <__memory/allocate_at_least.h>
294303#include <__memory/pointer_traits.h>
295304#include <__memory/swap_allocator.h>
305#include <__memory/temp_value.h>
306#include <__memory/uninitialized_algorithms.h>
307#include <__memory_resource/polymorphic_allocator.h>
296308#include <__split_buffer>
309#include <__type_traits/is_allocator.h>
310#include <__type_traits/noexcept_move_assign_container.h>
311#include <__utility/exception_guard.h>
297312#include <__utility/forward.h>
298313#include <__utility/move.h>
299314#include <__utility/swap.h>
......@@ -302,17 +317,10 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
302317#include <cstring>
303318#include <iosfwd> // for forward declaration of vector
304319#include <limits>
305#include <memory>
306320#include <stdexcept>
307321#include <type_traits>
308322#include <version>
309323
310#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
311# include <algorithm>
312# include <typeinfo>
313# include <utility>
314#endif
315
316324// standard-mandated includes
317325
318326// [iterator.range]
......@@ -352,20 +360,25 @@ public:
352360 typedef typename __alloc_traits::difference_type difference_type;
353361 typedef typename __alloc_traits::pointer pointer;
354362 typedef typename __alloc_traits::const_pointer const_pointer;
363 // TODO: Implement iterator bounds checking without requiring the global database.
355364 typedef __wrap_iter<pointer> iterator;
356365 typedef __wrap_iter<const_pointer> const_iterator;
357 typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
358 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
366 typedef std::reverse_iterator<iterator> reverse_iterator;
367 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
359368
360369 static_assert((is_same<typename allocator_type::value_type, value_type>::value),
361370 "Allocator::value_type must be same type as value_type");
362371
363 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
372 static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
373 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
374 "original allocator");
375
376 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
364377 vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
365378 {
366 _VSTD::__debug_db_insert_c(this);
379 std::__debug_db_insert_c(this);
367380 }
368 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
381 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(const allocator_type& __a)
369382#if _LIBCPP_STD_VER <= 14
370383 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
371384#else
......@@ -373,20 +386,20 @@ public:
373386#endif
374387 : __end_cap_(nullptr, __a)
375388 {
376 _VSTD::__debug_db_insert_c(this);
389 std::__debug_db_insert_c(this);
377390 }
378 _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n);
391 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n);
379392#if _LIBCPP_STD_VER > 11
380 _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n, const allocator_type& __a);
393 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n, const allocator_type& __a);
381394#endif
382 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __x);
395 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(size_type __n, const value_type& __x);
383396
384397 template <class = __enable_if_t<__is_allocator<_Allocator>::value> >
385 _LIBCPP_CONSTEXPR_AFTER_CXX17
398 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
386399 vector(size_type __n, const value_type& __x, const allocator_type& __a)
387400 : __end_cap_(nullptr, __a)
388401 {
389 _VSTD::__debug_db_insert_c(this);
402 std::__debug_db_insert_c(this);
390403 if (__n > 0)
391404 {
392405 __vallocate(__n);
......@@ -394,68 +407,72 @@ public:
394407 }
395408 }
396409
397 template <class _InputIterator>
398 _LIBCPP_CONSTEXPR_AFTER_CXX17
399 vector(_InputIterator __first,
400 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
401 is_constructible<
402 value_type,
403 typename iterator_traits<_InputIterator>::reference>::value,
404 _InputIterator>::type __last);
405 template <class _InputIterator>
406 _LIBCPP_CONSTEXPR_AFTER_CXX17
407 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
408 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
409 is_constructible<
410 value_type,
411 typename iterator_traits<_InputIterator>::reference>::value>::type* = 0);
412 template <class _ForwardIterator>
413 _LIBCPP_CONSTEXPR_AFTER_CXX17
414 vector(_ForwardIterator __first,
415 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
416 is_constructible<
417 value_type,
418 typename iterator_traits<_ForwardIterator>::reference>::value,
419 _ForwardIterator>::type __last);
420 template <class _ForwardIterator>
421 _LIBCPP_CONSTEXPR_AFTER_CXX17
422 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
423 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
424 is_constructible<
425 value_type,
426 typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0);
410 template <class _InputIterator,
411 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
412 is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value,
413 int> = 0>
414 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_InputIterator __first, _InputIterator __last);
415 template <class _InputIterator,
416 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
417 is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value,
418 int> = 0>
419 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
420 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a);
421
422 template <
423 class _ForwardIterator,
424 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
425 is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value,
426 int> = 0>
427 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_ForwardIterator __first, _ForwardIterator __last);
428
429 template <class _ForwardIterator,
430 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
431 is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value,
432 int> = 0>
433 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
434 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a);
427435
428 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
429 ~vector()
430 {
431 __annotate_delete();
432 std::__debug_db_erase_c(this);
436private:
437 class __destroy_vector {
438 public:
439 _LIBCPP_CONSTEXPR __destroy_vector(vector& __vec) : __vec_(__vec) {}
433440
434 if (this->__begin_ != nullptr)
435 {
436 __clear();
437 __alloc_traits::deallocate(__alloc(), this->__begin_, capacity());
441 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void operator()() {
442 __vec_.__annotate_delete();
443 std::__debug_db_erase_c(std::addressof(__vec_));
444
445 if (__vec_.__begin_ != nullptr) {
446 __vec_.__clear();
447 __alloc_traits::deallocate(__vec_.__alloc(), __vec_.__begin_, __vec_.capacity());
448 }
438449 }
439 }
440450
441 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __x);
442 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __x, const __type_identity_t<allocator_type>& __a);
443 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
451 private:
452 vector& __vec_;
453 };
454
455public:
456 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~vector() { __destroy_vector(*this)(); }
457
458 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(const vector& __x);
459 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(const vector& __x, const __type_identity_t<allocator_type>& __a);
460 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
444461 vector& operator=(const vector& __x);
445462
446463#ifndef _LIBCPP_CXX03_LANG
447 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
464 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
448465 vector(initializer_list<value_type> __il);
449466
450 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
467 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
451468 vector(initializer_list<value_type> __il, const allocator_type& __a);
452469
453 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
470 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
454471 vector& operator=(initializer_list<value_type> __il)
455472 {assign(__il.begin(), __il.end()); return *this;}
456473#endif // !_LIBCPP_CXX03_LANG
457474
458 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
475 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
459476 vector(vector&& __x)
460477#if _LIBCPP_STD_VER > 14
461478 noexcept;
......@@ -463,174 +480,163 @@ public:
463480 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
464481#endif
465482
466 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
483 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
467484 vector(vector&& __x, const __type_identity_t<allocator_type>& __a);
468 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
485 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
469486 vector& operator=(vector&& __x)
470487 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
471488
472 template <class _InputIterator>
473 _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
474 is_constructible<
475 value_type,
476 typename iterator_traits<_InputIterator>::reference>::value,
477 void
478 >::type
479 assign(_InputIterator __first, _InputIterator __last);
480 template <class _ForwardIterator>
481 _LIBCPP_CONSTEXPR_AFTER_CXX17
482 typename enable_if
483 <
484 __is_cpp17_forward_iterator<_ForwardIterator>::value &&
485 is_constructible<
486 value_type,
487 typename iterator_traits<_ForwardIterator>::reference>::value,
488 void
489 >::type
490 assign(_ForwardIterator __first, _ForwardIterator __last);
489 template <class _InputIterator,
490 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
491 is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value,
492 int> = 0>
493 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(_InputIterator __first, _InputIterator __last);
494 template <
495 class _ForwardIterator,
496 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
497 is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value,
498 int> = 0>
499 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(_ForwardIterator __first, _ForwardIterator __last);
491500
492 _LIBCPP_CONSTEXPR_AFTER_CXX17 void assign(size_type __n, const_reference __u);
501 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const_reference __u);
493502
494503#ifndef _LIBCPP_CXX03_LANG
495 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
504 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
496505 void assign(initializer_list<value_type> __il)
497506 {assign(__il.begin(), __il.end());}
498507#endif
499508
500 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
509 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
501510 allocator_type get_allocator() const _NOEXCEPT
502511 {return this->__alloc();}
503512
504 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT;
505 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT;
506 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT;
507 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT;
513 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT;
514 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT;
515 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT;
516 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT;
508517
509 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
518 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
510519 reverse_iterator rbegin() _NOEXCEPT
511520 {return reverse_iterator(end());}
512 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
521 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
513522 const_reverse_iterator rbegin() const _NOEXCEPT
514523 {return const_reverse_iterator(end());}
515 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
524 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
516525 reverse_iterator rend() _NOEXCEPT
517526 {return reverse_iterator(begin());}
518 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
527 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
519528 const_reverse_iterator rend() const _NOEXCEPT
520529 {return const_reverse_iterator(begin());}
521530
522 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
531 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
523532 const_iterator cbegin() const _NOEXCEPT
524533 {return begin();}
525 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
534 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
526535 const_iterator cend() const _NOEXCEPT
527536 {return end();}
528 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
537 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
529538 const_reverse_iterator crbegin() const _NOEXCEPT
530539 {return rbegin();}
531 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
540 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
532541 const_reverse_iterator crend() const _NOEXCEPT
533542 {return rend();}
534543
535 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
544 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
536545 size_type size() const _NOEXCEPT
537546 {return static_cast<size_type>(this->__end_ - this->__begin_);}
538 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
547 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
539548 size_type capacity() const _NOEXCEPT
540549 {return static_cast<size_type>(__end_cap() - this->__begin_);}
541 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
550 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
542551 bool empty() const _NOEXCEPT
543552 {return this->__begin_ == this->__end_;}
544 _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT;
545 _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n);
546 _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT;
553 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT;
554 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n);
555 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT;
547556
548 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) _NOEXCEPT;
549 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const _NOEXCEPT;
550 _LIBCPP_CONSTEXPR_AFTER_CXX17 reference at(size_type __n);
551 _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference at(size_type __n) const;
557 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __n) _NOEXCEPT;
558 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __n) const _NOEXCEPT;
559 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference at(size_type __n);
560 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __n) const;
552561
553 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference front() _NOEXCEPT
562 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() _NOEXCEPT
554563 {
555564 _LIBCPP_ASSERT(!empty(), "front() called on an empty vector");
556565 return *this->__begin_;
557566 }
558 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT
567 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const _NOEXCEPT
559568 {
560569 _LIBCPP_ASSERT(!empty(), "front() called on an empty vector");
561570 return *this->__begin_;
562571 }
563 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference back() _NOEXCEPT
572 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() _NOEXCEPT
564573 {
565574 _LIBCPP_ASSERT(!empty(), "back() called on an empty vector");
566575 return *(this->__end_ - 1);
567576 }
568 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference back() const _NOEXCEPT
577 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT
569578 {
570579 _LIBCPP_ASSERT(!empty(), "back() called on an empty vector");
571580 return *(this->__end_ - 1);
572581 }
573582
574 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
583 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
575584 value_type* data() _NOEXCEPT
576 {return _VSTD::__to_address(this->__begin_);}
585 {return std::__to_address(this->__begin_);}
577586
578 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
587 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
579588 const value_type* data() const _NOEXCEPT
580 {return _VSTD::__to_address(this->__begin_);}
589 {return std::__to_address(this->__begin_);}
581590
582 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
591 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(const_reference __x);
583592
584 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x);
593 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x);
585594
586595 template <class... _Args>
587 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
596 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
588597#if _LIBCPP_STD_VER > 14
589598 reference emplace_back(_Args&&... __args);
590599#else
591600 void emplace_back(_Args&&... __args);
592601#endif
593602
594 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
603 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
595604 void pop_back();
596605
597 _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, const_reference __x);
606 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, const_reference __x);
598607
599 _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, value_type&& __x);
608 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, value_type&& __x);
600609 template <class... _Args>
601 _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator emplace(const_iterator __position, _Args&&... __args);
602
603 _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, size_type __n, const_reference __x);
604 template <class _InputIterator>
605 _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
606 is_constructible<
607 value_type,
608 typename iterator_traits<_InputIterator>::reference>::value,
609 iterator
610 >::type
611 insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
612 template <class _ForwardIterator>
613 _LIBCPP_CONSTEXPR_AFTER_CXX17
614 typename enable_if
615 <
616 __is_cpp17_forward_iterator<_ForwardIterator>::value &&
617 is_constructible<
618 value_type,
619 typename iterator_traits<_ForwardIterator>::reference>::value,
620 iterator
621 >::type
622 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
610 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __position, _Args&&... __args);
611
612 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
613 iterator insert(const_iterator __position, size_type __n, const_reference __x);
614
615 template <class _InputIterator,
616 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
617 is_constructible< value_type, typename iterator_traits<_InputIterator>::reference>::value,
618 int> = 0>
619 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
620 insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
621
622 template <
623 class _ForwardIterator,
624 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
625 is_constructible< value_type, typename iterator_traits<_ForwardIterator>::reference>::value,
626 int> = 0>
627 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
628 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
623629
624630#ifndef _LIBCPP_CXX03_LANG
625 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
631 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
626632 iterator insert(const_iterator __position, initializer_list<value_type> __il)
627633 {return insert(__position, __il.begin(), __il.end());}
628634#endif
629635
630 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);
631 _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __first, const_iterator __last);
636 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __position);
637 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last);
632638
633 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
639 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
634640 void clear() _NOEXCEPT
635641 {
636642 size_type __old_size = size();
......@@ -639,10 +645,10 @@ public:
639645 std::__debug_db_invalidate_all(this);
640646 }
641647
642 _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __sz);
643 _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __sz, const_reference __x);
648 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void resize(size_type __sz);
649 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void resize(size_type __sz, const_reference __x);
644650
645 _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(vector&)
651 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(vector&)
646652#if _LIBCPP_STD_VER >= 14
647653 _NOEXCEPT;
648654#else
......@@ -650,7 +656,7 @@ public:
650656 __is_nothrow_swappable<allocator_type>::value);
651657#endif
652658
653 _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const;
659 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const;
654660
655661#ifdef _LIBCPP_ENABLE_DEBUG_MODE
656662
......@@ -667,7 +673,7 @@ private:
667673 __compressed_pair<pointer, allocator_type> __end_cap_ =
668674 __compressed_pair<pointer, allocator_type>(nullptr, __default_init_tag());
669675
670 _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last);
676 _LIBCPP_HIDE_FROM_ABI void __invalidate_iterators_past(pointer __new_last);
671677
672678 // Allocate space for __n objects
673679 // throws length_error if __n > max_size()
......@@ -676,7 +682,7 @@ private:
676682 // Precondition: __n > 0
677683 // Postcondition: capacity() >= __n
678684 // Postcondition: size() == 0
679 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) {
685 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) {
680686 if (__n > max_size())
681687 __throw_length_error();
682688 auto __allocation = std::__allocate_at_least(__alloc(), __n);
......@@ -686,33 +692,30 @@ private:
686692 __annotate_new(0);
687693 }
688694
689 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vdeallocate() _NOEXCEPT;
690 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
691 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n);
692 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
695 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vdeallocate() _NOEXCEPT;
696 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __recommend(size_type __new_size) const;
697 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n);
698 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
693699 void __construct_at_end(size_type __n, const_reference __x);
694 template <class _ForwardIterator>
695 _LIBCPP_CONSTEXPR_AFTER_CXX17
696 typename enable_if
697 <
698 __is_cpp17_forward_iterator<_ForwardIterator>::value,
699 void
700 >::type
701 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n);
702 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n);
703 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n, const_reference __x);
704 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
705 iterator __make_iter(pointer __p) _NOEXCEPT;
706 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
707 const_iterator __make_iter(const_pointer __p) const _NOEXCEPT;
708 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v);
709 _LIBCPP_CONSTEXPR_AFTER_CXX17 pointer __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p);
710 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_range(pointer __from_s, pointer __from_e, pointer __to);
711 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, true_type)
700
701 template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value, int> = 0>
702 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
703 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n);
704
705 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n);
706 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n, const_reference __x);
707 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
708 iterator __make_iter(pointer __p) _NOEXCEPT { return iterator(this, __p); }
709 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
710 const_iterator __make_iter(const_pointer __p) const _NOEXCEPT { return const_iterator(this, __p); }
711 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v);
712 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p);
713 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_range(pointer __from_s, pointer __from_e, pointer __to);
714 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, true_type)
712715 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
713 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, false_type)
716 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, false_type)
714717 _NOEXCEPT_(__alloc_traits::is_always_equal::value);
715 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
718 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
716719 void __destruct_at_end(pointer __new_last) _NOEXCEPT
717720 {
718721 if (!__libcpp_is_constant_evaluated())
......@@ -723,11 +726,11 @@ private:
723726 }
724727
725728 template <class _Up>
726 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
729 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
727730 inline void __push_back_slow_path(_Up&& __x);
728731
729732 template <class... _Args>
730 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
733 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
731734 inline void __emplace_back_slow_path(_Args&&... __args);
732735
733736 // The following functions are no-ops outside of AddressSanitizer mode.
......@@ -735,7 +738,7 @@ private:
735738 // may not meet the AddressSanitizer alignment constraints.
736739 // See the documentation for __sanitizer_annotate_contiguous_container for more details.
737740#ifndef _LIBCPP_HAS_NO_ASAN
738 _LIBCPP_CONSTEXPR_AFTER_CXX17
741 _LIBCPP_CONSTEXPR_SINCE_CXX20
739742 void __annotate_contiguous_container(const void *__beg, const void *__end,
740743 const void *__old_mid,
741744 const void *__new_mid) const
......@@ -745,30 +748,30 @@ private:
745748 __sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid);
746749 }
747750#else
748 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
751 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
749752 void __annotate_contiguous_container(const void*, const void*, const void*,
750753 const void*) const _NOEXCEPT {}
751754#endif
752 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
755 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
753756 void __annotate_new(size_type __current_size) const _NOEXCEPT {
754757 __annotate_contiguous_container(data(), data() + capacity(),
755758 data() + capacity(), data() + __current_size);
756759 }
757760
758 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
761 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
759762 void __annotate_delete() const _NOEXCEPT {
760763 __annotate_contiguous_container(data(), data() + capacity(),
761764 data() + size(), data() + capacity());
762765 }
763766
764 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
767 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
765768 void __annotate_increase(size_type __n) const _NOEXCEPT
766769 {
767770 __annotate_contiguous_container(data(), data() + capacity(),
768771 data() + size(), data() + size() + __n);
769772 }
770773
771 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
774 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
772775 void __annotate_shrink(size_type __old_size) const _NOEXCEPT
773776 {
774777 __annotate_contiguous_container(data(), data() + capacity(),
......@@ -776,14 +779,14 @@ private:
776779 }
777780
778781 struct _ConstructTransaction {
779 _LIBCPP_CONSTEXPR_AFTER_CXX17
782 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
780783 explicit _ConstructTransaction(vector &__v, size_type __n)
781784 : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) {
782785#ifndef _LIBCPP_HAS_NO_ASAN
783786 __v_.__annotate_increase(__n);
784787#endif
785788 }
786 _LIBCPP_CONSTEXPR_AFTER_CXX17 ~_ConstructTransaction() {
789 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() {
787790 __v_.__end_ = __pos_;
788791#ifndef _LIBCPP_HAS_NO_ASAN
789792 if (__pos_ != __new_end_) {
......@@ -802,44 +805,44 @@ private:
802805 };
803806
804807 template <class ..._Args>
805 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
808 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
806809 void __construct_one_at_end(_Args&& ...__args) {
807810 _ConstructTransaction __tx(*this, 1);
808 __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_),
809 _VSTD::forward<_Args>(__args)...);
811 __alloc_traits::construct(this->__alloc(), std::__to_address(__tx.__pos_),
812 std::forward<_Args>(__args)...);
810813 ++__tx.__pos_;
811814 }
812815
813 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
816 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
814817 allocator_type& __alloc() _NOEXCEPT
815818 {return this->__end_cap_.second();}
816 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
819 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
817820 const allocator_type& __alloc() const _NOEXCEPT
818821 {return this->__end_cap_.second();}
819 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
822 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
820823 pointer& __end_cap() _NOEXCEPT
821824 {return this->__end_cap_.first();}
822 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
825 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
823826 const pointer& __end_cap() const _NOEXCEPT
824827 {return this->__end_cap_.first();}
825828
826 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
829 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
827830 void __clear() _NOEXCEPT {__base_destruct_at_end(this->__begin_);}
828831
829 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
832 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
830833 void __base_destruct_at_end(pointer __new_last) _NOEXCEPT {
831834 pointer __soon_to_be_end = this->__end_;
832835 while (__new_last != __soon_to_be_end)
833 __alloc_traits::destroy(__alloc(), _VSTD::__to_address(--__soon_to_be_end));
836 __alloc_traits::destroy(__alloc(), std::__to_address(--__soon_to_be_end));
834837 this->__end_ = __new_last;
835838 }
836839
837 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
840 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
838841 void __copy_assign_alloc(const vector& __c)
839842 {__copy_assign_alloc(__c, integral_constant<bool,
840843 __alloc_traits::propagate_on_container_copy_assignment::value>());}
841844
842 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
845 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
843846 void __move_assign_alloc(vector& __c)
844847 _NOEXCEPT_(
845848 !__alloc_traits::propagate_on_container_move_assignment::value ||
......@@ -849,15 +852,15 @@ private:
849852
850853 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
851854 void __throw_length_error() const {
852 _VSTD::__throw_length_error("vector");
855 std::__throw_length_error("vector");
853856 }
854857
855858 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
856859 void __throw_out_of_range() const {
857 _VSTD::__throw_out_of_range("vector");
860 std::__throw_out_of_range("vector");
858861 }
859862
860 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
863 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
861864 void __copy_assign_alloc(const vector& __c, true_type)
862865 {
863866 if (__alloc() != __c.__alloc())
......@@ -869,18 +872,18 @@ private:
869872 __alloc() = __c.__alloc();
870873 }
871874
872 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
875 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
873876 void __copy_assign_alloc(const vector&, false_type)
874877 {}
875878
876 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
879 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
877880 void __move_assign_alloc(vector& __c, true_type)
878881 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
879882 {
880 __alloc() = _VSTD::move(__c.__alloc());
883 __alloc() = std::move(__c.__alloc());
881884 }
882885
883 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
886 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
884887 void __move_assign_alloc(vector&, false_type)
885888 _NOEXCEPT
886889 {}
......@@ -905,7 +908,7 @@ vector(_InputIterator, _InputIterator, _Alloc)
905908#endif
906909
907910template <class _Tp, class _Allocator>
908_LIBCPP_CONSTEXPR_AFTER_CXX17
911_LIBCPP_CONSTEXPR_SINCE_CXX20
909912void
910913vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v)
911914{
......@@ -914,16 +917,16 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
914917 __v.__begin_ = std::__uninitialized_allocator_move_if_noexcept(
915918 __alloc(), _RevIter(__end_), _RevIter(__begin_), _RevIter(__v.__begin_))
916919 .base();
917 _VSTD::swap(this->__begin_, __v.__begin_);
918 _VSTD::swap(this->__end_, __v.__end_);
919 _VSTD::swap(this->__end_cap(), __v.__end_cap());
920 std::swap(this->__begin_, __v.__begin_);
921 std::swap(this->__end_, __v.__end_);
922 std::swap(this->__end_cap(), __v.__end_cap());
920923 __v.__first_ = __v.__begin_;
921924 __annotate_new(size());
922925 std::__debug_db_invalidate_all(this);
923926}
924927
925928template <class _Tp, class _Allocator>
926_LIBCPP_CONSTEXPR_AFTER_CXX17
929_LIBCPP_CONSTEXPR_SINCE_CXX20
927930typename vector<_Tp, _Allocator>::pointer
928931vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p)
929932{
......@@ -934,9 +937,9 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
934937 __alloc(), _RevIter(__p), _RevIter(__begin_), _RevIter(__v.__begin_))
935938 .base();
936939 __v.__end_ = std::__uninitialized_allocator_move_if_noexcept(__alloc(), __p, __end_, __v.__end_);
937 _VSTD::swap(this->__begin_, __v.__begin_);
938 _VSTD::swap(this->__end_, __v.__end_);
939 _VSTD::swap(this->__end_cap(), __v.__end_cap());
940 std::swap(this->__begin_, __v.__begin_);
941 std::swap(this->__end_, __v.__end_);
942 std::swap(this->__end_cap(), __v.__end_cap());
940943 __v.__first_ = __v.__begin_;
941944 __annotate_new(size());
942945 std::__debug_db_invalidate_all(this);
......@@ -944,7 +947,7 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
944947}
945948
946949template <class _Tp, class _Allocator>
947_LIBCPP_CONSTEXPR_AFTER_CXX17
950_LIBCPP_CONSTEXPR_SINCE_CXX20
948951void
949952vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT
950953{
......@@ -957,18 +960,18 @@ vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT
957960}
958961
959962template <class _Tp, class _Allocator>
960_LIBCPP_CONSTEXPR_AFTER_CXX17
963_LIBCPP_CONSTEXPR_SINCE_CXX20
961964typename vector<_Tp, _Allocator>::size_type
962965vector<_Tp, _Allocator>::max_size() const _NOEXCEPT
963966{
964 return _VSTD::min<size_type>(__alloc_traits::max_size(this->__alloc()),
967 return std::min<size_type>(__alloc_traits::max_size(this->__alloc()),
965968 numeric_limits<difference_type>::max());
966969}
967970
968971// Precondition: __new_size > capacity()
969972template <class _Tp, class _Allocator>
970_LIBCPP_CONSTEXPR_AFTER_CXX17
971inline _LIBCPP_INLINE_VISIBILITY
973_LIBCPP_CONSTEXPR_SINCE_CXX20
974inline _LIBCPP_HIDE_FROM_ABI
972975typename vector<_Tp, _Allocator>::size_type
973976vector<_Tp, _Allocator>::__recommend(size_type __new_size) const
974977{
......@@ -978,7 +981,7 @@ vector<_Tp, _Allocator>::__recommend(size_type __new_size) const
978981 const size_type __cap = capacity();
979982 if (__cap >= __ms / 2)
980983 return __ms;
981 return _VSTD::max<size_type>(2 * __cap, __new_size);
984 return std::max<size_type>(2 * __cap, __new_size);
982985}
983986
984987// Default constructs __n objects starting at __end_
......@@ -987,14 +990,14 @@ vector<_Tp, _Allocator>::__recommend(size_type __new_size) const
987990// Precondition: size() + __n <= capacity()
988991// Postcondition: size() == size() + __n
989992template <class _Tp, class _Allocator>
990_LIBCPP_CONSTEXPR_AFTER_CXX17
993_LIBCPP_CONSTEXPR_SINCE_CXX20
991994void
992995vector<_Tp, _Allocator>::__construct_at_end(size_type __n)
993996{
994997 _ConstructTransaction __tx(*this, __n);
995998 const_pointer __new_end = __tx.__new_end_;
996999 for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) {
997 __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__pos));
1000 __alloc_traits::construct(this->__alloc(), std::__to_address(__pos));
9981001 }
9991002}
10001003
......@@ -1005,7 +1008,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n)
10051008// Postcondition: size() == old size() + __n
10061009// Postcondition: [i] == __x for all i in [size() - __n, __n)
10071010template <class _Tp, class _Allocator>
1008_LIBCPP_CONSTEXPR_AFTER_CXX17
1011_LIBCPP_CONSTEXPR_SINCE_CXX20
10091012inline
10101013void
10111014vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
......@@ -1013,18 +1016,13 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
10131016 _ConstructTransaction __tx(*this, __n);
10141017 const_pointer __new_end = __tx.__new_end_;
10151018 for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) {
1016 __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__pos), __x);
1019 __alloc_traits::construct(this->__alloc(), std::__to_address(__pos), __x);
10171020 }
10181021}
10191022
10201023template <class _Tp, class _Allocator>
1021template <class _ForwardIterator>
1022_LIBCPP_CONSTEXPR_AFTER_CXX17
1023typename enable_if
1024<
1025 __is_cpp17_forward_iterator<_ForwardIterator>::value,
1026 void
1027>::type
1024template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value, int> >
1025_LIBCPP_CONSTEXPR_SINCE_CXX20 void
10281026vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n)
10291027{
10301028 _ConstructTransaction __tx(*this, __n);
......@@ -1036,7 +1034,7 @@ vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIt
10361034// Postcondition: size() == size() + __n
10371035// Exception safety: strong.
10381036template <class _Tp, class _Allocator>
1039_LIBCPP_CONSTEXPR_AFTER_CXX17
1037_LIBCPP_CONSTEXPR_SINCE_CXX20
10401038void
10411039vector<_Tp, _Allocator>::__append(size_type __n)
10421040{
......@@ -1056,7 +1054,7 @@ vector<_Tp, _Allocator>::__append(size_type __n)
10561054// Postcondition: size() == size() + __n
10571055// Exception safety: strong.
10581056template <class _Tp, class _Allocator>
1059_LIBCPP_CONSTEXPR_AFTER_CXX17
1057_LIBCPP_CONSTEXPR_SINCE_CXX20
10601058void
10611059vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)
10621060{
......@@ -1072,152 +1070,160 @@ vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)
10721070}
10731071
10741072template <class _Tp, class _Allocator>
1075_LIBCPP_CONSTEXPR_AFTER_CXX17
1073_LIBCPP_CONSTEXPR_SINCE_CXX20
10761074vector<_Tp, _Allocator>::vector(size_type __n)
10771075{
1078 _VSTD::__debug_db_insert_c(this);
1076 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1077 std::__debug_db_insert_c(this);
10791078 if (__n > 0)
10801079 {
10811080 __vallocate(__n);
10821081 __construct_at_end(__n);
10831082 }
1083 __guard.__complete();
10841084}
10851085
10861086#if _LIBCPP_STD_VER > 11
10871087template <class _Tp, class _Allocator>
1088_LIBCPP_CONSTEXPR_AFTER_CXX17
1088_LIBCPP_CONSTEXPR_SINCE_CXX20
10891089vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)
10901090 : __end_cap_(nullptr, __a)
10911091{
1092 _VSTD::__debug_db_insert_c(this);
1092 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1093 std::__debug_db_insert_c(this);
10931094 if (__n > 0)
10941095 {
10951096 __vallocate(__n);
10961097 __construct_at_end(__n);
10971098 }
1099 __guard.__complete();
10981100}
10991101#endif
11001102
11011103template <class _Tp, class _Allocator>
1102_LIBCPP_CONSTEXPR_AFTER_CXX17
1104_LIBCPP_CONSTEXPR_SINCE_CXX20
11031105vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x)
11041106{
1105 _VSTD::__debug_db_insert_c(this);
1107 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1108 std::__debug_db_insert_c(this);
11061109 if (__n > 0)
11071110 {
11081111 __vallocate(__n);
11091112 __construct_at_end(__n, __x);
11101113 }
1114 __guard.__complete();
11111115}
11121116
11131117template <class _Tp, class _Allocator>
1114template <class _InputIterator>
1115_LIBCPP_CONSTEXPR_AFTER_CXX17
1116vector<_Tp, _Allocator>::vector(_InputIterator __first,
1117 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
1118 is_constructible<
1119 value_type,
1120 typename iterator_traits<_InputIterator>::reference>::value,
1121 _InputIterator>::type __last)
1122{
1123 _VSTD::__debug_db_insert_c(this);
1118template <class _InputIterator, __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
1119 is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value,
1120 int> >
1121_LIBCPP_CONSTEXPR_SINCE_CXX20
1122vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last)
1123{
1124 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1125 std::__debug_db_insert_c(this);
11241126 for (; __first != __last; ++__first)
11251127 emplace_back(*__first);
1128 __guard.__complete();
11261129}
11271130
11281131template <class _Tp, class _Allocator>
1129template <class _InputIterator>
1130_LIBCPP_CONSTEXPR_AFTER_CXX17
1131vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
1132 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
1133 is_constructible<
1134 value_type,
1135 typename iterator_traits<_InputIterator>::reference>::value>::type*)
1132template <class _InputIterator, __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
1133 is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value,
1134 int> >
1135_LIBCPP_CONSTEXPR_SINCE_CXX20
1136vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a)
11361137 : __end_cap_(nullptr, __a)
11371138{
1138 _VSTD::__debug_db_insert_c(this);
1139 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1140 std::__debug_db_insert_c(this);
11391141 for (; __first != __last; ++__first)
11401142 emplace_back(*__first);
1143 __guard.__complete();
11411144}
11421145
11431146template <class _Tp, class _Allocator>
1144template <class _ForwardIterator>
1145_LIBCPP_CONSTEXPR_AFTER_CXX17
1146vector<_Tp, _Allocator>::vector(_ForwardIterator __first,
1147 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
1148 is_constructible<
1149 value_type,
1150 typename iterator_traits<_ForwardIterator>::reference>::value,
1151 _ForwardIterator>::type __last)
1152{
1153 _VSTD::__debug_db_insert_c(this);
1154 size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
1147template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
1148 is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value,
1149 int> >
1150_LIBCPP_CONSTEXPR_SINCE_CXX20
1151vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last)
1152{
1153 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1154 std::__debug_db_insert_c(this);
1155 size_type __n = static_cast<size_type>(std::distance(__first, __last));
11551156 if (__n > 0)
11561157 {
11571158 __vallocate(__n);
11581159 __construct_at_end(__first, __last, __n);
11591160 }
1161 __guard.__complete();
11601162}
11611163
11621164template <class _Tp, class _Allocator>
1163template <class _ForwardIterator>
1164_LIBCPP_CONSTEXPR_AFTER_CXX17
1165vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
1166 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
1167 is_constructible<
1168 value_type,
1169 typename iterator_traits<_ForwardIterator>::reference>::value>::type*)
1165template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
1166 is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value,
1167 int> >
1168_LIBCPP_CONSTEXPR_SINCE_CXX20
1169vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a)
11701170 : __end_cap_(nullptr, __a)
11711171{
1172 _VSTD::__debug_db_insert_c(this);
1173 size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
1172 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1173 std::__debug_db_insert_c(this);
1174 size_type __n = static_cast<size_type>(std::distance(__first, __last));
11741175 if (__n > 0)
11751176 {
11761177 __vallocate(__n);
11771178 __construct_at_end(__first, __last, __n);
11781179 }
1180 __guard.__complete();
11791181}
11801182
11811183template <class _Tp, class _Allocator>
1182_LIBCPP_CONSTEXPR_AFTER_CXX17
1184_LIBCPP_CONSTEXPR_SINCE_CXX20
11831185vector<_Tp, _Allocator>::vector(const vector& __x)
11841186 : __end_cap_(nullptr, __alloc_traits::select_on_container_copy_construction(__x.__alloc()))
11851187{
1186 _VSTD::__debug_db_insert_c(this);
1188 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1189 std::__debug_db_insert_c(this);
11871190 size_type __n = __x.size();
11881191 if (__n > 0)
11891192 {
11901193 __vallocate(__n);
11911194 __construct_at_end(__x.__begin_, __x.__end_, __n);
11921195 }
1196 __guard.__complete();
11931197}
11941198
11951199template <class _Tp, class _Allocator>
1196_LIBCPP_CONSTEXPR_AFTER_CXX17
1200_LIBCPP_CONSTEXPR_SINCE_CXX20
11971201vector<_Tp, _Allocator>::vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
11981202 : __end_cap_(nullptr, __a)
11991203{
1200 _VSTD::__debug_db_insert_c(this);
1204 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1205 std::__debug_db_insert_c(this);
12011206 size_type __n = __x.size();
12021207 if (__n > 0)
12031208 {
12041209 __vallocate(__n);
12051210 __construct_at_end(__x.__begin_, __x.__end_, __n);
12061211 }
1212 __guard.__complete();
12071213}
12081214
12091215template <class _Tp, class _Allocator>
1210_LIBCPP_CONSTEXPR_AFTER_CXX17
1211inline _LIBCPP_INLINE_VISIBILITY
1216_LIBCPP_CONSTEXPR_SINCE_CXX20
1217inline _LIBCPP_HIDE_FROM_ABI
12121218vector<_Tp, _Allocator>::vector(vector&& __x)
12131219#if _LIBCPP_STD_VER > 14
12141220 noexcept
12151221#else
12161222 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
12171223#endif
1218 : __end_cap_(nullptr, _VSTD::move(__x.__alloc()))
1224 : __end_cap_(nullptr, std::move(__x.__alloc()))
12191225{
1220 _VSTD::__debug_db_insert_c(this);
1226 std::__debug_db_insert_c(this);
12211227 std::__debug_db_swap(this, std::addressof(__x));
12221228 this->__begin_ = __x.__begin_;
12231229 this->__end_ = __x.__end_;
......@@ -1226,12 +1232,12 @@ vector<_Tp, _Allocator>::vector(vector&& __x)
12261232}
12271233
12281234template <class _Tp, class _Allocator>
1229_LIBCPP_CONSTEXPR_AFTER_CXX17
1230inline _LIBCPP_INLINE_VISIBILITY
1235_LIBCPP_CONSTEXPR_SINCE_CXX20
1236inline _LIBCPP_HIDE_FROM_ABI
12311237vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_type>& __a)
12321238 : __end_cap_(nullptr, __a)
12331239{
1234 _VSTD::__debug_db_insert_c(this);
1240 std::__debug_db_insert_c(this);
12351241 if (__a == __x.__alloc())
12361242 {
12371243 this->__begin_ = __x.__begin_;
......@@ -1243,44 +1249,50 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_
12431249 else
12441250 {
12451251 typedef move_iterator<iterator> _Ip;
1252 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
12461253 assign(_Ip(__x.begin()), _Ip(__x.end()));
1254 __guard.__complete();
12471255 }
12481256}
12491257
12501258#ifndef _LIBCPP_CXX03_LANG
12511259
12521260template <class _Tp, class _Allocator>
1253_LIBCPP_CONSTEXPR_AFTER_CXX17
1254inline _LIBCPP_INLINE_VISIBILITY
1261_LIBCPP_CONSTEXPR_SINCE_CXX20
1262inline _LIBCPP_HIDE_FROM_ABI
12551263vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
12561264{
1257 _VSTD::__debug_db_insert_c(this);
1265 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1266 std::__debug_db_insert_c(this);
12581267 if (__il.size() > 0)
12591268 {
12601269 __vallocate(__il.size());
12611270 __construct_at_end(__il.begin(), __il.end(), __il.size());
12621271 }
1272 __guard.__complete();
12631273}
12641274
12651275template <class _Tp, class _Allocator>
1266_LIBCPP_CONSTEXPR_AFTER_CXX17
1267inline _LIBCPP_INLINE_VISIBILITY
1276_LIBCPP_CONSTEXPR_SINCE_CXX20
1277inline _LIBCPP_HIDE_FROM_ABI
12681278vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
12691279 : __end_cap_(nullptr, __a)
12701280{
1271 _VSTD::__debug_db_insert_c(this);
1281 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1282 std::__debug_db_insert_c(this);
12721283 if (__il.size() > 0)
12731284 {
12741285 __vallocate(__il.size());
12751286 __construct_at_end(__il.begin(), __il.end(), __il.size());
12761287 }
1288 __guard.__complete();
12771289}
12781290
12791291#endif // _LIBCPP_CXX03_LANG
12801292
12811293template <class _Tp, class _Allocator>
1282_LIBCPP_CONSTEXPR_AFTER_CXX17
1283inline _LIBCPP_INLINE_VISIBILITY
1294_LIBCPP_CONSTEXPR_SINCE_CXX20
1295inline _LIBCPP_HIDE_FROM_ABI
12841296vector<_Tp, _Allocator>&
12851297vector<_Tp, _Allocator>::operator=(vector&& __x)
12861298 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
......@@ -1291,7 +1303,7 @@ vector<_Tp, _Allocator>::operator=(vector&& __x)
12911303}
12921304
12931305template <class _Tp, class _Allocator>
1294_LIBCPP_CONSTEXPR_AFTER_CXX17
1306_LIBCPP_CONSTEXPR_SINCE_CXX20
12951307void
12961308vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)
12971309 _NOEXCEPT_(__alloc_traits::is_always_equal::value)
......@@ -1306,7 +1318,7 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)
13061318}
13071319
13081320template <class _Tp, class _Allocator>
1309_LIBCPP_CONSTEXPR_AFTER_CXX17
1321_LIBCPP_CONSTEXPR_SINCE_CXX20
13101322void
13111323vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
13121324 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
......@@ -1321,12 +1333,12 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
13211333}
13221334
13231335template <class _Tp, class _Allocator>
1324_LIBCPP_CONSTEXPR_AFTER_CXX17
1325inline _LIBCPP_INLINE_VISIBILITY
1336_LIBCPP_CONSTEXPR_SINCE_CXX20
1337inline _LIBCPP_HIDE_FROM_ABI
13261338vector<_Tp, _Allocator>&
13271339vector<_Tp, _Allocator>::operator=(const vector& __x)
13281340{
1329 if (this != _VSTD::addressof(__x))
1341 if (this != std::addressof(__x))
13301342 {
13311343 __copy_assign_alloc(__x);
13321344 assign(__x.__begin_, __x.__end_);
......@@ -1335,13 +1347,10 @@ vector<_Tp, _Allocator>::operator=(const vector& __x)
13351347}
13361348
13371349template <class _Tp, class _Allocator>
1338template <class _InputIterator>
1339_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
1340 is_constructible<
1341 _Tp,
1342 typename iterator_traits<_InputIterator>::reference>::value,
1343 void
1344>::type
1350template <class _InputIterator, __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
1351 is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value,
1352 int> >
1353_LIBCPP_CONSTEXPR_SINCE_CXX20 void
13451354vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
13461355{
13471356 clear();
......@@ -1350,19 +1359,13 @@ vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
13501359}
13511360
13521361template <class _Tp, class _Allocator>
1353template <class _ForwardIterator>
1354_LIBCPP_CONSTEXPR_AFTER_CXX17
1355typename enable_if
1356<
1357 __is_cpp17_forward_iterator<_ForwardIterator>::value &&
1358 is_constructible<
1359 _Tp,
1360 typename iterator_traits<_ForwardIterator>::reference>::value,
1361 void
1362>::type
1362template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
1363 is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value,
1364 int> >
1365_LIBCPP_CONSTEXPR_SINCE_CXX20 void
13631366vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)
13641367{
1365 size_type __new_size = static_cast<size_type>(_VSTD::distance(__first, __last));
1368 size_type __new_size = static_cast<size_type>(std::distance(__first, __last));
13661369 if (__new_size <= capacity())
13671370 {
13681371 _ForwardIterator __mid = __last;
......@@ -1371,9 +1374,9 @@ vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __las
13711374 {
13721375 __growing = true;
13731376 __mid = __first;
1374 _VSTD::advance(__mid, size());
1377 std::advance(__mid, size());
13751378 }
1376 pointer __m = _VSTD::copy(__first, __mid, this->__begin_);
1379 pointer __m = std::copy(__first, __mid, this->__begin_);
13771380 if (__growing)
13781381 __construct_at_end(__mid, __last, __new_size - size());
13791382 else
......@@ -1389,14 +1392,14 @@ vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __las
13891392}
13901393
13911394template <class _Tp, class _Allocator>
1392_LIBCPP_CONSTEXPR_AFTER_CXX17
1395_LIBCPP_CONSTEXPR_SINCE_CXX20
13931396void
13941397vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)
13951398{
13961399 if (__n <= capacity())
13971400 {
13981401 size_type __s = size();
1399 _VSTD::fill_n(this->__begin_, _VSTD::min(__n, __s), __u);
1402 std::fill_n(this->__begin_, std::min(__n, __s), __u);
14001403 if (__n > __s)
14011404 __construct_at_end(__n - __s, __u);
14021405 else
......@@ -1412,44 +1415,44 @@ vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)
14121415}
14131416
14141417template <class _Tp, class _Allocator>
1415_LIBCPP_CONSTEXPR_AFTER_CXX17
1416inline _LIBCPP_INLINE_VISIBILITY
1418_LIBCPP_CONSTEXPR_SINCE_CXX20
1419inline _LIBCPP_HIDE_FROM_ABI
14171420typename vector<_Tp, _Allocator>::iterator
14181421vector<_Tp, _Allocator>::begin() _NOEXCEPT
14191422{
1420 return iterator(this, this->__begin_);
1423 return __make_iter(this->__begin_);
14211424}
14221425
14231426template <class _Tp, class _Allocator>
1424_LIBCPP_CONSTEXPR_AFTER_CXX17
1425inline _LIBCPP_INLINE_VISIBILITY
1427_LIBCPP_CONSTEXPR_SINCE_CXX20
1428inline _LIBCPP_HIDE_FROM_ABI
14261429typename vector<_Tp, _Allocator>::const_iterator
14271430vector<_Tp, _Allocator>::begin() const _NOEXCEPT
14281431{
1429 return const_iterator(this, this->__begin_);
1432 return __make_iter(this->__begin_);
14301433}
14311434
14321435template <class _Tp, class _Allocator>
1433_LIBCPP_CONSTEXPR_AFTER_CXX17
1434inline _LIBCPP_INLINE_VISIBILITY
1436_LIBCPP_CONSTEXPR_SINCE_CXX20
1437inline _LIBCPP_HIDE_FROM_ABI
14351438typename vector<_Tp, _Allocator>::iterator
14361439vector<_Tp, _Allocator>::end() _NOEXCEPT
14371440{
1438 return iterator(this, this->__end_);
1441 return __make_iter(this->__end_);
14391442}
14401443
14411444template <class _Tp, class _Allocator>
1442_LIBCPP_CONSTEXPR_AFTER_CXX17
1443inline _LIBCPP_INLINE_VISIBILITY
1445_LIBCPP_CONSTEXPR_SINCE_CXX20
1446inline _LIBCPP_HIDE_FROM_ABI
14441447typename vector<_Tp, _Allocator>::const_iterator
14451448vector<_Tp, _Allocator>::end() const _NOEXCEPT
14461449{
1447 return const_iterator(this, this->__end_);
1450 return __make_iter(this->__end_);
14481451}
14491452
14501453template <class _Tp, class _Allocator>
1451_LIBCPP_CONSTEXPR_AFTER_CXX17
1452inline _LIBCPP_INLINE_VISIBILITY
1454_LIBCPP_CONSTEXPR_SINCE_CXX20
1455inline _LIBCPP_HIDE_FROM_ABI
14531456typename vector<_Tp, _Allocator>::reference
14541457vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT
14551458{
......@@ -1458,8 +1461,8 @@ vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT
14581461}
14591462
14601463template <class _Tp, class _Allocator>
1461_LIBCPP_CONSTEXPR_AFTER_CXX17
1462inline _LIBCPP_INLINE_VISIBILITY
1464_LIBCPP_CONSTEXPR_SINCE_CXX20
1465inline _LIBCPP_HIDE_FROM_ABI
14631466typename vector<_Tp, _Allocator>::const_reference
14641467vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT
14651468{
......@@ -1468,7 +1471,7 @@ vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT
14681471}
14691472
14701473template <class _Tp, class _Allocator>
1471_LIBCPP_CONSTEXPR_AFTER_CXX17
1474_LIBCPP_CONSTEXPR_SINCE_CXX20
14721475typename vector<_Tp, _Allocator>::reference
14731476vector<_Tp, _Allocator>::at(size_type __n)
14741477{
......@@ -1478,7 +1481,7 @@ vector<_Tp, _Allocator>::at(size_type __n)
14781481}
14791482
14801483template <class _Tp, class _Allocator>
1481_LIBCPP_CONSTEXPR_AFTER_CXX17
1484_LIBCPP_CONSTEXPR_SINCE_CXX20
14821485typename vector<_Tp, _Allocator>::const_reference
14831486vector<_Tp, _Allocator>::at(size_type __n) const
14841487{
......@@ -1488,7 +1491,7 @@ vector<_Tp, _Allocator>::at(size_type __n) const
14881491}
14891492
14901493template <class _Tp, class _Allocator>
1491_LIBCPP_CONSTEXPR_AFTER_CXX17
1494_LIBCPP_CONSTEXPR_SINCE_CXX20
14921495void
14931496vector<_Tp, _Allocator>::reserve(size_type __n)
14941497{
......@@ -1503,7 +1506,7 @@ vector<_Tp, _Allocator>::reserve(size_type __n)
15031506}
15041507
15051508template <class _Tp, class _Allocator>
1506_LIBCPP_CONSTEXPR_AFTER_CXX17
1509_LIBCPP_CONSTEXPR_SINCE_CXX20
15071510void
15081511vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
15091512{
......@@ -1527,21 +1530,21 @@ vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
15271530
15281531template <class _Tp, class _Allocator>
15291532template <class _Up>
1530_LIBCPP_CONSTEXPR_AFTER_CXX17
1533_LIBCPP_CONSTEXPR_SINCE_CXX20
15311534void
15321535vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x)
15331536{
15341537 allocator_type& __a = this->__alloc();
15351538 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);
1536 // __v.push_back(_VSTD::forward<_Up>(__x));
1537 __alloc_traits::construct(__a, _VSTD::__to_address(__v.__end_), _VSTD::forward<_Up>(__x));
1539 // __v.push_back(std::forward<_Up>(__x));
1540 __alloc_traits::construct(__a, std::__to_address(__v.__end_), std::forward<_Up>(__x));
15381541 __v.__end_++;
15391542 __swap_out_circular_buffer(__v);
15401543}
15411544
15421545template <class _Tp, class _Allocator>
1543_LIBCPP_CONSTEXPR_AFTER_CXX17
1544inline _LIBCPP_INLINE_VISIBILITY
1546_LIBCPP_CONSTEXPR_SINCE_CXX20
1547inline _LIBCPP_HIDE_FROM_ABI
15451548void
15461549vector<_Tp, _Allocator>::push_back(const_reference __x)
15471550{
......@@ -1554,36 +1557,36 @@ vector<_Tp, _Allocator>::push_back(const_reference __x)
15541557}
15551558
15561559template <class _Tp, class _Allocator>
1557_LIBCPP_CONSTEXPR_AFTER_CXX17
1558inline _LIBCPP_INLINE_VISIBILITY
1560_LIBCPP_CONSTEXPR_SINCE_CXX20
1561inline _LIBCPP_HIDE_FROM_ABI
15591562void
15601563vector<_Tp, _Allocator>::push_back(value_type&& __x)
15611564{
15621565 if (this->__end_ < this->__end_cap())
15631566 {
1564 __construct_one_at_end(_VSTD::move(__x));
1567 __construct_one_at_end(std::move(__x));
15651568 }
15661569 else
1567 __push_back_slow_path(_VSTD::move(__x));
1570 __push_back_slow_path(std::move(__x));
15681571}
15691572
15701573template <class _Tp, class _Allocator>
15711574template <class... _Args>
1572_LIBCPP_CONSTEXPR_AFTER_CXX17
1575_LIBCPP_CONSTEXPR_SINCE_CXX20
15731576void
15741577vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args)
15751578{
15761579 allocator_type& __a = this->__alloc();
15771580 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);
1578// __v.emplace_back(_VSTD::forward<_Args>(__args)...);
1579 __alloc_traits::construct(__a, _VSTD::__to_address(__v.__end_), _VSTD::forward<_Args>(__args)...);
1581// __v.emplace_back(std::forward<_Args>(__args)...);
1582 __alloc_traits::construct(__a, std::__to_address(__v.__end_), std::forward<_Args>(__args)...);
15801583 __v.__end_++;
15811584 __swap_out_circular_buffer(__v);
15821585}
15831586
15841587template <class _Tp, class _Allocator>
15851588template <class... _Args>
1586_LIBCPP_CONSTEXPR_AFTER_CXX17
1589_LIBCPP_CONSTEXPR_SINCE_CXX20
15871590inline
15881591#if _LIBCPP_STD_VER > 14
15891592typename vector<_Tp, _Allocator>::reference
......@@ -1594,17 +1597,17 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)
15941597{
15951598 if (this->__end_ < this->__end_cap())
15961599 {
1597 __construct_one_at_end(_VSTD::forward<_Args>(__args)...);
1600 __construct_one_at_end(std::forward<_Args>(__args)...);
15981601 }
15991602 else
1600 __emplace_back_slow_path(_VSTD::forward<_Args>(__args)...);
1603 __emplace_back_slow_path(std::forward<_Args>(__args)...);
16011604#if _LIBCPP_STD_VER > 14
16021605 return this->back();
16031606#endif
16041607}
16051608
16061609template <class _Tp, class _Allocator>
1607_LIBCPP_CONSTEXPR_AFTER_CXX17
1610_LIBCPP_CONSTEXPR_SINCE_CXX20
16081611inline
16091612void
16101613vector<_Tp, _Allocator>::pop_back()
......@@ -1614,47 +1617,45 @@ vector<_Tp, _Allocator>::pop_back()
16141617}
16151618
16161619template <class _Tp, class _Allocator>
1617_LIBCPP_CONSTEXPR_AFTER_CXX17
1618inline _LIBCPP_INLINE_VISIBILITY
1620_LIBCPP_CONSTEXPR_SINCE_CXX20
1621inline _LIBCPP_HIDE_FROM_ABI
16191622typename vector<_Tp, _Allocator>::iterator
16201623vector<_Tp, _Allocator>::erase(const_iterator __position)
16211624{
1622 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
1625 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__position)) == this,
16231626 "vector::erase(iterator) called with an iterator not referring to this vector");
16241627 _LIBCPP_ASSERT(__position != end(),
16251628 "vector::erase(iterator) called with a non-dereferenceable iterator");
16261629 difference_type __ps = __position - cbegin();
16271630 pointer __p = this->__begin_ + __ps;
1628 this->__destruct_at_end(_VSTD::move(__p + 1, this->__end_, __p));
1631 this->__destruct_at_end(std::move(__p + 1, this->__end_, __p));
16291632 if (!__libcpp_is_constant_evaluated())
16301633 this->__invalidate_iterators_past(__p - 1);
1631 iterator __r = iterator(this, __p);
1632 return __r;
1634 return __make_iter(__p);
16331635}
16341636
16351637template <class _Tp, class _Allocator>
1636_LIBCPP_CONSTEXPR_AFTER_CXX17
1638_LIBCPP_CONSTEXPR_SINCE_CXX20
16371639typename vector<_Tp, _Allocator>::iterator
16381640vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last)
16391641{
1640 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__first)) == this,
1642 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__first)) == this,
16411643 "vector::erase(iterator, iterator) called with an iterator not referring to this vector");
1642 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__last)) == this,
1644 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__last)) == this,
16431645 "vector::erase(iterator, iterator) called with an iterator not referring to this vector");
16441646
16451647 _LIBCPP_ASSERT(__first <= __last, "vector::erase(first, last) called with invalid range");
16461648 pointer __p = this->__begin_ + (__first - begin());
16471649 if (__first != __last) {
1648 this->__destruct_at_end(_VSTD::move(__p + (__last - __first), this->__end_, __p));
1650 this->__destruct_at_end(std::move(__p + (__last - __first), this->__end_, __p));
16491651 if (!__libcpp_is_constant_evaluated())
16501652 this->__invalidate_iterators_past(__p - 1);
16511653 }
1652 iterator __r = iterator(this, __p);
1653 return __r;
1654 return __make_iter(__p);
16541655}
16551656
16561657template <class _Tp, class _Allocator>
1657_LIBCPP_CONSTEXPR_AFTER_CXX17
1658_LIBCPP_CONSTEXPR_SINCE_CXX20
16581659void
16591660vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to)
16601661{
......@@ -1666,19 +1667,19 @@ vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointe
16661667 for (pointer __pos = __tx.__pos_; __i < __from_e;
16671668 ++__i, (void) ++__pos, __tx.__pos_ = __pos) {
16681669 __alloc_traits::construct(this->__alloc(),
1669 _VSTD::__to_address(__pos),
1670 _VSTD::move(*__i));
1670 std::__to_address(__pos),
1671 std::move(*__i));
16711672 }
16721673 }
1673 _VSTD::move_backward(__from_s, __from_s + __n, __old_last);
1674 std::move_backward(__from_s, __from_s + __n, __old_last);
16741675}
16751676
16761677template <class _Tp, class _Allocator>
1677_LIBCPP_CONSTEXPR_AFTER_CXX17
1678_LIBCPP_CONSTEXPR_SINCE_CXX20
16781679typename vector<_Tp, _Allocator>::iterator
16791680vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
16801681{
1681 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
1682 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__position)) == this,
16821683 "vector::insert(iterator, x) called with an iterator not referring to this vector");
16831684 pointer __p = this->__begin_ + (__position - begin());
16841685 // We can't compare unrelated pointers inside constant expressions
......@@ -1704,77 +1705,77 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
17041705 __v.push_back(__x);
17051706 __p = __swap_out_circular_buffer(__v, __p);
17061707 }
1707 return iterator(this, __p);
1708 return __make_iter(__p);
17081709}
17091710
17101711template <class _Tp, class _Allocator>
1711_LIBCPP_CONSTEXPR_AFTER_CXX17
1712_LIBCPP_CONSTEXPR_SINCE_CXX20
17121713typename vector<_Tp, _Allocator>::iterator
17131714vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)
17141715{
1715 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
1716 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__position)) == this,
17161717 "vector::insert(iterator, x) called with an iterator not referring to this vector");
17171718 pointer __p = this->__begin_ + (__position - begin());
17181719 if (this->__end_ < this->__end_cap())
17191720 {
17201721 if (__p == this->__end_)
17211722 {
1722 __construct_one_at_end(_VSTD::move(__x));
1723 __construct_one_at_end(std::move(__x));
17231724 }
17241725 else
17251726 {
17261727 __move_range(__p, this->__end_, __p + 1);
1727 *__p = _VSTD::move(__x);
1728 *__p = std::move(__x);
17281729 }
17291730 }
17301731 else
17311732 {
17321733 allocator_type& __a = this->__alloc();
17331734 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a);
1734 __v.push_back(_VSTD::move(__x));
1735 __v.push_back(std::move(__x));
17351736 __p = __swap_out_circular_buffer(__v, __p);
17361737 }
1737 return iterator(this, __p);
1738 return __make_iter(__p);
17381739}
17391740
17401741template <class _Tp, class _Allocator>
17411742template <class... _Args>
1742_LIBCPP_CONSTEXPR_AFTER_CXX17
1743_LIBCPP_CONSTEXPR_SINCE_CXX20
17431744typename vector<_Tp, _Allocator>::iterator
17441745vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
17451746{
1746 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
1747 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__position)) == this,
17471748 "vector::emplace(iterator, x) called with an iterator not referring to this vector");
17481749 pointer __p = this->__begin_ + (__position - begin());
17491750 if (this->__end_ < this->__end_cap())
17501751 {
17511752 if (__p == this->__end_)
17521753 {
1753 __construct_one_at_end(_VSTD::forward<_Args>(__args)...);
1754 __construct_one_at_end(std::forward<_Args>(__args)...);
17541755 }
17551756 else
17561757 {
1757 __temp_value<value_type, _Allocator> __tmp(this->__alloc(), _VSTD::forward<_Args>(__args)...);
1758 __temp_value<value_type, _Allocator> __tmp(this->__alloc(), std::forward<_Args>(__args)...);
17581759 __move_range(__p, this->__end_, __p + 1);
1759 *__p = _VSTD::move(__tmp.get());
1760 *__p = std::move(__tmp.get());
17601761 }
17611762 }
17621763 else
17631764 {
17641765 allocator_type& __a = this->__alloc();
17651766 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a);
1766 __v.emplace_back(_VSTD::forward<_Args>(__args)...);
1767 __v.emplace_back(std::forward<_Args>(__args)...);
17671768 __p = __swap_out_circular_buffer(__v, __p);
17681769 }
1769 return iterator(this, __p);
1770 return __make_iter(__p);
17701771}
17711772
17721773template <class _Tp, class _Allocator>
1773_LIBCPP_CONSTEXPR_AFTER_CXX17
1774_LIBCPP_CONSTEXPR_SINCE_CXX20
17741775typename vector<_Tp, _Allocator>::iterator
17751776vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x)
17761777{
1777 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
1778 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__position)) == this,
17781779 "vector::insert(iterator, n, x) called with an iterator not referring to this vector");
17791780 pointer __p = this->__begin_ + (__position - begin());
17801781 if (__n > 0)
......@@ -1796,7 +1797,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_
17961797 const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
17971798 if (__p <= __xr && __xr < this->__end_)
17981799 __xr += __old_n;
1799 _VSTD::fill_n(__p, __n, *__xr);
1800 std::fill_n(__p, __n, *__xr);
18001801 }
18011802 }
18021803 else
......@@ -1807,20 +1808,17 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_
18071808 __p = __swap_out_circular_buffer(__v, __p);
18081809 }
18091810 }
1810 return iterator(this, __p);
1811 return __make_iter(__p);
18111812}
18121813
18131814template <class _Tp, class _Allocator>
1814template <class _InputIterator>
1815_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
1816 is_constructible<
1817 _Tp,
1818 typename iterator_traits<_InputIterator>::reference>::value,
1819 typename vector<_Tp, _Allocator>::iterator
1820>::type
1815template <class _InputIterator, __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
1816 is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value,
1817 int> >
1818_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
18211819vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
18221820{
1823 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
1821 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__position)) == this,
18241822 "vector::insert(iterator, range) called with an iterator not referring to this vector");
18251823 difference_type __off = __position - begin();
18261824 pointer __p = this->__begin_ + __off;
......@@ -1847,34 +1845,28 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __firs
18471845 }
18481846 catch (...)
18491847 {
1850 erase(iterator(this, __old_last), end());
1848 erase(__make_iter(__old_last), end());
18511849 throw;
18521850 }
18531851#endif // _LIBCPP_NO_EXCEPTIONS
18541852 }
1855 __p = _VSTD::rotate(__p, __old_last, this->__end_);
1856 insert(iterator(this, __p), _VSTD::make_move_iterator(__v.begin()),
1857 _VSTD::make_move_iterator(__v.end()));
1853 __p = std::rotate(__p, __old_last, this->__end_);
1854 insert(__make_iter(__p), std::make_move_iterator(__v.begin()),
1855 std::make_move_iterator(__v.end()));
18581856 return begin() + __off;
18591857}
18601858
18611859template <class _Tp, class _Allocator>
1862template <class _ForwardIterator>
1863_LIBCPP_CONSTEXPR_AFTER_CXX17
1864typename enable_if
1865<
1866 __is_cpp17_forward_iterator<_ForwardIterator>::value &&
1867 is_constructible<
1868 _Tp,
1869 typename iterator_traits<_ForwardIterator>::reference>::value,
1870 typename vector<_Tp, _Allocator>::iterator
1871>::type
1860template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
1861 is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value,
1862 int> >
1863_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
18721864vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last)
18731865{
1874 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
1866 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__position)) == this,
18751867 "vector::insert(iterator, range) called with an iterator not referring to this vector");
18761868 pointer __p = this->__begin_ + (__position - begin());
1877 difference_type __n = _VSTD::distance(__first, __last);
1869 difference_type __n = std::distance(__first, __last);
18781870 if (__n > 0)
18791871 {
18801872 if (__n <= this->__end_cap() - this->__end_)
......@@ -1887,14 +1879,14 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __fi
18871879 {
18881880 __m = __first;
18891881 difference_type __diff = this->__end_ - __p;
1890 _VSTD::advance(__m, __diff);
1882 std::advance(__m, __diff);
18911883 __construct_at_end(__m, __last, __n - __diff);
18921884 __n = __dx;
18931885 }
18941886 if (__n > 0)
18951887 {
18961888 __move_range(__p, __old_last, __p + __old_n);
1897 _VSTD::copy(__first, __m, __p);
1889 std::copy(__first, __m, __p);
18981890 }
18991891 }
19001892 else
......@@ -1905,11 +1897,11 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __fi
19051897 __p = __swap_out_circular_buffer(__v, __p);
19061898 }
19071899 }
1908 return iterator(this, __p);
1900 return __make_iter(__p);
19091901}
19101902
19111903template <class _Tp, class _Allocator>
1912_LIBCPP_CONSTEXPR_AFTER_CXX17
1904_LIBCPP_CONSTEXPR_SINCE_CXX20
19131905void
19141906vector<_Tp, _Allocator>::resize(size_type __sz)
19151907{
......@@ -1921,7 +1913,7 @@ vector<_Tp, _Allocator>::resize(size_type __sz)
19211913}
19221914
19231915template <class _Tp, class _Allocator>
1924_LIBCPP_CONSTEXPR_AFTER_CXX17
1916_LIBCPP_CONSTEXPR_SINCE_CXX20
19251917void
19261918vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)
19271919{
......@@ -1933,7 +1925,7 @@ vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)
19331925}
19341926
19351927template <class _Tp, class _Allocator>
1936_LIBCPP_CONSTEXPR_AFTER_CXX17
1928_LIBCPP_CONSTEXPR_SINCE_CXX20
19371929void
19381930vector<_Tp, _Allocator>::swap(vector& __x)
19391931#if _LIBCPP_STD_VER >= 14
......@@ -1947,16 +1939,16 @@ vector<_Tp, _Allocator>::swap(vector& __x)
19471939 this->__alloc() == __x.__alloc(),
19481940 "vector::swap: Either propagate_on_container_swap must be true"
19491941 " or the allocators must compare equal");
1950 _VSTD::swap(this->__begin_, __x.__begin_);
1951 _VSTD::swap(this->__end_, __x.__end_);
1952 _VSTD::swap(this->__end_cap(), __x.__end_cap());
1953 _VSTD::__swap_allocator(this->__alloc(), __x.__alloc(),
1942 std::swap(this->__begin_, __x.__begin_);
1943 std::swap(this->__end_, __x.__end_);
1944 std::swap(this->__end_cap(), __x.__end_cap());
1945 std::__swap_allocator(this->__alloc(), __x.__alloc(),
19541946 integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>());
19551947 std::__debug_db_swap(this, std::addressof(__x));
19561948}
19571949
19581950template <class _Tp, class _Allocator>
1959_LIBCPP_CONSTEXPR_AFTER_CXX17
1951_LIBCPP_CONSTEXPR_SINCE_CXX20
19601952bool
19611953vector<_Tp, _Allocator>::__invariants() const
19621954{
......@@ -2012,7 +2004,7 @@ vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __
20122004#endif // _LIBCPP_ENABLE_DEBUG_MODE
20132005
20142006template <class _Tp, class _Allocator>
2015inline _LIBCPP_INLINE_VISIBILITY
2007inline _LIBCPP_HIDE_FROM_ABI
20162008void
20172009vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) {
20182010#ifdef _LIBCPP_ENABLE_DEBUG_MODE
......@@ -2023,7 +2015,7 @@ vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) {
20232015 if (__i->base() > __new_last) {
20242016 (*__p)->__c_ = nullptr;
20252017 if (--__c->end_ != __p)
2026 _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
2018 std::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
20272019 }
20282020 }
20292021 __get_db()->unlock();
......@@ -2059,11 +2051,11 @@ public:
20592051 typedef __bit_iterator<vector, true> const_pointer;
20602052 typedef pointer iterator;
20612053 typedef const_pointer const_iterator;
2062 typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
2063 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
2054 typedef std::reverse_iterator<iterator> reverse_iterator;
2055 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
20642056
20652057private:
2066 typedef typename __rebind_alloc_helper<__alloc_traits, __storage_type>::type __storage_allocator;
2058 typedef __rebind_alloc<__alloc_traits, __storage_type> __storage_allocator;
20672059 typedef allocator_traits<__storage_allocator> __storage_traits;
20682060 typedef typename __storage_traits::pointer __storage_pointer;
20692061 typedef typename __storage_traits::const_pointer __const_storage_pointer;
......@@ -2079,81 +2071,99 @@ public:
20792071 typedef __bit_const_reference<vector> const_reference;
20802072#endif
20812073private:
2082 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2074 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
20832075 size_type& __cap() _NOEXCEPT
20842076 {return __cap_alloc_.first();}
2085 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2077 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
20862078 const size_type& __cap() const _NOEXCEPT
20872079 {return __cap_alloc_.first();}
2088 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2080 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
20892081 __storage_allocator& __alloc() _NOEXCEPT
20902082 {return __cap_alloc_.second();}
2091 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2083 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
20922084 const __storage_allocator& __alloc() const _NOEXCEPT
20932085 {return __cap_alloc_.second();}
20942086
20952087 static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
20962088
2097 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2089 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
20982090 static size_type __internal_cap_to_external(size_type __n) _NOEXCEPT
20992091 {return __n * __bits_per_word;}
2100 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2092 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
21012093 static size_type __external_cap_to_internal(size_type __n) _NOEXCEPT
21022094 {return (__n - 1) / __bits_per_word + 1;}
21032095
21042096public:
2105 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2097 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
21062098 vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
21072099
2108 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(const allocator_type& __a)
2100 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(const allocator_type& __a)
21092101#if _LIBCPP_STD_VER <= 14
21102102 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);
21112103#else
21122104 _NOEXCEPT;
21132105#endif
2114 _LIBCPP_CONSTEXPR_AFTER_CXX17 ~vector();
2115 _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n);
2106
2107private:
2108 class __destroy_vector {
2109 public:
2110 _LIBCPP_CONSTEXPR __destroy_vector(vector& __vec) : __vec_(__vec) {}
2111
2112 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void operator()() {
2113 if (__vec_.__begin_ != nullptr)
2114 __storage_traits::deallocate(__vec_.__alloc(), __vec_.__begin_, __vec_.__cap());
2115 std::__debug_db_invalidate_all(this);
2116 }
2117
2118 private:
2119 vector& __vec_;
2120 };
2121
2122public:
2123 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~vector() { __destroy_vector(*this)(); }
2124
2125 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(size_type __n);
21162126#if _LIBCPP_STD_VER > 11
2117 _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n, const allocator_type& __a);
2127 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(size_type __n, const allocator_type& __a);
21182128#endif
2119 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __v);
2120 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __v, const allocator_type& __a);
2129 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(size_type __n, const value_type& __v);
2130 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(size_type __n, const value_type& __v, const allocator_type& __a);
21212131 template <class _InputIterator>
2122 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_InputIterator __first, _InputIterator __last,
2132 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_InputIterator __first, _InputIterator __last,
21232133 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type* = 0);
21242134 template <class _InputIterator>
2125 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
2135 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
21262136 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type* = 0);
21272137 template <class _ForwardIterator>
2128 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_ForwardIterator __first, _ForwardIterator __last,
2138 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_ForwardIterator __first, _ForwardIterator __last,
21292139 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);
21302140 template <class _ForwardIterator>
2131 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
2141 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
21322142 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);
21332143
2134 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __v);
2135 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __v, const allocator_type& __a);
2136 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector& operator=(const vector& __v);
2144 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(const vector& __v);
2145 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(const vector& __v, const allocator_type& __a);
2146 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector& operator=(const vector& __v);
21372147
21382148#ifndef _LIBCPP_CXX03_LANG
2139 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(initializer_list<value_type> __il);
2140 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(initializer_list<value_type> __il, const allocator_type& __a);
2149 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(initializer_list<value_type> __il);
2150 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(initializer_list<value_type> __il, const allocator_type& __a);
21412151
2142 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2152 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
21432153 vector& operator=(initializer_list<value_type> __il)
21442154 {assign(__il.begin(), __il.end()); return *this;}
21452155
21462156#endif // !_LIBCPP_CXX03_LANG
21472157
2148 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2158 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
21492159 vector(vector&& __v)
21502160#if _LIBCPP_STD_VER > 14
21512161 noexcept;
21522162#else
21532163 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
21542164#endif
2155 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(vector&& __v, const __type_identity_t<allocator_type>& __a);
2156 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2165 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(vector&& __v, const __type_identity_t<allocator_type>& __a);
2166 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
21572167 vector& operator=(vector&& __v)
21582168 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
21592169
......@@ -2161,162 +2171,162 @@ public:
21612171 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
21622172 void
21632173 >::type
2164 _LIBCPP_CONSTEXPR_AFTER_CXX17 assign(_InputIterator __first, _InputIterator __last);
2174 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 assign(_InputIterator __first, _InputIterator __last);
21652175 template <class _ForwardIterator>
21662176 typename enable_if
21672177 <
21682178 __is_cpp17_forward_iterator<_ForwardIterator>::value,
21692179 void
21702180 >::type
2171 _LIBCPP_CONSTEXPR_AFTER_CXX17 assign(_ForwardIterator __first, _ForwardIterator __last);
2181 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 assign(_ForwardIterator __first, _ForwardIterator __last);
21722182
2173 _LIBCPP_CONSTEXPR_AFTER_CXX17 void assign(size_type __n, const value_type& __x);
2183 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void assign(size_type __n, const value_type& __x);
21742184
21752185#ifndef _LIBCPP_CXX03_LANG
2176 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2186 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
21772187 void assign(initializer_list<value_type> __il)
21782188 {assign(__il.begin(), __il.end());}
21792189#endif
21802190
2181 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 allocator_type get_allocator() const _NOEXCEPT
2191 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator_type get_allocator() const _NOEXCEPT
21822192 {return allocator_type(this->__alloc());}
21832193
2184 _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT;
2185 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2194 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT;
2195 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
21862196 size_type capacity() const _NOEXCEPT
21872197 {return __internal_cap_to_external(__cap());}
2188 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2198 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
21892199 size_type size() const _NOEXCEPT
21902200 {return __size_;}
2191 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2201 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
21922202 bool empty() const _NOEXCEPT
21932203 {return __size_ == 0;}
2194 _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n);
2195 _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT;
2204 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reserve(size_type __n);
2205 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT;
21962206
2197 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2207 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
21982208 iterator begin() _NOEXCEPT
21992209 {return __make_iter(0);}
2200 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2210 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
22012211 const_iterator begin() const _NOEXCEPT
22022212 {return __make_iter(0);}
2203 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2213 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
22042214 iterator end() _NOEXCEPT
22052215 {return __make_iter(__size_);}
2206 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2216 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
22072217 const_iterator end() const _NOEXCEPT
22082218 {return __make_iter(__size_);}
22092219
2210 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2220 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
22112221 reverse_iterator rbegin() _NOEXCEPT
22122222 {return reverse_iterator(end());}
2213 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2223 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
22142224 const_reverse_iterator rbegin() const _NOEXCEPT
22152225 {return const_reverse_iterator(end());}
2216 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2226 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
22172227 reverse_iterator rend() _NOEXCEPT
22182228 {return reverse_iterator(begin());}
2219 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2229 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
22202230 const_reverse_iterator rend() const _NOEXCEPT
22212231 {return const_reverse_iterator(begin());}
22222232
2223 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2233 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
22242234 const_iterator cbegin() const _NOEXCEPT
22252235 {return __make_iter(0);}
2226 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2236 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
22272237 const_iterator cend() const _NOEXCEPT
22282238 {return __make_iter(__size_);}
2229 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2239 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
22302240 const_reverse_iterator crbegin() const _NOEXCEPT
22312241 {return rbegin();}
2232 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2242 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
22332243 const_reverse_iterator crend() const _NOEXCEPT
22342244 {return rend();}
22352245
2236 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator[](size_type __n) {return __make_ref(__n);}
2237 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference operator[](size_type __n) const {return __make_ref(__n);}
2238 reference at(size_type __n);
2239 const_reference at(size_type __n) const;
2246 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator[](size_type __n) {return __make_ref(__n);}
2247 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference operator[](size_type __n) const {return __make_ref(__n);}
2248 _LIBCPP_HIDE_FROM_ABI reference at(size_type __n);
2249 _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __n) const;
22402250
2241 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference front() {return __make_ref(0);}
2242 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference front() const {return __make_ref(0);}
2243 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference back() {return __make_ref(__size_ - 1);}
2244 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference back() const {return __make_ref(__size_ - 1);}
2251 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference front() {return __make_ref(0);}
2252 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference front() const {return __make_ref(0);}
2253 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference back() {return __make_ref(__size_ - 1);}
2254 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference back() const {return __make_ref(__size_ - 1);}
22452255
2246 _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(const value_type& __x);
2256 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void push_back(const value_type& __x);
22472257#if _LIBCPP_STD_VER > 11
22482258 template <class... _Args>
22492259#if _LIBCPP_STD_VER > 14
2250 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference emplace_back(_Args&&... __args)
2260 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference emplace_back(_Args&&... __args)
22512261#else
2252 _LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args)
2262 _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args)
22532263#endif
22542264 {
2255 push_back ( value_type ( _VSTD::forward<_Args>(__args)... ));
2265 push_back ( value_type ( std::forward<_Args>(__args)... ));
22562266#if _LIBCPP_STD_VER > 14
22572267 return this->back();
22582268#endif
22592269 }
22602270#endif
22612271
2262 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void pop_back() {--__size_;}
2272 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void pop_back() {--__size_;}
22632273
22642274#if _LIBCPP_STD_VER > 11
22652275 template <class... _Args>
2266 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator emplace(const_iterator __position, _Args&&... __args)
2267 { return insert ( __position, value_type ( _VSTD::forward<_Args>(__args)... )); }
2276 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator emplace(const_iterator __position, _Args&&... __args)
2277 { return insert ( __position, value_type ( std::forward<_Args>(__args)... )); }
22682278#endif
22692279
2270 _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, const value_type& __x);
2271 _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, size_type __n, const value_type& __x);
2280 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __position, const value_type& __x);
2281 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __position, size_type __n, const value_type& __x);
22722282 template <class _InputIterator>
22732283 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
22742284 iterator
22752285 >::type
2276 _LIBCPP_CONSTEXPR_AFTER_CXX17 insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
2286 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
22772287 template <class _ForwardIterator>
22782288 typename enable_if
22792289 <
22802290 __is_cpp17_forward_iterator<_ForwardIterator>::value,
22812291 iterator
22822292 >::type
2283 _LIBCPP_CONSTEXPR_AFTER_CXX17 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
2293 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
22842294
22852295#ifndef _LIBCPP_CXX03_LANG
2286 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2296 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
22872297 iterator insert(const_iterator __position, initializer_list<value_type> __il)
22882298 {return insert(__position, __il.begin(), __il.end());}
22892299#endif
22902300
2291 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __position);
2292 _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __first, const_iterator __last);
2301 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __position);
2302 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __first, const_iterator __last);
22932303
2294 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2304 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
22952305 void clear() _NOEXCEPT {__size_ = 0;}
22962306
2297 _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(vector&)
2307 _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(vector&)
22982308#if _LIBCPP_STD_VER >= 14
22992309 _NOEXCEPT;
23002310#else
23012311 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
23022312 __is_nothrow_swappable<allocator_type>::value);
23032313#endif
2304 _LIBCPP_CONSTEXPR_AFTER_CXX17 static void swap(reference __x, reference __y) _NOEXCEPT { _VSTD::swap(__x, __y); }
2314 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void swap(reference __x, reference __y) _NOEXCEPT { std::swap(__x, __y); }
23052315
2306 _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __sz, value_type __x = false);
2307 _LIBCPP_CONSTEXPR_AFTER_CXX17 void flip() _NOEXCEPT;
2316 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __sz, value_type __x = false);
2317 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void flip() _NOEXCEPT;
23082318
2309 _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const;
2319 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __invariants() const;
23102320
23112321private:
23122322 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
23132323 void __throw_length_error() const {
2314 _VSTD::__throw_length_error("vector");
2324 std::__throw_length_error("vector");
23152325 }
23162326
23172327 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
23182328 void __throw_out_of_range() const {
2319 _VSTD::__throw_out_of_range("vector");
2329 std::__throw_out_of_range("vector");
23202330 }
23212331
23222332 // Allocate space for __n objects
......@@ -2326,7 +2336,7 @@ private:
23262336 // Precondition: __n > 0
23272337 // Postcondition: capacity() >= __n
23282338 // Postcondition: size() == 0
2329 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vallocate(size_type __n) {
2339 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __vallocate(size_type __n) {
23302340 if (__n > max_size())
23312341 __throw_length_error();
23322342 auto __allocation = std::__allocate_at_least(__alloc(), __external_cap_to_internal(__n));
......@@ -2339,43 +2349,43 @@ private:
23392349 }
23402350 }
23412351
2342 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vdeallocate() _NOEXCEPT;
2343 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2352 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __vdeallocate() _NOEXCEPT;
2353 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
23442354 static size_type __align_it(size_type __new_size) _NOEXCEPT
23452355 {return (__new_size + (__bits_per_word-1)) & ~((size_type)__bits_per_word-1);}
2346 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type __recommend(size_type __new_size) const;
2347 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n, bool __x);
2356 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __recommend(size_type __new_size) const;
2357 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct_at_end(size_type __n, bool __x);
23482358 template <class _ForwardIterator>
23492359 typename enable_if
23502360 <
23512361 __is_cpp17_forward_iterator<_ForwardIterator>::value,
23522362 void
23532363 >::type
2354 _LIBCPP_CONSTEXPR_AFTER_CXX17 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
2355 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n, const_reference __x);
2356 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2364 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
2365 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __append(size_type __n, const_reference __x);
2366 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
23572367 reference __make_ref(size_type __pos) _NOEXCEPT
23582368 {return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}
2359 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2369 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
23602370 const_reference __make_ref(size_type __pos) const _NOEXCEPT {
23612371 return __bit_const_reference<vector>(__begin_ + __pos / __bits_per_word,
23622372 __storage_type(1) << __pos % __bits_per_word);
23632373 }
2364 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2374 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
23652375 iterator __make_iter(size_type __pos) _NOEXCEPT
23662376 {return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}
2367 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2377 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
23682378 const_iterator __make_iter(size_type __pos) const _NOEXCEPT
23692379 {return const_iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}
2370 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2380 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
23712381 iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT
23722382 {return begin() + (__p - cbegin());}
23732383
2374 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2384 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
23752385 void __copy_assign_alloc(const vector& __v)
23762386 {__copy_assign_alloc(__v, integral_constant<bool,
23772387 __storage_traits::propagate_on_container_copy_assignment::value>());}
2378 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2388 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
23792389 void __copy_assign_alloc(const vector& __c, true_type)
23802390 {
23812391 if (__alloc() != __c.__alloc())
......@@ -2383,33 +2393,33 @@ private:
23832393 __alloc() = __c.__alloc();
23842394 }
23852395
2386 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2396 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
23872397 void __copy_assign_alloc(const vector&, false_type)
23882398 {}
23892399
2390 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, false_type);
2391 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, true_type)
2400 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign(vector& __c, false_type);
2401 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign(vector& __c, true_type)
23922402 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
2393 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2403 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
23942404 void __move_assign_alloc(vector& __c)
23952405 _NOEXCEPT_(
23962406 !__storage_traits::propagate_on_container_move_assignment::value ||
23972407 is_nothrow_move_assignable<allocator_type>::value)
23982408 {__move_assign_alloc(__c, integral_constant<bool,
23992409 __storage_traits::propagate_on_container_move_assignment::value>());}
2400 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2410 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
24012411 void __move_assign_alloc(vector& __c, true_type)
24022412 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
24032413 {
2404 __alloc() = _VSTD::move(__c.__alloc());
2414 __alloc() = std::move(__c.__alloc());
24052415 }
24062416
2407 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2417 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
24082418 void __move_assign_alloc(vector&, false_type)
24092419 _NOEXCEPT
24102420 {}
24112421
2412 _LIBCPP_CONSTEXPR_AFTER_CXX17 size_t __hash_code() const _NOEXCEPT;
2422 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t __hash_code() const _NOEXCEPT;
24132423
24142424 friend class __bit_reference<vector>;
24152425 friend class __bit_const_reference<vector>;
......@@ -2420,7 +2430,7 @@ private:
24202430};
24212431
24222432template <class _Allocator>
2423_LIBCPP_CONSTEXPR_AFTER_CXX17 void
2433_LIBCPP_CONSTEXPR_SINCE_CXX20 void
24242434vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT
24252435{
24262436 if (this->__begin_ != nullptr)
......@@ -2433,7 +2443,7 @@ vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT
24332443}
24342444
24352445template <class _Allocator>
2436_LIBCPP_CONSTEXPR_AFTER_CXX17
2446_LIBCPP_CONSTEXPR_SINCE_CXX20
24372447typename vector<bool, _Allocator>::size_type
24382448vector<bool, _Allocator>::max_size() const _NOEXCEPT
24392449{
......@@ -2446,7 +2456,7 @@ vector<bool, _Allocator>::max_size() const _NOEXCEPT
24462456
24472457// Precondition: __new_size > capacity()
24482458template <class _Allocator>
2449inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2459inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
24502460typename vector<bool, _Allocator>::size_type
24512461vector<bool, _Allocator>::__recommend(size_type __new_size) const
24522462{
......@@ -2456,7 +2466,7 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const
24562466 const size_type __cap = capacity();
24572467 if (__cap >= __ms / 2)
24582468 return __ms;
2459 return _VSTD::max(2 * __cap, __align_it(__new_size));
2469 return std::max(2 * __cap, __align_it(__new_size));
24602470}
24612471
24622472// Default constructs __n objects starting at __end_
......@@ -2464,7 +2474,7 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const
24642474// Precondition: size() + __n <= capacity()
24652475// Postcondition: size() == size() + __n
24662476template <class _Allocator>
2467inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2477inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
24682478void
24692479vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x)
24702480{
......@@ -2477,12 +2487,12 @@ vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x)
24772487 else
24782488 this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0);
24792489 }
2480 _VSTD::fill_n(__make_iter(__old_size), __n, __x);
2490 std::fill_n(__make_iter(__old_size), __n, __x);
24812491}
24822492
24832493template <class _Allocator>
24842494template <class _ForwardIterator>
2485_LIBCPP_CONSTEXPR_AFTER_CXX17
2495_LIBCPP_CONSTEXPR_SINCE_CXX20
24862496typename enable_if
24872497<
24882498 __is_cpp17_forward_iterator<_ForwardIterator>::value,
......@@ -2491,7 +2501,7 @@ typename enable_if
24912501vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
24922502{
24932503 size_type __old_size = this->__size_;
2494 this->__size_ += _VSTD::distance(__first, __last);
2504 this->__size_ += std::distance(__first, __last);
24952505 if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word))
24962506 {
24972507 if (this->__size_ <= __bits_per_word)
......@@ -2499,11 +2509,11 @@ vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardI
24992509 else
25002510 this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0);
25012511 }
2502 _VSTD::copy(__first, __last, __make_iter(__old_size));
2512 std::copy(__first, __last, __make_iter(__old_size));
25032513}
25042514
25052515template <class _Allocator>
2506inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2516inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
25072517vector<bool, _Allocator>::vector()
25082518 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
25092519 : __begin_(nullptr),
......@@ -2513,7 +2523,7 @@ vector<bool, _Allocator>::vector()
25132523}
25142524
25152525template <class _Allocator>
2516inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2526inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
25172527vector<bool, _Allocator>::vector(const allocator_type& __a)
25182528#if _LIBCPP_STD_VER <= 14
25192529 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
......@@ -2527,7 +2537,7 @@ vector<bool, _Allocator>::vector(const allocator_type& __a)
25272537}
25282538
25292539template <class _Allocator>
2530_LIBCPP_CONSTEXPR_AFTER_CXX17
2540_LIBCPP_CONSTEXPR_SINCE_CXX20
25312541vector<bool, _Allocator>::vector(size_type __n)
25322542 : __begin_(nullptr),
25332543 __size_(0),
......@@ -2542,7 +2552,7 @@ vector<bool, _Allocator>::vector(size_type __n)
25422552
25432553#if _LIBCPP_STD_VER > 11
25442554template <class _Allocator>
2545_LIBCPP_CONSTEXPR_AFTER_CXX17
2555_LIBCPP_CONSTEXPR_SINCE_CXX20
25462556vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)
25472557 : __begin_(nullptr),
25482558 __size_(0),
......@@ -2557,7 +2567,7 @@ vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)
25572567#endif
25582568
25592569template <class _Allocator>
2560_LIBCPP_CONSTEXPR_AFTER_CXX17
2570_LIBCPP_CONSTEXPR_SINCE_CXX20
25612571vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
25622572 : __begin_(nullptr),
25632573 __size_(0),
......@@ -2571,7 +2581,7 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
25712581}
25722582
25732583template <class _Allocator>
2574_LIBCPP_CONSTEXPR_AFTER_CXX17
2584_LIBCPP_CONSTEXPR_SINCE_CXX20
25752585vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a)
25762586 : __begin_(nullptr),
25772587 __size_(0),
......@@ -2586,7 +2596,7 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const all
25862596
25872597template <class _Allocator>
25882598template <class _InputIterator>
2589_LIBCPP_CONSTEXPR_AFTER_CXX17
2599_LIBCPP_CONSTEXPR_SINCE_CXX20
25902600vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
25912601 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type*)
25922602 : __begin_(nullptr),
......@@ -2613,7 +2623,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
26132623
26142624template <class _Allocator>
26152625template <class _InputIterator>
2616_LIBCPP_CONSTEXPR_AFTER_CXX17
2626_LIBCPP_CONSTEXPR_SINCE_CXX20
26172627vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
26182628 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type*)
26192629 : __begin_(nullptr),
......@@ -2640,42 +2650,46 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
26402650
26412651template <class _Allocator>
26422652template <class _ForwardIterator>
2643_LIBCPP_CONSTEXPR_AFTER_CXX17
2653_LIBCPP_CONSTEXPR_SINCE_CXX20
26442654vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last,
26452655 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*)
26462656 : __begin_(nullptr),
26472657 __size_(0),
26482658 __cap_alloc_(0, __default_init_tag())
26492659{
2650 size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
2660 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
2661 size_type __n = static_cast<size_type>(std::distance(__first, __last));
26512662 if (__n > 0)
26522663 {
26532664 __vallocate(__n);
26542665 __construct_at_end(__first, __last);
26552666 }
2667 __guard.__complete();
26562668}
26572669
26582670template <class _Allocator>
26592671template <class _ForwardIterator>
2660_LIBCPP_CONSTEXPR_AFTER_CXX17
2672_LIBCPP_CONSTEXPR_SINCE_CXX20
26612673vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
26622674 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*)
26632675 : __begin_(nullptr),
26642676 __size_(0),
26652677 __cap_alloc_(0, static_cast<__storage_allocator>(__a))
26662678{
2667 size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
2679 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
2680 size_type __n = static_cast<size_type>(std::distance(__first, __last));
26682681 if (__n > 0)
26692682 {
26702683 __vallocate(__n);
26712684 __construct_at_end(__first, __last);
26722685 }
2686 __guard.__complete();
26732687}
26742688
26752689#ifndef _LIBCPP_CXX03_LANG
26762690
26772691template <class _Allocator>
2678_LIBCPP_CONSTEXPR_AFTER_CXX17
2692_LIBCPP_CONSTEXPR_SINCE_CXX20
26792693vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
26802694 : __begin_(nullptr),
26812695 __size_(0),
......@@ -2690,7 +2704,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
26902704}
26912705
26922706template <class _Allocator>
2693_LIBCPP_CONSTEXPR_AFTER_CXX17
2707_LIBCPP_CONSTEXPR_SINCE_CXX20
26942708vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
26952709 : __begin_(nullptr),
26962710 __size_(0),
......@@ -2707,16 +2721,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const alloca
27072721#endif // _LIBCPP_CXX03_LANG
27082722
27092723template <class _Allocator>
2710_LIBCPP_CONSTEXPR_AFTER_CXX17
2711vector<bool, _Allocator>::~vector()
2712{
2713 if (__begin_ != nullptr)
2714 __storage_traits::deallocate(__alloc(), __begin_, __cap());
2715 std::__debug_db_invalidate_all(this);
2716}
2717
2718template <class _Allocator>
2719_LIBCPP_CONSTEXPR_AFTER_CXX17
2724_LIBCPP_CONSTEXPR_SINCE_CXX20
27202725vector<bool, _Allocator>::vector(const vector& __v)
27212726 : __begin_(nullptr),
27222727 __size_(0),
......@@ -2730,7 +2735,7 @@ vector<bool, _Allocator>::vector(const vector& __v)
27302735}
27312736
27322737template <class _Allocator>
2733_LIBCPP_CONSTEXPR_AFTER_CXX17
2738_LIBCPP_CONSTEXPR_SINCE_CXX20
27342739vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)
27352740 : __begin_(nullptr),
27362741 __size_(0),
......@@ -2744,11 +2749,11 @@ vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)
27442749}
27452750
27462751template <class _Allocator>
2747_LIBCPP_CONSTEXPR_AFTER_CXX17
2752_LIBCPP_CONSTEXPR_SINCE_CXX20
27482753vector<bool, _Allocator>&
27492754vector<bool, _Allocator>::operator=(const vector& __v)
27502755{
2751 if (this != _VSTD::addressof(__v))
2756 if (this != std::addressof(__v))
27522757 {
27532758 __copy_assign_alloc(__v);
27542759 if (__v.__size_)
......@@ -2758,7 +2763,7 @@ vector<bool, _Allocator>::operator=(const vector& __v)
27582763 __vdeallocate();
27592764 __vallocate(__v.__size_);
27602765 }
2761 _VSTD::copy(__v.__begin_, __v.__begin_ + __external_cap_to_internal(__v.__size_), __begin_);
2766 std::copy(__v.__begin_, __v.__begin_ + __external_cap_to_internal(__v.__size_), __begin_);
27622767 }
27632768 __size_ = __v.__size_;
27642769 }
......@@ -2766,7 +2771,7 @@ vector<bool, _Allocator>::operator=(const vector& __v)
27662771}
27672772
27682773template <class _Allocator>
2769inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 vector<bool, _Allocator>::vector(vector&& __v)
2774inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(vector&& __v)
27702775#if _LIBCPP_STD_VER > 14
27712776 _NOEXCEPT
27722777#else
......@@ -2774,14 +2779,14 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 vector<bool, _All
27742779#endif
27752780 : __begin_(__v.__begin_),
27762781 __size_(__v.__size_),
2777 __cap_alloc_(_VSTD::move(__v.__cap_alloc_)) {
2782 __cap_alloc_(std::move(__v.__cap_alloc_)) {
27782783 __v.__begin_ = nullptr;
27792784 __v.__size_ = 0;
27802785 __v.__cap() = 0;
27812786}
27822787
27832788template <class _Allocator>
2784_LIBCPP_CONSTEXPR_AFTER_CXX17
2789_LIBCPP_CONSTEXPR_SINCE_CXX20
27852790vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator_type>& __a)
27862791 : __begin_(nullptr),
27872792 __size_(0),
......@@ -2803,7 +2808,7 @@ vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator
28032808}
28042809
28052810template <class _Allocator>
2806inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
2811inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
28072812vector<bool, _Allocator>&
28082813vector<bool, _Allocator>::operator=(vector&& __v)
28092814 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
......@@ -2814,7 +2819,7 @@ vector<bool, _Allocator>::operator=(vector&& __v)
28142819}
28152820
28162821template <class _Allocator>
2817_LIBCPP_CONSTEXPR_AFTER_CXX17 void
2822_LIBCPP_CONSTEXPR_SINCE_CXX20 void
28182823vector<bool, _Allocator>::__move_assign(vector& __c, false_type)
28192824{
28202825 if (__alloc() != __c.__alloc())
......@@ -2824,7 +2829,7 @@ vector<bool, _Allocator>::__move_assign(vector& __c, false_type)
28242829}
28252830
28262831template <class _Allocator>
2827_LIBCPP_CONSTEXPR_AFTER_CXX17 void
2832_LIBCPP_CONSTEXPR_SINCE_CXX20 void
28282833vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
28292834 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
28302835{
......@@ -2838,7 +2843,7 @@ vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
28382843}
28392844
28402845template <class _Allocator>
2841_LIBCPP_CONSTEXPR_AFTER_CXX17 void
2846_LIBCPP_CONSTEXPR_SINCE_CXX20 void
28422847vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)
28432848{
28442849 __size_ = 0;
......@@ -2854,14 +2859,14 @@ vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)
28542859 __v.__size_ = __n;
28552860 swap(__v);
28562861 }
2857 _VSTD::fill_n(begin(), __n, __x);
2862 std::fill_n(begin(), __n, __x);
28582863 }
28592864 std::__debug_db_invalidate_all(this);
28602865}
28612866
28622867template <class _Allocator>
28632868template <class _InputIterator>
2864_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
2869_LIBCPP_CONSTEXPR_SINCE_CXX20 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
28652870 void
28662871>::type
28672872vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
......@@ -2873,7 +2878,7 @@ vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
28732878
28742879template <class _Allocator>
28752880template <class _ForwardIterator>
2876_LIBCPP_CONSTEXPR_AFTER_CXX17
2881_LIBCPP_CONSTEXPR_SINCE_CXX20
28772882typename enable_if
28782883<
28792884 __is_cpp17_forward_iterator<_ForwardIterator>::value,
......@@ -2882,7 +2887,7 @@ typename enable_if
28822887vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)
28832888{
28842889 clear();
2885 difference_type __ns = _VSTD::distance(__first, __last);
2890 difference_type __ns = std::distance(__first, __last);
28862891 _LIBCPP_ASSERT(__ns >= 0, "invalid range specified");
28872892 const size_t __n = static_cast<size_type>(__ns);
28882893 if (__n)
......@@ -2897,7 +2902,7 @@ vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __la
28972902}
28982903
28992904template <class _Allocator>
2900_LIBCPP_CONSTEXPR_AFTER_CXX17 void
2905_LIBCPP_CONSTEXPR_SINCE_CXX20 void
29012906vector<bool, _Allocator>::reserve(size_type __n)
29022907{
29032908 if (__n > capacity())
......@@ -2913,7 +2918,7 @@ vector<bool, _Allocator>::reserve(size_type __n)
29132918}
29142919
29152920template <class _Allocator>
2916_LIBCPP_CONSTEXPR_AFTER_CXX17 void
2921_LIBCPP_CONSTEXPR_SINCE_CXX20 void
29172922vector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT
29182923{
29192924 if (__external_cap_to_internal(size()) > __cap())
......@@ -2951,7 +2956,7 @@ vector<bool, _Allocator>::at(size_type __n) const
29512956}
29522957
29532958template <class _Allocator>
2954_LIBCPP_CONSTEXPR_AFTER_CXX17 void
2959_LIBCPP_CONSTEXPR_SINCE_CXX20 void
29552960vector<bool, _Allocator>::push_back(const value_type& __x)
29562961{
29572962 if (this->__size_ == this->capacity())
......@@ -2961,7 +2966,7 @@ vector<bool, _Allocator>::push_back(const value_type& __x)
29612966}
29622967
29632968template <class _Allocator>
2964_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<bool, _Allocator>::iterator
2969_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator
29652970vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __x)
29662971{
29672972 iterator __r;
......@@ -2969,7 +2974,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __
29692974 {
29702975 const_iterator __old_end = end();
29712976 ++__size_;
2972 _VSTD::copy_backward(__position, __old_end, end());
2977 std::copy_backward(__position, __old_end, end());
29732978 __r = __const_iterator_cast(__position);
29742979 }
29752980 else
......@@ -2977,8 +2982,8 @@ vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __
29772982 vector __v(get_allocator());
29782983 __v.reserve(__recommend(__size_ + 1));
29792984 __v.__size_ = __size_ + 1;
2980 __r = _VSTD::copy(cbegin(), __position, __v.begin());
2981 _VSTD::copy_backward(__position, cend(), __v.end());
2985 __r = std::copy(cbegin(), __position, __v.begin());
2986 std::copy_backward(__position, cend(), __v.end());
29822987 swap(__v);
29832988 }
29842989 *__r = __x;
......@@ -2986,7 +2991,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __
29862991}
29872992
29882993template <class _Allocator>
2989_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<bool, _Allocator>::iterator
2994_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator
29902995vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const value_type& __x)
29912996{
29922997 iterator __r;
......@@ -2995,7 +3000,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const
29953000 {
29963001 const_iterator __old_end = end();
29973002 __size_ += __n;
2998 _VSTD::copy_backward(__position, __old_end, end());
3003 std::copy_backward(__position, __old_end, end());
29993004 __r = __const_iterator_cast(__position);
30003005 }
30013006 else
......@@ -3003,17 +3008,17 @@ vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const
30033008 vector __v(get_allocator());
30043009 __v.reserve(__recommend(__size_ + __n));
30053010 __v.__size_ = __size_ + __n;
3006 __r = _VSTD::copy(cbegin(), __position, __v.begin());
3007 _VSTD::copy_backward(__position, cend(), __v.end());
3011 __r = std::copy(cbegin(), __position, __v.begin());
3012 std::copy_backward(__position, cend(), __v.end());
30083013 swap(__v);
30093014 }
3010 _VSTD::fill_n(__r, __n, __x);
3015 std::fill_n(__r, __n, __x);
30113016 return __r;
30123017}
30133018
30143019template <class _Allocator>
30153020template <class _InputIterator>
3016_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
3021_LIBCPP_CONSTEXPR_SINCE_CXX20 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
30173022 typename vector<bool, _Allocator>::iterator
30183023>::type
30193024vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
......@@ -3048,14 +3053,14 @@ vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __fir
30483053 }
30493054#endif // _LIBCPP_NO_EXCEPTIONS
30503055 }
3051 __p = _VSTD::rotate(__p, __old_end, end());
3056 __p = std::rotate(__p, __old_end, end());
30523057 insert(__p, __v.begin(), __v.end());
30533058 return begin() + __off;
30543059}
30553060
30563061template <class _Allocator>
30573062template <class _ForwardIterator>
3058_LIBCPP_CONSTEXPR_AFTER_CXX17
3063_LIBCPP_CONSTEXPR_SINCE_CXX20
30593064typename enable_if
30603065<
30613066 __is_cpp17_forward_iterator<_ForwardIterator>::value,
......@@ -3063,7 +3068,7 @@ typename enable_if
30633068>::type
30643069vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last)
30653070{
3066 const difference_type __n_signed = _VSTD::distance(__first, __last);
3071 const difference_type __n_signed = std::distance(__first, __last);
30673072 _LIBCPP_ASSERT(__n_signed >= 0, "invalid range specified");
30683073 const size_type __n = static_cast<size_type>(__n_signed);
30693074 iterator __r;
......@@ -3072,7 +3077,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __f
30723077 {
30733078 const_iterator __old_end = end();
30743079 __size_ += __n;
3075 _VSTD::copy_backward(__position, __old_end, end());
3080 std::copy_backward(__position, __old_end, end());
30763081 __r = __const_iterator_cast(__position);
30773082 }
30783083 else
......@@ -3080,39 +3085,39 @@ vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __f
30803085 vector __v(get_allocator());
30813086 __v.reserve(__recommend(__size_ + __n));
30823087 __v.__size_ = __size_ + __n;
3083 __r = _VSTD::copy(cbegin(), __position, __v.begin());
3084 _VSTD::copy_backward(__position, cend(), __v.end());
3088 __r = std::copy(cbegin(), __position, __v.begin());
3089 std::copy_backward(__position, cend(), __v.end());
30853090 swap(__v);
30863091 }
3087 _VSTD::copy(__first, __last, __r);
3092 std::copy(__first, __last, __r);
30883093 return __r;
30893094}
30903095
30913096template <class _Allocator>
3092inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
3097inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
30933098typename vector<bool, _Allocator>::iterator
30943099vector<bool, _Allocator>::erase(const_iterator __position)
30953100{
30963101 iterator __r = __const_iterator_cast(__position);
3097 _VSTD::copy(__position + 1, this->cend(), __r);
3102 std::copy(__position + 1, this->cend(), __r);
30983103 --__size_;
30993104 return __r;
31003105}
31013106
31023107template <class _Allocator>
3103_LIBCPP_CONSTEXPR_AFTER_CXX17
3108_LIBCPP_CONSTEXPR_SINCE_CXX20
31043109typename vector<bool, _Allocator>::iterator
31053110vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last)
31063111{
31073112 iterator __r = __const_iterator_cast(__first);
31083113 difference_type __d = __last - __first;
3109 _VSTD::copy(__last, this->cend(), __r);
3114 std::copy(__last, this->cend(), __r);
31103115 __size_ -= __d;
31113116 return __r;
31123117}
31133118
31143119template <class _Allocator>
3115_LIBCPP_CONSTEXPR_AFTER_CXX17 void
3120_LIBCPP_CONSTEXPR_SINCE_CXX20 void
31163121vector<bool, _Allocator>::swap(vector& __x)
31173122#if _LIBCPP_STD_VER >= 14
31183123 _NOEXCEPT
......@@ -3121,15 +3126,15 @@ vector<bool, _Allocator>::swap(vector& __x)
31213126 __is_nothrow_swappable<allocator_type>::value)
31223127#endif
31233128{
3124 _VSTD::swap(this->__begin_, __x.__begin_);
3125 _VSTD::swap(this->__size_, __x.__size_);
3126 _VSTD::swap(this->__cap(), __x.__cap());
3127 _VSTD::__swap_allocator(this->__alloc(), __x.__alloc(),
3129 std::swap(this->__begin_, __x.__begin_);
3130 std::swap(this->__size_, __x.__size_);
3131 std::swap(this->__cap(), __x.__cap());
3132 std::__swap_allocator(this->__alloc(), __x.__alloc(),
31283133 integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>());
31293134}
31303135
31313136template <class _Allocator>
3132_LIBCPP_CONSTEXPR_AFTER_CXX17 void
3137_LIBCPP_CONSTEXPR_SINCE_CXX20 void
31333138vector<bool, _Allocator>::resize(size_type __sz, value_type __x)
31343139{
31353140 size_type __cs = size();
......@@ -3148,17 +3153,17 @@ vector<bool, _Allocator>::resize(size_type __sz, value_type __x)
31483153 vector __v(get_allocator());
31493154 __v.reserve(__recommend(__size_ + __n));
31503155 __v.__size_ = __size_ + __n;
3151 __r = _VSTD::copy(cbegin(), cend(), __v.begin());
3156 __r = std::copy(cbegin(), cend(), __v.begin());
31523157 swap(__v);
31533158 }
3154 _VSTD::fill_n(__r, __n, __x);
3159 std::fill_n(__r, __n, __x);
31553160 }
31563161 else
31573162 __size_ = __sz;
31583163}
31593164
31603165template <class _Allocator>
3161_LIBCPP_CONSTEXPR_AFTER_CXX17 void
3166_LIBCPP_CONSTEXPR_SINCE_CXX20 void
31623167vector<bool, _Allocator>::flip() _NOEXCEPT
31633168{
31643169 // do middle whole words
......@@ -3177,7 +3182,7 @@ vector<bool, _Allocator>::flip() _NOEXCEPT
31773182}
31783183
31793184template <class _Allocator>
3180_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
3185_LIBCPP_CONSTEXPR_SINCE_CXX20 bool
31813186vector<bool, _Allocator>::__invariants() const
31823187{
31833188 if (this->__begin_ == nullptr)
......@@ -3196,7 +3201,7 @@ vector<bool, _Allocator>::__invariants() const
31963201}
31973202
31983203template <class _Allocator>
3199_LIBCPP_CONSTEXPR_AFTER_CXX17 size_t
3204_LIBCPP_CONSTEXPR_SINCE_CXX20 size_t
32003205vector<bool, _Allocator>::__hash_code() const _NOEXCEPT
32013206{
32023207 size_t __h = 0;
......@@ -3218,24 +3223,24 @@ template <class _Allocator>
32183223struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> >
32193224 : public __unary_function<vector<bool, _Allocator>, size_t>
32203225{
3221 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
3226 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
32223227 size_t operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT
32233228 {return __vec.__hash_code();}
32243229};
32253230
32263231template <class _Tp, class _Allocator>
3227_LIBCPP_CONSTEXPR_AFTER_CXX17
3228inline _LIBCPP_INLINE_VISIBILITY
3232_LIBCPP_CONSTEXPR_SINCE_CXX20
3233inline _LIBCPP_HIDE_FROM_ABI
32293234bool
32303235operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
32313236{
32323237 const typename vector<_Tp, _Allocator>::size_type __sz = __x.size();
3233 return __sz == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
3238 return __sz == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());
32343239}
32353240
32363241template <class _Tp, class _Allocator>
3237_LIBCPP_CONSTEXPR_AFTER_CXX17
3238inline _LIBCPP_INLINE_VISIBILITY
3242_LIBCPP_CONSTEXPR_SINCE_CXX20
3243inline _LIBCPP_HIDE_FROM_ABI
32393244bool
32403245operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
32413246{
......@@ -3243,17 +3248,17 @@ operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
32433248}
32443249
32453250template <class _Tp, class _Allocator>
3246_LIBCPP_CONSTEXPR_AFTER_CXX17
3247inline _LIBCPP_INLINE_VISIBILITY
3251_LIBCPP_CONSTEXPR_SINCE_CXX20
3252inline _LIBCPP_HIDE_FROM_ABI
32483253bool
32493254operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
32503255{
3251 return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
3256 return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
32523257}
32533258
32543259template <class _Tp, class _Allocator>
3255_LIBCPP_CONSTEXPR_AFTER_CXX17
3256inline _LIBCPP_INLINE_VISIBILITY
3260_LIBCPP_CONSTEXPR_SINCE_CXX20
3261inline _LIBCPP_HIDE_FROM_ABI
32573262bool
32583263operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
32593264{
......@@ -3261,8 +3266,8 @@ operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
32613266}
32623267
32633268template <class _Tp, class _Allocator>
3264_LIBCPP_CONSTEXPR_AFTER_CXX17
3265inline _LIBCPP_INLINE_VISIBILITY
3269_LIBCPP_CONSTEXPR_SINCE_CXX20
3270inline _LIBCPP_HIDE_FROM_ABI
32663271bool
32673272operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
32683273{
......@@ -3270,8 +3275,8 @@ operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
32703275}
32713276
32723277template <class _Tp, class _Allocator>
3273_LIBCPP_CONSTEXPR_AFTER_CXX17
3274inline _LIBCPP_INLINE_VISIBILITY
3278_LIBCPP_CONSTEXPR_SINCE_CXX20
3279inline _LIBCPP_HIDE_FROM_ABI
32753280bool
32763281operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
32773282{
......@@ -3279,8 +3284,8 @@ operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
32793284}
32803285
32813286template <class _Tp, class _Allocator>
3282_LIBCPP_CONSTEXPR_AFTER_CXX17
3283inline _LIBCPP_INLINE_VISIBILITY
3287_LIBCPP_CONSTEXPR_SINCE_CXX20
3288inline _LIBCPP_HIDE_FROM_ABI
32843289void
32853290swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y)
32863291 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
......@@ -3290,34 +3295,72 @@ swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y)
32903295
32913296#if _LIBCPP_STD_VER > 17
32923297template <class _Tp, class _Allocator, class _Up>
3293_LIBCPP_CONSTEXPR_AFTER_CXX17
3294inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type
3298_LIBCPP_CONSTEXPR_SINCE_CXX20
3299inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type
32953300erase(vector<_Tp, _Allocator>& __c, const _Up& __v) {
32963301 auto __old_size = __c.size();
3297 __c.erase(_VSTD::remove(__c.begin(), __c.end(), __v), __c.end());
3302 __c.erase(std::remove(__c.begin(), __c.end(), __v), __c.end());
32983303 return __old_size - __c.size();
32993304}
33003305
33013306template <class _Tp, class _Allocator, class _Predicate>
3302_LIBCPP_CONSTEXPR_AFTER_CXX17
3303inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type
3307_LIBCPP_CONSTEXPR_SINCE_CXX20
3308inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type
33043309erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) {
33053310 auto __old_size = __c.size();
3306 __c.erase(_VSTD::remove_if(__c.begin(), __c.end(), __pred), __c.end());
3311 __c.erase(std::remove_if(__c.begin(), __c.end(), __pred), __c.end());
33073312 return __old_size - __c.size();
33083313}
33093314
33103315template <>
3311inline constexpr bool __format::__enable_insertable<std::vector<char>> = true;
3316inline constexpr bool __format::__enable_insertable<vector<char>> = true;
33123317#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
33133318template <>
3314inline constexpr bool __format::__enable_insertable<std::vector<wchar_t>> = true;
3319inline constexpr bool __format::__enable_insertable<vector<wchar_t>> = true;
33153320#endif
33163321
33173322#endif // _LIBCPP_STD_VER > 17
33183323
3324#if _LIBCPP_STD_VER > 20
3325template <class _Tp, class CharT>
3326// Since is-vector-bool-reference is only used once it's inlined here.
3327 requires same_as<typename _Tp::__container, vector<bool, typename _Tp::__container::allocator_type>>
3328struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_Tp, CharT> {
3329private:
3330 formatter<bool, CharT> __underlying_;
3331
3332public:
3333 template <class _ParseContext>
3334 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
3335 return __underlying_.parse(__ctx);
3336 }
3337
3338 template <class _FormatContext>
3339 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(const _Tp& __ref, _FormatContext& __ctx) const {
3340 return __underlying_.format(__ref, __ctx);
3341 }
3342};
3343#endif // _LIBCPP_STD_VER > 20
3344
33193345_LIBCPP_END_NAMESPACE_STD
33203346
3347#if _LIBCPP_STD_VER > 14
3348_LIBCPP_BEGIN_NAMESPACE_STD
3349namespace pmr {
3350template <class _ValueT>
3351using vector = std::vector<_ValueT, polymorphic_allocator<_ValueT>>;
3352} // namespace pmr
3353_LIBCPP_END_NAMESPACE_STD
3354#endif
3355
33213356_LIBCPP_POP_MACROS
33223357
3358#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
3359# include <algorithm>
3360# include <atomic>
3361# include <concepts>
3362# include <typeinfo>
3363# include <utility>
3364#endif
3365
33233366#endif // _LIBCPP_VECTOR
lib/libcxx/include/version+22-11
......@@ -55,13 +55,16 @@ __cpp_lib_chrono_udls 201304L <chrono>
5555__cpp_lib_clamp 201603L <algorithm>
5656__cpp_lib_complex_udls 201309L <complex>
5757__cpp_lib_concepts 202002L <concepts>
58__cpp_lib_constexpr_algorithms 201806L <algorithm>
58__cpp_lib_constexpr_algorithms 201806L <algorithm> <utility>
59__cpp_lib_constexpr_bitset 202207L <bitset>
60__cpp_lib_constexpr_charconv 202207L <charconv>
5961__cpp_lib_constexpr_cmath 202202L <cmath> <cstdlib>
6062__cpp_lib_constexpr_complex 201711L <complex>
6163__cpp_lib_constexpr_dynamic_alloc 201907L <memory>
6264__cpp_lib_constexpr_functional 201907L <functional>
6365__cpp_lib_constexpr_iterator 201811L <iterator>
64__cpp_lib_constexpr_memory 201811L <memory>
66__cpp_lib_constexpr_memory 202202L <memory>
67 201811L // C++20
6568__cpp_lib_constexpr_numeric 201911L <numeric>
6669__cpp_lib_constexpr_string 201907L <string>
6770__cpp_lib_constexpr_string_view 201811L <string_view>
......@@ -79,8 +82,10 @@ __cpp_lib_erase_if 202002L <deque> <forward
7982__cpp_lib_exchange_function 201304L <utility>
8083__cpp_lib_execution 201902L <execution>
8184 201603L // C++17
85__cpp_lib_expected 202202L <expected>
8286__cpp_lib_filesystem 201703L <filesystem>
8387__cpp_lib_format 202106L <format>
88__cpp_lib_forward_like 202207L <utility>
8489__cpp_lib_gcd_lcm 201606L <numeric>
8590__cpp_lib_generic_associative_lookup 201304L <map> <set>
8691__cpp_lib_generic_unordered_lookup 201811L <unordered_map> <unordered_set>
......@@ -132,7 +137,7 @@ __cpp_lib_out_ptr 202106L <memory>
132137__cpp_lib_parallel_algorithm 201603L <algorithm> <numeric>
133138__cpp_lib_polymorphic_allocator 201902L <memory_resource>
134139__cpp_lib_quoted_string_io 201304L <iomanip>
135__cpp_lib_ranges 201811L <algorithm> <functional> <iterator>
140__cpp_lib_ranges 202106L <algorithm> <functional> <iterator>
136141 <memory> <ranges>
137142__cpp_lib_ranges_chunk 202202L <ranges>
138143__cpp_lib_ranges_chunk_by 202202L <ranges>
......@@ -262,7 +267,7 @@ __cpp_lib_void_t 201411L <type_traits>
262267# define __cpp_lib_make_from_tuple 201606L
263268# define __cpp_lib_map_try_emplace 201411L
264269// # define __cpp_lib_math_special_functions 201603L
265// # define __cpp_lib_memory_resource 201603L
270# define __cpp_lib_memory_resource 201603L
266271# define __cpp_lib_node_extract 201606L
267272# define __cpp_lib_nonmember_container_access 201411L
268273# define __cpp_lib_not_fn 201603L
......@@ -312,7 +317,7 @@ __cpp_lib_void_t 201411L <type_traits>
312317# endif
313318# define __cpp_lib_concepts 202002L
314319# define __cpp_lib_constexpr_algorithms 201806L
315// # define __cpp_lib_constexpr_complex 201711L
320# define __cpp_lib_constexpr_complex 201711L
316321# define __cpp_lib_constexpr_dynamic_alloc 201907L
317322# define __cpp_lib_constexpr_functional 201907L
318323# define __cpp_lib_constexpr_iterator 201811L
......@@ -322,7 +327,7 @@ __cpp_lib_void_t 201411L <type_traits>
322327# define __cpp_lib_constexpr_string_view 201811L
323328# define __cpp_lib_constexpr_tuple 201811L
324329# define __cpp_lib_constexpr_utility 201811L
325// # define __cpp_lib_constexpr_vector 201907L
330# define __cpp_lib_constexpr_vector 201907L
326331# define __cpp_lib_coroutine 201902L
327332# if _LIBCPP_STD_VER > 17 && defined(__cpp_impl_destroying_delete) && __cpp_impl_destroying_delete >= 201806L
328333# define __cpp_lib_destroying_delete 201806L
......@@ -350,10 +355,8 @@ __cpp_lib_void_t 201411L <type_traits>
350355# endif
351356# define __cpp_lib_list_remove_return_type 201806L
352357# define __cpp_lib_math_constants 201907L
353// # define __cpp_lib_polymorphic_allocator 201902L
354# if !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
355# define __cpp_lib_ranges 201811L
356# endif
358# define __cpp_lib_polymorphic_allocator 201902L
359# define __cpp_lib_ranges 202106L
357360# define __cpp_lib_remove_cvref 201711L
358361# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore)
359362# define __cpp_lib_semaphore 201907L
......@@ -362,7 +365,9 @@ __cpp_lib_void_t 201411L <type_traits>
362365# define __cpp_lib_shared_ptr_arrays 201707L
363366# define __cpp_lib_shift 201806L
364367// # define __cpp_lib_smart_ptr_for_overwrite 202002L
365// # define __cpp_lib_source_location 201907L
368# if __has_builtin(__builtin_source_location)
369# define __cpp_lib_source_location 201907L
370# endif
366371# define __cpp_lib_span 202002L
367372# define __cpp_lib_ssize 201902L
368373# define __cpp_lib_starts_ends_with 201711L
......@@ -382,8 +387,14 @@ __cpp_lib_void_t 201411L <type_traits>
382387// # define __cpp_lib_associative_heterogeneous_erasure 202110L
383388// # define __cpp_lib_bind_back 202202L
384389# define __cpp_lib_byteswap 202110L
390# define __cpp_lib_constexpr_bitset 202207L
391# define __cpp_lib_constexpr_charconv 202207L
385392// # define __cpp_lib_constexpr_cmath 202202L
393# undef __cpp_lib_constexpr_memory
394# define __cpp_lib_constexpr_memory 202202L
386395// # define __cpp_lib_constexpr_typeinfo 202106L
396# define __cpp_lib_expected 202202L
397# define __cpp_lib_forward_like 202207L
387398// # define __cpp_lib_invoke_r 202106L
388399# define __cpp_lib_is_scoped_enum 202011L
389400// # define __cpp_lib_move_only_function 202110L
lib/libcxx/include/wchar.h+3-1
......@@ -120,7 +120,9 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
120120#define __CORRECT_ISO_CPP_WCHAR_H_PROTO
121121#endif
122122
123#include_next <wchar.h>
123# if __has_include_next(<wchar.h>)
124# include_next <wchar.h>
125# endif
124126
125127// Determine whether we have const-correct overloads for wcschr and friends.
126128#if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_)
lib/libcxx/src/atomic.cpp+24-3
......@@ -26,6 +26,11 @@
2626# define SYS_futex SYS_futex_time64
2727#endif
2828
29#elif defined(__FreeBSD__)
30
31#include <sys/types.h>
32#include <sys/umtx.h>
33
2934#else // <- Add other operating systems here
3035
3136// Baseline needs no new headers
......@@ -52,11 +57,11 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo
5257#elif defined(__APPLE__) && defined(_LIBCPP_USE_ULOCK)
5358
5459extern "C" int __ulock_wait(uint32_t operation, void *addr, uint64_t value,
55 uint32_t timeout); /* timeout is specified in microseconds */
60 uint32_t timeout); /* timeout is specified in microseconds */
5661extern "C" int __ulock_wake(uint32_t operation, void *addr, uint64_t wake_value);
5762
58#define UL_COMPARE_AND_WAIT 1
59#define ULF_WAKE_ALL 0x00000100
63#define UL_COMPARE_AND_WAIT 1
64#define ULF_WAKE_ALL 0x00000100
6065
6166static void __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr,
6267 __cxx_contention_t __val)
......@@ -72,6 +77,22 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo
7277 const_cast<__cxx_atomic_contention_t*>(__ptr), 0);
7378}
7479
80#elif defined(__FreeBSD__)
81
82static void __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr,
83 __cxx_contention_t __val)
84{
85 _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr),
86 UMTX_OP_WAIT_UINT_PRIVATE, __val, NULL, NULL);
87}
88
89static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr,
90 bool __notify_one)
91{
92 _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr),
93 UMTX_OP_WAKE_PRIVATE, __notify_one ? 1 : INT_MAX, NULL, NULL);
94}
95
7596#else // <- Add other operating systems here
7697
7798// Baseline is just a timed backoff
lib/libcxx/src/charconv.cpp+2-2
......@@ -21,13 +21,13 @@ namespace __itoa
2121_LIBCPP_FUNC_VIS char*
2222__u32toa(uint32_t value, char* buffer) noexcept
2323{
24 return __base_10_u32(buffer, value);
24 return __base_10_u32(buffer, value);
2525}
2626
2727_LIBCPP_FUNC_VIS char*
2828__u64toa(uint64_t value, char* buffer) noexcept
2929{
30 return __base_10_u64(buffer, value);
30 return __base_10_u64(buffer, value);
3131}
3232
3333} // namespace __itoa
lib/libcxx/src/experimental/memory_resource.cpp+3-1
......@@ -8,6 +8,8 @@
88
99#include <experimental/memory_resource>
1010
11_LIBCPP_SUPPRESS_DEPRECATED_PUSH
12
1113#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER
1214# include <atomic>
1315#elif !defined(_LIBCPP_HAS_NO_THREADS)
......@@ -72,7 +74,7 @@ union ResourceInitHelper {
7274 __null_memory_resource_imp null_res;
7375 } resources;
7476 char dummy;
75 _LIBCPP_CONSTEXPR_AFTER_CXX11 ResourceInitHelper() : resources() {}
77 _LIBCPP_CONSTEXPR_SINCE_CXX14 ResourceInitHelper() : resources() {}
7678 ~ResourceInitHelper() {}
7779};
7880
lib/libcxx/src/filesystem/filesystem_common.h+10-10
......@@ -124,7 +124,7 @@ error_code make_windows_error(int err) {
124124template <class T>
125125T error_value();
126126template <>
127_LIBCPP_CONSTEXPR_AFTER_CXX11 void error_value<void>() {}
127_LIBCPP_CONSTEXPR_SINCE_CXX14 void error_value<void>() {}
128128template <>
129129bool error_value<bool>() {
130130 return false;
......@@ -140,7 +140,7 @@ uintmax_t error_value<uintmax_t>() {
140140 return uintmax_t(-1);
141141}
142142template <>
143_LIBCPP_CONSTEXPR_AFTER_CXX11 file_time_type error_value<file_time_type>() {
143_LIBCPP_CONSTEXPR_SINCE_CXX14 file_time_type error_value<file_time_type>() {
144144 return file_time_type::min();
145145}
146146template <>
......@@ -309,7 +309,7 @@ struct time_util_base {
309309 .count();
310310
311311private:
312 static _LIBCPP_CONSTEXPR_AFTER_CXX11 fs_duration get_min_nsecs() {
312 static _LIBCPP_CONSTEXPR_SINCE_CXX14 fs_duration get_min_nsecs() {
313313 return duration_cast<fs_duration>(
314314 fs_nanoseconds(min_nsec_timespec) -
315315 duration_cast<fs_nanoseconds>(fs_seconds(1)));
......@@ -319,7 +319,7 @@ private:
319319 FileTimeT::duration::min(),
320320 "value doesn't roundtrip");
321321
322 static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool check_range() {
322 static _LIBCPP_CONSTEXPR_SINCE_CXX14 bool check_range() {
323323 // This kinda sucks, but it's what happens when we don't have __int128_t.
324324 if (sizeof(TimeT) == sizeof(rep)) {
325325 typedef duration<long long, ratio<3600 * 24 * 365> > Years;
......@@ -385,7 +385,7 @@ struct time_util : time_util_base<FileTimeT, TimeT> {
385385
386386public:
387387 template <class CType, class ChronoType>
388 static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool checked_set(CType* out,
388 static _LIBCPP_CONSTEXPR_SINCE_CXX14 bool checked_set(CType* out,
389389 ChronoType time) {
390390 using Lim = numeric_limits<CType>;
391391 if (time > Lim::max() || time < Lim::min())
......@@ -394,7 +394,7 @@ public:
394394 return true;
395395 }
396396
397 static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool is_representable(TimeSpecT tm) {
397 static _LIBCPP_CONSTEXPR_SINCE_CXX14 bool is_representable(TimeSpecT tm) {
398398 if (tm.tv_sec >= 0) {
399399 return tm.tv_sec < max_seconds ||
400400 (tm.tv_sec == max_seconds && tm.tv_nsec <= max_nsec);
......@@ -405,7 +405,7 @@ public:
405405 }
406406 }
407407
408 static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool is_representable(FileTimeT tm) {
408 static _LIBCPP_CONSTEXPR_SINCE_CXX14 bool is_representable(FileTimeT tm) {
409409 auto secs = duration_cast<fs_seconds>(tm.time_since_epoch());
410410 auto nsecs = duration_cast<fs_nanoseconds>(tm.time_since_epoch() - secs);
411411 if (nsecs.count() < 0) {
......@@ -418,7 +418,7 @@ public:
418418 return secs.count() >= TLim::min();
419419 }
420420
421 static _LIBCPP_CONSTEXPR_AFTER_CXX11 FileTimeT
421 static _LIBCPP_CONSTEXPR_SINCE_CXX14 FileTimeT
422422 convert_from_timespec(TimeSpecT tm) {
423423 if (tm.tv_sec >= 0 || tm.tv_nsec == 0) {
424424 return FileTimeT(fs_seconds(tm.tv_sec) +
......@@ -432,7 +432,7 @@ public:
432432 }
433433
434434 template <class SubSecT>
435 static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool
435 static _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
436436 set_times_checked(TimeT* sec_out, SubSecT* subsec_out, FileTimeT tp) {
437437 auto dur = tp.time_since_epoch();
438438 auto sec_dur = duration_cast<fs_seconds>(dur);
......@@ -449,7 +449,7 @@ public:
449449 return checked_set(sec_out, sec_dur.count()) &&
450450 checked_set(subsec_out, subsec_dur.count());
451451 }
452 static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool convert_to_timespec(TimeSpecT& dest,
452 static _LIBCPP_CONSTEXPR_SINCE_CXX14 bool convert_to_timespec(TimeSpecT& dest,
453453 FileTimeT tp) {
454454 if (!is_representable(tp))
455455 return false;
lib/libcxx/src/filesystem/operations.cpp+2-1
......@@ -1348,7 +1348,7 @@ bool __remove(const path& p, error_code* ec) {
13481348//
13491349// The second implementation is used on platforms where `openat()` & friends are available,
13501350// and it threads file descriptors through recursive calls to avoid such race conditions.
1351#if defined(_LIBCPP_WIN32API)
1351#if defined(_LIBCPP_WIN32API) || defined (__MVS__)
13521352# define REMOVE_ALL_USE_DIRECTORY_ITERATOR
13531353#endif
13541354
......@@ -1408,6 +1408,7 @@ struct scope_exit {
14081408private:
14091409 Cleanup cleanup_;
14101410};
1411_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(scope_exit);
14111412
14121413uintmax_t remove_all_impl(int parent_directory, const path& p, error_code& ec) {
14131414 // First, try to open the path as a directory.
lib/libcxx/src/format.cpp+2
......@@ -10,6 +10,8 @@
1010
1111_LIBCPP_BEGIN_NAMESPACE_STD
1212
13#ifndef _LIBCPP_INLINE_FORMAT_ERROR_DTOR
1314format_error::~format_error() noexcept = default;
15#endif
1416
1517_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/include/apple_availability.h+1
......@@ -5,6 +5,7 @@
55// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66//
77//===----------------------------------------------------------------------===//
8
89#ifndef _LIBCPP_SRC_INCLUDE_APPLE_AVAILABILITY_H
910#define _LIBCPP_SRC_INCLUDE_APPLE_AVAILABILITY_H
1011
lib/libcxx/src/include/ryu/digit_table.h+1-1
......@@ -50,7 +50,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
5050// In order to minimize the diff in the Ryu code between MSVC STL and libc++
5151// the code uses the name __DIGIT_TABLE. In order to avoid code duplication it
5252// reuses the table already available in libc++.
53inline constexpr auto& __DIGIT_TABLE = __itoa::__table<>::__digits_base_10;
53inline constexpr auto& __DIGIT_TABLE = __itoa::__digits_base_10;
5454
5555_LIBCPP_END_NAMESPACE_STD
5656
lib/libcxx/src/ios.cpp+5-5
......@@ -145,11 +145,11 @@ int ios_base::__xindex_ = 0;
145145template <typename _Tp>
146146static size_t __ios_new_cap(size_t __req_size, size_t __current_cap)
147147{ // Precondition: __req_size > __current_cap
148 const size_t mx = std::numeric_limits<size_t>::max() / sizeof(_Tp);
149 if (__req_size < mx/2)
150 return _VSTD::max(2 * __current_cap, __req_size);
151 else
152 return mx;
148 const size_t mx = std::numeric_limits<size_t>::max() / sizeof(_Tp);
149 if (__req_size < mx/2)
150 return _VSTD::max(2 * __current_cap, __req_size);
151 else
152 return mx;
153153}
154154
155155int
lib/libcxx/src/ios.instantiations.cpp+3
......@@ -36,9 +36,12 @@ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_stringbuf<char>;
3636template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_stringstream<char>;
3737template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostringstream<char>;
3838template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istringstream<char>;
39
40#ifndef _LIBCPP_HAS_NO_FSTREAM
3941template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ifstream<char>;
4042template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ofstream<char>;
4143template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_filebuf<char>;
44#endif
4245
4346// Add more here if needed...
4447
lib/libcxx/src/iostream.cpp+2-2
......@@ -109,8 +109,8 @@ static void force_locale_initialization() {
109109
110110class DoIOSInit {
111111public:
112 DoIOSInit();
113 ~DoIOSInit();
112 DoIOSInit();
113 ~DoIOSInit();
114114};
115115
116116DoIOSInit::DoIOSInit()
lib/libcxx/src/locale.cpp+160-167
......@@ -141,14 +141,7 @@ class _LIBCPP_HIDDEN locale::__imp
141141 : public facet
142142{
143143 enum {N = 30};
144#if defined(_LIBCPP_COMPILER_MSVC)
145// FIXME: MSVC doesn't support aligned parameters by value.
146// I can't get the __sso_allocator to work here
147// for MSVC I think for this reason.
148 vector<facet*> facets_;
149#else
150144 vector<facet*, __sso_allocator<facet*, N> > facets_;
151#endif
152145 string name_;
153146public:
154147 explicit __imp(size_t refs = 0);
......@@ -739,25 +732,25 @@ locale::id::__init()
739732
740733collate_byname<char>::collate_byname(const char* n, size_t refs)
741734 : collate<char>(refs),
742 __l(newlocale(LC_ALL_MASK, n, 0))
735 __l_(newlocale(LC_ALL_MASK, n, 0))
743736{
744 if (__l == 0)
737 if (__l_ == 0)
745738 __throw_runtime_error("collate_byname<char>::collate_byname"
746739 " failed to construct for " + string(n));
747740}
748741
749742collate_byname<char>::collate_byname(const string& name, size_t refs)
750743 : collate<char>(refs),
751 __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
744 __l_(newlocale(LC_ALL_MASK, name.c_str(), 0))
752745{
753 if (__l == 0)
746 if (__l_ == 0)
754747 __throw_runtime_error("collate_byname<char>::collate_byname"
755748 " failed to construct for " + name);
756749}
757750
758751collate_byname<char>::~collate_byname()
759752{
760 freelocale(__l);
753 freelocale(__l_);
761754}
762755
763756int
......@@ -766,7 +759,7 @@ collate_byname<char>::do_compare(const char_type* __lo1, const char_type* __hi1,
766759{
767760 string_type lhs(__lo1, __hi1);
768761 string_type rhs(__lo2, __hi2);
769 int r = strcoll_l(lhs.c_str(), rhs.c_str(), __l);
762 int r = strcoll_l(lhs.c_str(), rhs.c_str(), __l_);
770763 if (r < 0)
771764 return -1;
772765 if (r > 0)
......@@ -778,8 +771,8 @@ collate_byname<char>::string_type
778771collate_byname<char>::do_transform(const char_type* lo, const char_type* hi) const
779772{
780773 const string_type in(lo, hi);
781 string_type out(strxfrm_l(0, in.c_str(), 0, __l), char());
782 strxfrm_l(const_cast<char*>(out.c_str()), in.c_str(), out.size()+1, __l);
774 string_type out(strxfrm_l(0, in.c_str(), 0, __l_), char());
775 strxfrm_l(const_cast<char*>(out.c_str()), in.c_str(), out.size()+1, __l_);
783776 return out;
784777}
785778
......@@ -788,25 +781,25 @@ collate_byname<char>::do_transform(const char_type* lo, const char_type* hi) con
788781#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
789782collate_byname<wchar_t>::collate_byname(const char* n, size_t refs)
790783 : collate<wchar_t>(refs),
791 __l(newlocale(LC_ALL_MASK, n, 0))
784 __l_(newlocale(LC_ALL_MASK, n, 0))
792785{
793 if (__l == 0)
786 if (__l_ == 0)
794787 __throw_runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)"
795788 " failed to construct for " + string(n));
796789}
797790
798791collate_byname<wchar_t>::collate_byname(const string& name, size_t refs)
799792 : collate<wchar_t>(refs),
800 __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
793 __l_(newlocale(LC_ALL_MASK, name.c_str(), 0))
801794{
802 if (__l == 0)
795 if (__l_ == 0)
803796 __throw_runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)"
804797 " failed to construct for " + name);
805798}
806799
807800collate_byname<wchar_t>::~collate_byname()
808801{
809 freelocale(__l);
802 freelocale(__l_);
810803}
811804
812805int
......@@ -815,7 +808,7 @@ collate_byname<wchar_t>::do_compare(const char_type* __lo1, const char_type* __h
815808{
816809 string_type lhs(__lo1, __hi1);
817810 string_type rhs(__lo2, __hi2);
818 int r = wcscoll_l(lhs.c_str(), rhs.c_str(), __l);
811 int r = wcscoll_l(lhs.c_str(), rhs.c_str(), __l_);
819812 if (r < 0)
820813 return -1;
821814 if (r > 0)
......@@ -827,8 +820,8 @@ collate_byname<wchar_t>::string_type
827820collate_byname<wchar_t>::do_transform(const char_type* lo, const char_type* hi) const
828821{
829822 const string_type in(lo, hi);
830 string_type out(wcsxfrm_l(0, in.c_str(), 0, __l), wchar_t());
831 wcsxfrm_l(const_cast<wchar_t*>(out.c_str()), in.c_str(), out.size()+1, __l);
823 string_type out(wcsxfrm_l(0, in.c_str(), 0, __l_), wchar_t());
824 wcsxfrm_l(const_cast<wchar_t*>(out.c_str()), in.c_str(), out.size()+1, __l_);
832825 return out;
833826}
834827#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
......@@ -1190,7 +1183,7 @@ ctype<char>::classic_table() noexcept
11901183const ctype<char>::mask*
11911184ctype<char>::classic_table() noexcept
11921185{
1193#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__)
1186#if defined(__APPLE__) || defined(__FreeBSD__)
11941187 return _DefaultRuneLocale.__runetype;
11951188#elif defined(__NetBSD__)
11961189 return _C_ctype_tab_ + 1;
......@@ -1286,52 +1279,52 @@ ctype<char>::__classic_upper_table() _NOEXCEPT
12861279
12871280ctype_byname<char>::ctype_byname(const char* name, size_t refs)
12881281 : ctype<char>(0, false, refs),
1289 __l(newlocale(LC_ALL_MASK, name, 0))
1282 __l_(newlocale(LC_ALL_MASK, name, 0))
12901283{
1291 if (__l == 0)
1284 if (__l_ == 0)
12921285 __throw_runtime_error("ctype_byname<char>::ctype_byname"
12931286 " failed to construct for " + string(name));
12941287}
12951288
12961289ctype_byname<char>::ctype_byname(const string& name, size_t refs)
12971290 : ctype<char>(0, false, refs),
1298 __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
1291 __l_(newlocale(LC_ALL_MASK, name.c_str(), 0))
12991292{
1300 if (__l == 0)
1293 if (__l_ == 0)
13011294 __throw_runtime_error("ctype_byname<char>::ctype_byname"
13021295 " failed to construct for " + name);
13031296}
13041297
13051298ctype_byname<char>::~ctype_byname()
13061299{
1307 freelocale(__l);
1300 freelocale(__l_);
13081301}
13091302
13101303char
13111304ctype_byname<char>::do_toupper(char_type c) const
13121305{
1313 return static_cast<char>(toupper_l(static_cast<unsigned char>(c), __l));
1306 return static_cast<char>(toupper_l(static_cast<unsigned char>(c), __l_));
13141307}
13151308
13161309const char*
13171310ctype_byname<char>::do_toupper(char_type* low, const char_type* high) const
13181311{
13191312 for (; low != high; ++low)
1320 *low = static_cast<char>(toupper_l(static_cast<unsigned char>(*low), __l));
1313 *low = static_cast<char>(toupper_l(static_cast<unsigned char>(*low), __l_));
13211314 return low;
13221315}
13231316
13241317char
13251318ctype_byname<char>::do_tolower(char_type c) const
13261319{
1327 return static_cast<char>(tolower_l(static_cast<unsigned char>(c), __l));
1320 return static_cast<char>(tolower_l(static_cast<unsigned char>(c), __l_));
13281321}
13291322
13301323const char*
13311324ctype_byname<char>::do_tolower(char_type* low, const char_type* high) const
13321325{
13331326 for (; low != high; ++low)
1334 *low = static_cast<char>(tolower_l(static_cast<unsigned char>(*low), __l));
1327 *low = static_cast<char>(tolower_l(static_cast<unsigned char>(*low), __l_));
13351328 return low;
13361329}
13371330
......@@ -1340,45 +1333,45 @@ ctype_byname<char>::do_tolower(char_type* low, const char_type* high) const
13401333#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
13411334ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs)
13421335 : ctype<wchar_t>(refs),
1343 __l(newlocale(LC_ALL_MASK, name, 0))
1336 __l_(newlocale(LC_ALL_MASK, name, 0))
13441337{
1345 if (__l == 0)
1338 if (__l_ == 0)
13461339 __throw_runtime_error("ctype_byname<wchar_t>::ctype_byname"
13471340 " failed to construct for " + string(name));
13481341}
13491342
13501343ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs)
13511344 : ctype<wchar_t>(refs),
1352 __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
1345 __l_(newlocale(LC_ALL_MASK, name.c_str(), 0))
13531346{
1354 if (__l == 0)
1347 if (__l_ == 0)
13551348 __throw_runtime_error("ctype_byname<wchar_t>::ctype_byname"
13561349 " failed to construct for " + name);
13571350}
13581351
13591352ctype_byname<wchar_t>::~ctype_byname()
13601353{
1361 freelocale(__l);
1354 freelocale(__l_);
13621355}
13631356
13641357bool
13651358ctype_byname<wchar_t>::do_is(mask m, char_type c) const
13661359{
13671360#ifdef _LIBCPP_WCTYPE_IS_MASK
1368 return static_cast<bool>(iswctype_l(c, m, __l));
1361 return static_cast<bool>(iswctype_l(c, m, __l_));
13691362#else
13701363 bool result = false;
13711364 wint_t ch = static_cast<wint_t>(c);
1372 if ((m & space) == space) result |= (iswspace_l(ch, __l) != 0);
1373 if ((m & print) == print) result |= (iswprint_l(ch, __l) != 0);
1374 if ((m & cntrl) == cntrl) result |= (iswcntrl_l(ch, __l) != 0);
1375 if ((m & upper) == upper) result |= (iswupper_l(ch, __l) != 0);
1376 if ((m & lower) == lower) result |= (iswlower_l(ch, __l) != 0);
1377 if ((m & alpha) == alpha) result |= (iswalpha_l(ch, __l) != 0);
1378 if ((m & digit) == digit) result |= (iswdigit_l(ch, __l) != 0);
1379 if ((m & punct) == punct) result |= (iswpunct_l(ch, __l) != 0);
1380 if ((m & xdigit) == xdigit) result |= (iswxdigit_l(ch, __l) != 0);
1381 if ((m & blank) == blank) result |= (iswblank_l(ch, __l) != 0);
1365 if ((m & space) == space) result |= (iswspace_l(ch, __l_) != 0);
1366 if ((m & print) == print) result |= (iswprint_l(ch, __l_) != 0);
1367 if ((m & cntrl) == cntrl) result |= (iswcntrl_l(ch, __l_) != 0);
1368 if ((m & upper) == upper) result |= (iswupper_l(ch, __l_) != 0);
1369 if ((m & lower) == lower) result |= (iswlower_l(ch, __l_) != 0);
1370 if ((m & alpha) == alpha) result |= (iswalpha_l(ch, __l_) != 0);
1371 if ((m & digit) == digit) result |= (iswdigit_l(ch, __l_) != 0);
1372 if ((m & punct) == punct) result |= (iswpunct_l(ch, __l_) != 0);
1373 if ((m & xdigit) == xdigit) result |= (iswxdigit_l(ch, __l_) != 0);
1374 if ((m & blank) == blank) result |= (iswblank_l(ch, __l_) != 0);
13821375 return result;
13831376#endif
13841377}
......@@ -1394,32 +1387,32 @@ ctype_byname<wchar_t>::do_is(const char_type* low, const char_type* high, mask*
13941387 {
13951388 *vec = 0;
13961389 wint_t ch = static_cast<wint_t>(*low);
1397 if (iswspace_l(ch, __l))
1390 if (iswspace_l(ch, __l_))
13981391 *vec |= space;
13991392#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
1400 if (iswprint_l(ch, __l))
1393 if (iswprint_l(ch, __l_))
14011394 *vec |= print;
14021395#endif
1403 if (iswcntrl_l(ch, __l))
1396 if (iswcntrl_l(ch, __l_))
14041397 *vec |= cntrl;
1405 if (iswupper_l(ch, __l))
1398 if (iswupper_l(ch, __l_))
14061399 *vec |= upper;
1407 if (iswlower_l(ch, __l))
1400 if (iswlower_l(ch, __l_))
14081401 *vec |= lower;
14091402#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
1410 if (iswalpha_l(ch, __l))
1403 if (iswalpha_l(ch, __l_))
14111404 *vec |= alpha;
14121405#endif
1413 if (iswdigit_l(ch, __l))
1406 if (iswdigit_l(ch, __l_))
14141407 *vec |= digit;
1415 if (iswpunct_l(ch, __l))
1408 if (iswpunct_l(ch, __l_))
14161409 *vec |= punct;
14171410#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT
1418 if (iswxdigit_l(ch, __l))
1411 if (iswxdigit_l(ch, __l_))
14191412 *vec |= xdigit;
14201413#endif
14211414#if !defined(__sun__)
1422 if (iswblank_l(ch, __l))
1415 if (iswblank_l(ch, __l_))
14231416 *vec |= blank;
14241417#endif
14251418 }
......@@ -1433,20 +1426,20 @@ ctype_byname<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type*
14331426 for (; low != high; ++low)
14341427 {
14351428#ifdef _LIBCPP_WCTYPE_IS_MASK
1436 if (iswctype_l(*low, m, __l))
1429 if (iswctype_l(*low, m, __l_))
14371430 break;
14381431#else
14391432 wint_t ch = static_cast<wint_t>(*low);
1440 if ((m & space) == space && iswspace_l(ch, __l)) break;
1441 if ((m & print) == print && iswprint_l(ch, __l)) break;
1442 if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l)) break;
1443 if ((m & upper) == upper && iswupper_l(ch, __l)) break;
1444 if ((m & lower) == lower && iswlower_l(ch, __l)) break;
1445 if ((m & alpha) == alpha && iswalpha_l(ch, __l)) break;
1446 if ((m & digit) == digit && iswdigit_l(ch, __l)) break;
1447 if ((m & punct) == punct && iswpunct_l(ch, __l)) break;
1448 if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l)) break;
1449 if ((m & blank) == blank && iswblank_l(ch, __l)) break;
1433 if ((m & space) == space && iswspace_l(ch, __l_)) break;
1434 if ((m & print) == print && iswprint_l(ch, __l_)) break;
1435 if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l_)) break;
1436 if ((m & upper) == upper && iswupper_l(ch, __l_)) break;
1437 if ((m & lower) == lower && iswlower_l(ch, __l_)) break;
1438 if ((m & alpha) == alpha && iswalpha_l(ch, __l_)) break;
1439 if ((m & digit) == digit && iswdigit_l(ch, __l_)) break;
1440 if ((m & punct) == punct && iswpunct_l(ch, __l_)) break;
1441 if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l_)) break;
1442 if ((m & blank) == blank && iswblank_l(ch, __l_)) break;
14501443#endif
14511444 }
14521445 return low;
......@@ -1458,20 +1451,20 @@ ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type
14581451 for (; low != high; ++low)
14591452 {
14601453#ifdef _LIBCPP_WCTYPE_IS_MASK
1461 if (!iswctype_l(*low, m, __l))
1454 if (!iswctype_l(*low, m, __l_))
14621455 break;
14631456#else
14641457 wint_t ch = static_cast<wint_t>(*low);
1465 if ((m & space) == space && iswspace_l(ch, __l)) continue;
1466 if ((m & print) == print && iswprint_l(ch, __l)) continue;
1467 if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l)) continue;
1468 if ((m & upper) == upper && iswupper_l(ch, __l)) continue;
1469 if ((m & lower) == lower && iswlower_l(ch, __l)) continue;
1470 if ((m & alpha) == alpha && iswalpha_l(ch, __l)) continue;
1471 if ((m & digit) == digit && iswdigit_l(ch, __l)) continue;
1472 if ((m & punct) == punct && iswpunct_l(ch, __l)) continue;
1473 if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l)) continue;
1474 if ((m & blank) == blank && iswblank_l(ch, __l)) continue;
1458 if ((m & space) == space && iswspace_l(ch, __l_)) continue;
1459 if ((m & print) == print && iswprint_l(ch, __l_)) continue;
1460 if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l_)) continue;
1461 if ((m & upper) == upper && iswupper_l(ch, __l_)) continue;
1462 if ((m & lower) == lower && iswlower_l(ch, __l_)) continue;
1463 if ((m & alpha) == alpha && iswalpha_l(ch, __l_)) continue;
1464 if ((m & digit) == digit && iswdigit_l(ch, __l_)) continue;
1465 if ((m & punct) == punct && iswpunct_l(ch, __l_)) continue;
1466 if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l_)) continue;
1467 if ((m & blank) == blank && iswblank_l(ch, __l_)) continue;
14751468 break;
14761469#endif
14771470 }
......@@ -1481,49 +1474,49 @@ ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type
14811474wchar_t
14821475ctype_byname<wchar_t>::do_toupper(char_type c) const
14831476{
1484 return towupper_l(c, __l);
1477 return towupper_l(c, __l_);
14851478}
14861479
14871480const wchar_t*
14881481ctype_byname<wchar_t>::do_toupper(char_type* low, const char_type* high) const
14891482{
14901483 for (; low != high; ++low)
1491 *low = towupper_l(*low, __l);
1484 *low = towupper_l(*low, __l_);
14921485 return low;
14931486}
14941487
14951488wchar_t
14961489ctype_byname<wchar_t>::do_tolower(char_type c) const
14971490{
1498 return towlower_l(c, __l);
1491 return towlower_l(c, __l_);
14991492}
15001493
15011494const wchar_t*
15021495ctype_byname<wchar_t>::do_tolower(char_type* low, const char_type* high) const
15031496{
15041497 for (; low != high; ++low)
1505 *low = towlower_l(*low, __l);
1498 *low = towlower_l(*low, __l_);
15061499 return low;
15071500}
15081501
15091502wchar_t
15101503ctype_byname<wchar_t>::do_widen(char c) const
15111504{
1512 return __libcpp_btowc_l(c, __l);
1505 return __libcpp_btowc_l(c, __l_);
15131506}
15141507
15151508const char*
15161509ctype_byname<wchar_t>::do_widen(const char* low, const char* high, char_type* dest) const
15171510{
15181511 for (; low != high; ++low, ++dest)
1519 *dest = __libcpp_btowc_l(*low, __l);
1512 *dest = __libcpp_btowc_l(*low, __l_);
15201513 return low;
15211514}
15221515
15231516char
15241517ctype_byname<wchar_t>::do_narrow(char_type c, char dfault) const
15251518{
1526 int r = __libcpp_wctob_l(c, __l);
1519 int r = __libcpp_wctob_l(c, __l_);
15271520 return (r != EOF) ? static_cast<char>(r) : dfault;
15281521}
15291522
......@@ -1532,7 +1525,7 @@ ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, ch
15321525{
15331526 for (; low != high; ++low, ++dest)
15341527 {
1535 int r = __libcpp_wctob_l(*low, __l);
1528 int r = __libcpp_wctob_l(*low, __l_);
15361529 *dest = (r != EOF) ? static_cast<char>(r) : dfault;
15371530 }
15381531 return low;
......@@ -1607,23 +1600,23 @@ locale::id codecvt<wchar_t, char, mbstate_t>::id;
16071600
16081601codecvt<wchar_t, char, mbstate_t>::codecvt(size_t refs)
16091602 : locale::facet(refs),
1610 __l(_LIBCPP_GET_C_LOCALE)
1603 __l_(_LIBCPP_GET_C_LOCALE)
16111604{
16121605}
16131606
16141607codecvt<wchar_t, char, mbstate_t>::codecvt(const char* nm, size_t refs)
16151608 : locale::facet(refs),
1616 __l(newlocale(LC_ALL_MASK, nm, 0))
1609 __l_(newlocale(LC_ALL_MASK, nm, 0))
16171610{
1618 if (__l == 0)
1611 if (__l_ == 0)
16191612 __throw_runtime_error("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname"
16201613 " failed to construct for " + string(nm));
16211614}
16221615
16231616codecvt<wchar_t, char, mbstate_t>::~codecvt()
16241617{
1625 if (__l != _LIBCPP_GET_C_LOCALE)
1626 freelocale(__l);
1618 if (__l_ != _LIBCPP_GET_C_LOCALE)
1619 freelocale(__l_);
16271620}
16281621
16291622codecvt<wchar_t, char, mbstate_t>::result
......@@ -1643,13 +1636,13 @@ codecvt<wchar_t, char, mbstate_t>::do_out(state_type& st,
16431636 // save state in case it is needed to recover to_nxt on error
16441637 mbstate_t save_state = st;
16451638 size_t n = __libcpp_wcsnrtombs_l(to, &frm_nxt, static_cast<size_t>(fend-frm),
1646 static_cast<size_t>(to_end-to), &st, __l);
1639 static_cast<size_t>(to_end-to), &st, __l_);
16471640 if (n == size_t(-1))
16481641 {
16491642 // need to recover to_nxt
16501643 for (to_nxt = to; frm != frm_nxt; ++frm)
16511644 {
1652 n = __libcpp_wcrtomb_l(to_nxt, *frm, &save_state, __l);
1645 n = __libcpp_wcrtomb_l(to_nxt, *frm, &save_state, __l_);
16531646 if (n == size_t(-1))
16541647 break;
16551648 to_nxt += n;
......@@ -1666,7 +1659,7 @@ codecvt<wchar_t, char, mbstate_t>::do_out(state_type& st,
16661659 {
16671660 // Try to write the terminating null
16681661 extern_type tmp[MB_LEN_MAX];
1669 n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l);
1662 n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l_);
16701663 if (n == size_t(-1)) // on error
16711664 return error;
16721665 if (n > static_cast<size_t>(to_end-to_nxt)) // is there room?
......@@ -1700,14 +1693,14 @@ codecvt<wchar_t, char, mbstate_t>::do_in(state_type& st,
17001693 // save state in case it is needed to recover to_nxt on error
17011694 mbstate_t save_state = st;
17021695 size_t n = __libcpp_mbsnrtowcs_l(to, &frm_nxt, static_cast<size_t>(fend-frm),
1703 static_cast<size_t>(to_end-to), &st, __l);
1696 static_cast<size_t>(to_end-to), &st, __l_);
17041697 if (n == size_t(-1))
17051698 {
17061699 // need to recover to_nxt
17071700 for (to_nxt = to; frm != frm_nxt; ++to_nxt)
17081701 {
17091702 n = __libcpp_mbrtowc_l(to_nxt, frm, static_cast<size_t>(fend-frm),
1710 &save_state, __l);
1703 &save_state, __l_);
17111704 switch (n)
17121705 {
17131706 case 0:
......@@ -1735,7 +1728,7 @@ codecvt<wchar_t, char, mbstate_t>::do_in(state_type& st,
17351728 if (fend != frm_end) // set up next null terminated sequence
17361729 {
17371730 // Try to write the terminating null
1738 n = __libcpp_mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l);
1731 n = __libcpp_mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l_);
17391732 if (n != 0) // on error
17401733 return error;
17411734 ++to_nxt;
......@@ -1755,7 +1748,7 @@ codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& st,
17551748{
17561749 to_nxt = to;
17571750 extern_type tmp[MB_LEN_MAX];
1758 size_t n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l);
1751 size_t n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l_);
17591752 if (n == size_t(-1) || n == 0) // on error
17601753 return error;
17611754 --n;
......@@ -1769,11 +1762,11 @@ codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& st,
17691762int
17701763codecvt<wchar_t, char, mbstate_t>::do_encoding() const noexcept
17711764{
1772 if (__libcpp_mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) != 0)
1765 if (__libcpp_mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l_) != 0)
17731766 return -1;
17741767
17751768 // stateless encoding
1776 if (__l == 0 || __libcpp_mb_cur_max_l(__l) == 1) // there are no known constant length encodings
1769 if (__l_ == 0 || __libcpp_mb_cur_max_l(__l_) == 1) // there are no known constant length encodings
17771770 return 1; // which take more than 1 char to form a wchar_t
17781771 return 0;
17791772}
......@@ -1791,7 +1784,7 @@ codecvt<wchar_t, char, mbstate_t>::do_length(state_type& st,
17911784 int nbytes = 0;
17921785 for (size_t nwchar_t = 0; nwchar_t < mx && frm != frm_end; ++nwchar_t)
17931786 {
1794 size_t n = __libcpp_mbrlen_l(frm, static_cast<size_t>(frm_end-frm), &st, __l);
1787 size_t n = __libcpp_mbrlen_l(frm, static_cast<size_t>(frm_end-frm), &st, __l_);
17951788 switch (n)
17961789 {
17971790 case 0:
......@@ -1813,7 +1806,7 @@ codecvt<wchar_t, char, mbstate_t>::do_length(state_type& st,
18131806int
18141807codecvt<wchar_t, char, mbstate_t>::do_max_length() const noexcept
18151808{
1816 return __l == 0 ? 1 : static_cast<int>(__libcpp_mb_cur_max_l(__l));
1809 return __l_ == 0 ? 1 : static_cast<int>(__libcpp_mb_cur_max_l(__l_));
18171810}
18181811#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
18191812
......@@ -3545,10 +3538,10 @@ __codecvt_utf8<wchar_t>::do_out(state_type&,
35453538 uint8_t* _to_nxt = _to;
35463539#if defined(_LIBCPP_SHORT_WCHAR)
35473540 result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3548 _Maxcode_, _Mode_);
3541 __maxcode_, __mode_);
35493542#else
35503543 result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3551 _Maxcode_, _Mode_);
3544 __maxcode_, __mode_);
35523545#endif
35533546 frm_nxt = frm + (_frm_nxt - _frm);
35543547 to_nxt = to + (_to_nxt - _to);
......@@ -3568,13 +3561,13 @@ __codecvt_utf8<wchar_t>::do_in(state_type&,
35683561 uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
35693562 uint16_t* _to_nxt = _to;
35703563 result r = utf8_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3571 _Maxcode_, _Mode_);
3564 __maxcode_, __mode_);
35723565#else
35733566 uint32_t* _to = reinterpret_cast<uint32_t*>(to);
35743567 uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
35753568 uint32_t* _to_nxt = _to;
35763569 result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3577 _Maxcode_, _Mode_);
3570 __maxcode_, __mode_);
35783571#endif
35793572 frm_nxt = frm + (_frm_nxt - _frm);
35803573 to_nxt = to + (_to_nxt - _to);
......@@ -3608,9 +3601,9 @@ __codecvt_utf8<wchar_t>::do_length(state_type&,
36083601 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
36093602 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
36103603#if defined(_LIBCPP_SHORT_WCHAR)
3611 return utf8_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
3604 return utf8_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
36123605#else
3613 return utf8_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
3606 return utf8_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
36143607#endif
36153608}
36163609
......@@ -3619,11 +3612,11 @@ int
36193612__codecvt_utf8<wchar_t>::do_max_length() const noexcept
36203613{
36213614#if defined(_LIBCPP_SHORT_WCHAR)
3622 if (_Mode_ & consume_header)
3615 if (__mode_ & consume_header)
36233616 return 6;
36243617 return 3;
36253618#else
3626 if (_Mode_ & consume_header)
3619 if (__mode_ & consume_header)
36273620 return 7;
36283621 return 4;
36293622#endif
......@@ -3644,7 +3637,7 @@ __codecvt_utf8<char16_t>::do_out(state_type&,
36443637 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
36453638 uint8_t* _to_nxt = _to;
36463639 result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3647 _Maxcode_, _Mode_);
3640 __maxcode_, __mode_);
36483641 frm_nxt = frm + (_frm_nxt - _frm);
36493642 to_nxt = to + (_to_nxt - _to);
36503643 return r;
......@@ -3662,7 +3655,7 @@ __codecvt_utf8<char16_t>::do_in(state_type&,
36623655 uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
36633656 uint16_t* _to_nxt = _to;
36643657 result r = utf8_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3665 _Maxcode_, _Mode_);
3658 __maxcode_, __mode_);
36663659 frm_nxt = frm + (_frm_nxt - _frm);
36673660 to_nxt = to + (_to_nxt - _to);
36683661 return r;
......@@ -3694,14 +3687,14 @@ __codecvt_utf8<char16_t>::do_length(state_type&,
36943687{
36953688 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
36963689 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
3697 return utf8_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
3690 return utf8_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
36983691}
36993692
37003693_LIBCPP_SUPPRESS_DEPRECATED_PUSH
37013694int
37023695__codecvt_utf8<char16_t>::do_max_length() const noexcept
37033696{
3704 if (_Mode_ & consume_header)
3697 if (__mode_ & consume_header)
37053698 return 6;
37063699 return 3;
37073700}
......@@ -3721,7 +3714,7 @@ __codecvt_utf8<char32_t>::do_out(state_type&,
37213714 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
37223715 uint8_t* _to_nxt = _to;
37233716 result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3724 _Maxcode_, _Mode_);
3717 __maxcode_, __mode_);
37253718 frm_nxt = frm + (_frm_nxt - _frm);
37263719 to_nxt = to + (_to_nxt - _to);
37273720 return r;
......@@ -3739,7 +3732,7 @@ __codecvt_utf8<char32_t>::do_in(state_type&,
37393732 uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
37403733 uint32_t* _to_nxt = _to;
37413734 result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3742 _Maxcode_, _Mode_);
3735 __maxcode_, __mode_);
37433736 frm_nxt = frm + (_frm_nxt - _frm);
37443737 to_nxt = to + (_to_nxt - _to);
37453738 return r;
......@@ -3771,14 +3764,14 @@ __codecvt_utf8<char32_t>::do_length(state_type&,
37713764{
37723765 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
37733766 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
3774 return utf8_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
3767 return utf8_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
37753768}
37763769
37773770_LIBCPP_SUPPRESS_DEPRECATED_PUSH
37783771int
37793772__codecvt_utf8<char32_t>::do_max_length() const noexcept
37803773{
3781 if (_Mode_ & consume_header)
3774 if (__mode_ & consume_header)
37823775 return 7;
37833776 return 4;
37843777}
......@@ -3806,10 +3799,10 @@ __codecvt_utf16<wchar_t, false>::do_out(state_type&,
38063799 uint8_t* _to_nxt = _to;
38073800#if defined(_LIBCPP_SHORT_WCHAR)
38083801 result r = ucs2_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3809 _Maxcode_, _Mode_);
3802 __maxcode_, __mode_);
38103803#else
38113804 result r = ucs4_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3812 _Maxcode_, _Mode_);
3805 __maxcode_, __mode_);
38133806#endif
38143807 frm_nxt = frm + (_frm_nxt - _frm);
38153808 to_nxt = to + (_to_nxt - _to);
......@@ -3829,13 +3822,13 @@ __codecvt_utf16<wchar_t, false>::do_in(state_type&,
38293822 uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
38303823 uint16_t* _to_nxt = _to;
38313824 result r = utf16be_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3832 _Maxcode_, _Mode_);
3825 __maxcode_, __mode_);
38333826#else
38343827 uint32_t* _to = reinterpret_cast<uint32_t*>(to);
38353828 uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
38363829 uint32_t* _to_nxt = _to;
38373830 result r = utf16be_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3838 _Maxcode_, _Mode_);
3831 __maxcode_, __mode_);
38393832#endif
38403833 frm_nxt = frm + (_frm_nxt - _frm);
38413834 to_nxt = to + (_to_nxt - _to);
......@@ -3869,9 +3862,9 @@ __codecvt_utf16<wchar_t, false>::do_length(state_type&,
38693862 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
38703863 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
38713864#if defined(_LIBCPP_SHORT_WCHAR)
3872 return utf16be_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
3865 return utf16be_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
38733866#else
3874 return utf16be_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
3867 return utf16be_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
38753868#endif
38763869}
38773870
......@@ -3879,11 +3872,11 @@ int
38793872__codecvt_utf16<wchar_t, false>::do_max_length() const noexcept
38803873{
38813874#if defined(_LIBCPP_SHORT_WCHAR)
3882 if (_Mode_ & consume_header)
3875 if (__mode_ & consume_header)
38833876 return 4;
38843877 return 2;
38853878#else
3886 if (_Mode_ & consume_header)
3879 if (__mode_ & consume_header)
38873880 return 6;
38883881 return 4;
38893882#endif
......@@ -3910,10 +3903,10 @@ __codecvt_utf16<wchar_t, true>::do_out(state_type&,
39103903 uint8_t* _to_nxt = _to;
39113904#if defined(_LIBCPP_SHORT_WCHAR)
39123905 result r = ucs2_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3913 _Maxcode_, _Mode_);
3906 __maxcode_, __mode_);
39143907#else
39153908 result r = ucs4_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3916 _Maxcode_, _Mode_);
3909 __maxcode_, __mode_);
39173910#endif
39183911 frm_nxt = frm + (_frm_nxt - _frm);
39193912 to_nxt = to + (_to_nxt - _to);
......@@ -3933,13 +3926,13 @@ __codecvt_utf16<wchar_t, true>::do_in(state_type&,
39333926 uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
39343927 uint16_t* _to_nxt = _to;
39353928 result r = utf16le_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3936 _Maxcode_, _Mode_);
3929 __maxcode_, __mode_);
39373930#else
39383931 uint32_t* _to = reinterpret_cast<uint32_t*>(to);
39393932 uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
39403933 uint32_t* _to_nxt = _to;
39413934 result r = utf16le_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3942 _Maxcode_, _Mode_);
3935 __maxcode_, __mode_);
39433936#endif
39443937 frm_nxt = frm + (_frm_nxt - _frm);
39453938 to_nxt = to + (_to_nxt - _to);
......@@ -3973,9 +3966,9 @@ __codecvt_utf16<wchar_t, true>::do_length(state_type&,
39733966 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
39743967 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
39753968#if defined(_LIBCPP_SHORT_WCHAR)
3976 return utf16le_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
3969 return utf16le_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
39773970#else
3978 return utf16le_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
3971 return utf16le_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
39793972#endif
39803973}
39813974
......@@ -3983,11 +3976,11 @@ int
39833976__codecvt_utf16<wchar_t, true>::do_max_length() const noexcept
39843977{
39853978#if defined(_LIBCPP_SHORT_WCHAR)
3986 if (_Mode_ & consume_header)
3979 if (__mode_ & consume_header)
39873980 return 4;
39883981 return 2;
39893982#else
3990 if (_Mode_ & consume_header)
3983 if (__mode_ & consume_header)
39913984 return 6;
39923985 return 4;
39933986#endif
......@@ -4008,7 +4001,7 @@ __codecvt_utf16<char16_t, false>::do_out(state_type&,
40084001 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
40094002 uint8_t* _to_nxt = _to;
40104003 result r = ucs2_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4011 _Maxcode_, _Mode_);
4004 __maxcode_, __mode_);
40124005 frm_nxt = frm + (_frm_nxt - _frm);
40134006 to_nxt = to + (_to_nxt - _to);
40144007 return r;
......@@ -4026,7 +4019,7 @@ __codecvt_utf16<char16_t, false>::do_in(state_type&,
40264019 uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
40274020 uint16_t* _to_nxt = _to;
40284021 result r = utf16be_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4029 _Maxcode_, _Mode_);
4022 __maxcode_, __mode_);
40304023 frm_nxt = frm + (_frm_nxt - _frm);
40314024 to_nxt = to + (_to_nxt - _to);
40324025 return r;
......@@ -4058,14 +4051,14 @@ __codecvt_utf16<char16_t, false>::do_length(state_type&,
40584051{
40594052 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
40604053 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
4061 return utf16be_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
4054 return utf16be_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
40624055}
40634056
40644057_LIBCPP_SUPPRESS_DEPRECATED_PUSH
40654058int
40664059__codecvt_utf16<char16_t, false>::do_max_length() const noexcept
40674060{
4068 if (_Mode_ & consume_header)
4061 if (__mode_ & consume_header)
40694062 return 4;
40704063 return 2;
40714064}
......@@ -4085,7 +4078,7 @@ __codecvt_utf16<char16_t, true>::do_out(state_type&,
40854078 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
40864079 uint8_t* _to_nxt = _to;
40874080 result r = ucs2_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4088 _Maxcode_, _Mode_);
4081 __maxcode_, __mode_);
40894082 frm_nxt = frm + (_frm_nxt - _frm);
40904083 to_nxt = to + (_to_nxt - _to);
40914084 return r;
......@@ -4103,7 +4096,7 @@ __codecvt_utf16<char16_t, true>::do_in(state_type&,
41034096 uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
41044097 uint16_t* _to_nxt = _to;
41054098 result r = utf16le_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4106 _Maxcode_, _Mode_);
4099 __maxcode_, __mode_);
41074100 frm_nxt = frm + (_frm_nxt - _frm);
41084101 to_nxt = to + (_to_nxt - _to);
41094102 return r;
......@@ -4135,14 +4128,14 @@ __codecvt_utf16<char16_t, true>::do_length(state_type&,
41354128{
41364129 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
41374130 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
4138 return utf16le_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
4131 return utf16le_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
41394132}
41404133
41414134_LIBCPP_SUPPRESS_DEPRECATED_PUSH
41424135int
41434136__codecvt_utf16<char16_t, true>::do_max_length() const noexcept
41444137{
4145 if (_Mode_ & consume_header)
4138 if (__mode_ & consume_header)
41464139 return 4;
41474140 return 2;
41484141}
......@@ -4162,7 +4155,7 @@ __codecvt_utf16<char32_t, false>::do_out(state_type&,
41624155 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
41634156 uint8_t* _to_nxt = _to;
41644157 result r = ucs4_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4165 _Maxcode_, _Mode_);
4158 __maxcode_, __mode_);
41664159 frm_nxt = frm + (_frm_nxt - _frm);
41674160 to_nxt = to + (_to_nxt - _to);
41684161 return r;
......@@ -4180,7 +4173,7 @@ __codecvt_utf16<char32_t, false>::do_in(state_type&,
41804173 uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
41814174 uint32_t* _to_nxt = _to;
41824175 result r = utf16be_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4183 _Maxcode_, _Mode_);
4176 __maxcode_, __mode_);
41844177 frm_nxt = frm + (_frm_nxt - _frm);
41854178 to_nxt = to + (_to_nxt - _to);
41864179 return r;
......@@ -4212,14 +4205,14 @@ __codecvt_utf16<char32_t, false>::do_length(state_type&,
42124205{
42134206 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
42144207 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
4215 return utf16be_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
4208 return utf16be_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
42164209}
42174210
42184211_LIBCPP_SUPPRESS_DEPRECATED_PUSH
42194212int
42204213__codecvt_utf16<char32_t, false>::do_max_length() const noexcept
42214214{
4222 if (_Mode_ & consume_header)
4215 if (__mode_ & consume_header)
42234216 return 6;
42244217 return 4;
42254218}
......@@ -4239,7 +4232,7 @@ __codecvt_utf16<char32_t, true>::do_out(state_type&,
42394232 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
42404233 uint8_t* _to_nxt = _to;
42414234 result r = ucs4_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4242 _Maxcode_, _Mode_);
4235 __maxcode_, __mode_);
42434236 frm_nxt = frm + (_frm_nxt - _frm);
42444237 to_nxt = to + (_to_nxt - _to);
42454238 return r;
......@@ -4257,7 +4250,7 @@ __codecvt_utf16<char32_t, true>::do_in(state_type&,
42574250 uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
42584251 uint32_t* _to_nxt = _to;
42594252 result r = utf16le_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4260 _Maxcode_, _Mode_);
4253 __maxcode_, __mode_);
42614254 frm_nxt = frm + (_frm_nxt - _frm);
42624255 to_nxt = to + (_to_nxt - _to);
42634256 return r;
......@@ -4289,14 +4282,14 @@ __codecvt_utf16<char32_t, true>::do_length(state_type&,
42894282{
42904283 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
42914284 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
4292 return utf16le_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
4285 return utf16le_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
42934286}
42944287
42954288_LIBCPP_SUPPRESS_DEPRECATED_PUSH
42964289int
42974290__codecvt_utf16<char32_t, true>::do_max_length() const noexcept
42984291{
4299 if (_Mode_ & consume_header)
4292 if (__mode_ & consume_header)
43004293 return 6;
43014294 return 4;
43024295}
......@@ -4323,7 +4316,7 @@ __codecvt_utf8_utf16<wchar_t>::do_out(state_type&,
43234316 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
43244317 uint8_t* _to_nxt = _to;
43254318 result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4326 _Maxcode_, _Mode_);
4319 __maxcode_, __mode_);
43274320 frm_nxt = frm + (_frm_nxt - _frm);
43284321 to_nxt = to + (_to_nxt - _to);
43294322 return r;
......@@ -4347,7 +4340,7 @@ __codecvt_utf8_utf16<wchar_t>::do_in(state_type&,
43474340 uint32_t* _to_nxt = _to;
43484341#endif
43494342 result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4350 _Maxcode_, _Mode_);
4343 __maxcode_, __mode_);
43514344 frm_nxt = frm + (_frm_nxt - _frm);
43524345 to_nxt = to + (_to_nxt - _to);
43534346 return r;
......@@ -4379,13 +4372,13 @@ __codecvt_utf8_utf16<wchar_t>::do_length(state_type&,
43794372{
43804373 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
43814374 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
4382 return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
4375 return utf8_to_utf16_length(_frm, _frm_end, mx, __maxcode_, __mode_);
43834376}
43844377
43854378int
43864379__codecvt_utf8_utf16<wchar_t>::do_max_length() const noexcept
43874380{
4388 if (_Mode_ & consume_header)
4381 if (__mode_ & consume_header)
43894382 return 7;
43904383 return 4;
43914384}
......@@ -4405,7 +4398,7 @@ __codecvt_utf8_utf16<char16_t>::do_out(state_type&,
44054398 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
44064399 uint8_t* _to_nxt = _to;
44074400 result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4408 _Maxcode_, _Mode_);
4401 __maxcode_, __mode_);
44094402 frm_nxt = frm + (_frm_nxt - _frm);
44104403 to_nxt = to + (_to_nxt - _to);
44114404 return r;
......@@ -4423,7 +4416,7 @@ __codecvt_utf8_utf16<char16_t>::do_in(state_type&,
44234416 uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
44244417 uint16_t* _to_nxt = _to;
44254418 result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4426 _Maxcode_, _Mode_);
4419 __maxcode_, __mode_);
44274420 frm_nxt = frm + (_frm_nxt - _frm);
44284421 to_nxt = to + (_to_nxt - _to);
44294422 return r;
......@@ -4455,14 +4448,14 @@ __codecvt_utf8_utf16<char16_t>::do_length(state_type&,
44554448{
44564449 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
44574450 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
4458 return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
4451 return utf8_to_utf16_length(_frm, _frm_end, mx, __maxcode_, __mode_);
44594452}
44604453
44614454_LIBCPP_SUPPRESS_DEPRECATED_PUSH
44624455int
44634456__codecvt_utf8_utf16<char16_t>::do_max_length() const noexcept
44644457{
4465 if (_Mode_ & consume_header)
4458 if (__mode_ & consume_header)
44664459 return 7;
44674460 return 4;
44684461}
......@@ -4482,7 +4475,7 @@ __codecvt_utf8_utf16<char32_t>::do_out(state_type&,
44824475 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
44834476 uint8_t* _to_nxt = _to;
44844477 result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4485 _Maxcode_, _Mode_);
4478 __maxcode_, __mode_);
44864479 frm_nxt = frm + (_frm_nxt - _frm);
44874480 to_nxt = to + (_to_nxt - _to);
44884481 return r;
......@@ -4500,7 +4493,7 @@ __codecvt_utf8_utf16<char32_t>::do_in(state_type&,
45004493 uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
45014494 uint32_t* _to_nxt = _to;
45024495 result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4503 _Maxcode_, _Mode_);
4496 __maxcode_, __mode_);
45044497 frm_nxt = frm + (_frm_nxt - _frm);
45054498 to_nxt = to + (_to_nxt - _to);
45064499 return r;
......@@ -4532,14 +4525,14 @@ __codecvt_utf8_utf16<char32_t>::do_length(state_type&,
45324525{
45334526 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
45344527 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
4535 return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
4528 return utf8_to_utf16_length(_frm, _frm_end, mx, __maxcode_, __mode_);
45364529}
45374530
45384531_LIBCPP_SUPPRESS_DEPRECATED_PUSH
45394532int
45404533__codecvt_utf8_utf16<char32_t>::do_max_length() const noexcept
45414534{
4542 if (_Mode_ & consume_header)
4535 if (__mode_ & consume_header)
45434536 return 7;
45444537 return 4;
45454538}
......@@ -4805,7 +4798,7 @@ __check_grouping(const string& __grouping, unsigned* __g, unsigned* __g_end,
48054798{
48064799// if the grouping pattern is empty _or_ there are no grouping bits, then do nothing
48074800// we always have at least a single entry in [__g, __g_end); the end of the input sequence
4808 if (__grouping.size() != 0 && __g_end - __g > 1)
4801 if (__grouping.size() != 0 && __g_end - __g > 1)
48094802 {
48104803 reverse(__g, __g_end);
48114804 const char* __ig = __grouping.data();
......@@ -4838,7 +4831,7 @@ __num_put_base::__format_int(char* __fmtp, const char* __len, bool __signd,
48384831 if ((__flags & ios_base::showpos) &&
48394832 (__flags & ios_base::basefield) != ios_base::oct &&
48404833 (__flags & ios_base::basefield) != ios_base::hex &&
4841 __signd)
4834 __signd)
48424835 *__fmtp++ = '+';
48434836 if (__flags & ios_base::showbase)
48444837 *__fmtp++ = '#';
lib/libcxx/src/memory.cpp+4-4
......@@ -152,21 +152,21 @@ static constinit __libcpp_mutex_t mut_back[__sp_mut_count] =
152152};
153153
154154_LIBCPP_CONSTEXPR __sp_mut::__sp_mut(void* p) noexcept
155 : __lx(p)
155 : __lx_(p)
156156{
157157}
158158
159159void
160160__sp_mut::lock() noexcept
161161{
162 auto m = static_cast<__libcpp_mutex_t*>(__lx);
162 auto m = static_cast<__libcpp_mutex_t*>(__lx_);
163163 __libcpp_mutex_lock(m);
164164}
165165
166166void
167167__sp_mut::unlock() noexcept
168168{
169 __libcpp_mutex_unlock(static_cast<__libcpp_mutex_t*>(__lx));
169 __libcpp_mutex_unlock(static_cast<__libcpp_mutex_t*>(__lx_));
170170}
171171
172172__sp_mut&
......@@ -194,7 +194,7 @@ align(size_t alignment, size_t size, void*& ptr, size_t& space)
194194 if (size <= space)
195195 {
196196 char* p1 = static_cast<char*>(ptr);
197 char* p2 = reinterpret_cast<char*>(reinterpret_cast<size_t>(p1 + (alignment - 1)) & -alignment);
197 char* p2 = reinterpret_cast<char*>(reinterpret_cast<uintptr_t>(p1 + (alignment - 1)) & -alignment);
198198 size_t d = static_cast<size_t>(p2 - p1);
199199 if (d <= space - size)
200200 {
lib/libcxx/src/memory_resource.cpp created+496
......@@ -0,0 +1,496 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include <memory>
10#include <memory_resource>
11
12#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER
13# include <atomic>
14#elif !defined(_LIBCPP_HAS_NO_THREADS)
15# include <mutex>
16# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
17# pragma comment(lib, "pthread")
18# endif
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23namespace pmr {
24
25// memory_resource
26
27memory_resource::~memory_resource() = default;
28
29// new_delete_resource()
30
31#ifdef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
32static bool is_aligned_to(void* ptr, size_t align) {
33 void* p2 = ptr;
34 size_t space = 1;
35 void* result = std::align(align, 1, p2, space);
36 return (result == ptr);
37}
38#endif
39
40class _LIBCPP_TYPE_VIS __new_delete_memory_resource_imp : public memory_resource {
41 void* do_allocate(size_t bytes, size_t align) override {
42#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
43 return std::__libcpp_allocate(bytes, align);
44#else
45 if (bytes == 0)
46 bytes = 1;
47 void* result = std::__libcpp_allocate(bytes, align);
48 if (!is_aligned_to(result, align)) {
49 std::__libcpp_deallocate(result, bytes, align);
50 __throw_bad_alloc();
51 }
52 return result;
53#endif
54 }
55
56 void do_deallocate(void* p, size_t bytes, size_t align) override { std::__libcpp_deallocate(p, bytes, align); }
57
58 bool do_is_equal(const memory_resource& other) const noexcept override { return &other == this; }
59};
60
61// null_memory_resource()
62
63class _LIBCPP_TYPE_VIS __null_memory_resource_imp : public memory_resource {
64 void* do_allocate(size_t, size_t) override { __throw_bad_alloc(); }
65 void do_deallocate(void*, size_t, size_t) override {}
66 bool do_is_equal(const memory_resource& other) const noexcept override { return &other == this; }
67};
68
69namespace {
70
71union ResourceInitHelper {
72 struct {
73 __new_delete_memory_resource_imp new_delete_res;
74 __null_memory_resource_imp null_res;
75 } resources;
76 char dummy;
77 _LIBCPP_CONSTEXPR_SINCE_CXX14 ResourceInitHelper() : resources() {}
78 ~ResourceInitHelper() {}
79};
80
81// Pretend we're inside a system header so the compiler doesn't flag the use of the init_priority
82// attribute with a value that's reserved for the implementation (we're the implementation).
83#include "memory_resource_init_helper.h"
84
85} // end namespace
86
87memory_resource* new_delete_resource() noexcept { return &res_init.resources.new_delete_res; }
88
89memory_resource* null_memory_resource() noexcept { return &res_init.resources.null_res; }
90
91// default_memory_resource()
92
93static memory_resource* __default_memory_resource(bool set = false, memory_resource* new_res = nullptr) noexcept {
94#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER
95 static constinit atomic<memory_resource*> __res{&res_init.resources.new_delete_res};
96 if (set) {
97 new_res = new_res ? new_res : new_delete_resource();
98 // TODO: Can a weaker ordering be used?
99 return std::atomic_exchange_explicit(&__res, new_res, memory_order_acq_rel);
100 } else {
101 return std::atomic_load_explicit(&__res, memory_order_acquire);
102 }
103#elif !defined(_LIBCPP_HAS_NO_THREADS)
104 static constinit memory_resource* res = &res_init.resources.new_delete_res;
105 static mutex res_lock;
106 if (set) {
107 new_res = new_res ? new_res : new_delete_resource();
108 lock_guard<mutex> guard(res_lock);
109 memory_resource* old_res = res;
110 res = new_res;
111 return old_res;
112 } else {
113 lock_guard<mutex> guard(res_lock);
114 return res;
115 }
116#else
117 static constinit memory_resource* res = &res_init.resources.new_delete_res;
118 if (set) {
119 new_res = new_res ? new_res : new_delete_resource();
120 memory_resource* old_res = res;
121 res = new_res;
122 return old_res;
123 } else {
124 return res;
125 }
126#endif
127}
128
129memory_resource* get_default_resource() noexcept { return __default_memory_resource(); }
130
131memory_resource* set_default_resource(memory_resource* __new_res) noexcept {
132 return __default_memory_resource(true, __new_res);
133}
134
135// 23.12.5, mem.res.pool
136
137static size_t roundup(size_t count, size_t alignment) {
138 size_t mask = alignment - 1;
139 return (count + mask) & ~mask;
140}
141
142struct unsynchronized_pool_resource::__adhoc_pool::__chunk_footer {
143 __chunk_footer* __next_;
144 char* __start_;
145 size_t __align_;
146 size_t __allocation_size() { return (reinterpret_cast<char*>(this) - __start_) + sizeof(*this); }
147};
148
149void unsynchronized_pool_resource::__adhoc_pool::__release_ptr(memory_resource* upstream) {
150 while (__first_ != nullptr) {
151 __chunk_footer* next = __first_->__next_;
152 upstream->deallocate(__first_->__start_, __first_->__allocation_size(), __first_->__align_);
153 __first_ = next;
154 }
155}
156
157void* unsynchronized_pool_resource::__adhoc_pool::__do_allocate(memory_resource* upstream, size_t bytes, size_t align) {
158 const size_t footer_size = sizeof(__chunk_footer);
159 const size_t footer_align = alignof(__chunk_footer);
160
161 if (align < footer_align)
162 align = footer_align;
163
164 size_t aligned_capacity = roundup(bytes, footer_align) + footer_size;
165
166 void* result = upstream->allocate(aligned_capacity, align);
167
168 __chunk_footer* h = (__chunk_footer*)((char*)result + aligned_capacity - footer_size);
169 h->__next_ = __first_;
170 h->__start_ = (char*)result;
171 h->__align_ = align;
172 __first_ = h;
173 return result;
174}
175
176void unsynchronized_pool_resource::__adhoc_pool::__do_deallocate(
177 memory_resource* upstream, void* p, size_t bytes, size_t align) {
178 _LIBCPP_ASSERT(__first_ != nullptr, "deallocating a block that was not allocated with this allocator");
179 if (__first_->__start_ == p) {
180 __chunk_footer* next = __first_->__next_;
181 upstream->deallocate(p, __first_->__allocation_size(), __first_->__align_);
182 __first_ = next;
183 } else {
184 for (__chunk_footer* h = __first_; h->__next_ != nullptr; h = h->__next_) {
185 if (h->__next_->__start_ == p) {
186 __chunk_footer* next = h->__next_->__next_;
187 upstream->deallocate(p, h->__next_->__allocation_size(), h->__next_->__align_);
188 h->__next_ = next;
189 return;
190 }
191 }
192 _LIBCPP_ASSERT(false, "deallocating a block that was not allocated with this allocator");
193 }
194}
195
196class unsynchronized_pool_resource::__fixed_pool {
197 struct __chunk_footer {
198 __chunk_footer* __next_;
199 char* __start_;
200 size_t __align_;
201 size_t __allocation_size() { return (reinterpret_cast<char*>(this) - __start_) + sizeof(*this); }
202 };
203
204 struct __vacancy_header {
205 __vacancy_header* __next_vacancy_;
206 };
207
208 __chunk_footer* __first_chunk_ = nullptr;
209 __vacancy_header* __first_vacancy_ = nullptr;
210
211public:
212 explicit __fixed_pool() = default;
213
214 void __release_ptr(memory_resource* upstream) {
215 __first_vacancy_ = nullptr;
216 while (__first_chunk_ != nullptr) {
217 __chunk_footer* next = __first_chunk_->__next_;
218 upstream->deallocate(__first_chunk_->__start_, __first_chunk_->__allocation_size(), __first_chunk_->__align_);
219 __first_chunk_ = next;
220 }
221 }
222
223 void* __try_allocate_from_vacancies() {
224 if (__first_vacancy_ != nullptr) {
225 void* result = __first_vacancy_;
226 __first_vacancy_ = __first_vacancy_->__next_vacancy_;
227 return result;
228 }
229 return nullptr;
230 }
231
232 void* __allocate_in_new_chunk(memory_resource* upstream, size_t block_size, size_t chunk_size) {
233 _LIBCPP_ASSERT(chunk_size % block_size == 0, "");
234 static_assert(__default_alignment >= alignof(std::max_align_t), "");
235 static_assert(__default_alignment >= alignof(__chunk_footer), "");
236 static_assert(__default_alignment >= alignof(__vacancy_header), "");
237
238 const size_t footer_size = sizeof(__chunk_footer);
239 const size_t footer_align = alignof(__chunk_footer);
240
241 size_t aligned_capacity = roundup(chunk_size, footer_align) + footer_size;
242
243 void* result = upstream->allocate(aligned_capacity, __default_alignment);
244
245 __chunk_footer* h = (__chunk_footer*)((char*)result + aligned_capacity - footer_size);
246 h->__next_ = __first_chunk_;
247 h->__start_ = (char*)result;
248 h->__align_ = __default_alignment;
249 __first_chunk_ = h;
250
251 if (chunk_size > block_size) {
252 __vacancy_header* last_vh = this->__first_vacancy_;
253 for (size_t i = block_size; i != chunk_size; i += block_size) {
254 __vacancy_header* vh = (__vacancy_header*)((char*)result + i);
255 vh->__next_vacancy_ = last_vh;
256 last_vh = vh;
257 }
258 this->__first_vacancy_ = last_vh;
259 }
260 return result;
261 }
262
263 void __evacuate(void* p) {
264 __vacancy_header* vh = (__vacancy_header*)(p);
265 vh->__next_vacancy_ = __first_vacancy_;
266 __first_vacancy_ = vh;
267 }
268
269 size_t __previous_chunk_size_in_bytes() const { return __first_chunk_ ? __first_chunk_->__allocation_size() : 0; }
270
271 static const size_t __default_alignment = alignof(max_align_t);
272};
273
274size_t unsynchronized_pool_resource::__pool_block_size(int i) const { return size_t(1) << __log2_pool_block_size(i); }
275
276int unsynchronized_pool_resource::__log2_pool_block_size(int i) const { return (i + __log2_smallest_block_size); }
277
278int unsynchronized_pool_resource::__pool_index(size_t bytes, size_t align) const {
279 if (align > alignof(std::max_align_t) || bytes > (size_t(1) << __num_fixed_pools_))
280 return __num_fixed_pools_;
281 else {
282 int i = 0;
283 bytes = (bytes > align) ? bytes : align;
284 bytes -= 1;
285 bytes >>= __log2_smallest_block_size;
286 while (bytes != 0) {
287 bytes >>= 1;
288 i += 1;
289 }
290 return i;
291 }
292}
293
294unsynchronized_pool_resource::unsynchronized_pool_resource(const pool_options& opts, memory_resource* upstream)
295 : __res_(upstream), __fixed_pools_(nullptr) {
296 size_t largest_block_size;
297 if (opts.largest_required_pool_block == 0)
298 largest_block_size = __default_largest_block_size;
299 else if (opts.largest_required_pool_block < __smallest_block_size)
300 largest_block_size = __smallest_block_size;
301 else if (opts.largest_required_pool_block > __max_largest_block_size)
302 largest_block_size = __max_largest_block_size;
303 else
304 largest_block_size = opts.largest_required_pool_block;
305
306 if (opts.max_blocks_per_chunk == 0)
307 __options_max_blocks_per_chunk_ = __max_blocks_per_chunk;
308 else if (opts.max_blocks_per_chunk < __min_blocks_per_chunk)
309 __options_max_blocks_per_chunk_ = __min_blocks_per_chunk;
310 else if (opts.max_blocks_per_chunk > __max_blocks_per_chunk)
311 __options_max_blocks_per_chunk_ = __max_blocks_per_chunk;
312 else
313 __options_max_blocks_per_chunk_ = opts.max_blocks_per_chunk;
314
315 __num_fixed_pools_ = 1;
316 size_t capacity = __smallest_block_size;
317 while (capacity < largest_block_size) {
318 capacity <<= 1;
319 __num_fixed_pools_ += 1;
320 }
321}
322
323pool_options unsynchronized_pool_resource::options() const {
324 pool_options p;
325 p.max_blocks_per_chunk = __options_max_blocks_per_chunk_;
326 p.largest_required_pool_block = __pool_block_size(__num_fixed_pools_ - 1);
327 return p;
328}
329
330void unsynchronized_pool_resource::release() {
331 __adhoc_pool_.__release_ptr(__res_);
332 if (__fixed_pools_ != nullptr) {
333 const int n = __num_fixed_pools_;
334 for (int i = 0; i < n; ++i)
335 __fixed_pools_[i].__release_ptr(__res_);
336 __res_->deallocate(__fixed_pools_, __num_fixed_pools_ * sizeof(__fixed_pool), alignof(__fixed_pool));
337 __fixed_pools_ = nullptr;
338 }
339}
340
341void* unsynchronized_pool_resource::do_allocate(size_t bytes, size_t align) {
342 // A pointer to allocated storage (6.6.4.4.1) with a size of at least bytes.
343 // The size and alignment of the allocated memory shall meet the requirements for
344 // a class derived from memory_resource (23.12).
345 // If the pool selected for a block of size bytes is unable to satisfy the memory request
346 // from its own internal data structures, it will call upstream_resource()->allocate()
347 // to obtain more memory. If bytes is larger than that which the largest pool can handle,
348 // then memory will be allocated using upstream_resource()->allocate().
349
350 int i = __pool_index(bytes, align);
351 if (i == __num_fixed_pools_)
352 return __adhoc_pool_.__do_allocate(__res_, bytes, align);
353 else {
354 if (__fixed_pools_ == nullptr) {
355 __fixed_pools_ =
356 (__fixed_pool*)__res_->allocate(__num_fixed_pools_ * sizeof(__fixed_pool), alignof(__fixed_pool));
357 __fixed_pool* first = __fixed_pools_;
358 __fixed_pool* last = __fixed_pools_ + __num_fixed_pools_;
359 for (__fixed_pool* pool = first; pool != last; ++pool)
360 ::new ((void*)pool) __fixed_pool;
361 }
362 void* result = __fixed_pools_[i].__try_allocate_from_vacancies();
363 if (result == nullptr) {
364 auto min = [](size_t a, size_t b) { return a < b ? a : b; };
365 auto max = [](size_t a, size_t b) { return a < b ? b : a; };
366
367 size_t prev_chunk_size_in_bytes = __fixed_pools_[i].__previous_chunk_size_in_bytes();
368 size_t prev_chunk_size_in_blocks = prev_chunk_size_in_bytes >> __log2_pool_block_size(i);
369
370 size_t chunk_size_in_blocks;
371
372 if (prev_chunk_size_in_blocks == 0) {
373 size_t min_blocks_per_chunk = max(__min_bytes_per_chunk >> __log2_pool_block_size(i), __min_blocks_per_chunk);
374 chunk_size_in_blocks = min_blocks_per_chunk;
375 } else {
376 static_assert(__max_bytes_per_chunk <= SIZE_MAX - (__max_bytes_per_chunk / 4), "unsigned overflow is possible");
377 chunk_size_in_blocks = prev_chunk_size_in_blocks + (prev_chunk_size_in_blocks / 4);
378 }
379
380 size_t max_blocks_per_chunk =
381 min((__max_bytes_per_chunk >> __log2_pool_block_size(i)),
382 min(__max_blocks_per_chunk, __options_max_blocks_per_chunk_));
383 if (chunk_size_in_blocks > max_blocks_per_chunk)
384 chunk_size_in_blocks = max_blocks_per_chunk;
385
386 size_t block_size = __pool_block_size(i);
387
388 size_t chunk_size_in_bytes = (chunk_size_in_blocks << __log2_pool_block_size(i));
389 result = __fixed_pools_[i].__allocate_in_new_chunk(__res_, block_size, chunk_size_in_bytes);
390 }
391 return result;
392 }
393}
394
395void unsynchronized_pool_resource::do_deallocate(void* p, size_t bytes, size_t align) {
396 // Returns the memory at p to the pool. It is unspecified if,
397 // or under what circumstances, this operation will result in
398 // a call to upstream_resource()->deallocate().
399
400 int i = __pool_index(bytes, align);
401 if (i == __num_fixed_pools_)
402 return __adhoc_pool_.__do_deallocate(__res_, p, bytes, align);
403 else {
404 _LIBCPP_ASSERT(__fixed_pools_ != nullptr, "deallocating a block that was not allocated with this allocator");
405 __fixed_pools_[i].__evacuate(p);
406 }
407}
408
409bool synchronized_pool_resource::do_is_equal(const memory_resource& other) const noexcept { return &other == this; }
410
411// 23.12.6, mem.res.monotonic.buffer
412
413static void* align_down(size_t align, size_t size, void*& ptr, size_t& space) {
414 if (size > space)
415 return nullptr;
416
417 char* p1 = static_cast<char*>(ptr);
418 char* new_ptr = reinterpret_cast<char*>(reinterpret_cast<uintptr_t>(p1 - size) & ~(align - 1));
419
420 if (new_ptr < (p1 - space))
421 return nullptr;
422
423 ptr = new_ptr;
424 space -= p1 - new_ptr;
425
426 return ptr;
427}
428
429void* monotonic_buffer_resource::__initial_descriptor::__try_allocate_from_chunk(size_t bytes, size_t align) {
430 if (!__cur_)
431 return nullptr;
432 void* new_ptr = static_cast<void*>(__cur_);
433 size_t new_capacity = (__cur_ - __start_);
434 void* aligned_ptr = align_down(align, bytes, new_ptr, new_capacity);
435 if (aligned_ptr != nullptr)
436 __cur_ = static_cast<char*>(new_ptr);
437 return aligned_ptr;
438}
439
440void* monotonic_buffer_resource::__chunk_footer::__try_allocate_from_chunk(size_t bytes, size_t align) {
441 void* new_ptr = static_cast<void*>(__cur_);
442 size_t new_capacity = (__cur_ - __start_);
443 void* aligned_ptr = align_down(align, bytes, new_ptr, new_capacity);
444 if (aligned_ptr != nullptr)
445 __cur_ = static_cast<char*>(new_ptr);
446 return aligned_ptr;
447}
448
449void* monotonic_buffer_resource::do_allocate(size_t bytes, size_t align) {
450 const size_t footer_size = sizeof(__chunk_footer);
451 const size_t footer_align = alignof(__chunk_footer);
452
453 auto previous_allocation_size = [&]() {
454 if (__chunks_ != nullptr)
455 return __chunks_->__allocation_size();
456
457 size_t newsize = (__initial_.__start_ != nullptr) ? (__initial_.__end_ - __initial_.__start_) : __initial_.__size_;
458
459 return roundup(newsize, footer_align) + footer_size;
460 };
461
462 if (void* result = __initial_.__try_allocate_from_chunk(bytes, align))
463 return result;
464 if (__chunks_ != nullptr) {
465 if (void* result = __chunks_->__try_allocate_from_chunk(bytes, align))
466 return result;
467 }
468
469 // Allocate a brand-new chunk.
470
471 if (align < footer_align)
472 align = footer_align;
473
474 size_t aligned_capacity = roundup(bytes, footer_align) + footer_size;
475 size_t previous_capacity = previous_allocation_size();
476
477 if (aligned_capacity <= previous_capacity) {
478 size_t newsize = 2 * (previous_capacity - footer_size);
479 aligned_capacity = roundup(newsize, footer_align) + footer_size;
480 }
481
482 char* start = (char*)__res_->allocate(aligned_capacity, align);
483 auto end = start + aligned_capacity - footer_size;
484 __chunk_footer* footer = (__chunk_footer*)(end);
485 footer->__next_ = __chunks_;
486 footer->__start_ = start;
487 footer->__cur_ = end;
488 footer->__align_ = align;
489 __chunks_ = footer;
490
491 return __chunks_->__try_allocate_from_chunk(bytes, align);
492}
493
494} // namespace pmr
495
496_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/memory_resource_init_helper.h created+2
......@@ -0,0 +1,2 @@
1#pragma GCC system_header
2static constinit ResourceInitHelper res_init _LIBCPP_INIT_PRIORITY_MAX;
lib/libcxx/src/optional.cpp+5-5
......@@ -16,7 +16,7 @@ bad_optional_access::~bad_optional_access() noexcept = default;
1616
1717const char* bad_optional_access::what() const noexcept {
1818 return "bad_optional_access";
19 }
19}
2020
2121} // std
2222
......@@ -28,13 +28,13 @@ const char* bad_optional_access::what() const noexcept {
2828_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
2929
3030class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access
31 : public std::logic_error
31 : public std::logic_error
3232{
3333public:
34 bad_optional_access() : std::logic_error("Bad optional Access") {}
34 bad_optional_access() : std::logic_error("Bad optional Access") {}
3535
36// Get the key function ~bad_optional_access() into the dylib
37 virtual ~bad_optional_access() noexcept;
36 // Get the key function ~bad_optional_access() into the dylib
37 virtual ~bad_optional_access() noexcept;
3838};
3939
4040bad_optional_access::~bad_optional_access() noexcept = default;
lib/libcxx/src/shared_mutex.cpp+7-7
......@@ -106,13 +106,13 @@ __shared_mutex_base::unlock_shared()
106106
107107// Shared Timed Mutex
108108// These routines are here for ABI stability
109shared_timed_mutex::shared_timed_mutex() : __base() {}
110void shared_timed_mutex::lock() { return __base.lock(); }
111bool shared_timed_mutex::try_lock() { return __base.try_lock(); }
112void shared_timed_mutex::unlock() { return __base.unlock(); }
113void shared_timed_mutex::lock_shared() { return __base.lock_shared(); }
114bool shared_timed_mutex::try_lock_shared() { return __base.try_lock_shared(); }
115void shared_timed_mutex::unlock_shared() { return __base.unlock_shared(); }
109shared_timed_mutex::shared_timed_mutex() : __base_() {}
110void shared_timed_mutex::lock() { return __base_.lock(); }
111bool shared_timed_mutex::try_lock() { return __base_.try_lock(); }
112void shared_timed_mutex::unlock() { return __base_.unlock(); }
113void shared_timed_mutex::lock_shared() { return __base_.lock_shared(); }
114bool shared_timed_mutex::try_lock_shared() { return __base_.try_lock_shared(); }
115void shared_timed_mutex::unlock_shared() { return __base_.unlock_shared(); }
116116
117117_LIBCPP_END_NAMESPACE_STD
118118
lib/libcxx/src/string.cpp+2-2
......@@ -85,7 +85,7 @@ template<typename V, typename S, typename F>
8585inline V as_integer_helper(const string& func, const S& str, size_t* idx, int base, F f) {
8686 typename S::value_type* ptr = nullptr;
8787 const typename S::value_type* const p = str.c_str();
88 typename remove_reference<decltype(errno)>::type errno_save = errno;
88 __libcpp_remove_reference_t<decltype(errno)> errno_save = errno;
8989 errno = 0;
9090 V r = f(p, &ptr, base);
9191 swap(errno, errno_save);
......@@ -172,7 +172,7 @@ template<typename V, typename S, typename F>
172172inline V as_float_helper(const string& func, const S& str, size_t* idx, F f) {
173173 typename S::value_type* ptr = nullptr;
174174 const typename S::value_type* const p = str.c_str();
175 typename remove_reference<decltype(errno)>::type errno_save = errno;
175 __libcpp_remove_reference_t<decltype(errno)> errno_save = errno;
176176 errno = 0;
177177 V r = f(p, &ptr);
178178 swap(errno, errno_save);
lib/libcxx/src/support/ibm/wcsnrtombs.cpp+1-1
......@@ -14,7 +14,7 @@
1414// Converts `max_source_chars` from the wide character buffer pointer to by *`src`,
1515// into the multi byte character sequence buffer stored at `dst`, which must be
1616// `dst_size_bytes` bytes in size. Returns the number of bytes in the sequence
17// converted from *src, excluding the null terminator.
17// converted from *src, excluding the null terminator.
1818// Returns (size_t) -1 if an error occurs and sets errno.
1919// If `dst` is NULL, `dst_size_bytes` is ignored and no bytes are copied to `dst`.
2020_LIBCPP_FUNC_VIS
lib/libcxx/src/support/runtime/stdexcept_vcruntime.ipp+1-1
......@@ -7,7 +7,7 @@
77//===----------------------------------------------------------------------===//
88
99#ifndef _LIBCPP_ABI_VCRUNTIME
10#error This file may only be used when defering to vcruntime
10#error This file may only be used when deferring to vcruntime
1111#endif
1212
1313namespace std {
lib/libcxx/src/thread.cpp+1-1
......@@ -164,8 +164,8 @@ __thread_struct_imp::~__thread_struct_imp()
164164 for (_Notify::iterator i = notify_.begin(), e = notify_.end();
165165 i != e; ++i)
166166 {
167 i->second->unlock();
168167 i->first->notify_all();
168 i->second->unlock();
169169 }
170170 for (_AsyncStates::iterator i = async_states_.begin(), e = async_states_.end();
171171 i != e; ++i)