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 @@...@@ -23,7 +23,7 @@
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2424
25template <class _Iter, class _Sent, class _BinaryPredicate>25template <class _Iter, class _Sent, class _BinaryPredicate>
26_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter26_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter
27__adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {27__adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
28 if (__first == __last)28 if (__first == __last)
29 return __first;29 return __first;
...@@ -37,16 +37,15 @@ __adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {...@@ -37,16 +37,15 @@ __adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
37}37}
3838
39template <class _ForwardIterator, class _BinaryPredicate>39template <class _ForwardIterator, class _BinaryPredicate>
40_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator40_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
41adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {41adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
42 return std::__adjacent_find(std::move(__first), std::move(__last), __pred);42 return std::__adjacent_find(std::move(__first), std::move(__last), __pred);
43}43}
4444
45template <class _ForwardIterator>45template <class _ForwardIterator>
46_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator46_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
47adjacent_find(_ForwardIterator __first, _ForwardIterator __last) {47adjacent_find(_ForwardIterator __first, _ForwardIterator __last) {
48 typedef typename iterator_traits<_ForwardIterator>::value_type __v;48 return std::adjacent_find(std::move(__first), std::move(__last), __equal_to());
49 return std::adjacent_find(std::move(__first), std::move(__last), __equal_to<__v>());
50}49}
5150
52_LIBCPP_END_NAMESPACE_STD51_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/all_of.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _InputIterator, class _Predicate>21template <class _InputIterator, class _Predicate>
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
23all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {23all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
24 for (; __first != __last; ++__first)24 for (; __first != __last; ++__first)
25 if (!__pred(*__first))25 if (!__pred(*__first))
lib/libcxx/include/__algorithm/any_of.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _InputIterator, class _Predicate>21template <class _InputIterator, class _Predicate>
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
23any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {23any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
24 for (; __first != __last; ++__first)24 for (; __first != __last; ++__first)
25 if (__pred(*__first))25 if (__pred(*__first))
lib/libcxx/include/__algorithm/binary_search.h+3-4
...@@ -23,18 +23,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,18 +23,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323
24template <class _ForwardIterator, class _Tp, class _Compare>24template <class _ForwardIterator, class _Tp, class _Compare>
25_LIBCPP_NODISCARD_EXT inline25_LIBCPP_NODISCARD_EXT inline
26_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1726_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
27bool27bool
28binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp)28binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp)
29{29{
30 using _Comp_ref = typename __comp_ref_type<_Compare>::type;30 __first = std::lower_bound<_ForwardIterator, _Tp, __comp_ref_type<_Compare> >(__first, __last, __value, __comp);
31 __first = std::lower_bound<_ForwardIterator, _Tp, _Comp_ref>(__first, __last, __value, __comp);
32 return __first != __last && !__comp(__value, *__first);31 return __first != __last && !__comp(__value, *__first);
33}32}
3433
35template <class _ForwardIterator, class _Tp>34template <class _ForwardIterator, class _Tp>
36_LIBCPP_NODISCARD_EXT inline35_LIBCPP_NODISCARD_EXT inline
37_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1736_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
38bool37bool
39binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)38binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
40{39{
lib/libcxx/include/__algorithm/comp.h+12-38
...@@ -17,73 +17,47 @@...@@ -17,73 +17,47 @@
1717
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
1919
20// I'd like to replace these with _VSTD::equal_to<void>, but can't because:20struct __equal_to {
21// * That only works with C++14 and later, and21 template <class _T1, class _T2>
22// * We haven't included <functional> here.22 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _T1& __x, const _T2& __y) const {
23template <class _T1, class _T2 = _T1>23 return __x == __y;
24struct __equal_to24 }
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;}
51};25};
5226
53template <class _T1, class _T2 = _T1>27template <class _T1, class _T2 = _T1>
54struct __less28struct __less
55{29{
56 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1130 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
57 bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}31 bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
5832
59 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1133 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
60 bool operator()(const _T1& __x, const _T2& __y) const {return __x < __y;}34 bool operator()(const _T1& __x, const _T2& __y) const {return __x < __y;}
6135
62 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1136 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
63 bool operator()(const _T2& __x, const _T1& __y) const {return __x < __y;}37 bool operator()(const _T2& __x, const _T1& __y) const {return __x < __y;}
6438
65 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1139 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
66 bool operator()(const _T2& __x, const _T2& __y) const {return __x < __y;}40 bool operator()(const _T2& __x, const _T2& __y) const {return __x < __y;}
67};41};
6842
69template <class _T1>43template <class _T1>
70struct __less<_T1, _T1>44struct __less<_T1, _T1>
71{45{
72 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1146 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
73 bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}47 bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
74};48};
7549
76template <class _T1>50template <class _T1>
77struct __less<const _T1, _T1>51struct __less<const _T1, _T1>
78{52{
79 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1153 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
80 bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}54 bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
81};55};
8256
83template <class _T1>57template <class _T1>
84struct __less<_T1, const _T1>58struct __less<_T1, const _T1>
85{59{
86 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1160 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
87 bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}61 bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
88};62};
8963
lib/libcxx/include/__algorithm/comp_ref_type.h+13-14
...@@ -23,11 +23,11 @@ template <class _Compare>...@@ -23,11 +23,11 @@ template <class _Compare>
23struct __debug_less23struct __debug_less
24{24{
25 _Compare &__comp_;25 _Compare &__comp_;
26 _LIBCPP_CONSTEXPR_AFTER_CXX1126 _LIBCPP_CONSTEXPR_SINCE_CXX14
27 __debug_less(_Compare& __c) : __comp_(__c) {}27 __debug_less(_Compare& __c) : __comp_(__c) {}
2828
29 template <class _Tp, class _Up>29 template <class _Tp, class _Up>
30 _LIBCPP_CONSTEXPR_AFTER_CXX1130 _LIBCPP_CONSTEXPR_SINCE_CXX14
31 bool operator()(const _Tp& __x, const _Up& __y)31 bool operator()(const _Tp& __x, const _Up& __y)
32 {32 {
33 bool __r = __comp_(__x, __y);33 bool __r = __comp_(__x, __y);
...@@ -37,7 +37,7 @@ struct __debug_less...@@ -37,7 +37,7 @@ struct __debug_less
37 }37 }
3838
39 template <class _Tp, class _Up>39 template <class _Tp, class _Up>
40 _LIBCPP_CONSTEXPR_AFTER_CXX1140 _LIBCPP_CONSTEXPR_SINCE_CXX14
41 bool operator()(_Tp& __x, _Up& __y)41 bool operator()(_Tp& __x, _Up& __y)
42 {42 {
43 bool __r = __comp_(__x, __y);43 bool __r = __comp_(__x, __y);
...@@ -47,10 +47,10 @@ struct __debug_less...@@ -47,10 +47,10 @@ struct __debug_less
47 }47 }
4848
49 template <class _LHS, class _RHS>49 template <class _LHS, class _RHS>
50 _LIBCPP_CONSTEXPR_AFTER_CXX1150 _LIBCPP_CONSTEXPR_SINCE_CXX14
51 inline _LIBCPP_INLINE_VISIBILITY51 inline _LIBCPP_INLINE_VISIBILITY
52 decltype((void)declval<_Compare&>()(52 decltype((void)std::declval<_Compare&>()(
53 declval<_LHS &>(), declval<_RHS &>()))53 std::declval<_LHS &>(), std::declval<_RHS &>()))
54 __do_compare_assert(int, _LHS & __l, _RHS & __r) {54 __do_compare_assert(int, _LHS & __l, _RHS & __r) {
55 _LIBCPP_DEBUG_ASSERT(!__comp_(__l, __r),55 _LIBCPP_DEBUG_ASSERT(!__comp_(__l, __r),
56 "Comparator does not induce a strict weak ordering");56 "Comparator does not induce a strict weak ordering");
...@@ -59,21 +59,20 @@ struct __debug_less...@@ -59,21 +59,20 @@ struct __debug_less
59 }59 }
6060
61 template <class _LHS, class _RHS>61 template <class _LHS, class _RHS>
62 _LIBCPP_CONSTEXPR_AFTER_CXX1162 _LIBCPP_CONSTEXPR_SINCE_CXX14
63 inline _LIBCPP_INLINE_VISIBILITY63 inline _LIBCPP_INLINE_VISIBILITY
64 void __do_compare_assert(long, _LHS &, _RHS &) {}64 void __do_compare_assert(long, _LHS &, _RHS &) {}
65};65};
6666
67template <class _Comp>67// Pass the comparator by lvalue reference. Or in debug mode, using a
68struct __comp_ref_type {68// debugging wrapper that stores a reference.
69 // Pass the comparator by lvalue reference. Or in debug mode, using a
70 // debugging wrapper that stores a reference.
71#ifdef _LIBCPP_ENABLE_DEBUG_MODE69#ifdef _LIBCPP_ENABLE_DEBUG_MODE
72 typedef __debug_less<_Comp> type;70template <class _Comp>
71using __comp_ref_type = __debug_less<_Comp>;
73#else72#else
74 typedef _Comp& type;73template <class _Comp>
74using __comp_ref_type = _Comp&;
75#endif75#endif
76};
7776
78_LIBCPP_END_NAMESPACE_STD77_LIBCPP_END_NAMESPACE_STD
7978
lib/libcxx/include/__algorithm/copy.h+90-72
...@@ -9,100 +9,118 @@...@@ -9,100 +9,118 @@
9#ifndef _LIBCPP___ALGORITHM_COPY_H9#ifndef _LIBCPP___ALGORITHM_COPY_H
10#define _LIBCPP___ALGORITHM_COPY_H10#define _LIBCPP___ALGORITHM_COPY_H
1111
12#include <__algorithm/unwrap_iter.h>12#include <__algorithm/copy_move_common.h>
13#include <__algorithm/unwrap_range.h>13#include <__algorithm/iterator_operations.h>
14#include <__algorithm/min.h>
14#include <__config>15#include <__config>
15#include <__iterator/iterator_traits.h>16#include <__iterator/segmented_iterator.h>
16#include <__iterator/reverse_iterator.h>17#include <__type_traits/common_type.h>
17#include <__utility/move.h>18#include <__utility/move.h>
18#include <__utility/pair.h>19#include <__utility/pair.h>
19#include <cstring>
20#include <type_traits>
2120
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header22# pragma GCC system_header
24#endif23#endif
2524
25_LIBCPP_PUSH_MACROS
26#include <__undef_macros>
27
26_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2729
28// copy30template <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>44 return std::make_pair(std::move(__first), std::move(__result));
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;
37 }45 }
38 return pair<_InIter, _OutIter>(std::move(__first), std::move(__result));
39}
4046
41template <class _InValueT,47 template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0>
42 class _OutValueT,48 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
43 class = __enable_if_t<is_same<typename remove_const<_InValueT>::type, _OutValueT>::value49 operator()(_InIter __first, _InIter __last, _OutIter __result) const {
44 && is_trivially_copy_assignable<_OutValueT>::value> >50 using _Traits = __segmented_iterator_traits<_InIter>;
45inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1151 auto __sfirst = _Traits::__segment(__first);
46pair<_InValueT*, _OutValueT*> __copy_impl(_InValueT* __first, _InValueT* __last, _OutValueT* __result) {52 auto __slast = _Traits::__segment(__last);
47 if (__libcpp_is_constant_evaluated()53 if (__sfirst == __slast) {
48// TODO: Remove this once GCC supports __builtin_memmove during constant evaluation54 auto __iters = std::__copy<_AlgPolicy>(_Traits::__local(__first), _Traits::__local(__last), std::move(__result));
49#ifndef _LIBCPP_COMPILER_GCC55 return std::make_pair(__last, std::move(__iters.second));
50 && !is_trivially_copyable<_InValueT>::value56 }
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}
5957
60template <class _InIter, class _OutIter,58 __result = std::__copy<_AlgPolicy>(_Traits::__local(__first), _Traits::__end(__sfirst), std::move(__result)).second;
61 __enable_if_t<is_same<typename remove_const<__iter_value_type<_InIter> >::type, __iter_value_type<_OutIter> >::value59 ++__sfirst;
62 && __is_cpp17_contiguous_iterator<typename _InIter::iterator_type>::value60 while (__sfirst != __slast) {
63 && __is_cpp17_contiguous_iterator<typename _OutIter::iterator_type>::value61 __result =
64 && is_trivially_copy_assignable<__iter_value_type<_OutIter> >::value62 std::__copy<_AlgPolicy>(_Traits::__begin(__sfirst), _Traits::__end(__sfirst), std::move(__result)).second;
65 && __is_reverse_iterator<_InIter>::value63 ++__sfirst;
66 && __is_reverse_iterator<_OutIter>::value, int> = 0>64 }
67inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1165 __result =
68pair<_InIter, _OutIter>66 std::__copy<_AlgPolicy>(_Traits::__begin(__sfirst), _Traits::__local(__last), std::move(__result)).second;
69__copy_impl(_InIter __first, _InIter __last, _OutIter __result) {67 return std::make_pair(__last, std::move(__result));
70 auto __first_base = std::__unwrap_iter(__first.base());68 }
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}
7769
78template <class _InIter, class _Sent, class _OutIter,70 template <class _InIter,
79 __enable_if_t<!(is_copy_constructible<_InIter>::value71 class _OutIter,
80 && is_copy_constructible<_Sent>::value72 __enable_if_t<__is_cpp17_random_access_iterator<_InIter>::value &&
81 && is_copy_constructible<_OutIter>::value), int> = 0 >73 !__is_segmented_iterator<_InIter>::value && __is_segmented_iterator<_OutIter>::value,
82inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1174 int> = 0>
83pair<_InIter, _OutIter> __copy(_InIter __first, _Sent __last, _OutIter __result) {75 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
84 return std::__copy_impl(std::move(__first), std::move(__last), std::move(__result));76 operator()(_InIter __first, _InIter __last, _OutIter __result) {
85}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,80 if (__first == __last)
88 __enable_if_t<is_copy_constructible<_InIter>::value81 return std::make_pair(std::move(__first), std::move(__result));
89 && is_copy_constructible<_Sent>::value82
90 && is_copy_constructible<_OutIter>::value, int> = 0>83 auto __local_first = _Traits::__local(__result);
91inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1184 auto __segment_iterator = _Traits::__segment(__result);
92pair<_InIter, _OutIter> __copy(_InIter __first, _Sent __last, _OutIter __result) {85 while (true) {
93 auto __range = std::__unwrap_range(__first, __last);86 auto __local_last = _Traits::__end(__segment_iterator);
94 auto __ret = std::__copy_impl(std::move(__range.first), std::move(__range.second), std::__unwrap_iter(__result));87 auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first);
95 return std::make_pair(88 auto __iters = std::__copy<_AlgPolicy>(__first, __first + __size, __local_first);
96 std::__rewrap_range<_Sent>(__first, __ret.first), std::__rewrap_iter(__result, __ret.second));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));
97}114}
98115
99template <class _InputIterator, class _OutputIterator>116template <class _InputIterator, class _OutputIterator>
100inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17117inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
101_OutputIterator
102copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {118copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
103 return std::__copy(__first, __last, __result).second;119 return std::__copy<_ClassicAlgPolicy>(__first, __last, __result).second;
104}120}
105121
106_LIBCPP_END_NAMESPACE_STD122_LIBCPP_END_NAMESPACE_STD
107123
124_LIBCPP_POP_MACROS
125
108#endif // _LIBCPP___ALGORITHM_COPY_H126#endif // _LIBCPP___ALGORITHM_COPY_H
lib/libcxx/include/__algorithm/copy_backward.h+112-30
...@@ -9,53 +9,135 @@...@@ -9,53 +9,135 @@
9#ifndef _LIBCPP___ALGORITHM_COPY_BACKWARD_H9#ifndef _LIBCPP___ALGORITHM_COPY_BACKWARD_H
10#define _LIBCPP___ALGORITHM_COPY_BACKWARD_H10#define _LIBCPP___ALGORITHM_COPY_BACKWARD_H
1111
12#include <__algorithm/copy.h>12#include <__algorithm/copy_move_common.h>
13#include <__algorithm/iterator_operations.h>13#include <__algorithm/iterator_operations.h>
14#include <__algorithm/ranges_copy.h>14#include <__algorithm/min.h>
15#include <__algorithm/unwrap_iter.h>
16#include <__concepts/same_as.h>
17#include <__config>15#include <__config>
18#include <__iterator/iterator_traits.h>16#include <__iterator/segmented_iterator.h>
19#include <__iterator/reverse_iterator.h>17#include <__type_traits/common_type.h>
20#include <__ranges/subrange.h>18#include <__type_traits/is_copy_constructible.h>
21#include <__utility/move.h>19#include <__utility/move.h>
22#include <__utility/pair.h>20#include <__utility/pair.h>
23#include <type_traits>
2421
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26# pragma GCC system_header23# pragma GCC system_header
27#endif24#endif
2825
26_LIBCPP_PUSH_MACROS
27#include <__undef_macros>
28
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
31template <class _AlgPolicy, class _InputIterator, class _OutputIterator,31template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>
32 __enable_if_t<is_same<_AlgPolicy, _ClassicAlgPolicy>::value, int> = 0>32_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InIter, _OutIter>
33inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_InputIterator, _OutputIterator>33__copy_backward(_InIter __first, _Sent __last, _OutIter __result);
34__copy_backward(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {34
35 auto __ret = std::__copy(35template <class _AlgPolicy>
36 __unconstrained_reverse_iterator<_InputIterator>(__last),36struct __copy_backward_loop {
37 __unconstrained_reverse_iterator<_InputIterator>(__first),37 template <class _InIter, class _Sent, class _OutIter>
38 __unconstrained_reverse_iterator<_OutputIterator>(__result));38 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
39 return pair<_InputIterator, _OutputIterator>(__ret.first.base(), __ret.second.base());39 operator()(_InIter __first, _Sent __last, _OutIter __result) const {
40}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)88 // When the range contains no elements, __result might not be a valid iterator
43template <class _AlgPolicy, class _Iter1, class _Sent1, class _Iter2,89 if (__first == __last)
44 __enable_if_t<is_same<_AlgPolicy, _RangeAlgPolicy>::value, int> = 0>90 return std::make_pair(__first, __result);
45_LIBCPP_HIDE_FROM_ABI constexpr pair<_Iter1, _Iter2> __copy_backward(_Iter1 __first, _Sent1 __last, _Iter2 __result) {91
46 auto __last_iter = _IterOps<_AlgPolicy>::next(__first, std::move(__last));92 auto __local_last = _Traits::__local(__result);
47 auto __reverse_range = std::__reverse_range(std::ranges::subrange(std::move(__first), __last_iter));93 while (true) {
48 auto __ret = ranges::copy(std::move(__reverse_range), std::make_reverse_iterator(__result));94 using _DiffT = typename common_type<__iter_diff_t<_InIter>, __iter_diff_t<_OutIter> >::type;
49 return std::make_pair(__last_iter, __ret.out.base());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));
50}124}
51#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
52125
53template <class _BidirectionalIterator1, class _BidirectionalIterator2>126template <class _BidirectionalIterator1, class _BidirectionalIterator2>
54inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator2127inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
55copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, _BidirectionalIterator2 __result) {128_BidirectionalIterator2
56 return std::__copy_backward<_ClassicAlgPolicy>(__first, __last, __result).second;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;
57}137}
58138
59_LIBCPP_END_NAMESPACE_STD139_LIBCPP_END_NAMESPACE_STD
60140
141_LIBCPP_POP_MACROS
142
61#endif // _LIBCPP___ALGORITHM_COPY_BACKWARD_H143#endif // _LIBCPP___ALGORITHM_COPY_BACKWARD_H
lib/libcxx/include/__algorithm/copy_if.h+1-1
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
1919
20template<class _InputIterator, class _OutputIterator, class _Predicate>20template<class _InputIterator, class _OutputIterator, class _Predicate>
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1721inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
22_OutputIterator22_OutputIterator
23copy_if(_InputIterator __first, _InputIterator __last,23copy_if(_InputIterator __first, _InputIterator __last,
24 _OutputIterator __result, _Predicate __pred)24 _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 @@...@@ -12,6 +12,7 @@
12#include <__algorithm/copy.h>12#include <__algorithm/copy.h>
13#include <__config>13#include <__config>
14#include <__iterator/iterator_traits.h>14#include <__iterator/iterator_traits.h>
15#include <__utility/convert_to_integral.h>
15#include <type_traits>16#include <type_traits>
1617
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -21,7 +22,7 @@...@@ -21,7 +22,7 @@
21_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2223
23template<class _InputIterator, class _Size, class _OutputIterator>24template<class _InputIterator, class _Size, class _OutputIterator>
24inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1725inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
25typename enable_if26typename enable_if
26<27<
27 __is_cpp17_input_iterator<_InputIterator>::value &&28 __is_cpp17_input_iterator<_InputIterator>::value &&
...@@ -47,7 +48,7 @@ copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)...@@ -47,7 +48,7 @@ copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
47}48}
4849
49template<class _InputIterator, class _Size, class _OutputIterator>50template<class _InputIterator, class _Size, class _OutputIterator>
50inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1751inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
51typename enable_if52typename enable_if
52<53<
53 __is_cpp17_random_access_iterator<_InputIterator>::value,54 __is_cpp17_random_access_iterator<_InputIterator>::value,
lib/libcxx/include/__algorithm/count.h+1-1
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <class _InputIterator, class _Tp>22template <class _InputIterator, class _Tp>
23_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1723_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
24 typename iterator_traits<_InputIterator>::difference_type24 typename iterator_traits<_InputIterator>::difference_type
25 count(_InputIterator __first, _InputIterator __last, const _Tp& __value) {25 count(_InputIterator __first, _InputIterator __last, const _Tp& __value) {
26 typename iterator_traits<_InputIterator>::difference_type __r(0);26 typename iterator_traits<_InputIterator>::difference_type __r(0);
lib/libcxx/include/__algorithm/count_if.h+1-1
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <class _InputIterator, class _Predicate>22template <class _InputIterator, class _Predicate>
23_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1723_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
24 typename iterator_traits<_InputIterator>::difference_type24 typename iterator_traits<_InputIterator>::difference_type
25 count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) {25 count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
26 typename iterator_traits<_InputIterator>::difference_type __r(0);26 typename iterator_traits<_InputIterator>::difference_type __r(0);
lib/libcxx/include/__algorithm/equal.h+15-14
...@@ -22,7 +22,7 @@...@@ -22,7 +22,7 @@
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2323
24template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>24template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
25_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool25_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
26equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) {26equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) {
27 for (; __first1 != __last1; ++__first1, (void)++__first2)27 for (; __first1 != __last1; ++__first1, (void)++__first2)
28 if (!__pred(*__first1, *__first2))28 if (!__pred(*__first1, *__first2))
...@@ -31,16 +31,14 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first...@@ -31,16 +31,14 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first
31}31}
3232
33template <class _InputIterator1, class _InputIterator2>33template <class _InputIterator1, class _InputIterator2>
34_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool34_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
35equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) {35equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) {
36 typedef typename iterator_traits<_InputIterator1>::value_type __v1;36 return std::equal(__first1, __last1, __first2, __equal_to());
37 typedef typename iterator_traits<_InputIterator2>::value_type __v2;
38 return _VSTD::equal(__first1, __last1, __first2, __equal_to<__v1, __v2>());
39}37}
4038
41#if _LIBCPP_STD_VER > 1139#if _LIBCPP_STD_VER > 11
42template <class _BinaryPredicate, class _InputIterator1, class _InputIterator2>40template <class _BinaryPredicate, class _InputIterator1, class _InputIterator2>
43inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool41inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
44__equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,42__equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
45 _BinaryPredicate __pred, input_iterator_tag, input_iterator_tag) {43 _BinaryPredicate __pred, input_iterator_tag, input_iterator_tag) {
46 for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2)44 for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2)
...@@ -50,7 +48,7 @@ __equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fir...@@ -50,7 +48,7 @@ __equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fir
50}48}
5149
52template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>50template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
53inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool51inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
54__equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2,52__equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2,
55 _RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag,53 _RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag,
56 random_access_iterator_tag) {54 random_access_iterator_tag) {
...@@ -61,7 +59,7 @@ __equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _Random...@@ -61,7 +59,7 @@ __equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _Random
61}59}
6260
63template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>61template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
64_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool62_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
65equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,63equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
66 _BinaryPredicate __pred) {64 _BinaryPredicate __pred) {
67 return _VSTD::__equal<_BinaryPredicate&>(65 return _VSTD::__equal<_BinaryPredicate&>(
...@@ -70,13 +68,16 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first...@@ -70,13 +68,16 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first
70}68}
7169
72template <class _InputIterator1, class _InputIterator2>70template <class _InputIterator1, class _InputIterator2>
73_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool71_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
74equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {72equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
75 typedef typename iterator_traits<_InputIterator1>::value_type __v1;73 return std::__equal(
76 typedef typename iterator_traits<_InputIterator2>::value_type __v2;74 __first1,
77 return _VSTD::__equal(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>(),75 __last1,
78 typename iterator_traits<_InputIterator1>::iterator_category(),76 __first2,
79 typename iterator_traits<_InputIterator2>::iterator_category());77 __last2,
78 __equal_to(),
79 typename iterator_traits<_InputIterator1>::iterator_category(),
80 typename iterator_traits<_InputIterator2>::iterator_category());
80}81}
81#endif82#endif
8283
lib/libcxx/include/__algorithm/equal_range.h+8-5
...@@ -34,7 +34,7 @@...@@ -34,7 +34,7 @@
34_LIBCPP_BEGIN_NAMESPACE_STD34_LIBCPP_BEGIN_NAMESPACE_STD
3535
36template <class _AlgPolicy, class _Compare, class _Iter, class _Sent, class _Tp, class _Proj>36template <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>
38__equal_range(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp, _Proj&& __proj) {38__equal_range(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp, _Proj&& __proj) {
39 auto __len = _IterOps<_AlgPolicy>::distance(__first, __last);39 auto __len = _IterOps<_AlgPolicy>::distance(__first, __last);
40 _Iter __end = _IterOps<_AlgPolicy>::next(__first, __last);40 _Iter __end = _IterOps<_AlgPolicy>::next(__first, __last);
...@@ -58,19 +58,22 @@ __equal_range(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp...@@ -58,19 +58,22 @@ __equal_range(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp
58}58}
5959
60template <class _ForwardIterator, class _Tp, class _Compare>60template <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>
62equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {62equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
63 static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value,63 static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value,
64 "The comparator has to be callable");64 "The comparator has to be callable");
65 static_assert(is_copy_constructible<_ForwardIterator>::value,65 static_assert(is_copy_constructible<_ForwardIterator>::value,
66 "Iterator has to be copy constructible");66 "Iterator has to be copy constructible");
67 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
68 return std::__equal_range<_ClassicAlgPolicy>(67 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());
70}73}
7174
72template <class _ForwardIterator, class _Tp>75template <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>
74equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {77equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
75 return std::equal_range(78 return std::equal_range(
76 std::move(__first),79 std::move(__first),
lib/libcxx/include/__algorithm/fill.h+3-3
...@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
23// fill isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset.23// fill isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset.
2424
25template <class _ForwardIterator, class _Tp>25template <class _ForwardIterator, class _Tp>
26inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1726inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
27void27void
28__fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, forward_iterator_tag)28__fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, forward_iterator_tag)
29{29{
...@@ -32,7 +32,7 @@ __fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, fo...@@ -32,7 +32,7 @@ __fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, fo
32}32}
3333
34template <class _RandomAccessIterator, class _Tp>34template <class _RandomAccessIterator, class _Tp>
35inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1735inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
36void36void
37__fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value, random_access_iterator_tag)37__fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value, random_access_iterator_tag)
38{38{
...@@ -40,7 +40,7 @@ __fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& _...@@ -40,7 +40,7 @@ __fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& _
40}40}
4141
42template <class _ForwardIterator, class _Tp>42template <class _ForwardIterator, class _Tp>
43inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1743inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
44void44void
45fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)45fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
46{46{
lib/libcxx/include/__algorithm/fill_n.h+3-2
...@@ -11,6 +11,7 @@...@@ -11,6 +11,7 @@
1111
12#include <__config>12#include <__config>
13#include <__iterator/iterator_traits.h>13#include <__iterator/iterator_traits.h>
14#include <__utility/convert_to_integral.h>
14#include <type_traits>15#include <type_traits>
1516
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -22,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22// fill_n isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset.23// fill_n isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset.
2324
24template <class _OutputIterator, class _Size, class _Tp>25template <class _OutputIterator, class _Size, class _Tp>
25inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1726inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
26_OutputIterator27_OutputIterator
27__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)28__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)
28{29{
...@@ -32,7 +33,7 @@ __fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)...@@ -32,7 +33,7 @@ __fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)
32}33}
3334
34template <class _OutputIterator, class _Size, class _Tp>35template <class _OutputIterator, class _Size, class _Tp>
35inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1736inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
36_OutputIterator37_OutputIterator
37fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)38fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)
38{39{
lib/libcxx/include/__algorithm/find.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _InputIterator, class _Tp>21template <class _InputIterator, class _Tp>
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
23find(_InputIterator __first, _InputIterator __last, const _Tp& __value) {23find(_InputIterator __first, _InputIterator __last, const _Tp& __value) {
24 for (; __first != __last; ++__first)24 for (; __first != __last; ++__first)
25 if (*__first == __value)25 if (*__first == __value)
lib/libcxx/include/__algorithm/find_end.h+7-9
...@@ -37,7 +37,7 @@ template <...@@ -37,7 +37,7 @@ template <
37 class _Pred,37 class _Pred,
38 class _Proj1,38 class _Proj1,
39 class _Proj2>39 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(
41 _Iter1 __first1,41 _Iter1 __first1,
42 _Sent1 __last1,42 _Sent1 __last1,
43 _Iter2 __first2,43 _Iter2 __first2,
...@@ -91,7 +91,7 @@ template <...@@ -91,7 +91,7 @@ template <
91 class _Sent2,91 class _Sent2,
92 class _Proj1,92 class _Proj1,
93 class _Proj2>93 class _Proj2>
94_LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter1 __find_end(94_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter1 __find_end(
95 _Iter1 __first1,95 _Iter1 __first1,
96 _Sent1 __sent1,96 _Sent1 __sent1,
97 _Iter2 __first2,97 _Iter2 __first2,
...@@ -144,7 +144,7 @@ template <...@@ -144,7 +144,7 @@ template <
144 class _Sent2,144 class _Sent2,
145 class _Proj1,145 class _Proj1,
146 class _Proj2>146 class _Proj2>
147_LIBCPP_CONSTEXPR_AFTER_CXX11 _Iter1 __find_end(147_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter1 __find_end(
148 _Iter1 __first1,148 _Iter1 __first1,
149 _Sent1 __sent1,149 _Sent1 __sent1,
150 _Iter2 __first2,150 _Iter2 __first2,
...@@ -189,7 +189,7 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 _Iter1 __find_end(...@@ -189,7 +189,7 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 _Iter1 __find_end(
189}189}
190190
191template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>191template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
192_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11192_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
193_ForwardIterator1 __find_end_classic(_ForwardIterator1 __first1, _ForwardIterator1 __last1,193_ForwardIterator1 __find_end_classic(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
194 _ForwardIterator2 __first2, _ForwardIterator2 __last2,194 _ForwardIterator2 __first2, _ForwardIterator2 __last2,
195 _BinaryPredicate& __pred) {195 _BinaryPredicate& __pred) {
...@@ -208,7 +208,7 @@ _ForwardIterator1 __find_end_classic(_ForwardIterator1 __first1, _ForwardIterato...@@ -208,7 +208,7 @@ _ForwardIterator1 __find_end_classic(_ForwardIterator1 __first1, _ForwardIterato
208}208}
209209
210template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>210template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
211_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17211_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
212_ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,212_ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
213 _ForwardIterator2 __first2, _ForwardIterator2 __last2,213 _ForwardIterator2 __first2, _ForwardIterator2 __last2,
214 _BinaryPredicate __pred) {214 _BinaryPredicate __pred) {
...@@ -216,12 +216,10 @@ _ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1...@@ -216,12 +216,10 @@ _ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1
216}216}
217217
218template <class _ForwardIterator1, class _ForwardIterator2>218template <class _ForwardIterator1, class _ForwardIterator2>
219_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17219_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
220_ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,220_ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
221 _ForwardIterator2 __first2, _ForwardIterator2 __last2) {221 _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
222 using __v1 = typename iterator_traits<_ForwardIterator1>::value_type;222 return std::find_end(__first1, __last1, __first2, __last2, __equal_to());
223 using __v2 = typename iterator_traits<_ForwardIterator2>::value_type;
224 return std::find_end(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
225}223}
226224
227_LIBCPP_END_NAMESPACE_STD225_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/find_first_of.h+5-6
...@@ -21,7 +21,8 @@...@@ -21,7 +21,8 @@
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>23template <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,
25 _ForwardIterator1 __last1,26 _ForwardIterator1 __last1,
26 _ForwardIterator2 __first2,27 _ForwardIterator2 __first2,
27 _ForwardIterator2 __last2,28 _ForwardIterator2 __last2,
...@@ -34,18 +35,16 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator1 __find_first_of_ce(_ForwardItera...@@ -34,18 +35,16 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator1 __find_first_of_ce(_ForwardItera
34}35}
3536
36template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>37template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
37_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator138_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1
38find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,39find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
39 _ForwardIterator2 __last2, _BinaryPredicate __pred) {40 _ForwardIterator2 __last2, _BinaryPredicate __pred) {
40 return _VSTD::__find_first_of_ce(__first1, __last1, __first2, __last2, __pred);41 return _VSTD::__find_first_of_ce(__first1, __last1, __first2, __last2, __pred);
41}42}
4243
43template <class _ForwardIterator1, class _ForwardIterator2>44template <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(
45 _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {46 _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
46 typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;47 return std::__find_first_of_ce(__first1, __last1, __first2, __last2, __equal_to());
47 typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
48 return _VSTD::__find_first_of_ce(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
49}48}
5049
51_LIBCPP_END_NAMESPACE_STD50_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/find_if.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _InputIterator, class _Predicate>21template <class _InputIterator, class _Predicate>
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
23find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) {23find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
24 for (; __first != __last; ++__first)24 for (; __first != __last; ++__first)
25 if (__pred(*__first))25 if (__pred(*__first))
lib/libcxx/include/__algorithm/find_if_not.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _InputIterator, class _Predicate>21template <class _InputIterator, class _Predicate>
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
23find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) {23find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
24 for (; __first != __last; ++__first)24 for (; __first != __last; ++__first)
25 if (!__pred(*__first))25 if (!__pred(*__first))
lib/libcxx/include/__algorithm/for_each.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _InputIterator, class _Function>21template <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,
23 _InputIterator __last,23 _InputIterator __last,
24 _Function __f) {24 _Function __f) {
25 for (; __first != __last; ++__first)25 for (; __first != __last; ++__first)
lib/libcxx/include/__algorithm/for_each_n.h+2-1
...@@ -11,6 +11,7 @@...@@ -11,6 +11,7 @@
11#define _LIBCPP___ALGORITHM_FOR_EACH_N_H11#define _LIBCPP___ALGORITHM_FOR_EACH_N_H
1212
13#include <__config>13#include <__config>
14#include <__utility/convert_to_integral.h>
14#include <type_traits>15#include <type_traits>
1516
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -22,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22#if _LIBCPP_STD_VER > 1423#if _LIBCPP_STD_VER > 14
2324
24template <class _InputIterator, class _Size, class _Function>25template <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,
26 _Size __orig_n,27 _Size __orig_n,
27 _Function __f) {28 _Function __f) {
28 typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;29 typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
lib/libcxx/include/__algorithm/generate.h+1-1
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
1919
20template <class _ForwardIterator, class _Generator>20template <class _ForwardIterator, class _Generator>
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1721inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
22void22void
23generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen)23generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen)
24{24{
lib/libcxx/include/__algorithm/generate_n.h+2-1
...@@ -10,6 +10,7 @@...@@ -10,6 +10,7 @@
10#define _LIBCPP___ALGORITHM_GENERATE_N_H10#define _LIBCPP___ALGORITHM_GENERATE_N_H
1111
12#include <__config>12#include <__config>
13#include <__utility/convert_to_integral.h>
13#include <type_traits>14#include <type_traits>
1415
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -19,7 +20,7 @@...@@ -19,7 +20,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2021
21template <class _OutputIterator, class _Size, class _Generator>22template <class _OutputIterator, class _Size, class _Generator>
22inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1723inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
23_OutputIterator24_OutputIterator
24generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen)25generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen)
25{26{
lib/libcxx/include/__algorithm/half_positive.h+1-1
...@@ -29,7 +29,7 @@ typename enable_if...@@ -29,7 +29,7 @@ typename enable_if
29>::type29>::type
30__half_positive(_Integral __value)30__half_positive(_Integral __value)
31{31{
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);
33}33}
3434
35template <typename _Tp>35template <typename _Tp>
lib/libcxx/include/__algorithm/in_found_result.h+2-2
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18# pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)21#if _LIBCPP_STD_VER > 17
2222
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2424
...@@ -44,6 +44,6 @@ struct in_found_result {...@@ -44,6 +44,6 @@ struct in_found_result {
4444
45_LIBCPP_END_NAMESPACE_STD45_LIBCPP_END_NAMESPACE_STD
4646
47#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)47#endif // _LIBCPP_STD_VER > 17
4848
49#endif // _LIBCPP___ALGORITHM_IN_FOUND_RESULT_H49#endif // _LIBCPP___ALGORITHM_IN_FOUND_RESULT_H
lib/libcxx/include/__algorithm/in_fun_result.h+2-2
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)23#if _LIBCPP_STD_VER > 17
2424
25namespace ranges {25namespace ranges {
26template <class _InIter1, class _Func1>26template <class _InIter1, class _Func1>
...@@ -42,7 +42,7 @@ struct in_fun_result {...@@ -42,7 +42,7 @@ struct in_fun_result {
42};42};
43} // namespace ranges43} // namespace ranges
4444
45#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)45#endif // _LIBCPP_STD_VER > 17
4646
47_LIBCPP_END_NAMESPACE_STD47_LIBCPP_END_NAMESPACE_STD
4848
lib/libcxx/include/__algorithm/in_in_out_result.h+2-2
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)23#if _LIBCPP_STD_VER > 17
2424
25namespace ranges {25namespace ranges {
2626
...@@ -49,7 +49,7 @@ struct in_in_out_result {...@@ -49,7 +49,7 @@ struct in_in_out_result {
4949
50} // namespace ranges50} // namespace ranges
5151
52#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)52#endif // _LIBCPP_STD_VER > 17
5353
54_LIBCPP_END_NAMESPACE_STD54_LIBCPP_END_NAMESPACE_STD
5555
lib/libcxx/include/__algorithm/in_in_result.h+2-2
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)23#if _LIBCPP_STD_VER > 17
2424
25namespace ranges {25namespace ranges {
2626
...@@ -46,7 +46,7 @@ struct in_in_result {...@@ -46,7 +46,7 @@ struct in_in_result {
4646
47} // namespace ranges47} // namespace ranges
4848
49#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)49#endif // _LIBCPP_STD_VER > 17
5050
51_LIBCPP_END_NAMESPACE_STD51_LIBCPP_END_NAMESPACE_STD
5252
lib/libcxx/include/__algorithm/in_out_out_result.h+2-2
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)23#if _LIBCPP_STD_VER > 17
2424
25namespace ranges {25namespace ranges {
26template <class _InIter1, class _OutIter1, class _OutIter2>26template <class _InIter1, class _OutIter1, class _OutIter2>
...@@ -47,7 +47,7 @@ struct in_out_out_result {...@@ -47,7 +47,7 @@ struct in_out_out_result {
47};47};
48} // namespace ranges48} // namespace ranges
4949
50#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)50#endif // _LIBCPP_STD_VER > 17
5151
52_LIBCPP_END_NAMESPACE_STD52_LIBCPP_END_NAMESPACE_STD
5353
lib/libcxx/include/__algorithm/in_out_result.h+2-2
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)23#if _LIBCPP_STD_VER > 17
2424
25namespace ranges {25namespace ranges {
2626
...@@ -46,7 +46,7 @@ struct in_out_result {...@@ -46,7 +46,7 @@ struct in_out_result {
4646
47} // namespace ranges47} // namespace ranges
4848
49#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)49#endif // _LIBCPP_STD_VER > 17
5050
51_LIBCPP_END_NAMESPACE_STD51_LIBCPP_END_NAMESPACE_STD
5252
lib/libcxx/include/__algorithm/includes.h+10-6
...@@ -25,7 +25,7 @@...@@ -25,7 +25,7 @@
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Comp, class _Proj1, class _Proj2>27template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Comp, class _Proj1, class _Proj2>
28_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool28_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
29__includes(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,29__includes(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
30 _Comp&& __comp, _Proj1&& __proj1, _Proj2&& __proj2) {30 _Comp&& __comp, _Proj1&& __proj1, _Proj2&& __proj2) {
31 for (; __first2 != __last2; ++__first1) {31 for (; __first2 != __last2; ++__first1) {
...@@ -39,7 +39,7 @@ __includes(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,...@@ -39,7 +39,7 @@ __includes(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
39}39}
4040
41template <class _InputIterator1, class _InputIterator2, class _Compare>41template <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(
43 _InputIterator1 __first1,43 _InputIterator1 __first1,
44 _InputIterator1 __last1,44 _InputIterator1 __last1,
45 _InputIterator2 __first2,45 _InputIterator2 __first2,
...@@ -48,14 +48,18 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17...@@ -48,14 +48,18 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
48 static_assert(__is_callable<_Compare, decltype(*__first1), decltype(*__first2)>::value,48 static_assert(__is_callable<_Compare, decltype(*__first1), decltype(*__first2)>::value,
49 "Comparator has to be callable");49 "Comparator has to be callable");
5050
51 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
52 return std::__includes(51 return std::__includes(
53 std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2),52 std::move(__first1),
54 static_cast<_Comp_ref>(__comp), __identity(), __identity());53 std::move(__last1),
54 std::move(__first2),
55 std::move(__last2),
56 static_cast<__comp_ref_type<_Compare> >(__comp),
57 __identity(),
58 __identity());
55}59}
5660
57template <class _InputIterator1, class _InputIterator2>61template <class _InputIterator1, class _InputIterator2>
58_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool62_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
59includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {63includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
60 return std::includes(64 return std::includes(
61 std::move(__first1),65 std::move(__first1),
lib/libcxx/include/__algorithm/inplace_merge.h+8-3
...@@ -23,7 +23,11 @@...@@ -23,7 +23,11 @@
23#include <__iterator/distance.h>23#include <__iterator/distance.h>
24#include <__iterator/iterator_traits.h>24#include <__iterator/iterator_traits.h>
25#include <__iterator/reverse_iterator.h>25#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
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)32#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29# pragma GCC system_header33# pragma GCC system_header
...@@ -56,6 +60,7 @@ public:...@@ -56,6 +60,7 @@ public:
5660
57template <class _AlgPolicy, class _Compare, class _InputIterator1, class _Sent1,61template <class _AlgPolicy, class _Compare, class _InputIterator1, class _Sent1,
58 class _InputIterator2, class _Sent2, class _OutputIterator>62 class _InputIterator2, class _Sent2, class _OutputIterator>
63_LIBCPP_HIDE_FROM_ABI
59void __half_inplace_merge(_InputIterator1 __first1, _Sent1 __last1,64void __half_inplace_merge(_InputIterator1 __first1, _Sent1 __last1,
60 _InputIterator2 __first2, _Sent2 __last2,65 _InputIterator2 __first2, _Sent2 __last2,
61 _OutputIterator __result, _Compare&& __comp)66 _OutputIterator __result, _Compare&& __comp)
...@@ -83,6 +88,7 @@ void __half_inplace_merge(_InputIterator1 __first1, _Sent1 __last1,...@@ -83,6 +88,7 @@ void __half_inplace_merge(_InputIterator1 __first1, _Sent1 __last1,
83}88}
8489
85template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>90template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
91_LIBCPP_HIDE_FROM_ABI
86void __buffered_inplace_merge(92void __buffered_inplace_merge(
87 _BidirectionalIterator __first,93 _BidirectionalIterator __first,
88 _BidirectionalIterator __middle,94 _BidirectionalIterator __middle,
...@@ -231,9 +237,8 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP...@@ -231,9 +237,8 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
231template <class _BidirectionalIterator, class _Compare>237template <class _BidirectionalIterator, class _Compare>
232inline _LIBCPP_HIDE_FROM_ABI void inplace_merge(238inline _LIBCPP_HIDE_FROM_ABI void inplace_merge(
233 _BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare __comp) {239 _BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare __comp) {
234 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
235 std::__inplace_merge<_ClassicAlgPolicy>(240 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));
237}242}
238243
239template <class _BidirectionalIterator>244template <class _BidirectionalIterator>
lib/libcxx/include/__algorithm/is_heap.h+3-4
...@@ -23,17 +23,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,17 +23,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323
24template <class _RandomAccessIterator, class _Compare>24template <class _RandomAccessIterator, class _Compare>
25_LIBCPP_NODISCARD_EXT inline25_LIBCPP_NODISCARD_EXT inline
26_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1726_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
27bool27bool
28is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)28is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
29{29{
30 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;30 return std::__is_heap_until(__first, __last, static_cast<__comp_ref_type<_Compare> >(__comp)) == __last;
31 return std::__is_heap_until(__first, __last, static_cast<_Comp_ref>(__comp)) == __last;
32}31}
3332
34template<class _RandomAccessIterator>33template<class _RandomAccessIterator>
35_LIBCPP_NODISCARD_EXT inline34_LIBCPP_NODISCARD_EXT inline
36_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1735_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
37bool36bool
38is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)37is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
39{38{
lib/libcxx/include/__algorithm/is_heap_until.h+4-5
...@@ -21,7 +21,7 @@...@@ -21,7 +21,7 @@
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _Compare, class _RandomAccessIterator>23template <class _Compare, class _RandomAccessIterator>
24_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator24_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator
25__is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp)25__is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp)
26{26{
27 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;27 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
...@@ -48,15 +48,14 @@ __is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co...@@ -48,15 +48,14 @@ __is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co
48}48}
4949
50template <class _RandomAccessIterator, class _Compare>50template <class _RandomAccessIterator, class _Compare>
51_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator51_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator
52is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)52is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
53{53{
54 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;54 return std::__is_heap_until(__first, __last, static_cast<__comp_ref_type<_Compare> >(__comp));
55 return std::__is_heap_until(__first, __last, static_cast<_Comp_ref>(__comp));
56}55}
5756
58template<class _RandomAccessIterator>57template<class _RandomAccessIterator>
59_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator58_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator
60is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last)59is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last)
61{60{
62 return _VSTD::__is_heap_until(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());61 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 @@...@@ -18,7 +18,7 @@
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
1919
20template <class _InputIterator, class _Predicate>20template <class _InputIterator, class _Predicate>
21_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 bool21_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
22is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred)22is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred)
23{23{
24 for (; __first != __last; ++__first)24 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<...@@ -55,7 +55,7 @@ struct _ConstTimeDistance<_Iter1, _Iter1, _Iter2, _Iter2, __enable_if_t<
55template <class _AlgPolicy,55template <class _AlgPolicy,
56 class _Iter1, class _Sent1, class _Iter2, class _Sent2,56 class _Iter1, class _Sent1, class _Iter2, class _Sent2,
57 class _Proj1, class _Proj2, class _Pred>57 class _Proj1, class _Proj2, class _Pred>
58_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool58_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
59__is_permutation_impl(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,59__is_permutation_impl(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
60 _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2) {60 _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2) {
61 using _D1 = __iter_diff_t<_Iter1>;61 using _D1 = __iter_diff_t<_Iter1>;
...@@ -94,7 +94,7 @@ __is_permutation_impl(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 _...@@ -94,7 +94,7 @@ __is_permutation_impl(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 _
9494
95// 2+1 iterators, predicate. Not used by range algorithms.95// 2+1 iterators, predicate. Not used by range algorithms.
96template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _BinaryPredicate>96template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _BinaryPredicate>
97_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool97_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
98__is_permutation(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2,98__is_permutation(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2,
99 _BinaryPredicate&& __pred) {99 _BinaryPredicate&& __pred) {
100 // Shorten sequences as much as possible by lopping of any equal prefix.100 // Shorten sequences as much as possible by lopping of any equal prefix.
...@@ -122,7 +122,7 @@ __is_permutation(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterato...@@ -122,7 +122,7 @@ __is_permutation(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterato
122template <class _AlgPolicy,122template <class _AlgPolicy,
123 class _Iter1, class _Sent1, class _Iter2, class _Sent2,123 class _Iter1, class _Sent1, class _Iter2, class _Sent2,
124 class _Proj1, class _Proj2, class _Pred>124 class _Proj1, class _Proj2, class _Pred>
125_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool125_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
126__is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,126__is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
127 _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2,127 _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2,
128 /*_ConstTimeDistance=*/false_type) {128 /*_ConstTimeDistance=*/false_type) {
...@@ -156,7 +156,7 @@ __is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last...@@ -156,7 +156,7 @@ __is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last
156template <class _AlgPolicy,156template <class _AlgPolicy,
157 class _Iter1, class _Sent1, class _Iter2, class _Sent2,157 class _Iter1, class _Sent1, class _Iter2, class _Sent2,
158 class _Proj1, class _Proj2, class _Pred>158 class _Proj1, class _Proj2, class _Pred>
159_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool159_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
160__is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,160__is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
161 _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2,161 _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2,
162 /*_ConstTimeDistance=*/true_type) {162 /*_ConstTimeDistance=*/true_type) {
...@@ -172,7 +172,7 @@ __is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last...@@ -172,7 +172,7 @@ __is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last
172template <class _AlgPolicy,172template <class _AlgPolicy,
173 class _Iter1, class _Sent1, class _Iter2, class _Sent2,173 class _Iter1, class _Sent1, class _Iter2, class _Sent2,
174 class _Proj1, class _Proj2, class _Pred>174 class _Proj1, class _Proj2, class _Pred>
175_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool175_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
176__is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,176__is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
177 _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2) {177 _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2) {
178 return std::__is_permutation<_AlgPolicy>(178 return std::__is_permutation<_AlgPolicy>(
...@@ -185,7 +185,7 @@ __is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last...@@ -185,7 +185,7 @@ __is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last
185185
186// 2+1 iterators, predicate186// 2+1 iterators, predicate
187template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>187template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
188_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool188_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
189is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,189is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
190 _BinaryPredicate __pred) {190 _BinaryPredicate __pred) {
191 static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value,191 static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value,
...@@ -197,31 +197,30 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIt...@@ -197,31 +197,30 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIt
197197
198// 2+1 iterators198// 2+1 iterators
199template <class _ForwardIterator1, class _ForwardIterator2>199template <class _ForwardIterator1, class _ForwardIterator2>
200_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool200_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
201is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {201is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {
202 using __v1 = __iter_value_type<_ForwardIterator1>;202 return std::is_permutation(__first1, __last1, __first2, __equal_to());
203 using __v2 = __iter_value_type<_ForwardIterator2>;
204 return std::is_permutation(__first1, __last1, __first2, __equal_to<__v1, __v2>());
205}203}
206204
207#if _LIBCPP_STD_VER > 11205#if _LIBCPP_STD_VER > 11
208206
209// 2+2 iterators207// 2+2 iterators
210template <class _ForwardIterator1, class _ForwardIterator2>208template <class _ForwardIterator1, class _ForwardIterator2>
211_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool209_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation(
212is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,210 _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
213 _ForwardIterator2 __last2) {
214 using __v1 = __iter_value_type<_ForwardIterator1>;
215 using __v2 = __iter_value_type<_ForwardIterator2>;
216
217 return std::__is_permutation<_ClassicAlgPolicy>(211 return std::__is_permutation<_ClassicAlgPolicy>(
218 std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2),212 std::move(__first1),
219 __equal_to<__v1, __v2>(), __identity(), __identity());213 std::move(__last1),
214 std::move(__first2),
215 std::move(__last2),
216 __equal_to(),
217 __identity(),
218 __identity());
220}219}
221220
222// 2+2 iterators, predicate221// 2+2 iterators, predicate
223template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>222template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
224_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool223_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
225is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,224is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
226 _ForwardIterator2 __last2, _BinaryPredicate __pred) {225 _ForwardIterator2 __last2, _BinaryPredicate __pred) {
227 static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value,226 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...@@ -23,17 +23,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323
24template <class _ForwardIterator, class _Compare>24template <class _ForwardIterator, class _Compare>
25_LIBCPP_NODISCARD_EXT inline25_LIBCPP_NODISCARD_EXT inline
26_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1726_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
27bool27bool
28is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)28is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
29{29{
30 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;30 return _VSTD::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp) == __last;
31 return _VSTD::__is_sorted_until<_Comp_ref>(__first, __last, __comp) == __last;
32}31}
3332
34template<class _ForwardIterator>33template<class _ForwardIterator>
35_LIBCPP_NODISCARD_EXT inline34_LIBCPP_NODISCARD_EXT inline
36_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1735_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
37bool36bool
38is_sorted(_ForwardIterator __first, _ForwardIterator __last)37is_sorted(_ForwardIterator __first, _ForwardIterator __last)
39{38{
lib/libcxx/include/__algorithm/is_sorted_until.h+4-5
...@@ -21,7 +21,7 @@...@@ -21,7 +21,7 @@
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _Compare, class _ForwardIterator>23template <class _Compare, class _ForwardIterator>
24_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator24_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
25__is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)25__is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
26{26{
27 if (__first != __last)27 if (__first != __last)
...@@ -38,15 +38,14 @@ __is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __...@@ -38,15 +38,14 @@ __is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __
38}38}
3939
40template <class _ForwardIterator, class _Compare>40template <class _ForwardIterator, class _Compare>
41_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator41_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
42is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)42is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
43{43{
44 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;44 return _VSTD::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp);
45 return _VSTD::__is_sorted_until<_Comp_ref>(__first, __last, __comp);
46}45}
4746
48template<class _ForwardIterator>47template<class _ForwardIterator>
49_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator48_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
50is_sorted_until(_ForwardIterator __first, _ForwardIterator __last)49is_sorted_until(_ForwardIterator __first, _ForwardIterator __last)
51{50{
52 return _VSTD::is_sorted_until(__first, __last, __less<typename iterator_traits<_ForwardIterator>::value_type>());51 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 @@...@@ -20,10 +20,10 @@
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <class _ForwardIterator1, class _ForwardIterator2>22template <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,
24 _ForwardIterator2 __b)24 _ForwardIterator2 __b)
25 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))25 // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
26 _NOEXCEPT_(_NOEXCEPT_(swap(*declval<_ForwardIterator1>(), *declval<_ForwardIterator2>()))) {26 _NOEXCEPT_(_NOEXCEPT_(swap(*std::declval<_ForwardIterator1>(), *std::declval<_ForwardIterator2>()))) {
27 swap(*__a, *__b);27 swap(*__a, *__b);
28}28}
2929
lib/libcxx/include/__algorithm/iterator_operations.h+20-17
...@@ -21,10 +21,13 @@...@@ -21,10 +21,13 @@
21#include <__iterator/next.h>21#include <__iterator/next.h>
22#include <__iterator/prev.h>22#include <__iterator/prev.h>
23#include <__iterator/readable_traits.h>23#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>
24#include <__utility/declval.h>28#include <__utility/declval.h>
25#include <__utility/forward.h>29#include <__utility/forward.h>
26#include <__utility/move.h>30#include <__utility/move.h>
27#include <type_traits>
2831
29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)32#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
30# pragma GCC system_header33# pragma GCC system_header
...@@ -34,7 +37,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -34,7 +37,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3437
35template <class _AlgPolicy> struct _IterOps;38template <class _AlgPolicy> struct _IterOps;
3639
37#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)40#if _LIBCPP_STD_VER > 17
38struct _RangeAlgPolicy {};41struct _RangeAlgPolicy {};
3942
40template <>43template <>
...@@ -76,14 +79,14 @@ struct _IterOps<_ClassicAlgPolicy> {...@@ -76,14 +79,14 @@ struct _IterOps<_ClassicAlgPolicy> {
7679
77 // advance80 // advance
78 template <class _Iter, class _Distance>81 template <class _Iter, class _Distance>
79 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1182 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
80 static void advance(_Iter& __iter, _Distance __count) {83 static void advance(_Iter& __iter, _Distance __count) {
81 std::advance(__iter, __count);84 std::advance(__iter, __count);
82 }85 }
8386
84 // distance87 // distance
85 template <class _Iter>88 template <class _Iter>
86 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1189 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
87 static typename iterator_traits<_Iter>::difference_type distance(_Iter __first, _Iter __last) {90 static typename iterator_traits<_Iter>::difference_type distance(_Iter __first, _Iter __last) {
88 return std::distance(__first, __last);91 return std::distance(__first, __last);
89 }92 }
...@@ -95,9 +98,9 @@ struct _IterOps<_ClassicAlgPolicy> {...@@ -95,9 +98,9 @@ struct _IterOps<_ClassicAlgPolicy> {
95 using __move_t = decltype(std::move(*std::declval<_Iter&>()));98 using __move_t = decltype(std::move(*std::declval<_Iter&>()));
9699
97 template <class _Iter>100 template <class _Iter>
98 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11101 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
99 static void __validate_iter_reference() {102 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,
101 "It looks like your iterator's `iterator_traits<It>::reference` does not match the return type of "104 "It looks like your iterator's `iterator_traits<It>::reference` does not match the return type of "
102 "dereferencing the iterator, i.e., calling `*it`. This is undefined behavior according to [input.iterators] "105 "dereferencing the iterator, i.e., calling `*it`. This is undefined behavior according to [input.iterators] "
103 "and can lead to dangling reference issues at runtime, so we are flagging this.");106 "and can lead to dangling reference issues at runtime, so we are flagging this.");
...@@ -105,7 +108,7 @@ struct _IterOps<_ClassicAlgPolicy> {...@@ -105,7 +108,7 @@ struct _IterOps<_ClassicAlgPolicy> {
105108
106 // iter_move109 // iter_move
107 template <class _Iter>110 template <class _Iter>
108 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static111 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static
109 // If the result of dereferencing `_Iter` is a reference type, deduce the result of calling `std::move` on it. Note112 // If the result of dereferencing `_Iter` is a reference type, deduce the result of calling `std::move` on it. Note
110 // that the C++03 mode doesn't support `decltype(auto)` as the return type.113 // that the C++03 mode doesn't support `decltype(auto)` as the return type.
111 __enable_if_t<114 __enable_if_t<
...@@ -118,7 +121,7 @@ struct _IterOps<_ClassicAlgPolicy> {...@@ -118,7 +121,7 @@ struct _IterOps<_ClassicAlgPolicy> {
118 }121 }
119122
120 template <class _Iter>123 template <class _Iter>
121 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static124 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static
122 // If the result of dereferencing `_Iter` is a value type, deduce the return value of this function to also be a125 // If the result of dereferencing `_Iter` is a value type, deduce the return value of this function to also be a
123 // value -- otherwise, after `operator*` returns a temporary, this function would return a dangling reference to that126 // value -- otherwise, after `operator*` returns a temporary, this function would return a dangling reference to that
124 // temporary. Note that the C++03 mode doesn't support `auto` as the return type.127 // temporary. Note that the C++03 mode doesn't support `auto` as the return type.
...@@ -133,35 +136,35 @@ struct _IterOps<_ClassicAlgPolicy> {...@@ -133,35 +136,35 @@ struct _IterOps<_ClassicAlgPolicy> {
133136
134 // iter_swap137 // iter_swap
135 template <class _Iter1, class _Iter2>138 template <class _Iter1, class _Iter2>
136 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11139 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
137 static void iter_swap(_Iter1&& __a, _Iter2&& __b) {140 static void iter_swap(_Iter1&& __a, _Iter2&& __b) {
138 std::iter_swap(std::forward<_Iter1>(__a), std::forward<_Iter2>(__b));141 std::iter_swap(std::forward<_Iter1>(__a), std::forward<_Iter2>(__b));
139 }142 }
140143
141 // next144 // next
142 template <class _Iterator>145 template <class _Iterator>
143 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11146 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX14
144 _Iterator next(_Iterator, _Iterator __last) {147 _Iterator next(_Iterator, _Iterator __last) {
145 return __last;148 return __last;
146 }149 }
147150
148 template <class _Iter>151 template <class _Iter>
149 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11152 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX14
150 __uncvref_t<_Iter> next(_Iter&& __it,153 __remove_cvref_t<_Iter> next(_Iter&& __it,
151 typename iterator_traits<__uncvref_t<_Iter> >::difference_type __n = 1) {154 typename iterator_traits<__remove_cvref_t<_Iter> >::difference_type __n = 1) {
152 return std::next(std::forward<_Iter>(__it), __n);155 return std::next(std::forward<_Iter>(__it), __n);
153 }156 }
154157
155 // prev158 // prev
156 template <class _Iter>159 template <class _Iter>
157 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11160 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX14
158 __uncvref_t<_Iter> prev(_Iter&& __iter,161 __remove_cvref_t<_Iter> prev(_Iter&& __iter,
159 typename iterator_traits<__uncvref_t<_Iter> >::difference_type __n = 1) {162 typename iterator_traits<__remove_cvref_t<_Iter> >::difference_type __n = 1) {
160 return std::prev(std::forward<_Iter>(__iter), __n);163 return std::prev(std::forward<_Iter>(__iter), __n);
161 }164 }
162165
163 template <class _Iter>166 template <class _Iter>
164 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11167 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX14
165 void __advance_to(_Iter& __first, _Iter __last) {168 void __advance_to(_Iter& __first, _Iter __last) {
166 __first = __last;169 __first = __last;
167 }170 }
lib/libcxx/include/__algorithm/lexicographical_compare.h+4-5
...@@ -21,7 +21,7 @@...@@ -21,7 +21,7 @@
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _Compare, class _InputIterator1, class _InputIterator2>23template <class _Compare, class _InputIterator1, class _InputIterator2>
24_LIBCPP_CONSTEXPR_AFTER_CXX17 bool24_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
25__lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,25__lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
26 _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)26 _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)
27{27{
...@@ -37,18 +37,17 @@ __lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,...@@ -37,18 +37,17 @@ __lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
3737
38template <class _InputIterator1, class _InputIterator2, class _Compare>38template <class _InputIterator1, class _InputIterator2, class _Compare>
39_LIBCPP_NODISCARD_EXT inline39_LIBCPP_NODISCARD_EXT inline
40_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1740_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
41bool41bool
42lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,42lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
43 _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)43 _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)
44{44{
45 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;45 return _VSTD::__lexicographical_compare<__comp_ref_type<_Compare> >(__first1, __last1, __first2, __last2, __comp);
46 return _VSTD::__lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __comp);
47}46}
4847
49template <class _InputIterator1, class _InputIterator2>48template <class _InputIterator1, class _InputIterator2>
50_LIBCPP_NODISCARD_EXT inline49_LIBCPP_NODISCARD_EXT inline
51_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1750_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
52bool51bool
53lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,52lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
54 _InputIterator2 __first2, _InputIterator2 __last2)53 _InputIterator2 __first2, _InputIterator2 __last2)
lib/libcxx/include/__algorithm/lower_bound.h+3-3
...@@ -29,7 +29,7 @@...@@ -29,7 +29,7 @@
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
31template <class _AlgPolicy, class _Iter, class _Sent, class _Type, class _Proj, class _Comp>31template <class _AlgPolicy, class _Iter, class _Sent, class _Type, class _Proj, class _Comp>
32_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1732_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
33_Iter __lower_bound_impl(_Iter __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) {33_Iter __lower_bound_impl(_Iter __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) {
34 auto __len = _IterOps<_AlgPolicy>::distance(__first, __last);34 auto __len = _IterOps<_AlgPolicy>::distance(__first, __last);
3535
...@@ -48,7 +48,7 @@ _Iter __lower_bound_impl(_Iter __first, _Sent __last, const _Type& __value, _Com...@@ -48,7 +48,7 @@ _Iter __lower_bound_impl(_Iter __first, _Sent __last, const _Type& __value, _Com
48}48}
4949
50template <class _ForwardIterator, class _Tp, class _Compare>50template <class _ForwardIterator, class _Tp, class _Compare>
51_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1751_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
52_ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {52_ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
53 static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value,53 static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value,
54 "The comparator has to be callable");54 "The comparator has to be callable");
...@@ -57,7 +57,7 @@ _ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last,...@@ -57,7 +57,7 @@ _ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last,
57}57}
5858
59template <class _ForwardIterator, class _Tp>59template <class _ForwardIterator, class _Tp>
60_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1760_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
61_ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {61_ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
62 return std::lower_bound(__first, __last, __value,62 return std::lower_bound(__first, __last, __value,
63 __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());63 __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
lib/libcxx/include/__algorithm/make_heap.h+4-5
...@@ -24,10 +24,9 @@...@@ -24,10 +24,9 @@
24_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
2525
26template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>26template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
27inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1127inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
28void __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp) {28void __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp) {
29 using _CompRef = typename __comp_ref_type<_Compare>::type;29 __comp_ref_type<_Compare> __comp_ref = __comp;
30 _CompRef __comp_ref = __comp;
3130
32 using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;31 using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;
33 difference_type __n = __last - __first;32 difference_type __n = __last - __first;
...@@ -40,13 +39,13 @@ void __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _C...@@ -40,13 +39,13 @@ void __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _C
40}39}
4140
42template <class _RandomAccessIterator, class _Compare>41template <class _RandomAccessIterator, class _Compare>
43inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1742inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
44void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {43void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
45 std::__make_heap<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp);44 std::__make_heap<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp);
46}45}
4746
48template <class _RandomAccessIterator>47template <class _RandomAccessIterator>
49inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1748inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
50void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {49void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {
51 std::make_heap(std::move(__first), std::move(__last),50 std::make_heap(std::move(__first), std::move(__last),
52 __less<typename iterator_traits<_RandomAccessIterator>::value_type>());51 __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&) {...@@ -93,7 +93,7 @@ __make_projected(_Pred& __pred, _Proj&) {
9393
94_LIBCPP_END_NAMESPACE_STD94_LIBCPP_END_NAMESPACE_STD
9595
96#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)96#if _LIBCPP_STD_VER > 17
9797
98_LIBCPP_BEGIN_NAMESPACE_STD98_LIBCPP_BEGIN_NAMESPACE_STD
9999
...@@ -121,6 +121,6 @@ decltype(auto) __make_projected_comp(_Comp& __comp, _Proj1& __proj1, _Proj2& __p...@@ -121,6 +121,6 @@ decltype(auto) __make_projected_comp(_Comp& __comp, _Proj1& __proj1, _Proj2& __p
121121
122_LIBCPP_END_NAMESPACE_STD122_LIBCPP_END_NAMESPACE_STD
123123
124#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)124#endif // _LIBCPP_STD_VER > 17
125125
126#endif // _LIBCPP___ALGORITHM_MAKE_PROJECTED_H126#endif // _LIBCPP___ALGORITHM_MAKE_PROJECTED_H
lib/libcxx/include/__algorithm/max.h+5-6
...@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2626
27template <class _Tp, class _Compare>27template <class _Tp, class _Compare>
28_LIBCPP_NODISCARD_EXT inline28_LIBCPP_NODISCARD_EXT inline
29_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1129_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
30const _Tp&30const _Tp&
31max(const _Tp& __a, const _Tp& __b, _Compare __comp)31max(const _Tp& __a, const _Tp& __b, _Compare __comp)
32{32{
...@@ -35,7 +35,7 @@ max(const _Tp& __a, const _Tp& __b, _Compare __comp)...@@ -35,7 +35,7 @@ max(const _Tp& __a, const _Tp& __b, _Compare __comp)
3535
36template <class _Tp>36template <class _Tp>
37_LIBCPP_NODISCARD_EXT inline37_LIBCPP_NODISCARD_EXT inline
38_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1138_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
39const _Tp&39const _Tp&
40max(const _Tp& __a, const _Tp& __b)40max(const _Tp& __a, const _Tp& __b)
41{41{
...@@ -46,17 +46,16 @@ max(const _Tp& __a, const _Tp& __b)...@@ -46,17 +46,16 @@ max(const _Tp& __a, const _Tp& __b)
4646
47template<class _Tp, class _Compare>47template<class _Tp, class _Compare>
48_LIBCPP_NODISCARD_EXT inline48_LIBCPP_NODISCARD_EXT inline
49_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1149_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
50_Tp50_Tp
51max(initializer_list<_Tp> __t, _Compare __comp)51max(initializer_list<_Tp> __t, _Compare __comp)
52{52{
53 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;53 return *_VSTD::__max_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp);
54 return *_VSTD::__max_element<_Comp_ref>(__t.begin(), __t.end(), __comp);
55}54}
5655
57template<class _Tp>56template<class _Tp>
58_LIBCPP_NODISCARD_EXT inline57_LIBCPP_NODISCARD_EXT inline
59_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1158_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
60_Tp59_Tp
61max(initializer_list<_Tp> __t)60max(initializer_list<_Tp> __t)
62{61{
lib/libcxx/include/__algorithm/max_element.h+4-5
...@@ -21,7 +21,7 @@...@@ -21,7 +21,7 @@
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _Compare, class _ForwardIterator>23template <class _Compare, class _ForwardIterator>
24inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator24inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
25__max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)25__max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
26{26{
27 static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,27 static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
...@@ -37,16 +37,15 @@ __max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp...@@ -37,16 +37,15 @@ __max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp
37}37}
3838
39template <class _ForwardIterator, class _Compare>39template <class _ForwardIterator, class _Compare>
40_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator40_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
41max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)41max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
42{42{
43 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;43 return _VSTD::__max_element<__comp_ref_type<_Compare> >(__first, __last, __comp);
44 return _VSTD::__max_element<_Comp_ref>(__first, __last, __comp);
45}44}
4645
4746
48template <class _ForwardIterator>47template <class _ForwardIterator>
49_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator48_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
50max_element(_ForwardIterator __first, _ForwardIterator __last)49max_element(_ForwardIterator __first, _ForwardIterator __last)
51{50{
52 return _VSTD::max_element(__first, __last,51 return _VSTD::max_element(__first, __last,
lib/libcxx/include/__algorithm/merge.h+4-5
...@@ -22,7 +22,7 @@...@@ -22,7 +22,7 @@
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2323
24template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>24template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
25_LIBCPP_CONSTEXPR_AFTER_CXX1725_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
26_OutputIterator26_OutputIterator
27__merge(_InputIterator1 __first1, _InputIterator1 __last1,27__merge(_InputIterator1 __first1, _InputIterator1 __last1,
28 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)28 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
...@@ -46,17 +46,16 @@ __merge(_InputIterator1 __first1, _InputIterator1 __last1,...@@ -46,17 +46,16 @@ __merge(_InputIterator1 __first1, _InputIterator1 __last1,
46}46}
4747
48template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>48template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
49inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1749inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
50_OutputIterator50_OutputIterator
51merge(_InputIterator1 __first1, _InputIterator1 __last1,51merge(_InputIterator1 __first1, _InputIterator1 __last1,
52 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)52 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
53{53{
54 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;54 return _VSTD::__merge<__comp_ref_type<_Compare> >(__first1, __last1, __first2, __last2, __result, __comp);
55 return _VSTD::__merge<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
56}55}
5756
58template <class _InputIterator1, class _InputIterator2, class _OutputIterator>57template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
59inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1758inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
60_OutputIterator59_OutputIterator
61merge(_InputIterator1 __first1, _InputIterator1 __last1,60merge(_InputIterator1 __first1, _InputIterator1 __last1,
62 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)61 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
lib/libcxx/include/__algorithm/min.h+5-6
...@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2626
27template <class _Tp, class _Compare>27template <class _Tp, class _Compare>
28_LIBCPP_NODISCARD_EXT inline28_LIBCPP_NODISCARD_EXT inline
29_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1129_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
30const _Tp&30const _Tp&
31min(const _Tp& __a, const _Tp& __b, _Compare __comp)31min(const _Tp& __a, const _Tp& __b, _Compare __comp)
32{32{
...@@ -35,7 +35,7 @@ min(const _Tp& __a, const _Tp& __b, _Compare __comp)...@@ -35,7 +35,7 @@ min(const _Tp& __a, const _Tp& __b, _Compare __comp)
3535
36template <class _Tp>36template <class _Tp>
37_LIBCPP_NODISCARD_EXT inline37_LIBCPP_NODISCARD_EXT inline
38_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1138_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
39const _Tp&39const _Tp&
40min(const _Tp& __a, const _Tp& __b)40min(const _Tp& __a, const _Tp& __b)
41{41{
...@@ -46,17 +46,16 @@ min(const _Tp& __a, const _Tp& __b)...@@ -46,17 +46,16 @@ min(const _Tp& __a, const _Tp& __b)
4646
47template<class _Tp, class _Compare>47template<class _Tp, class _Compare>
48_LIBCPP_NODISCARD_EXT inline48_LIBCPP_NODISCARD_EXT inline
49_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1149_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
50_Tp50_Tp
51min(initializer_list<_Tp> __t, _Compare __comp)51min(initializer_list<_Tp> __t, _Compare __comp)
52{52{
53 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;53 return *_VSTD::__min_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp);
54 return *_VSTD::__min_element<_Comp_ref>(__t.begin(), __t.end(), __comp);
55}54}
5655
57template<class _Tp>56template<class _Tp>
58_LIBCPP_NODISCARD_EXT inline57_LIBCPP_NODISCARD_EXT inline
59_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1158_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
60_Tp59_Tp
61min(initializer_list<_Tp> __t)60min(initializer_list<_Tp> __t)
62{61{
lib/libcxx/include/__algorithm/min_element.h+5-6
...@@ -25,7 +25,7 @@...@@ -25,7 +25,7 @@
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27template <class _Comp, class _Iter, class _Sent, class _Proj>27template <class _Comp, class _Iter, class _Sent, class _Proj>
28inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1128inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
29_Iter __min_element(_Iter __first, _Sent __last, _Comp __comp, _Proj& __proj) {29_Iter __min_element(_Iter __first, _Sent __last, _Comp __comp, _Proj& __proj) {
30 if (__first == __last)30 if (__first == __last)
31 return __first;31 return __first;
...@@ -39,14 +39,14 @@ _Iter __min_element(_Iter __first, _Sent __last, _Comp __comp, _Proj& __proj) {...@@ -39,14 +39,14 @@ _Iter __min_element(_Iter __first, _Sent __last, _Comp __comp, _Proj& __proj) {
39}39}
4040
41template <class _Comp, class _Iter, class _Sent>41template <class _Comp, class _Iter, class _Sent>
42_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1142_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
43_Iter __min_element(_Iter __first, _Sent __last, _Comp __comp) {43_Iter __min_element(_Iter __first, _Sent __last, _Comp __comp) {
44 auto __proj = __identity();44 auto __proj = __identity();
45 return std::__min_element<_Comp>(std::move(__first), std::move(__last), __comp, __proj);45 return std::__min_element<_Comp>(std::move(__first), std::move(__last), __comp, __proj);
46}46}
4747
48template <class _ForwardIterator, class _Compare>48template <class _ForwardIterator, class _Compare>
49_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator49_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
50min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)50min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
51{51{
52 static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,52 static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
...@@ -54,12 +54,11 @@ min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)...@@ -54,12 +54,11 @@ min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
54 static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__first)>::value,54 static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__first)>::value,
55 "The comparator has to be callable");55 "The comparator has to be callable");
5656
57 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;57 return std::__min_element<__comp_ref_type<_Compare> >(std::move(__first), std::move(__last), __comp);
58 return std::__min_element<_Comp_ref>(std::move(__first), std::move(__last), __comp);
59}58}
6059
61template <class _ForwardIterator>60template <class _ForwardIterator>
62_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator61_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
63min_element(_ForwardIterator __first, _ForwardIterator __last)62min_element(_ForwardIterator __first, _ForwardIterator __last)
64{63{
65 return _VSTD::min_element(__first, __last,64 return _VSTD::min_element(__first, __last,
lib/libcxx/include/__algorithm/min_max_result.h+2-2
...@@ -23,7 +23,7 @@ _LIBCPP_PUSH_MACROS...@@ -23,7 +23,7 @@ _LIBCPP_PUSH_MACROS
2323
24_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
2525
26#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)26#if _LIBCPP_STD_VER > 17
2727
28namespace ranges {28namespace ranges {
2929
...@@ -47,7 +47,7 @@ struct min_max_result {...@@ -47,7 +47,7 @@ struct min_max_result {
4747
48} // namespace ranges48} // namespace ranges
4949
50#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)50#endif // _LIBCPP_STD_VER > 17
5151
52_LIBCPP_END_NAMESPACE_STD52_LIBCPP_END_NAMESPACE_STD
5353
lib/libcxx/include/__algorithm/minmax.h+4-4
...@@ -25,7 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -25,7 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2525
26template<class _Tp, class _Compare>26template<class _Tp, class _Compare>
27_LIBCPP_NODISCARD_EXT inline27_LIBCPP_NODISCARD_EXT inline
28_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1128_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
29pair<const _Tp&, const _Tp&>29pair<const _Tp&, const _Tp&>
30minmax(const _Tp& __a, const _Tp& __b, _Compare __comp)30minmax(const _Tp& __a, const _Tp& __b, _Compare __comp)
31{31{
...@@ -35,7 +35,7 @@ minmax(const _Tp& __a, const _Tp& __b, _Compare __comp)...@@ -35,7 +35,7 @@ minmax(const _Tp& __a, const _Tp& __b, _Compare __comp)
3535
36template<class _Tp>36template<class _Tp>
37_LIBCPP_NODISCARD_EXT inline37_LIBCPP_NODISCARD_EXT inline
38_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1138_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
39pair<const _Tp&, const _Tp&>39pair<const _Tp&, const _Tp&>
40minmax(const _Tp& __a, const _Tp& __b)40minmax(const _Tp& __a, const _Tp& __b)
41{41{
...@@ -45,7 +45,7 @@ minmax(const _Tp& __a, const _Tp& __b)...@@ -45,7 +45,7 @@ minmax(const _Tp& __a, const _Tp& __b)
45#ifndef _LIBCPP_CXX03_LANG45#ifndef _LIBCPP_CXX03_LANG
4646
47template<class _Tp, class _Compare>47template<class _Tp, class _Compare>
48_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1148_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
49pair<_Tp, _Tp> minmax(initializer_list<_Tp> __t, _Compare __comp) {49pair<_Tp, _Tp> minmax(initializer_list<_Tp> __t, _Compare __comp) {
50 static_assert(__is_callable<_Compare, _Tp, _Tp>::value, "The comparator has to be callable");50 static_assert(__is_callable<_Compare, _Tp, _Tp>::value, "The comparator has to be callable");
51 __identity __proj;51 __identity __proj;
...@@ -55,7 +55,7 @@ pair<_Tp, _Tp> minmax(initializer_list<_Tp> __t, _Compare __comp) {...@@ -55,7 +55,7 @@ pair<_Tp, _Tp> minmax(initializer_list<_Tp> __t, _Compare __comp) {
5555
56template<class _Tp>56template<class _Tp>
57_LIBCPP_NODISCARD_EXT inline57_LIBCPP_NODISCARD_EXT inline
58_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1158_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
59pair<_Tp, _Tp>59pair<_Tp, _Tp>
60minmax(initializer_list<_Tp> __t)60minmax(initializer_list<_Tp> __t)
61{61{
lib/libcxx/include/__algorithm/minmax_element.h+4-4
...@@ -32,14 +32,14 @@ public:...@@ -32,14 +32,14 @@ public:
32 _MinmaxElementLessFunc(_Comp& __comp, _Proj& __proj) : __comp_(__comp), __proj_(__proj) {}32 _MinmaxElementLessFunc(_Comp& __comp, _Proj& __proj) : __comp_(__comp), __proj_(__proj) {}
3333
34 template <class _Iter>34 template <class _Iter>
35 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1135 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
36 bool operator()(_Iter& __it1, _Iter& __it2) {36 bool operator()(_Iter& __it1, _Iter& __it2) {
37 return std::__invoke(__comp_, std::__invoke(__proj_, *__it1), std::__invoke(__proj_, *__it2));37 return std::__invoke(__comp_, std::__invoke(__proj_, *__it1), std::__invoke(__proj_, *__it2));
38 }38 }
39};39};
4040
41template <class _Iter, class _Sent, class _Proj, class _Comp>41template <class _Iter, class _Sent, class _Proj, class _Comp>
42_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1142_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
43pair<_Iter, _Iter> __minmax_element_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {43pair<_Iter, _Iter> __minmax_element_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
44 auto __less = _MinmaxElementLessFunc<_Comp, _Proj>(__comp, __proj);44 auto __less = _MinmaxElementLessFunc<_Comp, _Proj>(__comp, __proj);
4545
...@@ -79,7 +79,7 @@ pair<_Iter, _Iter> __minmax_element_impl(_Iter __first, _Sent __last, _Comp& __c...@@ -79,7 +79,7 @@ pair<_Iter, _Iter> __minmax_element_impl(_Iter __first, _Sent __last, _Comp& __c
79}79}
8080
81template <class _ForwardIterator, class _Compare>81template <class _ForwardIterator, class _Compare>
82_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX1182_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
83pair<_ForwardIterator, _ForwardIterator>83pair<_ForwardIterator, _ForwardIterator>
84minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {84minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {
85 static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,85 static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
...@@ -91,7 +91,7 @@ minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __com...@@ -91,7 +91,7 @@ minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __com
91}91}
9292
93template <class _ForwardIterator>93template <class _ForwardIterator>
94_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1194_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
95pair<_ForwardIterator, _ForwardIterator> minmax_element(_ForwardIterator __first, _ForwardIterator __last) {95pair<_ForwardIterator, _ForwardIterator> minmax_element(_ForwardIterator __first, _ForwardIterator __last) {
96 return std::minmax_element(__first, __last, __less<typename iterator_traits<_ForwardIterator>::value_type>());96 return std::minmax_element(__first, __last, __less<typename iterator_traits<_ForwardIterator>::value_type>());
97}97}
lib/libcxx/include/__algorithm/mismatch.h+6-10
...@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323
24template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>24template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
25_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY25_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
26 _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>26 _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
27 mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) {27 mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) {
28 for (; __first1 != __last1; ++__first1, (void)++__first2)28 for (; __first1 != __last1; ++__first1, (void)++__first2)
29 if (!__pred(*__first1, *__first2))29 if (!__pred(*__first1, *__first2))
...@@ -33,17 +33,15 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY...@@ -33,17 +33,15 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
3333
34template <class _InputIterator1, class _InputIterator2>34template <class _InputIterator1, class _InputIterator2>
35_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY35_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
36 _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>36 _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
37 mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) {37 mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) {
38 typedef typename iterator_traits<_InputIterator1>::value_type __v1;38 return std::mismatch(__first1, __last1, __first2, __equal_to());
39 typedef typename iterator_traits<_InputIterator2>::value_type __v2;
40 return _VSTD::mismatch(__first1, __last1, __first2, __equal_to<__v1, __v2>());
41}39}
4240
43#if _LIBCPP_STD_VER > 1141#if _LIBCPP_STD_VER > 11
44template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>42template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
45_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY43_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
46 _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>44 _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
47 mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,45 mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
48 _BinaryPredicate __pred) {46 _BinaryPredicate __pred) {
49 for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2)47 for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2)
...@@ -54,11 +52,9 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY...@@ -54,11 +52,9 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
5452
55template <class _InputIterator1, class _InputIterator2>53template <class _InputIterator1, class _InputIterator2>
56_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY54_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
57 _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>55 _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
58 mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {56 mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
59 typedef typename iterator_traits<_InputIterator1>::value_type __v1;57 return std::mismatch(__first1, __last1, __first2, __last2, __equal_to());
60 typedef typename iterator_traits<_InputIterator2>::value_type __v2;
61 return _VSTD::mismatch(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
62}58}
63#endif59#endif
6460
lib/libcxx/include/__algorithm/move.h+93-82
...@@ -9,111 +9,122 @@...@@ -9,111 +9,122 @@
9#ifndef _LIBCPP___ALGORITHM_MOVE_H9#ifndef _LIBCPP___ALGORITHM_MOVE_H
10#define _LIBCPP___ALGORITHM_MOVE_H10#define _LIBCPP___ALGORITHM_MOVE_H
1111
12#include <__algorithm/copy_move_common.h>
12#include <__algorithm/iterator_operations.h>13#include <__algorithm/iterator_operations.h>
13#include <__algorithm/unwrap_iter.h>14#include <__algorithm/min.h>
14#include <__config>15#include <__config>
15#include <__iterator/iterator_traits.h>16#include <__iterator/segmented_iterator.h>
16#include <__iterator/reverse_iterator.h>17#include <__type_traits/common_type.h>
18#include <__type_traits/is_copy_constructible.h>
17#include <__utility/move.h>19#include <__utility/move.h>
18#include <__utility/pair.h>20#include <__utility/pair.h>
19#include <cstring>
20#include <type_traits>
2121
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header23# pragma GCC system_header
24#endif24#endif
2525
26_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_PUSH_MACROS
27#include <__undef_macros>
2728
28// move29_LIBCPP_BEGIN_NAMESPACE_STD
2930
30template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>31template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>
31inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1432inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
32pair<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) {33__move(_InIter __first, _Sent __last, _OutIter __result);
33 while (__first != __last) {34
34 *__result = _IterOps<_AlgPolicy>::__iter_move(__first);35template <class _AlgPolicy>
35 ++__first;36struct __move_loop {
36 ++__result;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));
37 }46 }
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>48 template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0>
61struct __is_trivially_move_assignable_unwrapped_impl : false_type {};49 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
6250 operator()(_InIter __first, _InIter __last, _OutIter __result) const {
63template <class _Type>51 using _Traits = __segmented_iterator_traits<_InIter>;
64struct __is_trivially_move_assignable_unwrapped_impl<_Type*> : is_trivially_move_assignable<_Type> {};52 auto __sfirst = _Traits::__segment(__first);
6553 auto __slast = _Traits::__segment(__last);
66template <class _Iter>54 if (__sfirst == __slast) {
67struct __is_trivially_move_assignable_unwrapped55 auto __iters = std::__move<_AlgPolicy>(_Traits::__local(__first), _Traits::__local(__last), std::move(__result));
68 : __is_trivially_move_assignable_unwrapped_impl<decltype(std::__unwrap_iter<_Iter>(std::declval<_Iter>()))> {};56 return std::make_pair(__last, std::move(__iters.second));
6957 }
70template <class _AlgPolicy,58
71 class _InIter,59 __result = std::__move<_AlgPolicy>(_Traits::__local(__first), _Traits::__end(__sfirst), std::move(__result)).second;
72 class _OutIter,60 ++__sfirst;
73 __enable_if_t<is_same<typename remove_const<typename iterator_traits<_InIter>::value_type>::type,61 while (__sfirst != __slast) {
74 typename iterator_traits<_OutIter>::value_type>::value62 __result =
75 && __is_cpp17_contiguous_iterator<_InIter>::value63 std::__move<_AlgPolicy>(_Traits::__begin(__sfirst), _Traits::__end(__sfirst), std::move(__result)).second;
76 && __is_cpp17_contiguous_iterator<_OutIter>::value64 ++__sfirst;
77 && is_trivially_move_assignable<__iter_value_type<_OutIter> >::value, int> = 0>65 }
78inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1466 __result =
79pair<reverse_iterator<_InIter>, reverse_iterator<_OutIter> >67 std::__move<_AlgPolicy>(_Traits::__begin(__sfirst), _Traits::__local(__last), std::move(__result)).second;
80__move_impl(reverse_iterator<_InIter> __first,68 return std::make_pair(__last, std::move(__result));
81 reverse_iterator<_InIter> __last,69 }
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}
9070
91template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>71 template <class _InIter,
92inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1172 class _OutIter,
93__enable_if_t<is_copy_constructible<_InIter>::value73 __enable_if_t<__is_cpp17_random_access_iterator<_InIter>::value &&
94 && is_copy_constructible<_Sent>::value74 !__is_segmented_iterator<_InIter>::value && __is_segmented_iterator<_OutIter>::value,
95 && is_copy_constructible<_OutIter>::value, pair<_InIter, _OutIter> >75 int> = 0>
96__move(_InIter __first, _Sent __last, _OutIter __result) {76 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
97 auto __ret = std::__move_impl<_AlgPolicy>(77 operator()(_InIter __first, _InIter __last, _OutIter __result) {
98 std::__unwrap_iter(__first), std::__unwrap_iter(__last), std::__unwrap_iter(__result));78 using _Traits = __segmented_iterator_traits<_OutIter>;
99 return std::make_pair(std::__rewrap_iter(__first, __ret.first), std::__rewrap_iter(__result, __ret.second));79 using _DiffT = typename common_type<__iter_diff_t<_InIter>, __iter_diff_t<_OutIter> >::type;
100}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
102template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>110template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>
103inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11111inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
104__enable_if_t<!is_copy_constructible<_InIter>::value
105 || !is_copy_constructible<_Sent>::value
106 || !is_copy_constructible<_OutIter>::value, pair<_InIter, _OutIter> >
107__move(_InIter __first, _Sent __last, _OutIter __result) {112__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));
109}115}
110116
111template <class _InputIterator, class _OutputIterator>117template <class _InputIterator, class _OutputIterator>
112inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17118inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
113_OutputIterator move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {119move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
114 return std::__move<_ClassicAlgPolicy>(__first, __last, __result).second;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;
115}124}
116125
117_LIBCPP_END_NAMESPACE_STD126_LIBCPP_END_NAMESPACE_STD
118127
128_LIBCPP_POP_MACROS
129
119#endif // _LIBCPP___ALGORITHM_MOVE_H130#endif // _LIBCPP___ALGORITHM_MOVE_H
lib/libcxx/include/__algorithm/move_backward.h+105-55
...@@ -9,81 +9,131 @@...@@ -9,81 +9,131 @@
9#ifndef _LIBCPP___ALGORITHM_MOVE_BACKWARD_H9#ifndef _LIBCPP___ALGORITHM_MOVE_BACKWARD_H
10#define _LIBCPP___ALGORITHM_MOVE_BACKWARD_H10#define _LIBCPP___ALGORITHM_MOVE_BACKWARD_H
1111
12#include <__algorithm/copy_move_common.h>
12#include <__algorithm/iterator_operations.h>13#include <__algorithm/iterator_operations.h>
13#include <__algorithm/unwrap_iter.h>14#include <__algorithm/min.h>
14#include <__config>15#include <__config>
16#include <__iterator/segmented_iterator.h>
17#include <__type_traits/common_type.h>
18#include <__type_traits/is_copy_constructible.h>
15#include <__utility/move.h>19#include <__utility/move.h>
16#include <cstring>20#include <__utility/pair.h>
17#include <type_traits>
1821
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header23# pragma GCC system_header
21#endif24#endif
2225
26_LIBCPP_PUSH_MACROS
27#include <__undef_macros>
28
23_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
2430
25template <class _AlgPolicy, class _InputIterator, class _OutputIterator>31template <class _AlgPolicy, class _BidirectionalIterator1, class _Sentinel, class _BidirectionalIterator2>
26inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1432_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_BidirectionalIterator1, _BidirectionalIterator2>
27_OutputIterator33__move_backward(_BidirectionalIterator1 __first, _Sentinel __last, _BidirectionalIterator2 __result);
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}
3434
35template <class _AlgPolicy, class _InputIterator, class _OutputIterator>35template <class _AlgPolicy>
36inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1436struct __move_backward_loop {
37_OutputIterator37 template <class _InIter, class _Sent, class _OutIter>
38__move_backward_impl(_InputIterator __first, _InputIterator __last, _OutputIterator __result)38 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
39{39 operator()(_InIter __first, _Sent __last, _OutIter __result) const {
40 return _VSTD::__move_backward_constexpr<_AlgPolicy>(__first, __last, __result);40 auto __last_iter = _IterOps<_AlgPolicy>::next(__first, __last);
41}41 auto __original_last_iter = __last_iter;
4242
43template <class _AlgPolicy, class _Tp, class _Up>43 while (__first != __last_iter) {
44inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1444 *--__result = _IterOps<_AlgPolicy>::__iter_move(--__last_iter);
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));
58 }45 }
59 return __result;
60}
6146
62template <class _AlgPolicy, class _BidirectionalIterator1, class _BidirectionalIterator2>47 return std::make_pair(std::move(__original_last_iter), std::move(__result));
63inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1748 }
64_BidirectionalIterator249
65__move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,50 template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0>
66 _BidirectionalIterator2 __result)51 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
67{52 operator()(_InIter __first, _InIter __last, _OutIter __result) const {
68 if (__libcpp_is_constant_evaluated()) {53 using _Traits = __segmented_iterator_traits<_InIter>;
69 return _VSTD::__move_backward_constexpr<_AlgPolicy>(__first, __last, __result);54 auto __sfirst = _Traits::__segment(__first);
70 } else {55 auto __slast = _Traits::__segment(__last);
71 return _VSTD::__rewrap_iter(__result,56 if (__sfirst == __slast) {
72 _VSTD::__move_backward_impl<_AlgPolicy>(_VSTD::__unwrap_iter(__first),57 auto __iters =
73 _VSTD::__unwrap_iter(__last),58 std::__move_backward<_AlgPolicy>(_Traits::__local(__first), _Traits::__local(__last), std::move(__result));
74 _VSTD::__unwrap_iter(__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);
75 }105 }
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));
76}127}
77128
78template <class _BidirectionalIterator1, class _BidirectionalIterator2>129template <class _BidirectionalIterator1, class _BidirectionalIterator2>
79inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17130inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _BidirectionalIterator2
80_BidirectionalIterator2131move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, _BidirectionalIterator2 __result) {
81move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,132 return std::__move_backward<_ClassicAlgPolicy>(std::move(__first), std::move(__last), std::move(__result)).second;
82 _BidirectionalIterator2 __result)
83{
84 return std::__move_backward<_ClassicAlgPolicy>(std::move(__first), std::move(__last), std::move(__result));
85}133}
86134
87_LIBCPP_END_NAMESPACE_STD135_LIBCPP_END_NAMESPACE_STD
88136
137_LIBCPP_POP_MACROS
138
89#endif // _LIBCPP___ALGORITHM_MOVE_BACKWARD_H139#endif // _LIBCPP___ALGORITHM_MOVE_BACKWARD_H
lib/libcxx/include/__algorithm/next_permutation.h+4-6
...@@ -25,8 +25,7 @@...@@ -25,8 +25,7 @@
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27template <class _AlgPolicy, class _Compare, class _BidirectionalIterator, class _Sentinel>27template <class _AlgPolicy, class _Compare, class _BidirectionalIterator, class _Sentinel>
28_LIBCPP_CONSTEXPR_AFTER_CXX1728_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_BidirectionalIterator, bool>
29pair<_BidirectionalIterator, bool>
30__next_permutation(_BidirectionalIterator __first, _Sentinel __last, _Compare&& __comp)29__next_permutation(_BidirectionalIterator __first, _Sentinel __last, _Compare&& __comp)
31{30{
32 using _Result = pair<_BidirectionalIterator, bool>;31 using _Result = pair<_BidirectionalIterator, bool>;
...@@ -57,17 +56,16 @@ __next_permutation(_BidirectionalIterator __first, _Sentinel __last, _Compare&&...@@ -57,17 +56,16 @@ __next_permutation(_BidirectionalIterator __first, _Sentinel __last, _Compare&&
57}56}
5857
59template <class _BidirectionalIterator, class _Compare>58template <class _BidirectionalIterator, class _Compare>
60inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1759inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
61bool60bool
62next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)61next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
63{62{
64 using _Comp_ref = typename __comp_ref_type<_Compare>::type;
65 return std::__next_permutation<_ClassicAlgPolicy>(63 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;
67}65}
6866
69template <class _BidirectionalIterator>67template <class _BidirectionalIterator>
70inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1768inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
71bool69bool
72next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)70next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)
73{71{
lib/libcxx/include/__algorithm/none_of.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _InputIterator, class _Predicate>21template <class _InputIterator, class _Predicate>
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool22_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
23none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {23none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
24 for (; __first != __last; ++__first)24 for (; __first != __last; ++__first)
25 if (__pred(*__first))25 if (__pred(*__first))
lib/libcxx/include/__algorithm/nth_element.h+6-7
...@@ -26,7 +26,7 @@...@@ -26,7 +26,7 @@
26_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
2727
28template<class _Compare, class _RandomAccessIterator>28template<class _Compare, class _RandomAccessIterator>
29_LIBCPP_CONSTEXPR_AFTER_CXX11 bool29_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
30__nth_element_find_guard(_RandomAccessIterator& __i, _RandomAccessIterator& __j,30__nth_element_find_guard(_RandomAccessIterator& __i, _RandomAccessIterator& __j,
31 _RandomAccessIterator __m, _Compare __comp)31 _RandomAccessIterator __m, _Compare __comp)
32{32{
...@@ -42,7 +42,7 @@ __nth_element_find_guard(_RandomAccessIterator& __i, _RandomAccessIterator& __j,...@@ -42,7 +42,7 @@ __nth_element_find_guard(_RandomAccessIterator& __i, _RandomAccessIterator& __j,
42}42}
4343
44template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>44template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
45_LIBCPP_CONSTEXPR_AFTER_CXX11 void45_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
46__nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp)46__nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp)
47{47{
48 using _Ops = _IterOps<_AlgPolicy>;48 using _Ops = _IterOps<_AlgPolicy>;
...@@ -223,7 +223,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando...@@ -223,7 +223,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
223}223}
224224
225template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>225template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
226inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17226inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
227void __nth_element_impl(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last,227void __nth_element_impl(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last,
228 _Compare& __comp) {228 _Compare& __comp) {
229 if (__nth == __last)229 if (__nth == __last)
...@@ -231,8 +231,7 @@ void __nth_element_impl(_RandomAccessIterator __first, _RandomAccessIterator __n...@@ -231,8 +231,7 @@ void __nth_element_impl(_RandomAccessIterator __first, _RandomAccessIterator __n
231231
232 std::__debug_randomize_range<_AlgPolicy>(__first, __last);232 std::__debug_randomize_range<_AlgPolicy>(__first, __last);
233233
234 using _Comp_ref = typename __comp_ref_type<_Compare>::type;234 std::__nth_element<_AlgPolicy, __comp_ref_type<_Compare> >(__first, __nth, __last, __comp);
235 std::__nth_element<_AlgPolicy, _Comp_ref>(__first, __nth, __last, __comp);
236235
237 std::__debug_randomize_range<_AlgPolicy>(__first, __nth);236 std::__debug_randomize_range<_AlgPolicy>(__first, __nth);
238 if (__nth != __last) {237 if (__nth != __last) {
...@@ -241,14 +240,14 @@ void __nth_element_impl(_RandomAccessIterator __first, _RandomAccessIterator __n...@@ -241,14 +240,14 @@ void __nth_element_impl(_RandomAccessIterator __first, _RandomAccessIterator __n
241}240}
242241
243template <class _RandomAccessIterator, class _Compare>242template <class _RandomAccessIterator, class _Compare>
244inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17243inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
245void nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last,244void nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last,
246 _Compare __comp) {245 _Compare __comp) {
247 std::__nth_element_impl<_ClassicAlgPolicy>(std::move(__first), std::move(__nth), std::move(__last), __comp);246 std::__nth_element_impl<_ClassicAlgPolicy>(std::move(__first), std::move(__nth), std::move(__last), __comp);
248}247}
249248
250template <class _RandomAccessIterator>249template <class _RandomAccessIterator>
251inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17250inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
252void nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last) {251void nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last) {
253 std::nth_element(std::move(__first), std::move(__nth), std::move(__last), __less<typename252 std::nth_element(std::move(__first), std::move(__nth), std::move(__last), __less<typename
254 iterator_traits<_RandomAccessIterator>::value_type>());253 iterator_traits<_RandomAccessIterator>::value_type>());
lib/libcxx/include/__algorithm/partial_sort.h+6-7
...@@ -29,7 +29,7 @@...@@ -29,7 +29,7 @@
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
31template <class _AlgPolicy, class _Compare, class _RandomAccessIterator, class _Sentinel>31template <class _AlgPolicy, class _Compare, class _RandomAccessIterator, class _Sentinel>
32_LIBCPP_CONSTEXPR_AFTER_CXX1732_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
33_RandomAccessIterator __partial_sort_impl(33_RandomAccessIterator __partial_sort_impl(
34 _RandomAccessIterator __first, _RandomAccessIterator __middle, _Sentinel __last, _Compare&& __comp) {34 _RandomAccessIterator __first, _RandomAccessIterator __middle, _Sentinel __last, _Compare&& __comp) {
35 if (__first == __middle) {35 if (__first == __middle) {
...@@ -47,7 +47,6 @@ _RandomAccessIterator __partial_sort_impl(...@@ -47,7 +47,6 @@ _RandomAccessIterator __partial_sort_impl(
47 _IterOps<_AlgPolicy>::iter_swap(__i, __first);47 _IterOps<_AlgPolicy>::iter_swap(__i, __first);
48 std::__sift_down<_AlgPolicy>(__first, __comp, __len, __first);48 std::__sift_down<_AlgPolicy>(__first, __comp, __len, __first);
49 }49 }
50
51 }50 }
52 std::__sort_heap<_AlgPolicy>(std::move(__first), std::move(__middle), __comp);51 std::__sort_heap<_AlgPolicy>(std::move(__first), std::move(__middle), __comp);
5352
...@@ -55,7 +54,7 @@ _RandomAccessIterator __partial_sort_impl(...@@ -55,7 +54,7 @@ _RandomAccessIterator __partial_sort_impl(
55}54}
5655
57template <class _AlgPolicy, class _Compare, class _RandomAccessIterator, class _Sentinel>56template <class _AlgPolicy, class _Compare, class _RandomAccessIterator, class _Sentinel>
58_LIBCPP_CONSTEXPR_AFTER_CXX1757_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
59_RandomAccessIterator __partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Sentinel __last,58_RandomAccessIterator __partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Sentinel __last,
60 _Compare& __comp) {59 _Compare& __comp) {
61 if (__first == __middle)60 if (__first == __middle)
...@@ -63,8 +62,8 @@ _RandomAccessIterator __partial_sort(_RandomAccessIterator __first, _RandomAcces...@@ -63,8 +62,8 @@ _RandomAccessIterator __partial_sort(_RandomAccessIterator __first, _RandomAcces
6362
64 std::__debug_randomize_range<_AlgPolicy>(__first, __last);63 std::__debug_randomize_range<_AlgPolicy>(__first, __last);
6564
66 using _Comp_ref = typename __comp_ref_type<_Compare>::type;65 auto __last_iter =
67 auto __last_iter = std::__partial_sort_impl<_AlgPolicy>(__first, __middle, __last, static_cast<_Comp_ref>(__comp));66 std::__partial_sort_impl<_AlgPolicy>(__first, __middle, __last, static_cast<__comp_ref_type<_Compare> >(__comp));
6867
69 std::__debug_randomize_range<_AlgPolicy>(__middle, __last);68 std::__debug_randomize_range<_AlgPolicy>(__middle, __last);
7069
...@@ -72,7 +71,7 @@ _RandomAccessIterator __partial_sort(_RandomAccessIterator __first, _RandomAcces...@@ -72,7 +71,7 @@ _RandomAccessIterator __partial_sort(_RandomAccessIterator __first, _RandomAcces
72}71}
7372
74template <class _RandomAccessIterator, class _Compare>73template <class _RandomAccessIterator, class _Compare>
75inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1774inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
76void75void
77partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,76partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
78 _Compare __comp)77 _Compare __comp)
...@@ -84,7 +83,7 @@ partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran...@@ -84,7 +83,7 @@ partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran
84}83}
8584
86template <class _RandomAccessIterator>85template <class _RandomAccessIterator>
87inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1786inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
88void87void
89partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)88partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)
90{89{
lib/libcxx/include/__algorithm/partial_sort_copy.h+4-5
...@@ -33,7 +33,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -33,7 +33,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
33template <class _AlgPolicy, class _Compare,33template <class _AlgPolicy, class _Compare,
34 class _InputIterator, class _Sentinel1, class _RandomAccessIterator, class _Sentinel2,34 class _InputIterator, class _Sentinel1, class _RandomAccessIterator, class _Sentinel2,
35 class _Proj1, class _Proj2>35 class _Proj1, class _Proj2>
36_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator, _RandomAccessIterator>36_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator, _RandomAccessIterator>
37__partial_sort_copy(_InputIterator __first, _Sentinel1 __last,37__partial_sort_copy(_InputIterator __first, _Sentinel1 __last,
38 _RandomAccessIterator __result_first, _Sentinel2 __result_last,38 _RandomAccessIterator __result_first, _Sentinel2 __result_last,
39 _Compare&& __comp, _Proj1&& __proj1, _Proj2&& __proj2)39 _Compare&& __comp, _Proj1&& __proj1, _Proj2&& __proj2)
...@@ -60,7 +60,7 @@ __partial_sort_copy(_InputIterator __first, _Sentinel1 __last,...@@ -60,7 +60,7 @@ __partial_sort_copy(_InputIterator __first, _Sentinel1 __last,
60}60}
6161
62template <class _InputIterator, class _RandomAccessIterator, class _Compare>62template <class _InputIterator, class _RandomAccessIterator, class _Compare>
63inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1763inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
64_RandomAccessIterator64_RandomAccessIterator
65partial_sort_copy(_InputIterator __first, _InputIterator __last,65partial_sort_copy(_InputIterator __first, _InputIterator __last,
66 _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)66 _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)
...@@ -68,14 +68,13 @@ partial_sort_copy(_InputIterator __first, _InputIterator __last,...@@ -68,14 +68,13 @@ partial_sort_copy(_InputIterator __first, _InputIterator __last,
68 static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__result_first)>::value,68 static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__result_first)>::value,
69 "Comparator has to be callable");69 "Comparator has to be callable");
7070
71 using _Comp_ref = typename __comp_ref_type<_Compare>::type;
72 auto __result = std::__partial_sort_copy<_ClassicAlgPolicy>(__first, __last, __result_first, __result_last,71 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());
74 return __result.second;73 return __result.second;
75}74}
7675
77template <class _InputIterator, class _RandomAccessIterator>76template <class _InputIterator, class _RandomAccessIterator>
78inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1777inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
79_RandomAccessIterator78_RandomAccessIterator
80partial_sort_copy(_InputIterator __first, _InputIterator __last,79partial_sort_copy(_InputIterator __first, _InputIterator __last,
81 _RandomAccessIterator __result_first, _RandomAccessIterator __result_last)80 _RandomAccessIterator __result_first, _RandomAccessIterator __result_last)
lib/libcxx/include/__algorithm/partition.h+5-5
...@@ -23,7 +23,7 @@...@@ -23,7 +23,7 @@
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2424
25template <class _Predicate, class _AlgPolicy, class _ForwardIterator, class _Sentinel>25template <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>
27__partition_impl(_ForwardIterator __first, _Sentinel __last, _Predicate __pred, forward_iterator_tag)27__partition_impl(_ForwardIterator __first, _Sentinel __last, _Predicate __pred, forward_iterator_tag)
28{28{
29 while (true)29 while (true)
...@@ -48,7 +48,7 @@ __partition_impl(_ForwardIterator __first, _Sentinel __last, _Predicate __pred,...@@ -48,7 +48,7 @@ __partition_impl(_ForwardIterator __first, _Sentinel __last, _Predicate __pred,
48}48}
4949
50template <class _Predicate, class _AlgPolicy, class _BidirectionalIterator, class _Sentinel>50template <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>
52__partition_impl(_BidirectionalIterator __first, _Sentinel __sentinel, _Predicate __pred,52__partition_impl(_BidirectionalIterator __first, _Sentinel __sentinel, _Predicate __pred,
53 bidirectional_iterator_tag)53 bidirectional_iterator_tag)
54{54{
...@@ -76,15 +76,15 @@ __partition_impl(_BidirectionalIterator __first, _Sentinel __sentinel, _Predicat...@@ -76,15 +76,15 @@ __partition_impl(_BidirectionalIterator __first, _Sentinel __sentinel, _Predicat
76}76}
7777
78template <class _AlgPolicy, class _ForwardIterator, class _Sentinel, class _Predicate, class _IterCategory>78template <class _AlgPolicy, class _ForwardIterator, class _Sentinel, class _Predicate, class _IterCategory>
79inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1779inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
80pair<_ForwardIterator, _ForwardIterator> __partition(80pair<_ForwardIterator, _ForwardIterator> __partition(
81 _ForwardIterator __first, _Sentinel __last, _Predicate&& __pred, _IterCategory __iter_category) {81 _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>(
83 std::move(__first), std::move(__last), __pred, __iter_category);83 std::move(__first), std::move(__last), __pred, __iter_category);
84}84}
8585
86template <class _ForwardIterator, class _Predicate>86template <class _ForwardIterator, class _Predicate>
87inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1787inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
88_ForwardIterator88_ForwardIterator
89partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)89partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
90{90{
lib/libcxx/include/__algorithm/partition_copy.h+1-1
...@@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <class _InputIterator, class _OutputIterator1,22template <class _InputIterator, class _OutputIterator1,
23 class _OutputIterator2, class _Predicate>23 class _OutputIterator2, class _Predicate>
24_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_OutputIterator1, _OutputIterator2>24_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_OutputIterator1, _OutputIterator2>
25partition_copy(_InputIterator __first, _InputIterator __last,25partition_copy(_InputIterator __first, _InputIterator __last,
26 _OutputIterator1 __out_true, _OutputIterator2 __out_false,26 _OutputIterator1 __out_true, _OutputIterator2 __out_false,
27 _Predicate __pred)27 _Predicate __pred)
lib/libcxx/include/__algorithm/partition_point.h+1-1
...@@ -22,7 +22,7 @@...@@ -22,7 +22,7 @@
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2323
24template<class _ForwardIterator, class _Predicate>24template<class _ForwardIterator, class _Predicate>
25_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator25_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
26partition_point(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)26partition_point(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
27{27{
28 typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;28 typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
lib/libcxx/include/__algorithm/pop_heap.h+4-5
...@@ -27,13 +27,12 @@...@@ -27,13 +27,12 @@
27_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2828
29template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>29template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
30inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1130inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
31void __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp,31void __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp,
32 typename iterator_traits<_RandomAccessIterator>::difference_type __len) {32 typename iterator_traits<_RandomAccessIterator>::difference_type __len) {
33 _LIBCPP_ASSERT(__len > 0, "The heap given to pop_heap must be non-empty");33 _LIBCPP_ASSERT(__len > 0, "The heap given to pop_heap must be non-empty");
3434
35 using _CompRef = typename __comp_ref_type<_Compare>::type;35 __comp_ref_type<_Compare> __comp_ref = __comp;
36 _CompRef __comp_ref = __comp;
3736
38 using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;37 using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
39 if (__len > 1) {38 if (__len > 1) {
...@@ -53,7 +52,7 @@ void __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co...@@ -53,7 +52,7 @@ void __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co
53}52}
5453
55template <class _RandomAccessIterator, class _Compare>54template <class _RandomAccessIterator, class _Compare>
56inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1755inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
57void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {56void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
58 static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible.");57 static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible.");
59 static_assert(std::is_copy_assignable<_RandomAccessIterator>::value, "Iterators must be copy assignable.");58 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...@@ -63,7 +62,7 @@ void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp
63}62}
6463
65template <class _RandomAccessIterator>64template <class _RandomAccessIterator>
66inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1765inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
67void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {66void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {
68 std::pop_heap(std::move(__first), std::move(__last),67 std::pop_heap(std::move(__first), std::move(__last),
69 __less<typename iterator_traits<_RandomAccessIterator>::value_type>());68 __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
lib/libcxx/include/__algorithm/prev_permutation.h+4-5
...@@ -25,7 +25,7 @@...@@ -25,7 +25,7 @@
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27template <class _AlgPolicy, class _Compare, class _BidirectionalIterator, class _Sentinel>27template <class _AlgPolicy, class _Compare, class _BidirectionalIterator, class _Sentinel>
28_LIBCPP_CONSTEXPR_AFTER_CXX1728_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
29pair<_BidirectionalIterator, bool>29pair<_BidirectionalIterator, bool>
30__prev_permutation(_BidirectionalIterator __first, _Sentinel __last, _Compare&& __comp)30__prev_permutation(_BidirectionalIterator __first, _Sentinel __last, _Compare&& __comp)
31{31{
...@@ -57,17 +57,16 @@ __prev_permutation(_BidirectionalIterator __first, _Sentinel __last, _Compare&&...@@ -57,17 +57,16 @@ __prev_permutation(_BidirectionalIterator __first, _Sentinel __last, _Compare&&
57}57}
5858
59template <class _BidirectionalIterator, class _Compare>59template <class _BidirectionalIterator, class _Compare>
60inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1760inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
61bool61bool
62prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)62prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
63{63{
64 using _Comp_ref = typename __comp_ref_type<_Compare>::type;
65 return std::__prev_permutation<_ClassicAlgPolicy>(64 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;
67}66}
6867
69template <class _BidirectionalIterator>68template <class _BidirectionalIterator>
70inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1769inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
71bool70bool
72prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)71prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)
73{72{
lib/libcxx/include/__algorithm/push_heap.h+5-6
...@@ -24,7 +24,7 @@...@@ -24,7 +24,7 @@
24_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
2525
26template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>26template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
27_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1127_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
28void __sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp,28void __sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp,
29 typename iterator_traits<_RandomAccessIterator>::difference_type __len) {29 typename iterator_traits<_RandomAccessIterator>::difference_type __len) {
30 using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;30 using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
...@@ -50,15 +50,14 @@ void __sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Com...@@ -50,15 +50,14 @@ void __sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Com
50}50}
5151
52template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>52template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
53inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1153inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
54void __push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp) {54void __push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp) {
55 using _CompRef = typename __comp_ref_type<_Compare>::type;
56 typename iterator_traits<_RandomAccessIterator>::difference_type __len = __last - __first;55 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);
58}57}
5958
60template <class _RandomAccessIterator, class _Compare>59template <class _RandomAccessIterator, class _Compare>
61inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1760inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
62void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {61void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
63 static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible.");62 static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible.");
64 static_assert(std::is_copy_assignable<_RandomAccessIterator>::value, "Iterators must be copy assignable.");63 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...@@ -67,7 +66,7 @@ void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Com
67}66}
6867
69template <class _RandomAccessIterator>68template <class _RandomAccessIterator>
70inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1769inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
71void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {70void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {
72 std::push_heap(std::move(__first), std::move(__last),71 std::push_heap(std::move(__first), std::move(__last),
73 __less<typename iterator_traits<_RandomAccessIterator>::value_type>());72 __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
lib/libcxx/include/__algorithm/ranges_adjacent_find.h+4-4
...@@ -24,7 +24,7 @@...@@ -24,7 +24,7 @@
24# pragma GCC system_header24# pragma GCC system_header
25#endif25#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)27#if _LIBCPP_STD_VER > 17
2828
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
...@@ -50,7 +50,7 @@ struct __fn {...@@ -50,7 +50,7 @@ struct __fn {
50 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent,50 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent,
51 class _Proj = identity,51 class _Proj = identity,
52 indirect_binary_predicate<projected<_Iter, _Proj>, projected<_Iter, _Proj>> _Pred = ranges::equal_to>52 indirect_binary_predicate<projected<_Iter, _Proj>, projected<_Iter, _Proj>> _Pred = ranges::equal_to>
53 _LIBCPP_HIDE_FROM_ABI constexpr53 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
54 _Iter operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {54 _Iter operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {
55 return __adjacent_find_impl(std::move(__first), std::move(__last), __pred, __proj);55 return __adjacent_find_impl(std::move(__first), std::move(__last), __pred, __proj);
56 }56 }
...@@ -59,7 +59,7 @@ struct __fn {...@@ -59,7 +59,7 @@ struct __fn {
59 class _Proj = identity,59 class _Proj = identity,
60 indirect_binary_predicate<projected<iterator_t<_Range>, _Proj>,60 indirect_binary_predicate<projected<iterator_t<_Range>, _Proj>,
61 projected<iterator_t<_Range>, _Proj>> _Pred = ranges::equal_to>61 projected<iterator_t<_Range>, _Proj>> _Pred = ranges::equal_to>
62 _LIBCPP_HIDE_FROM_ABI constexpr62 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
63 borrowed_iterator_t<_Range> operator()(_Range&& __range, _Pred __pred = {}, _Proj __proj = {}) const {63 borrowed_iterator_t<_Range> operator()(_Range&& __range, _Pred __pred = {}, _Proj __proj = {}) const {
64 return __adjacent_find_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);64 return __adjacent_find_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
65 }65 }
...@@ -73,6 +73,6 @@ inline namespace __cpo {...@@ -73,6 +73,6 @@ inline namespace __cpo {
7373
74_LIBCPP_END_NAMESPACE_STD74_LIBCPP_END_NAMESPACE_STD
7575
76#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)76#endif // _LIBCPP_STD_VER > 17
7777
78#endif // _LIBCPP___ALGORITHM_RANGES_ADJACENT_FIND_H78#endif // _LIBCPP___ALGORITHM_RANGES_ADJACENT_FIND_H
lib/libcxx/include/__algorithm/ranges_all_of.h+4-4
...@@ -22,7 +22,7 @@...@@ -22,7 +22,7 @@
22# pragma GCC system_header22# pragma GCC system_header
23#endif23#endif
2424
25#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)25#if _LIBCPP_STD_VER > 17
2626
27_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2828
...@@ -42,14 +42,14 @@ struct __fn {...@@ -42,14 +42,14 @@ struct __fn {
4242
43 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,43 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
44 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>44 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
45 _LIBCPP_HIDE_FROM_ABI constexpr45 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
46 bool operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {46 bool operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
47 return __all_of_impl(std::move(__first), std::move(__last), __pred, __proj);47 return __all_of_impl(std::move(__first), std::move(__last), __pred, __proj);
48 }48 }
4949
50 template <input_range _Range, class _Proj = identity,50 template <input_range _Range, class _Proj = identity,
51 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>51 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
52 _LIBCPP_HIDE_FROM_ABI constexpr52 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
53 bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {53 bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
54 return __all_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);54 return __all_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
55 }55 }
...@@ -63,6 +63,6 @@ inline namespace __cpo {...@@ -63,6 +63,6 @@ inline namespace __cpo {
6363
64_LIBCPP_END_NAMESPACE_STD64_LIBCPP_END_NAMESPACE_STD
6565
66#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)66#endif // _LIBCPP_STD_VER > 17
6767
68#endif // _LIBCPP___ALGORITHM_RANGES_ALL_OF_H68#endif // _LIBCPP___ALGORITHM_RANGES_ALL_OF_H
lib/libcxx/include/__algorithm/ranges_any_of.h+4-4
...@@ -22,7 +22,7 @@...@@ -22,7 +22,7 @@
22# pragma GCC system_header22# pragma GCC system_header
23#endif23#endif
2424
25#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)25#if _LIBCPP_STD_VER > 17
2626
27_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2828
...@@ -42,14 +42,14 @@ struct __fn {...@@ -42,14 +42,14 @@ struct __fn {
4242
43 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,43 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
44 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>44 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
45 _LIBCPP_HIDE_FROM_ABI constexpr45 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
46 bool operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {46 bool operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {
47 return __any_of_impl(std::move(__first), std::move(__last), __pred, __proj);47 return __any_of_impl(std::move(__first), std::move(__last), __pred, __proj);
48 }48 }
4949
50 template <input_range _Range, class _Proj = identity,50 template <input_range _Range, class _Proj = identity,
51 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>51 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
52 _LIBCPP_HIDE_FROM_ABI constexpr52 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
53 bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {53 bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
54 return __any_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);54 return __any_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
55 }55 }
...@@ -63,6 +63,6 @@ inline namespace __cpo {...@@ -63,6 +63,6 @@ inline namespace __cpo {
6363
64_LIBCPP_END_NAMESPACE_STD64_LIBCPP_END_NAMESPACE_STD
6565
66#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)66#endif // _LIBCPP_STD_VER > 17
6767
68#endif // _LIBCPP___ALGORITHM_RANGES_ANY_OF_H68#endif // _LIBCPP___ALGORITHM_RANGES_ANY_OF_H
lib/libcxx/include/__algorithm/ranges_binary_search.h+4-4
...@@ -24,7 +24,7 @@...@@ -24,7 +24,7 @@
24# pragma GCC system_header24# pragma GCC system_header
25#endif25#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)27#if _LIBCPP_STD_VER > 17
2828
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
...@@ -33,7 +33,7 @@ namespace __binary_search {...@@ -33,7 +33,7 @@ namespace __binary_search {
33struct __fn {33struct __fn {
34 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity,34 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity,
35 indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less>35 indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less>
36 _LIBCPP_HIDE_FROM_ABI constexpr36 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
37 bool operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {37 bool operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
38 auto __ret = std::__lower_bound_impl<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj);38 auto __ret = std::__lower_bound_impl<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj);
39 return __ret != __last && !std::invoke(__comp, __value, std::invoke(__proj, *__first));39 return __ret != __last && !std::invoke(__comp, __value, std::invoke(__proj, *__first));
...@@ -41,7 +41,7 @@ struct __fn {...@@ -41,7 +41,7 @@ struct __fn {
4141
42 template <forward_range _Range, class _Type, class _Proj = identity,42 template <forward_range _Range, class _Type, class _Proj = identity,
43 indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>43 indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
44 _LIBCPP_HIDE_FROM_ABI constexpr44 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
45 bool operator()(_Range&& __r, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {45 bool operator()(_Range&& __r, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
46 auto __first = ranges::begin(__r);46 auto __first = ranges::begin(__r);
47 auto __last = ranges::end(__r);47 auto __last = ranges::end(__r);
...@@ -58,6 +58,6 @@ inline namespace __cpo {...@@ -58,6 +58,6 @@ inline namespace __cpo {
5858
59_LIBCPP_END_NAMESPACE_STD59_LIBCPP_END_NAMESPACE_STD
6060
61#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)61#endif // _LIBCPP_STD_VER > 17
6262
63#endif // _LIBCPP___ALGORITHM_RANGES_BINARY_SEARCH_H63#endif // _LIBCPP___ALGORITHM_RANGES_BINARY_SEARCH_H
lib/libcxx/include/__algorithm/ranges_clamp.h+3-3
...@@ -22,7 +22,7 @@...@@ -22,7 +22,7 @@
22# pragma GCC system_header22# pragma GCC system_header
23#endif23#endif
2424
25#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)25#if _LIBCPP_STD_VER > 17
2626
27_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2828
...@@ -33,7 +33,7 @@ struct __fn {...@@ -33,7 +33,7 @@ struct __fn {
33 template <class _Type,33 template <class _Type,
34 class _Proj = identity,34 class _Proj = identity,
35 indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>35 indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>
36 _LIBCPP_HIDE_FROM_ABI constexpr36 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
37 const _Type& operator()(const _Type& __value,37 const _Type& operator()(const _Type& __value,
38 const _Type& __low,38 const _Type& __low,
39 const _Type& __high,39 const _Type& __high,
...@@ -60,6 +60,6 @@ inline namespace __cpo {...@@ -60,6 +60,6 @@ inline namespace __cpo {
6060
61_LIBCPP_END_NAMESPACE_STD61_LIBCPP_END_NAMESPACE_STD
6262
63#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)63#endif // _LIBCPP_STD_VER > 17
6464
65#endif // _LIBCPP___ALGORITHM_RANGES_CLAMP_H65#endif // _LIBCPP___ALGORITHM_RANGES_CLAMP_H
lib/libcxx/include/__algorithm/ranges_copy.h+6-4
...@@ -11,6 +11,7 @@...@@ -11,6 +11,7 @@
1111
12#include <__algorithm/copy.h>12#include <__algorithm/copy.h>
13#include <__algorithm/in_out_result.h>13#include <__algorithm/in_out_result.h>
14#include <__algorithm/iterator_operations.h>
14#include <__config>15#include <__config>
15#include <__functional/identity.h>16#include <__functional/identity.h>
16#include <__iterator/concepts.h>17#include <__iterator/concepts.h>
...@@ -18,12 +19,13 @@...@@ -18,12 +19,13 @@
18#include <__ranges/concepts.h>19#include <__ranges/concepts.h>
19#include <__ranges/dangling.h>20#include <__ranges/dangling.h>
20#include <__utility/move.h>21#include <__utility/move.h>
22#include <__utility/pair.h>
2123
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header25# pragma GCC system_header
24#endif26#endif
2527
26#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)28#if _LIBCPP_STD_VER > 17
2729
28_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
2931
...@@ -39,7 +41,7 @@ struct __fn {...@@ -39,7 +41,7 @@ struct __fn {
39 requires indirectly_copyable<_InIter, _OutIter>41 requires indirectly_copyable<_InIter, _OutIter>
40 _LIBCPP_HIDE_FROM_ABI constexpr42 _LIBCPP_HIDE_FROM_ABI constexpr
41 copy_result<_InIter, _OutIter> operator()(_InIter __first, _Sent __last, _OutIter __result) const {43 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));
43 return {std::move(__ret.first), std::move(__ret.second)};45 return {std::move(__ret.first), std::move(__ret.second)};
44 }46 }
4547
...@@ -47,7 +49,7 @@ struct __fn {...@@ -47,7 +49,7 @@ struct __fn {
47 requires indirectly_copyable<iterator_t<_Range>, _OutIter>49 requires indirectly_copyable<iterator_t<_Range>, _OutIter>
48 _LIBCPP_HIDE_FROM_ABI constexpr50 _LIBCPP_HIDE_FROM_ABI constexpr
49 copy_result<borrowed_iterator_t<_Range>, _OutIter> operator()(_Range&& __r, _OutIter __result) const {51 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));
51 return {std::move(__ret.first), std::move(__ret.second)};53 return {std::move(__ret.first), std::move(__ret.second)};
52 }54 }
53};55};
...@@ -60,6 +62,6 @@ inline namespace __cpo {...@@ -60,6 +62,6 @@ inline namespace __cpo {
6062
61_LIBCPP_END_NAMESPACE_STD63_LIBCPP_END_NAMESPACE_STD
6264
63#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)65#endif // _LIBCPP_STD_VER > 17
6466
65#endif // _LIBCPP___ALGORITHM_RANGES_COPY_H67#endif // _LIBCPP___ALGORITHM_RANGES_COPY_H
lib/libcxx/include/__algorithm/ranges_copy_backward.h+2-3
...@@ -14,7 +14,6 @@...@@ -14,7 +14,6 @@
14#include <__algorithm/iterator_operations.h>14#include <__algorithm/iterator_operations.h>
15#include <__config>15#include <__config>
16#include <__iterator/concepts.h>16#include <__iterator/concepts.h>
17#include <__iterator/reverse_iterator.h>
18#include <__ranges/access.h>17#include <__ranges/access.h>
19#include <__ranges/concepts.h>18#include <__ranges/concepts.h>
20#include <__ranges/dangling.h>19#include <__ranges/dangling.h>
...@@ -24,7 +23,7 @@...@@ -24,7 +23,7 @@
24# pragma GCC system_header23# pragma GCC system_header
25#endif24#endif
2625
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)26#if _LIBCPP_STD_VER > 17
2827
29_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
3029
...@@ -61,6 +60,6 @@ inline namespace __cpo {...@@ -61,6 +60,6 @@ inline namespace __cpo {
6160
62_LIBCPP_END_NAMESPACE_STD61_LIBCPP_END_NAMESPACE_STD
6362
64#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)63#endif // _LIBCPP_STD_VER > 17
6564
66#endif // _LIBCPP___ALGORITHM_RANGES_COPY_BACKWARD_H65#endif // _LIBCPP___ALGORITHM_RANGES_COPY_BACKWARD_H
lib/libcxx/include/__algorithm/ranges_copy_if.h+2-2
...@@ -24,7 +24,7 @@...@@ -24,7 +24,7 @@
24# pragma GCC system_header24# pragma GCC system_header
25#endif25#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)27#if _LIBCPP_STD_VER > 17
2828
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
...@@ -76,6 +76,6 @@ inline namespace __cpo {...@@ -76,6 +76,6 @@ inline namespace __cpo {
7676
77_LIBCPP_END_NAMESPACE_STD77_LIBCPP_END_NAMESPACE_STD
7878
79#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)79#endif // _LIBCPP_STD_VER > 17
8080
81#endif // _LIBCPP___ALGORITHM_RANGES_COPY_IF_H81#endif // _LIBCPP___ALGORITHM_RANGES_COPY_IF_H
lib/libcxx/include/__algorithm/ranges_copy_n.h+4-3
...@@ -11,6 +11,7 @@...@@ -11,6 +11,7 @@
1111
12#include <__algorithm/copy.h>12#include <__algorithm/copy.h>
13#include <__algorithm/in_out_result.h>13#include <__algorithm/in_out_result.h>
14#include <__algorithm/iterator_operations.h>
14#include <__algorithm/ranges_copy.h>15#include <__algorithm/ranges_copy.h>
15#include <__config>16#include <__config>
16#include <__functional/identity.h>17#include <__functional/identity.h>
...@@ -26,7 +27,7 @@...@@ -26,7 +27,7 @@
2627
27_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2829
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)30#if _LIBCPP_STD_VER > 17
3031
31namespace ranges {32namespace ranges {
3233
...@@ -51,7 +52,7 @@ struct __fn {...@@ -51,7 +52,7 @@ struct __fn {
51 template <random_access_iterator _InIter, class _DiffType, random_access_iterator _OutIter>52 template <random_access_iterator _InIter, class _DiffType, random_access_iterator _OutIter>
52 _LIBCPP_HIDE_FROM_ABI constexpr static53 _LIBCPP_HIDE_FROM_ABI constexpr static
53 copy_n_result<_InIter, _OutIter> __go(_InIter __first, _DiffType __n, _OutIter __result) {54 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);
55 return {__ret.first, __ret.second};56 return {__ret.first, __ret.second};
56 }57 }
5758
...@@ -69,7 +70,7 @@ inline namespace __cpo {...@@ -69,7 +70,7 @@ inline namespace __cpo {
69} // namespace __cpo70} // namespace __cpo
70} // namespace ranges71} // namespace ranges
7172
72#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)73#endif // _LIBCPP_STD_VER > 17
7374
74_LIBCPP_END_NAMESPACE_STD75_LIBCPP_END_NAMESPACE_STD
7576
lib/libcxx/include/__algorithm/ranges_count.h+4-4
...@@ -25,7 +25,7 @@...@@ -25,7 +25,7 @@
25# pragma GCC system_header25# pragma GCC system_header
26#endif26#endif
2727
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)28#if _LIBCPP_STD_VER > 17
2929
30_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
3131
...@@ -34,7 +34,7 @@ namespace __count {...@@ -34,7 +34,7 @@ namespace __count {
34struct __fn {34struct __fn {
35 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>35 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>
36 requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>36 requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>
37 _LIBCPP_HIDE_FROM_ABI constexpr37 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
38 iter_difference_t<_Iter> operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const {38 iter_difference_t<_Iter> operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const {
39 auto __pred = [&](auto&& __e) { return __e == __value; };39 auto __pred = [&](auto&& __e) { return __e == __value; };
40 return ranges::__count_if_impl(std::move(__first), std::move(__last), __pred, __proj);40 return ranges::__count_if_impl(std::move(__first), std::move(__last), __pred, __proj);
...@@ -42,7 +42,7 @@ struct __fn {...@@ -42,7 +42,7 @@ struct __fn {
4242
43 template <input_range _Range, class _Type, class _Proj = identity>43 template <input_range _Range, class _Type, class _Proj = identity>
44 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>44 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
45 _LIBCPP_HIDE_FROM_ABI constexpr45 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
46 range_difference_t<_Range> operator()(_Range&& __r, const _Type& __value, _Proj __proj = {}) const {46 range_difference_t<_Range> operator()(_Range&& __r, const _Type& __value, _Proj __proj = {}) const {
47 auto __pred = [&](auto&& __e) { return __e == __value; };47 auto __pred = [&](auto&& __e) { return __e == __value; };
48 return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);48 return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
...@@ -57,6 +57,6 @@ inline namespace __cpo {...@@ -57,6 +57,6 @@ inline namespace __cpo {
5757
58_LIBCPP_END_NAMESPACE_STD58_LIBCPP_END_NAMESPACE_STD
5959
60#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)60#endif // _LIBCPP_STD_VER > 17
6161
62#endif // _LIBCPP___ALGORITHM_RANGES_COUNT_H62#endif // _LIBCPP___ALGORITHM_RANGES_COUNT_H
lib/libcxx/include/__algorithm/ranges_count_if.h+4-4
...@@ -25,7 +25,7 @@...@@ -25,7 +25,7 @@
25# pragma GCC system_header25# pragma GCC system_header
26#endif26#endif
2727
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)28#if _LIBCPP_STD_VER > 17
2929
30_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
3131
...@@ -46,14 +46,14 @@ namespace __count_if {...@@ -46,14 +46,14 @@ namespace __count_if {
46struct __fn {46struct __fn {
47 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,47 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
48 indirect_unary_predicate<projected<_Iter, _Proj>> _Predicate>48 indirect_unary_predicate<projected<_Iter, _Proj>> _Predicate>
49 _LIBCPP_HIDE_FROM_ABI constexpr49 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
50 iter_difference_t<_Iter> operator()(_Iter __first, _Sent __last, _Predicate __pred, _Proj __proj = {}) const {50 iter_difference_t<_Iter> operator()(_Iter __first, _Sent __last, _Predicate __pred, _Proj __proj = {}) const {
51 return ranges::__count_if_impl(std::move(__first), std::move(__last), __pred, __proj);51 return ranges::__count_if_impl(std::move(__first), std::move(__last), __pred, __proj);
52 }52 }
5353
54 template <input_range _Range, class _Proj = identity,54 template <input_range _Range, class _Proj = identity,
55 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Predicate>55 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Predicate>
56 _LIBCPP_HIDE_FROM_ABI constexpr56 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
57 range_difference_t<_Range> operator()(_Range&& __r, _Predicate __pred, _Proj __proj = {}) const {57 range_difference_t<_Range> operator()(_Range&& __r, _Predicate __pred, _Proj __proj = {}) const {
58 return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);58 return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
59 }59 }
...@@ -67,6 +67,6 @@ inline namespace __cpo {...@@ -67,6 +67,6 @@ inline namespace __cpo {
6767
68_LIBCPP_END_NAMESPACE_STD68_LIBCPP_END_NAMESPACE_STD
6969
70#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)70#endif // _LIBCPP_STD_VER > 17
7171
72#endif // _LIBCPP___ALGORITHM_RANGES_COUNT_IF_H72#endif // _LIBCPP___ALGORITHM_RANGES_COUNT_IF_H
lib/libcxx/include/__algorithm/ranges_equal.h+4-4
...@@ -24,7 +24,7 @@...@@ -24,7 +24,7 @@
24# pragma GCC system_header24# pragma GCC system_header
25#endif25#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)27#if _LIBCPP_STD_VER > 17
2828
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
...@@ -60,7 +60,7 @@ public:...@@ -60,7 +60,7 @@ public:
60 class _Proj1 = identity,60 class _Proj1 = identity,
61 class _Proj2 = identity>61 class _Proj2 = identity>
62 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>62 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
63 _LIBCPP_HIDE_FROM_ABI constexpr63 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
64 bool operator()(_Iter1 __first1, _Sent1 __last1,64 bool operator()(_Iter1 __first1, _Sent1 __last1,
65 _Iter2 __first2, _Sent2 __last2,65 _Iter2 __first2, _Sent2 __last2,
66 _Pred __pred = {},66 _Pred __pred = {},
...@@ -83,7 +83,7 @@ public:...@@ -83,7 +83,7 @@ public:
83 class _Proj1 = identity,83 class _Proj1 = identity,
84 class _Proj2 = identity>84 class _Proj2 = identity>
85 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>85 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
86 _LIBCPP_HIDE_FROM_ABI constexpr86 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
87 bool operator()(_Range1&& __range1,87 bool operator()(_Range1&& __range1,
88 _Range2&& __range2,88 _Range2&& __range2,
89 _Pred __pred = {},89 _Pred __pred = {},
...@@ -110,6 +110,6 @@ inline namespace __cpo {...@@ -110,6 +110,6 @@ inline namespace __cpo {
110110
111_LIBCPP_END_NAMESPACE_STD111_LIBCPP_END_NAMESPACE_STD
112112
113#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)113#endif // _LIBCPP_STD_VER > 17
114114
115#endif // _LIBCPP___ALGORITHM_RANGES_EQUAL_H115#endif // _LIBCPP___ALGORITHM_RANGES_EQUAL_H
lib/libcxx/include/__algorithm/ranges_equal_range.h+5-4
...@@ -24,12 +24,13 @@...@@ -24,12 +24,13 @@
24#include <__ranges/subrange.h>24#include <__ranges/subrange.h>
25#include <__utility/forward.h>25#include <__utility/forward.h>
26#include <__utility/move.h>26#include <__utility/move.h>
27#include <__utility/pair.h>
2728
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29# pragma GCC system_header30# pragma GCC system_header
30#endif31#endif
3132
32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)33#if _LIBCPP_STD_VER > 17
3334
34_LIBCPP_BEGIN_NAMESPACE_STD35_LIBCPP_BEGIN_NAMESPACE_STD
3536
...@@ -43,7 +44,7 @@ struct __fn {...@@ -43,7 +44,7 @@ struct __fn {
43 class _Tp,44 class _Tp,
44 class _Proj = identity,45 class _Proj = identity,
45 indirect_strict_weak_order<const _Tp*, projected<_Iter, _Proj>> _Comp = ranges::less>46 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>
47 operator()(_Iter __first, _Sent __last, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const {48 operator()(_Iter __first, _Sent __last, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const {
48 auto __ret = std::__equal_range<_RangeAlgPolicy>(49 auto __ret = std::__equal_range<_RangeAlgPolicy>(
49 std::move(__first), std::move(__last), __value, __comp, __proj);50 std::move(__first), std::move(__last), __value, __comp, __proj);
...@@ -55,7 +56,7 @@ struct __fn {...@@ -55,7 +56,7 @@ struct __fn {
55 class _Tp,56 class _Tp,
56 class _Proj = identity,57 class _Proj = identity,
57 indirect_strict_weak_order<const _Tp*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>58 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>
59 operator()(_Range&& __range, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const {60 operator()(_Range&& __range, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const {
60 auto __ret = std::__equal_range<_RangeAlgPolicy>(61 auto __ret = std::__equal_range<_RangeAlgPolicy>(
61 ranges::begin(__range), ranges::end(__range), __value, __comp, __proj);62 ranges::begin(__range), ranges::end(__range), __value, __comp, __proj);
...@@ -72,6 +73,6 @@ inline namespace __cpo {...@@ -72,6 +73,6 @@ inline namespace __cpo {
7273
73_LIBCPP_END_NAMESPACE_STD74_LIBCPP_END_NAMESPACE_STD
7475
75#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)76#endif // _LIBCPP_STD_VER > 17
7677
77#endif // _LIBCPP___ALGORITHM_RANGES_EQUAL_RANGE_H78#endif // _LIBCPP___ALGORITHM_RANGES_EQUAL_RANGE_H
lib/libcxx/include/__algorithm/ranges_fill.h+2-2
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
20# pragma GCC system_header20# pragma GCC system_header
21#endif21#endif
2222
23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)23#if _LIBCPP_STD_VER > 17
2424
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
...@@ -54,6 +54,6 @@ inline namespace __cpo {...@@ -54,6 +54,6 @@ inline namespace __cpo {
5454
55_LIBCPP_END_NAMESPACE_STD55_LIBCPP_END_NAMESPACE_STD
5656
57#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)57#endif // _LIBCPP_STD_VER > 17
5858
59#endif // _LIBCPP___ALGORITHM_RANGES_FILL_H59#endif // _LIBCPP___ALGORITHM_RANGES_FILL_H
lib/libcxx/include/__algorithm/ranges_fill_n.h+2-2
...@@ -17,7 +17,7 @@...@@ -17,7 +17,7 @@
17# pragma GCC system_header17# pragma GCC system_header
18#endif18#endif
1919
20#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)20#if _LIBCPP_STD_VER > 17
2121
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2323
...@@ -43,6 +43,6 @@ inline namespace __cpo {...@@ -43,6 +43,6 @@ inline namespace __cpo {
4343
44_LIBCPP_END_NAMESPACE_STD44_LIBCPP_END_NAMESPACE_STD
4545
46#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)46#endif // _LIBCPP_STD_VER > 17
4747
48#endif // _LIBCPP___ALGORITHM_RANGES_FILL_N_H48#endif // _LIBCPP___ALGORITHM_RANGES_FILL_N_H
lib/libcxx/include/__algorithm/ranges_find.h+4-4
...@@ -26,7 +26,7 @@...@@ -26,7 +26,7 @@
26# pragma GCC system_header26# pragma GCC system_header
27#endif27#endif
2828
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)29#if _LIBCPP_STD_VER > 17
3030
31_LIBCPP_BEGIN_NAMESPACE_STD31_LIBCPP_BEGIN_NAMESPACE_STD
3232
...@@ -35,7 +35,7 @@ namespace __find {...@@ -35,7 +35,7 @@ namespace __find {
35struct __fn {35struct __fn {
36 template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, class _Proj = identity>36 template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, class _Proj = identity>
37 requires indirect_binary_predicate<ranges::equal_to, projected<_Ip, _Proj>, const _Tp*>37 requires indirect_binary_predicate<ranges::equal_to, projected<_Ip, _Proj>, const _Tp*>
38 _LIBCPP_HIDE_FROM_ABI constexpr38 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
39 _Ip operator()(_Ip __first, _Sp __last, const _Tp& __value, _Proj __proj = {}) const {39 _Ip operator()(_Ip __first, _Sp __last, const _Tp& __value, _Proj __proj = {}) const {
40 auto __pred = [&](auto&& __e) { return std::forward<decltype(__e)>(__e) == __value; };40 auto __pred = [&](auto&& __e) { return std::forward<decltype(__e)>(__e) == __value; };
41 return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred, __proj);41 return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred, __proj);
...@@ -43,7 +43,7 @@ struct __fn {...@@ -43,7 +43,7 @@ struct __fn {
4343
44 template <input_range _Rp, class _Tp, class _Proj = identity>44 template <input_range _Rp, class _Tp, class _Proj = identity>
45 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Rp>, _Proj>, const _Tp*>45 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Rp>, _Proj>, const _Tp*>
46 _LIBCPP_HIDE_FROM_ABI constexpr46 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
47 borrowed_iterator_t<_Rp> operator()(_Rp&& __r, const _Tp& __value, _Proj __proj = {}) const {47 borrowed_iterator_t<_Rp> operator()(_Rp&& __r, const _Tp& __value, _Proj __proj = {}) const {
48 auto __pred = [&](auto&& __e) { return std::forward<decltype(__e)>(__e) == __value; };48 auto __pred = [&](auto&& __e) { return std::forward<decltype(__e)>(__e) == __value; };
49 return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);49 return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
...@@ -58,6 +58,6 @@ inline namespace __cpo {...@@ -58,6 +58,6 @@ inline namespace __cpo {
5858
59_LIBCPP_END_NAMESPACE_STD59_LIBCPP_END_NAMESPACE_STD
6060
61#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)61#endif // _LIBCPP_STD_VER > 17
6262
63#endif // _LIBCPP___ALGORITHM_RANGES_FIND_H63#endif // _LIBCPP___ALGORITHM_RANGES_FIND_H
lib/libcxx/include/__algorithm/ranges_find_end.h+5-4
...@@ -21,12 +21,13 @@...@@ -21,12 +21,13 @@
21#include <__ranges/access.h>21#include <__ranges/access.h>
22#include <__ranges/concepts.h>22#include <__ranges/concepts.h>
23#include <__ranges/subrange.h>23#include <__ranges/subrange.h>
24#include <__utility/pair.h>
2425
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26# pragma GCC system_header27# pragma GCC system_header
27#endif28#endif
2829
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)30#if _LIBCPP_STD_VER > 17
3031
31_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
3233
...@@ -39,7 +40,7 @@ struct __fn {...@@ -39,7 +40,7 @@ struct __fn {
39 class _Proj1 = identity,40 class _Proj1 = identity,
40 class _Proj2 = identity>41 class _Proj2 = identity>
41 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>42 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
42 _LIBCPP_HIDE_FROM_ABI constexpr43 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
43 subrange<_Iter1> operator()(_Iter1 __first1, _Sent1 __last1,44 subrange<_Iter1> operator()(_Iter1 __first1, _Sent1 __last1,
44 _Iter2 __first2, _Sent2 __last2,45 _Iter2 __first2, _Sent2 __last2,
45 _Pred __pred = {},46 _Pred __pred = {},
...@@ -64,7 +65,7 @@ struct __fn {...@@ -64,7 +65,7 @@ struct __fn {
64 class _Proj1 = identity,65 class _Proj1 = identity,
65 class _Proj2 = identity>66 class _Proj2 = identity>
66 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>67 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
67 _LIBCPP_HIDE_FROM_ABI constexpr68 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
68 borrowed_subrange_t<_Range1> operator()(_Range1&& __range1,69 borrowed_subrange_t<_Range1> operator()(_Range1&& __range1,
69 _Range2&& __range2,70 _Range2&& __range2,
70 _Pred __pred = {},71 _Pred __pred = {},
...@@ -92,6 +93,6 @@ inline namespace __cpo {...@@ -92,6 +93,6 @@ inline namespace __cpo {
9293
93_LIBCPP_END_NAMESPACE_STD94_LIBCPP_END_NAMESPACE_STD
9495
95#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)96#endif // _LIBCPP_STD_VER > 17
9697
97#endif // _LIBCPP___ALGORITHM_RANGES_FIND_END_H98#endif // _LIBCPP___ALGORITHM_RANGES_FIND_END_H
lib/libcxx/include/__algorithm/ranges_find_first_of.h+4-4
...@@ -24,7 +24,7 @@...@@ -24,7 +24,7 @@
24# pragma GCC system_header24# pragma GCC system_header
25#endif25#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)27#if _LIBCPP_STD_VER > 17
2828
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
...@@ -54,7 +54,7 @@ struct __fn {...@@ -54,7 +54,7 @@ struct __fn {
54 class _Proj1 = identity,54 class _Proj1 = identity,
55 class _Proj2 = identity>55 class _Proj2 = identity>
56 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>56 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
57 _LIBCPP_HIDE_FROM_ABI constexpr57 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
58 _Iter1 operator()(_Iter1 __first1, _Sent1 __last1,58 _Iter1 operator()(_Iter1 __first1, _Sent1 __last1,
59 _Iter2 __first2, _Sent2 __last2,59 _Iter2 __first2, _Sent2 __last2,
60 _Pred __pred = {},60 _Pred __pred = {},
...@@ -73,7 +73,7 @@ struct __fn {...@@ -73,7 +73,7 @@ struct __fn {
73 class _Proj1 = identity,73 class _Proj1 = identity,
74 class _Proj2 = identity>74 class _Proj2 = identity>
75 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>75 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
76 _LIBCPP_HIDE_FROM_ABI constexpr76 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
77 borrowed_iterator_t<_Range1> operator()(_Range1&& __range1,77 borrowed_iterator_t<_Range1> operator()(_Range1&& __range1,
78 _Range2&& __range2,78 _Range2&& __range2,
79 _Pred __pred = {},79 _Pred __pred = {},
...@@ -96,6 +96,6 @@ inline namespace __cpo {...@@ -96,6 +96,6 @@ inline namespace __cpo {
9696
97_LIBCPP_END_NAMESPACE_STD97_LIBCPP_END_NAMESPACE_STD
9898
99#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)99#endif // _LIBCPP_STD_VER > 17
100100
101#endif // _LIBCPP___ALGORITHM_RANGES_FIND_FIRST_OF_H101#endif // _LIBCPP___ALGORITHM_RANGES_FIND_FIRST_OF_H
lib/libcxx/include/__algorithm/ranges_find_if.h+4-4
...@@ -24,7 +24,7 @@...@@ -24,7 +24,7 @@
24# pragma GCC system_header24# pragma GCC system_header
25#endif25#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)27#if _LIBCPP_STD_VER > 17
2828
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
...@@ -45,14 +45,14 @@ struct __fn {...@@ -45,14 +45,14 @@ struct __fn {
4545
46 template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,46 template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
47 indirect_unary_predicate<projected<_Ip, _Proj>> _Pred>47 indirect_unary_predicate<projected<_Ip, _Proj>> _Pred>
48 _LIBCPP_HIDE_FROM_ABI constexpr48 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
49 _Ip operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const {49 _Ip operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const {
50 return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred, __proj);50 return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred, __proj);
51 }51 }
5252
53 template <input_range _Rp, class _Proj = identity,53 template <input_range _Rp, class _Proj = identity,
54 indirect_unary_predicate<projected<iterator_t<_Rp>, _Proj>> _Pred>54 indirect_unary_predicate<projected<iterator_t<_Rp>, _Proj>> _Pred>
55 _LIBCPP_HIDE_FROM_ABI constexpr55 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
56 borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const {56 borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const {
57 return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);57 return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
58 }58 }
...@@ -66,6 +66,6 @@ inline namespace __cpo {...@@ -66,6 +66,6 @@ inline namespace __cpo {
6666
67_LIBCPP_END_NAMESPACE_STD67_LIBCPP_END_NAMESPACE_STD
6868
69#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)69#endif // _LIBCPP_STD_VER > 17
7070
71#endif // _LIBCPP___ALGORITHM_RANGES_FIND_IF_H71#endif // _LIBCPP___ALGORITHM_RANGES_FIND_IF_H
lib/libcxx/include/__algorithm/ranges_find_if_not.h+4-4
...@@ -26,7 +26,7 @@...@@ -26,7 +26,7 @@
26# pragma GCC system_header26# pragma GCC system_header
27#endif27#endif
2828
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)29#if _LIBCPP_STD_VER > 17
3030
31_LIBCPP_BEGIN_NAMESPACE_STD31_LIBCPP_BEGIN_NAMESPACE_STD
3232
...@@ -35,7 +35,7 @@ namespace __find_if_not {...@@ -35,7 +35,7 @@ namespace __find_if_not {
35struct __fn {35struct __fn {
36 template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,36 template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
37 indirect_unary_predicate<projected<_Ip, _Proj>> _Pred>37 indirect_unary_predicate<projected<_Ip, _Proj>> _Pred>
38 _LIBCPP_HIDE_FROM_ABI constexpr38 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
39 _Ip operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const {39 _Ip operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const {
40 auto __pred2 = [&](auto&& __e) { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); };40 auto __pred2 = [&](auto&& __e) { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); };
41 return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred2, __proj);41 return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred2, __proj);
...@@ -43,7 +43,7 @@ struct __fn {...@@ -43,7 +43,7 @@ struct __fn {
4343
44 template <input_range _Rp, class _Proj = identity,44 template <input_range _Rp, class _Proj = identity,
45 indirect_unary_predicate<projected<iterator_t<_Rp>, _Proj>> _Pred>45 indirect_unary_predicate<projected<iterator_t<_Rp>, _Proj>> _Pred>
46 _LIBCPP_HIDE_FROM_ABI constexpr46 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
47 borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const {47 borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const {
48 auto __pred2 = [&](auto&& __e) { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); };48 auto __pred2 = [&](auto&& __e) { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); };
49 return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred2, __proj);49 return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred2, __proj);
...@@ -58,6 +58,6 @@ inline namespace __cpo {...@@ -58,6 +58,6 @@ inline namespace __cpo {
5858
59_LIBCPP_END_NAMESPACE_STD59_LIBCPP_END_NAMESPACE_STD
6060
61#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)61#endif // _LIBCPP_STD_VER > 17
6262
63#endif // _LIBCPP___ALGORITHM_RANGES_FIND_IF_NOT_H63#endif // _LIBCPP___ALGORITHM_RANGES_FIND_IF_NOT_H
lib/libcxx/include/__algorithm/ranges_for_each.h+2-2
...@@ -24,7 +24,7 @@...@@ -24,7 +24,7 @@
24# pragma GCC system_header24# pragma GCC system_header
25#endif25#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)27#if _LIBCPP_STD_VER > 17
2828
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
...@@ -73,6 +73,6 @@ inline namespace __cpo {...@@ -73,6 +73,6 @@ inline namespace __cpo {
7373
74_LIBCPP_END_NAMESPACE_STD74_LIBCPP_END_NAMESPACE_STD
7575
76#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)76#endif // _LIBCPP_STD_VER > 17
7777
78#endif // _LIBCPP___ALGORITHM_RANGES_FOR_EACH_H78#endif // _LIBCPP___ALGORITHM_RANGES_FOR_EACH_H
lib/libcxx/include/__algorithm/ranges_for_each_n.h+2-2
...@@ -24,7 +24,7 @@...@@ -24,7 +24,7 @@
24# pragma GCC system_header24# pragma GCC system_header
25#endif25#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)27#if _LIBCPP_STD_VER > 17
2828
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
...@@ -61,6 +61,6 @@ inline namespace __cpo {...@@ -61,6 +61,6 @@ inline namespace __cpo {
6161
62_LIBCPP_END_NAMESPACE_STD62_LIBCPP_END_NAMESPACE_STD
6363
64#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)64#endif // _LIBCPP_STD_VER > 17
6565
66#endif // _LIBCPP___ALGORITHM_RANGES_FOR_EACH_N_H66#endif // _LIBCPP___ALGORITHM_RANGES_FOR_EACH_N_H
lib/libcxx/include/__algorithm/ranges_generate.h+2-2
...@@ -24,7 +24,7 @@...@@ -24,7 +24,7 @@
24# pragma GCC system_header24# pragma GCC system_header
25#endif25#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)27#if _LIBCPP_STD_VER > 17
2828
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
...@@ -68,6 +68,6 @@ inline namespace __cpo {...@@ -68,6 +68,6 @@ inline namespace __cpo {
6868
69_LIBCPP_END_NAMESPACE_STD69_LIBCPP_END_NAMESPACE_STD
7070
71#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)71#endif // _LIBCPP_STD_VER > 17
7272
73#endif // _LIBCPP___ALGORITHM_RANGES_GENERATE_H73#endif // _LIBCPP___ALGORITHM_RANGES_GENERATE_H
lib/libcxx/include/__algorithm/ranges_generate_n.h+2-2
...@@ -25,7 +25,7 @@...@@ -25,7 +25,7 @@
25# pragma GCC system_header25# pragma GCC system_header
26#endif26#endif
2727
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)28#if _LIBCPP_STD_VER > 17
2929
30_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
3131
...@@ -57,6 +57,6 @@ inline namespace __cpo {...@@ -57,6 +57,6 @@ inline namespace __cpo {
5757
58_LIBCPP_END_NAMESPACE_STD58_LIBCPP_END_NAMESPACE_STD
5959
60#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)60#endif // _LIBCPP_STD_VER > 17
6161
62#endif // _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H62#endif // _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H
lib/libcxx/include/__algorithm/ranges_includes.h+4-4
...@@ -27,7 +27,7 @@...@@ -27,7 +27,7 @@
27# pragma GCC system_header27# pragma GCC system_header
28#endif28#endif
2929
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)30#if _LIBCPP_STD_VER > 17
3131
32_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
3333
...@@ -43,7 +43,7 @@ struct __fn {...@@ -43,7 +43,7 @@ struct __fn {
43 class _Proj1 = identity,43 class _Proj1 = identity,
44 class _Proj2 = identity,44 class _Proj2 = identity,
45 indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less>45 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()(
47 _Iter1 __first1,47 _Iter1 __first1,
48 _Sent1 __last1,48 _Sent1 __last1,
49 _Iter2 __first2,49 _Iter2 __first2,
...@@ -68,7 +68,7 @@ struct __fn {...@@ -68,7 +68,7 @@ struct __fn {
68 class _Proj2 = identity,68 class _Proj2 = identity,
69 indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>>69 indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>>
70 _Comp = ranges::less>70 _Comp = ranges::less>
71 _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(71 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
72 _Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {72 _Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
73 return std::__includes(73 return std::__includes(
74 ranges::begin(__range1),74 ranges::begin(__range1),
...@@ -90,6 +90,6 @@ inline namespace __cpo {...@@ -90,6 +90,6 @@ inline namespace __cpo {
9090
91_LIBCPP_END_NAMESPACE_STD91_LIBCPP_END_NAMESPACE_STD
9292
93#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)93#endif // _LIBCPP_STD_VER > 17
9494
95#endif // _LIBCPP___ALGORITHM_RANGES_INCLUDES_H95#endif // _LIBCPP___ALGORITHM_RANGES_INCLUDES_H
lib/libcxx/include/__algorithm/ranges_inplace_merge.h+2-2
...@@ -31,7 +31,7 @@...@@ -31,7 +31,7 @@
31# pragma GCC system_header31# pragma GCC system_header
32#endif32#endif
3333
34#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)34#if _LIBCPP_STD_VER > 17
3535
36_LIBCPP_BEGIN_NAMESPACE_STD36_LIBCPP_BEGIN_NAMESPACE_STD
3737
...@@ -80,6 +80,6 @@ inline namespace __cpo {...@@ -80,6 +80,6 @@ inline namespace __cpo {
8080
81_LIBCPP_END_NAMESPACE_STD81_LIBCPP_END_NAMESPACE_STD
8282
83#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)83#endif // _LIBCPP_STD_VER > 17
8484
85#endif // _LIBCPP___ALGORITHM_RANGES_INPLACE_MERGE_H85#endif // _LIBCPP___ALGORITHM_RANGES_INPLACE_MERGE_H
lib/libcxx/include/__algorithm/ranges_is_heap.h+4-4
...@@ -26,7 +26,7 @@...@@ -26,7 +26,7 @@
26# pragma GCC system_header26# pragma GCC system_header
27#endif27#endif
2828
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)29#if _LIBCPP_STD_VER > 17
3030
31_LIBCPP_BEGIN_NAMESPACE_STD31_LIBCPP_BEGIN_NAMESPACE_STD
3232
...@@ -47,14 +47,14 @@ struct __fn {...@@ -47,14 +47,14 @@ struct __fn {
4747
48 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,48 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
49 indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>49 indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
50 _LIBCPP_HIDE_FROM_ABI constexpr50 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
51 bool operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {51 bool operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
52 return __is_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj);52 return __is_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
53 }53 }
5454
55 template <random_access_range _Range, class _Proj = identity,55 template <random_access_range _Range, class _Proj = identity,
56 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>56 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
57 _LIBCPP_HIDE_FROM_ABI constexpr57 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
58 bool operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {58 bool operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
59 return __is_heap_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);59 return __is_heap_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);
60 }60 }
...@@ -69,6 +69,6 @@ inline namespace __cpo {...@@ -69,6 +69,6 @@ inline namespace __cpo {
6969
70_LIBCPP_END_NAMESPACE_STD70_LIBCPP_END_NAMESPACE_STD
7171
72#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)72#endif // _LIBCPP_STD_VER > 17
7373
74#endif // _LIBCPP___ALGORITHM_RANGES_IS_HEAP_H74#endif // _LIBCPP___ALGORITHM_RANGES_IS_HEAP_H
lib/libcxx/include/__algorithm/ranges_is_heap_until.h+4-4
...@@ -27,7 +27,7 @@...@@ -27,7 +27,7 @@
27# pragma GCC system_header27# pragma GCC system_header
28#endif28#endif
2929
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)30#if _LIBCPP_STD_VER > 17
3131
32_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
3333
...@@ -47,14 +47,14 @@ struct __fn {...@@ -47,14 +47,14 @@ struct __fn {
4747
48 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,48 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
49 indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>49 indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
50 _LIBCPP_HIDE_FROM_ABI constexpr50 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
51 _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {51 _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
52 return __is_heap_until_fn_impl(std::move(__first), std::move(__last), __comp, __proj);52 return __is_heap_until_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
53 }53 }
5454
55 template <random_access_range _Range, class _Proj = identity,55 template <random_access_range _Range, class _Proj = identity,
56 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>56 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
57 _LIBCPP_HIDE_FROM_ABI constexpr57 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
58 borrowed_iterator_t<_Range> operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {58 borrowed_iterator_t<_Range> operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
59 return __is_heap_until_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);59 return __is_heap_until_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);
60 }60 }
...@@ -70,6 +70,6 @@ inline namespace __cpo {...@@ -70,6 +70,6 @@ inline namespace __cpo {
7070
71_LIBCPP_END_NAMESPACE_STD71_LIBCPP_END_NAMESPACE_STD
7272
73#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)73#endif // _LIBCPP_STD_VER > 17
7474
75#endif // _LIBCPP___ALGORITHM_RANGES_IS_HEAP_UNTIL_H75#endif // _LIBCPP___ALGORITHM_RANGES_IS_HEAP_UNTIL_H
lib/libcxx/include/__algorithm/ranges_is_partitioned.h+4-4
...@@ -23,7 +23,7 @@...@@ -23,7 +23,7 @@
23# pragma GCC system_header23# pragma GCC system_header
24#endif24#endif
2525
26#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)26#if _LIBCPP_STD_VER > 17
2727
28_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2929
...@@ -54,7 +54,7 @@ struct __fn {...@@ -54,7 +54,7 @@ struct __fn {
54 template <input_iterator _Iter, sentinel_for<_Iter> _Sent,54 template <input_iterator _Iter, sentinel_for<_Iter> _Sent,
55 class _Proj = identity,55 class _Proj = identity,
56 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>56 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
57 _LIBCPP_HIDE_FROM_ABI constexpr57 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
58 bool operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {58 bool operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
59 return __is_parititioned_impl(std::move(__first), std::move(__last), __pred, __proj);59 return __is_parititioned_impl(std::move(__first), std::move(__last), __pred, __proj);
60 }60 }
...@@ -62,7 +62,7 @@ struct __fn {...@@ -62,7 +62,7 @@ struct __fn {
62 template <input_range _Range,62 template <input_range _Range,
63 class _Proj = identity,63 class _Proj = identity,
64 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>64 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
65 _LIBCPP_HIDE_FROM_ABI constexpr65 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
66 bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {66 bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
67 return __is_parititioned_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);67 return __is_parititioned_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
68 }68 }
...@@ -76,6 +76,6 @@ inline namespace __cpo {...@@ -76,6 +76,6 @@ inline namespace __cpo {
7676
77_LIBCPP_END_NAMESPACE_STD77_LIBCPP_END_NAMESPACE_STD
7878
79#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)79#endif // _LIBCPP_STD_VER > 17
8080
81#endif // _LIBCPP___ALGORITHM_RANGES_IS_PARTITIONED_H81#endif // _LIBCPP___ALGORITHM_RANGES_IS_PARTITIONED_H
lib/libcxx/include/__algorithm/ranges_is_permutation.h+4-4
...@@ -25,7 +25,7 @@...@@ -25,7 +25,7 @@
25# pragma GCC system_header25# pragma GCC system_header
26#endif26#endif
2727
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)28#if _LIBCPP_STD_VER > 17
2929
30_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
3131
...@@ -49,7 +49,7 @@ struct __fn {...@@ -49,7 +49,7 @@ struct __fn {
49 class _Proj2 = identity,49 class _Proj2 = identity,
50 indirect_equivalence_relation<projected<_Iter1, _Proj1>,50 indirect_equivalence_relation<projected<_Iter1, _Proj1>,
51 projected<_Iter2, _Proj2>> _Pred = ranges::equal_to>51 projected<_Iter2, _Proj2>> _Pred = ranges::equal_to>
52 _LIBCPP_HIDE_FROM_ABI constexpr52 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
53 bool operator()(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,53 bool operator()(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2,
54 _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {54 _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
55 return __is_permutation_func_impl(55 return __is_permutation_func_impl(
...@@ -62,7 +62,7 @@ struct __fn {...@@ -62,7 +62,7 @@ struct __fn {
62 class _Proj1 = identity,62 class _Proj1 = identity,
63 class _Proj2 = identity,63 class _Proj2 = identity,
64 indirect_equivalence_relation<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>> _Pred = ranges::equal_to>64 indirect_equivalence_relation<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>> _Pred = ranges::equal_to>
65 _LIBCPP_HIDE_FROM_ABI constexpr65 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
66 bool operator()(_Range1&& __range1, _Range2&& __range2,66 bool operator()(_Range1&& __range1, _Range2&& __range2,
67 _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {67 _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
68 if constexpr (sized_range<_Range1> && sized_range<_Range2>) {68 if constexpr (sized_range<_Range1> && sized_range<_Range2>) {
...@@ -84,6 +84,6 @@ inline namespace __cpo {...@@ -84,6 +84,6 @@ inline namespace __cpo {
8484
85_LIBCPP_END_NAMESPACE_STD85_LIBCPP_END_NAMESPACE_STD
8686
87#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)87#endif // _LIBCPP_STD_VER > 17
8888
89#endif // _LIBCPP___ALGORITHM_RANGES_IS_PERMUTATION_H89#endif // _LIBCPP___ALGORITHM_RANGES_IS_PERMUTATION_H
lib/libcxx/include/__algorithm/ranges_is_sorted.h+4-4
...@@ -23,7 +23,7 @@...@@ -23,7 +23,7 @@
23# pragma GCC system_header23# pragma GCC system_header
24#endif24#endif
2525
26#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)26#if _LIBCPP_STD_VER > 17
2727
28_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2929
...@@ -33,7 +33,7 @@ struct __fn {...@@ -33,7 +33,7 @@ struct __fn {
33 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent,33 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent,
34 class _Proj = identity,34 class _Proj = identity,
35 indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>35 indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
36 _LIBCPP_HIDE_FROM_ABI constexpr36 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
37 bool operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {37 bool operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
38 return ranges::__is_sorted_until_impl(std::move(__first), __last, __comp, __proj) == __last;38 return ranges::__is_sorted_until_impl(std::move(__first), __last, __comp, __proj) == __last;
39 }39 }
...@@ -41,7 +41,7 @@ struct __fn {...@@ -41,7 +41,7 @@ struct __fn {
41 template <forward_range _Range,41 template <forward_range _Range,
42 class _Proj = identity,42 class _Proj = identity,
43 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>43 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
44 _LIBCPP_HIDE_FROM_ABI constexpr44 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
45 bool operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {45 bool operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
46 auto __last = ranges::end(__range);46 auto __last = ranges::end(__range);
47 return ranges::__is_sorted_until_impl(ranges::begin(__range), __last, __comp, __proj) == __last;47 return ranges::__is_sorted_until_impl(ranges::begin(__range), __last, __comp, __proj) == __last;
...@@ -56,6 +56,6 @@ inline namespace __cpo {...@@ -56,6 +56,6 @@ inline namespace __cpo {
5656
57_LIBCPP_END_NAMESPACE_STD57_LIBCPP_END_NAMESPACE_STD
5858
59#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)59#endif // _LIBCPP_STD_VER > 17
6060
61#endif // _LIBCPP__ALGORITHM_RANGES_IS_SORTED_H61#endif // _LIBCPP__ALGORITHM_RANGES_IS_SORTED_H
lib/libcxx/include/__algorithm/ranges_is_sorted_until.h+4-4
...@@ -24,7 +24,7 @@...@@ -24,7 +24,7 @@
24# pragma GCC system_header24# pragma GCC system_header
25#endif25#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)27#if _LIBCPP_STD_VER > 17
2828
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
...@@ -49,7 +49,7 @@ struct __fn {...@@ -49,7 +49,7 @@ struct __fn {
49 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent,49 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent,
50 class _Proj = identity,50 class _Proj = identity,
51 indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>51 indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
52 _LIBCPP_HIDE_FROM_ABI constexpr52 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
53 _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {53 _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
54 return ranges::__is_sorted_until_impl(std::move(__first), std::move(__last), __comp, __proj);54 return ranges::__is_sorted_until_impl(std::move(__first), std::move(__last), __comp, __proj);
55 }55 }
...@@ -57,7 +57,7 @@ struct __fn {...@@ -57,7 +57,7 @@ struct __fn {
57 template <forward_range _Range,57 template <forward_range _Range,
58 class _Proj = identity,58 class _Proj = identity,
59 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>59 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
60 _LIBCPP_HIDE_FROM_ABI constexpr60 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
61 borrowed_iterator_t<_Range> operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {61 borrowed_iterator_t<_Range> operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
62 return ranges::__is_sorted_until_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);62 return ranges::__is_sorted_until_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);
63 }63 }
...@@ -71,6 +71,6 @@ inline namespace __cpo {...@@ -71,6 +71,6 @@ inline namespace __cpo {
7171
72_LIBCPP_END_NAMESPACE_STD72_LIBCPP_END_NAMESPACE_STD
7373
74#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)74#endif // _LIBCPP_STD_VER > 17
7575
76#endif // _LIBCPP__ALGORITHM_RANGES_IS_SORTED_UNTIL_H76#endif // _LIBCPP__ALGORITHM_RANGES_IS_SORTED_UNTIL_H
lib/libcxx/include/__algorithm/ranges_iterator_concept.h+4-4
...@@ -12,13 +12,13 @@...@@ -12,13 +12,13 @@
12#include <__config>12#include <__config>
13#include <__iterator/concepts.h>13#include <__iterator/concepts.h>
14#include <__iterator/iterator_traits.h>14#include <__iterator/iterator_traits.h>
15#include <type_traits>15#include <__type_traits/remove_cvref.h>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header18# pragma GCC system_header
19#endif19#endif
2020
21#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)21#if _LIBCPP_STD_VER > 17
2222
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2424
...@@ -26,7 +26,7 @@ namespace ranges {...@@ -26,7 +26,7 @@ namespace ranges {
2626
27template <class _IterMaybeQualified>27template <class _IterMaybeQualified>
28consteval auto __get_iterator_concept() {28consteval auto __get_iterator_concept() {
29 using _Iter = __uncvref_t<_IterMaybeQualified>;29 using _Iter = __remove_cvref_t<_IterMaybeQualified>;
3030
31 if constexpr (contiguous_iterator<_Iter>)31 if constexpr (contiguous_iterator<_Iter>)
32 return contiguous_iterator_tag();32 return contiguous_iterator_tag();
...@@ -46,6 +46,6 @@ using __iterator_concept = decltype(__get_iterator_concept<_Iter>());...@@ -46,6 +46,6 @@ using __iterator_concept = decltype(__get_iterator_concept<_Iter>());
46} // namespace ranges46} // namespace ranges
47_LIBCPP_END_NAMESPACE_STD47_LIBCPP_END_NAMESPACE_STD
4848
49#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)49#endif // _LIBCPP_STD_VER > 17
5050
51#endif // _LIBCPP___ALGORITHM_RANGES_ITERATOR_CONCEPT_H51#endif // _LIBCPP___ALGORITHM_RANGES_ITERATOR_CONCEPT_H
lib/libcxx/include/__algorithm/ranges_lexicographical_compare.h+4-4
...@@ -23,7 +23,7 @@...@@ -23,7 +23,7 @@
23# pragma GCC system_header23# pragma GCC system_header
24#endif24#endif
2525
26#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)26#if _LIBCPP_STD_VER > 17
2727
28_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2929
...@@ -55,7 +55,7 @@ struct __fn {...@@ -55,7 +55,7 @@ struct __fn {
55 class _Proj1 = identity,55 class _Proj1 = identity,
56 class _Proj2 = identity,56 class _Proj2 = identity,
57 indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less>57 indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less>
58 _LIBCPP_HIDE_FROM_ABI constexpr58 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
59 bool operator()(_Iter1 __first1, _Sent1 __last1,59 bool operator()(_Iter1 __first1, _Sent1 __last1,
60 _Iter2 __first2, _Sent2 __last2,60 _Iter2 __first2, _Sent2 __last2,
61 _Comp __comp = {},61 _Comp __comp = {},
...@@ -74,7 +74,7 @@ struct __fn {...@@ -74,7 +74,7 @@ struct __fn {
74 class _Proj2 = identity,74 class _Proj2 = identity,
75 indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>,75 indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>,
76 projected<iterator_t<_Range2>, _Proj2>> _Comp = ranges::less>76 projected<iterator_t<_Range2>, _Proj2>> _Comp = ranges::less>
77 _LIBCPP_HIDE_FROM_ABI constexpr77 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
78 bool operator()(_Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {78 bool operator()(_Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
79 return __lexicographical_compare_impl(ranges::begin(__range1), ranges::end(__range1),79 return __lexicographical_compare_impl(ranges::begin(__range1), ranges::end(__range1),
80 ranges::begin(__range2), ranges::end(__range2),80 ranges::begin(__range2), ranges::end(__range2),
...@@ -93,6 +93,6 @@ inline namespace __cpo {...@@ -93,6 +93,6 @@ inline namespace __cpo {
9393
94_LIBCPP_END_NAMESPACE_STD94_LIBCPP_END_NAMESPACE_STD
9595
96#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)96#endif // _LIBCPP_STD_VER > 17
9797
98#endif // _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H98#endif // _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H
lib/libcxx/include/__algorithm/ranges_lower_bound.h+4-4
...@@ -27,7 +27,7 @@...@@ -27,7 +27,7 @@
27# pragma GCC system_header27# pragma GCC system_header
28#endif28#endif
2929
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)30#if _LIBCPP_STD_VER > 17
3131
32_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
3333
...@@ -37,14 +37,14 @@ namespace __lower_bound {...@@ -37,14 +37,14 @@ namespace __lower_bound {
37struct __fn {37struct __fn {
38 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity,38 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity,
39 indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less>39 indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less>
40 _LIBCPP_HIDE_FROM_ABI constexpr40 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
41 _Iter operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {41 _Iter operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
42 return std::__lower_bound_impl<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj);42 return std::__lower_bound_impl<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj);
43 }43 }
4444
45 template <forward_range _Range, class _Type, class _Proj = identity,45 template <forward_range _Range, class _Type, class _Proj = identity,
46 indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>46 indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
47 _LIBCPP_HIDE_FROM_ABI constexpr47 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
48 borrowed_iterator_t<_Range> operator()(_Range&& __r,48 borrowed_iterator_t<_Range> operator()(_Range&& __r,
49 const _Type& __value,49 const _Type& __value,
50 _Comp __comp = {},50 _Comp __comp = {},
...@@ -61,6 +61,6 @@ inline namespace __cpo {...@@ -61,6 +61,6 @@ inline namespace __cpo {
6161
62_LIBCPP_END_NAMESPACE_STD62_LIBCPP_END_NAMESPACE_STD
6363
64#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)64#endif // _LIBCPP_STD_VER > 17
6565
66#endif // _LIBCPP___ALGORITHM_RANGES_LOWER_BOUND_H66#endif // _LIBCPP___ALGORITHM_RANGES_LOWER_BOUND_H
lib/libcxx/include/__algorithm/ranges_make_heap.h+2-2
...@@ -32,7 +32,7 @@...@@ -32,7 +32,7 @@
32# pragma GCC system_header32# pragma GCC system_header
33#endif33#endif
3434
35#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)35#if _LIBCPP_STD_VER > 17
3636
37_LIBCPP_BEGIN_NAMESPACE_STD37_LIBCPP_BEGIN_NAMESPACE_STD
3838
...@@ -75,6 +75,6 @@ inline namespace __cpo {...@@ -75,6 +75,6 @@ inline namespace __cpo {
7575
76_LIBCPP_END_NAMESPACE_STD76_LIBCPP_END_NAMESPACE_STD
7777
78#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)78#endif // _LIBCPP_STD_VER > 17
7979
80#endif // _LIBCPP___ALGORITHM_RANGES_MAKE_HEAP_H80#endif // _LIBCPP___ALGORITHM_RANGES_MAKE_HEAP_H
lib/libcxx/include/__algorithm/ranges_max.h+5-5
...@@ -27,7 +27,7 @@...@@ -27,7 +27,7 @@
27# pragma GCC system_header27# pragma GCC system_header
28#endif28#endif
2929
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)30#if _LIBCPP_STD_VER > 17
3131
32_LIBCPP_PUSH_MACROS32_LIBCPP_PUSH_MACROS
33#include <__undef_macros>33#include <__undef_macros>
...@@ -39,14 +39,14 @@ namespace __max {...@@ -39,14 +39,14 @@ namespace __max {
39struct __fn {39struct __fn {
40 template <class _Tp, class _Proj = identity,40 template <class _Tp, class _Proj = identity,
41 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>41 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
42 _LIBCPP_HIDE_FROM_ABI constexpr42 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
43 const _Tp& operator()(const _Tp& __a, const _Tp& __b, _Comp __comp = {}, _Proj __proj = {}) const {43 const _Tp& operator()(const _Tp& __a, const _Tp& __b, _Comp __comp = {}, _Proj __proj = {}) const {
44 return std::invoke(__comp, std::invoke(__proj, __a), std::invoke(__proj, __b)) ? __b : __a;44 return std::invoke(__comp, std::invoke(__proj, __a), std::invoke(__proj, __b)) ? __b : __a;
45 }45 }
4646
47 template <copyable _Tp, class _Proj = identity,47 template <copyable _Tp, class _Proj = identity,
48 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>48 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
49 _LIBCPP_HIDE_FROM_ABI constexpr49 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
50 _Tp operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const {50 _Tp operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const {
51 _LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list must contain at least one element");51 _LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list must contain at least one element");
5252
...@@ -57,7 +57,7 @@ struct __fn {...@@ -57,7 +57,7 @@ struct __fn {
57 template <input_range _Rp, class _Proj = identity,57 template <input_range _Rp, class _Proj = identity,
58 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>58 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
59 requires indirectly_copyable_storable<iterator_t<_Rp>, range_value_t<_Rp>*>59 requires indirectly_copyable_storable<iterator_t<_Rp>, range_value_t<_Rp>*>
60 _LIBCPP_HIDE_FROM_ABI constexpr60 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
61 range_value_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {61 range_value_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
62 auto __first = ranges::begin(__r);62 auto __first = ranges::begin(__r);
63 auto __last = ranges::end(__r);63 auto __last = ranges::end(__r);
...@@ -88,6 +88,6 @@ _LIBCPP_END_NAMESPACE_STD...@@ -88,6 +88,6 @@ _LIBCPP_END_NAMESPACE_STD
8888
89_LIBCPP_POP_MACROS89_LIBCPP_POP_MACROS
9090
91#endif // _LIBCPP_STD_VER > 17 && && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)91#endif // _LIBCPP_STD_VER > 17 &&
9292
93#endif // _LIBCPP___ALGORITHM_RANGES_MAX_H93#endif // _LIBCPP___ALGORITHM_RANGES_MAX_H
lib/libcxx/include/__algorithm/ranges_max_element.h+4-4
...@@ -24,7 +24,7 @@...@@ -24,7 +24,7 @@
24# pragma GCC system_header24# pragma GCC system_header
25#endif25#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)27#if _LIBCPP_STD_VER > 17
2828
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
...@@ -33,7 +33,7 @@ namespace __max_element {...@@ -33,7 +33,7 @@ namespace __max_element {
33struct __fn {33struct __fn {
34 template <forward_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,34 template <forward_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
35 indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less>35 indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less>
36 _LIBCPP_HIDE_FROM_ABI constexpr36 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
37 _Ip operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {37 _Ip operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
38 auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); };38 auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); };
39 return ranges::__min_element_impl(__first, __last, __comp_lhs_rhs_swapped, __proj);39 return ranges::__min_element_impl(__first, __last, __comp_lhs_rhs_swapped, __proj);
...@@ -41,7 +41,7 @@ struct __fn {...@@ -41,7 +41,7 @@ struct __fn {
4141
42 template <forward_range _Rp, class _Proj = identity,42 template <forward_range _Rp, class _Proj = identity,
43 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>43 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
44 _LIBCPP_HIDE_FROM_ABI constexpr44 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
45 borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {45 borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
46 auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); };46 auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); };
47 return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp_lhs_rhs_swapped, __proj);47 return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp_lhs_rhs_swapped, __proj);
...@@ -56,6 +56,6 @@ inline namespace __cpo {...@@ -56,6 +56,6 @@ inline namespace __cpo {
5656
57_LIBCPP_END_NAMESPACE_STD57_LIBCPP_END_NAMESPACE_STD
5858
59#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)59#endif // _LIBCPP_STD_VER > 17
6060
61#endif // _LIBCPP___ALGORITHM_RANGES_MAX_ELEMENT_H61#endif // _LIBCPP___ALGORITHM_RANGES_MAX_ELEMENT_H
lib/libcxx/include/__algorithm/ranges_merge.h+4-4
...@@ -27,7 +27,7 @@...@@ -27,7 +27,7 @@
27# pragma GCC system_header27# pragma GCC system_header
28#endif28#endif
2929
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)30#if _LIBCPP_STD_VER > 17
3131
32_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
3333
...@@ -47,7 +47,7 @@ template <...@@ -47,7 +47,7 @@ template <
47 class _Comp,47 class _Comp,
48 class _Proj1,48 class _Proj1,
49 class _Proj2>49 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>>
51__merge_impl(51__merge_impl(
52 _InIter1&& __first1,52 _InIter1&& __first1,
53 _Sent1&& __last1,53 _Sent1&& __last1,
...@@ -107,7 +107,7 @@ struct __fn {...@@ -107,7 +107,7 @@ struct __fn {
107 _OutIter,107 _OutIter,
108 _Comp,108 _Comp,
109 _Proj1,109 _Proj1,
110 _Proj2> 110 _Proj2>
111 _LIBCPP_HIDE_FROM_ABI constexpr merge_result<borrowed_iterator_t<_Range1>, borrowed_iterator_t<_Range2>, _OutIter>111 _LIBCPP_HIDE_FROM_ABI constexpr merge_result<borrowed_iterator_t<_Range1>, borrowed_iterator_t<_Range2>, _OutIter>
112 operator()(112 operator()(
113 _Range1&& __range1,113 _Range1&& __range1,
...@@ -137,6 +137,6 @@ inline namespace __cpo {...@@ -137,6 +137,6 @@ inline namespace __cpo {
137137
138_LIBCPP_END_NAMESPACE_STD138_LIBCPP_END_NAMESPACE_STD
139139
140#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)140#endif // _LIBCPP_STD_VER > 17
141141
142#endif // _LIBCPP___ALGORITHM_RANGES_MERGE_H142#endif // _LIBCPP___ALGORITHM_RANGES_MERGE_H
lib/libcxx/include/__algorithm/ranges_min.h+5-5
...@@ -26,7 +26,7 @@...@@ -26,7 +26,7 @@
26# pragma GCC system_header26# pragma GCC system_header
27#endif27#endif
2828
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)29#if _LIBCPP_STD_VER > 17
3030
31_LIBCPP_PUSH_MACROS31_LIBCPP_PUSH_MACROS
32#include <__undef_macros>32#include <__undef_macros>
...@@ -38,14 +38,14 @@ namespace __min {...@@ -38,14 +38,14 @@ namespace __min {
38struct __fn {38struct __fn {
39 template <class _Tp, class _Proj = identity,39 template <class _Tp, class _Proj = identity,
40 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>40 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
41 _LIBCPP_HIDE_FROM_ABI constexpr41 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
42 const _Tp& operator()(const _Tp& __a, const _Tp& __b, _Comp __comp = {}, _Proj __proj = {}) const {42 const _Tp& operator()(const _Tp& __a, const _Tp& __b, _Comp __comp = {}, _Proj __proj = {}) const {
43 return std::invoke(__comp, std::invoke(__proj, __b), std::invoke(__proj, __a)) ? __b : __a;43 return std::invoke(__comp, std::invoke(__proj, __b), std::invoke(__proj, __a)) ? __b : __a;
44 }44 }
4545
46 template <copyable _Tp, class _Proj = identity,46 template <copyable _Tp, class _Proj = identity,
47 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>47 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
48 _LIBCPP_HIDE_FROM_ABI constexpr48 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
49 _Tp operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const {49 _Tp operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const {
50 _LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list must contain at least one element");50 _LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list must contain at least one element");
51 return *ranges::__min_element_impl(__il.begin(), __il.end(), __comp, __proj);51 return *ranges::__min_element_impl(__il.begin(), __il.end(), __comp, __proj);
...@@ -54,7 +54,7 @@ struct __fn {...@@ -54,7 +54,7 @@ struct __fn {
54 template <input_range _Rp, class _Proj = identity,54 template <input_range _Rp, class _Proj = identity,
55 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>55 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
56 requires indirectly_copyable_storable<iterator_t<_Rp>, range_value_t<_Rp>*>56 requires indirectly_copyable_storable<iterator_t<_Rp>, range_value_t<_Rp>*>
57 _LIBCPP_HIDE_FROM_ABI constexpr57 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
58 range_value_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {58 range_value_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
59 auto __first = ranges::begin(__r);59 auto __first = ranges::begin(__r);
60 auto __last = ranges::end(__r);60 auto __last = ranges::end(__r);
...@@ -84,6 +84,6 @@ _LIBCPP_END_NAMESPACE_STD...@@ -84,6 +84,6 @@ _LIBCPP_END_NAMESPACE_STD
8484
85_LIBCPP_POP_MACROS85_LIBCPP_POP_MACROS
8686
87#endif // _LIBCPP_STD_VER > 17 && && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)87#endif // _LIBCPP_STD_VER > 17 &&
8888
89#endif // _LIBCPP___ALGORITHM_RANGES_MIN_H89#endif // _LIBCPP___ALGORITHM_RANGES_MIN_H
lib/libcxx/include/__algorithm/ranges_min_element.h+4-4
...@@ -24,7 +24,7 @@...@@ -24,7 +24,7 @@
24# pragma GCC system_header24# pragma GCC system_header
25#endif25#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)27#if _LIBCPP_STD_VER > 17
2828
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
...@@ -48,14 +48,14 @@ namespace __min_element {...@@ -48,14 +48,14 @@ namespace __min_element {
48struct __fn {48struct __fn {
49 template <forward_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,49 template <forward_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
50 indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less>50 indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less>
51 _LIBCPP_HIDE_FROM_ABI constexpr51 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
52 _Ip operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {52 _Ip operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
53 return ranges::__min_element_impl(__first, __last, __comp, __proj);53 return ranges::__min_element_impl(__first, __last, __comp, __proj);
54 }54 }
5555
56 template <forward_range _Rp, class _Proj = identity,56 template <forward_range _Rp, class _Proj = identity,
57 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>57 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
58 _LIBCPP_HIDE_FROM_ABI constexpr58 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
59 borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {59 borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
60 return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);60 return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
61 }61 }
...@@ -69,6 +69,6 @@ inline namespace __cpo {...@@ -69,6 +69,6 @@ inline namespace __cpo {
6969
70_LIBCPP_END_NAMESPACE_STD70_LIBCPP_END_NAMESPACE_STD
7171
72#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)72#endif // _LIBCPP_STD_VER > 17
7373
74#endif // _LIBCPP___ALGORITHM_RANGES_MIN_ELEMENT_H74#endif // _LIBCPP___ALGORITHM_RANGES_MIN_ELEMENT_H
lib/libcxx/include/__algorithm/ranges_minmax.h+6-5
...@@ -23,13 +23,14 @@...@@ -23,13 +23,14 @@
23#include <__ranges/concepts.h>23#include <__ranges/concepts.h>
24#include <__utility/forward.h>24#include <__utility/forward.h>
25#include <__utility/move.h>25#include <__utility/move.h>
26#include <__utility/pair.h>
26#include <initializer_list>27#include <initializer_list>
2728
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29# pragma GCC system_header30# pragma GCC system_header
30#endif31#endif
3132
32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)33#if _LIBCPP_STD_VER > 17
3334
34_LIBCPP_PUSH_MACROS35_LIBCPP_PUSH_MACROS
35#include <__undef_macros>36#include <__undef_macros>
...@@ -44,7 +45,7 @@ namespace __minmax {...@@ -44,7 +45,7 @@ namespace __minmax {
44struct __fn {45struct __fn {
45 template <class _Type, class _Proj = identity,46 template <class _Type, class _Proj = identity,
46 indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>47 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&>
48 operator()(const _Type& __a, const _Type& __b, _Comp __comp = {}, _Proj __proj = {}) const {49 operator()(const _Type& __a, const _Type& __b, _Comp __comp = {}, _Proj __proj = {}) const {
49 if (std::invoke(__comp, std::invoke(__proj, __b), std::invoke(__proj, __a)))50 if (std::invoke(__comp, std::invoke(__proj, __b), std::invoke(__proj, __a)))
50 return {__b, __a};51 return {__b, __a};
...@@ -53,7 +54,7 @@ struct __fn {...@@ -53,7 +54,7 @@ struct __fn {
5354
54 template <copyable _Type, class _Proj = identity,55 template <copyable _Type, class _Proj = identity,
55 indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>56 indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>
56 _LIBCPP_HIDE_FROM_ABI constexpr57 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
57 ranges::minmax_result<_Type> operator()(initializer_list<_Type> __il, _Comp __comp = {}, _Proj __proj = {}) const {58 ranges::minmax_result<_Type> operator()(initializer_list<_Type> __il, _Comp __comp = {}, _Proj __proj = {}) const {
58 _LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list has to contain at least one element");59 _LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list has to contain at least one element");
59 auto __iters = std::__minmax_element_impl(__il.begin(), __il.end(), __comp, __proj);60 auto __iters = std::__minmax_element_impl(__il.begin(), __il.end(), __comp, __proj);
...@@ -63,7 +64,7 @@ struct __fn {...@@ -63,7 +64,7 @@ struct __fn {
63 template <input_range _Range, class _Proj = identity,64 template <input_range _Range, class _Proj = identity,
64 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>65 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
65 requires indirectly_copyable_storable<iterator_t<_Range>, range_value_t<_Range>*>66 requires indirectly_copyable_storable<iterator_t<_Range>, range_value_t<_Range>*>
66 _LIBCPP_HIDE_FROM_ABI constexpr67 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
67 ranges::minmax_result<range_value_t<_Range>> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {68 ranges::minmax_result<range_value_t<_Range>> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
68 auto __first = ranges::begin(__r);69 auto __first = ranges::begin(__r);
69 auto __last = ranges::end(__r);70 auto __last = ranges::end(__r);
...@@ -128,6 +129,6 @@ _LIBCPP_END_NAMESPACE_STD...@@ -128,6 +129,6 @@ _LIBCPP_END_NAMESPACE_STD
128129
129_LIBCPP_POP_MACROS130_LIBCPP_POP_MACROS
130131
131#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)132#endif // _LIBCPP_STD_VER > 17
132133
133#endif // _LIBCPP___ALGORITHM_RANGES_MINMAX_H134#endif // _LIBCPP___ALGORITHM_RANGES_MINMAX_H
lib/libcxx/include/__algorithm/ranges_minmax_element.h+4-4
...@@ -29,7 +29,7 @@...@@ -29,7 +29,7 @@
29# pragma GCC system_header29# pragma GCC system_header
30#endif30#endif
3131
32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)32#if _LIBCPP_STD_VER > 17
3333
34_LIBCPP_BEGIN_NAMESPACE_STD34_LIBCPP_BEGIN_NAMESPACE_STD
3535
...@@ -42,7 +42,7 @@ namespace __minmax_element {...@@ -42,7 +42,7 @@ namespace __minmax_element {
42struct __fn {42struct __fn {
43 template <forward_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,43 template <forward_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
44 indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less>44 indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less>
45 _LIBCPP_HIDE_FROM_ABI constexpr45 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
46 ranges::minmax_element_result<_Ip> operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {46 ranges::minmax_element_result<_Ip> operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
47 auto __ret = std::__minmax_element_impl(std::move(__first), std::move(__last), __comp, __proj);47 auto __ret = std::__minmax_element_impl(std::move(__first), std::move(__last), __comp, __proj);
48 return {__ret.first, __ret.second};48 return {__ret.first, __ret.second};
...@@ -50,7 +50,7 @@ struct __fn {...@@ -50,7 +50,7 @@ struct __fn {
5050
51 template <forward_range _Rp, class _Proj = identity,51 template <forward_range _Rp, class _Proj = identity,
52 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>52 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
53 _LIBCPP_HIDE_FROM_ABI constexpr53 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
54 ranges::minmax_element_result<borrowed_iterator_t<_Rp>>54 ranges::minmax_element_result<borrowed_iterator_t<_Rp>>
55 operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {55 operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
56 auto __ret = std::__minmax_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);56 auto __ret = std::__minmax_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
...@@ -67,6 +67,6 @@ inline namespace __cpo {...@@ -67,6 +67,6 @@ inline namespace __cpo {
6767
68_LIBCPP_END_NAMESPACE_STD68_LIBCPP_END_NAMESPACE_STD
6969
70#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)70#endif // _LIBCPP_STD_VER > 17
7171
72#endif // _LIBCPP___ALGORITHM_RANGES_MINMAX_H72#endif // _LIBCPP___ALGORITHM_RANGES_MINMAX_H
lib/libcxx/include/__algorithm/ranges_mismatch.h+4-4
...@@ -27,7 +27,7 @@...@@ -27,7 +27,7 @@
2727
28_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2929
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)30#if _LIBCPP_STD_VER > 17
3131
32namespace ranges {32namespace ranges {
3333
...@@ -55,7 +55,7 @@ struct __fn {...@@ -55,7 +55,7 @@ struct __fn {
55 input_iterator _I2, sentinel_for<_I2> _S2,55 input_iterator _I2, sentinel_for<_I2> _S2,
56 class _Pred = ranges::equal_to, class _Proj1 = identity, class _Proj2 = identity>56 class _Pred = ranges::equal_to, class _Proj1 = identity, class _Proj2 = identity>
57 requires indirectly_comparable<_I1, _I2, _Pred, _Proj1, _Proj2>57 requires indirectly_comparable<_I1, _I2, _Pred, _Proj1, _Proj2>
58 _LIBCPP_HIDE_FROM_ABI constexpr58 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
59 mismatch_result<_I1, _I2> operator()(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2,59 mismatch_result<_I1, _I2> operator()(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2,
60 _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {60 _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
61 return __go(std::move(__first1), __last1, std::move(__first2), __last2, __pred, __proj1, __proj2);61 return __go(std::move(__first1), __last1, std::move(__first2), __last2, __pred, __proj1, __proj2);
...@@ -64,7 +64,7 @@ struct __fn {...@@ -64,7 +64,7 @@ struct __fn {
64 template <input_range _R1, input_range _R2,64 template <input_range _R1, input_range _R2,
65 class _Pred = ranges::equal_to, class _Proj1 = identity, class _Proj2 = identity>65 class _Pred = ranges::equal_to, class _Proj1 = identity, class _Proj2 = identity>
66 requires indirectly_comparable<iterator_t<_R1>, iterator_t<_R2>, _Pred, _Proj1, _Proj2>66 requires indirectly_comparable<iterator_t<_R1>, iterator_t<_R2>, _Pred, _Proj1, _Proj2>
67 _LIBCPP_HIDE_FROM_ABI constexpr67 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
68 mismatch_result<borrowed_iterator_t<_R1>, borrowed_iterator_t<_R2>>68 mismatch_result<borrowed_iterator_t<_R1>, borrowed_iterator_t<_R2>>
69 operator()(_R1&& __r1, _R2&& __r2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {69 operator()(_R1&& __r1, _R2&& __r2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
70 return __go(ranges::begin(__r1), ranges::end(__r1), ranges::begin(__r2), ranges::end(__r2),70 return __go(ranges::begin(__r1), ranges::end(__r1), ranges::begin(__r2), ranges::end(__r2),
...@@ -78,7 +78,7 @@ inline namespace __cpo {...@@ -78,7 +78,7 @@ inline namespace __cpo {
78} // namespace __cpo78} // namespace __cpo
79} // namespace ranges79} // namespace ranges
8080
81#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)81#endif // _LIBCPP_STD_VER > 17
8282
83_LIBCPP_END_NAMESPACE_STD83_LIBCPP_END_NAMESPACE_STD
8484
lib/libcxx/include/__algorithm/ranges_move.h+2-3
...@@ -14,7 +14,6 @@...@@ -14,7 +14,6 @@
14#include <__algorithm/move.h>14#include <__algorithm/move.h>
15#include <__config>15#include <__config>
16#include <__iterator/concepts.h>16#include <__iterator/concepts.h>
17#include <__iterator/iter_move.h>
18#include <__ranges/access.h>17#include <__ranges/access.h>
19#include <__ranges/concepts.h>18#include <__ranges/concepts.h>
20#include <__ranges/dangling.h>19#include <__ranges/dangling.h>
...@@ -24,7 +23,7 @@...@@ -24,7 +23,7 @@
24# pragma GCC system_header23# pragma GCC system_header
25#endif24#endif
2625
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)26#if _LIBCPP_STD_VER > 17
2827
29_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
3029
...@@ -67,6 +66,6 @@ inline namespace __cpo {...@@ -67,6 +66,6 @@ inline namespace __cpo {
6766
68_LIBCPP_END_NAMESPACE_STD67_LIBCPP_END_NAMESPACE_STD
6968
70#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)69#endif // _LIBCPP_STD_VER > 17
7170
72#endif // _LIBCPP___ALGORITHM_RANGES_MOVE_H71#endif // _LIBCPP___ALGORITHM_RANGES_MOVE_H
lib/libcxx/include/__algorithm/ranges_move_backward.h+6-9
...@@ -10,12 +10,12 @@...@@ -10,12 +10,12 @@
10#define _LIBCPP___ALGORITHM_RANGES_MOVE_BACKWARD_H10#define _LIBCPP___ALGORITHM_RANGES_MOVE_BACKWARD_H
1111
12#include <__algorithm/in_out_result.h>12#include <__algorithm/in_out_result.h>
13#include <__algorithm/ranges_move.h>13#include <__algorithm/iterator_operations.h>
14#include <__algorithm/move_backward.h>
14#include <__config>15#include <__config>
15#include <__iterator/concepts.h>16#include <__iterator/concepts.h>
16#include <__iterator/iter_move.h>17#include <__iterator/iter_move.h>
17#include <__iterator/next.h>18#include <__iterator/next.h>
18#include <__iterator/reverse_iterator.h>
19#include <__ranges/access.h>19#include <__ranges/access.h>
20#include <__ranges/concepts.h>20#include <__ranges/concepts.h>
21#include <__ranges/dangling.h>21#include <__ranges/dangling.h>
...@@ -25,7 +25,7 @@...@@ -25,7 +25,7 @@
25# pragma GCC system_header25# pragma GCC system_header
26#endif26#endif
2727
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)28#if _LIBCPP_STD_VER > 17
2929
30_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
3131
...@@ -40,11 +40,8 @@ struct __fn {...@@ -40,11 +40,8 @@ struct __fn {
40 template <class _InIter, class _Sent, class _OutIter>40 template <class _InIter, class _Sent, class _OutIter>
41 _LIBCPP_HIDE_FROM_ABI constexpr static41 _LIBCPP_HIDE_FROM_ABI constexpr static
42 move_backward_result<_InIter, _OutIter> __move_backward_impl(_InIter __first, _Sent __last, _OutIter __result) {42 move_backward_result<_InIter, _OutIter> __move_backward_impl(_InIter __first, _Sent __last, _OutIter __result) {
43 auto __last_iter = ranges::next(__first, std::move(__last));43 auto __ret = std::__move_backward<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__result));
44 auto __ret = ranges::move(std::make_reverse_iterator(__last_iter),44 return {std::move(__ret.first), std::move(__ret.second)};
45 std::make_reverse_iterator(__first),
46 std::make_reverse_iterator(__result));
47 return {std::move(__last_iter), std::move(__ret.out.base())};
48 }45 }
4946
50 template <bidirectional_iterator _InIter, sentinel_for<_InIter> _Sent, bidirectional_iterator _OutIter>47 template <bidirectional_iterator _InIter, sentinel_for<_InIter> _Sent, bidirectional_iterator _OutIter>
...@@ -71,6 +68,6 @@ inline namespace __cpo {...@@ -71,6 +68,6 @@ inline namespace __cpo {
7168
72_LIBCPP_END_NAMESPACE_STD69_LIBCPP_END_NAMESPACE_STD
7370
74#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)71#endif // _LIBCPP_STD_VER > 17
7572
76#endif // _LIBCPP___ALGORITHM_RANGES_MOVE_BACKWARD_H73#endif // _LIBCPP___ALGORITHM_RANGES_MOVE_BACKWARD_H
lib/libcxx/include/__algorithm/ranges_next_permutation.h+3-2
...@@ -22,12 +22,13 @@...@@ -22,12 +22,13 @@
22#include <__ranges/concepts.h>22#include <__ranges/concepts.h>
23#include <__ranges/dangling.h>23#include <__ranges/dangling.h>
24#include <__utility/move.h>24#include <__utility/move.h>
25#include <__utility/pair.h>
2526
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header28# pragma GCC system_header
28#endif29#endif
2930
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)31#if _LIBCPP_STD_VER > 17
3132
32_LIBCPP_BEGIN_NAMESPACE_STD33_LIBCPP_BEGIN_NAMESPACE_STD
3334
...@@ -67,6 +68,6 @@ constexpr inline auto next_permutation = __next_permutation::__fn{};...@@ -67,6 +68,6 @@ constexpr inline auto next_permutation = __next_permutation::__fn{};
6768
68_LIBCPP_END_NAMESPACE_STD69_LIBCPP_END_NAMESPACE_STD
6970
70#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)71#endif // _LIBCPP_STD_VER > 17
7172
72#endif // _LIBCPP___ALGORITHM_RANGES_NEXT_PERMUTATION_H73#endif // _LIBCPP___ALGORITHM_RANGES_NEXT_PERMUTATION_H
lib/libcxx/include/__algorithm/ranges_none_of.h+4-4
...@@ -22,7 +22,7 @@...@@ -22,7 +22,7 @@
22# pragma GCC system_header22# pragma GCC system_header
23#endif23#endif
2424
25#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)25#if _LIBCPP_STD_VER > 17
2626
27_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2828
...@@ -42,14 +42,14 @@ struct __fn {...@@ -42,14 +42,14 @@ struct __fn {
4242
43 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,43 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity,
44 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>44 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
45 _LIBCPP_HIDE_FROM_ABI constexpr45 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
46 bool operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {46 bool operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {
47 return __none_of_impl(std::move(__first), std::move(__last), __pred, __proj);47 return __none_of_impl(std::move(__first), std::move(__last), __pred, __proj);
48 }48 }
4949
50 template <input_range _Range, class _Proj = identity,50 template <input_range _Range, class _Proj = identity,
51 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>51 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
52 _LIBCPP_HIDE_FROM_ABI constexpr52 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
53 bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {53 bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
54 return __none_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);54 return __none_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
55 }55 }
...@@ -63,6 +63,6 @@ inline namespace __cpo {...@@ -63,6 +63,6 @@ inline namespace __cpo {
6363
64_LIBCPP_END_NAMESPACE_STD64_LIBCPP_END_NAMESPACE_STD
6565
66#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)66#endif // _LIBCPP_STD_VER > 17
6767
68#endif // _LIBCPP___ALGORITHM_RANGES_NONE_OF_H68#endif // _LIBCPP___ALGORITHM_RANGES_NONE_OF_H
lib/libcxx/include/__algorithm/ranges_nth_element.h+2-2
...@@ -31,7 +31,7 @@...@@ -31,7 +31,7 @@
31# pragma GCC system_header31# pragma GCC system_header
32#endif32#endif
3333
34#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)34#if _LIBCPP_STD_VER > 17
3535
36_LIBCPP_BEGIN_NAMESPACE_STD36_LIBCPP_BEGIN_NAMESPACE_STD
3737
...@@ -75,6 +75,6 @@ inline namespace __cpo {...@@ -75,6 +75,6 @@ inline namespace __cpo {
7575
76_LIBCPP_END_NAMESPACE_STD76_LIBCPP_END_NAMESPACE_STD
7777
78#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)78#endif // _LIBCPP_STD_VER > 17
7979
80#endif // _LIBCPP___ALGORITHM_RANGES_NTH_ELEMENT_H80#endif // _LIBCPP___ALGORITHM_RANGES_NTH_ELEMENT_H
lib/libcxx/include/__algorithm/ranges_partial_sort.h+3-2
...@@ -27,12 +27,13 @@...@@ -27,12 +27,13 @@
27#include <__ranges/dangling.h>27#include <__ranges/dangling.h>
28#include <__utility/forward.h>28#include <__utility/forward.h>
29#include <__utility/move.h>29#include <__utility/move.h>
30#include <__utility/pair.h>
3031
31#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)32#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
32# pragma GCC system_header33# pragma GCC system_header
33#endif34#endif
3435
35#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)36#if _LIBCPP_STD_VER > 17
3637
37_LIBCPP_BEGIN_NAMESPACE_STD38_LIBCPP_BEGIN_NAMESPACE_STD
3839
...@@ -72,6 +73,6 @@ inline namespace __cpo {...@@ -72,6 +73,6 @@ inline namespace __cpo {
7273
73_LIBCPP_END_NAMESPACE_STD74_LIBCPP_END_NAMESPACE_STD
7475
75#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)76#endif // _LIBCPP_STD_VER > 17
7677
77#endif // _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_H78#endif // _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_H
lib/libcxx/include/__algorithm/ranges_partial_sort_copy.h+3-2
...@@ -24,12 +24,13 @@...@@ -24,12 +24,13 @@
24#include <__ranges/concepts.h>24#include <__ranges/concepts.h>
25#include <__ranges/dangling.h>25#include <__ranges/dangling.h>
26#include <__utility/move.h>26#include <__utility/move.h>
27#include <__utility/pair.h>
2728
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29# pragma GCC system_header30# pragma GCC system_header
30#endif31#endif
3132
32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)33#if _LIBCPP_STD_VER > 17
3334
34_LIBCPP_BEGIN_NAMESPACE_STD35_LIBCPP_BEGIN_NAMESPACE_STD
3536
...@@ -86,6 +87,6 @@ inline namespace __cpo {...@@ -86,6 +87,6 @@ inline namespace __cpo {
8687
87_LIBCPP_END_NAMESPACE_STD88_LIBCPP_END_NAMESPACE_STD
8889
89#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)90#endif // _LIBCPP_STD_VER > 17
9091
91#endif // _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_COPY_H92#endif // _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_COPY_H
lib/libcxx/include/__algorithm/ranges_partition.h+4-3
...@@ -26,13 +26,14 @@...@@ -26,13 +26,14 @@
26#include <__ranges/subrange.h>26#include <__ranges/subrange.h>
27#include <__utility/forward.h>27#include <__utility/forward.h>
28#include <__utility/move.h>28#include <__utility/move.h>
29#include <__utility/pair.h>
29#include <type_traits>30#include <type_traits>
3031
31#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)32#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
32# pragma GCC system_header33# pragma GCC system_header
33#endif34#endif
3435
35#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)36#if _LIBCPP_STD_VER > 17
3637
37_LIBCPP_BEGIN_NAMESPACE_STD38_LIBCPP_BEGIN_NAMESPACE_STD
3839
...@@ -43,7 +44,7 @@ struct __fn {...@@ -43,7 +44,7 @@ struct __fn {
4344
44 template <class _Iter, class _Sent, class _Proj, class _Pred>45 template <class _Iter, class _Sent, class _Proj, class _Pred>
45 _LIBCPP_HIDE_FROM_ABI static constexpr46 _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) {
47 auto&& __projected_pred = std::__make_projected(__pred, __proj);48 auto&& __projected_pred = std::__make_projected(__pred, __proj);
48 auto __result = std::__partition<_RangeAlgPolicy>(49 auto __result = std::__partition<_RangeAlgPolicy>(
49 std::move(__first), std::move(__last), __projected_pred, __iterator_concept<_Iter>());50 std::move(__first), std::move(__last), __projected_pred, __iterator_concept<_Iter>());
...@@ -77,6 +78,6 @@ inline namespace __cpo {...@@ -77,6 +78,6 @@ inline namespace __cpo {
7778
78_LIBCPP_END_NAMESPACE_STD79_LIBCPP_END_NAMESPACE_STD
7980
80#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)81#endif // _LIBCPP_STD_VER > 17
8182
82#endif // _LIBCPP___ALGORITHM_RANGES_PARTITION_H83#endif // _LIBCPP___ALGORITHM_RANGES_PARTITION_H
lib/libcxx/include/__algorithm/ranges_partition_copy.h+3-3
...@@ -26,7 +26,7 @@...@@ -26,7 +26,7 @@
26# pragma GCC system_header26# pragma GCC system_header
27#endif27#endif
2828
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)29#if _LIBCPP_STD_VER > 17
3030
31_LIBCPP_BEGIN_NAMESPACE_STD31_LIBCPP_BEGIN_NAMESPACE_STD
3232
...@@ -43,7 +43,7 @@ struct __fn {...@@ -43,7 +43,7 @@ struct __fn {
43 template <class _InIter, class _Sent, class _OutIter1, class _OutIter2, class _Proj, class _Pred>43 template <class _InIter, class _Sent, class _OutIter1, class _OutIter2, class _Proj, class _Pred>
44 _LIBCPP_HIDE_FROM_ABI constexpr44 _LIBCPP_HIDE_FROM_ABI constexpr
45 static partition_copy_result<45 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>
47 > __partition_copy_fn_impl( _InIter&& __first, _Sent&& __last, _OutIter1&& __out_true, _OutIter2&& __out_false,47 > __partition_copy_fn_impl( _InIter&& __first, _Sent&& __last, _OutIter1&& __out_true, _OutIter2&& __out_false,
48 _Pred& __pred, _Proj& __proj) {48 _Pred& __pred, _Proj& __proj) {
49 for (; __first != __last; ++__first) {49 for (; __first != __last; ++__first) {
...@@ -93,6 +93,6 @@ inline namespace __cpo {...@@ -93,6 +93,6 @@ inline namespace __cpo {
9393
94_LIBCPP_END_NAMESPACE_STD94_LIBCPP_END_NAMESPACE_STD
9595
96#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)96#endif // _LIBCPP_STD_VER > 17
9797
98#endif // _LIBCPP___ALGORITHM_RANGES_PARTITION_COPY_H98#endif // _LIBCPP___ALGORITHM_RANGES_PARTITION_COPY_H
lib/libcxx/include/__algorithm/ranges_partition_point.h+2-2
...@@ -27,7 +27,7 @@...@@ -27,7 +27,7 @@
27# pragma GCC system_header27# pragma GCC system_header
28#endif28#endif
2929
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)30#if _LIBCPP_STD_VER > 17
3131
32_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
3333
...@@ -83,6 +83,6 @@ inline namespace __cpo {...@@ -83,6 +83,6 @@ inline namespace __cpo {
8383
84_LIBCPP_END_NAMESPACE_STD84_LIBCPP_END_NAMESPACE_STD
8585
86#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)86#endif // _LIBCPP_STD_VER > 17
8787
88#endif // _LIBCPP___ALGORITHM_RANGES_PARTITION_POINT_H88#endif // _LIBCPP___ALGORITHM_RANGES_PARTITION_POINT_H
lib/libcxx/include/__algorithm/ranges_pop_heap.h+2-2
...@@ -32,7 +32,7 @@...@@ -32,7 +32,7 @@
32# pragma GCC system_header32# pragma GCC system_header
33#endif33#endif
3434
35#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)35#if _LIBCPP_STD_VER > 17
3636
37_LIBCPP_BEGIN_NAMESPACE_STD37_LIBCPP_BEGIN_NAMESPACE_STD
3838
...@@ -76,6 +76,6 @@ inline namespace __cpo {...@@ -76,6 +76,6 @@ inline namespace __cpo {
7676
77_LIBCPP_END_NAMESPACE_STD77_LIBCPP_END_NAMESPACE_STD
7878
79#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)79#endif // _LIBCPP_STD_VER > 17
8080
81#endif // _LIBCPP___ALGORITHM_RANGES_POP_HEAP_H81#endif // _LIBCPP___ALGORITHM_RANGES_POP_HEAP_H
lib/libcxx/include/__algorithm/ranges_prev_permutation.h+3-2
...@@ -22,12 +22,13 @@...@@ -22,12 +22,13 @@
22#include <__ranges/concepts.h>22#include <__ranges/concepts.h>
23#include <__ranges/dangling.h>23#include <__ranges/dangling.h>
24#include <__utility/move.h>24#include <__utility/move.h>
25#include <__utility/pair.h>
2526
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header28# pragma GCC system_header
28#endif29#endif
2930
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)31#if _LIBCPP_STD_VER > 17
3132
32_LIBCPP_BEGIN_NAMESPACE_STD33_LIBCPP_BEGIN_NAMESPACE_STD
3334
...@@ -71,6 +72,6 @@ constexpr inline auto prev_permutation = __prev_permutation::__fn{};...@@ -71,6 +72,6 @@ constexpr inline auto prev_permutation = __prev_permutation::__fn{};
7172
72_LIBCPP_END_NAMESPACE_STD73_LIBCPP_END_NAMESPACE_STD
7374
74#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)75#endif // _LIBCPP_STD_VER > 17
7576
76#endif // _LIBCPP___ALGORITHM_RANGES_PREV_PERMUTATION_H77#endif // _LIBCPP___ALGORITHM_RANGES_PREV_PERMUTATION_H
lib/libcxx/include/__algorithm/ranges_push_heap.h+2-2
...@@ -32,7 +32,7 @@...@@ -32,7 +32,7 @@
32# pragma GCC system_header32# pragma GCC system_header
33#endif33#endif
3434
35#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)35#if _LIBCPP_STD_VER > 17
3636
37_LIBCPP_BEGIN_NAMESPACE_STD37_LIBCPP_BEGIN_NAMESPACE_STD
3838
...@@ -75,6 +75,6 @@ inline namespace __cpo {...@@ -75,6 +75,6 @@ inline namespace __cpo {
7575
76_LIBCPP_END_NAMESPACE_STD76_LIBCPP_END_NAMESPACE_STD
7777
78#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)78#endif // _LIBCPP_STD_VER > 17
7979
80#endif // _LIBCPP___ALGORITHM_RANGES_PUSH_HEAP_H80#endif // _LIBCPP___ALGORITHM_RANGES_PUSH_HEAP_H
lib/libcxx/include/__algorithm/ranges_remove.h+4-4
...@@ -25,7 +25,7 @@...@@ -25,7 +25,7 @@
25# pragma GCC system_header25# pragma GCC system_header
26#endif26#endif
2727
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)28#if _LIBCPP_STD_VER > 17
2929
30_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
3131
...@@ -35,7 +35,7 @@ struct __fn {...@@ -35,7 +35,7 @@ struct __fn {
3535
36 template <permutable _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>36 template <permutable _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>
37 requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>37 requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>
38 _LIBCPP_HIDE_FROM_ABI constexpr38 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
39 subrange<_Iter> operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const {39 subrange<_Iter> operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const {
40 auto __pred = [&](auto&& __other) { return __value == __other; };40 auto __pred = [&](auto&& __other) { return __value == __other; };
41 return ranges::__remove_if_impl(std::move(__first), std::move(__last), __pred, __proj);41 return ranges::__remove_if_impl(std::move(__first), std::move(__last), __pred, __proj);
...@@ -44,7 +44,7 @@ struct __fn {...@@ -44,7 +44,7 @@ struct __fn {
44 template <forward_range _Range, class _Type, class _Proj = identity>44 template <forward_range _Range, class _Type, class _Proj = identity>
45 requires permutable<iterator_t<_Range>>45 requires permutable<iterator_t<_Range>>
46 && indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>46 && indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
47 _LIBCPP_HIDE_FROM_ABI constexpr47 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
48 borrowed_subrange_t<_Range> operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const {48 borrowed_subrange_t<_Range> operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const {
49 auto __pred = [&](auto&& __other) { return __value == __other; };49 auto __pred = [&](auto&& __other) { return __value == __other; };
50 return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);50 return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
...@@ -59,6 +59,6 @@ inline namespace __cpo {...@@ -59,6 +59,6 @@ inline namespace __cpo {
5959
60_LIBCPP_END_NAMESPACE_STD60_LIBCPP_END_NAMESPACE_STD
6161
62#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)62#endif // _LIBCPP_STD_VER > 17
6363
64#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_H64#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_H
lib/libcxx/include/__algorithm/ranges_remove_copy.h+2-2
...@@ -26,7 +26,7 @@...@@ -26,7 +26,7 @@
26# pragma GCC system_header26# pragma GCC system_header
27#endif27#endif
2828
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)29#if _LIBCPP_STD_VER > 17
3030
31_LIBCPP_BEGIN_NAMESPACE_STD31_LIBCPP_BEGIN_NAMESPACE_STD
3232
...@@ -71,6 +71,6 @@ inline namespace __cpo {...@@ -71,6 +71,6 @@ inline namespace __cpo {
7171
72_LIBCPP_END_NAMESPACE_STD72_LIBCPP_END_NAMESPACE_STD
7373
74#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)74#endif // _LIBCPP_STD_VER > 17
7575
76#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_H76#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_H
lib/libcxx/include/__algorithm/ranges_remove_copy_if.h+2-2
...@@ -29,7 +29,7 @@...@@ -29,7 +29,7 @@
29# pragma GCC system_header29# pragma GCC system_header
30#endif30#endif
3131
32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)32#if _LIBCPP_STD_VER > 17
3333
34_LIBCPP_BEGIN_NAMESPACE_STD34_LIBCPP_BEGIN_NAMESPACE_STD
3535
...@@ -85,6 +85,6 @@ inline namespace __cpo {...@@ -85,6 +85,6 @@ inline namespace __cpo {
8585
86_LIBCPP_END_NAMESPACE_STD86_LIBCPP_END_NAMESPACE_STD
8787
88#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)88#endif // _LIBCPP_STD_VER > 17
8989
90#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_IF_H90#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_IF_H
lib/libcxx/include/__algorithm/ranges_remove_if.h+4-4
...@@ -27,7 +27,7 @@...@@ -27,7 +27,7 @@
27# pragma GCC system_header27# pragma GCC system_header
28#endif28#endif
2929
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)30#if _LIBCPP_STD_VER > 17
3131
32_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
3333
...@@ -56,7 +56,7 @@ struct __fn {...@@ -56,7 +56,7 @@ struct __fn {
56 template <permutable _Iter, sentinel_for<_Iter> _Sent,56 template <permutable _Iter, sentinel_for<_Iter> _Sent,
57 class _Proj = identity,57 class _Proj = identity,
58 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>58 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
59 _LIBCPP_HIDE_FROM_ABI constexpr59 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
60 subrange<_Iter> operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {60 subrange<_Iter> operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
61 return ranges::__remove_if_impl(std::move(__first), std::move(__last), __pred, __proj);61 return ranges::__remove_if_impl(std::move(__first), std::move(__last), __pred, __proj);
62 }62 }
...@@ -65,7 +65,7 @@ struct __fn {...@@ -65,7 +65,7 @@ struct __fn {
65 class _Proj = identity,65 class _Proj = identity,
66 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>66 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
67 requires permutable<iterator_t<_Range>>67 requires permutable<iterator_t<_Range>>
68 _LIBCPP_HIDE_FROM_ABI constexpr68 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
69 borrowed_subrange_t<_Range> operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {69 borrowed_subrange_t<_Range> operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
70 return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);70 return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
71 }71 }
...@@ -80,6 +80,6 @@ inline namespace __cpo {...@@ -80,6 +80,6 @@ inline namespace __cpo {
8080
81_LIBCPP_END_NAMESPACE_STD81_LIBCPP_END_NAMESPACE_STD
8282
83#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)83#endif // _LIBCPP_STD_VER > 17
8484
85#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_IF_H85#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_IF_H
lib/libcxx/include/__algorithm/ranges_replace.h+2-2
...@@ -24,7 +24,7 @@...@@ -24,7 +24,7 @@
24# pragma GCC system_header24# pragma GCC system_header
25#endif25#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES)27#if _LIBCPP_STD_VER > 17
2828
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
...@@ -69,6 +69,6 @@ inline namespace __cpo {...@@ -69,6 +69,6 @@ inline namespace __cpo {
6969
70_LIBCPP_END_NAMESPACE_STD70_LIBCPP_END_NAMESPACE_STD
7171
72#endif // _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES)72#endif // _LIBCPP_STD_VER > 17
7373
74#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_H74#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_H
lib/libcxx/include/__algorithm/ranges_replace_copy.h+2-2
...@@ -26,7 +26,7 @@...@@ -26,7 +26,7 @@
26# pragma GCC system_header26# pragma GCC system_header
27#endif27#endif
2828
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)29#if _LIBCPP_STD_VER > 17
3030
31_LIBCPP_BEGIN_NAMESPACE_STD31_LIBCPP_BEGIN_NAMESPACE_STD
3232
...@@ -86,6 +86,6 @@ inline namespace __cpo {...@@ -86,6 +86,6 @@ inline namespace __cpo {
8686
87_LIBCPP_END_NAMESPACE_STD87_LIBCPP_END_NAMESPACE_STD
8888
89#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)89#endif // _LIBCPP_STD_VER > 17
9090
91#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_H91#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_H
lib/libcxx/include/__algorithm/ranges_replace_copy_if.h+2-2
...@@ -24,7 +24,7 @@...@@ -24,7 +24,7 @@
24# pragma GCC system_header24# pragma GCC system_header
25#endif25#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)27#if _LIBCPP_STD_VER > 17
2828
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
...@@ -88,6 +88,6 @@ inline namespace __cpo {...@@ -88,6 +88,6 @@ inline namespace __cpo {
8888
89_LIBCPP_END_NAMESPACE_STD89_LIBCPP_END_NAMESPACE_STD
9090
91#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)91#endif // _LIBCPP_STD_VER > 17
9292
93#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_IF_H93#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_IF_H
lib/libcxx/include/__algorithm/ranges_replace_if.h+2-2
...@@ -23,7 +23,7 @@...@@ -23,7 +23,7 @@
23# pragma GCC system_header23# pragma GCC system_header
24#endif24#endif
2525
26#if _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES)26#if _LIBCPP_STD_VER > 17
2727
28_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2929
...@@ -72,6 +72,6 @@ inline namespace __cpo {...@@ -72,6 +72,6 @@ inline namespace __cpo {
7272
73_LIBCPP_END_NAMESPACE_STD73_LIBCPP_END_NAMESPACE_STD
7474
75#endif // _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES)75#endif // _LIBCPP_STD_VER > 17
7676
77#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_IF_H77#endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_IF_H
lib/libcxx/include/__algorithm/ranges_reverse.h+2-2
...@@ -22,7 +22,7 @@...@@ -22,7 +22,7 @@
22# pragma GCC system_header22# pragma GCC system_header
23#endif23#endif
2424
25#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)25#if _LIBCPP_STD_VER > 17
2626
27_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2828
...@@ -78,6 +78,6 @@ inline namespace __cpo {...@@ -78,6 +78,6 @@ inline namespace __cpo {
7878
79_LIBCPP_END_NAMESPACE_STD79_LIBCPP_END_NAMESPACE_STD
8080
81#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)81#endif // _LIBCPP_STD_VER > 17
8282
83#endif // _LIBCPP___ALGORITHM_RANGES_REVERSE_H83#endif // _LIBCPP___ALGORITHM_RANGES_REVERSE_H
lib/libcxx/include/__algorithm/ranges_reverse_copy.h+2-2
...@@ -25,7 +25,7 @@...@@ -25,7 +25,7 @@
25# pragma GCC system_header25# pragma GCC system_header
26#endif26#endif
2727
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)28#if _LIBCPP_STD_VER > 17
2929
30_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
3131
...@@ -62,6 +62,6 @@ inline namespace __cpo {...@@ -62,6 +62,6 @@ inline namespace __cpo {
6262
63_LIBCPP_END_NAMESPACE_STD63_LIBCPP_END_NAMESPACE_STD
6464
65#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)65#endif // _LIBCPP_STD_VER > 17
6666
67#endif // _LIBCPP___ALGORITHM_RANGES_REVERSE_COPY_H67#endif // _LIBCPP___ALGORITHM_RANGES_REVERSE_COPY_H
lib/libcxx/include/__algorithm/ranges_rotate.h+2-2
...@@ -25,7 +25,7 @@...@@ -25,7 +25,7 @@
25# pragma GCC system_header25# pragma GCC system_header
26#endif26#endif
2727
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)28#if _LIBCPP_STD_VER > 17
2929
30_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
3131
...@@ -66,6 +66,6 @@ inline namespace __cpo {...@@ -66,6 +66,6 @@ inline namespace __cpo {
6666
67_LIBCPP_END_NAMESPACE_STD67_LIBCPP_END_NAMESPACE_STD
6868
69#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)69#endif // _LIBCPP_STD_VER > 17
7070
71#endif // _LIBCPP___ALGORITHM_RANGES_ROTATE_H71#endif // _LIBCPP___ALGORITHM_RANGES_ROTATE_H
lib/libcxx/include/__algorithm/ranges_rotate_copy.h+2-2
...@@ -23,7 +23,7 @@...@@ -23,7 +23,7 @@
23# pragma GCC system_header23# pragma GCC system_header
24#endif24#endif
2525
26#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)26#if _LIBCPP_STD_VER > 17
2727
28_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2929
...@@ -63,6 +63,6 @@ inline namespace __cpo {...@@ -63,6 +63,6 @@ inline namespace __cpo {
6363
64_LIBCPP_END_NAMESPACE_STD64_LIBCPP_END_NAMESPACE_STD
6565
66#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)66#endif // _LIBCPP_STD_VER > 17
6767
68#endif // _LIBCPP___ALGORITHM_RANGES_ROTATE_COPY_H68#endif // _LIBCPP___ALGORITHM_RANGES_ROTATE_COPY_H
lib/libcxx/include/__algorithm/ranges_sample.h+2-2
...@@ -27,7 +27,7 @@...@@ -27,7 +27,7 @@
27# pragma GCC system_header27# pragma GCC system_header
28#endif28#endif
2929
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)30#if _LIBCPP_STD_VER > 17
3131
32_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
3333
...@@ -69,6 +69,6 @@ inline namespace __cpo {...@@ -69,6 +69,6 @@ inline namespace __cpo {
6969
70_LIBCPP_END_NAMESPACE_STD70_LIBCPP_END_NAMESPACE_STD
7171
72#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)72#endif // _LIBCPP_STD_VER > 17
7373
74#endif // _LIBCPP___ALGORITHM_RANGES_SAMPLE_H74#endif // _LIBCPP___ALGORITHM_RANGES_SAMPLE_H
lib/libcxx/include/__algorithm/ranges_search.h+5-4
...@@ -22,12 +22,13 @@...@@ -22,12 +22,13 @@
22#include <__ranges/concepts.h>22#include <__ranges/concepts.h>
23#include <__ranges/size.h>23#include <__ranges/size.h>
24#include <__ranges/subrange.h>24#include <__ranges/subrange.h>
25#include <__utility/pair.h>
2526
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header28# pragma GCC system_header
28#endif29#endif
2930
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)31#if _LIBCPP_STD_VER > 17
3132
32_LIBCPP_BEGIN_NAMESPACE_STD33_LIBCPP_BEGIN_NAMESPACE_STD
3334
...@@ -74,7 +75,7 @@ struct __fn {...@@ -74,7 +75,7 @@ struct __fn {
74 class _Proj1 = identity,75 class _Proj1 = identity,
75 class _Proj2 = identity>76 class _Proj2 = identity>
76 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>77 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
77 _LIBCPP_HIDE_FROM_ABI constexpr78 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
78 subrange<_Iter1> operator()(_Iter1 __first1, _Sent1 __last1,79 subrange<_Iter1> operator()(_Iter1 __first1, _Sent1 __last1,
79 _Iter2 __first2, _Sent2 __last2,80 _Iter2 __first2, _Sent2 __last2,
80 _Pred __pred = {},81 _Pred __pred = {},
...@@ -89,7 +90,7 @@ struct __fn {...@@ -89,7 +90,7 @@ struct __fn {
89 class _Proj1 = identity,90 class _Proj1 = identity,
90 class _Proj2 = identity>91 class _Proj2 = identity>
91 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>92 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
92 _LIBCPP_HIDE_FROM_ABI constexpr93 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
93 borrowed_subrange_t<_Range1> operator()(_Range1&& __range1,94 borrowed_subrange_t<_Range1> operator()(_Range1&& __range1,
94 _Range2&& __range2,95 _Range2&& __range2,
95 _Pred __pred = {},96 _Pred __pred = {},
...@@ -129,6 +130,6 @@ inline namespace __cpo {...@@ -129,6 +130,6 @@ inline namespace __cpo {
129130
130_LIBCPP_END_NAMESPACE_STD131_LIBCPP_END_NAMESPACE_STD
131132
132#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)133#endif // _LIBCPP_STD_VER > 17
133134
134#endif // _LIBCPP___ALGORITHM_RANGES_SEARCH_H135#endif // _LIBCPP___ALGORITHM_RANGES_SEARCH_H
lib/libcxx/include/__algorithm/ranges_search_n.h+7-10
...@@ -25,12 +25,13 @@...@@ -25,12 +25,13 @@
25#include <__ranges/size.h>25#include <__ranges/size.h>
26#include <__ranges/subrange.h>26#include <__ranges/subrange.h>
27#include <__utility/move.h>27#include <__utility/move.h>
28#include <__utility/pair.h>
2829
29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
30# pragma GCC system_header31# pragma GCC system_header
31#endif32#endif
3233
33#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)34#if _LIBCPP_STD_VER > 17
3435
35_LIBCPP_BEGIN_NAMESPACE_STD36_LIBCPP_BEGIN_NAMESPACE_STD
3637
...@@ -52,12 +53,8 @@ struct __fn {...@@ -52,12 +53,8 @@ struct __fn {
52 }53 }
5354
54 if constexpr (random_access_iterator<_Iter1>) {55 if constexpr (random_access_iterator<_Iter1>) {
55 auto __ret = __search_n_random_access_impl<_RangeAlgPolicy>(__first, __last,56 auto __ret = std::__search_n_random_access_impl<_RangeAlgPolicy>(
56 __count,57 __first, __last, __count, __value, __pred, __proj, __size);
57 __value,
58 __pred,
59 __proj,
60 __size);
61 return {std::move(__ret.first), std::move(__ret.second)};58 return {std::move(__ret.first), std::move(__ret.second)};
62 }59 }
63 }60 }
...@@ -75,7 +72,7 @@ struct __fn {...@@ -75,7 +72,7 @@ struct __fn {
75 class _Pred = ranges::equal_to,72 class _Pred = ranges::equal_to,
76 class _Proj = identity>73 class _Proj = identity>
77 requires indirectly_comparable<_Iter, const _Type*, _Pred, _Proj>74 requires indirectly_comparable<_Iter, const _Type*, _Pred, _Proj>
78 _LIBCPP_HIDE_FROM_ABI constexpr75 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
79 subrange<_Iter> operator()(_Iter __first, _Sent __last,76 subrange<_Iter> operator()(_Iter __first, _Sent __last,
80 iter_difference_t<_Iter> __count,77 iter_difference_t<_Iter> __count,
81 const _Type& __value,78 const _Type& __value,
...@@ -86,7 +83,7 @@ struct __fn {...@@ -86,7 +83,7 @@ struct __fn {
8683
87 template <forward_range _Range, class _Type, class _Pred = ranges::equal_to, class _Proj = identity>84 template <forward_range _Range, class _Type, class _Pred = ranges::equal_to, class _Proj = identity>
88 requires indirectly_comparable<iterator_t<_Range>, const _Type*, _Pred, _Proj>85 requires indirectly_comparable<iterator_t<_Range>, const _Type*, _Pred, _Proj>
89 _LIBCPP_HIDE_FROM_ABI constexpr86 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
90 borrowed_subrange_t<_Range> operator()(_Range&& __range,87 borrowed_subrange_t<_Range> operator()(_Range&& __range,
91 range_difference_t<_Range> __count,88 range_difference_t<_Range> __count,
92 const _Type& __value,89 const _Type& __value,
...@@ -115,6 +112,6 @@ inline namespace __cpo {...@@ -115,6 +112,6 @@ inline namespace __cpo {
115112
116_LIBCPP_END_NAMESPACE_STD113_LIBCPP_END_NAMESPACE_STD
117114
118#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)115#endif // _LIBCPP_STD_VER > 17
119116
120#endif // _LIBCPP___ALGORITHM_RANGES_SEARCH_N_H117#endif // _LIBCPP___ALGORITHM_RANGES_SEARCH_N_H
lib/libcxx/include/__algorithm/ranges_set_difference.h+7-5
...@@ -10,6 +10,7 @@...@@ -10,6 +10,7 @@
10#define _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H10#define _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H
1111
12#include <__algorithm/in_out_result.h>12#include <__algorithm/in_out_result.h>
13#include <__algorithm/iterator_operations.h>
13#include <__algorithm/make_projected.h>14#include <__algorithm/make_projected.h>
14#include <__algorithm/set_difference.h>15#include <__algorithm/set_difference.h>
15#include <__config>16#include <__config>
...@@ -23,12 +24,13 @@...@@ -23,12 +24,13 @@
23#include <__ranges/dangling.h>24#include <__ranges/dangling.h>
24#include <__type_traits/decay.h>25#include <__type_traits/decay.h>
25#include <__utility/move.h>26#include <__utility/move.h>
27#include <__utility/pair.h>
2628
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header30# pragma GCC system_header
29#endif31#endif
3032
31#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)33#if _LIBCPP_STD_VER > 17
3234
33_LIBCPP_BEGIN_NAMESPACE_STD35_LIBCPP_BEGIN_NAMESPACE_STD
3436
...@@ -59,7 +61,7 @@ struct __fn {...@@ -59,7 +61,7 @@ struct __fn {
59 _Comp __comp = {},61 _Comp __comp = {},
60 _Proj1 __proj1 = {},62 _Proj1 __proj1 = {},
61 _Proj2 __proj2 = {}) const {63 _Proj2 __proj2 = {}) const {
62 auto __ret = std::__set_difference(64 auto __ret = std::__set_difference<_RangeAlgPolicy>(
63 __first1, __last1, __first2, __last2, __result, ranges::__make_projected_comp(__comp, __proj1, __proj2));65 __first1, __last1, __first2, __last2, __result, ranges::__make_projected_comp(__comp, __proj1, __proj2));
64 return {std::move(__ret.first), std::move(__ret.second)};66 return {std::move(__ret.first), std::move(__ret.second)};
65 }67 }
...@@ -71,7 +73,7 @@ struct __fn {...@@ -71,7 +73,7 @@ struct __fn {
71 class _Comp = less,73 class _Comp = less,
72 class _Proj1 = identity,74 class _Proj1 = identity,
73 class _Proj2 = identity>75 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>
75 _LIBCPP_HIDE_FROM_ABI constexpr set_difference_result<borrowed_iterator_t<_Range1>, _OutIter>77 _LIBCPP_HIDE_FROM_ABI constexpr set_difference_result<borrowed_iterator_t<_Range1>, _OutIter>
76 operator()(78 operator()(
77 _Range1&& __range1,79 _Range1&& __range1,
...@@ -80,7 +82,7 @@ struct __fn {...@@ -80,7 +82,7 @@ struct __fn {
80 _Comp __comp = {},82 _Comp __comp = {},
81 _Proj1 __proj1 = {},83 _Proj1 __proj1 = {},
82 _Proj2 __proj2 = {}) const {84 _Proj2 __proj2 = {}) const {
83 auto __ret = std::__set_difference(85 auto __ret = std::__set_difference<_RangeAlgPolicy>(
84 ranges::begin(__range1),86 ranges::begin(__range1),
85 ranges::end(__range1),87 ranges::end(__range1),
86 ranges::begin(__range2),88 ranges::begin(__range2),
...@@ -100,5 +102,5 @@ inline namespace __cpo {...@@ -100,5 +102,5 @@ inline namespace __cpo {
100102
101_LIBCPP_END_NAMESPACE_STD103_LIBCPP_END_NAMESPACE_STD
102104
103#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)105#endif // _LIBCPP_STD_VER > 17
104#endif // _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H106#endif // _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H
lib/libcxx/include/__algorithm/ranges_set_intersection.h+3-3
...@@ -28,7 +28,7 @@...@@ -28,7 +28,7 @@
28# pragma GCC system_header28# pragma GCC system_header
29#endif29#endif
3030
31#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)31#if _LIBCPP_STD_VER > 17
3232
33_LIBCPP_BEGIN_NAMESPACE_STD33_LIBCPP_BEGIN_NAMESPACE_STD
3434
...@@ -82,7 +82,7 @@ struct __fn {...@@ -82,7 +82,7 @@ struct __fn {
82 _OutIter,82 _OutIter,
83 _Comp,83 _Comp,
84 _Proj1,84 _Proj1,
85 _Proj2> 85 _Proj2>
86 _LIBCPP_HIDE_FROM_ABI constexpr set_intersection_result<borrowed_iterator_t<_Range1>,86 _LIBCPP_HIDE_FROM_ABI constexpr set_intersection_result<borrowed_iterator_t<_Range1>,
87 borrowed_iterator_t<_Range2>,87 borrowed_iterator_t<_Range2>,
88 _OutIter>88 _OutIter>
...@@ -113,5 +113,5 @@ inline namespace __cpo {...@@ -113,5 +113,5 @@ inline namespace __cpo {
113113
114_LIBCPP_END_NAMESPACE_STD114_LIBCPP_END_NAMESPACE_STD
115115
116#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)116#endif // _LIBCPP_STD_VER > 17
117#endif // _LIBCPP___ALGORITHM_RANGES_SET_INTERSECTION_H117#endif // _LIBCPP___ALGORITHM_RANGES_SET_INTERSECTION_H
lib/libcxx/include/__algorithm/ranges_set_symmetric_difference.h+6-5
...@@ -10,6 +10,7 @@...@@ -10,6 +10,7 @@
10#define _LIBCPP___ALGORITHM_RANGES_SET_SYMMETRIC_DIFFERENCE_H10#define _LIBCPP___ALGORITHM_RANGES_SET_SYMMETRIC_DIFFERENCE_H
1111
12#include <__algorithm/in_in_out_result.h>12#include <__algorithm/in_in_out_result.h>
13#include <__algorithm/iterator_operations.h>
13#include <__algorithm/make_projected.h>14#include <__algorithm/make_projected.h>
14#include <__algorithm/set_symmetric_difference.h>15#include <__algorithm/set_symmetric_difference.h>
15#include <__config>16#include <__config>
...@@ -27,7 +28,7 @@...@@ -27,7 +28,7 @@
27# pragma GCC system_header28# pragma GCC system_header
28#endif29#endif
2930
30#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)31#if _LIBCPP_STD_VER > 17
3132
32_LIBCPP_BEGIN_NAMESPACE_STD33_LIBCPP_BEGIN_NAMESPACE_STD
3334
...@@ -58,7 +59,7 @@ struct __fn {...@@ -58,7 +59,7 @@ struct __fn {
58 _Comp __comp = {},59 _Comp __comp = {},
59 _Proj1 __proj1 = {},60 _Proj1 __proj1 = {},
60 _Proj2 __proj2 = {}) const {61 _Proj2 __proj2 = {}) const {
61 auto __ret = std::__set_symmetric_difference(62 auto __ret = std::__set_symmetric_difference<_RangeAlgPolicy>(
62 std::move(__first1),63 std::move(__first1),
63 std::move(__last1),64 std::move(__last1),
64 std::move(__first2),65 std::move(__first2),
...@@ -81,7 +82,7 @@ struct __fn {...@@ -81,7 +82,7 @@ struct __fn {
81 _OutIter,82 _OutIter,
82 _Comp,83 _Comp,
83 _Proj1,84 _Proj1,
84 _Proj2> 85 _Proj2>
85 _LIBCPP_HIDE_FROM_ABI constexpr set_symmetric_difference_result<borrowed_iterator_t<_Range1>,86 _LIBCPP_HIDE_FROM_ABI constexpr set_symmetric_difference_result<borrowed_iterator_t<_Range1>,
86 borrowed_iterator_t<_Range2>,87 borrowed_iterator_t<_Range2>,
87 _OutIter>88 _OutIter>
...@@ -92,7 +93,7 @@ struct __fn {...@@ -92,7 +93,7 @@ struct __fn {
92 _Comp __comp = {},93 _Comp __comp = {},
93 _Proj1 __proj1 = {},94 _Proj1 __proj1 = {},
94 _Proj2 __proj2 = {}) const {95 _Proj2 __proj2 = {}) const {
95 auto __ret = std::__set_symmetric_difference(96 auto __ret = std::__set_symmetric_difference<_RangeAlgPolicy>(
96 ranges::begin(__range1),97 ranges::begin(__range1),
97 ranges::end(__range1),98 ranges::end(__range1),
98 ranges::begin(__range2),99 ranges::begin(__range2),
...@@ -112,5 +113,5 @@ inline namespace __cpo {...@@ -112,5 +113,5 @@ inline namespace __cpo {
112113
113_LIBCPP_END_NAMESPACE_STD114_LIBCPP_END_NAMESPACE_STD
114115
115#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)116#endif // _LIBCPP_STD_VER > 17
116#endif // _LIBCPP___ALGORITHM_RANGES_SET_SYMMETRIC_DIFFERENCE_H117#endif // _LIBCPP___ALGORITHM_RANGES_SET_SYMMETRIC_DIFFERENCE_H
lib/libcxx/include/__algorithm/ranges_set_union.h+6-5
...@@ -10,6 +10,7 @@...@@ -10,6 +10,7 @@
10#define _LIBCPP___ALGORITHM_RANGES_SET_UNION_H10#define _LIBCPP___ALGORITHM_RANGES_SET_UNION_H
1111
12#include <__algorithm/in_in_out_result.h>12#include <__algorithm/in_in_out_result.h>
13#include <__algorithm/iterator_operations.h>
13#include <__algorithm/make_projected.h>14#include <__algorithm/make_projected.h>
14#include <__algorithm/set_union.h>15#include <__algorithm/set_union.h>
15#include <__config>16#include <__config>
...@@ -30,7 +31,7 @@...@@ -30,7 +31,7 @@
30# pragma GCC system_header31# pragma GCC system_header
31#endif32#endif
3233
33#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)34#if _LIBCPP_STD_VER > 17
3435
35_LIBCPP_BEGIN_NAMESPACE_STD36_LIBCPP_BEGIN_NAMESPACE_STD
3637
...@@ -61,7 +62,7 @@ struct __fn {...@@ -61,7 +62,7 @@ struct __fn {
61 _Comp __comp = {},62 _Comp __comp = {},
62 _Proj1 __proj1 = {},63 _Proj1 __proj1 = {},
63 _Proj2 __proj2 = {}) const {64 _Proj2 __proj2 = {}) const {
64 auto __ret = std::__set_union(65 auto __ret = std::__set_union<_RangeAlgPolicy>(
65 std::move(__first1),66 std::move(__first1),
66 std::move(__last1),67 std::move(__last1),
67 std::move(__first2),68 std::move(__first2),
...@@ -84,7 +85,7 @@ struct __fn {...@@ -84,7 +85,7 @@ struct __fn {
84 _OutIter,85 _OutIter,
85 _Comp,86 _Comp,
86 _Proj1,87 _Proj1,
87 _Proj2> 88 _Proj2>
88 _LIBCPP_HIDE_FROM_ABI constexpr set_union_result<borrowed_iterator_t<_Range1>,89 _LIBCPP_HIDE_FROM_ABI constexpr set_union_result<borrowed_iterator_t<_Range1>,
89 borrowed_iterator_t<_Range2>,90 borrowed_iterator_t<_Range2>,
90 _OutIter>91 _OutIter>
...@@ -95,7 +96,7 @@ struct __fn {...@@ -95,7 +96,7 @@ struct __fn {
95 _Comp __comp = {},96 _Comp __comp = {},
96 _Proj1 __proj1 = {},97 _Proj1 __proj1 = {},
97 _Proj2 __proj2 = {}) const {98 _Proj2 __proj2 = {}) const {
98 auto __ret = std::__set_union(99 auto __ret = std::__set_union<_RangeAlgPolicy>(
99 ranges::begin(__range1),100 ranges::begin(__range1),
100 ranges::end(__range1),101 ranges::end(__range1),
101 ranges::begin(__range2),102 ranges::begin(__range2),
...@@ -115,6 +116,6 @@ inline namespace __cpo {...@@ -115,6 +116,6 @@ inline namespace __cpo {
115116
116_LIBCPP_END_NAMESPACE_STD117_LIBCPP_END_NAMESPACE_STD
117118
118#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)119#endif // _LIBCPP_STD_VER > 17
119120
120#endif // _LIBCPP___ALGORITHM_RANGES_SET_UNION_H121#endif // _LIBCPP___ALGORITHM_RANGES_SET_UNION_H
lib/libcxx/include/__algorithm/ranges_shuffle.h+2-2
...@@ -31,7 +31,7 @@...@@ -31,7 +31,7 @@
31# pragma GCC system_header31# pragma GCC system_header
32#endif32#endif
3333
34#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)34#if _LIBCPP_STD_VER > 17
3535
36_LIBCPP_BEGIN_NAMESPACE_STD36_LIBCPP_BEGIN_NAMESPACE_STD
3737
...@@ -66,6 +66,6 @@ inline namespace __cpo {...@@ -66,6 +66,6 @@ inline namespace __cpo {
6666
67_LIBCPP_END_NAMESPACE_STD67_LIBCPP_END_NAMESPACE_STD
6868
69#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)69#endif // _LIBCPP_STD_VER > 17
7070
71#endif // _LIBCPP___ALGORITHM_RANGES_SHUFFLE_H71#endif // _LIBCPP___ALGORITHM_RANGES_SHUFFLE_H
lib/libcxx/include/__algorithm/ranges_sort.h+2-2
...@@ -31,7 +31,7 @@...@@ -31,7 +31,7 @@
31# pragma GCC system_header31# pragma GCC system_header
32#endif32#endif
3333
34#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)34#if _LIBCPP_STD_VER > 17
3535
36_LIBCPP_BEGIN_NAMESPACE_STD36_LIBCPP_BEGIN_NAMESPACE_STD
3737
...@@ -74,6 +74,6 @@ inline namespace __cpo {...@@ -74,6 +74,6 @@ inline namespace __cpo {
7474
75_LIBCPP_END_NAMESPACE_STD75_LIBCPP_END_NAMESPACE_STD
7676
77#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)77#endif // _LIBCPP_STD_VER > 17
7878
79#endif // _LIBCPP___ALGORITHM_RANGES_SORT_H79#endif // _LIBCPP___ALGORITHM_RANGES_SORT_H
lib/libcxx/include/__algorithm/ranges_sort_heap.h+2-2
...@@ -32,7 +32,7 @@...@@ -32,7 +32,7 @@
32# pragma GCC system_header32# pragma GCC system_header
33#endif33#endif
3434
35#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)35#if _LIBCPP_STD_VER > 17
3636
37_LIBCPP_BEGIN_NAMESPACE_STD37_LIBCPP_BEGIN_NAMESPACE_STD
3838
...@@ -75,6 +75,6 @@ inline namespace __cpo {...@@ -75,6 +75,6 @@ inline namespace __cpo {
7575
76_LIBCPP_END_NAMESPACE_STD76_LIBCPP_END_NAMESPACE_STD
7777
78#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)78#endif // _LIBCPP_STD_VER > 17
7979
80#endif // _LIBCPP___ALGORITHM_RANGES_SORT_HEAP_H80#endif // _LIBCPP___ALGORITHM_RANGES_SORT_HEAP_H
lib/libcxx/include/__algorithm/ranges_stable_partition.h+3-3
...@@ -34,7 +34,7 @@...@@ -34,7 +34,7 @@
34# pragma GCC system_header34# pragma GCC system_header
35#endif35#endif
3636
37#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)37#if _LIBCPP_STD_VER > 17
3838
39_LIBCPP_BEGIN_NAMESPACE_STD39_LIBCPP_BEGIN_NAMESPACE_STD
4040
...@@ -45,7 +45,7 @@ struct __fn {...@@ -45,7 +45,7 @@ struct __fn {
4545
46 template <class _Iter, class _Sent, class _Proj, class _Pred>46 template <class _Iter, class _Sent, class _Proj, class _Pred>
47 _LIBCPP_HIDE_FROM_ABI static47 _LIBCPP_HIDE_FROM_ABI static
48 subrange<__uncvref_t<_Iter>> __stable_partition_fn_impl(48 subrange<__remove_cvref_t<_Iter>> __stable_partition_fn_impl(
49 _Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {49 _Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {
50 auto __last_iter = ranges::next(__first, __last);50 auto __last_iter = ranges::next(__first, __last);
5151
...@@ -83,6 +83,6 @@ inline namespace __cpo {...@@ -83,6 +83,6 @@ inline namespace __cpo {
8383
84_LIBCPP_END_NAMESPACE_STD84_LIBCPP_END_NAMESPACE_STD
8585
86#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)86#endif // _LIBCPP_STD_VER > 17
8787
88#endif // _LIBCPP___ALGORITHM_RANGES_STABLE_PARTITION_H88#endif // _LIBCPP___ALGORITHM_RANGES_STABLE_PARTITION_H
lib/libcxx/include/__algorithm/ranges_stable_sort.h+2-2
...@@ -31,7 +31,7 @@...@@ -31,7 +31,7 @@
31# pragma GCC system_header31# pragma GCC system_header
32#endif32#endif
3333
34#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)34#if _LIBCPP_STD_VER > 17
3535
36_LIBCPP_BEGIN_NAMESPACE_STD36_LIBCPP_BEGIN_NAMESPACE_STD
3737
...@@ -74,6 +74,6 @@ inline namespace __cpo {...@@ -74,6 +74,6 @@ inline namespace __cpo {
7474
75_LIBCPP_END_NAMESPACE_STD75_LIBCPP_END_NAMESPACE_STD
7676
77#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)77#endif // _LIBCPP_STD_VER > 17
7878
79#endif // _LIBCPP___ALGORITHM_RANGES_STABLE_SORT_H79#endif // _LIBCPP___ALGORITHM_RANGES_STABLE_SORT_H
lib/libcxx/include/__algorithm/ranges_swap_ranges.h+2-2
...@@ -24,7 +24,7 @@...@@ -24,7 +24,7 @@
24# pragma GCC system_header24# pragma GCC system_header
25#endif25#endif
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)27#if _LIBCPP_STD_VER > 17
2828
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
...@@ -63,6 +63,6 @@ inline namespace __cpo {...@@ -63,6 +63,6 @@ inline namespace __cpo {
6363
64_LIBCPP_END_NAMESPACE_STD64_LIBCPP_END_NAMESPACE_STD
6565
66#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)66#endif // _LIBCPP_STD_VER > 17
6767
68#endif // _LIBCPP___ALGORITHM_RANGES_SWAP_RANGES_H68#endif // _LIBCPP___ALGORITHM_RANGES_SWAP_RANGES_H
lib/libcxx/include/__algorithm/ranges_transform.h+2-2
...@@ -26,7 +26,7 @@...@@ -26,7 +26,7 @@
26# pragma GCC system_header26# pragma GCC system_header
27#endif27#endif
2828
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)29#if _LIBCPP_STD_VER > 17
3030
31_LIBCPP_BEGIN_NAMESPACE_STD31_LIBCPP_BEGIN_NAMESPACE_STD
3232
...@@ -165,6 +165,6 @@ inline namespace __cpo {...@@ -165,6 +165,6 @@ inline namespace __cpo {
165165
166_LIBCPP_END_NAMESPACE_STD166_LIBCPP_END_NAMESPACE_STD
167167
168#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)168#endif // _LIBCPP_STD_VER > 17
169169
170#endif // _LIBCPP___ALGORITHM_RANGES_TRANSFORM_H170#endif // _LIBCPP___ALGORITHM_RANGES_TRANSFORM_H
lib/libcxx/include/__algorithm/ranges_unique.h+5-4
...@@ -26,12 +26,13 @@...@@ -26,12 +26,13 @@
26#include <__ranges/subrange.h>26#include <__ranges/subrange.h>
27#include <__utility/forward.h>27#include <__utility/forward.h>
28#include <__utility/move.h>28#include <__utility/move.h>
29#include <__utility/pair.h>
2930
30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)31#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
31# pragma GCC system_header32# pragma GCC system_header
32#endif33#endif
3334
34#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)35#if _LIBCPP_STD_VER > 17
3536
36_LIBCPP_BEGIN_NAMESPACE_STD37_LIBCPP_BEGIN_NAMESPACE_STD
3738
...@@ -44,7 +45,7 @@ namespace __unique {...@@ -44,7 +45,7 @@ namespace __unique {
44 sentinel_for<_Iter> _Sent,45 sentinel_for<_Iter> _Sent,
45 class _Proj = identity,46 class _Proj = identity,
46 indirect_equivalence_relation<projected<_Iter, _Proj>> _Comp = ranges::equal_to>47 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>
48 operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {49 operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
49 auto __ret = std::__unique<_RangeAlgPolicy>(50 auto __ret = std::__unique<_RangeAlgPolicy>(
50 std::move(__first), std::move(__last), std::__make_projected(__comp, __proj));51 std::move(__first), std::move(__last), std::__make_projected(__comp, __proj));
...@@ -56,7 +57,7 @@ namespace __unique {...@@ -56,7 +57,7 @@ namespace __unique {
56 class _Proj = identity,57 class _Proj = identity,
57 indirect_equivalence_relation<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::equal_to>58 indirect_equivalence_relation<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::equal_to>
58 requires permutable<iterator_t<_Range>>59 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>
60 operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {61 operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
61 auto __ret = std::__unique<_RangeAlgPolicy>(62 auto __ret = std::__unique<_RangeAlgPolicy>(
62 ranges::begin(__range), ranges::end(__range), std::__make_projected(__comp, __proj));63 ranges::begin(__range), ranges::end(__range), std::__make_projected(__comp, __proj));
...@@ -73,6 +74,6 @@ inline namespace __cpo {...@@ -73,6 +74,6 @@ inline namespace __cpo {
7374
74_LIBCPP_END_NAMESPACE_STD75_LIBCPP_END_NAMESPACE_STD
7576
76#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)77#endif // _LIBCPP_STD_VER > 17
7778
78#endif // _LIBCPP___ALGORITHM_RANGES_UNIQUE_H79#endif // _LIBCPP___ALGORITHM_RANGES_UNIQUE_H
lib/libcxx/include/__algorithm/ranges_unique_copy.h+3-2
...@@ -27,12 +27,13 @@...@@ -27,12 +27,13 @@
27#include <__ranges/dangling.h>27#include <__ranges/dangling.h>
28#include <__utility/forward.h>28#include <__utility/forward.h>
29#include <__utility/move.h>29#include <__utility/move.h>
30#include <__utility/pair.h>
3031
31#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)32#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
32# pragma GCC system_header33# pragma GCC system_header
33#endif34#endif
3435
35#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)36#if _LIBCPP_STD_VER > 17
3637
37_LIBCPP_BEGIN_NAMESPACE_STD38_LIBCPP_BEGIN_NAMESPACE_STD
3839
...@@ -110,6 +111,6 @@ inline constexpr auto unique_copy = __unique_copy::__fn{};...@@ -110,6 +111,6 @@ inline constexpr auto unique_copy = __unique_copy::__fn{};
110111
111_LIBCPP_END_NAMESPACE_STD112_LIBCPP_END_NAMESPACE_STD
112113
113#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)114#endif // _LIBCPP_STD_VER > 17
114115
115#endif // _LIBCPP___ALGORITHM_RANGES_UNIQUE_COPY_H116#endif // _LIBCPP___ALGORITHM_RANGES_UNIQUE_COPY_H
lib/libcxx/include/__algorithm/ranges_upper_bound.h+4-4
...@@ -25,7 +25,7 @@...@@ -25,7 +25,7 @@
25# pragma GCC system_header25# pragma GCC system_header
26#endif26#endif
2727
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)28#if _LIBCPP_STD_VER > 17
2929
30_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
3131
...@@ -34,7 +34,7 @@ namespace __upper_bound {...@@ -34,7 +34,7 @@ namespace __upper_bound {
34struct __fn {34struct __fn {
35 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity,35 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity,
36 indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less>36 indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less>
37 _LIBCPP_HIDE_FROM_ABI constexpr37 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
38 _Iter operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {38 _Iter operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
39 auto __comp_lhs_rhs_swapped = [&](const auto& __lhs, const auto& __rhs) {39 auto __comp_lhs_rhs_swapped = [&](const auto& __lhs, const auto& __rhs) {
40 return !std::invoke(__comp, __rhs, __lhs);40 return !std::invoke(__comp, __rhs, __lhs);
...@@ -45,7 +45,7 @@ struct __fn {...@@ -45,7 +45,7 @@ struct __fn {
4545
46 template <forward_range _Range, class _Type, class _Proj = identity,46 template <forward_range _Range, class _Type, class _Proj = identity,
47 indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>47 indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
48 _LIBCPP_HIDE_FROM_ABI constexpr48 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr
49 borrowed_iterator_t<_Range> operator()(_Range&& __r,49 borrowed_iterator_t<_Range> operator()(_Range&& __r,
50 const _Type& __value,50 const _Type& __value,
51 _Comp __comp = {},51 _Comp __comp = {},
...@@ -70,6 +70,6 @@ inline namespace __cpo {...@@ -70,6 +70,6 @@ inline namespace __cpo {
7070
71_LIBCPP_END_NAMESPACE_STD71_LIBCPP_END_NAMESPACE_STD
7272
73#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)73#endif // _LIBCPP_STD_VER > 17
7474
75#endif // _LIBCPP___ALGORITHM_RANGES_UPPER_BOUND_H75#endif // _LIBCPP___ALGORITHM_RANGES_UPPER_BOUND_H
lib/libcxx/include/__algorithm/remove.h+1-1
...@@ -21,7 +21,7 @@...@@ -21,7 +21,7 @@
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _ForwardIterator, class _Tp>23template <class _ForwardIterator, class _Tp>
24_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator24_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
25remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)25remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
26{26{
27 __first = _VSTD::find(__first, __last, __value);27 __first = _VSTD::find(__first, __last, __value);
lib/libcxx/include/__algorithm/remove_copy.h+1-1
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
1919
20template <class _InputIterator, class _OutputIterator, class _Tp>20template <class _InputIterator, class _OutputIterator, class _Tp>
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1721inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
22_OutputIterator22_OutputIterator
23remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value)23remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value)
24{24{
lib/libcxx/include/__algorithm/remove_copy_if.h+1-1
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
1919
20template <class _InputIterator, class _OutputIterator, class _Predicate>20template <class _InputIterator, class _OutputIterator, class _Predicate>
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1721inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
22_OutputIterator22_OutputIterator
23remove_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred)23remove_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred)
24{24{
lib/libcxx/include/__algorithm/remove_if.h+1-1
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <class _ForwardIterator, class _Predicate>22template <class _ForwardIterator, class _Predicate>
23_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator23_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
24remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)24remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
25{25{
26 __first = _VSTD::find_if<_ForwardIterator, _Predicate&>(__first, __last, __pred);26 __first = _VSTD::find_if<_ForwardIterator, _Predicate&>(__first, __last, __pred);
lib/libcxx/include/__algorithm/replace.h+1-1
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
1919
20template <class _ForwardIterator, class _Tp>20template <class _ForwardIterator, class _Tp>
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1721inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
22void22void
23replace(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_value, const _Tp& __new_value)23replace(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_value, const _Tp& __new_value)
24{24{
lib/libcxx/include/__algorithm/replace_copy.h+1-1
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
1919
20template <class _InputIterator, class _OutputIterator, class _Tp>20template <class _InputIterator, class _OutputIterator, class _Tp>
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1721inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
22_OutputIterator22_OutputIterator
23replace_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result,23replace_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
24 const _Tp& __old_value, const _Tp& __new_value)24 const _Tp& __old_value, const _Tp& __new_value)
lib/libcxx/include/__algorithm/replace_copy_if.h+1-1
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
1919
20template <class _InputIterator, class _OutputIterator, class _Predicate, class _Tp>20template <class _InputIterator, class _OutputIterator, class _Predicate, class _Tp>
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1721inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
22_OutputIterator22_OutputIterator
23replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result,23replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
24 _Predicate __pred, const _Tp& __new_value)24 _Predicate __pred, const _Tp& __new_value)
lib/libcxx/include/__algorithm/replace_if.h+1-1
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
1919
20template <class _ForwardIterator, class _Predicate, class _Tp>20template <class _ForwardIterator, class _Predicate, class _Tp>
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1721inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
22void22void
23replace_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, const _Tp& __new_value)23replace_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, const _Tp& __new_value)
24{24{
lib/libcxx/include/__algorithm/reverse.h+4-4
...@@ -22,7 +22,7 @@...@@ -22,7 +22,7 @@
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2323
24template <class _AlgPolicy, class _BidirectionalIterator>24template <class _AlgPolicy, class _BidirectionalIterator>
25inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1725inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
26void26void
27__reverse_impl(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirectional_iterator_tag)27__reverse_impl(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirectional_iterator_tag)
28{28{
...@@ -36,7 +36,7 @@ __reverse_impl(_BidirectionalIterator __first, _BidirectionalIterator __last, bi...@@ -36,7 +36,7 @@ __reverse_impl(_BidirectionalIterator __first, _BidirectionalIterator __last, bi
36}36}
3737
38template <class _AlgPolicy, class _RandomAccessIterator>38template <class _AlgPolicy, class _RandomAccessIterator>
39inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1739inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
40void40void
41__reverse_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, random_access_iterator_tag)41__reverse_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, random_access_iterator_tag)
42{42{
...@@ -46,14 +46,14 @@ __reverse_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, rand...@@ -46,14 +46,14 @@ __reverse_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, rand
46}46}
4747
48template <class _AlgPolicy, class _BidirectionalIterator, class _Sentinel>48template <class _AlgPolicy, class _BidirectionalIterator, class _Sentinel>
49_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1749_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
50void __reverse(_BidirectionalIterator __first, _Sentinel __last) {50void __reverse(_BidirectionalIterator __first, _Sentinel __last) {
51 using _IterCategory = typename _IterOps<_AlgPolicy>::template __iterator_category<_BidirectionalIterator>;51 using _IterCategory = typename _IterOps<_AlgPolicy>::template __iterator_category<_BidirectionalIterator>;
52 std::__reverse_impl<_AlgPolicy>(std::move(__first), std::move(__last), _IterCategory());52 std::__reverse_impl<_AlgPolicy>(std::move(__first), std::move(__last), _IterCategory());
53}53}
5454
55template <class _BidirectionalIterator>55template <class _BidirectionalIterator>
56inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1756inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
57void57void
58reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)58reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
59{59{
lib/libcxx/include/__algorithm/reverse_copy.h+1-1
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
1919
20template <class _BidirectionalIterator, class _OutputIterator>20template <class _BidirectionalIterator, class _OutputIterator>
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1721inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
22_OutputIterator22_OutputIterator
23reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)23reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
24{24{
lib/libcxx/include/__algorithm/rotate.h+11-11
...@@ -26,7 +26,7 @@...@@ -26,7 +26,7 @@
26_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
2727
28template <class _AlgPolicy, class _ForwardIterator>28template <class _AlgPolicy, class _ForwardIterator>
29_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator29_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
30__rotate_left(_ForwardIterator __first, _ForwardIterator __last)30__rotate_left(_ForwardIterator __first, _ForwardIterator __last)
31{31{
32 typedef typename iterator_traits<_ForwardIterator>::value_type value_type;32 typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
...@@ -40,7 +40,7 @@ __rotate_left(_ForwardIterator __first, _ForwardIterator __last)...@@ -40,7 +40,7 @@ __rotate_left(_ForwardIterator __first, _ForwardIterator __last)
40}40}
4141
42template <class _AlgPolicy, class _BidirectionalIterator>42template <class _AlgPolicy, class _BidirectionalIterator>
43_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator43_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _BidirectionalIterator
44__rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)44__rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)
45{45{
46 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;46 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
...@@ -48,13 +48,13 @@ __rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)...@@ -48,13 +48,13 @@ __rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)
4848
49 _BidirectionalIterator __lm1 = _Ops::prev(__last);49 _BidirectionalIterator __lm1 = _Ops::prev(__last);
50 value_type __tmp = _Ops::__iter_move(__lm1);50 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;
52 *__first = _VSTD::move(__tmp);52 *__first = _VSTD::move(__tmp);
53 return __fp1;53 return __fp1;
54}54}
5555
56template <class _AlgPolicy, class _ForwardIterator>56template <class _AlgPolicy, class _ForwardIterator>
57_LIBCPP_CONSTEXPR_AFTER_CXX14 _ForwardIterator57_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _ForwardIterator
58__rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)58__rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
59{59{
60 _ForwardIterator __i = __middle;60 _ForwardIterator __i = __middle;
...@@ -90,7 +90,7 @@ __rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIt...@@ -90,7 +90,7 @@ __rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIt
9090
91template<typename _Integral>91template<typename _Integral>
92inline _LIBCPP_INLINE_VISIBILITY92inline _LIBCPP_INLINE_VISIBILITY
93_LIBCPP_CONSTEXPR_AFTER_CXX14 _Integral93_LIBCPP_CONSTEXPR_SINCE_CXX17 _Integral
94__algo_gcd(_Integral __x, _Integral __y)94__algo_gcd(_Integral __x, _Integral __y)
95{95{
96 do96 do
...@@ -103,7 +103,7 @@ __algo_gcd(_Integral __x, _Integral __y)...@@ -103,7 +103,7 @@ __algo_gcd(_Integral __x, _Integral __y)
103}103}
104104
105template <class _AlgPolicy, typename _RandomAccessIterator>105template <class _AlgPolicy, typename _RandomAccessIterator>
106_LIBCPP_CONSTEXPR_AFTER_CXX14 _RandomAccessIterator106_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _RandomAccessIterator
107__rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)107__rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)
108{108{
109 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;109 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
...@@ -140,7 +140,7 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran...@@ -140,7 +140,7 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran
140140
141template <class _AlgPolicy, class _ForwardIterator>141template <class _AlgPolicy, class _ForwardIterator>
142inline _LIBCPP_INLINE_VISIBILITY142inline _LIBCPP_INLINE_VISIBILITY
143_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator143_LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
144__rotate_impl(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last,144__rotate_impl(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last,
145 _VSTD::forward_iterator_tag)145 _VSTD::forward_iterator_tag)
146{146{
...@@ -155,7 +155,7 @@ __rotate_impl(_ForwardIterator __first, _ForwardIterator __middle, _ForwardItera...@@ -155,7 +155,7 @@ __rotate_impl(_ForwardIterator __first, _ForwardIterator __middle, _ForwardItera
155155
156template <class _AlgPolicy, class _BidirectionalIterator>156template <class _AlgPolicy, class _BidirectionalIterator>
157inline _LIBCPP_INLINE_VISIBILITY157inline _LIBCPP_INLINE_VISIBILITY
158_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator158_LIBCPP_CONSTEXPR_SINCE_CXX14 _BidirectionalIterator
159__rotate_impl(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,159__rotate_impl(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
160 bidirectional_iterator_tag)160 bidirectional_iterator_tag)
161{161{
...@@ -172,7 +172,7 @@ __rotate_impl(_BidirectionalIterator __first, _BidirectionalIterator __middle, _...@@ -172,7 +172,7 @@ __rotate_impl(_BidirectionalIterator __first, _BidirectionalIterator __middle, _
172172
173template <class _AlgPolicy, class _RandomAccessIterator>173template <class _AlgPolicy, class _RandomAccessIterator>
174inline _LIBCPP_INLINE_VISIBILITY174inline _LIBCPP_INLINE_VISIBILITY
175_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator175_LIBCPP_CONSTEXPR_SINCE_CXX14 _RandomAccessIterator
176__rotate_impl(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,176__rotate_impl(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
177 random_access_iterator_tag)177 random_access_iterator_tag)
178{178{
...@@ -189,7 +189,7 @@ __rotate_impl(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ra...@@ -189,7 +189,7 @@ __rotate_impl(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ra
189}189}
190190
191template <class _AlgPolicy, class _Iterator, class _Sentinel>191template <class _AlgPolicy, class _Iterator, class _Sentinel>
192_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11192_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
193pair<_Iterator, _Iterator>193pair<_Iterator, _Iterator>
194__rotate(_Iterator __first, _Iterator __middle, _Sentinel __last) {194__rotate(_Iterator __first, _Iterator __middle, _Sentinel __last) {
195 using _Ret = pair<_Iterator, _Iterator>;195 using _Ret = pair<_Iterator, _Iterator>;
...@@ -209,7 +209,7 @@ __rotate(_Iterator __first, _Iterator __middle, _Sentinel __last) {...@@ -209,7 +209,7 @@ __rotate(_Iterator __first, _Iterator __middle, _Sentinel __last) {
209209
210template <class _ForwardIterator>210template <class _ForwardIterator>
211inline _LIBCPP_INLINE_VISIBILITY211inline _LIBCPP_INLINE_VISIBILITY
212_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator212_LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
213rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)213rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
214{214{
215 return std::__rotate<_ClassicAlgPolicy>(215 return std::__rotate<_ClassicAlgPolicy>(
lib/libcxx/include/__algorithm/rotate_copy.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _ForwardIterator, class _OutputIterator>21template <class _ForwardIterator, class _OutputIterator>
22inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1722inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
23_OutputIterator23_OutputIterator
24rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, _OutputIterator __result)24rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, _OutputIterator __result)
25{25{
lib/libcxx/include/__algorithm/search.h+8-10
...@@ -33,7 +33,7 @@ template <class _AlgPolicy,...@@ -33,7 +33,7 @@ template <class _AlgPolicy,
33 class _Pred,33 class _Pred,
34 class _Proj1,34 class _Proj1,
35 class _Proj2>35 class _Proj2>
36_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1136_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
37pair<_Iter1, _Iter1> __search_forward_impl(_Iter1 __first1, _Sent1 __last1,37pair<_Iter1, _Iter1> __search_forward_impl(_Iter1 __first1, _Sent1 __last1,
38 _Iter2 __first2, _Sent2 __last2,38 _Iter2 __first2, _Sent2 __last2,
39 _Pred& __pred,39 _Pred& __pred,
...@@ -80,7 +80,7 @@ template <class _AlgPolicy,...@@ -80,7 +80,7 @@ template <class _AlgPolicy,
80 class _Proj2,80 class _Proj2,
81 class _DiffT1,81 class _DiffT1,
82 class _DiffT2>82 class _DiffT2>
83_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1183_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
84pair<_Iter1, _Iter1> __search_random_access_impl(_Iter1 __first1, _Sent1 __last1,84pair<_Iter1, _Iter1> __search_random_access_impl(_Iter1 __first1, _Sent1 __last1,
85 _Iter2 __first2, _Sent2 __last2,85 _Iter2 __first2, _Sent2 __last2,
86 _Pred& __pred,86 _Pred& __pred,
...@@ -120,7 +120,7 @@ template <class _Iter1, class _Sent1,...@@ -120,7 +120,7 @@ template <class _Iter1, class _Sent1,
120 class _Pred,120 class _Pred,
121 class _Proj1,121 class _Proj1,
122 class _Proj2>122 class _Proj2>
123_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11123_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
124pair<_Iter1, _Iter1> __search_impl(_Iter1 __first1, _Sent1 __last1,124pair<_Iter1, _Iter1> __search_impl(_Iter1 __first1, _Sent1 __last1,
125 _Iter2 __first2, _Sent2 __last2,125 _Iter2 __first2, _Sent2 __last2,
126 _Pred& __pred,126 _Pred& __pred,
...@@ -152,7 +152,7 @@ template <class _Iter1, class _Sent1,...@@ -152,7 +152,7 @@ template <class _Iter1, class _Sent1,
152 class _Pred,152 class _Pred,
153 class _Proj1,153 class _Proj1,
154 class _Proj2>154 class _Proj2>
155_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11155_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
156pair<_Iter1, _Iter1> __search_impl(_Iter1 __first1, _Sent1 __last1,156pair<_Iter1, _Iter1> __search_impl(_Iter1 __first1, _Sent1 __last1,
157 _Iter2 __first2, _Sent2 __last2,157 _Iter2 __first2, _Sent2 __last2,
158 _Pred& __pred,158 _Pred& __pred,
...@@ -170,7 +170,7 @@ pair<_Iter1, _Iter1> __search_impl(_Iter1 __first1, _Sent1 __last1,...@@ -170,7 +170,7 @@ pair<_Iter1, _Iter1> __search_impl(_Iter1 __first1, _Sent1 __last1,
170}170}
171171
172template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>172template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
173_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17173_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
174_ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,174_ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
175 _ForwardIterator2 __first2, _ForwardIterator2 __last2,175 _ForwardIterator2 __first2, _ForwardIterator2 __last2,
176 _BinaryPredicate __pred) {176 _BinaryPredicate __pred) {
...@@ -181,17 +181,15 @@ _ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,...@@ -181,17 +181,15 @@ _ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
181}181}
182182
183template <class _ForwardIterator1, class _ForwardIterator2>183template <class _ForwardIterator1, class _ForwardIterator2>
184_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17184_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
185_ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,185_ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
186 _ForwardIterator2 __first2, _ForwardIterator2 __last2) {186 _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
187 using __v1 = typename iterator_traits<_ForwardIterator1>::value_type;187 return std::search(__first1, __last1, __first2, __last2, __equal_to());
188 using __v2 = typename iterator_traits<_ForwardIterator2>::value_type;
189 return std::search(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
190}188}
191189
192#if _LIBCPP_STD_VER > 14190#if _LIBCPP_STD_VER > 14
193template <class _ForwardIterator, class _Searcher>191template <class _ForwardIterator, class _Searcher>
194_LIBCPP_NODISCARD_EXT _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator192_LIBCPP_NODISCARD_EXT _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
195search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher& __s) {193search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher& __s) {
196 return __s(__f, __l).first;194 return __s(__f, __l).first;
197}195}
lib/libcxx/include/__algorithm/search_n.h+8-8
...@@ -19,6 +19,7 @@...@@ -19,6 +19,7 @@
19#include <__iterator/distance.h>19#include <__iterator/distance.h>
20#include <__iterator/iterator_traits.h>20#include <__iterator/iterator_traits.h>
21#include <__ranges/concepts.h>21#include <__ranges/concepts.h>
22#include <__utility/convert_to_integral.h>
22#include <__utility/pair.h>23#include <__utility/pair.h>
23#include <type_traits> // __convert_to_integral24#include <type_traits> // __convert_to_integral
2425
...@@ -29,7 +30,7 @@...@@ -29,7 +30,7 @@
29_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
3031
31template <class _AlgPolicy, class _Pred, class _Iter, class _Sent, class _SizeT, class _Type, class _Proj>32template <class _AlgPolicy, class _Pred, class _Iter, class _Sent, class _SizeT, class _Type, class _Proj>
32_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1133_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
33pair<_Iter, _Iter> __search_n_forward_impl(_Iter __first, _Sent __last,34pair<_Iter, _Iter> __search_n_forward_impl(_Iter __first, _Sent __last,
34 _SizeT __count,35 _SizeT __count,
35 const _Type& __value,36 const _Type& __value,
...@@ -71,7 +72,7 @@ pair<_Iter, _Iter> __search_n_forward_impl(_Iter __first, _Sent __last,...@@ -71,7 +72,7 @@ pair<_Iter, _Iter> __search_n_forward_impl(_Iter __first, _Sent __last,
71}72}
7273
73template <class _AlgPolicy, class _Pred, class _Iter, class _Sent, class _SizeT, class _Type, class _Proj, class _DiffT>74template <class _AlgPolicy, class _Pred, class _Iter, class _Sent, class _SizeT, class _Type, class _Proj, class _DiffT>
74_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1175_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
75std::pair<_Iter, _Iter> __search_n_random_access_impl(_Iter __first, _Sent __last,76std::pair<_Iter, _Iter> __search_n_random_access_impl(_Iter __first, _Sent __last,
76 _SizeT __count,77 _SizeT __count,
77 const _Type& __value,78 const _Type& __value,
...@@ -122,7 +123,7 @@ template <class _Iter, class _Sent,...@@ -122,7 +123,7 @@ template <class _Iter, class _Sent,
122 class _Type,123 class _Type,
123 class _Pred,124 class _Pred,
124 class _Proj>125 class _Proj>
125_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11126_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
126pair<_Iter, _Iter> __search_n_impl(_Iter __first, _Sent __last,127pair<_Iter, _Iter> __search_n_impl(_Iter __first, _Sent __last,
127 _DiffT __count,128 _DiffT __count,
128 const _Type& __value,129 const _Type& __value,
...@@ -142,7 +143,7 @@ template <class _Iter1, class _Sent1,...@@ -142,7 +143,7 @@ template <class _Iter1, class _Sent1,
142 class _Type,143 class _Type,
143 class _Pred,144 class _Pred,
144 class _Proj>145 class _Proj>
145_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11146_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
146pair<_Iter1, _Iter1> __search_n_impl(_Iter1 __first, _Sent1 __last,147pair<_Iter1, _Iter1> __search_n_impl(_Iter1 __first, _Sent1 __last,
147 _DiffT __count,148 _DiffT __count,
148 const _Type& __value,149 const _Type& __value,
...@@ -158,7 +159,7 @@ pair<_Iter1, _Iter1> __search_n_impl(_Iter1 __first, _Sent1 __last,...@@ -158,7 +159,7 @@ pair<_Iter1, _Iter1> __search_n_impl(_Iter1 __first, _Sent1 __last,
158}159}
159160
160template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate>161template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate>
161_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17162_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
162_ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last,163_ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last,
163 _Size __count,164 _Size __count,
164 const _Tp& __value,165 const _Tp& __value,
...@@ -170,10 +171,9 @@ _ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last,...@@ -170,10 +171,9 @@ _ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last,
170}171}
171172
172template <class _ForwardIterator, class _Size, class _Tp>173template <class _ForwardIterator, class _Size, class _Tp>
173_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17174_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
174_ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value) {175_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());
176 return std::search_n(__first, __last, std::__convert_to_integral(__count), __value, __equal_to<__v, _Tp>());
177}177}
178178
179_LIBCPP_END_NAMESPACE_STD179_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/set_difference.h+10-8
...@@ -12,6 +12,7 @@...@@ -12,6 +12,7 @@
12#include <__algorithm/comp.h>12#include <__algorithm/comp.h>
13#include <__algorithm/comp_ref_type.h>13#include <__algorithm/comp_ref_type.h>
14#include <__algorithm/copy.h>14#include <__algorithm/copy.h>
15#include <__algorithm/iterator_operations.h>
15#include <__config>16#include <__config>
16#include <__functional/identity.h>17#include <__functional/identity.h>
17#include <__functional/invoke.h>18#include <__functional/invoke.h>
...@@ -26,8 +27,8 @@...@@ -26,8 +27,8 @@
2627
27_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2829
29template < class _Comp, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>30template <class _AlgPolicy, 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> >31_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__remove_cvref_t<_InIter1>, __remove_cvref_t<_OutIter> >
31__set_difference(32__set_difference(
32 _InIter1&& __first1, _Sent1&& __last1, _InIter2&& __first2, _Sent2&& __last2, _OutIter&& __result, _Comp&& __comp) {33 _InIter1&& __first1, _Sent1&& __last1, _InIter2&& __first2, _Sent2&& __last2, _OutIter&& __result, _Comp&& __comp) {
33 while (__first1 != __last1 && __first2 != __last2) {34 while (__first1 != __last1 && __first2 != __last2) {
...@@ -42,29 +43,30 @@ __set_difference(...@@ -42,29 +43,30 @@ __set_difference(
42 ++__first2;43 ++__first2;
43 }44 }
44 }45 }
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));
46}47}
4748
48template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>49template <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(
50 _InputIterator1 __first1,51 _InputIterator1 __first1,
51 _InputIterator1 __last1,52 _InputIterator1 __last1,
52 _InputIterator2 __first2,53 _InputIterator2 __first2,
53 _InputIterator2 __last2,54 _InputIterator2 __last2,
54 _OutputIterator __result,55 _OutputIterator __result,
55 _Compare __comp) {56 _Compare __comp) {
56 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;57 return std::__set_difference<_ClassicAlgPolicy, __comp_ref_type<_Compare> >(
57 return std::__set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp).second;58 __first1, __last1, __first2, __last2, __result, __comp)
59 .second;
58}60}
5961
60template <class _InputIterator1, class _InputIterator2, class _OutputIterator>62template <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(
62 _InputIterator1 __first1,64 _InputIterator1 __first1,
63 _InputIterator1 __last1,65 _InputIterator1 __last1,
64 _InputIterator2 __first2,66 _InputIterator2 __first2,
65 _InputIterator2 __last2,67 _InputIterator2 __last2,
66 _OutputIterator __result) {68 _OutputIterator __result) {
67 return std::__set_difference(69 return std::__set_difference<_ClassicAlgPolicy>(
68 __first1,70 __first1,
69 __last1,71 __last1,
70 __first2,72 __first2,
lib/libcxx/include/__algorithm/set_intersection.h+5-6
...@@ -30,13 +30,13 @@ struct __set_intersection_result {...@@ -30,13 +30,13 @@ struct __set_intersection_result {
30 _OutIter __out_;30 _OutIter __out_;
3131
32 // need a constructor as C++03 aggregate init is hard32 // need a constructor as C++03 aggregate init is hard
33 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1733 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
34 __set_intersection_result(_InIter1&& __in_iter1, _InIter2&& __in_iter2, _OutIter&& __out_iter)34 __set_intersection_result(_InIter1&& __in_iter1, _InIter2&& __in_iter2, _OutIter&& __out_iter)
35 : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}35 : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}
36};36};
3737
38template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>38template <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>
40__set_intersection(40__set_intersection(
41 _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {41 _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {
42 while (__first1 != __last1 && __first2 != __last2) {42 while (__first1 != __last1 && __first2 != __last2) {
...@@ -59,15 +59,14 @@ __set_intersection(...@@ -59,15 +59,14 @@ __set_intersection(
59}59}
6060
61template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>61template <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(
63 _InputIterator1 __first1,63 _InputIterator1 __first1,
64 _InputIterator1 __last1,64 _InputIterator1 __last1,
65 _InputIterator2 __first2,65 _InputIterator2 __first2,
66 _InputIterator2 __last2,66 _InputIterator2 __last2,
67 _OutputIterator __result,67 _OutputIterator __result,
68 _Compare __comp) {68 _Compare __comp) {
69 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;69 return std::__set_intersection<_ClassicAlgPolicy, __comp_ref_type<_Compare> >(
70 return std::__set_intersection<_ClassicAlgPolicy, _Comp_ref>(
71 std::move(__first1),70 std::move(__first1),
72 std::move(__last1),71 std::move(__last1),
73 std::move(__first2),72 std::move(__first2),
...@@ -78,7 +77,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_i...@@ -78,7 +77,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_i
78}77}
7978
80template <class _InputIterator1, class _InputIterator2, class _OutputIterator>79template <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(
82 _InputIterator1 __first1,81 _InputIterator1 __first1,
83 _InputIterator1 __last1,82 _InputIterator1 __last1,
84 _InputIterator2 __first2,83 _InputIterator2 __first2,
lib/libcxx/include/__algorithm/set_symmetric_difference.h+10-9
...@@ -12,9 +12,11 @@...@@ -12,9 +12,11 @@
12#include <__algorithm/comp.h>12#include <__algorithm/comp.h>
13#include <__algorithm/comp_ref_type.h>13#include <__algorithm/comp_ref_type.h>
14#include <__algorithm/copy.h>14#include <__algorithm/copy.h>
15#include <__algorithm/iterator_operations.h>
15#include <__config>16#include <__config>
16#include <__iterator/iterator_traits.h>17#include <__iterator/iterator_traits.h>
17#include <__utility/move.h>18#include <__utility/move.h>
19#include <__utility/pair.h>
1820
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header22# pragma GCC system_header
...@@ -29,18 +31,18 @@ struct __set_symmetric_difference_result {...@@ -29,18 +31,18 @@ struct __set_symmetric_difference_result {
29 _OutIter __out_;31 _OutIter __out_;
3032
31 // need a constructor as C++03 aggregate init is hard33 // need a constructor as C++03 aggregate init is hard
32 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1734 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
33 __set_symmetric_difference_result(_InIter1&& __in_iter1, _InIter2&& __in_iter2, _OutIter&& __out_iter)35 __set_symmetric_difference_result(_InIter1&& __in_iter1, _InIter2&& __in_iter2, _OutIter&& __out_iter)
34 : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}36 : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}
35};37};
3638
37template <class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>39template <class _AlgPolicy, 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>40_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>
39__set_symmetric_difference(41__set_symmetric_difference(
40 _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {42 _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {
41 while (__first1 != __last1) {43 while (__first1 != __last1) {
42 if (__first2 == __last2) {44 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));
44 return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>(46 return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>(
45 std::move(__ret1.first), std::move(__first2), std::move((__ret1.second)));47 std::move(__ret1.first), std::move(__first2), std::move((__ret1.second)));
46 }48 }
...@@ -58,21 +60,20 @@ __set_symmetric_difference(...@@ -58,21 +60,20 @@ __set_symmetric_difference(
58 ++__first2;60 ++__first2;
59 }61 }
60 }62 }
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));
62 return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>(64 return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>(
63 std::move(__first1), std::move(__ret2.first), std::move((__ret2.second)));65 std::move(__first1), std::move(__ret2.first), std::move((__ret2.second)));
64}66}
6567
66template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>68template <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(
68 _InputIterator1 __first1,70 _InputIterator1 __first1,
69 _InputIterator1 __last1,71 _InputIterator1 __last1,
70 _InputIterator2 __first2,72 _InputIterator2 __first2,
71 _InputIterator2 __last2,73 _InputIterator2 __last2,
72 _OutputIterator __result,74 _OutputIterator __result,
73 _Compare __comp) {75 _Compare __comp) {
74 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;76 return std::__set_symmetric_difference<_ClassicAlgPolicy, __comp_ref_type<_Compare> >(
75 return std::__set_symmetric_difference<_Comp_ref>(
76 std::move(__first1),77 std::move(__first1),
77 std::move(__last1),78 std::move(__last1),
78 std::move(__first2),79 std::move(__first2),
...@@ -83,7 +84,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_symmetri...@@ -83,7 +84,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_symmetri
83}84}
8485
85template <class _InputIterator1, class _InputIterator2, class _OutputIterator>86template <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(
87 _InputIterator1 __first1,88 _InputIterator1 __first1,
88 _InputIterator1 __last1,89 _InputIterator1 __last1,
89 _InputIterator2 __first2,90 _InputIterator2 __first2,
lib/libcxx/include/__algorithm/set_union.h+10-9
...@@ -12,9 +12,11 @@...@@ -12,9 +12,11 @@
12#include <__algorithm/comp.h>12#include <__algorithm/comp.h>
13#include <__algorithm/comp_ref_type.h>13#include <__algorithm/comp_ref_type.h>
14#include <__algorithm/copy.h>14#include <__algorithm/copy.h>
15#include <__algorithm/iterator_operations.h>
15#include <__config>16#include <__config>
16#include <__iterator/iterator_traits.h>17#include <__iterator/iterator_traits.h>
17#include <__utility/move.h>18#include <__utility/move.h>
19#include <__utility/pair.h>
1820
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header22# pragma GCC system_header
...@@ -29,17 +31,17 @@ struct __set_union_result {...@@ -29,17 +31,17 @@ struct __set_union_result {
29 _OutIter __out_;31 _OutIter __out_;
3032
31 // need a constructor as C++03 aggregate init is hard33 // need a constructor as C++03 aggregate init is hard
32 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1734 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
33 __set_union_result(_InIter1&& __in_iter1, _InIter2&& __in_iter2, _OutIter&& __out_iter)35 __set_union_result(_InIter1&& __in_iter1, _InIter2&& __in_iter2, _OutIter&& __out_iter)
34 : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}36 : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}
35};37};
3638
37template <class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>39template <class _AlgPolicy, 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(40_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_union_result<_InIter1, _InIter2, _OutIter> __set_union(
39 _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {41 _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {
40 for (; __first1 != __last1; ++__result) {42 for (; __first1 != __last1; ++__result) {
41 if (__first2 == __last2) {43 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));
43 return __set_union_result<_InIter1, _InIter2, _OutIter>(45 return __set_union_result<_InIter1, _InIter2, _OutIter>(
44 std::move(__ret1.first), std::move(__first2), std::move((__ret1.second)));46 std::move(__ret1.first), std::move(__first2), std::move((__ret1.second)));
45 }47 }
...@@ -54,21 +56,20 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 __set_union_result<_InIter1,...@@ -54,21 +56,20 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 __set_union_result<_InIter1,
54 ++__first1;56 ++__first1;
55 }57 }
56 }58 }
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));
58 return __set_union_result<_InIter1, _InIter2, _OutIter>(60 return __set_union_result<_InIter1, _InIter2, _OutIter>(
59 std::move(__first1), std::move(__ret2.first), std::move((__ret2.second)));61 std::move(__first1), std::move(__ret2.first), std::move((__ret2.second)));
60}62}
6163
62template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>64template <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(
64 _InputIterator1 __first1,66 _InputIterator1 __first1,
65 _InputIterator1 __last1,67 _InputIterator1 __last1,
66 _InputIterator2 __first2,68 _InputIterator2 __first2,
67 _InputIterator2 __last2,69 _InputIterator2 __last2,
68 _OutputIterator __result,70 _OutputIterator __result,
69 _Compare __comp) {71 _Compare __comp) {
70 typedef typename __comp_ref_type<_Compare>::type _Comp_ref;72 return std::__set_union<_ClassicAlgPolicy, __comp_ref_type<_Compare> >(
71 return std::__set_union<_Comp_ref>(
72 std::move(__first1),73 std::move(__first1),
73 std::move(__last1),74 std::move(__last1),
74 std::move(__first2),75 std::move(__first2),
...@@ -79,7 +80,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_union(...@@ -79,7 +80,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_union(
79}80}
8081
81template <class _InputIterator1, class _InputIterator2, class _OutputIterator>82template <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(
83 _InputIterator1 __first1,84 _InputIterator1 __first1,
84 _InputIterator1 __last1,85 _InputIterator1 __last1,
85 _InputIterator2 __first2,86 _InputIterator2 __first2,
lib/libcxx/include/__algorithm/shuffle.h+13-12
...@@ -16,6 +16,7 @@...@@ -16,6 +16,7 @@
16#include <__random/uniform_int_distribution.h>16#include <__random/uniform_int_distribution.h>
17#include <__utility/forward.h>17#include <__utility/forward.h>
18#include <__utility/move.h>18#include <__utility/move.h>
19#include <__utility/swap.h>
19#include <cstddef>20#include <cstddef>
20#include <cstdint>21#include <cstdint>
2122
...@@ -31,9 +32,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -31,9 +32,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
31class _LIBCPP_TYPE_VIS __libcpp_debug_randomizer {32class _LIBCPP_TYPE_VIS __libcpp_debug_randomizer {
32public:33public:
33 __libcpp_debug_randomizer() {34 __libcpp_debug_randomizer() {
34 __state = __seed();35 __state_ = __seed();
35 __inc = __state + 0xda3e39cb94b95bdbULL;36 __inc_ = __state_ + 0xda3e39cb94b95bdbULL;
36 __inc = (__inc << 1) | 1;37 __inc_ = (__inc_ << 1) | 1;
37 }38 }
38 typedef uint_fast32_t result_type;39 typedef uint_fast32_t result_type;
3940
...@@ -41,8 +42,8 @@ public:...@@ -41,8 +42,8 @@ public:
41 static const result_type _Max = 0xFFFFFFFF;42 static const result_type _Max = 0xFFFFFFFF;
4243
43 _LIBCPP_HIDE_FROM_ABI result_type operator()() {44 _LIBCPP_HIDE_FROM_ABI result_type operator()() {
44 uint_fast64_t __oldstate = __state;45 uint_fast64_t __oldstate = __state_;
45 __state = __oldstate * 6364136223846793005ULL + __inc;46 __state_ = __oldstate * 6364136223846793005ULL + __inc_;
46 return __oldstate >> 32;47 return __oldstate >> 32;
47 }48 }
4849
...@@ -50,8 +51,8 @@ public:...@@ -50,8 +51,8 @@ public:
50 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR result_type max() { return _Max; }51 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR result_type max() { return _Max; }
5152
52private:53private:
53 uint_fast64_t __state;54 uint_fast64_t __state_;
54 uint_fast64_t __inc;55 uint_fast64_t __inc_;
55 _LIBCPP_HIDE_FROM_ABI static uint_fast64_t __seed() {56 _LIBCPP_HIDE_FROM_ABI static uint_fast64_t __seed() {
56#ifdef _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY_SEED57#ifdef _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY_SEED
57 return _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY_SEED;58 return _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY_SEED;
...@@ -93,7 +94,7 @@ public:...@@ -93,7 +94,7 @@ public:
93_LIBCPP_FUNC_VIS __rs_default __rs_get();94_LIBCPP_FUNC_VIS __rs_default __rs_get();
9495
95template <class _RandomAccessIterator>96template <class _RandomAccessIterator>
96_LIBCPP_DEPRECATED_IN_CXX14 void97_LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX14 void
97random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)98random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
98{99{
99 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;100 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
...@@ -114,7 +115,7 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)...@@ -114,7 +115,7 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
114}115}
115116
116template <class _RandomAccessIterator, class _RandomNumberGenerator>117template <class _RandomAccessIterator, class _RandomNumberGenerator>
117_LIBCPP_DEPRECATED_IN_CXX14 void118_LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX14 void
118random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,119random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
119#ifndef _LIBCPP_CXX03_LANG120#ifndef _LIBCPP_CXX03_LANG
120 _RandomNumberGenerator&& __rand)121 _RandomNumberGenerator&& __rand)
...@@ -137,7 +138,7 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,...@@ -137,7 +138,7 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
137#endif138#endif
138139
139template <class _AlgPolicy, class _RandomAccessIterator, class _Sentinel, class _UniformRandomNumberGenerator>140template <class _AlgPolicy, class _RandomAccessIterator, class _Sentinel, class _UniformRandomNumberGenerator>
140_RandomAccessIterator __shuffle(141_LIBCPP_HIDE_FROM_ABI _RandomAccessIterator __shuffle(
141 _RandomAccessIterator __first, _Sentinel __last_sentinel, _UniformRandomNumberGenerator&& __g) {142 _RandomAccessIterator __first, _Sentinel __last_sentinel, _UniformRandomNumberGenerator&& __g) {
142 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;143 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
143 typedef uniform_int_distribution<ptrdiff_t> _Dp;144 typedef uniform_int_distribution<ptrdiff_t> _Dp;
...@@ -161,8 +162,8 @@ _RandomAccessIterator __shuffle(...@@ -161,8 +162,8 @@ _RandomAccessIterator __shuffle(
161}162}
162163
163template <class _RandomAccessIterator, class _UniformRandomNumberGenerator>164template <class _RandomAccessIterator, class _UniformRandomNumberGenerator>
164void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,165_LIBCPP_HIDE_FROM_ABI void
165 _UniformRandomNumberGenerator&& __g) {166shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, _UniformRandomNumberGenerator&& __g) {
166 (void)std::__shuffle<_ClassicAlgPolicy>(167 (void)std::__shuffle<_ClassicAlgPolicy>(
167 std::move(__first), std::move(__last), std::forward<_UniformRandomNumberGenerator>(__g));168 std::move(__first), std::move(__last), std::forward<_UniformRandomNumberGenerator>(__g));
168}169}
lib/libcxx/include/__algorithm/sift_down.h+2-2
...@@ -22,7 +22,7 @@...@@ -22,7 +22,7 @@
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2323
24template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>24template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
25_LIBCPP_CONSTEXPR_AFTER_CXX11 void25_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
26__sift_down(_RandomAccessIterator __first, _Compare&& __comp,26__sift_down(_RandomAccessIterator __first, _Compare&& __comp,
27 typename iterator_traits<_RandomAccessIterator>::difference_type __len,27 typename iterator_traits<_RandomAccessIterator>::difference_type __len,
28 _RandomAccessIterator __start)28 _RandomAccessIterator __start)
...@@ -78,7 +78,7 @@ __sift_down(_RandomAccessIterator __first, _Compare&& __comp,...@@ -78,7 +78,7 @@ __sift_down(_RandomAccessIterator __first, _Compare&& __comp,
78}78}
7979
80template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>80template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
81_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator81_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _RandomAccessIterator
82__floyd_sift_down(_RandomAccessIterator __first, _Compare&& __comp,82__floyd_sift_down(_RandomAccessIterator __first, _Compare&& __comp,
83 typename iterator_traits<_RandomAccessIterator>::difference_type __len)83 typename iterator_traits<_RandomAccessIterator>::difference_type __len)
84{84{
lib/libcxx/include/__algorithm/sort.h+470-174
...@@ -11,19 +11,29 @@...@@ -11,19 +11,29 @@
1111
12#include <__algorithm/comp.h>12#include <__algorithm/comp.h>
13#include <__algorithm/comp_ref_type.h>13#include <__algorithm/comp_ref_type.h>
14#include <__algorithm/iter_swap.h>
14#include <__algorithm/iterator_operations.h>15#include <__algorithm/iterator_operations.h>
15#include <__algorithm/min_element.h>16#include <__algorithm/min_element.h>
16#include <__algorithm/partial_sort.h>17#include <__algorithm/partial_sort.h>
17#include <__algorithm/unwrap_iter.h>18#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>
19#include <__config>23#include <__config>
20#include <__debug>24#include <__debug>
21#include <__debug_utils/randomize_range.h>25#include <__debug_utils/randomize_range.h>
22#include <__functional/operations.h>26#include <__functional/operations.h>
23#include <__functional/ranges_operations.h>27#include <__functional/ranges_operations.h>
24#include <__iterator/iterator_traits.h>28#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>
25#include <climits>35#include <climits>
26#include <memory>36#include <cstdint>
2737
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)38#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29# pragma GCC system_header39# pragma GCC system_header
...@@ -43,7 +53,7 @@ struct _WrapAlgPolicy {...@@ -43,7 +53,7 @@ struct _WrapAlgPolicy {
43 using _Comp = _CompT;53 using _Comp = _CompT;
44 _Comp& __comp;54 _Comp& __comp;
4555
46 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1156 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
47 _WrapAlgPolicy(_Comp& __c) : __comp(__c) {}57 _WrapAlgPolicy(_Comp& __c) : __comp(__c) {}
48};58};
4959
...@@ -62,7 +72,7 @@ struct _UnwrapAlgPolicy {...@@ -62,7 +72,7 @@ struct _UnwrapAlgPolicy {
62 using _AlgPolicy = _ClassicAlgPolicy;72 using _AlgPolicy = _ClassicAlgPolicy;
63 using _Comp = _CompT;73 using _Comp = _CompT;
6474
65 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static75 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static
66 _Comp __get_comp(_Comp __comp) { return __comp; }76 _Comp __get_comp(_Comp __comp) { return __comp; }
67};77};
6878
...@@ -73,14 +83,15 @@ struct _UnwrapAlgPolicy<_WrapAlgPolicy<_Ts...> > {...@@ -73,14 +83,15 @@ struct _UnwrapAlgPolicy<_WrapAlgPolicy<_Ts...> > {
73 using _AlgPolicy = typename _Wrapped::_AlgPolicy;83 using _AlgPolicy = typename _Wrapped::_AlgPolicy;
74 using _Comp = typename _Wrapped::_Comp;84 using _Comp = typename _Wrapped::_Comp;
7585
76 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static86 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static
77 _Comp __get_comp(_Wrapped& __w) { return __w.__comp; }87 _Comp __get_comp(_Wrapped& __w) { return __w.__comp; }
78};88};
7989
80// stable, 2-3 compares, 0-2 swaps90// stable, 2-3 compares, 0-2 swaps
8191
82template <class _AlgPolicy, class _Compare, class _ForwardIterator>92template <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,
84 _Compare __c) {95 _Compare __c) {
85 using _Ops = _IterOps<_AlgPolicy>;96 using _Ops = _IterOps<_AlgPolicy>;
8697
...@@ -118,10 +129,10 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 unsigned __sort3(_ForwardIterator __x, _ForwardIte...@@ -118,10 +129,10 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 unsigned __sort3(_ForwardIterator __x, _ForwardIte
118// stable, 3-6 compares, 0-5 swaps129// stable, 3-6 compares, 0-5 swaps
119130
120template <class _AlgPolicy, class _Compare, class _ForwardIterator>131template <class _AlgPolicy, class _Compare, class _ForwardIterator>
132_LIBCPP_HIDE_FROM_ABI
121unsigned __sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, _ForwardIterator __x4,133unsigned __sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, _ForwardIterator __x4,
122 _Compare __c) {134 _Compare __c) {
123 using _Ops = _IterOps<_AlgPolicy>;135 using _Ops = _IterOps<_AlgPolicy>;
124
125 unsigned __r = std::__sort3<_AlgPolicy, _Compare>(__x1, __x2, __x3, __c);136 unsigned __r = std::__sort3<_AlgPolicy, _Compare>(__x1, __x2, __x3, __c);
126 if (__c(*__x4, *__x3)) {137 if (__c(*__x4, *__x3)) {
127 _Ops::iter_swap(__x3, __x4);138 _Ops::iter_swap(__x3, __x4);
...@@ -171,12 +182,12 @@ _LIBCPP_HIDDEN unsigned __sort5(_ForwardIterator __x1, _ForwardIterator __x2, _F...@@ -171,12 +182,12 @@ _LIBCPP_HIDDEN unsigned __sort5(_ForwardIterator __x1, _ForwardIterator __x2, _F
171}182}
172183
173template <class _AlgPolicy, class _Compare, class _ForwardIterator>184template <class _AlgPolicy, class _Compare, class _ForwardIterator>
174_LIBCPP_HIDDEN unsigned __sort5_wrap_policy(185_LIBCPP_HIDE_FROM_ABI unsigned __sort5_wrap_policy(
175 _ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, _ForwardIterator __x4, _ForwardIterator __x5,186 _ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, _ForwardIterator __x4, _ForwardIterator __x5,
176 _Compare __c) {187 _Compare __c) {
177 using _WrappedComp = typename _WrapAlgPolicy<_AlgPolicy, _Compare>::type;188 using _WrappedComp = typename _WrapAlgPolicy<_AlgPolicy, _Compare>::type;
178 _WrappedComp __wrapped_comp(__c);189 _WrappedComp __wrapped_comp(__c);
179 return std::__sort5<_WrappedComp>(190 return std::__sort5<_WrappedComp, _ForwardIterator>(
180 std::move(__x1), std::move(__x2), std::move(__x3), std::move(__x4), std::move(__x5), __wrapped_comp);191 std::move(__x1), std::move(__x2), std::move(__x3), std::move(__x4), std::move(__x5), __wrapped_comp);
181}192}
182193
...@@ -201,6 +212,13 @@ using __use_branchless_sort =...@@ -201,6 +212,13 @@ using __use_branchless_sort =
201 integral_constant<bool, __is_cpp17_contiguous_iterator<_Iter>::value && sizeof(_Tp) <= sizeof(void*) &&212 integral_constant<bool, __is_cpp17_contiguous_iterator<_Iter>::value && sizeof(_Tp) <= sizeof(void*) &&
202 is_arithmetic<_Tp>::value && __is_simple_comparator<_Compare>::value>;213 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
204// Ensures that __c(*__x, *__y) is true by swapping *__x and *__y if necessary.222// Ensures that __c(*__x, *__y) is true by swapping *__x and *__y if necessary.
205template <class _Compare, class _RandomAccessIterator>223template <class _Compare, class _RandomAccessIterator>
206inline _LIBCPP_HIDE_FROM_ABI void __cond_swap(_RandomAccessIterator __x, _RandomAccessIterator __y, _Compare __c) {224inline _LIBCPP_HIDE_FROM_ABI void __cond_swap(_RandomAccessIterator __x, _RandomAccessIterator __y, _Compare __c) {
...@@ -231,8 +249,8 @@ template <class, class _Compare, class _RandomAccessIterator>...@@ -231,8 +249,8 @@ template <class, class _Compare, class _RandomAccessIterator>
231inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>249inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
232__sort3_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,250__sort3_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
233 _Compare __c) {251 _Compare __c) {
234 _VSTD::__cond_swap<_Compare>(__x2, __x3, __c);252 std::__cond_swap<_Compare>(__x2, __x3, __c);
235 _VSTD::__partially_sorted_swap<_Compare>(__x1, __x2, __x3, __c);253 std::__partially_sorted_swap<_Compare>(__x1, __x2, __x3, __c);
236}254}
237255
238template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>256template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
...@@ -246,11 +264,11 @@ template <class, class _Compare, class _RandomAccessIterator>...@@ -246,11 +264,11 @@ template <class, class _Compare, class _RandomAccessIterator>
246inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>264inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
247__sort4_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,265__sort4_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
248 _RandomAccessIterator __x4, _Compare __c) {266 _RandomAccessIterator __x4, _Compare __c) {
249 _VSTD::__cond_swap<_Compare>(__x1, __x3, __c);267 std::__cond_swap<_Compare>(__x1, __x3, __c);
250 _VSTD::__cond_swap<_Compare>(__x2, __x4, __c);268 std::__cond_swap<_Compare>(__x2, __x4, __c);
251 _VSTD::__cond_swap<_Compare>(__x1, __x2, __c);269 std::__cond_swap<_Compare>(__x1, __x2, __c);
252 _VSTD::__cond_swap<_Compare>(__x3, __x4, __c);270 std::__cond_swap<_Compare>(__x3, __x4, __c);
253 _VSTD::__cond_swap<_Compare>(__x2, __x3, __c);271 std::__cond_swap<_Compare>(__x2, __x3, __c);
254}272}
255273
256template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>274template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
...@@ -260,16 +278,21 @@ __sort4_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2,...@@ -260,16 +278,21 @@ __sort4_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2,
260 std::__sort4<_AlgPolicy, _Compare>(__x1, __x2, __x3, __x4, __c);278 std::__sort4<_AlgPolicy, _Compare>(__x1, __x2, __x3, __x4, __c);
261}279}
262280
263template <class, class _Compare, class _RandomAccessIterator>281template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
264inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>282inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
265__sort5_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,283__sort5_maybe_branchless(
266 _RandomAccessIterator __x4, _RandomAccessIterator __x5, _Compare __c) {284 _RandomAccessIterator __x1,
267 _VSTD::__cond_swap<_Compare>(__x1, __x2, __c);285 _RandomAccessIterator __x2,
268 _VSTD::__cond_swap<_Compare>(__x4, __x5, __c);286 _RandomAccessIterator __x3,
269 _VSTD::__partially_sorted_swap<_Compare>(__x3, __x4, __x5, __c);287 _RandomAccessIterator __x4,
270 _VSTD::__cond_swap<_Compare>(__x2, __x5, __c);288 _RandomAccessIterator __x5,
271 _VSTD::__partially_sorted_swap<_Compare>(__x1, __x3, __x4, __c);289 _Compare __c) {
272 _VSTD::__partially_sorted_swap<_Compare>(__x2, __x3, __x4, __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);
273}296}
274297
275template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>298template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
...@@ -281,7 +304,8 @@ __sort5_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2,...@@ -281,7 +304,8 @@ __sort5_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2,
281304
282// Assumes size > 0305// Assumes size > 0
283template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>306template <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,
285 _Compare __comp) {309 _Compare __comp) {
286 _BidirectionalIterator __lm1 = __last;310 _BidirectionalIterator __lm1 = __last;
287 for (--__lm1; __first != __lm1; ++__first) {311 for (--__lm1; __first != __lm1; ++__first) {
...@@ -291,32 +315,48 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 void __selection_sort(_BidirectionalIterator __fir...@@ -291,32 +315,48 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 void __selection_sort(_BidirectionalIterator __fir
291 }315 }
292}316}
293317
318// Sort the iterator range [__first, __last) using the comparator __comp using
319// the insertion sort algorithm.
294template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>320template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
321_LIBCPP_HIDE_FROM_ABI
295void __insertion_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) {322void __insertion_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) {
296 using _Ops = _IterOps<_AlgPolicy>;323 using _Ops = _IterOps<_AlgPolicy>;
297324
298 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;325 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
299 if (__first != __last) {326 if (__first == __last)
300 _BidirectionalIterator __i = __first;327 return;
301 for (++__i; __i != __last; ++__i) {328 _BidirectionalIterator __i = __first;
302 _BidirectionalIterator __j = __i;329 for (++__i; __i != __last; ++__i) {
303 value_type __t(_Ops::__iter_move(__j));330 _BidirectionalIterator __j = __i;
304 for (_BidirectionalIterator __k = __i; __k != __first && __comp(__t, *--__k); --__j)331 --__j;
332 if (__comp(*__i, *__j)) {
333 value_type __t(_Ops::__iter_move(__i));
334 _BidirectionalIterator __k = __j;
335 __j = __i;
336 do {
305 *__j = _Ops::__iter_move(__k);337 *__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);
307 }341 }
308 }342 }
309}343}
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.
311template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>350template <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) {
313 using _Ops = _IterOps<_AlgPolicy>;353 using _Ops = _IterOps<_AlgPolicy>;
314
315 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;354 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
316 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;355 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
317 _RandomAccessIterator __j = __first + difference_type(2);356 if (__first == __last)
318 std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), __j, __comp);357 return;
319 for (_RandomAccessIterator __i = __j + difference_type(1); __i != __last; ++__i) {358 for (_RandomAccessIterator __i = __first + difference_type(1); __i != __last; ++__i) {
359 _RandomAccessIterator __j = __i - difference_type(1);
320 if (__comp(*__i, *__j)) {360 if (__comp(*__i, *__j)) {
321 value_type __t(_Ops::__iter_move(__i));361 value_type __t(_Ops::__iter_move(__i));
322 _RandomAccessIterator __k = __j;362 _RandomAccessIterator __k = __j;
...@@ -324,15 +364,14 @@ void __insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __l...@@ -324,15 +364,14 @@ void __insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __l
324 do {364 do {
325 *__j = _Ops::__iter_move(__k);365 *__j = _Ops::__iter_move(__k);
326 __j = __k;366 __j = __k;
327 } while (__j != __first && __comp(__t, *--__k));367 } while (__comp(__t, *--__k)); // No need for bounds check due to the assumption stated above.
328 *__j = _VSTD::move(__t);368 *__j = std::move(__t);
329 }369 }
330 __j = __i;
331 }370 }
332}371}
333372
334template <class _WrappedComp, class _RandomAccessIterator>373template <class _WrappedComp, class _RandomAccessIterator>
335bool __insertion_sort_incomplete(374_LIBCPP_HIDDEN bool __insertion_sort_incomplete(
336 _RandomAccessIterator __first, _RandomAccessIterator __last, _WrappedComp __wrapped_comp) {375 _RandomAccessIterator __first, _RandomAccessIterator __last, _WrappedComp __wrapped_comp) {
337 using _Unwrap = _UnwrapAlgPolicy<_WrappedComp>;376 using _Unwrap = _UnwrapAlgPolicy<_WrappedComp>;
338 using _AlgPolicy = typename _Unwrap::_AlgPolicy;377 using _AlgPolicy = typename _Unwrap::_AlgPolicy;
...@@ -348,7 +387,7 @@ bool __insertion_sort_incomplete(...@@ -348,7 +387,7 @@ bool __insertion_sort_incomplete(
348 return true;387 return true;
349 case 2:388 case 2:
350 if (__comp(*--__last, *__first))389 if (__comp(*--__last, *__first))
351 _IterOps<_AlgPolicy>::iter_swap(__first, __last);390 _Ops::iter_swap(__first, __last);
352 return true;391 return true;
353 case 3:392 case 3:
354 std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), --__last, __comp);393 std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), --__last, __comp);
...@@ -377,7 +416,7 @@ bool __insertion_sort_incomplete(...@@ -377,7 +416,7 @@ bool __insertion_sort_incomplete(
377 *__j = _Ops::__iter_move(__k);416 *__j = _Ops::__iter_move(__k);
378 __j = __k;417 __j = __k;
379 } while (__j != __first && __comp(__t, *--__k));418 } while (__j != __first && __comp(__t, *--__k));
380 *__j = _VSTD::move(__t);419 *__j = std::move(__t);
381 if (++__count == __limit)420 if (++__count == __limit)
382 return ++__i == __last;421 return ++__i == __last;
383 }422 }
...@@ -387,6 +426,7 @@ bool __insertion_sort_incomplete(...@@ -387,6 +426,7 @@ bool __insertion_sort_incomplete(
387}426}
388427
389template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>428template <class _AlgPolicy, class _Compare, class _BidirectionalIterator>
429_LIBCPP_HIDE_FROM_ABI
390void __insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterator __last1,430void __insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterator __last1,
391 typename iterator_traits<_BidirectionalIterator>::value_type* __first2, _Compare __comp) {431 typename iterator_traits<_BidirectionalIterator>::value_type* __first2, _Compare __comp) {
392 using _Ops = _IterOps<_AlgPolicy>;432 using _Ops = _IterOps<_AlgPolicy>;
...@@ -416,17 +456,336 @@ void __insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterat...@@ -416,17 +456,336 @@ void __insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterat
416 }456 }
417}457}
418458
419template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>459template <class _AlgPolicy, class _RandomAccessIterator>
420void __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,460inline _LIBCPP_HIDE_FROM_ABI void __swap_bitmap_pos(
421 typename iterator_traits<_RandomAccessIterator>::difference_type __depth) {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) {
422 using _Ops = _IterOps<_AlgPolicy>;601 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>;
424 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;684 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
425 typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;685 typedef typename std::iterator_traits<_RandomAccessIterator>::value_type value_type;
426 const difference_type __limit =686 _LIBCPP_ASSERT(__last - __first >= difference_type(3), "");
427 is_trivially_copy_constructible<value_type>::value && is_trivially_copy_assignable<value_type>::value ? 30 : 6;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;
428 while (true) {788 while (true) {
429 __restart:
430 difference_type __len = __last - __first;789 difference_type __len = __last - __first;
431 switch (__len) {790 switch (__len) {
432 case 0:791 case 0:
...@@ -434,7 +793,7 @@ void __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _C...@@ -434,7 +793,7 @@ void __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _C
434 return;793 return;
435 case 2:794 case 2:
436 if (__comp(*--__last, *__first))795 if (__comp(*--__last, *__first))
437 _IterOps<_AlgPolicy>::iter_swap(__first, __last);796 _Ops::iter_swap(__first, __last);
438 return;797 return;
439 case 3:798 case 3:
440 std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), --__last, __comp);799 std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), --__last, __comp);
...@@ -449,127 +808,60 @@ void __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _C...@@ -449,127 +808,60 @@ void __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _C
449 --__last, __comp);808 --__last, __comp);
450 return;809 return;
451 }810 }
452 if (__len <= __limit) {811 // Use insertion sort if the length of the range is below the specified limit.
453 std::__insertion_sort_3<_AlgPolicy, _Compare>(__first, __last, __comp);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 }
454 return;818 return;
455 }819 }
456 // __len > 5
457 if (__depth == 0) {820 if (__depth == 0) {
458 // Fallback to heap sort as Introsort suggests.821 // Fallback to heap sort as Introsort suggests.
459 std::__partial_sort<_AlgPolicy, _Compare>(__first, __last, __last, __comp);822 std::__partial_sort<_AlgPolicy, _Compare>(__first, __last, __last, __comp);
460 return;823 return;
461 }824 }
462 --__depth;825 --__depth;
463 _RandomAccessIterator __m = __first;
464 _RandomAccessIterator __lm1 = __last;
465 --__lm1;
466 unsigned __n_swaps;
467 {826 {
468 difference_type __delta;827 difference_type __half_len = __len / 2;
469 if (__len >= 1000) {828 // Use Tuckey's ninther technique or median of 3 for pivot selection
470 __delta = __len / 2;829 // depending on the length of the range being sorted.
471 __m += __delta;830 if (__len > __ninther_threshold) {
472 __delta /= 2;831 std::__sort3<_AlgPolicy, _Compare>(__first, __first + __half_len, __last - difference_type(1), __comp);
473 __n_swaps = std::__sort5_wrap_policy<_AlgPolicy, _Compare>(832 std::__sort3<_AlgPolicy, _Compare>(
474 __first, __first + __delta, __m, __m + __delta, __lm1, __comp);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);
475 } else {839 } else {
476 __delta = __len / 2;840 std::__sort3<_AlgPolicy, _Compare>(__first + __half_len, __first, __last - difference_type(1), __comp);
477 __m += __delta;
478 __n_swaps = std::__sort3<_AlgPolicy, _Compare>(__first, __m, __lm1, __comp);
479 }841 }
480 }842 }
481 // *__m is median843 // The elements to the left of the current iterator range are already
482 // partition [__first, __m) < *__m and *__m <= [__m, __last)844 // sorted. If the current iterator range to be sorted is not the
483 // (this inhibits tossing elements equivalent to __m around unnecessarily)845 // leftmost part of the entire iterator range and the pivot is same as
484 _RandomAccessIterator __i = __first;846 // the highest element in the range to the left, then we know that all
485 _RandomAccessIterator __j = __lm1;847 // the elements in the range [first, pivot] would be equal to the pivot,
486 // j points beyond range to be tested, *__m is known to be <= *__lm1848 // assuming the equal elements are put on the left side when
487 // The search going up is known to be guarded but the search coming down isn't.849 // partitioned. This also means that we do not need to sort the left
488 // Prime the downward search with a guard.850 // side of the partition.
489 if (!__comp(*__i, *__m)) // if *__first == *__m851 if (!__leftmost && !__comp(*(__first - difference_type(1)), *__first)) {
490 {852 __first = std::__partition_with_equals_on_left<_AlgPolicy, _RandomAccessIterator, _Comp_ref>(
491 // *__first == *__m, *__first doesn't go in first part853 __first, __last, _Comp_ref(__comp));
492 // manually guard downward moving __j against __i854 continue;
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;
569 }855 }
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;
570 // [__first, __i) < *__i and *__i <= [__i+1, __last)862 // [__first, __i) < *__i and *__i <= [__i+1, __last)
571 // If we were given a perfect partition, see if insertion sort is quick...863 // If we were given a perfect partition, see if insertion sort is quick...
572 if (__n_swaps == 0) {864 if (__ret.second) {
573 using _WrappedComp = typename _WrapAlgPolicy<_AlgPolicy, _Compare>::type;865 using _WrappedComp = typename _WrapAlgPolicy<_AlgPolicy, _Compare>::type;
574 _WrappedComp __wrapped_comp(__comp);866 _WrappedComp __wrapped_comp(__comp);
575 bool __fs = std::__insertion_sort_incomplete<_WrappedComp>(__first, __i, __wrapped_comp);867 bool __fs = std::__insertion_sort_incomplete<_WrappedComp>(__first, __i, __wrapped_comp);
...@@ -585,14 +877,11 @@ void __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _C...@@ -585,14 +877,11 @@ void __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _C
585 }877 }
586 }878 }
587 }879 }
588 // sort smaller range with recursive call and larger with tail recursion elimination880 // Sort the left partiton recursively and the right partition with tail recursion elimination.
589 if (__i - __first < __last - __i) {881 std::__introsort<_AlgPolicy, _Compare, _RandomAccessIterator, _UseBitSetPartition>(
590 std::__introsort<_AlgPolicy, _Compare>(__first, __i, __comp, __depth);882 __first, __i, __comp, __depth, __leftmost);
591 __first = ++__i;883 __leftmost = false;
592 } else {884 __first = ++__i;
593 std::__introsort<_AlgPolicy, _Compare>(__i + difference_type(1), __last, __comp, __depth);
594 __last = __i;
595 }
596 }885 }
597}886}
598887
...@@ -616,15 +905,22 @@ inline _LIBCPP_HIDE_FROM_ABI _Number __log2i(_Number __n) {...@@ -616,15 +905,22 @@ inline _LIBCPP_HIDE_FROM_ABI _Number __log2i(_Number __n) {
616}905}
617906
618template <class _WrappedComp, class _RandomAccessIterator>907template <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) {
620 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;909 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
623 using _Unwrap = _UnwrapAlgPolicy<_WrappedComp>;912 using _Unwrap = _UnwrapAlgPolicy<_WrappedComp>;
624 using _AlgPolicy = typename _Unwrap::_AlgPolicy;913 using _AlgPolicy = typename _Unwrap::_AlgPolicy;
625 using _Compare = typename _Unwrap::_Comp;914 using _Compare = typename _Unwrap::_Comp;
626 _Compare __comp = _Unwrap::__get_comp(__wrapped_comp);915 _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);
628}924}
629925
630template <class _Compare, class _Tp>926template <class _Compare, class _Tp>
...@@ -672,11 +968,11 @@ extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long do...@@ -672,11 +968,11 @@ extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long do
672extern template _LIBCPP_FUNC_VIS unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&);968extern 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
674template <class _AlgPolicy, class _RandomAccessIterator, class _Comp>970template <class _AlgPolicy, class _RandomAccessIterator, class _Comp>
675inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17971inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
676void __sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp& __comp) {972void __sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp& __comp) {
677 std::__debug_randomize_range<_AlgPolicy>(__first, __last);973 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>;
680 if (__libcpp_is_constant_evaluated()) {976 if (__libcpp_is_constant_evaluated()) {
681 std::__partial_sort<_AlgPolicy>(__first, __last, __last, __comp);977 std::__partial_sort<_AlgPolicy>(__first, __last, __last, __comp);
682978
...@@ -689,13 +985,13 @@ void __sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, _C...@@ -689,13 +985,13 @@ void __sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, _C
689}985}
690986
691template <class _RandomAccessIterator, class _Comp>987template <class _RandomAccessIterator, class _Comp>
692inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17988inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
693void sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) {989void sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) {
694 std::__sort_impl<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp);990 std::__sort_impl<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp);
695}991}
696992
697template <class _RandomAccessIterator>993template <class _RandomAccessIterator>
698inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17994inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
699void sort(_RandomAccessIterator __first, _RandomAccessIterator __last) {995void sort(_RandomAccessIterator __first, _RandomAccessIterator __last) {
700 std::sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());996 std::sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
701}997}
lib/libcxx/include/__algorithm/sort_heap.h+4-5
...@@ -25,10 +25,9 @@...@@ -25,10 +25,9 @@
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>27template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
28inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1128inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
29void __sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp) {29void __sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp) {
30 using _CompRef = typename __comp_ref_type<_Compare>::type;30 __comp_ref_type<_Compare> __comp_ref = __comp;
31 _CompRef __comp_ref = __comp;
3231
33 using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;32 using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;
34 for (difference_type __n = __last - __first; __n > 1; --__last, (void) --__n)33 for (difference_type __n = __last - __first; __n > 1; --__last, (void) --__n)
...@@ -36,7 +35,7 @@ void __sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _C...@@ -36,7 +35,7 @@ void __sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _C
36}35}
3736
38template <class _RandomAccessIterator, class _Compare>37template <class _RandomAccessIterator, class _Compare>
39inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1738inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
40void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {39void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
41 static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible.");40 static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible.");
42 static_assert(std::is_copy_assignable<_RandomAccessIterator>::value, "Iterators must be copy assignable.");41 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...@@ -45,7 +44,7 @@ void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Com
45}44}
4645
47template <class _RandomAccessIterator>46template <class _RandomAccessIterator>
48inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1747inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
49void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {48void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {
50 std::sort_heap(std::move(__first), std::move(__last),49 std::sort_heap(std::move(__first), std::move(__last),
51 __less<typename iterator_traits<_RandomAccessIterator>::value_type>());50 __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
lib/libcxx/include/__algorithm/stable_partition.h+10-5
...@@ -15,7 +15,12 @@...@@ -15,7 +15,12 @@
15#include <__iterator/advance.h>15#include <__iterator/advance.h>
16#include <__iterator/distance.h>16#include <__iterator/distance.h>
17#include <__iterator/iterator_traits.h>17#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>
19#include <type_traits>24#include <type_traits>
2025
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -25,7 +30,7 @@...@@ -25,7 +30,7 @@
25_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
2631
27template <class _AlgPolicy, class _Predicate, class _ForwardIterator, class _Distance, class _Pair>32template <class _AlgPolicy, class _Predicate, class _ForwardIterator, class _Distance, class _Pair>
28_ForwardIterator33_LIBCPP_HIDE_FROM_ABI _ForwardIterator
29__stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,34__stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,
30 _Distance __len, _Pair __p, forward_iterator_tag __fit)35 _Distance __len, _Pair __p, forward_iterator_tag __fit)
31{36{
...@@ -114,7 +119,7 @@ __second_half_done:...@@ -114,7 +119,7 @@ __second_half_done:
114}119}
115120
116template <class _AlgPolicy, class _Predicate, class _ForwardIterator>121template <class _AlgPolicy, class _Predicate, class _ForwardIterator>
117_ForwardIterator122_LIBCPP_HIDE_FROM_ABI _ForwardIterator
118__stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,123__stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,
119 forward_iterator_tag)124 forward_iterator_tag)
120{125{
...@@ -259,7 +264,7 @@ __second_half_done:...@@ -259,7 +264,7 @@ __second_half_done:
259}264}
260265
261template <class _AlgPolicy, class _Predicate, class _BidirectionalIterator>266template <class _AlgPolicy, class _Predicate, class _BidirectionalIterator>
262_BidirectionalIterator267_LIBCPP_HIDE_FROM_ABI _BidirectionalIterator
263__stable_partition_impl(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,268__stable_partition_impl(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,
264 bidirectional_iterator_tag)269 bidirectional_iterator_tag)
265{270{
...@@ -305,7 +310,7 @@ template <class _AlgPolicy, class _Predicate, class _ForwardIterator, class _Ite...@@ -305,7 +310,7 @@ template <class _AlgPolicy, class _Predicate, class _ForwardIterator, class _Ite
305_LIBCPP_HIDE_FROM_ABI310_LIBCPP_HIDE_FROM_ABI
306_ForwardIterator __stable_partition(311_ForwardIterator __stable_partition(
307 _ForwardIterator __first, _ForwardIterator __last, _Predicate&& __pred, _IterCategory __iter_category) {312 _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>&>(
309 std::move(__first), std::move(__last), __pred, __iter_category);314 std::move(__first), std::move(__last), __pred, __iter_category);
310}315}
311316
lib/libcxx/include/__algorithm/stable_sort.h+8-5
...@@ -16,8 +16,12 @@...@@ -16,8 +16,12 @@
16#include <__algorithm/sort.h>16#include <__algorithm/sort.h>
17#include <__config>17#include <__config>
18#include <__iterator/iterator_traits.h>18#include <__iterator/iterator_traits.h>
19#include <__memory/destruct_n.h>
20#include <__memory/temporary_buffer.h>
21#include <__memory/unique_ptr.h>
19#include <__utility/move.h>22#include <__utility/move.h>
20#include <memory>23#include <__utility/pair.h>
24#include <new>
21#include <type_traits>25#include <type_traits>
2226
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -27,7 +31,7 @@...@@ -27,7 +31,7 @@
27_LIBCPP_BEGIN_NAMESPACE_STD31_LIBCPP_BEGIN_NAMESPACE_STD
2832
29template <class _AlgPolicy, class _Compare, class _InputIterator1, class _InputIterator2>33template <class _AlgPolicy, class _Compare, class _InputIterator1, class _InputIterator2>
30void34_LIBCPP_HIDE_FROM_ABI void
31__merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1,35__merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1,
32 _InputIterator2 __first2, _InputIterator2 __last2,36 _InputIterator2 __first2, _InputIterator2 __last2,
33 typename iterator_traits<_InputIterator1>::value_type* __result, _Compare __comp)37 typename iterator_traits<_InputIterator1>::value_type* __result, _Compare __comp)
...@@ -69,7 +73,7 @@ __merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1,...@@ -69,7 +73,7 @@ __merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1,
69}73}
7074
71template <class _AlgPolicy, class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>75template <class _AlgPolicy, class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
72void76_LIBCPP_HIDE_FROM_ABI void
73__merge_move_assign(_InputIterator1 __first1, _InputIterator1 __last1,77__merge_move_assign(_InputIterator1 __first1, _InputIterator1 __last1,
74 _InputIterator2 __first2, _InputIterator2 __last2,78 _InputIterator2 __first2, _InputIterator2 __last2,
75 _OutputIterator __result, _Compare __comp)79 _OutputIterator __result, _Compare __comp)
...@@ -223,8 +227,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP...@@ -223,8 +227,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
223 __h.reset(__buf.first);227 __h.reset(__buf.first);
224 }228 }
225229
226 using _Comp_ref = typename __comp_ref_type<_Compare>::type;230 std::__stable_sort<_AlgPolicy, __comp_ref_type<_Compare> >(__first, __last, __comp, __len, __buf.first, __buf.second);
227 std::__stable_sort<_AlgPolicy, _Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second);
228}231}
229232
230template <class _RandomAccessIterator, class _Compare>233template <class _RandomAccessIterator, class _Compare>
lib/libcxx/include/__algorithm/swap_ranges.h+3-3
...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222
23// 2+2 iterators: the shorter size will be used.23// 2+2 iterators: the shorter size will be used.
24template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _Sentinel2>24template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _Sentinel2>
25_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1725_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
26pair<_ForwardIterator1, _ForwardIterator2>26pair<_ForwardIterator1, _ForwardIterator2>
27__swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2, _Sentinel2 __last2) {27__swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2, _Sentinel2 __last2) {
28 while (__first1 != __last1 && __first2 != __last2) {28 while (__first1 != __last1 && __first2 != __last2) {
...@@ -36,7 +36,7 @@ __swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2...@@ -36,7 +36,7 @@ __swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2
3636
37// 2+1 iterators: size2 >= size1.37// 2+1 iterators: size2 >= size1.
38template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2>38template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2>
39_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1739_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
40pair<_ForwardIterator1, _ForwardIterator2>40pair<_ForwardIterator1, _ForwardIterator2>
41__swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2) {41__swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2) {
42 while (__first1 != __last1) {42 while (__first1 != __last1) {
...@@ -49,7 +49,7 @@ __swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2...@@ -49,7 +49,7 @@ __swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2
49}49}
5050
51template <class _ForwardIterator1, class _ForwardIterator2>51template <class _ForwardIterator1, class _ForwardIterator2>
52inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator252inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator2
53swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {53swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {
54 return std::__swap_ranges<_ClassicAlgPolicy>(54 return std::__swap_ranges<_ClassicAlgPolicy>(
55 std::move(__first1), std::move(__last1), std::move(__first2)).second;55 std::move(__first1), std::move(__last1), std::move(__first2)).second;
lib/libcxx/include/__algorithm/transform.h+2-2
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
1919
20template <class _InputIterator, class _OutputIterator, class _UnaryOperation>20template <class _InputIterator, class _OutputIterator, class _UnaryOperation>
21inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1721inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
22_OutputIterator22_OutputIterator
23transform(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _UnaryOperation __op)23transform(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _UnaryOperation __op)
24{24{
...@@ -28,7 +28,7 @@ transform(_InputIterator __first, _InputIterator __last, _OutputIterator __resul...@@ -28,7 +28,7 @@ transform(_InputIterator __first, _InputIterator __last, _OutputIterator __resul
28}28}
2929
30template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _BinaryOperation>30template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _BinaryOperation>
31inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1731inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
32_OutputIterator32_OutputIterator
33transform(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,33transform(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,
34 _OutputIterator __result, _BinaryOperation __binary_op)34 _OutputIterator __result, _BinaryOperation __binary_op)
lib/libcxx/include/__algorithm/uniform_random_bit_generator_adaptor.h+5-5
...@@ -36,21 +36,21 @@ template <class _Gen>...@@ -36,21 +36,21 @@ template <class _Gen>
36class _ClassicGenAdaptor {36class _ClassicGenAdaptor {
37private:37private:
38 // The generator is not required to be copyable or movable, so it has to be stored as a reference.38 // 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
41public:41public:
42 using result_type = invoke_result_t<_Gen&>;42 using result_type = invoke_result_t<_Gen&>;
4343
44 _LIBCPP_HIDE_FROM_ABI44 _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(); }
46 _LIBCPP_HIDE_FROM_ABI46 _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
49 _LIBCPP_HIDE_FROM_ABI49 _LIBCPP_HIDE_FROM_ABI
50 constexpr explicit _ClassicGenAdaptor(_Gen& __g) : __gen(__g) {}50 constexpr explicit _ClassicGenAdaptor(_Gen& __g) : __gen_(__g) {}
5151
52 _LIBCPP_HIDE_FROM_ABI52 _LIBCPP_HIDE_FROM_ABI
53 constexpr auto operator()() const { return __gen(); }53 constexpr auto operator()() const { return __gen_(); }
54};54};
5555
56_LIBCPP_END_NAMESPACE_STD56_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/unique.h+4-5
...@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
26// unique26// unique
2727
28template <class _AlgPolicy, class _Iter, class _Sent, class _BinaryPredicate>28template <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>
30__unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {30__unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
31 __first = std::__adjacent_find(__first, __last, __pred);31 __first = std::__adjacent_find(__first, __last, __pred);
32 if (__first != __last) {32 if (__first != __last) {
...@@ -43,16 +43,15 @@ __unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {...@@ -43,16 +43,15 @@ __unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
43}43}
4444
45template <class _ForwardIterator, class _BinaryPredicate>45template <class _ForwardIterator, class _BinaryPredicate>
46_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator46_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
47unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {47unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
48 return std::__unique<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __pred).first;48 return std::__unique<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __pred).first;
49}49}
5050
51template <class _ForwardIterator>51template <class _ForwardIterator>
52_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator52_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
53unique(_ForwardIterator __first, _ForwardIterator __last) {53unique(_ForwardIterator __first, _ForwardIterator __last) {
54 typedef typename iterator_traits<_ForwardIterator>::value_type __v;54 return std::unique(__first, __last, __equal_to());
55 return std::unique(__first, __last, __equal_to<__v>());
56}55}
5756
58_LIBCPP_END_NAMESPACE_STD57_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/unique_copy.h+9-10
...@@ -34,7 +34,7 @@ struct __read_from_tmp_value_tag {};...@@ -34,7 +34,7 @@ struct __read_from_tmp_value_tag {};
34} // namespace __unique_copy_tags34} // namespace __unique_copy_tags
3535
36template <class _AlgPolicy, class _BinaryPredicate, class _InputIterator, class _Sent, class _OutputIterator>36template <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>
38__unique_copy(_InputIterator __first,38__unique_copy(_InputIterator __first,
39 _Sent __last,39 _Sent __last,
40 _OutputIterator __result,40 _OutputIterator __result,
...@@ -56,7 +56,7 @@ __unique_copy(_InputIterator __first,...@@ -56,7 +56,7 @@ __unique_copy(_InputIterator __first,
56}56}
5757
58template <class _AlgPolicy, class _BinaryPredicate, class _ForwardIterator, class _Sent, class _OutputIterator>58template <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>
60__unique_copy(_ForwardIterator __first,60__unique_copy(_ForwardIterator __first,
61 _Sent __last,61 _Sent __last,
62 _OutputIterator __result,62 _OutputIterator __result,
...@@ -78,7 +78,7 @@ __unique_copy(_ForwardIterator __first,...@@ -78,7 +78,7 @@ __unique_copy(_ForwardIterator __first,
78}78}
7979
80template <class _AlgPolicy, class _BinaryPredicate, class _InputIterator, class _Sent, class _InputAndOutputIterator>80template <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>
82__unique_copy(_InputIterator __first,82__unique_copy(_InputIterator __first,
83 _Sent __last,83 _Sent __last,
84 _InputAndOutputIterator __result,84 _InputAndOutputIterator __result,
...@@ -95,27 +95,26 @@ __unique_copy(_InputIterator __first,...@@ -95,27 +95,26 @@ __unique_copy(_InputIterator __first,
95}95}
9696
97template <class _InputIterator, class _OutputIterator, class _BinaryPredicate>97template <class _InputIterator, class _OutputIterator, class _BinaryPredicate>
98inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator98inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
99unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred) {99unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred) {
100 using __algo_tag = typename conditional<100 using __algo_tag = __conditional_t<
101 is_base_of<forward_iterator_tag, typename iterator_traits<_InputIterator>::iterator_category>::value,101 is_base_of<forward_iterator_tag, typename iterator_traits<_InputIterator>::iterator_category>::value,
102 __unique_copy_tags::__reread_from_input_tag,102 __unique_copy_tags::__reread_from_input_tag,
103 typename conditional<103 __conditional_t<
104 is_base_of<forward_iterator_tag, typename iterator_traits<_OutputIterator>::iterator_category>::value &&104 is_base_of<forward_iterator_tag, typename iterator_traits<_OutputIterator>::iterator_category>::value &&
105 is_same< typename iterator_traits<_InputIterator>::value_type,105 is_same< typename iterator_traits<_InputIterator>::value_type,
106 typename iterator_traits<_OutputIterator>::value_type>::value,106 typename iterator_traits<_OutputIterator>::value_type>::value,
107 __unique_copy_tags::__reread_from_output_tag,107 __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> >;
109 return std::__unique_copy<_ClassicAlgPolicy>(109 return std::__unique_copy<_ClassicAlgPolicy>(
110 std::move(__first), std::move(__last), std::move(__result), __pred, __algo_tag())110 std::move(__first), std::move(__last), std::move(__result), __pred, __algo_tag())
111 .second;111 .second;
112}112}
113113
114template <class _InputIterator, class _OutputIterator>114template <class _InputIterator, class _OutputIterator>
115inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator115inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
116unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {116unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
117 typedef typename iterator_traits<_InputIterator>::value_type __v;117 return std::unique_copy(std::move(__first), std::move(__last), std::move(__result), __equal_to());
118 return std::unique_copy(std::move(__first), std::move(__last), std::move(__result), __equal_to<__v>());
119}118}
120119
121_LIBCPP_END_NAMESPACE_STD120_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/unwrap_iter.h+4-2
...@@ -12,8 +12,10 @@...@@ -12,8 +12,10 @@
12#include <__config>12#include <__config>
13#include <__iterator/iterator_traits.h>13#include <__iterator/iterator_traits.h>
14#include <__memory/pointer_traits.h>14#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>
15#include <__utility/move.h>18#include <__utility/move.h>
16#include <type_traits>
1719
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header21# pragma GCC system_header
...@@ -57,7 +59,7 @@ struct __unwrap_iter_impl<_Iter, true> {...@@ -57,7 +59,7 @@ struct __unwrap_iter_impl<_Iter, true> {
57template<class _Iter,59template<class _Iter,
58 class _Impl = __unwrap_iter_impl<_Iter>,60 class _Impl = __unwrap_iter_impl<_Iter>,
59 __enable_if_t<is_copy_constructible<_Iter>::value, int> = 0>61 __enable_if_t<is_copy_constructible<_Iter>::value, int> = 0>
60inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1162inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
61decltype(_Impl::__unwrap(std::declval<_Iter>())) __unwrap_iter(_Iter __i) _NOEXCEPT {63decltype(_Impl::__unwrap(std::declval<_Iter>())) __unwrap_iter(_Iter __i) _NOEXCEPT {
62 return _Impl::__unwrap(__i);64 return _Impl::__unwrap(__i);
63}65}
lib/libcxx/include/__algorithm/unwrap_range.h+1-1
...@@ -28,7 +28,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -28,7 +28,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
28// __unwrap_iter and __rewrap_iter don't work for this, because they assume that the iterator and sentinel have28// __unwrap_iter and __rewrap_iter don't work for this, because they assume that the iterator and sentinel have
29// the same type. __unwrap_range tries to get two iterators and then forward to __unwrap_iter.29// 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
32template <class _Iter, class _Sent>32template <class _Iter, class _Sent>
33struct __unwrap_range_impl {33struct __unwrap_range_impl {
34 _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Sent __sent)34 _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 @@...@@ -28,7 +28,7 @@
28_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2929
30template <class _AlgPolicy, class _Compare, class _Iter, class _Sent, class _Tp, class _Proj>30template <class _AlgPolicy, class _Compare, class _Iter, class _Sent, class _Tp, class _Proj>
31_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter31_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter
32__upper_bound(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp, _Proj&& __proj) {32__upper_bound(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp, _Proj&& __proj) {
33 auto __len = _IterOps<_AlgPolicy>::distance(__first, __last);33 auto __len = _IterOps<_AlgPolicy>::distance(__first, __last);
34 while (__len != 0) {34 while (__len != 0) {
...@@ -45,7 +45,7 @@ __upper_bound(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp...@@ -45,7 +45,7 @@ __upper_bound(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp
45}45}
4646
47template <class _ForwardIterator, class _Tp, class _Compare>47template <class _ForwardIterator, class _Tp, class _Compare>
48_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator48_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
49upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {49upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
50 static_assert(is_copy_constructible<_ForwardIterator>::value,50 static_assert(is_copy_constructible<_ForwardIterator>::value,
51 "Iterator has to be copy constructible");51 "Iterator has to be copy constructible");
...@@ -54,7 +54,7 @@ upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu...@@ -54,7 +54,7 @@ upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu
54}54}
5555
56template <class _ForwardIterator, class _Tp>56template <class _ForwardIterator, class _Tp>
57_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator57_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
58upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {58upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
59 return std::upper_bound(59 return std::upper_bound(
60 std::move(__first),60 std::move(__first),
lib/libcxx/include/__assert+3-7
...@@ -17,13 +17,9 @@...@@ -17,13 +17,9 @@
17# pragma GCC system_header17# pragma GCC system_header
18#endif18#endif
1919
20// This is for backwards compatibility with code that might have been enabling20// TODO: Remove in LLVM 17.
21// assertions through the Debug mode previously.
22// TODO: In LLVM 16, make it an error to define _LIBCPP_DEBUG
23#if defined(_LIBCPP_DEBUG)21#if defined(_LIBCPP_DEBUG)
24# ifndef _LIBCPP_ENABLE_ASSERTIONS22# error "Defining _LIBCPP_DEBUG is not supported anymore. Please use _LIBCPP_ENABLE_DEBUG_MODE instead."
25# define _LIBCPP_ENABLE_ASSERTIONS 1
26# endif
27#endif23#endif
2824
29// Automatically enable assertions when the debug mode is enabled.25// Automatically enable assertions when the debug mode is enabled.
...@@ -45,7 +41,7 @@...@@ -45,7 +41,7 @@
45# define _LIBCPP_ASSERT(expression, message) \41# define _LIBCPP_ASSERT(expression, message) \
46 (__builtin_expect(static_cast<bool>(expression), 1) ? \42 (__builtin_expect(static_cast<bool>(expression), 1) ? \
47 (void)0 : \43 (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))
49#elif !defined(_LIBCPP_ASSERTIONS_DISABLE_ASSUME) && __has_builtin(__builtin_assume)45#elif !defined(_LIBCPP_ASSERTIONS_DISABLE_ASSUME) && __has_builtin(__builtin_assume)
50# define _LIBCPP_ASSERT(expression, message) \46# define _LIBCPP_ASSERT(expression, message) \
51 (_LIBCPP_DIAGNOSTIC_PUSH \47 (_LIBCPP_DIAGNOSTIC_PUSH \
lib/libcxx/include/__availability+3-14
...@@ -156,20 +156,9 @@...@@ -156,20 +156,9 @@
156# define _LIBCPP_AVAILABILITY_FORMAT156# define _LIBCPP_AVAILABILITY_FORMAT
157// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format157// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format
158158
159 // This controls whether the default verbose termination function is159 // This controls whether the library claims to provide a default verbose
160 // provided by the library.160 // termination function, and consequently whether the headers will try
161 //161 // to use it when the mechanism isn't overriden at compile-time.
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.
173// # define _LIBCPP_HAS_NO_VERBOSE_ABORT_IN_LIBRARY162// # define _LIBCPP_HAS_NO_VERBOSE_ABORT_IN_LIBRARY
174163
175#elif defined(__APPLE__)164#elif defined(__APPLE__)
lib/libcxx/include/__bit/bit_cast.h+1-1
...@@ -11,7 +11,7 @@...@@ -11,7 +11,7 @@
11#define _LIBCPP___BIT_BIT_CAST_H11#define _LIBCPP___BIT_BIT_CAST_H
1212
13#include <__config>13#include <__config>
14#include <type_traits>14#include <__type_traits/is_trivially_copyable.h>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header17# 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 @@...@@ -13,7 +13,8 @@
13#include <__algorithm/copy_n.h>13#include <__algorithm/copy_n.h>
14#include <__algorithm/fill_n.h>14#include <__algorithm/fill_n.h>
15#include <__algorithm/min.h>15#include <__algorithm/min.h>
16#include <__bits>16#include <__bit/countr.h>
17#include <__bit/popcount.h>
17#include <__config>18#include <__config>
18#include <__iterator/iterator_traits.h>19#include <__iterator/iterator_traits.h>
19#include <__memory/construct_at.h>20#include <__memory/construct_at.h>
...@@ -54,15 +55,17 @@ class __bit_reference...@@ -54,15 +55,17 @@ class __bit_reference
54 friend class __bit_const_reference<_Cp>;55 friend class __bit_const_reference<_Cp>;
55 friend class __bit_iterator<_Cp, false>;56 friend class __bit_iterator<_Cp, false>;
56public:57public:
57 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1758 using __container = typename _Cp::__self;
59
60 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
58 __bit_reference(const __bit_reference&) = default;61 __bit_reference(const __bit_reference&) = default;
5962
60 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 operator bool() const _NOEXCEPT63 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 operator bool() const _NOEXCEPT
61 {return static_cast<bool>(*__seg_ & __mask_);}64 {return static_cast<bool>(*__seg_ & __mask_);}
62 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool operator ~() const _NOEXCEPT65 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool operator ~() const _NOEXCEPT
63 {return !static_cast<bool>(*this);}66 {return !static_cast<bool>(*this);}
6467
65 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1768 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
66 __bit_reference& operator=(bool __x) _NOEXCEPT69 __bit_reference& operator=(bool __x) _NOEXCEPT
67 {70 {
68 if (__x)71 if (__x)
...@@ -82,15 +85,15 @@ public:...@@ -82,15 +85,15 @@ public:
82 }85 }
83#endif86#endif
8487
85 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1788 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
86 __bit_reference& operator=(const __bit_reference& __x) _NOEXCEPT89 __bit_reference& operator=(const __bit_reference& __x) _NOEXCEPT
87 {return operator=(static_cast<bool>(__x));}90 {return operator=(static_cast<bool>(__x));}
8891
89 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void flip() _NOEXCEPT {*__seg_ ^= __mask_;}92 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void flip() _NOEXCEPT {*__seg_ ^= __mask_;}
90 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false> operator&() const _NOEXCEPT93 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, false> operator&() const _NOEXCEPT
91 {return __bit_iterator<_Cp, false>(__seg_, static_cast<unsigned>(__libcpp_ctz(__mask_)));}94 {return __bit_iterator<_Cp, false>(__seg_, static_cast<unsigned>(std::__libcpp_ctz(__mask_)));}
92private:95private:
93 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1796 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
94 explicit __bit_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT97 explicit __bit_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT
95 : __seg_(__s), __mask_(__m) {}98 : __seg_(__s), __mask_(__m) {}
96};99};
...@@ -101,7 +104,7 @@ class __bit_reference<_Cp, false>...@@ -101,7 +104,7 @@ class __bit_reference<_Cp, false>
101};104};
102105
103template <class _Cp>106template <class _Cp>
104inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17107inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
105void108void
106swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT109swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT
107{110{
...@@ -111,7 +114,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT...@@ -111,7 +114,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT
111}114}
112115
113template <class _Cp, class _Dp>116template <class _Cp, class _Dp>
114inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17117inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
115void118void
116swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT119swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT
117{120{
...@@ -121,7 +124,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT...@@ -121,7 +124,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT
121}124}
122125
123template <class _Cp>126template <class _Cp>
124inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17127inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
125void128void
126swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT129swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT
127{130{
...@@ -131,7 +134,7 @@ swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT...@@ -131,7 +134,7 @@ swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT
131}134}
132135
133template <class _Cp>136template <class _Cp>
134inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17137inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
135void138void
136swap(bool& __x, __bit_reference<_Cp> __y) _NOEXCEPT139swap(bool& __x, __bit_reference<_Cp> __y) _NOEXCEPT
137{140{
...@@ -155,15 +158,15 @@ public:...@@ -155,15 +158,15 @@ public:
155 _LIBCPP_INLINE_VISIBILITY158 _LIBCPP_INLINE_VISIBILITY
156 __bit_const_reference(const __bit_const_reference&) = default;159 __bit_const_reference(const __bit_const_reference&) = default;
157160
158 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17161 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
159 __bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT162 __bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT
160 : __seg_(__x.__seg_), __mask_(__x.__mask_) {}163 : __seg_(__x.__seg_), __mask_(__x.__mask_) {}
161164
162 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator bool() const _NOEXCEPT165 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator bool() const _NOEXCEPT
163 {return static_cast<bool>(*__seg_ & __mask_);}166 {return static_cast<bool>(*__seg_ & __mask_);}
164167
165 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, true> operator&() const _NOEXCEPT168 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, true> operator&() const _NOEXCEPT
166 {return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(__libcpp_ctz(__mask_)));}169 {return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(std::__libcpp_ctz(__mask_)));}
167private:170private:
168 _LIBCPP_INLINE_VISIBILITY171 _LIBCPP_INLINE_VISIBILITY
169 _LIBCPP_CONSTEXPR172 _LIBCPP_CONSTEXPR
...@@ -176,7 +179,7 @@ private:...@@ -176,7 +179,7 @@ private:
176// find179// find
177180
178template <class _Cp, bool _IsConst>181template <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>
180__find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)183__find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
181{184{
182 typedef __bit_iterator<_Cp, _IsConst> _It;185 typedef __bit_iterator<_Cp, _IsConst> _It;
...@@ -212,7 +215,7 @@ __find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type...@@ -212,7 +215,7 @@ __find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
212}215}
213216
214template <class _Cp, bool _IsConst>217template <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>
216__find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)219__find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
217{220{
218 typedef __bit_iterator<_Cp, _IsConst> _It;221 typedef __bit_iterator<_Cp, _IsConst> _It;
...@@ -251,7 +254,7 @@ __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type...@@ -251,7 +254,7 @@ __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
251}254}
252255
253template <class _Cp, bool _IsConst, class _Tp>256template <class _Cp, bool _IsConst, class _Tp>
254inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17257inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
255__bit_iterator<_Cp, _IsConst>258__bit_iterator<_Cp, _IsConst>
256find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value)259find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value)
257{260{
...@@ -263,7 +266,7 @@ find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last...@@ -263,7 +266,7 @@ find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last
263// count266// count
264267
265template <class _Cp, bool _IsConst>268template <class _Cp, bool _IsConst>
266typename __bit_iterator<_Cp, _IsConst>::difference_type269_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __bit_iterator<_Cp, _IsConst>::difference_type
267__count_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)270__count_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
268{271{
269 typedef __bit_iterator<_Cp, _IsConst> _It;272 typedef __bit_iterator<_Cp, _IsConst> _It;
...@@ -294,7 +297,7 @@ __count_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type...@@ -294,7 +297,7 @@ __count_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
294}297}
295298
296template <class _Cp, bool _IsConst>299template <class _Cp, bool _IsConst>
297typename __bit_iterator<_Cp, _IsConst>::difference_type300_LIBCPP_HIDE_FROM_ABI typename __bit_iterator<_Cp, _IsConst>::difference_type
298__count_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)301__count_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
299{302{
300 typedef __bit_iterator<_Cp, _IsConst> _It;303 typedef __bit_iterator<_Cp, _IsConst> _It;
...@@ -337,7 +340,7 @@ count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __las...@@ -337,7 +340,7 @@ count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __las
337// fill_n340// fill_n
338341
339template <class _Cp>342template <class _Cp>
340_LIBCPP_CONSTEXPR_AFTER_CXX17 void343_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
341__fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)344__fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
342{345{
343 typedef __bit_iterator<_Cp, false> _It;346 typedef __bit_iterator<_Cp, false> _It;
...@@ -367,7 +370,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)...@@ -367,7 +370,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
367}370}
368371
369template <class _Cp>372template <class _Cp>
370_LIBCPP_CONSTEXPR_AFTER_CXX17 void373_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
371__fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)374__fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
372{375{
373 typedef __bit_iterator<_Cp, false> _It;376 typedef __bit_iterator<_Cp, false> _It;
...@@ -398,7 +401,7 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)...@@ -398,7 +401,7 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
398}401}
399402
400template <class _Cp>403template <class _Cp>
401inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17404inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
402void405void
403fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value)406fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value)
404{407{
...@@ -414,7 +417,7 @@ fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __v...@@ -414,7 +417,7 @@ fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __v
414// fill417// fill
415418
416template <class _Cp>419template <class _Cp>
417inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17420inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
418void421void
419fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool __value)422fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool __value)
420{423{
...@@ -424,8 +427,7 @@ fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool...@@ -424,8 +427,7 @@ fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool
424// copy427// copy
425428
426template <class _Cp, bool _IsConst>429template <class _Cp, bool _IsConst>
427_LIBCPP_CONSTEXPR_AFTER_CXX17430_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false>
428__bit_iterator<_Cp, false>
429__copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,431__copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
430 __bit_iterator<_Cp, false> __result)432 __bit_iterator<_Cp, false> __result)
431{433{
...@@ -472,8 +474,7 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon...@@ -472,8 +474,7 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon
472}474}
473475
474template <class _Cp, bool _IsConst>476template <class _Cp, bool _IsConst>
475_LIBCPP_CONSTEXPR_AFTER_CXX17477_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false>
476__bit_iterator<_Cp, false>
477__copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,478__copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
478 __bit_iterator<_Cp, false> __result)479 __bit_iterator<_Cp, false> __result)
479{480{
...@@ -551,7 +552,7 @@ __copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsC...@@ -551,7 +552,7 @@ __copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsC
551}552}
552553
553template <class _Cp, bool _IsConst>554template <class _Cp, bool _IsConst>
554inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17555inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
555__bit_iterator<_Cp, false>556__bit_iterator<_Cp, false>
556copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)557copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
557{558{
...@@ -563,7 +564,7 @@ copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last...@@ -563,7 +564,7 @@ copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last
563// copy_backward564// copy_backward
564565
565template <class _Cp, bool _IsConst>566template <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>
567__copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,568__copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
568 __bit_iterator<_Cp, false> __result)569 __bit_iterator<_Cp, false> __result)
569{570{
...@@ -610,7 +611,7 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C...@@ -610,7 +611,7 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C
610}611}
611612
612template <class _Cp, bool _IsConst>613template <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>
614__copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,615__copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
615 __bit_iterator<_Cp, false> __result)616 __bit_iterator<_Cp, false> __result)
616{617{
...@@ -696,7 +697,7 @@ __copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<...@@ -696,7 +697,7 @@ __copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<
696}697}
697698
698template <class _Cp, bool _IsConst>699template <class _Cp, bool _IsConst>
699inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17700inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
700__bit_iterator<_Cp, false>701__bit_iterator<_Cp, false>
701copy_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)702copy_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
702{703{
...@@ -728,7 +729,7 @@ move_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCons...@@ -728,7 +729,7 @@ move_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCons
728// swap_ranges729// swap_ranges
729730
730template <class __C1, class __C2>731template <class __C1, class __C2>
731__bit_iterator<__C2, false>732_LIBCPP_HIDE_FROM_ABI __bit_iterator<__C2, false>
732__swap_ranges_aligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1, false> __last,733__swap_ranges_aligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1, false> __last,
733 __bit_iterator<__C2, false> __result)734 __bit_iterator<__C2, false> __result)
734{735{
...@@ -778,7 +779,7 @@ __swap_ranges_aligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1,...@@ -778,7 +779,7 @@ __swap_ranges_aligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1,
778}779}
779780
780template <class __C1, class __C2>781template <class __C1, class __C2>
781__bit_iterator<__C2, false>782_LIBCPP_HIDE_FROM_ABI __bit_iterator<__C2, false>
782__swap_ranges_unaligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1, false> __last,783__swap_ranges_unaligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1, false> __last,
783 __bit_iterator<__C2, false> __result)784 __bit_iterator<__C2, false> __result)
784{785{
...@@ -903,19 +904,19 @@ struct __bit_array...@@ -903,19 +904,19 @@ struct __bit_array
903 difference_type __size_;904 difference_type __size_;
904 __storage_type __word_[_Np];905 __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()
907 {return static_cast<difference_type>(_Np * __bits_per_word);}908 {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) {
909 if (__libcpp_is_constant_evaluated()) {910 if (__libcpp_is_constant_evaluated()) {
910 for (size_t __i = 0; __i != __bit_array<_Cp>::_Np; ++__i)911 for (size_t __i = 0; __i != __bit_array<_Cp>::_Np; ++__i)
911 std::__construct_at(__word_ + __i, 0);912 std::__construct_at(__word_ + __i, 0);
912 }913 }
913 }914 }
914 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator begin()915 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin()
915 {916 {
916 return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0);917 return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0);
917 }918 }
918 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator end()919 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator end()
919 {920 {
920 return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word,921 return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word,
921 static_cast<unsigned>(__size_ % __bits_per_word));922 static_cast<unsigned>(__size_ % __bits_per_word));
...@@ -923,7 +924,7 @@ struct __bit_array...@@ -923,7 +924,7 @@ struct __bit_array
923};924};
924925
925template <class _Cp>926template <class _Cp>
926_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false>927_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false>
927rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle, __bit_iterator<_Cp, false> __last)928rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle, __bit_iterator<_Cp, false> __last)
928{929{
929 typedef __bit_iterator<_Cp, false> _I1;930 typedef __bit_iterator<_Cp, false> _I1;
...@@ -974,7 +975,7 @@ rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle,...@@ -974,7 +975,7 @@ rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle,
974// equal975// equal
975976
976template <class _Cp, bool _IC1, bool _IC2>977template <class _Cp, bool _IC1, bool _IC2>
977_LIBCPP_CONSTEXPR_AFTER_CXX17 bool978_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool
978__equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1,979__equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1,
979 __bit_iterator<_Cp, _IC2> __first2)980 __bit_iterator<_Cp, _IC2> __first2)
980{981{
...@@ -1056,7 +1057,7 @@ __equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1>...@@ -1056,7 +1057,7 @@ __equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1>
1056}1057}
10571058
1058template <class _Cp, bool _IC1, bool _IC2>1059template <class _Cp, bool _IC1, bool _IC2>
1059_LIBCPP_CONSTEXPR_AFTER_CXX17 bool1060_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool
1060__equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1,1061__equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1,
1061 __bit_iterator<_Cp, _IC2> __first2)1062 __bit_iterator<_Cp, _IC2> __first2)
1062{1063{
...@@ -1099,7 +1100,7 @@ __equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __...@@ -1099,7 +1100,7 @@ __equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __
1099}1100}
11001101
1101template <class _Cp, bool _IC1, bool _IC2>1102template <class _Cp, bool _IC1, bool _IC2>
1102inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171103inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1103bool1104bool
1104equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2)1105equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2)
1105{1106{
...@@ -1117,23 +1118,23 @@ public:...@@ -1117,23 +1118,23 @@ public:
1117 typedef bool value_type;1118 typedef bool value_type;
1118 typedef __bit_iterator pointer;1119 typedef __bit_iterator pointer;
1119#ifndef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL1120#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;
1121#else1122#else
1122 using reference = typename conditional<_IsConst, bool, __bit_reference<_Cp> >::type;1123 using reference = __conditional_t<_IsConst, bool, __bit_reference<_Cp> >;
1123#endif1124#endif
1124 typedef random_access_iterator_tag iterator_category;1125 typedef random_access_iterator_tag iterator_category;
11251126
1126private:1127private:
1127 typedef typename _Cp::__storage_type __storage_type;1128 typedef typename _Cp::__storage_type __storage_type;
1128 typedef typename conditional<_IsConst, typename _Cp::__const_storage_pointer,1129 typedef __conditional_t<_IsConst, typename _Cp::__const_storage_pointer, typename _Cp::__storage_pointer>
1129 typename _Cp::__storage_pointer>::type __storage_pointer;1130 __storage_pointer;
1130 static const unsigned __bits_per_word = _Cp::__bits_per_word;1131 static const unsigned __bits_per_word = _Cp::__bits_per_word;
11311132
1132 __storage_pointer __seg_;1133 __storage_pointer __seg_;
1133 unsigned __ctz_;1134 unsigned __ctz_;
11341135
1135public:1136public:
1136 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator() _NOEXCEPT1137 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator() _NOEXCEPT
1137#if _LIBCPP_STD_VER > 111138#if _LIBCPP_STD_VER > 11
1138 : __seg_(nullptr), __ctz_(0)1139 : __seg_(nullptr), __ctz_(0)
1139#endif1140#endif
...@@ -1144,7 +1145,7 @@ public:...@@ -1144,7 +1145,7 @@ public:
1144 // When _IsConst=true, this is a converting constructor;1145 // When _IsConst=true, this is a converting constructor;
1145 // the copy and move constructors are implicitly generated1146 // the copy and move constructors are implicitly generated
1146 // and trivial.1147 // and trivial.
1147 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171148 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1148 __bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT1149 __bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT
1149 : __seg_(__it.__seg_), __ctz_(__it.__ctz_) {}1150 : __seg_(__it.__seg_), __ctz_(__it.__ctz_) {}
11501151
...@@ -1153,19 +1154,19 @@ public:...@@ -1153,19 +1154,19 @@ public:
1153 // the implicit generation of a defaulted one is deprecated.1154 // the implicit generation of a defaulted one is deprecated.
1154 // When _IsConst=true, the assignment operators are1155 // When _IsConst=true, the assignment operators are
1155 // implicitly generated and trivial.1156 // implicitly generated and trivial.
1156 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171157 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1157 __bit_iterator& operator=(const _If<_IsConst, struct __private_nat, __bit_iterator>& __it) {1158 __bit_iterator& operator=(const _If<_IsConst, struct __private_nat, __bit_iterator>& __it) {
1158 __seg_ = __it.__seg_;1159 __seg_ = __it.__seg_;
1159 __ctz_ = __it.__ctz_;1160 __ctz_ = __it.__ctz_;
1160 return *this;1161 return *this;
1161 }1162 }
11621163
1163 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator*() const _NOEXCEPT {1164 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator*() const _NOEXCEPT {
1164 return typename conditional<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >1165 return __conditional_t<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >(
1165 ::type(__seg_, __storage_type(1) << __ctz_);1166 __seg_, __storage_type(1) << __ctz_);
1166 }1167 }
11671168
1168 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator++()1169 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator& operator++()
1169 {1170 {
1170 if (__ctz_ != __bits_per_word-1)1171 if (__ctz_ != __bits_per_word-1)
1171 ++__ctz_;1172 ++__ctz_;
...@@ -1177,14 +1178,14 @@ public:...@@ -1177,14 +1178,14 @@ public:
1177 return *this;1178 return *this;
1178 }1179 }
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)
1181 {1182 {
1182 __bit_iterator __tmp = *this;1183 __bit_iterator __tmp = *this;
1183 ++(*this);1184 ++(*this);
1184 return __tmp;1185 return __tmp;
1185 }1186 }
11861187
1187 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator--()1188 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator& operator--()
1188 {1189 {
1189 if (__ctz_ != 0)1190 if (__ctz_ != 0)
1190 --__ctz_;1191 --__ctz_;
...@@ -1196,14 +1197,14 @@ public:...@@ -1196,14 +1197,14 @@ public:
1196 return *this;1197 return *this;
1197 }1198 }
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)
1200 {1201 {
1201 __bit_iterator __tmp = *this;1202 __bit_iterator __tmp = *this;
1202 --(*this);1203 --(*this);
1203 return __tmp;1204 return __tmp;
1204 }1205 }
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)
1207 {1208 {
1208 if (__n >= 0)1209 if (__n >= 0)
1209 __seg_ += (__n + __ctz_) / __bits_per_word;1210 __seg_ += (__n + __ctz_) / __bits_per_word;
...@@ -1215,54 +1216,54 @@ public:...@@ -1215,54 +1216,54 @@ public:
1215 return *this;1216 return *this;
1216 }1217 }
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)
1219 {1220 {
1220 return *this += -__n;1221 return *this += -__n;
1221 }1222 }
12221223
1223 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator+(difference_type __n) const1224 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator operator+(difference_type __n) const
1224 {1225 {
1225 __bit_iterator __t(*this);1226 __bit_iterator __t(*this);
1226 __t += __n;1227 __t += __n;
1227 return __t;1228 return __t;
1228 }1229 }
12291230
1230 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator-(difference_type __n) const1231 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator operator-(difference_type __n) const
1231 {1232 {
1232 __bit_iterator __t(*this);1233 __bit_iterator __t(*this);
1233 __t -= __n;1234 __t -= __n;
1234 return __t;1235 return __t;
1235 }1236 }
12361237
1237 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171238 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1238 friend __bit_iterator operator+(difference_type __n, const __bit_iterator& __it) {return __it + __n;}1239 friend __bit_iterator operator+(difference_type __n, const __bit_iterator& __it) {return __it + __n;}
12391240
1240 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171241 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1241 friend difference_type operator-(const __bit_iterator& __x, const __bit_iterator& __y)1242 friend difference_type operator-(const __bit_iterator& __x, const __bit_iterator& __y)
1242 {return (__x.__seg_ - __y.__seg_) * __bits_per_word + __x.__ctz_ - __y.__ctz_;}1243 {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)
1247 {return __x.__seg_ == __y.__seg_ && __x.__ctz_ == __y.__ctz_;}1248 {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)
1250 {return !(__x == __y);}1251 {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)
1253 {return __x.__seg_ < __y.__seg_ || (__x.__seg_ == __y.__seg_ && __x.__ctz_ < __y.__ctz_);}1254 {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)
1256 {return __y < __x;}1257 {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)
1259 {return !(__y < __x);}1260 {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)
1262 {return !(__x < __y);}1263 {return !(__x < __y);}
12631264
1264private:1265private:
1265 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171266 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1266 explicit __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT1267 explicit __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT
1267 : __seg_(__s), __ctz_(__ctz) {}1268 : __seg_(__s), __ctz_(__ctz) {}
12681269
...@@ -1273,40 +1274,40 @@ private:...@@ -1273,40 +1274,40 @@ private:
1273 friend class __bit_iterator<_Cp, true>;1274 friend class __bit_iterator<_Cp, true>;
1274 template <class _Dp> friend struct __bit_array;1275 template <class _Dp> friend struct __bit_array;
1275 template <class _Dp>1276 template <class _Dp>
1276 _LIBCPP_CONSTEXPR_AFTER_CXX171277 _LIBCPP_CONSTEXPR_SINCE_CXX20
1277 friend void __fill_n_false(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);1278 friend void __fill_n_false(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
12781279
1279 template <class _Dp>1280 template <class _Dp>
1280 _LIBCPP_CONSTEXPR_AFTER_CXX171281 _LIBCPP_CONSTEXPR_SINCE_CXX20
1281 friend void __fill_n_true(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);1282 friend void __fill_n_true(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
12821283
1283 template <class _Dp, bool _IC>1284 template <class _Dp, bool _IC>
1284 _LIBCPP_CONSTEXPR_AFTER_CXX171285 _LIBCPP_CONSTEXPR_SINCE_CXX20
1285 friend __bit_iterator<_Dp, false> __copy_aligned(__bit_iterator<_Dp, _IC> __first,1286 friend __bit_iterator<_Dp, false> __copy_aligned(__bit_iterator<_Dp, _IC> __first,
1286 __bit_iterator<_Dp, _IC> __last,1287 __bit_iterator<_Dp, _IC> __last,
1287 __bit_iterator<_Dp, false> __result);1288 __bit_iterator<_Dp, false> __result);
1288 template <class _Dp, bool _IC>1289 template <class _Dp, bool _IC>
1289 _LIBCPP_CONSTEXPR_AFTER_CXX171290 _LIBCPP_CONSTEXPR_SINCE_CXX20
1290 friend __bit_iterator<_Dp, false> __copy_unaligned(__bit_iterator<_Dp, _IC> __first,1291 friend __bit_iterator<_Dp, false> __copy_unaligned(__bit_iterator<_Dp, _IC> __first,
1291 __bit_iterator<_Dp, _IC> __last,1292 __bit_iterator<_Dp, _IC> __last,
1292 __bit_iterator<_Dp, false> __result);1293 __bit_iterator<_Dp, false> __result);
1293 template <class _Dp, bool _IC>1294 template <class _Dp, bool _IC>
1294 _LIBCPP_CONSTEXPR_AFTER_CXX171295 _LIBCPP_CONSTEXPR_SINCE_CXX20
1295 friend __bit_iterator<_Dp, false> copy(__bit_iterator<_Dp, _IC> __first,1296 friend __bit_iterator<_Dp, false> copy(__bit_iterator<_Dp, _IC> __first,
1296 __bit_iterator<_Dp, _IC> __last,1297 __bit_iterator<_Dp, _IC> __last,
1297 __bit_iterator<_Dp, false> __result);1298 __bit_iterator<_Dp, false> __result);
1298 template <class _Dp, bool _IC>1299 template <class _Dp, bool _IC>
1299 _LIBCPP_CONSTEXPR_AFTER_CXX171300 _LIBCPP_CONSTEXPR_SINCE_CXX20
1300 friend __bit_iterator<_Dp, false> __copy_backward_aligned(__bit_iterator<_Dp, _IC> __first,1301 friend __bit_iterator<_Dp, false> __copy_backward_aligned(__bit_iterator<_Dp, _IC> __first,
1301 __bit_iterator<_Dp, _IC> __last,1302 __bit_iterator<_Dp, _IC> __last,
1302 __bit_iterator<_Dp, false> __result);1303 __bit_iterator<_Dp, false> __result);
1303 template <class _Dp, bool _IC>1304 template <class _Dp, bool _IC>
1304 _LIBCPP_CONSTEXPR_AFTER_CXX171305 _LIBCPP_CONSTEXPR_SINCE_CXX20
1305 friend __bit_iterator<_Dp, false> __copy_backward_unaligned(__bit_iterator<_Dp, _IC> __first,1306 friend __bit_iterator<_Dp, false> __copy_backward_unaligned(__bit_iterator<_Dp, _IC> __first,
1306 __bit_iterator<_Dp, _IC> __last,1307 __bit_iterator<_Dp, _IC> __last,
1307 __bit_iterator<_Dp, false> __result);1308 __bit_iterator<_Dp, false> __result);
1308 template <class _Dp, bool _IC>1309 template <class _Dp, bool _IC>
1309 _LIBCPP_CONSTEXPR_AFTER_CXX171310 _LIBCPP_CONSTEXPR_SINCE_CXX20
1310 friend __bit_iterator<_Dp, false> copy_backward(__bit_iterator<_Dp, _IC> __first,1311 friend __bit_iterator<_Dp, false> copy_backward(__bit_iterator<_Dp, _IC> __first,
1311 __bit_iterator<_Dp, _IC> __last,1312 __bit_iterator<_Dp, _IC> __last,
1312 __bit_iterator<_Dp, false> __result);1313 __bit_iterator<_Dp, false> __result);
...@@ -1320,32 +1321,33 @@ private:...@@ -1320,32 +1321,33 @@ private:
1320 __bit_iterator<__C1, false>,1321 __bit_iterator<__C1, false>,
1321 __bit_iterator<__C2, false>);1322 __bit_iterator<__C2, false>);
1322 template <class _Dp>1323 template <class _Dp>
1323 _LIBCPP_CONSTEXPR_AFTER_CXX171324 _LIBCPP_CONSTEXPR_SINCE_CXX20
1324 friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>,1325 friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>,
1325 __bit_iterator<_Dp, false>,1326 __bit_iterator<_Dp, false>,
1326 __bit_iterator<_Dp, false>);1327 __bit_iterator<_Dp, false>);
1327 template <class _Dp, bool _IC1, bool _IC2>1328 template <class _Dp, bool _IC1, bool _IC2>
1328 _LIBCPP_CONSTEXPR_AFTER_CXX171329 _LIBCPP_CONSTEXPR_SINCE_CXX20
1329 friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>,1330 friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>,
1330 __bit_iterator<_Dp, _IC1>,1331 __bit_iterator<_Dp, _IC1>,
1331 __bit_iterator<_Dp, _IC2>);1332 __bit_iterator<_Dp, _IC2>);
1332 template <class _Dp, bool _IC1, bool _IC2>1333 template <class _Dp, bool _IC1, bool _IC2>
1333 _LIBCPP_CONSTEXPR_AFTER_CXX171334 _LIBCPP_CONSTEXPR_SINCE_CXX20
1334 friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>,1335 friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>,
1335 __bit_iterator<_Dp, _IC1>,1336 __bit_iterator<_Dp, _IC1>,
1336 __bit_iterator<_Dp, _IC2>);1337 __bit_iterator<_Dp, _IC2>);
1337 template <class _Dp, bool _IC1, bool _IC2>1338 template <class _Dp, bool _IC1, bool _IC2>
1338 _LIBCPP_CONSTEXPR_AFTER_CXX171339 _LIBCPP_CONSTEXPR_SINCE_CXX20
1339 friend bool equal(__bit_iterator<_Dp, _IC1>,1340 friend bool equal(__bit_iterator<_Dp, _IC1>,
1340 __bit_iterator<_Dp, _IC1>,1341 __bit_iterator<_Dp, _IC1>,
1341 __bit_iterator<_Dp, _IC2>);1342 __bit_iterator<_Dp, _IC2>);
1342 template <class _Dp, bool _IC>1343 template <class _Dp, bool _IC>
1343 _LIBCPP_CONSTEXPR_AFTER_CXX171344 _LIBCPP_CONSTEXPR_SINCE_CXX20
1344 friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);1345 friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
1345 template <class _Dp, bool _IC>1346 template <class _Dp, bool _IC>
1346 _LIBCPP_CONSTEXPR_AFTER_CXX171347 _LIBCPP_CONSTEXPR_SINCE_CXX20
1347 friend __bit_iterator<_Dp, _IC> __find_bool_false(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);1348 friend __bit_iterator<_Dp, _IC> __find_bool_false(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
1348 template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type1349 template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type
1350 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
1349 __count_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);1351 __count_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
1350 template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type1352 template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type
1351 __count_bool_false(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);1353 __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 @@...@@ -13,7 +13,6 @@
13#ifndef _LIBCPP___BSD_LOCALE_FALLBACKS_H13#ifndef _LIBCPP___BSD_LOCALE_FALLBACKS_H
14#define _LIBCPP___BSD_LOCALE_FALLBACKS_H14#define _LIBCPP___BSD_LOCALE_FALLBACKS_H
1515
16#include <memory>
17#include <stdarg.h>16#include <stdarg.h>
18#include <stdlib.h>17#include <stdlib.h>
1918
lib/libcxx/include/__charconv/chars_format.h+5-5
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22#ifndef _LIBCPP_CXX03_LANG22#if _LIBCPP_STD_VER > 14
2323
24enum class _LIBCPP_ENUM_VIS chars_format24enum class _LIBCPP_ENUM_VIS chars_format
25{25{
...@@ -52,25 +52,25 @@ operator^(chars_format __x, chars_format __y) {...@@ -52,25 +52,25 @@ operator^(chars_format __x, chars_format __y) {
52 _VSTD::__to_underlying(__y));52 _VSTD::__to_underlying(__y));
53}53}
5454
55inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format&55inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format&
56operator&=(chars_format& __x, chars_format __y) {56operator&=(chars_format& __x, chars_format __y) {
57 __x = __x & __y;57 __x = __x & __y;
58 return __x;58 return __x;
59}59}
6060
61inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format&61inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format&
62operator|=(chars_format& __x, chars_format __y) {62operator|=(chars_format& __x, chars_format __y) {
63 __x = __x | __y;63 __x = __x | __y;
64 return __x;64 return __x;
65}65}
6666
67inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format&67inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format&
68operator^=(chars_format& __x, chars_format __y) {68operator^=(chars_format& __x, chars_format __y) {
69 __x = __x ^ __y;69 __x = __x ^ __y;
70 return __x;70 return __x;
71}71}
7272
73#endif // _LIBCPP_CXX03_LANG73#endif // _LIBCPP_STD_VER > 14
7474
75_LIBCPP_END_NAMESPACE_STD75_LIBCPP_END_NAMESPACE_STD
7676
lib/libcxx/include/__charconv/from_chars_result.h+2-2
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22#ifndef _LIBCPP_CXX03_LANG22#if _LIBCPP_STD_VER > 14
2323
24struct _LIBCPP_TYPE_VIS from_chars_result24struct _LIBCPP_TYPE_VIS from_chars_result
25{25{
...@@ -30,7 +30,7 @@ struct _LIBCPP_TYPE_VIS from_chars_result...@@ -30,7 +30,7 @@ struct _LIBCPP_TYPE_VIS from_chars_result
30# endif30# endif
31};31};
3232
33#endif // _LIBCPP_CXX03_LANG33#endif // _LIBCPP_STD_VER > 14
3434
35_LIBCPP_END_NAMESPACE_STD35_LIBCPP_END_NAMESPACE_STD
3636
lib/libcxx/include/__charconv/tables.h+10-36
...@@ -19,38 +19,16 @@...@@ -19,38 +19,16 @@
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22#ifndef _LIBCPP_CXX03_LANG22#if _LIBCPP_STD_VER > 14
2323
24namespace __itoa {24namespace __itoa {
2525
26/// Contains the charconv helper tables.26inline constexpr char __base_2_lut[64] = {
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] = {
48 '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '1', '0', '0', '0', '1', '1', '0', '1', '0', '0', '0', '1',27 '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '1', '0', '0', '0', '1', '1', '0', '1', '0', '0', '0', '1',
49 '0', '1', '0', '1', '1', '0', '0', '1', '1', '1', '1', '0', '0', '0', '1', '0', '0', '1', '1', '0', '1', '0',28 '0', '1', '0', '1', '1', '0', '0', '1', '1', '1', '1', '0', '0', '0', '1', '0', '0', '1', '1', '0', '1', '0',
50 '1', '0', '1', '1', '1', '1', '0', '0', '1', '1', '0', '1', '1', '1', '1', '0', '1', '1', '1', '1'};29 '1', '0', '1', '1', '1', '1', '0', '0', '1', '1', '0', '1', '1', '1', '1', '0', '1', '1', '1', '1'};
5130
52template <class _Tp>31inline constexpr char __base_8_lut[128] = {
53const char __table<_Tp>::__base_8_lut[128] = {
54 '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '1', '0', '1', '1', '1', '2',32 '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '1', '0', '1', '1', '1', '2',
55 '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5',33 '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5',
56 '2', '6', '2', '7', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '4', '0',34 '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] = {...@@ -58,8 +36,7 @@ const char __table<_Tp>::__base_8_lut[128] = {
58 '5', '4', '5', '5', '5', '6', '5', '7', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6',36 '5', '4', '5', '5', '5', '6', '5', '7', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6',
59 '6', '7', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7'};37 '6', '7', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7'};
6038
61template <class _Tp>39inline constexpr char __base_16_lut[512] = {
62const char __table<_Tp>::__base_16_lut[512] = {
63 '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', '0', 'a', '0',40 '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', '0', 'a', '0',
64 'b', '0', 'c', '0', 'd', '0', 'e', '0', 'f', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6',41 'b', '0', 'c', '0', 'd', '0', 'e', '0', 'f', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6',
65 '1', '7', '1', '8', '1', '9', '1', 'a', '1', 'b', '1', 'c', '1', 'd', '1', 'e', '1', 'f', '2', '0', '2', '1', '2',42 '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] = {...@@ -84,13 +61,11 @@ const char __table<_Tp>::__base_16_lut[512] = {
84 '1', 'f', '2', 'f', '3', 'f', '4', 'f', '5', 'f', '6', 'f', '7', 'f', '8', 'f', '9', 'f', 'a', 'f', 'b', 'f', 'c',61 '1', 'f', '2', 'f', '3', 'f', '4', 'f', '5', 'f', '6', 'f', '7', 'f', '8', 'f', '9', 'f', 'a', 'f', 'b', 'f', 'c',
85 'f', 'd', 'f', 'e', 'f', 'f'};62 'f', 'd', 'f', 'e', 'f', 'f'};
8663
87template <class _Tp>64inline constexpr uint32_t __pow10_32[10] = {
88const uint32_t __table<_Tp>::__pow10_32[10] = {
89 UINT32_C(0), UINT32_C(10), UINT32_C(100), UINT32_C(1000), UINT32_C(10000),65 UINT32_C(0), UINT32_C(10), UINT32_C(100), UINT32_C(1000), UINT32_C(10000),
90 UINT32_C(100000), UINT32_C(1000000), UINT32_C(10000000), UINT32_C(100000000), UINT32_C(1000000000)};66 UINT32_C(100000), UINT32_C(1000000), UINT32_C(10000000), UINT32_C(100000000), UINT32_C(1000000000)};
9167
92template <class _Tp>68inline constexpr uint64_t __pow10_64[20] = {UINT64_C(0),
93const uint64_t __table<_Tp>::__pow10_64[20] = {UINT64_C(0),
94 UINT64_C(10),69 UINT64_C(10),
95 UINT64_C(100),70 UINT64_C(100),
96 UINT64_C(1000),71 UINT64_C(1000),
...@@ -112,8 +87,8 @@ const uint64_t __table<_Tp>::__pow10_64[20] = {UINT64_C(0),...@@ -112,8 +87,8 @@ const uint64_t __table<_Tp>::__pow10_64[20] = {UINT64_C(0),
112 UINT64_C(10000000000000000000)};87 UINT64_C(10000000000000000000)};
11388
114# ifndef _LIBCPP_HAS_NO_INT12889# ifndef _LIBCPP_HAS_NO_INT128
115template <class _Tp>90inline constexpr int __pow10_128_offset = 0;
116const __uint128_t __table<_Tp>::__pow10_128[40] = {91inline constexpr __uint128_t __pow10_128[40] = {
117 UINT64_C(0),92 UINT64_C(0),
118 UINT64_C(10),93 UINT64_C(10),
119 UINT64_C(100),94 UINT64_C(100),
...@@ -156,8 +131,7 @@ const __uint128_t __table<_Tp>::__pow10_128[40] = {...@@ -156,8 +131,7 @@ const __uint128_t __table<_Tp>::__pow10_128[40] = {
156 (__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000000)) * 10};131 (__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000000)) * 10};
157# endif132# endif
158133
159template <class _Tp>134inline constexpr char __digits_base_10[200] = {
160const char __table<_Tp>::__digits_base_10[200] = {
161 // clang-format off135 // clang-format off
162 '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9',136 '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9',
163 '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '1', '8', '1', '9',137 '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] = {...@@ -173,7 +147,7 @@ const char __table<_Tp>::__digits_base_10[200] = {
173147
174} // namespace __itoa148} // namespace __itoa
175149
176#endif // _LIBCPP_CXX03_LANG150#endif // _LIBCPP_STD_VER > 14
177151
178_LIBCPP_END_NAMESPACE_STD152_LIBCPP_END_NAMESPACE_STD
179153
lib/libcxx/include/__charconv/to_chars_base_10.h+19-19
...@@ -25,54 +25,54 @@ _LIBCPP_PUSH_MACROS...@@ -25,54 +25,54 @@ _LIBCPP_PUSH_MACROS
2525
26_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
2727
28#ifndef _LIBCPP_CXX03_LANG28#if _LIBCPP_STD_VER > 14
2929
30namespace __itoa {30namespace __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 {
33 *__first = '0' + static_cast<char>(__value);33 *__first = '0' + static_cast<char>(__value);
34 return __first + 1;34 return __first + 1;
35}35}
3636
37_LIBCPP_HIDE_FROM_ABI inline char* __append2(char* __first, uint32_t __value) noexcept {37_LIBCPP_CONSTEXPR_SINCE_CXX23 _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);38 return std::copy_n(&__digits_base_10[__value * 2], 2, __first);
39}39}
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 {
42 return __itoa::__append2(__itoa::__append1(__first, __value / 100), __value % 100);42 return __itoa::__append2(__itoa::__append1(__first, __value / 100), __value % 100);
43}43}
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 {
46 return __itoa::__append2(__itoa::__append2(__first, __value / 100), __value % 100);46 return __itoa::__append2(__itoa::__append2(__first, __value / 100), __value % 100);
47}47}
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 {
50 return __itoa::__append4(__itoa::__append1(__first, __value / 10000), __value % 10000);50 return __itoa::__append4(__itoa::__append1(__first, __value / 10000), __value % 10000);
51}51}
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 {
54 return __itoa::__append4(__itoa::__append2(__first, __value / 10000), __value % 10000);54 return __itoa::__append4(__itoa::__append2(__first, __value / 10000), __value % 10000);
55}55}
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 {
58 return __itoa::__append6(__itoa::__append1(__first, __value / 1000000), __value % 1000000);58 return __itoa::__append6(__itoa::__append1(__first, __value / 1000000), __value % 1000000);
59}59}
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 {
62 return __itoa::__append6(__itoa::__append2(__first, __value / 1000000), __value % 1000000);62 return __itoa::__append6(__itoa::__append2(__first, __value / 1000000), __value % 1000000);
63}63}
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 {
66 return __itoa::__append8(__itoa::__append1(__first, __value / 100000000), __value % 100000000);66 return __itoa::__append8(__itoa::__append1(__first, __value / 100000000), __value % 100000000);
67}67}
6868
69template <class _Tp>69template <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 {
71 return __itoa::__append8(__itoa::__append2(__first, static_cast<uint32_t>(__value / 100000000)),71 return __itoa::__append8(__itoa::__append2(__first, static_cast<uint32_t>(__value / 100000000)),
72 static_cast<uint32_t>(__value % 100000000));72 static_cast<uint32_t>(__value % 100000000));
73}73}
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 {
76 if (__value < 1000000) {76 if (__value < 1000000) {
77 if (__value < 10000) {77 if (__value < 10000) {
78 if (__value < 100) {78 if (__value < 100) {
...@@ -107,7 +107,7 @@ _LIBCPP_HIDE_FROM_ABI inline char* __base_10_u32(char* __first, uint32_t __value...@@ -107,7 +107,7 @@ _LIBCPP_HIDE_FROM_ABI inline char* __base_10_u32(char* __first, uint32_t __value
107 return __itoa::__append10(__first, __value);107 return __itoa::__append10(__first, __value);
108}108}
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 {
111 if (__value <= UINT32_MAX)111 if (__value <= UINT32_MAX)
112 return __itoa::__base_10_u32(__buffer, static_cast<uint32_t>(__value));112 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...@@ -129,12 +129,12 @@ _LIBCPP_HIDE_FROM_ABI inline char* __base_10_u64(char* __buffer, uint64_t __valu
129/// \note The lookup table contains a partial set of exponents limiting the129/// \note The lookup table contains a partial set of exponents limiting the
130/// range that can be used. However the range is sufficient for130/// range that can be used. However the range is sufficient for
131/// \ref __base_10_u128.131/// \ref __base_10_u128.
132_LIBCPP_HIDE_FROM_ABI inline __uint128_t __pow_10(int __exp) noexcept {132_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline __uint128_t __pow_10(int __exp) noexcept {
133 _LIBCPP_ASSERT(__exp >= __table<>::__pow10_128_offset, "Index out of bounds");133 _LIBCPP_ASSERT(__exp >= __pow10_128_offset, "Index out of bounds");
134 return __table<>::__pow10_128[__exp - __table<>::__pow10_128_offset];134 return __pow10_128[__exp - __pow10_128_offset];
135}135}
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 {
138 _LIBCPP_ASSERT(138 _LIBCPP_ASSERT(
139 __value > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fail when this isn't true.");139 __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 __...@@ -176,7 +176,7 @@ _LIBCPP_HIDE_FROM_ABI inline char* __base_10_u128(char* __buffer, __uint128_t __
176# endif176# endif
177} // namespace __itoa177} // namespace __itoa
178178
179#endif // _LIBCPP_CXX03_LANG179#endif // _LIBCPP_STD_VER > 14
180180
181_LIBCPP_END_NAMESPACE_STD181_LIBCPP_END_NAMESPACE_STD
182182
lib/libcxx/include/__charconv/to_chars_result.h+2-2
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22#ifndef _LIBCPP_CXX03_LANG22#if _LIBCPP_STD_VER > 14
2323
24struct _LIBCPP_TYPE_VIS to_chars_result24struct _LIBCPP_TYPE_VIS to_chars_result
25{25{
...@@ -30,7 +30,7 @@ struct _LIBCPP_TYPE_VIS to_chars_result...@@ -30,7 +30,7 @@ struct _LIBCPP_TYPE_VIS to_chars_result
30# endif30# endif
31};31};
3232
33#endif // _LIBCPP_CXX03_LANG33#endif // _LIBCPP_STD_VER > 14
3434
35_LIBCPP_END_NAMESPACE_STD35_LIBCPP_END_NAMESPACE_STD
3636
lib/libcxx/include/__chrono/convert_to_timespec.h+1
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___CHRONO_CONVERT_TO_TIMESPEC_H10#ifndef _LIBCPP___CHRONO_CONVERT_TO_TIMESPEC_H
10#define _LIBCPP___CHRONO_CONVERT_TO_TIMESPEC_H11#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...@@ -27,18 +27,18 @@ namespace chrono
2727
28class day {28class day {
29private:29private:
30 unsigned char __d;30 unsigned char __d_;
31public:31public:
32 _LIBCPP_HIDE_FROM_ABI day() = default;32 _LIBCPP_HIDE_FROM_ABI day() = default;
33 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr day(unsigned __val) noexcept : __d(static_cast<unsigned char>(__val)) {}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; }34 _LIBCPP_HIDE_FROM_ABI inline constexpr day& operator++() noexcept { ++__d_; return *this; }
35 _LIBCPP_HIDE_FROM_ABI inline constexpr day operator++(int) noexcept { day __tmp = *this; ++(*this); return __tmp; }35 _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; }
37 _LIBCPP_HIDE_FROM_ABI inline constexpr day operator--(int) noexcept { day __tmp = *this; --(*this); return __tmp; }37 _LIBCPP_HIDE_FROM_ABI inline constexpr day operator--(int) noexcept { day __tmp = *this; --(*this); return __tmp; }
38 _LIBCPP_HIDE_FROM_ABI constexpr day& operator+=(const days& __dd) noexcept;38 _LIBCPP_HIDE_FROM_ABI constexpr day& operator+=(const days& __dd) noexcept;
39 _LIBCPP_HIDE_FROM_ABI constexpr day& operator-=(const days& __dd) noexcept;39 _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; }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; }41 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __d_ >= 1 && __d_ <= 31; }
42 };42 };
4343
4444
lib/libcxx/include/__chrono/duration.h+33-26
...@@ -11,9 +11,12 @@...@@ -11,9 +11,12 @@
11#define _LIBCPP___CHRONO_DURATION_H11#define _LIBCPP___CHRONO_DURATION_H
1212
13#include <__config>13#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>
14#include <limits>18#include <limits>
15#include <ratio>19#include <ratio>
16#include <type_traits>
1720
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header22# pragma GCC system_header
...@@ -151,7 +154,7 @@ typename enable_if...@@ -151,7 +154,7 @@ typename enable_if
151>::type154>::type
152floor(const duration<_Rep, _Period>& __d)155floor(const duration<_Rep, _Period>& __d)
153{156{
154 _ToDuration __t = duration_cast<_ToDuration>(__d);157 _ToDuration __t = chrono::duration_cast<_ToDuration>(__d);
155 if (__t > __d)158 if (__t > __d)
156 __t = __t - _ToDuration{1};159 __t = __t - _ToDuration{1};
157 return __t;160 return __t;
...@@ -166,7 +169,7 @@ typename enable_if...@@ -166,7 +169,7 @@ typename enable_if
166>::type169>::type
167ceil(const duration<_Rep, _Period>& __d)170ceil(const duration<_Rep, _Period>& __d)
168{171{
169 _ToDuration __t = duration_cast<_ToDuration>(__d);172 _ToDuration __t = chrono::duration_cast<_ToDuration>(__d);
170 if (__t < __d)173 if (__t < __d)
171 __t = __t + _ToDuration{1};174 __t = __t + _ToDuration{1};
172 return __t;175 return __t;
...@@ -181,7 +184,7 @@ typename enable_if...@@ -181,7 +184,7 @@ typename enable_if
181>::type184>::type
182round(const duration<_Rep, _Period>& __d)185round(const duration<_Rep, _Period>& __d)
183{186{
184 _ToDuration __lower = floor<_ToDuration>(__d);187 _ToDuration __lower = chrono::floor<_ToDuration>(__d);
185 _ToDuration __upper = __lower + _ToDuration{1};188 _ToDuration __upper = __lower + _ToDuration{1};
186 auto __lowerDiff = __d - __lower;189 auto __lowerDiff = __d - __lower;
187 auto __upperDiff = __upper - __d;190 auto __upperDiff = __upper - __d;
...@@ -278,18 +281,18 @@ public:...@@ -278,18 +281,18 @@ public:
278281
279 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator+() const {return typename common_type<duration>::type(*this);}282 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator+() const {return typename common_type<duration>::type(*this);}
280 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator-() const {return typename common_type<duration>::type(-__rep_);}283 _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;}284 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator++() {++__rep_; return *this;}
282 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration operator++(int) {return duration(__rep_++);}285 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration operator++(int) {return duration(__rep_++);}
283 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator--() {--__rep_; return *this;}286 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator--() {--__rep_; return *this;}
284 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration operator--(int) {return duration(__rep_--);}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;}289 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 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;}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;}292 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 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;}293 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 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;}294 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 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;}295 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 duration& operator%=(const duration& __rhs) {__rep_ %= __rhs.count(); return *this;}
293296
294 // special values297 // special values
295298
...@@ -534,67 +537,67 @@ inline namespace literals...@@ -534,67 +537,67 @@ inline namespace literals
534 inline namespace chrono_literals537 inline namespace chrono_literals
535 {538 {
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)
538 {541 {
539 return chrono::hours(static_cast<chrono::hours::rep>(__h));542 return chrono::hours(static_cast<chrono::hours::rep>(__h));
540 }543 }
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)
543 {546 {
544 return chrono::duration<long double, ratio<3600,1>>(__h);547 return chrono::duration<long double, ratio<3600,1>>(__h);
545 }548 }
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)
549 {552 {
550 return chrono::minutes(static_cast<chrono::minutes::rep>(__m));553 return chrono::minutes(static_cast<chrono::minutes::rep>(__m));
551 }554 }
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)
554 {557 {
555 return chrono::duration<long double, ratio<60,1>> (__m);558 return chrono::duration<long double, ratio<60,1>> (__m);
556 }559 }
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)
560 {563 {
561 return chrono::seconds(static_cast<chrono::seconds::rep>(__s));564 return chrono::seconds(static_cast<chrono::seconds::rep>(__s));
562 }565 }
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)
565 {568 {
566 return chrono::duration<long double> (__s);569 return chrono::duration<long double> (__s);
567 }570 }
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)
571 {574 {
572 return chrono::milliseconds(static_cast<chrono::milliseconds::rep>(__ms));575 return chrono::milliseconds(static_cast<chrono::milliseconds::rep>(__ms));
573 }576 }
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)
576 {579 {
577 return chrono::duration<long double, milli>(__ms);580 return chrono::duration<long double, milli>(__ms);
578 }581 }
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)
582 {585 {
583 return chrono::microseconds(static_cast<chrono::microseconds::rep>(__us));586 return chrono::microseconds(static_cast<chrono::microseconds::rep>(__us));
584 }587 }
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)
587 {590 {
588 return chrono::duration<long double, micro> (__us);591 return chrono::duration<long double, micro> (__us);
589 }592 }
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)
593 {596 {
594 return chrono::nanoseconds(static_cast<chrono::nanoseconds::rep>(__ns));597 return chrono::nanoseconds(static_cast<chrono::nanoseconds::rep>(__ns));
595 }598 }
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)
598 {601 {
599 return chrono::duration<long double, nano> (__ns);602 return chrono::duration<long double, nano> (__ns);
600 }603 }
...@@ -612,4 +615,8 @@ _LIBCPP_END_NAMESPACE_STD...@@ -612,4 +615,8 @@ _LIBCPP_END_NAMESPACE_STD
612615
613_LIBCPP_POP_MACROS616_LIBCPP_POP_MACROS
614617
618#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
619# include <type_traits>
620#endif
621
615#endif // _LIBCPP___CHRONO_DURATION_H622#endif // _LIBCPP___CHRONO_DURATION_H
lib/libcxx/include/__chrono/file_clock.h+1-1
...@@ -61,7 +61,7 @@ struct _FilesystemClock {...@@ -61,7 +61,7 @@ struct _FilesystemClock {
61 typedef chrono::time_point<_FilesystemClock> time_point;61 typedef chrono::time_point<_FilesystemClock> time_point;
6262
63 _LIBCPP_EXPORTED_FROM_ABI63 _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
66 _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_FUNC_VIS static time_point now() noexcept;66 _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:...@@ -57,33 +57,33 @@ public:
57 _LIBCPP_HIDE_FROM_ABI constexpr hh_mm_ss() noexcept : hh_mm_ss{_Duration::zero()} {}57 _LIBCPP_HIDE_FROM_ABI constexpr hh_mm_ss() noexcept : hh_mm_ss{_Duration::zero()} {}
5858
59 _LIBCPP_HIDE_FROM_ABI constexpr explicit hh_mm_ss(_Duration __d) noexcept :59 _LIBCPP_HIDE_FROM_ABI constexpr explicit hh_mm_ss(_Duration __d) noexcept :
60 __is_neg(__d < _Duration(0)),60 __is_neg_(__d < _Duration(0)),
61 __h(duration_cast<chrono::hours> (abs(__d))),61 __h_(chrono::duration_cast<chrono::hours> (chrono::abs(__d))),
62 __m(duration_cast<chrono::minutes>(abs(__d) - hours())),62 __m_(chrono::duration_cast<chrono::minutes>(chrono::abs(__d) - hours())),
63 __s(duration_cast<chrono::seconds>(abs(__d) - hours() - minutes())),63 __s_(chrono::duration_cast<chrono::seconds>(chrono::abs(__d) - hours() - minutes())),
64 __f(duration_cast<precision> (abs(__d) - hours() - minutes() - seconds()))64 __f_(chrono::duration_cast<precision> (chrono::abs(__d) - hours() - minutes() - seconds()))
65 {}65 {}
6666
67 _LIBCPP_HIDE_FROM_ABI constexpr bool is_negative() const noexcept { return __is_neg; }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; }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; }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; }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; }71 _LIBCPP_HIDE_FROM_ABI constexpr precision subseconds() const noexcept { return __f_; }
7272
73 _LIBCPP_HIDE_FROM_ABI constexpr precision to_duration() const noexcept73 _LIBCPP_HIDE_FROM_ABI constexpr precision to_duration() const noexcept
74 {74 {
75 auto __dur = __h + __m + __s + __f;75 auto __dur = __h_ + __m_ + __s_ + __f_;
76 return __is_neg ? -__dur : __dur;76 return __is_neg_ ? -__dur : __dur;
77 }77 }
7878
79 _LIBCPP_HIDE_FROM_ABI constexpr explicit operator precision() const noexcept { return to_duration(); }79 _LIBCPP_HIDE_FROM_ABI constexpr explicit operator precision() const noexcept { return to_duration(); }
8080
81private:81private:
82 bool __is_neg;82 bool __is_neg_;
83 chrono::hours __h;83 chrono::hours __h_;
84 chrono::minutes __m;84 chrono::minutes __m_;
85 chrono::seconds __s;85 chrono::seconds __s_;
86 precision __f;86 precision __f_;
87};87};
8888
89_LIBCPP_HIDE_FROM_ABI constexpr bool is_am(const hours& __h) noexcept { return __h >= hours( 0) && __h < hours(12); }89_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 @@...@@ -12,6 +12,7 @@
1212
13#include <__chrono/duration.h>13#include <__chrono/duration.h>
14#include <__config>14#include <__config>
15#include <compare>
1516
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header18# pragma GCC system_header
...@@ -26,18 +27,18 @@ namespace chrono...@@ -26,18 +27,18 @@ namespace chrono
2627
27class month {28class month {
28private:29private:
29 unsigned char __m;30 unsigned char __m_;
30public:31public:
31 _LIBCPP_HIDE_FROM_ABI month() = default;32 _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 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; }34 _LIBCPP_HIDE_FROM_ABI inline constexpr month& operator++() noexcept { ++__m_; return *this; }
34 _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++(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; }
36 _LIBCPP_HIDE_FROM_ABI inline constexpr month operator--(int) noexcept { month __tmp = *this; --(*this); return __tmp; }37 _LIBCPP_HIDE_FROM_ABI inline constexpr month operator--(int) noexcept { month __tmp = *this; --(*this); return __tmp; }
37 _LIBCPP_HIDE_FROM_ABI constexpr month& operator+=(const months& __m1) noexcept;38 _LIBCPP_HIDE_FROM_ABI constexpr month& operator+=(const months& __m1) noexcept;
38 _LIBCPP_HIDE_FROM_ABI constexpr month& operator-=(const months& __m1) noexcept;39 _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 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; }41 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_ >= 1 && __m_ <= 12; }
41};42};
4243
4344
...@@ -45,25 +46,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr...@@ -45,25 +46,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
45bool operator==(const month& __lhs, const month& __rhs) noexcept46bool operator==(const month& __lhs, const month& __rhs) noexcept
46{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }47{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
4748
48_LIBCPP_HIDE_FROM_ABI inline constexpr49_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const month& __lhs, const month& __rhs) noexcept {
49bool operator!=(const month& __lhs, const month& __rhs) noexcept50 return static_cast<unsigned>(__lhs) <=> static_cast<unsigned>(__rhs);
50{ return !(__lhs == __rhs); }51}
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); }
6752
68_LIBCPP_HIDE_FROM_ABI inline constexpr53_LIBCPP_HIDE_FROM_ABI inline constexpr
69month operator+ (const month& __lhs, const months& __rhs) noexcept54month operator+ (const month& __lhs, const months& __rhs) noexcept
lib/libcxx/include/__chrono/month_weekday.h+12-12
...@@ -27,14 +27,14 @@ namespace chrono...@@ -27,14 +27,14 @@ namespace chrono
2727
28class month_weekday {28class month_weekday {
29private:29private:
30 chrono::month __m;30 chrono::month __m_;
31 chrono::weekday_indexed __wdi;31 chrono::weekday_indexed __wdi_;
32public:32public:
33 _LIBCPP_HIDE_FROM_ABI constexpr month_weekday(const chrono::month& __mval, const chrono::weekday_indexed& __wdival) noexcept33 _LIBCPP_HIDE_FROM_ABI constexpr month_weekday(const chrono::month& __mval, const chrono::weekday_indexed& __wdival) noexcept
34 : __m{__mval}, __wdi{__wdival} {}34 : __m_{__mval}, __wdi_{__wdival} {}
35 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }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; }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(); }37 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_.ok() && __wdi_.ok(); }
38};38};
3939
40_LIBCPP_HIDE_FROM_ABI inline constexpr40_LIBCPP_HIDE_FROM_ABI inline constexpr
...@@ -63,14 +63,14 @@ month_weekday operator/(const weekday_indexed& __lhs, int __rhs) noexcept...@@ -63,14 +63,14 @@ month_weekday operator/(const weekday_indexed& __lhs, int __rhs) noexcept
6363
6464
65class month_weekday_last {65class month_weekday_last {
66 chrono::month __m;66 chrono::month __m_;
67 chrono::weekday_last __wdl;67 chrono::weekday_last __wdl_;
68 public:68 public:
69 _LIBCPP_HIDE_FROM_ABI constexpr month_weekday_last(const chrono::month& __mval, const chrono::weekday_last& __wdlval) noexcept69 _LIBCPP_HIDE_FROM_ABI constexpr month_weekday_last(const chrono::month& __mval, const chrono::weekday_last& __wdlval) noexcept
70 : __m{__mval}, __wdl{__wdlval} {}70 : __m_{__mval}, __wdl_{__wdlval} {}
71 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }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; }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(); }73 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_.ok() && __wdl_.ok(); }
74};74};
7575
76_LIBCPP_HIDE_FROM_ABI inline constexpr76_LIBCPP_HIDE_FROM_ABI inline constexpr
lib/libcxx/include/__chrono/monthday.h+22-53
...@@ -14,6 +14,7 @@...@@ -14,6 +14,7 @@
14#include <__chrono/day.h>14#include <__chrono/day.h>
15#include <__chrono/month.h>15#include <__chrono/month.h>
16#include <__config>16#include <__config>
17#include <compare>
1718
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header20# pragma GCC system_header
...@@ -28,26 +29,26 @@ namespace chrono...@@ -28,26 +29,26 @@ namespace chrono
2829
29class month_day {30class month_day {
30private:31private:
31 chrono::month __m;32 chrono::month __m_;
32 chrono::day __d;33 chrono::day __d_;
33public:34public:
34 _LIBCPP_HIDE_FROM_ABI month_day() = default;35 _LIBCPP_HIDE_FROM_ABI month_day() = default;
35 _LIBCPP_HIDE_FROM_ABI constexpr month_day(const chrono::month& __mval, const chrono::day& __dval) noexcept36 _LIBCPP_HIDE_FROM_ABI constexpr month_day(const chrono::month& __mval, const chrono::day& __dval) noexcept
36 : __m{__mval}, __d{__dval} {}37 : __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::month month() const noexcept { return __m_; }
38 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::day day() const noexcept { return __d; }39 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::day day() const noexcept { return __d_; }
39 _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept;40 _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept;
40};41};
4142
42_LIBCPP_HIDE_FROM_ABI inline constexpr43_LIBCPP_HIDE_FROM_ABI inline constexpr
43bool month_day::ok() const noexcept44bool month_day::ok() const noexcept
44{45{
45 if (!__m.ok()) return false;46 if (!__m_.ok()) return false;
46 const unsigned __dval = static_cast<unsigned>(__d);47 const unsigned __dval = static_cast<unsigned>(__d_);
47 if (__dval < 1 || __dval > 31) return false;48 if (__dval < 1 || __dval > 31) return false;
48 if (__dval <= 29) return true;49 if (__dval <= 29) return true;
49// Now we've got either 30 or 3150// Now we've got either 30 or 31
50 const unsigned __mval = static_cast<unsigned>(__m);51 const unsigned __mval = static_cast<unsigned>(__m_);
51 if (__mval == 2) return false;52 if (__mval == 2) return false;
52 if (__mval == 4 || __mval == 6 || __mval == 9 || __mval == 11)53 if (__mval == 4 || __mval == 6 || __mval == 9 || __mval == 11)
53 return __dval == 30;54 return __dval == 30;
...@@ -58,9 +59,11 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr...@@ -58,9 +59,11 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
58bool operator==(const month_day& __lhs, const month_day& __rhs) noexcept59bool operator==(const month_day& __lhs, const month_day& __rhs) noexcept
59{ return __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }60{ return __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
6061
61_LIBCPP_HIDE_FROM_ABI inline constexpr62_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const month_day& __lhs, const month_day& __rhs) noexcept {
62bool operator!=(const month_day& __lhs, const month_day& __rhs) noexcept63 if (auto __c = __lhs.month() <=> __rhs.month(); __c != 0)
63{ return !(__lhs == __rhs); }64 return __c;
65 return __lhs.day() <=> __rhs.day();
66}
6467
65_LIBCPP_HIDE_FROM_ABI inline constexpr68_LIBCPP_HIDE_FROM_ABI inline constexpr
66month_day operator/(const month& __lhs, const day& __rhs) noexcept69month_day operator/(const month& __lhs, const day& __rhs) noexcept
...@@ -82,58 +85,24 @@ _LIBCPP_HIDE_FROM_ABI constexpr...@@ -82,58 +85,24 @@ _LIBCPP_HIDE_FROM_ABI constexpr
82month_day operator/(const day& __lhs, int __rhs) noexcept85month_day operator/(const day& __lhs, int __rhs) noexcept
83{ return month(__rhs) / __lhs; }86{ 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
104class month_day_last {88class month_day_last {
105private:89private:
106 chrono::month __m;90 chrono::month __m_;
107public:91public:
108 _LIBCPP_HIDE_FROM_ABI explicit constexpr month_day_last(const chrono::month& __val) noexcept92 _LIBCPP_HIDE_FROM_ABI explicit constexpr month_day_last(const chrono::month& __val) noexcept
109 : __m{__val} {}93 : __m_{__val} {}
110 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; }94 _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(); }95 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_.ok(); }
112};96};
11397
114_LIBCPP_HIDE_FROM_ABI inline constexpr98_LIBCPP_HIDE_FROM_ABI inline constexpr
115bool operator==(const month_day_last& __lhs, const month_day_last& __rhs) noexcept99bool operator==(const month_day_last& __lhs, const month_day_last& __rhs) noexcept
116{ return __lhs.month() == __rhs.month(); }100{ return __lhs.month() == __rhs.month(); }
117101
118_LIBCPP_HIDE_FROM_ABI inline constexpr102_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering
119bool operator!=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept103operator<=>(const month_day_last& __lhs, const month_day_last& __rhs) noexcept {
120{ return !(__lhs == __rhs); }104 return __lhs.month() <=> __rhs.month();
121105}
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); }
137106
138_LIBCPP_HIDE_FROM_ABI inline constexpr107_LIBCPP_HIDE_FROM_ABI inline constexpr
139month_day_last operator/(const month& __lhs, last_spec) noexcept108month_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:...@@ -31,7 +31,7 @@ public:
31 typedef duration::rep rep;31 typedef duration::rep rep;
32 typedef duration::period period;32 typedef duration::period period;
33 typedef chrono::time_point<steady_clock, duration> time_point;33 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
36 static time_point now() _NOEXCEPT;36 static time_point now() _NOEXCEPT;
37};37};
lib/libcxx/include/__chrono/system_clock.h+1-1
...@@ -31,7 +31,7 @@ public:...@@ -31,7 +31,7 @@ public:
31 typedef duration::rep rep;31 typedef duration::rep rep;
32 typedef duration::period period;32 typedef duration::period period;
33 typedef chrono::time_point<system_clock> time_point;33 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
36 static time_point now() _NOEXCEPT;36 static time_point now() _NOEXCEPT;
37 static time_t to_time_t (const time_point& __t) _NOEXCEPT;37 static time_t to_time_t (const time_point& __t) _NOEXCEPT;
lib/libcxx/include/__chrono/time_point.h+23-21
...@@ -12,8 +12,10 @@...@@ -12,8 +12,10 @@
1212
13#include <__chrono/duration.h>13#include <__chrono/duration.h>
14#include <__config>14#include <__config>
15#include <__type_traits/common_type.h>
16#include <__type_traits/enable_if.h>
17#include <__type_traits/is_convertible.h>
15#include <limits>18#include <limits>
16#include <type_traits>
1719
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header21# pragma GCC system_header
...@@ -41,12 +43,12 @@ private:...@@ -41,12 +43,12 @@ private:
41 duration __d_;43 duration __d_;
4244
43public:45public:
44 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point() : __d_(duration::zero()) {}46 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 time_point() : __d_(duration::zero()) {}
45 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit time_point(const duration& __d) : __d_(__d) {}47 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit time_point(const duration& __d) : __d_(__d) {}
4648
47 // conversions49 // conversions
48 template <class _Duration2>50 template <class _Duration2>
49 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1151 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
50 time_point(const time_point<clock, _Duration2>& __t,52 time_point(const time_point<clock, _Duration2>& __t,
51 typename enable_if53 typename enable_if
52 <54 <
...@@ -56,12 +58,12 @@ public:...@@ -56,12 +58,12 @@ public:
5658
57 // observer59 // 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
61 // arithmetic63 // arithmetic
6264
63 _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;}
64 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 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
66 // special values68 // special values
6769
...@@ -81,7 +83,7 @@ struct _LIBCPP_TEMPLATE_VIS common_type<chrono::time_point<_Clock, _Duration1>,...@@ -81,7 +83,7 @@ struct _LIBCPP_TEMPLATE_VIS common_type<chrono::time_point<_Clock, _Duration1>,
81namespace chrono {83namespace chrono {
8284
83template <class _ToDuration, class _Clock, class _Duration>85template <class _ToDuration, class _Clock, class _Duration>
84inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1186inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
85time_point<_Clock, _ToDuration>87time_point<_Clock, _ToDuration>
86time_point_cast(const time_point<_Clock, _Duration>& __t)88time_point_cast(const time_point<_Clock, _Duration>& __t)
87{89{
...@@ -98,7 +100,7 @@ typename enable_if...@@ -98,7 +100,7 @@ typename enable_if
98>::type100>::type
99floor(const time_point<_Clock, _Duration>& __t)101floor(const time_point<_Clock, _Duration>& __t)
100{102{
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())};
102}104}
103105
104template <class _ToDuration, class _Clock, class _Duration>106template <class _ToDuration, class _Clock, class _Duration>
...@@ -110,7 +112,7 @@ typename enable_if...@@ -110,7 +112,7 @@ typename enable_if
110>::type112>::type
111ceil(const time_point<_Clock, _Duration>& __t)113ceil(const time_point<_Clock, _Duration>& __t)
112{114{
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())};
114}116}
115117
116template <class _ToDuration, class _Clock, class _Duration>118template <class _ToDuration, class _Clock, class _Duration>
...@@ -122,7 +124,7 @@ typename enable_if...@@ -122,7 +124,7 @@ typename enable_if
122>::type124>::type
123round(const time_point<_Clock, _Duration>& __t)125round(const time_point<_Clock, _Duration>& __t)
124{126{
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())};
126}128}
127129
128template <class _Rep, class _Period>130template <class _Rep, class _Period>
...@@ -141,7 +143,7 @@ abs(duration<_Rep, _Period> __d)...@@ -141,7 +143,7 @@ abs(duration<_Rep, _Period> __d)
141// time_point ==143// time_point ==
142144
143template <class _Clock, class _Duration1, class _Duration2>145template <class _Clock, class _Duration1, class _Duration2>
144inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11146inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
145bool147bool
146operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)148operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
147{149{
...@@ -151,7 +153,7 @@ operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,...@@ -151,7 +153,7 @@ operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
151// time_point !=153// time_point !=
152154
153template <class _Clock, class _Duration1, class _Duration2>155template <class _Clock, class _Duration1, class _Duration2>
154inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11156inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
155bool157bool
156operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)158operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
157{159{
...@@ -161,7 +163,7 @@ operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,...@@ -161,7 +163,7 @@ operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
161// time_point <163// time_point <
162164
163template <class _Clock, class _Duration1, class _Duration2>165template <class _Clock, class _Duration1, class _Duration2>
164inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11166inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
165bool167bool
166operator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)168operator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
167{169{
...@@ -171,7 +173,7 @@ operator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,...@@ -171,7 +173,7 @@ operator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
171// time_point >173// time_point >
172174
173template <class _Clock, class _Duration1, class _Duration2>175template <class _Clock, class _Duration1, class _Duration2>
174inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11176inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
175bool177bool
176operator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)178operator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
177{179{
...@@ -181,7 +183,7 @@ operator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,...@@ -181,7 +183,7 @@ operator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
181// time_point <=183// time_point <=
182184
183template <class _Clock, class _Duration1, class _Duration2>185template <class _Clock, class _Duration1, class _Duration2>
184inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11186inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
185bool187bool
186operator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)188operator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
187{189{
...@@ -191,7 +193,7 @@ operator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,...@@ -191,7 +193,7 @@ operator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
191// time_point >=193// time_point >=
192194
193template <class _Clock, class _Duration1, class _Duration2>195template <class _Clock, class _Duration1, class _Duration2>
194inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11196inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
195bool197bool
196operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)198operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
197{199{
...@@ -201,7 +203,7 @@ operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,...@@ -201,7 +203,7 @@ operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
201// time_point operator+(time_point x, duration y);203// time_point operator+(time_point x, duration y);
202204
203template <class _Clock, class _Duration1, class _Rep2, class _Period2>205template <class _Clock, class _Duration1, class _Rep2, class _Period2>
204inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11206inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
205time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>207time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
206operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)208operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
207{209{
...@@ -212,7 +214,7 @@ operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Pe...@@ -212,7 +214,7 @@ operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Pe
212// time_point operator+(duration x, time_point y);214// time_point operator+(duration x, time_point y);
213215
214template <class _Rep1, class _Period1, class _Clock, class _Duration2>216template <class _Rep1, class _Period1, class _Clock, class _Duration2>
215inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11217inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
216time_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type>218time_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type>
217operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)219operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
218{220{
...@@ -222,7 +224,7 @@ operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Dura...@@ -222,7 +224,7 @@ operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Dura
222// time_point operator-(time_point x, duration y);224// time_point operator-(time_point x, duration y);
223225
224template <class _Clock, class _Duration1, class _Rep2, class _Period2>226template <class _Clock, class _Duration1, class _Rep2, class _Period2>
225inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11227inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
226time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>228time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
227operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)229operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
228{230{
...@@ -233,7 +235,7 @@ operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Pe...@@ -233,7 +235,7 @@ operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Pe
233// duration operator-(time_point x, time_point y);235// duration operator-(time_point x, time_point y);
234236
235template <class _Clock, class _Duration1, class _Duration2>237template <class _Clock, class _Duration1, class _Duration2>
236inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11238inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
237typename common_type<_Duration1, _Duration2>::type239typename common_type<_Duration1, _Duration2>::type
238operator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)240operator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
239{241{
lib/libcxx/include/__chrono/weekday.h+19-19
...@@ -32,25 +32,25 @@ class weekday_last;...@@ -32,25 +32,25 @@ class weekday_last;
3232
33class weekday {33class weekday {
34private:34private:
35 unsigned char __wd;35 unsigned char __wd_;
36 _LIBCPP_HIDE_FROM_ABI static constexpr unsigned char __weekday_from_days(int __days) noexcept;36 _LIBCPP_HIDE_FROM_ABI static constexpr unsigned char __weekday_from_days(int __days) noexcept;
37public:37public:
38 _LIBCPP_HIDE_FROM_ABI weekday() = default;38 _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)) {}
40 _LIBCPP_HIDE_FROM_ABI inline constexpr weekday(const sys_days& __sysd) noexcept40 _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())) {}
42 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr weekday(const local_days& __locd) noexcept42 _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; }
46 _LIBCPP_HIDE_FROM_ABI inline constexpr weekday operator++(int) noexcept { weekday __tmp = *this; ++(*this); return __tmp; }46 _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; }
48 _LIBCPP_HIDE_FROM_ABI inline constexpr weekday operator--(int) noexcept { weekday __tmp = *this; --(*this); return __tmp; }48 _LIBCPP_HIDE_FROM_ABI inline constexpr weekday operator--(int) noexcept { weekday __tmp = *this; --(*this); return __tmp; }
49 _LIBCPP_HIDE_FROM_ABI constexpr weekday& operator+=(const days& __dd) noexcept;49 _LIBCPP_HIDE_FROM_ABI constexpr weekday& operator+=(const days& __dd) noexcept;
50 _LIBCPP_HIDE_FROM_ABI constexpr weekday& operator-=(const days& __dd) noexcept;50 _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; }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; }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; }53 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __wd_ <= 6; }
54 _LIBCPP_HIDE_FROM_ABI constexpr weekday_indexed operator[](unsigned __index) const noexcept;54 _LIBCPP_HIDE_FROM_ABI constexpr weekday_indexed operator[](unsigned __index) const noexcept;
55 _LIBCPP_HIDE_FROM_ABI constexpr weekday_last operator[](last_spec) const noexcept;55 _LIBCPP_HIDE_FROM_ABI constexpr weekday_last operator[](last_spec) const noexcept;
56};56};
...@@ -123,15 +123,15 @@ weekday& weekday::operator-=(const days& __dd) noexcept...@@ -123,15 +123,15 @@ weekday& weekday::operator-=(const days& __dd) noexcept
123123
124class weekday_indexed {124class weekday_indexed {
125private:125private:
126 chrono::weekday __wd;126 chrono::weekday __wd_;
127 unsigned char __idx;127 unsigned char __idx_;
128public:128public:
129 _LIBCPP_HIDE_FROM_ABI weekday_indexed() = default;129 _LIBCPP_HIDE_FROM_ABI weekday_indexed() = default;
130 _LIBCPP_HIDE_FROM_ABI inline constexpr weekday_indexed(const chrono::weekday& __wdval, unsigned __idxval) noexcept130 _LIBCPP_HIDE_FROM_ABI inline constexpr weekday_indexed(const chrono::weekday& __wdval, unsigned __idxval) noexcept
131 : __wd{__wdval}, __idx(__idxval) {}131 : __wd_{__wdval}, __idx_(__idxval) {}
132 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wd; }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; }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; }134 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __wd_.ok() && __idx_ >= 1 && __idx_ <= 5; }
135};135};
136136
137_LIBCPP_HIDE_FROM_ABI inline constexpr137_LIBCPP_HIDE_FROM_ABI inline constexpr
...@@ -145,12 +145,12 @@ bool operator!=(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noex...@@ -145,12 +145,12 @@ bool operator!=(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noex
145145
146class weekday_last {146class weekday_last {
147private:147private:
148 chrono::weekday __wd;148 chrono::weekday __wd_;
149public:149public:
150 _LIBCPP_HIDE_FROM_ABI explicit constexpr weekday_last(const chrono::weekday& __val) noexcept150 _LIBCPP_HIDE_FROM_ABI explicit constexpr weekday_last(const chrono::weekday& __val) noexcept
151 : __wd{__val} {}151 : __wd_{__val} {}
152 _LIBCPP_HIDE_FROM_ABI constexpr chrono::weekday weekday() const noexcept { return __wd; }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(); }153 _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept { return __wd_.ok(); }
154};154};
155155
156_LIBCPP_HIDE_FROM_ABI inline constexpr156_LIBCPP_HIDE_FROM_ABI inline constexpr
lib/libcxx/include/__chrono/year.h+13-28
...@@ -12,6 +12,7 @@...@@ -12,6 +12,7 @@
1212
13#include <__chrono/duration.h>13#include <__chrono/duration.h>
14#include <__config>14#include <__config>
15#include <compare>
15#include <limits>16#include <limits>
1617
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -30,22 +31,22 @@ namespace chrono...@@ -30,22 +31,22 @@ namespace chrono
3031
31class year {32class year {
32private:33private:
33 short __y;34 short __y_;
34public:35public:
35 _LIBCPP_HIDE_FROM_ABI year() = default;36 _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; }
39 _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++(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; }
41 _LIBCPP_HIDE_FROM_ABI inline constexpr year operator--(int) noexcept { year __tmp = *this; --(*this); return __tmp; }42 _LIBCPP_HIDE_FROM_ABI inline constexpr year operator--(int) noexcept { year __tmp = *this; --(*this); return __tmp; }
42 _LIBCPP_HIDE_FROM_ABI constexpr year& operator+=(const years& __dy) noexcept;43 _LIBCPP_HIDE_FROM_ABI constexpr year& operator+=(const years& __dy) noexcept;
43 _LIBCPP_HIDE_FROM_ABI constexpr year& operator-=(const years& __dy) noexcept;44 _LIBCPP_HIDE_FROM_ABI constexpr year& operator-=(const years& __dy) noexcept;
44 _LIBCPP_HIDE_FROM_ABI inline constexpr year operator+() const noexcept { return *this; }45 _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 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; }49 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator int() const noexcept { return __y_; }
49 _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept;50 _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept;
50 _LIBCPP_HIDE_FROM_ABI static inline constexpr year min() noexcept { return year{-32767}; }51 _LIBCPP_HIDE_FROM_ABI static inline constexpr year min() noexcept { return year{-32767}; }
51 _LIBCPP_HIDE_FROM_ABI static inline constexpr year max() noexcept { return year{ 32767}; }52 _LIBCPP_HIDE_FROM_ABI static inline constexpr year max() noexcept { return year{ 32767}; }
...@@ -56,25 +57,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr...@@ -56,25 +57,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
56bool operator==(const year& __lhs, const year& __rhs) noexcept57bool operator==(const year& __lhs, const year& __rhs) noexcept
57{ return static_cast<int>(__lhs) == static_cast<int>(__rhs); }58{ return static_cast<int>(__lhs) == static_cast<int>(__rhs); }
5859
59_LIBCPP_HIDE_FROM_ABI inline constexpr60_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const year& __lhs, const year& __rhs) noexcept {
60bool operator!=(const year& __lhs, const year& __rhs) noexcept61 return static_cast<int>(__lhs) <=> static_cast<int>(__rhs);
61{ return !(__lhs == __rhs); }62}
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); }
7863
79_LIBCPP_HIDE_FROM_ABI inline constexpr64_LIBCPP_HIDE_FROM_ABI inline constexpr
80year operator+ (const year& __lhs, const years& __rhs) noexcept65year operator+ (const year& __lhs, const years& __rhs) noexcept
...@@ -102,8 +87,8 @@ year& year::operator-=(const years& __dy) noexcept...@@ -102,8 +87,8 @@ year& year::operator-=(const years& __dy) noexcept
102{ *this = *this - __dy; return *this; }87{ *this = *this - __dy; return *this; }
10388
104_LIBCPP_HIDE_FROM_ABI constexpr bool year::ok() const noexcept {89_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()));90 static_assert(static_cast<int>(std::numeric_limits<decltype(__y_)>::max()) == static_cast<int>(max()));
106 return static_cast<int>(min()) <= __y;91 return static_cast<int>(min()) <= __y_;
107}92}
10893
109} // namespace chrono94} // namespace chrono
lib/libcxx/include/__chrono/year_month.h+16-29
...@@ -14,6 +14,7 @@...@@ -14,6 +14,7 @@
14#include <__chrono/month.h>14#include <__chrono/month.h>
15#include <__chrono/year.h>15#include <__chrono/year.h>
16#include <__config>16#include <__config>
17#include <compare>
1718
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header20# pragma GCC system_header
...@@ -27,19 +28,19 @@ namespace chrono...@@ -27,19 +28,19 @@ namespace chrono
27{28{
2829
29class year_month {30class year_month {
30 chrono::year __y;31 chrono::year __y_;
31 chrono::month __m;32 chrono::month __m_;
32public:33public:
33 _LIBCPP_HIDE_FROM_ABI year_month() = default;34 _LIBCPP_HIDE_FROM_ABI year_month() = default;
34 _LIBCPP_HIDE_FROM_ABI constexpr year_month(const chrono::year& __yval, const chrono::month& __mval) noexcept35 _LIBCPP_HIDE_FROM_ABI constexpr year_month(const chrono::year& __yval, const chrono::month& __mval) noexcept
35 : __y{__yval}, __m{__mval} {}36 : __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::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 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; }
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; }
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; }
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; }
42 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok(); }43 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y_.ok() && __m_.ok(); }
43};44};
4445
45_LIBCPP_HIDE_FROM_ABI inline constexpr46_LIBCPP_HIDE_FROM_ABI inline constexpr
...@@ -52,25 +53,11 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr...@@ -52,25 +53,11 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
52bool operator==(const year_month& __lhs, const year_month& __rhs) noexcept53bool operator==(const year_month& __lhs, const year_month& __rhs) noexcept
53{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month(); }54{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month(); }
5455
55_LIBCPP_HIDE_FROM_ABI inline constexpr56_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const year_month& __lhs, const year_month& __rhs) noexcept {
56bool operator!=(const year_month& __lhs, const year_month& __rhs) noexcept57 if (auto __c = __lhs.year() <=> __rhs.year(); __c != 0)
57{ return !(__lhs == __rhs); }58 return __c;
5859 return __lhs.month() <=> __rhs.month();
59_LIBCPP_HIDE_FROM_ABI inline constexpr60}
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); }
7461
75_LIBCPP_HIDE_FROM_ABI constexpr62_LIBCPP_HIDE_FROM_ABI constexpr
76year_month operator+(const year_month& __lhs, const months& __rhs) noexcept63year_month operator+(const year_month& __lhs, const months& __rhs) noexcept
lib/libcxx/include/__chrono/year_month_day.h+29-45
...@@ -20,6 +20,7 @@...@@ -20,6 +20,7 @@
20#include <__chrono/year.h>20#include <__chrono/year.h>
21#include <__chrono/year_month.h>21#include <__chrono/year_month.h>
22#include <__config>22#include <__config>
23#include <compare>
23#include <limits>24#include <limits>
2425
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -37,14 +38,14 @@ class year_month_day_last;...@@ -37,14 +38,14 @@ class year_month_day_last;
3738
38class year_month_day {39class year_month_day {
39private:40private:
40 chrono::year __y;41 chrono::year __y_;
41 chrono::month __m;42 chrono::month __m_;
42 chrono::day __d;43 chrono::day __d_;
43public:44public:
44 _LIBCPP_HIDE_FROM_ABI year_month_day() = default;45 _LIBCPP_HIDE_FROM_ABI year_month_day() = default;
45 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day(46 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day(
46 const chrono::year& __yval, const chrono::month& __mval, const chrono::day& __dval) noexcept47 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} {}
48 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day(const year_month_day_last& __ymdl) noexcept;49 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day(const year_month_day_last& __ymdl) noexcept;
49 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day(const sys_days& __sysd) noexcept50 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day(const sys_days& __sysd) noexcept
50 : year_month_day(__from_days(__sysd.time_since_epoch())) {}51 : year_month_day(__from_days(__sysd.time_since_epoch())) {}
...@@ -56,9 +57,9 @@ public:...@@ -56,9 +57,9 @@ public:
56 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day& operator+=(const years& __dy) noexcept;57 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day& operator+=(const years& __dy) noexcept;
57 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day& operator-=(const years& __dy) noexcept;58 _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::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::month month() const noexcept { return __m_; }
61 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::day day() const noexcept { return __d; }62 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::day day() const noexcept { return __d_; }
62 _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }63 _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
63 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }64 _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...@@ -94,9 +95,9 @@ days year_month_day::__to_days() const noexcept
94 static_assert(numeric_limits<unsigned>::digits >= 18, "");95 static_assert(numeric_limits<unsigned>::digits >= 18, "");
95 static_assert(numeric_limits<int>::digits >= 20 , "");96 static_assert(numeric_limits<int>::digits >= 20 , "");
9697
97 const int __yr = static_cast<int>(__y) - (__m <= February);98 const int __yr = static_cast<int>(__y_) - (__m_ <= February);
98 const unsigned __mth = static_cast<unsigned>(__m);99 const unsigned __mth = static_cast<unsigned>(__m_);
99 const unsigned __dy = static_cast<unsigned>(__d);100 const unsigned __dy = static_cast<unsigned>(__d_);
100101
101 const int __era = (__yr >= 0 ? __yr : __yr - 399) / 400;102 const int __era = (__yr >= 0 ? __yr : __yr - 399) / 400;
102 const unsigned __yoe = static_cast<unsigned>(__yr - __era * 400); // [0, 399]103 const unsigned __yoe = static_cast<unsigned>(__yr - __era * 400); // [0, 399]
...@@ -109,32 +110,15 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr...@@ -109,32 +110,15 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr
109bool operator==(const year_month_day& __lhs, const year_month_day& __rhs) noexcept110bool operator==(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
110{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }111{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
111112
112_LIBCPP_HIDE_FROM_ABI inline constexpr113_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering
113bool operator!=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept114operator<=>(const year_month_day& __lhs, const year_month_day& __rhs) noexcept {
114{ return !(__lhs == __rhs); }115 if (auto __c = __lhs.year() <=> __rhs.year(); __c != 0)
115116 return __c;
116_LIBCPP_HIDE_FROM_ABI inline constexpr117 if (auto __c = __lhs.month() <=> __rhs.month(); __c != 0)
117bool operator< (const year_month_day& __lhs, const year_month_day& __rhs) noexcept118 return __c;
118{119 return __lhs.day() <=> __rhs.day();
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();
124}120}
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
138_LIBCPP_HIDE_FROM_ABI inline constexpr122_LIBCPP_HIDE_FROM_ABI inline constexpr
139year_month_day operator/(const year_month& __lhs, const day& __rhs) noexcept123year_month_day operator/(const year_month& __lhs, const day& __rhs) noexcept
140{ return year_month_day{__lhs.year(), __lhs.month(), __rhs}; }124{ 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-...@@ -191,24 +175,24 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day& year_month_day::operator-
191175
192class year_month_day_last {176class year_month_day_last {
193private:177private:
194 chrono::year __y;178 chrono::year __y_;
195 chrono::month_day_last __mdl;179 chrono::month_day_last __mdl_;
196public:180public:
197 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last(const year& __yval, const month_day_last& __mdlval) noexcept181 _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
200 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator+=(const months& __m) noexcept;184 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator+=(const months& __m) noexcept;
201 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator-=(const months& __m) noexcept;185 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator-=(const months& __m) noexcept;
202 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator+=(const years& __y) noexcept;186 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator+=(const years& __y) noexcept;
203 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator-=(const years& __y) noexcept;187 _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; }189 _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(); }190 _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; }191 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month_day_last month_day_last() const noexcept { return __mdl_; }
208 _LIBCPP_HIDE_FROM_ABI constexpr chrono::day day() const noexcept;192 _LIBCPP_HIDE_FROM_ABI constexpr chrono::day day() const noexcept;
209 _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{year()/month()/day()}; }193 _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{year()/month()/day()}; }
210 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{year()/month()/day()}; }194 _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(); }
212};196};
213197
214_LIBCPP_HIDE_FROM_ABI inline constexpr198_LIBCPP_HIDE_FROM_ABI inline constexpr
...@@ -221,7 +205,7 @@ chrono::day year_month_day_last::day() const noexcept...@@ -221,7 +205,7 @@ chrono::day year_month_day_last::day() const noexcept
221 chrono::day(31), chrono::day(31), chrono::day(30),205 chrono::day(31), chrono::day(31), chrono::day(30),
222 chrono::day(31), chrono::day(30), chrono::day(31)206 chrono::day(31), chrono::day(30), chrono::day(31)
223 };207 };
224 return (month() != February || !__y.is_leap()) && month().ok() ?208 return (month() != February || !__y_.is_leap()) && month().ok() ?
225 __d[static_cast<unsigned>(month()) - 1] : chrono::day{29};209 __d[static_cast<unsigned>(month()) - 1] : chrono::day{29};
226}210}
227211
...@@ -305,13 +289,13 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last& year_month_day_last:...@@ -305,13 +289,13 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last& year_month_day_last:
305289
306_LIBCPP_HIDE_FROM_ABI inline constexpr290_LIBCPP_HIDE_FROM_ABI inline constexpr
307year_month_day::year_month_day(const year_month_day_last& __ymdl) noexcept291year_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
310_LIBCPP_HIDE_FROM_ABI inline constexpr294_LIBCPP_HIDE_FROM_ABI inline constexpr
311bool year_month_day::ok() const noexcept295bool year_month_day::ok() const noexcept
312{296{
313 if (!__y.ok() || !__m.ok()) return false;297 if (!__y_.ok() || !__m_.ok()) return false;
314 return chrono::day{1} <= __d && __d <= (__y / __m / last).day();298 return chrono::day{1} <= __d_ && __d_ <= (__y_ / __m_ / last).day();
315}299}
316300
317} // namespace chrono301} // namespace chrono
lib/libcxx/include/__chrono/year_month_weekday.h+28-28
...@@ -35,14 +35,14 @@ namespace chrono...@@ -35,14 +35,14 @@ namespace chrono
35{35{
3636
37class year_month_weekday {37class year_month_weekday {
38 chrono::year __y;38 chrono::year __y_;
39 chrono::month __m;39 chrono::month __m_;
40 chrono::weekday_indexed __wdi;40 chrono::weekday_indexed __wdi_;
41public:41public:
42 _LIBCPP_HIDE_FROM_ABI year_month_weekday() = default;42 _LIBCPP_HIDE_FROM_ABI year_month_weekday() = default;
43 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday(const chrono::year& __yval, const chrono::month& __mval,43 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday(const chrono::year& __yval, const chrono::month& __mval,
44 const chrono::weekday_indexed& __wdival) noexcept44 const chrono::weekday_indexed& __wdival) noexcept
45 : __y{__yval}, __m{__mval}, __wdi{__wdival} {}45 : __y_{__yval}, __m_{__mval}, __wdi_{__wdival} {}
46 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday(const sys_days& __sysd) noexcept46 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday(const sys_days& __sysd) noexcept
47 : year_month_weekday(__from_days(__sysd.time_since_epoch())) {}47 : year_month_weekday(__from_days(__sysd.time_since_epoch())) {}
48 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr year_month_weekday(const local_days& __locd) noexcept48 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr year_month_weekday(const local_days& __locd) noexcept
...@@ -52,24 +52,24 @@ public:...@@ -52,24 +52,24 @@ public:
52 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday& operator+=(const years&) noexcept;52 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday& operator+=(const years&) noexcept;
53 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday& operator-=(const years&) noexcept;53 _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; }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; }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(); }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(); }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; }59 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi_; }
6060
61 _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }61 _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
62 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }62 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
63 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept63 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept
64 {64 {
65 if (!__y.ok() || !__m.ok() || !__wdi.ok()) return false;65 if (!__y_.ok() || !__m_.ok() || !__wdi_.ok()) return false;
66 if (__wdi.index() <= 4) return true;66 if (__wdi_.index() <= 4) return true;
67 auto __nth_weekday_day =67 auto __nth_weekday_day =
68 __wdi.weekday() -68 __wdi_.weekday() -
69 chrono::weekday{static_cast<sys_days>(__y / __m / 1)} +69 chrono::weekday{static_cast<sys_days>(__y_ / __m_ / 1)} +
70 days{(__wdi.index() - 1) * 7 + 1};70 days{(__wdi_.index() - 1) * 7 + 1};
71 return static_cast<unsigned>(__nth_weekday_day.count()) <=71 return static_cast<unsigned>(__nth_weekday_day.count()) <=
72 static_cast<unsigned>((__y / __m / last).day());72 static_cast<unsigned>((__y_ / __m_ / last).day());
73 }73 }
7474
75 _LIBCPP_HIDE_FROM_ABI static constexpr year_month_weekday __from_days(days __d) noexcept;75 _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...@@ -89,8 +89,8 @@ year_month_weekday year_month_weekday::__from_days(days __d) noexcept
89_LIBCPP_HIDE_FROM_ABI inline constexpr89_LIBCPP_HIDE_FROM_ABI inline constexpr
90days year_month_weekday::__to_days() const noexcept90days year_month_weekday::__to_days() const noexcept
91{91{
92 const sys_days __sysd = sys_days(__y/__m/1);92 const sys_days __sysd = sys_days(__y_/__m_/1);
93 return (__sysd + (__wdi.weekday() - chrono::weekday(__sysd) + days{(__wdi.index()-1)*7}))93 return (__sysd + (__wdi_.weekday() - chrono::weekday(__sysd) + days{(__wdi_.index()-1)*7}))
94 .time_since_epoch();94 .time_since_epoch();
95}95}
9696
...@@ -155,25 +155,25 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday& year_month_weekday::o...@@ -155,25 +155,25 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday& year_month_weekday::o
155155
156class year_month_weekday_last {156class year_month_weekday_last {
157private:157private:
158 chrono::year __y;158 chrono::year __y_;
159 chrono::month __m;159 chrono::month __m_;
160 chrono::weekday_last __wdl;160 chrono::weekday_last __wdl_;
161public:161public:
162 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last(const chrono::year& __yval, const chrono::month& __mval,162 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last(const chrono::year& __yval, const chrono::month& __mval,
163 const chrono::weekday_last& __wdlval) noexcept163 const chrono::weekday_last& __wdlval) noexcept
164 : __y{__yval}, __m{__mval}, __wdl{__wdlval} {}164 : __y_{__yval}, __m_{__mval}, __wdl_{__wdlval} {}
165 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator+=(const months& __dm) noexcept;165 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator+=(const months& __dm) noexcept;
166 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator-=(const months& __dm) noexcept;166 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator-=(const months& __dm) noexcept;
167 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator+=(const years& __dy) noexcept;167 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator+=(const years& __dy) noexcept;
168 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator-=(const years& __dy) noexcept;168 _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; }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; }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(); }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; }173 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl_; }
174 _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }174 _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
175 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }175 _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
178 _LIBCPP_HIDE_FROM_ABI constexpr days __to_days() const noexcept;178 _LIBCPP_HIDE_FROM_ABI constexpr days __to_days() const noexcept;
179179
...@@ -182,8 +182,8 @@ public:...@@ -182,8 +182,8 @@ public:
182_LIBCPP_HIDE_FROM_ABI inline constexpr182_LIBCPP_HIDE_FROM_ABI inline constexpr
183days year_month_weekday_last::__to_days() const noexcept183days year_month_weekday_last::__to_days() const noexcept
184{184{
185 const sys_days __last = sys_days{__y/__m/last};185 const sys_days __last = sys_days{__y_/__m_/last};
186 return (__last - (chrono::weekday{__last} - __wdl.weekday())).time_since_epoch();186 return (__last - (chrono::weekday{__last} - __wdl_.weekday())).time_since_epoch();
187187
188}188}
189189
lib/libcxx/include/__compare/common_comparison_category.h+3-2
...@@ -11,7 +11,8 @@...@@ -11,7 +11,8 @@
1111
12#include <__compare/ordering.h>12#include <__compare/ordering.h>
13#include <__config>13#include <__config>
14#include <type_traits>14#include <__type_traits/is_same.h>
15#include <cstddef>
1516
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header18# pragma GCC system_header
...@@ -64,7 +65,7 @@ _LIBCPP_HIDE_FROM_ABI...@@ -64,7 +65,7 @@ _LIBCPP_HIDE_FROM_ABI
64constexpr auto __get_comp_type() {65constexpr auto __get_comp_type() {
65 using _CCC = _ClassifyCompCategory;66 using _CCC = _ClassifyCompCategory;
66 constexpr _CCC __type_kinds[] = {_StrongOrd, __type_to_enum<_Ts>()...};67 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);
68 if constexpr (_Cat == _None)69 if constexpr (_Cat == _None)
69 return void();70 return void();
70 else if constexpr (_Cat == _PartialOrd)71 else if constexpr (_Cat == _PartialOrd)
lib/libcxx/include/__compare/compare_partial_order_fallback.h+2-1
...@@ -12,9 +12,10 @@...@@ -12,9 +12,10 @@
12#include <__compare/ordering.h>12#include <__compare/ordering.h>
13#include <__compare/partial_order.h>13#include <__compare/partial_order.h>
14#include <__config>14#include <__config>
15#include <__type_traits/decay.h>
16#include <__type_traits/is_same.h>
15#include <__utility/forward.h>17#include <__utility/forward.h>
16#include <__utility/priority_tag.h>18#include <__utility/priority_tag.h>
17#include <type_traits>
1819
19#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER20#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
20# pragma GCC system_header21# pragma GCC system_header
lib/libcxx/include/__compare/compare_strong_order_fallback.h+2-1
...@@ -12,9 +12,10 @@...@@ -12,9 +12,10 @@
12#include <__compare/ordering.h>12#include <__compare/ordering.h>
13#include <__compare/strong_order.h>13#include <__compare/strong_order.h>
14#include <__config>14#include <__config>
15#include <__type_traits/decay.h>
16#include <__type_traits/is_same.h>
15#include <__utility/forward.h>17#include <__utility/forward.h>
16#include <__utility/priority_tag.h>18#include <__utility/priority_tag.h>
17#include <type_traits>
1819
19#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER20#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
20# pragma GCC system_header21# pragma GCC system_header
lib/libcxx/include/__compare/compare_three_way_result.h+4-3
...@@ -10,7 +10,8 @@...@@ -10,7 +10,8 @@
10#define _LIBCPP___COMPARE_COMPARE_THREE_WAY_RESULT_H10#define _LIBCPP___COMPARE_COMPARE_THREE_WAY_RESULT_H
1111
12#include <__config>12#include <__config>
13#include <type_traits>13#include <__type_traits/make_const_lvalue_ref.h>
14#include <__utility/declval.h>
1415
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header17# pragma GCC system_header
...@@ -25,9 +26,9 @@ struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result { };...@@ -25,9 +26,9 @@ struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result { };
2526
26template<class _Tp, class _Up>27template<class _Tp, class _Up>
27struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result<_Tp, _Up, decltype(28struct _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()
29)> {30)> {
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>>());
31};32};
3233
33template<class _Tp, class _Up = _Tp>34template<class _Tp, class _Up = _Tp>
lib/libcxx/include/__compare/compare_weak_order_fallback.h+2-1
...@@ -12,9 +12,10 @@...@@ -12,9 +12,10 @@
12#include <__compare/ordering.h>12#include <__compare/ordering.h>
13#include <__compare/weak_order.h>13#include <__compare/weak_order.h>
14#include <__config>14#include <__config>
15#include <__type_traits/decay.h>
16#include <__type_traits/is_same.h>
15#include <__utility/forward.h>17#include <__utility/forward.h>
16#include <__utility/priority_tag.h>18#include <__utility/priority_tag.h>
17#include <type_traits>
1819
19#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER20#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
20# pragma GCC system_header21# pragma GCC system_header
lib/libcxx/include/__compare/ordering.h+8-1
...@@ -10,7 +10,8 @@...@@ -10,7 +10,8 @@
10#define _LIBCPP___COMPARE_ORDERING_H10#define _LIBCPP___COMPARE_ORDERING_H
1111
12#include <__config>12#include <__config>
13#include <type_traits>13#include <__type_traits/enable_if.h>
14#include <__type_traits/is_same.h>
1415
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header17# pragma GCC system_header
...@@ -312,6 +313,12 @@ inline constexpr strong_ordering strong_ordering::equal(_OrdResult::__equiv);...@@ -312,6 +313,12 @@ inline constexpr strong_ordering strong_ordering::equal(_OrdResult::__equiv);
312inline constexpr strong_ordering strong_ordering::equivalent(_OrdResult::__equiv);313inline constexpr strong_ordering strong_ordering::equivalent(_OrdResult::__equiv);
313inline constexpr strong_ordering strong_ordering::greater(_OrdResult::__greater);314inline 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
315#endif // _LIBCPP_STD_VER > 17322#endif // _LIBCPP_STD_VER > 17
316323
317_LIBCPP_END_NAMESPACE_STD324_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__compare/partial_order.h+4-1
...@@ -13,9 +13,10 @@...@@ -13,9 +13,10 @@
13#include <__compare/ordering.h>13#include <__compare/ordering.h>
14#include <__compare/weak_order.h>14#include <__compare/weak_order.h>
15#include <__config>15#include <__config>
16#include <__type_traits/decay.h>
17#include <__type_traits/is_same.h>
16#include <__utility/forward.h>18#include <__utility/forward.h>
17#include <__utility/priority_tag.h>19#include <__utility/priority_tag.h>
18#include <type_traits>
1920
20#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER21#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
21# pragma GCC system_header22# pragma GCC system_header
...@@ -28,6 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -28,6 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
28// [cmp.alg]29// [cmp.alg]
29namespace __partial_order {30namespace __partial_order {
30 struct __fn {31 struct __fn {
32 // NOLINTBEGIN(libcpp-robust-against-adl) partial_order should use ADL, but only here
31 template<class _Tp, class _Up>33 template<class _Tp, class _Up>
32 requires is_same_v<decay_t<_Tp>, decay_t<_Up>>34 requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
33 _LIBCPP_HIDE_FROM_ABI static constexpr auto35 _LIBCPP_HIDE_FROM_ABI static constexpr auto
...@@ -35,6 +37,7 @@ namespace __partial_order {...@@ -35,6 +37,7 @@ namespace __partial_order {
35 noexcept(noexcept(partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))37 noexcept(noexcept(partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
36 -> decltype( partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))38 -> decltype( partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
37 { return partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }39 { return partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
40 // NOLINTEND(libcpp-robust-against-adl)
3841
39 template<class _Tp, class _Up>42 template<class _Tp, class _Up>
40 requires is_same_v<decay_t<_Tp>, decay_t<_Up>>43 requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
lib/libcxx/include/__compare/strong_order.h+4-1
...@@ -13,12 +13,13 @@...@@ -13,12 +13,13 @@
13#include <__compare/compare_three_way.h>13#include <__compare/compare_three_way.h>
14#include <__compare/ordering.h>14#include <__compare/ordering.h>
15#include <__config>15#include <__config>
16#include <__type_traits/conditional.h>
17#include <__type_traits/decay.h>
16#include <__utility/forward.h>18#include <__utility/forward.h>
17#include <__utility/priority_tag.h>19#include <__utility/priority_tag.h>
18#include <cmath>20#include <cmath>
19#include <cstdint>21#include <cstdint>
20#include <limits>22#include <limits>
21#include <type_traits>
2223
23#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER24#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
24# pragma GCC system_header25# pragma GCC system_header
...@@ -34,6 +35,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -34,6 +35,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
34// [cmp.alg]35// [cmp.alg]
35namespace __strong_order {36namespace __strong_order {
36 struct __fn {37 struct __fn {
38 // NOLINTBEGIN(libcpp-robust-against-adl) strong_order should use ADL, but only here
37 template<class _Tp, class _Up>39 template<class _Tp, class _Up>
38 requires is_same_v<decay_t<_Tp>, decay_t<_Up>>40 requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
39 _LIBCPP_HIDE_FROM_ABI static constexpr auto41 _LIBCPP_HIDE_FROM_ABI static constexpr auto
...@@ -41,6 +43,7 @@ namespace __strong_order {...@@ -41,6 +43,7 @@ namespace __strong_order {
41 noexcept(noexcept(strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))43 noexcept(noexcept(strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
42 -> decltype( strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))44 -> decltype( strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
43 { return strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }45 { return strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
46 // NOLINTEND(libcpp-robust-against-adl)
4447
45 template<class _Tp, class _Up, class _Dp = decay_t<_Tp>>48 template<class _Tp, class _Up, class _Dp = decay_t<_Tp>>
46 requires is_same_v<_Dp, decay_t<_Up>> && is_floating_point_v<_Dp>49 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 =...@@ -42,7 +42,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way =
42 };42 };
4343
44template <class _Tp, class _Up = _Tp>44template <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
47#endif // _LIBCPP_STD_VER > 1747#endif // _LIBCPP_STD_VER > 17
4848
lib/libcxx/include/__compare/three_way_comparable.h+2-1
...@@ -16,7 +16,8 @@...@@ -16,7 +16,8 @@
16#include <__concepts/same_as.h>16#include <__concepts/same_as.h>
17#include <__concepts/totally_ordered.h>17#include <__concepts/totally_ordered.h>
18#include <__config>18#include <__config>
19#include <type_traits>19#include <__type_traits/common_reference.h>
20#include <__type_traits/make_const_lvalue_ref.h>
2021
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header23# pragma GCC system_header
lib/libcxx/include/__compare/weak_order.h+3-1
...@@ -13,10 +13,10 @@...@@ -13,10 +13,10 @@
13#include <__compare/ordering.h>13#include <__compare/ordering.h>
14#include <__compare/strong_order.h>14#include <__compare/strong_order.h>
15#include <__config>15#include <__config>
16#include <__type_traits/decay.h>
16#include <__utility/forward.h>17#include <__utility/forward.h>
17#include <__utility/priority_tag.h>18#include <__utility/priority_tag.h>
18#include <cmath>19#include <cmath>
19#include <type_traits>
2020
21#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER21#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
22# pragma GCC system_header22# pragma GCC system_header
...@@ -29,6 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -29,6 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
29// [cmp.alg]29// [cmp.alg]
30namespace __weak_order {30namespace __weak_order {
31 struct __fn {31 struct __fn {
32 // NOLINTBEGIN(libcpp-robust-against-adl) weak_order should use ADL, but only here
32 template<class _Tp, class _Up>33 template<class _Tp, class _Up>
33 requires is_same_v<decay_t<_Tp>, decay_t<_Up>>34 requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
34 _LIBCPP_HIDE_FROM_ABI static constexpr auto35 _LIBCPP_HIDE_FROM_ABI static constexpr auto
...@@ -36,6 +37,7 @@ namespace __weak_order {...@@ -36,6 +37,7 @@ namespace __weak_order {
36 noexcept(noexcept(weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))37 noexcept(noexcept(weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
37 -> decltype( weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))38 -> decltype( weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
38 { return weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }39 { return weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
40 // NOLINTEND(libcpp-robust-against-adl)
3941
40 template<class _Tp, class _Up, class _Dp = decay_t<_Tp>>42 template<class _Tp, class _Up, class _Dp = decay_t<_Tp>>
41 requires is_same_v<_Dp, decay_t<_Up>> && is_floating_point_v<_Dp>43 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 @@...@@ -10,9 +10,11 @@
10#define _LIBCPP___CONCEPTS_ARITHMETIC_H10#define _LIBCPP___CONCEPTS_ARITHMETIC_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/is_floating_point.h>
14#include <__type_traits/is_integral.h>
15#include <__type_traits/is_signed.h>
13#include <__type_traits/is_signed_integer.h>16#include <__type_traits/is_signed_integer.h>
14#include <__type_traits/is_unsigned_integer.h>17#include <__type_traits/is_unsigned_integer.h>
15#include <type_traits>
1618
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header20# pragma GCC system_header
lib/libcxx/include/__concepts/assignable.h+2-1
...@@ -12,8 +12,9 @@...@@ -12,8 +12,9 @@
12#include <__concepts/common_reference_with.h>12#include <__concepts/common_reference_with.h>
13#include <__concepts/same_as.h>13#include <__concepts/same_as.h>
14#include <__config>14#include <__config>
15#include <__type_traits/is_reference.h>
16#include <__type_traits/make_const_lvalue_ref.h>
15#include <__utility/forward.h>17#include <__utility/forward.h>
16#include <type_traits>
1718
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header20# pragma GCC system_header
lib/libcxx/include/__concepts/class_or_enum.h+5-2
...@@ -10,7 +10,10 @@...@@ -10,7 +10,10 @@
10#define _LIBCPP___CONCEPTS_CLASS_OR_ENUM_H10#define _LIBCPP___CONCEPTS_CLASS_OR_ENUM_H
1111
12#include <__config>12#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
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header19# pragma GCC system_header
...@@ -28,7 +31,7 @@ concept __class_or_enum = is_class_v<_Tp> || is_union_v<_Tp> || is_enum_v<_Tp>;...@@ -28,7 +31,7 @@ concept __class_or_enum = is_class_v<_Tp> || is_union_v<_Tp> || is_enum_v<_Tp>;
28// Work around Clang bug https://llvm.org/PR5297031// Work around Clang bug https://llvm.org/PR52970
29// TODO: remove this workaround once libc++ no longer has to support Clang 13 (it was fixed in Clang 14).32// TODO: remove this workaround once libc++ no longer has to support Clang 13 (it was fixed in Clang 14).
30template<class _Tp>33template<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
33#endif // _LIBCPP_STD_VER > 1736#endif // _LIBCPP_STD_VER > 17
3437
lib/libcxx/include/__concepts/common_reference_with.h+1-1
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
12#include <__concepts/convertible_to.h>12#include <__concepts/convertible_to.h>
13#include <__concepts/same_as.h>13#include <__concepts/same_as.h>
14#include <__config>14#include <__config>
15#include <type_traits>15#include <__type_traits/common_reference.h>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header18# pragma GCC system_header
lib/libcxx/include/__concepts/common_with.h+6-3
...@@ -12,7 +12,10 @@...@@ -12,7 +12,10 @@
12#include <__concepts/common_reference_with.h>12#include <__concepts/common_reference_with.h>
13#include <__concepts/same_as.h>13#include <__concepts/same_as.h>
14#include <__config>14#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
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header21# pragma GCC system_header
...@@ -28,8 +31,8 @@ template<class _Tp, class _Up>...@@ -28,8 +31,8 @@ template<class _Tp, class _Up>
28concept common_with =31concept common_with =
29 same_as<common_type_t<_Tp, _Up>, common_type_t<_Up, _Tp>> &&32 same_as<common_type_t<_Tp, _Up>, common_type_t<_Up, _Tp>> &&
30 requires {33 requires {
31 static_cast<common_type_t<_Tp, _Up>>(declval<_Tp>());34 static_cast<common_type_t<_Tp, _Up>>(std::declval<_Tp>());
32 static_cast<common_type_t<_Tp, _Up>>(declval<_Up>());35 static_cast<common_type_t<_Tp, _Up>>(std::declval<_Up>());
33 } &&36 } &&
34 common_reference_with<37 common_reference_with<
35 add_lvalue_reference_t<const _Tp>,38 add_lvalue_reference_t<const _Tp>,
lib/libcxx/include/__concepts/constructible.h+1-1
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
12#include <__concepts/convertible_to.h>12#include <__concepts/convertible_to.h>
13#include <__concepts/destructible.h>13#include <__concepts/destructible.h>
14#include <__config>14#include <__config>
15#include <type_traits>15#include <__type_traits/is_constructible.h>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header18# pragma GCC system_header
lib/libcxx/include/__concepts/convertible_to.h+2-2
...@@ -10,8 +10,8 @@...@@ -10,8 +10,8 @@
10#define _LIBCPP___CONCEPTS_CONVERTIBLE_TO_H10#define _LIBCPP___CONCEPTS_CONVERTIBLE_TO_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/is_convertible.h>
13#include <__utility/declval.h>14#include <__utility/declval.h>
14#include <type_traits>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header17# pragma GCC system_header
...@@ -27,7 +27,7 @@ template<class _From, class _To>...@@ -27,7 +27,7 @@ template<class _From, class _To>
27concept convertible_to =27concept convertible_to =
28 is_convertible_v<_From, _To> &&28 is_convertible_v<_From, _To> &&
29 requires {29 requires {
30 static_cast<_To>(declval<_From>());30 static_cast<_To>(std::declval<_From>());
31 };31 };
3232
33#endif // _LIBCPP_STD_VER > 1733#endif // _LIBCPP_STD_VER > 17
lib/libcxx/include/__concepts/derived_from.h+2-1
...@@ -10,7 +10,8 @@...@@ -10,7 +10,8 @@
10#define _LIBCPP___CONCEPTS_DERIVED_FROM_H10#define _LIBCPP___CONCEPTS_DERIVED_FROM_H
1111
12#include <__config>12#include <__config>
13#include <type_traits>13#include <__type_traits/is_base_of.h>
14#include <__type_traits/is_convertible.h>
1415
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header17# pragma GCC system_header
lib/libcxx/include/__concepts/destructible.h+1-1
...@@ -10,7 +10,7 @@...@@ -10,7 +10,7 @@
10#define _LIBCPP___CONCEPTS_DESTRUCTIBLE_H10#define _LIBCPP___CONCEPTS_DESTRUCTIBLE_H
1111
12#include <__config>12#include <__config>
13#include <type_traits>13#include <__type_traits/is_nothrow_destructible.h>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header16# pragma GCC system_header
lib/libcxx/include/__concepts/different_from.h+1-1
...@@ -11,7 +11,7 @@...@@ -11,7 +11,7 @@
1111
12#include <__concepts/same_as.h>12#include <__concepts/same_as.h>
13#include <__config>13#include <__config>
14#include <type_traits>14#include <__type_traits/remove_cvref.h>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header17# pragma GCC system_header
lib/libcxx/include/__concepts/equality_comparable.h+2-1
...@@ -12,7 +12,8 @@...@@ -12,7 +12,8 @@
12#include <__concepts/boolean_testable.h>12#include <__concepts/boolean_testable.h>
13#include <__concepts/common_reference_with.h>13#include <__concepts/common_reference_with.h>
14#include <__config>14#include <__config>
15#include <type_traits>15#include <__type_traits/common_reference.h>
16#include <__type_traits/make_const_lvalue_ref.h>
1617
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header19# pragma GCC system_header
lib/libcxx/include/__concepts/invocable.h-1
...@@ -12,7 +12,6 @@...@@ -12,7 +12,6 @@
12#include <__config>12#include <__config>
13#include <__functional/invoke.h>13#include <__functional/invoke.h>
14#include <__utility/forward.h>14#include <__utility/forward.h>
15#include <type_traits>
1615
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header17# pragma GCC system_header
lib/libcxx/include/__concepts/movable.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <__concepts/constructible.h>13#include <__concepts/constructible.h>
14#include <__concepts/swappable.h>14#include <__concepts/swappable.h>
15#include <__config>15#include <__config>
16#include <type_traits>16#include <__type_traits/is_object.h>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header19# pragma GCC system_header
lib/libcxx/include/__concepts/predicate.h+1-1
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
12#include <__concepts/boolean_testable.h>12#include <__concepts/boolean_testable.h>
13#include <__concepts/invocable.h>13#include <__concepts/invocable.h>
14#include <__config>14#include <__config>
15#include <type_traits>15#include <__functional/invoke.h>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header18# pragma GCC system_header
lib/libcxx/include/__concepts/same_as.h+1-1
...@@ -10,7 +10,7 @@...@@ -10,7 +10,7 @@
10#define _LIBCPP___CONCEPTS_SAME_AS_H10#define _LIBCPP___CONCEPTS_SAME_AS_H
1111
12#include <__config>12#include <__config>
13#include <type_traits>13#include <__type_traits/is_same.h>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header16# pragma GCC system_header
lib/libcxx/include/__concepts/swappable.h+6-1
...@@ -14,10 +14,15 @@...@@ -14,10 +14,15 @@
14#include <__concepts/common_reference_with.h>14#include <__concepts/common_reference_with.h>
15#include <__concepts/constructible.h>15#include <__concepts/constructible.h>
16#include <__config>16#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>
17#include <__utility/exchange.h>21#include <__utility/exchange.h>
18#include <__utility/forward.h>22#include <__utility/forward.h>
19#include <__utility/move.h>23#include <__utility/move.h>
20#include <type_traits>24#include <__utility/swap.h>
25#include <cstddef>
2126
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header28# pragma GCC system_header
lib/libcxx/include/__concepts/totally_ordered.h+2-1
...@@ -12,7 +12,8 @@...@@ -12,7 +12,8 @@
12#include <__concepts/boolean_testable.h>12#include <__concepts/boolean_testable.h>
13#include <__concepts/equality_comparable.h>13#include <__concepts/equality_comparable.h>
14#include <__config>14#include <__config>
15#include <type_traits>15#include <__type_traits/common_reference.h>
16#include <__type_traits/make_const_lvalue_ref.h>
1617
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header19# pragma GCC system_header
lib/libcxx/include/__config+114-93
...@@ -10,6 +10,8 @@...@@ -10,6 +10,8 @@
10#ifndef _LIBCPP___CONFIG10#ifndef _LIBCPP___CONFIG
11#define _LIBCPP___CONFIG11#define _LIBCPP___CONFIG
1212
13#include <__config_site>
14
13#if defined(_MSC_VER) && !defined(__clang__)15#if defined(_MSC_VER) && !defined(__clang__)
14# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER17# define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
...@@ -28,13 +30,14 @@...@@ -28,13 +30,14 @@
28# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)30# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
29#elif defined(__GNUC__)31#elif defined(__GNUC__)
30# define _LIBCPP_COMPILER_GCC32# define _LIBCPP_COMPILER_GCC
31#elif defined(_MSC_VER)
32# define _LIBCPP_COMPILER_MSVC
33#endif33#endif
3434
35#ifdef __cplusplus35#ifdef __cplusplus
3636
37# define _LIBCPP_VERSION 1500337// _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
39# define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y42# define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
40# define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)43# define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)
...@@ -57,7 +60,8 @@...@@ -57,7 +60,8 @@
57# elif __cplusplus <= 202002L60# elif __cplusplus <= 202002L
58# define _LIBCPP_STD_VER 2061# define _LIBCPP_STD_VER 20
59# else62# else
60# define _LIBCPP_STD_VER 22 // current year, or date of c++2b ratification63// Expected release year of the next C++ standard
64# define _LIBCPP_STD_VER 23
61# endif65# endif
62# endif // _LIBCPP_STD_VER66# endif // _LIBCPP_STD_VER
6367
...@@ -148,7 +152,7 @@...@@ -148,7 +152,7 @@
148# endif152# endif
149// Feature macros for disabling pre ABI v1 features. All of these options153// Feature macros for disabling pre ABI v1 features. All of these options
150// are deprecated.154// are deprecated.
151# if defined(__FreeBSD__) || defined(__DragonFly__)155# if defined(__FreeBSD__)
152# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR156# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
153# endif157# endif
154# endif158# endif
...@@ -165,7 +169,7 @@...@@ -165,7 +169,7 @@
165# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION169# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
166# endif170# endif
167171
168# define _LIBCPP_TOSTRING2(x) # x172# define _LIBCPP_TOSTRING2(x) #x
169# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)173# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
170174
171# if __cplusplus < 201103L175# if __cplusplus < 201103L
...@@ -192,6 +196,10 @@...@@ -192,6 +196,10 @@
192# define __has_cpp_attribute(__x) 0196# define __has_cpp_attribute(__x) 0
193# endif197# endif
194198
199# ifndef __has_constexpr_builtin
200# define __has_constexpr_builtin(x) 0
201# endif
202
195// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by203// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
196// the compiler and '1' otherwise.204// the compiler and '1' otherwise.
197# ifndef __is_identifier205# ifndef __is_identifier
...@@ -212,12 +220,6 @@...@@ -212,12 +220,6 @@
212# error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11"220# error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11"
213# endif221# 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
221// FIXME: ABI detection should be done via compiler builtin macros. This223// FIXME: ABI detection should be done via compiler builtin macros. This
222// is just a placeholder until Clang implements such macros. For now assume224// is just a placeholder until Clang implements such macros. For now assume
223// that Windows compilers pretending to be MSVC++ target the Microsoft ABI,225// 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....@@ -251,7 +253,6 @@ If there are users of this configuration we are happy to provide support.
251// easier to grep for target specific flags once the feature is complete.253// easier to grep for target specific flags once the feature is complete.
252# if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY)254# if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY)
253# define _LIBCPP_HAS_NO_INCOMPLETE_FORMAT255# define _LIBCPP_HAS_NO_INCOMPLETE_FORMAT
254# define _LIBCPP_HAS_NO_INCOMPLETE_RANGES
255# endif256# endif
256257
257// Need to detect which libc we're using if we're on Linux.258// 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....@@ -416,17 +417,21 @@ If there are users of this configuration we are happy to provide support.
416# define _LIBCPP_NORETURN [[noreturn]]417# define _LIBCPP_NORETURN [[noreturn]]
417# define _NOEXCEPT noexcept418# define _NOEXCEPT noexcept
418# define _NOEXCEPT_(x) noexcept(x)419# define _NOEXCEPT_(x) noexcept(x)
420# define _LIBCPP_CONSTEXPR constexpr
419421
420# else422# else
421423
422# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)424# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
423# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))425# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
424# define _ALIGNAS(x) __attribute__((__aligned__(x)))426# define _ALIGNAS(x) __attribute__((__aligned__(x)))
425# define _LIBCPP_NORETURN __attribute__((noreturn))427# define _LIBCPP_NORETURN __attribute__((__noreturn__))
426# define _LIBCPP_HAS_NO_NOEXCEPT428# define _LIBCPP_HAS_NO_NOEXCEPT
427# define nullptr __nullptr429# define nullptr __nullptr
428# define _NOEXCEPT throw()430# define _NOEXCEPT throw()
429# define _NOEXCEPT_(x)431# define _NOEXCEPT_(x)
432# define static_assert(...) _Static_assert(__VA_ARGS__)
433# define decltype(...) __decltype(__VA_ARGS__)
434# define _LIBCPP_CONSTEXPR
430435
431typedef __char16_t char16_t;436typedef __char16_t char16_t;
432typedef __char32_t char32_t;437typedef __char32_t char32_t;
...@@ -485,27 +490,7 @@ typedef __char32_t char32_t;...@@ -485,27 +490,7 @@ typedef __char32_t char32_t;
485490
486# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__491# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
487492
488# elif defined(_LIBCPP_COMPILER_MSVC)493# endif // _LIBCPP_COMPILER_[CLANG|GCC]
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]
509494
510# if defined(_LIBCPP_OBJECT_FORMAT_COFF)495# if defined(_LIBCPP_OBJECT_FORMAT_COFF)
511496
...@@ -625,6 +610,15 @@ typedef __char32_t char32_t;...@@ -625,6 +610,15 @@ typedef __char32_t char32_t;
625// Note that we use _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION to ensure that we don't depend610// Note that we use _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION to ensure that we don't depend
626// on _LIBCPP_HIDE_FROM_ABI methods of classes explicitly instantiated in the dynamic library.611// on _LIBCPP_HIDE_FROM_ABI methods of classes explicitly instantiated in the dynamic library.
627//612//
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//
628// TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing622// TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing
629// the length of symbols with an ABI tag. In practice, we should remove the escape hatch and623// the length of symbols with an ABI tag. In practice, we should remove the escape hatch and
630// use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70.624// use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70.
...@@ -635,6 +629,7 @@ typedef __char32_t char32_t;...@@ -635,6 +629,7 @@ typedef __char32_t char32_t;
635# else629# else
636# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION630# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
637# endif631# endif
632# define _LIBCPP_HIDE_FROM_ABI_VIRTUAL _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
638633
639# ifdef _LIBCPP_BUILDING_LIBRARY634# ifdef _LIBCPP_BUILDING_LIBRARY
640# if _LIBCPP_ABI_VERSION > 1635# if _LIBCPP_ABI_VERSION > 1
...@@ -678,31 +673,20 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD...@@ -678,31 +673,20 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
678# define _LIBCPP_HAS_NO_INT128673# define _LIBCPP_HAS_NO_INT128
679# endif674# 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
692# ifndef __cpp_consteval676# ifndef __cpp_consteval
693# define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR677# define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR
694# else678# else
695# define _LIBCPP_CONSTEVAL consteval679# define _LIBCPP_CONSTEVAL consteval
696# endif680# endif
697681
698# ifdef __GNUC__682# if __has_attribute(__malloc__)
699# define _LIBCPP_NOALIAS __attribute__((__malloc__))683# define _LIBCPP_NOALIAS __attribute__((__malloc__))
700# else684# else
701# define _LIBCPP_NOALIAS685# define _LIBCPP_NOALIAS
702# endif686# endif
703687
704# if __has_attribute(using_if_exists)688# if __has_attribute(__using_if_exists__)
705# define _LIBCPP_USING_IF_EXISTS __attribute__((using_if_exists))689# define _LIBCPP_USING_IF_EXISTS __attribute__((__using_if_exists__))
706# else690# else
707# define _LIBCPP_USING_IF_EXISTS691# define _LIBCPP_USING_IF_EXISTS
708# endif692# endif
...@@ -726,11 +710,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD...@@ -726,11 +710,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
726# endif // _LIBCPP_CXX03_LANG710# endif // _LIBCPP_CXX03_LANG
727711
728# if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__sun__) || \712# if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__sun__) || \
729 defined(__NetBSD__) || defined(__DragonFly__)713 defined(__NetBSD__)
730# define _LIBCPP_LOCALE__L_EXTENSIONS 1714# define _LIBCPP_LOCALE__L_EXTENSIONS 1
731# endif715# endif
732716
733# if defined(__FreeBSD__) || defined(__DragonFly__)717# ifdef __FreeBSD__
734# define _DECLARE_C99_LDBL_MATH 1718# define _DECLARE_C99_LDBL_MATH 1
735# endif719# endif
736720
...@@ -750,11 +734,23 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD...@@ -750,11 +734,23 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
750# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION734# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
751# endif735# 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__)
754# define _LIBCPP_HAS_DEFAULTRUNELOCALE750# define _LIBCPP_HAS_DEFAULTRUNELOCALE
755# endif751# endif
756752
757# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) || defined(__DragonFly__)753# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
758# define _LIBCPP_WCTYPE_IS_MASK754# define _LIBCPP_WCTYPE_IS_MASK
759# endif755# endif
760756
...@@ -769,7 +765,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD...@@ -769,7 +765,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
769# if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)765# if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
770# if __has_attribute(deprecated)766# if __has_attribute(deprecated)
771# define _LIBCPP_DEPRECATED __attribute__((deprecated))767# define _LIBCPP_DEPRECATED __attribute__((deprecated))
772# define _LIBCPP_DEPRECATED_(m) __attribute__((deprected(m)))768# define _LIBCPP_DEPRECATED_(m) __attribute__((deprecated(m)))
773# elif _LIBCPP_STD_VER > 11769# elif _LIBCPP_STD_VER > 11
774# define _LIBCPP_DEPRECATED [[deprecated]]770# define _LIBCPP_DEPRECATED [[deprecated]]
775# define _LIBCPP_DEPRECATED_(m) [[deprecated(m)]]771# define _LIBCPP_DEPRECATED_(m) [[deprecated(m)]]
...@@ -806,6 +802,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD...@@ -806,6 +802,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
806# define _LIBCPP_DEPRECATED_IN_CXX20802# define _LIBCPP_DEPRECATED_IN_CXX20
807# endif803# 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
809# if !defined(_LIBCPP_HAS_NO_CHAR8_T)811# if !defined(_LIBCPP_HAS_NO_CHAR8_T)
810# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED812# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
811# else813# else
...@@ -830,27 +832,31 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD...@@ -830,27 +832,31 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
830# endif832# endif
831833
832# if _LIBCPP_STD_VER > 11834# if _LIBCPP_STD_VER > 11
833# define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr835# define _LIBCPP_CONSTEXPR_SINCE_CXX14 constexpr
834# else836# else
835# define _LIBCPP_CONSTEXPR_AFTER_CXX11837# define _LIBCPP_CONSTEXPR_SINCE_CXX14
836# endif838# endif
837839
838# if _LIBCPP_STD_VER > 14840# if _LIBCPP_STD_VER > 14
839# define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr841# define _LIBCPP_CONSTEXPR_SINCE_CXX17 constexpr
840# else842# else
841# define _LIBCPP_CONSTEXPR_AFTER_CXX14843# define _LIBCPP_CONSTEXPR_SINCE_CXX17
842# endif844# endif
843845
844# if _LIBCPP_STD_VER > 17846# if _LIBCPP_STD_VER > 17
845# define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr847# define _LIBCPP_CONSTEXPR_SINCE_CXX20 constexpr
846# else848# else
847# define _LIBCPP_CONSTEXPR_AFTER_CXX17849# define _LIBCPP_CONSTEXPR_SINCE_CXX20
848# endif850# 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)
851# define _LIBCPP_NODISCARD [[nodiscard]]859# define _LIBCPP_NODISCARD [[nodiscard]]
852# elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG)
853# define _LIBCPP_NODISCARD [[clang::warn_unused_result]]
854# else860# else
855// We can't use GCC's [[gnu::warn_unused_result]] and861// We can't use GCC's [[gnu::warn_unused_result]] and
856// __attribute__((warn_unused_result)), because GCC does not silence them via862// __attribute__((warn_unused_result)), because GCC does not silence them via
...@@ -860,19 +866,19 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD...@@ -860,19 +866,19 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
860866
861// _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not867// _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not
862// specified as such as an extension.868// specified as such as an extension.
863# if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT)869# if !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
864# define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD870# define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD
865# else871# else
866# define _LIBCPP_NODISCARD_EXT872# define _LIBCPP_NODISCARD_EXT
867# endif873# 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)
870# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD876# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD
871# else877# else
872# define _LIBCPP_NODISCARD_AFTER_CXX17878# define _LIBCPP_NODISCARD_AFTER_CXX17
873# endif879# endif
874880
875# if __has_attribute(no_destroy)881# if __has_attribute(__no_destroy__)
876# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))882# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
877# else883# else
878# define _LIBCPP_NO_DESTROY884# define _LIBCPP_NO_DESTROY
...@@ -901,7 +907,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD...@@ -901,7 +907,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
901907
902# if defined(__FreeBSD__) || \908# if defined(__FreeBSD__) || \
903 defined(__wasi__) || \909 defined(__wasi__) || \
904 defined(__DragonFly__) || \
905 defined(__NetBSD__) || \910 defined(__NetBSD__) || \
906 defined(__OpenBSD__) || \911 defined(__OpenBSD__) || \
907 defined(__NuttX__) || \912 defined(__NuttX__) || \
...@@ -1035,18 +1040,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD...@@ -1035,18 +1040,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
10351040
1036# if _LIBCPP_STD_VER > 171041# if _LIBCPP_STD_VER > 17
1037# define _LIBCPP_CONSTINIT constinit1042# define _LIBCPP_CONSTINIT constinit
1038# elif __has_attribute(require_constant_initialization)1043# elif __has_attribute(__require_constant_initialization__)
1039# define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__))1044# define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__))
1040# else1045# else
1041# define _LIBCPP_CONSTINIT1046# define _LIBCPP_CONSTINIT
1042# endif1047# endif
10431048
1044# if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)1049# if __has_attribute(__diagnose_if__) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
1045# define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((diagnose_if(__VA_ARGS__, "warning")))1050# define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((__diagnose_if__(__VA_ARGS__, "warning")))
1046# define _LIBCPP_DIAGNOSE_ERROR(...) __attribute__((diagnose_if(__VA_ARGS__, "error")))
1047# else1051# else
1048# define _LIBCPP_DIAGNOSE_WARNING(...)1052# define _LIBCPP_DIAGNOSE_WARNING(...)
1049# define _LIBCPP_DIAGNOSE_ERROR(...)
1050# endif1053# endif
10511054
1052// Use a function like macro to imply that it must be followed by a semicolon1055// 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...@@ -1058,6 +1061,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
1058# define _LIBCPP_FALLTHROUGH() ((void)0)1061# define _LIBCPP_FALLTHROUGH() ((void)0)
1059# endif1062# endif
10601063
1064# if __has_cpp_attribute(_Clang::__lifetimebound__)
1065# define _LIBCPP_LIFETIMEBOUND [[_Clang::__lifetimebound__]]
1066# else
1067# define _LIBCPP_LIFETIMEBOUND
1068# endif
1069
1061# if __has_attribute(__nodebug__)1070# if __has_attribute(__nodebug__)
1062# define _LIBCPP_NODEBUG __attribute__((__nodebug__))1071# define _LIBCPP_NODEBUG __attribute__((__nodebug__))
1063# else1072# else
...@@ -1086,7 +1095,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD...@@ -1086,7 +1095,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
1086# define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__1095# define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__
1087# endif1096# 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)
1090# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)1099# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
1091# else1100# else
1092# define _LIBCPP_DECLSPEC_EMPTY_BASES1101# define _LIBCPP_DECLSPEC_EMPTY_BASES
...@@ -1100,13 +1109,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD...@@ -1100,13 +1109,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
1100# define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION1109# define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
1101# endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES1110# 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
1110# if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)1112# if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)
1111# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS1113# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
1112# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION1114# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION
...@@ -1116,10 +1118,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD...@@ -1116,10 +1118,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
1116# define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS1118# define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS
1117# endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES1119# 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
1123# define _LIBCPP_PUSH_MACROS _Pragma("push_macro(\"min\")") _Pragma("push_macro(\"max\")")1121# define _LIBCPP_PUSH_MACROS _Pragma("push_macro(\"min\")") _Pragma("push_macro(\"max\")")
1124# define _LIBCPP_POP_MACROS _Pragma("pop_macro(\"min\")") _Pragma("pop_macro(\"max\")")1122# 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...@@ -1151,19 +1149,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
1151# define _LIBCPP_HAS_NO_FGETPOS_FSETPOS1149# define _LIBCPP_HAS_NO_FGETPOS_FSETPOS
1152# endif1150# endif
11531151
1154# if __has_attribute(init_priority)1152# if __has_attribute(__init_priority__)
1155// TODO: Remove this once we drop support for building libc++ with old Clangs1153# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((__init_priority__(100)))
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
1162# else1154# else
1163# define _LIBCPP_INIT_PRIORITY_MAX1155# define _LIBCPP_INIT_PRIORITY_MAX
1164# endif1156# endif
11651157
1166# if defined(__GNUC__) || defined(__clang__)1158# if __has_attribute(__format__)
1167// The attribute uses 1-based indices for ordinary and static member functions.1159// The attribute uses 1-based indices for ordinary and static member functions.
1168// The attribute uses 2-based indices for non-static member functions.1160// The attribute uses 2-based indices for non-static member functions.
1169# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \1161# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \
...@@ -1225,6 +1217,35 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD...@@ -1225,6 +1217,35 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
1225# define _LIBCPP_PACKED1217# define _LIBCPP_PACKED
1226# endif1218# 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
1228#endif // __cplusplus1249#endif // __cplusplus
12291250
1230#endif // _LIBCPP___CONFIG1251#endif // _LIBCPP___CONFIG
lib/libcxx/include/__coroutine/coroutine_handle.h+5-4
...@@ -13,14 +13,15 @@...@@ -13,14 +13,15 @@
13#include <__config>13#include <__config>
14#include <__functional/hash.h>14#include <__functional/hash.h>
15#include <__memory/addressof.h>15#include <__memory/addressof.h>
16#include <__type_traits/remove_cv.h>
16#include <compare>17#include <compare>
17#include <type_traits>18#include <cstddef>
1819
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header21# pragma GCC system_header
21#endif22#endif
2223
23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)24#if _LIBCPP_STD_VER > 17
2425
25_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
2627
...@@ -115,7 +116,7 @@ public:...@@ -115,7 +116,7 @@ public:
115116
116 _LIBCPP_HIDE_FROM_ABI117 _LIBCPP_HIDE_FROM_ABI
117 static coroutine_handle from_promise(_Promise& __promise) {118 static coroutine_handle from_promise(_Promise& __promise) {
118 using _RawPromise = typename remove_cv<_Promise>::type;119 using _RawPromise = __remove_cv_t<_Promise>;
119 coroutine_handle __tmp;120 coroutine_handle __tmp;
120 __tmp.__handle_ =121 __tmp.__handle_ =
121 __builtin_coro_promise(_VSTD::addressof(const_cast<_RawPromise&>(__promise)), alignof(_Promise), true);122 __builtin_coro_promise(_VSTD::addressof(const_cast<_RawPromise&>(__promise)), alignof(_Promise), true);
...@@ -197,6 +198,6 @@ struct hash<coroutine_handle<_Tp>> {...@@ -197,6 +198,6 @@ struct hash<coroutine_handle<_Tp>> {
197198
198_LIBCPP_END_NAMESPACE_STD199_LIBCPP_END_NAMESPACE_STD
199200
200#endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)201#endif // __LIBCPP_STD_VER > 17
201202
202#endif // _LIBCPP___COROUTINE_COROUTINE_HANDLE_H203#endif // _LIBCPP___COROUTINE_COROUTINE_HANDLE_H
lib/libcxx/include/__coroutine/coroutine_traits.h+4-4
...@@ -10,13 +10,13 @@...@@ -10,13 +10,13 @@
10#define _LIBCPP___COROUTINE_COROUTINE_TRAITS_H10#define _LIBCPP___COROUTINE_COROUTINE_TRAITS_H
1111
12#include <__config>12#include <__config>
13#include <type_traits>13#include <__type_traits/void_t.h>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)19#if _LIBCPP_STD_VER > 17
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
...@@ -35,7 +35,7 @@ struct __coroutine_traits_sfinae {};...@@ -35,7 +35,7 @@ struct __coroutine_traits_sfinae {};
3535
36template <class _Tp>36template <class _Tp>
37struct __coroutine_traits_sfinae<37struct __coroutine_traits_sfinae<
38 _Tp, typename __void_t<typename _Tp::promise_type>::type>38 _Tp, __void_t<typename _Tp::promise_type> >
39{39{
40 using promise_type = typename _Tp::promise_type;40 using promise_type = typename _Tp::promise_type;
41};41};
...@@ -48,6 +48,6 @@ struct coroutine_traits...@@ -48,6 +48,6 @@ struct coroutine_traits
4848
49_LIBCPP_END_NAMESPACE_STD49_LIBCPP_END_NAMESPACE_STD
5050
51#endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)51#endif // __LIBCPP_STD_VER > 17
5252
53#endif // _LIBCPP___COROUTINE_COROUTINE_TRAITS_H53#endif // _LIBCPP___COROUTINE_COROUTINE_TRAITS_H
lib/libcxx/include/__coroutine/noop_coroutine_handle.h+2-2
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16# pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)19#if _LIBCPP_STD_VER > 17
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
...@@ -107,6 +107,6 @@ noop_coroutine_handle noop_coroutine() noexcept { return noop_coroutine_handle()...@@ -107,6 +107,6 @@ noop_coroutine_handle noop_coroutine() noexcept { return noop_coroutine_handle()
107107
108_LIBCPP_END_NAMESPACE_STD108_LIBCPP_END_NAMESPACE_STD
109109
110#endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)110#endif // __LIBCPP_STD_VER > 17
111111
112#endif // _LIBCPP___COROUTINE_NOOP_COROUTINE_HANDLE_H112#endif // _LIBCPP___COROUTINE_NOOP_COROUTINE_HANDLE_H
lib/libcxx/include/__coroutine/trivial_awaitables.h+2-2
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16# pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)19#if _LIBCPP_STD_VER > 17
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
...@@ -41,6 +41,6 @@ struct suspend_always {...@@ -41,6 +41,6 @@ struct suspend_always {
4141
42_LIBCPP_END_NAMESPACE_STD42_LIBCPP_END_NAMESPACE_STD
4343
44#endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES)44#endif // __LIBCPP_STD_VER > 17
4545
46#endif // __LIBCPP___COROUTINE_TRIVIAL_AWAITABLES_H46#endif // __LIBCPP___COROUTINE_TRIVIAL_AWAITABLES_H
lib/libcxx/include/__debug+14-15
...@@ -12,22 +12,21 @@...@@ -12,22 +12,21 @@
1212
13#include <__assert>13#include <__assert>
14#include <__config>14#include <__config>
15#include <__type_traits/is_constant_evaluated.h>
15#include <cstddef>16#include <cstddef>
16#include <type_traits>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header19# pragma GCC system_header
20#endif20#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
27#if defined(_LIBCPP_ENABLE_DEBUG_MODE) && !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)22#if defined(_LIBCPP_ENABLE_DEBUG_MODE) && !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
28# define _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY23# define _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
29#endif24#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
31#ifdef _LIBCPP_ENABLE_DEBUG_MODE30#ifdef _LIBCPP_ENABLE_DEBUG_MODE
32# define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(::std::__libcpp_is_constant_evaluated() || (x), m)31# define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(::std::__libcpp_is_constant_evaluated() || (x), m)
33#else32#else
...@@ -87,10 +86,10 @@ struct _C_node...@@ -87,10 +86,10 @@ struct _C_node
87 explicit _C_node(void* __c, __c_node* __n)86 explicit _C_node(void* __c, __c_node* __n)
88 : __c_node(__c, __n) {}87 : __c_node(__c, __n) {}
8988
90 virtual bool __dereferenceable(const void*) const;89 bool __dereferenceable(const void*) const override;
91 virtual bool __decrementable(const void*) const;90 bool __decrementable(const void*) const override;
92 virtual bool __addable(const void*, ptrdiff_t) const;91 bool __addable(const void*, ptrdiff_t) const override;
93 virtual bool __subscriptable(const void*, ptrdiff_t) const;92 bool __subscriptable(const void*, ptrdiff_t) const override;
94};93};
9594
96template <class _Cont>95template <class _Cont>
...@@ -212,7 +211,7 @@ _LIBCPP_END_NAMESPACE_STD...@@ -212,7 +211,7 @@ _LIBCPP_END_NAMESPACE_STD
212_LIBCPP_BEGIN_NAMESPACE_STD211_LIBCPP_BEGIN_NAMESPACE_STD
213212
214template <class _Tp>213template <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) {
216#ifdef _LIBCPP_ENABLE_DEBUG_MODE215#ifdef _LIBCPP_ENABLE_DEBUG_MODE
217 if (!__libcpp_is_constant_evaluated())216 if (!__libcpp_is_constant_evaluated())
218 __get_db()->__insert_c(__c);217 __get_db()->__insert_c(__c);
...@@ -222,7 +221,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_inser...@@ -222,7 +221,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_inser
222}221}
223222
224template <class _Tp>223template <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) {
226#ifdef _LIBCPP_ENABLE_DEBUG_MODE225#ifdef _LIBCPP_ENABLE_DEBUG_MODE
227 if (!__libcpp_is_constant_evaluated())226 if (!__libcpp_is_constant_evaluated())
228 __get_db()->__insert_i(__i);227 __get_db()->__insert_i(__i);
...@@ -232,7 +231,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_inser...@@ -232,7 +231,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_inser
232}231}
233232
234template <class _Tp>233template <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) {
236#ifdef _LIBCPP_ENABLE_DEBUG_MODE235#ifdef _LIBCPP_ENABLE_DEBUG_MODE
237 if (!__libcpp_is_constant_evaluated())236 if (!__libcpp_is_constant_evaluated())
238 __get_db()->__erase_c(__c);237 __get_db()->__erase_c(__c);
...@@ -242,7 +241,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_erase...@@ -242,7 +241,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_erase
242}241}
243242
244template <class _Tp>243template <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) {
246#ifdef _LIBCPP_ENABLE_DEBUG_MODE245#ifdef _LIBCPP_ENABLE_DEBUG_MODE
247 if (!__libcpp_is_constant_evaluated())246 if (!__libcpp_is_constant_evaluated())
248 __get_db()->swap(__lhs, __rhs);247 __get_db()->swap(__lhs, __rhs);
...@@ -253,7 +252,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_swap(...@@ -253,7 +252,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_swap(
253}252}
254253
255template <class _Tp>254template <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) {
257#ifdef _LIBCPP_ENABLE_DEBUG_MODE256#ifdef _LIBCPP_ENABLE_DEBUG_MODE
258 if (!__libcpp_is_constant_evaluated())257 if (!__libcpp_is_constant_evaluated())
259 __get_db()->__invalidate_all(__c);258 __get_db()->__invalidate_all(__c);
lib/libcxx/include/__debug_utils/randomize_range.h+1-1
...@@ -23,7 +23,7 @@...@@ -23,7 +23,7 @@
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2424
25template <class _AlgPolicy, class _Iterator, class _Sentinel>25template <class _AlgPolicy, class _Iterator, class _Sentinel>
26_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1126_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
27void __debug_randomize_range(_Iterator __first, _Sentinel __last) {27void __debug_randomize_range(_Iterator __first, _Sentinel __last) {
28#ifdef _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY28#ifdef _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
29# ifdef _LIBCPP_CXX03_LANG29# 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:...@@ -215,21 +215,23 @@ public:
215 return __get_symlink_status(&__ec);215 return __get_symlink_status(&__ec);
216 }216 }
217217
218 _LIBCPP_INLINE_VISIBILITY
219 bool operator<(directory_entry const& __rhs) const noexcept {
220 return __p_ < __rhs.__p_;
221 }
222218
223 _LIBCPP_INLINE_VISIBILITY219 _LIBCPP_INLINE_VISIBILITY
224 bool operator==(directory_entry const& __rhs) const noexcept {220 bool operator==(directory_entry const& __rhs) const noexcept {
225 return __p_ == __rhs.__p_;221 return __p_ == __rhs.__p_;
226 }222 }
227223
224#if _LIBCPP_STD_VER <= 17
228 _LIBCPP_INLINE_VISIBILITY225 _LIBCPP_INLINE_VISIBILITY
229 bool operator!=(directory_entry const& __rhs) const noexcept {226 bool operator!=(directory_entry const& __rhs) const noexcept {
230 return __p_ != __rhs.__p_;227 return __p_ != __rhs.__p_;
231 }228 }
232229
230 _LIBCPP_INLINE_VISIBILITY
231 bool operator<(directory_entry const& __rhs) const noexcept {
232 return __p_ < __rhs.__p_;
233 }
234
233 _LIBCPP_INLINE_VISIBILITY235 _LIBCPP_INLINE_VISIBILITY
234 bool operator<=(directory_entry const& __rhs) const noexcept {236 bool operator<=(directory_entry const& __rhs) const noexcept {
235 return __p_ <= __rhs.__p_;237 return __p_ <= __rhs.__p_;
...@@ -245,6 +247,15 @@ public:...@@ -245,6 +247,15 @@ public:
245 return __p_ >= __rhs.__p_;247 return __p_ >= __rhs.__p_;
246 }248 }
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
248 template <class _CharT, class _Traits>259 template <class _CharT, class _Traits>
249 _LIBCPP_INLINE_VISIBILITY260 _LIBCPP_INLINE_VISIBILITY
250 friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const directory_entry& __d) {261 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 @@...@@ -14,6 +14,7 @@
14#include <__config>14#include <__config>
15#include <__filesystem/path.h>15#include <__filesystem/path.h>
16#include <__memory/shared_ptr.h>16#include <__memory/shared_ptr.h>
17#include <__utility/forward.h>
17#include <iosfwd>18#include <iosfwd>
18#include <new>19#include <new>
19#include <system_error>20#include <system_error>
...@@ -60,7 +61,7 @@ public:...@@ -60,7 +61,7 @@ public:
60 filesystem_error(const filesystem_error&) = default;61 filesystem_error(const filesystem_error&) = default;
61 ~filesystem_error() override; // key function62 ~filesystem_error() override; // key function
6263
63 _LIBCPP_INLINE_VISIBILITY64 _LIBCPP_HIDE_FROM_ABI_VIRTUAL
64 const char* what() const noexcept override {65 const char* what() const noexcept override {
65 return __storage_->__what_.c_str();66 return __storage_->__what_.c_str();
66 }67 }
lib/libcxx/include/__filesystem/path.h+37-30
...@@ -141,15 +141,15 @@ struct __is_pathable_string<...@@ -141,15 +141,15 @@ struct __is_pathable_string<
141141
142template <class _Source, class _DS = typename decay<_Source>::type,142template <class _Source, class _DS = typename decay<_Source>::type,
143 class _UnqualPtrType =143 class _UnqualPtrType =
144 typename remove_const<typename remove_pointer<_DS>::type>::type,144 __remove_const_t<__remove_pointer_t<_DS> >,
145 bool _IsCharPtr = is_pointer<_DS>::value&&145 bool _IsCharPtr = is_pointer<_DS>::value&&
146 __can_convert_char<_UnqualPtrType>::value>146 __can_convert_char<_UnqualPtrType>::value>
147struct __is_pathable_char_array : false_type {};147struct __is_pathable_char_array : false_type {};
148148
149template <class _Source, class _ECharT, class _UPtr>149template <class _Source, class _ECharT, class _UPtr>
150struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true>150struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true>
151 : __can_convert_char<typename remove_const<_ECharT>::type> {151 : __can_convert_char<__remove_const_t<_ECharT> > {
152 using _Base = __can_convert_char<typename remove_const<_ECharT>::type>;152 using _Base = __can_convert_char<__remove_const_t<_ECharT> >;
153153
154 _LIBCPP_HIDE_FROM_ABI154 _LIBCPP_HIDE_FROM_ABI
155 static _ECharT const* __range_begin(const _ECharT* __b) { return __b; }155 static _ECharT const* __range_begin(const _ECharT* __b) { return __b; }
...@@ -619,7 +619,7 @@ public:...@@ -619,7 +619,7 @@ public:
619 _EnableIfPathable<_Source> append(const _Source& __src) {619 _EnableIfPathable<_Source> append(const _Source& __src) {
620 using _Traits = __is_pathable<_Source>;620 using _Traits = __is_pathable<_Source>;
621 using _CVT = _PathCVT<_SourceChar<_Source> >;621 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));
623 if (__source_is_absolute)623 if (__source_is_absolute)
624 __pn_.clear();624 __pn_.clear();
625 else if (has_filename())625 else if (has_filename())
...@@ -634,7 +634,7 @@ public:...@@ -634,7 +634,7 @@ public:
634 typedef typename iterator_traits<_InputIt>::value_type _ItVal;634 typedef typename iterator_traits<_InputIt>::value_type _ItVal;
635 static_assert(__can_convert_char<_ItVal>::value, "Must convertible");635 static_assert(__can_convert_char<_ItVal>::value, "Must convertible");
636 using _CVT = _PathCVT<_ItVal>;636 using _CVT = _PathCVT<_ItVal>;
637 if (__first != __last && __is_separator(*__first))637 if (__first != __last && _VSTD_FS::__is_separator(*__first))
638 __pn_.clear();638 __pn_.clear();
639 else if (has_filename())639 else if (has_filename())
640 __pn_ += preferred_separator;640 __pn_ += preferred_separator;
...@@ -732,6 +732,37 @@ public:...@@ -732,6 +732,37 @@ public:
732732
733 path& replace_extension(const path& __replacement = path());733 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
735 _LIBCPP_HIDE_FROM_ABI766 _LIBCPP_HIDE_FROM_ABI
736 void swap(path& __rhs) noexcept { __pn_.swap(__rhs.__pn_); }767 void swap(path& __rhs) noexcept { __pn_.swap(__rhs.__pn_); }
737768
...@@ -835,7 +866,7 @@ public:...@@ -835,7 +866,7 @@ public:
835 using _Str = basic_string<_ECharT, _Traits, _Allocator>;866 using _Str = basic_string<_ECharT, _Traits, _Allocator>;
836 _Str __s(__a);867 _Str __s(__a);
837 __s.reserve(__pn_.size());868 __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());
839 return __s;870 return __s;
840 }871 }
841872
...@@ -1035,30 +1066,6 @@ public:...@@ -1035,30 +1066,6 @@ public:
1035 }1066 }
1036#endif // !_LIBCPP_HAS_NO_LOCALIZATION1067#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 }
1062private:1069private:
1063 inline _LIBCPP_HIDE_FROM_ABI path&1070 inline _LIBCPP_HIDE_FROM_ABI path&
1064 __assign_view(__string_view const& __s) noexcept {1071 __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 {...@@ -28,6 +28,10 @@ struct _LIBCPP_TYPE_VIS space_info {
28 uintmax_t capacity;28 uintmax_t capacity;
29 uintmax_t free;29 uintmax_t free;
30 uintmax_t available;30 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
31};35};
3236
33_LIBCPP_AVAILABILITY_FILESYSTEM_POP37_LIBCPP_AVAILABILITY_FILESYSTEM_POP
lib/libcxx/include/__format/buffer.h+283-79
...@@ -11,22 +11,27 @@...@@ -11,22 +11,27 @@
11#define _LIBCPP___FORMAT_BUFFER_H11#define _LIBCPP___FORMAT_BUFFER_H
1212
13#include <__algorithm/copy_n.h>13#include <__algorithm/copy_n.h>
14#include <__algorithm/fill_n.h>
14#include <__algorithm/max.h>15#include <__algorithm/max.h>
15#include <__algorithm/min.h>16#include <__algorithm/min.h>
17#include <__algorithm/ranges_copy_n.h>
18#include <__algorithm/transform.h>
16#include <__algorithm/unwrap_iter.h>19#include <__algorithm/unwrap_iter.h>
20#include <__concepts/same_as.h>
17#include <__config>21#include <__config>
22#include <__format/concepts.h>
18#include <__format/enable_insertable.h>23#include <__format/enable_insertable.h>
19#include <__format/format_to_n_result.h>24#include <__format/format_to_n_result.h>
20#include <__format/formatter.h> // for __char_type TODO FMT Move the concept?
21#include <__iterator/back_insert_iterator.h>25#include <__iterator/back_insert_iterator.h>
22#include <__iterator/concepts.h>26#include <__iterator/concepts.h>
23#include <__iterator/incrementable_traits.h>27#include <__iterator/incrementable_traits.h>
24#include <__iterator/iterator_traits.h>28#include <__iterator/iterator_traits.h>
25#include <__iterator/wrap_iter.h>29#include <__iterator/wrap_iter.h>
26#include <__utility/move.h>30#include <__utility/move.h>
27#include <concepts>
28#include <cstddef>31#include <cstddef>
32#include <string_view>
29#include <type_traits>33#include <type_traits>
34#include <vector>
3035
31#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)36#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
32# pragma GCC system_header37# pragma GCC system_header
...@@ -46,41 +51,125 @@ namespace __format {...@@ -46,41 +51,125 @@ namespace __format {
46/// This helper is used together with the @ref back_insert_iterator to offer51/// This helper is used together with the @ref back_insert_iterator to offer
47/// type-erasure for the formatting functions. This reduces the number to52/// type-erasure for the formatting functions. This reduces the number to
48/// template instantiations.53/// template instantiations.
49template <__formatter::__char_type _CharT>54template <__fmt_char_type _CharT>
50class _LIBCPP_TEMPLATE_VIS __output_buffer {55class _LIBCPP_TEMPLATE_VIS __output_buffer {
51public:56public:
52 using value_type = _CharT;57 using value_type = _CharT;
5358
54 template <class _Tp>59 template <class _Tp>
55 _LIBCPP_HIDE_FROM_ABI explicit __output_buffer(_CharT* __ptr,60 _LIBCPP_HIDE_FROM_ABI explicit __output_buffer(_CharT* __ptr, size_t __capacity, _Tp* __obj)
56 size_t __capacity, _Tp* __obj)61 : __ptr_(__ptr),
57 : __ptr_(__ptr), __capacity_(__capacity),62 __capacity_(__capacity),
58 __flush_([](_CharT* __p, size_t __size, void* __o) {63 __flush_([](_CharT* __p, size_t __n, void* __o) { static_cast<_Tp*>(__o)->__flush(__p, __n); }),
59 static_cast<_Tp*>(__o)->flush(__p, __size);
60 }),
61 __obj_(__obj) {}64 __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) {
64 __ptr_ = __ptr;67 __ptr_ = __ptr;
65 __capacity_ = __capacity;68 __capacity_ = __capacity;
66 }69 }
6770
68 _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() {71 _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return std::back_insert_iterator{*this}; }
69 return back_insert_iterator{*this};
70 }
7172
72 // TODO FMT It would be nice to have an overload taking a73 // Used in std::back_insert_iterator.
73 // basic_string_view<_CharT> and append it directly.
74 _LIBCPP_HIDE_FROM_ABI void push_back(_CharT __c) {74 _LIBCPP_HIDE_FROM_ABI void push_back(_CharT __c) {
75 __ptr_[__size_++] = __c;75 __ptr_[__size_++] = __c;
7676
77 // Profiling showed flushing after adding is more efficient than flushing77 // Profiling showed flushing after adding is more efficient than flushing
78 // when entering the function.78 // when entering the function.
79 if (__size_ == __capacity_)79 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);
81 }170 }
82171
83 _LIBCPP_HIDE_FROM_ABI void flush() {172 _LIBCPP_HIDE_FROM_ABI void __flush() {
84 __flush_(__ptr_, __size_, __obj_);173 __flush_(__ptr_, __size_, __obj_);
85 __size_ = 0;174 __size_ = 0;
86 }175 }
...@@ -91,16 +180,54 @@ private:...@@ -91,16 +180,54 @@ private:
91 size_t __size_{0};180 size_t __size_{0};
92 void (*__flush_)(_CharT*, size_t, void*);181 void (*__flush_)(_CharT*, size_t, void*);
93 void* __obj_;182 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 }
94};221};
95222
96/// A storage using an internal buffer.223/// A storage using an internal buffer.
97///224///
98/// This storage is used when writing a single element to the output iterator225/// This storage is used when writing a single element to the output iterator
99/// is expensive.226/// is expensive.
100template <__formatter::__char_type _CharT>227template <__fmt_char_type _CharT>
101class _LIBCPP_TEMPLATE_VIS __internal_storage {228class _LIBCPP_TEMPLATE_VIS __internal_storage {
102public:229public:
103 _LIBCPP_HIDE_FROM_ABI _CharT* begin() { return __buffer_; }230 _LIBCPP_HIDE_FROM_ABI _CharT* __begin() { return __buffer_; }
104231
105 static constexpr size_t __buffer_size = 256 / sizeof(_CharT);232 static constexpr size_t __buffer_size = 256 / sizeof(_CharT);
106233
...@@ -113,11 +240,11 @@ private:...@@ -113,11 +240,11 @@ private:
113/// This requires the storage to be a contiguous buffer of \a _CharT.240/// This requires the storage to be a contiguous buffer of \a _CharT.
114/// Since the output is directly written to the underlying storage this class241/// Since the output is directly written to the underlying storage this class
115/// is just an empty class.242/// is just an empty class.
116template <__formatter::__char_type _CharT>243template <__fmt_char_type _CharT>
117class _LIBCPP_TEMPLATE_VIS __direct_storage {};244class _LIBCPP_TEMPLATE_VIS __direct_storage {};
118245
119template <class _OutIt, class _CharT>246template <class _OutIt, class _CharT>
120concept __enable_direct_output = __formatter::__char_type<_CharT> &&247concept __enable_direct_output = __fmt_char_type<_CharT> &&
121 (same_as<_OutIt, _CharT*>248 (same_as<_OutIt, _CharT*>
122#ifndef _LIBCPP_ENABLE_DEBUG_MODE249#ifndef _LIBCPP_ENABLE_DEBUG_MODE
123 || same_as<_OutIt, __wrap_iter<_CharT*>>250 || same_as<_OutIt, __wrap_iter<_CharT*>>
...@@ -125,18 +252,18 @@ concept __enable_direct_output = __formatter::__char_type<_CharT> &&...@@ -125,18 +252,18 @@ concept __enable_direct_output = __formatter::__char_type<_CharT> &&
125 );252 );
126253
127/// Write policy for directly writing to the underlying output.254/// Write policy for directly writing to the underlying output.
128template <class _OutIt, __formatter::__char_type _CharT>255template <class _OutIt, __fmt_char_type _CharT>
129class _LIBCPP_TEMPLATE_VIS __writer_direct {256class _LIBCPP_TEMPLATE_VIS __writer_direct {
130public:257public:
131 _LIBCPP_HIDE_FROM_ABI explicit __writer_direct(_OutIt __out_it)258 _LIBCPP_HIDE_FROM_ABI explicit __writer_direct(_OutIt __out_it)
132 : __out_it_(__out_it) {}259 : __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) {
137 // _OutIt can be a __wrap_iter<CharT*>. Therefore the original iterator264 // _OutIt can be a __wrap_iter<CharT*>. Therefore the original iterator
138 // is adjusted.265 // is adjusted.
139 __out_it_ += __size;266 __out_it_ += __n;
140 }267 }
141268
142private:269private:
...@@ -144,16 +271,16 @@ private:...@@ -144,16 +271,16 @@ private:
144};271};
145272
146/// Write policy for copying the buffer to the output.273/// Write policy for copying the buffer to the output.
147template <class _OutIt, __formatter::__char_type _CharT>274template <class _OutIt, __fmt_char_type _CharT>
148class _LIBCPP_TEMPLATE_VIS __writer_iterator {275class _LIBCPP_TEMPLATE_VIS __writer_iterator {
149public:276public:
150 _LIBCPP_HIDE_FROM_ABI explicit __writer_iterator(_OutIt __out_it)277 _LIBCPP_HIDE_FROM_ABI explicit __writer_iterator(_OutIt __out_it)
151 : __out_it_{_VSTD::move(__out_it)} {}278 : __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) {282 _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) {
156 __out_it_ = _VSTD::copy_n(__ptr, __size, _VSTD::move(__out_it_));283 __out_it_ = std::ranges::copy_n(__ptr, __n, std::move(__out_it_)).out;
157 }284 }
158285
159private:286private:
...@@ -169,7 +296,7 @@ private:...@@ -169,7 +296,7 @@ private:
169/// \ref __enable_insertable.296/// \ref __enable_insertable.
170template <class _Container>297template <class _Container>
171concept __insertable =298concept __insertable =
172 __enable_insertable<_Container> && __formatter::__char_type<typename _Container::value_type> &&299 __enable_insertable<_Container> && __fmt_char_type<typename _Container::value_type> &&
173 requires(_Container& __t, add_pointer_t<typename _Container::value_type> __first,300 requires(_Container& __t, add_pointer_t<typename _Container::value_type> __first,
174 add_pointer_t<typename _Container::value_type> __last) { __t.insert(__t.end(), __first, __last); };301 add_pointer_t<typename _Container::value_type> __last) { __t.insert(__t.end(), __first, __last); };
175302
...@@ -193,10 +320,10 @@ public:...@@ -193,10 +320,10 @@ public:
193 _LIBCPP_HIDE_FROM_ABI explicit __writer_container(back_insert_iterator<_Container> __out_it)320 _LIBCPP_HIDE_FROM_ABI explicit __writer_container(back_insert_iterator<_Container> __out_it)
194 : __container_{__out_it.__get_container()} {}321 : __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) {325 _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) {
199 __container_->insert(__container_->end(), __ptr, __ptr + __size);326 __container_->insert(__container_->end(), __ptr, __ptr + __n);
200 }327 }
201328
202private:329private:
...@@ -215,7 +342,7 @@ public:...@@ -215,7 +342,7 @@ public:
215};342};
216343
217/// The generic formatting buffer.344/// The generic formatting buffer.
218template <class _OutIt, __formatter::__char_type _CharT>345template <class _OutIt, __fmt_char_type _CharT>
219requires(output_iterator<_OutIt, const _CharT&>) class _LIBCPP_TEMPLATE_VIS346requires(output_iterator<_OutIt, const _CharT&>) class _LIBCPP_TEMPLATE_VIS
220 __format_buffer {347 __format_buffer {
221 using _Storage =348 using _Storage =
...@@ -225,24 +352,20 @@ requires(output_iterator<_OutIt, const _CharT&>) class _LIBCPP_TEMPLATE_VIS...@@ -225,24 +352,20 @@ requires(output_iterator<_OutIt, const _CharT&>) class _LIBCPP_TEMPLATE_VIS
225public:352public:
226 _LIBCPP_HIDE_FROM_ABI explicit __format_buffer(_OutIt __out_it)353 _LIBCPP_HIDE_FROM_ABI explicit __format_buffer(_OutIt __out_it)
227 requires(same_as<_Storage, __internal_storage<_CharT>>)354 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
230 _LIBCPP_HIDE_FROM_ABI explicit __format_buffer(_OutIt __out_it) requires(357 _LIBCPP_HIDE_FROM_ABI explicit __format_buffer(_OutIt __out_it) requires(
231 same_as<_Storage, __direct_storage<_CharT>>)358 same_as<_Storage, __direct_storage<_CharT>>)
232 : __output_(_VSTD::__unwrap_iter(__out_it), size_t(-1), this),359 : __output_(_VSTD::__unwrap_iter(__out_it), size_t(-1), this),
233 __writer_(_VSTD::move(__out_it)) {}360 __writer_(_VSTD::move(__out_it)) {}
234361
235 _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() {362 _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return __output_.__make_output_iterator(); }
236 return __output_.make_output_iterator();
237 }
238363
239 _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) {364 _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) { __writer_.__flush(__ptr, __n); }
240 __writer_.flush(__ptr, __size);
241 }
242365
243 _LIBCPP_HIDE_FROM_ABI _OutIt out() && {366 _LIBCPP_HIDE_FROM_ABI _OutIt __out_it() && {
244 __output_.flush();367 __output_.__flush();
245 return _VSTD::move(__writer_).out();368 return _VSTD::move(__writer_).__out_it();
246 }369 }
247370
248private:371private:
...@@ -255,46 +378,46 @@ private:...@@ -255,46 +378,46 @@ private:
255///378///
256/// Since \ref formatted_size only needs to know the size, the output itself is379/// Since \ref formatted_size only needs to know the size, the output itself is
257/// discarded.380/// discarded.
258template <__formatter::__char_type _CharT>381template <__fmt_char_type _CharT>
259class _LIBCPP_TEMPLATE_VIS __formatted_size_buffer {382class _LIBCPP_TEMPLATE_VIS __formatted_size_buffer {
260public:383public:
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() && {388 _LIBCPP_HIDE_FROM_ABI size_t __result() && {
266 __output_.flush();389 __output_.__flush();
267 return __size_;390 return __size_;
268 }391 }
269392
270private:393private:
271 __internal_storage<_CharT> __storage_;394 __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};
273 size_t __size_{0};396 size_t __size_{0};
274};397};
275398
276/// The base of a buffer that counts and limits the number of insertions.399/// 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>
278 requires(output_iterator<_OutIt, const _CharT&>)401 requires(output_iterator<_OutIt, const _CharT&>)
279struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer_base {402struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer_base {
280 using _Size = iter_difference_t<_OutIt>;403 using _Size = iter_difference_t<_OutIt>;
281404
282public:405public:
283 _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __n)406 _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __max_size)
284 : __writer_(_VSTD::move(__out_it)), __n_(_VSTD::max(_Size(0), __n)) {}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) {409 _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) {
287 if (_Size(__size_) <= __n_)410 if (_Size(__size_) <= __max_size_)
288 __writer_.flush(__ptr, _VSTD::min(_Size(__size), __n_ - __size_));411 __writer_.__flush(__ptr, _VSTD::min(_Size(__n), __max_size_ - __size_));
289 __size_ += __size;412 __size_ += __n;
290 }413 }
291414
292protected:415protected:
293 __internal_storage<_CharT> __storage_;416 __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};
295 typename __writer_selector<_OutIt, _CharT>::type __writer_;418 typename __writer_selector<_OutIt, _CharT>::type __writer_;
296419
297 _Size __n_;420 _Size __max_size_;
298 _Size __size_{0};421 _Size __size_{0};
299};422};
300423
...@@ -302,35 +425,46 @@ protected:...@@ -302,35 +425,46 @@ protected:
302///425///
303/// This version is used when \c __enable_direct_output<_OutIt, _CharT> == true.426/// This version is used when \c __enable_direct_output<_OutIt, _CharT> == true.
304///427///
305/// This class limits the size available the the direct writer so it will not428/// This class limits the size available to the direct writer so it will not
306/// exceed the maximum number of code units.429/// exceed the maximum number of code units.
307template <class _OutIt, __formatter::__char_type _CharT>430template <class _OutIt, __fmt_char_type _CharT>
308 requires(output_iterator<_OutIt, const _CharT&>)431 requires(output_iterator<_OutIt, const _CharT&>)
309class _LIBCPP_TEMPLATE_VIS __format_to_n_buffer_base<_OutIt, _CharT, true> {432class _LIBCPP_TEMPLATE_VIS __format_to_n_buffer_base<_OutIt, _CharT, true> {
310 using _Size = iter_difference_t<_OutIt>;433 using _Size = iter_difference_t<_OutIt>;
311434
312public:435public:
313 _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __n)436 _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __max_size)
314 : __output_(_VSTD::__unwrap_iter(__out_it), __n, this), __writer_(_VSTD::move(__out_it)) {437 : __output_(_VSTD::__unwrap_iter(__out_it), __max_size, this),
315 if (__n <= 0) [[unlikely]]438 __writer_(_VSTD::move(__out_it)),
316 __output_.reset(__storage_.begin(), __storage_.__buffer_size);439 __max_size_(__max_size) {
440 if (__max_size <= 0) [[unlikely]]
441 __output_.__reset(__storage_.__begin(), __storage_.__buffer_size);
317 }442 }
318443
319 _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) {444 _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) {
320 // A flush to the direct writer happens in two occasions:445 // A __flush to the direct writer happens in the following occasions:
321 // - The format function has written the maximum number of allowed code446 // - The format function has written the maximum number of allowed code
322 // units. At this point it's no longer valid to write to this writer. So447 // units. At this point it's no longer valid to write to this writer. So
323 // switch to the internal storage. This internal storage doesn't need to448 // 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.
325 // - The format_to_n function is finished. In this case there's no need to453 // - The format_to_n function is finished. In this case there's no need to
326 // switch the buffer, but for simplicity the buffers are still switched.454 // switch the buffer, but for simplicity the buffers are still switched.
327 // When the __n <= 0 the constructor already switched the buffers.455 // When the __max_size <= 0 the constructor already switched the buffers.
328 if (__size_ == 0 && __ptr != __storage_.begin()) {456 if (__size_ == 0 && __ptr != __storage_.__begin()) {
329 __writer_.flush(__ptr, __size);457 __writer_.__flush(__ptr, __n);
330 __output_.reset(__storage_.begin(), __storage_.__buffer_size);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);
331 }465 }
332466
333 __size_ += __size;467 __size_ += __n;
334 }468 }
335469
336protected:470protected:
...@@ -338,11 +472,12 @@ protected:...@@ -338,11 +472,12 @@ protected:
338 __output_buffer<_CharT> __output_;472 __output_buffer<_CharT> __output_;
339 __writer_direct<_OutIt, _CharT> __writer_;473 __writer_direct<_OutIt, _CharT> __writer_;
340474
475 _Size __max_size_;
341 _Size __size_{0};476 _Size __size_{0};
342};477};
343478
344/// The buffer that counts and limits the number of insertions.479/// The buffer that counts and limits the number of insertions.
345template <class _OutIt, __formatter::__char_type _CharT>480template <class _OutIt, __fmt_char_type _CharT>
346 requires(output_iterator<_OutIt, const _CharT&>)481 requires(output_iterator<_OutIt, const _CharT&>)
347struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer final482struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer final
348 : public __format_to_n_buffer_base< _OutIt, _CharT, __enable_direct_output<_OutIt, _CharT>> {483 : 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...@@ -350,14 +485,83 @@ struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer final
350 using _Size = iter_difference_t<_OutIt>;485 using _Size = iter_difference_t<_OutIt>;
351486
352public:487public:
353 _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer(_OutIt __out_it, _Size __n) : _Base(_VSTD::move(__out_it), __n) {}488 _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer(_OutIt __out_it, _Size __max_size)
354 _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() { return this->__output_.make_output_iterator(); }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() && {538 _LIBCPP_HIDE_FROM_ABI explicit __retarget_buffer(size_t __size_hint) { __buffer_.reserve(__size_hint); }
357 this->__output_.flush();539
358 return {_VSTD::move(this->__writer_).out(), this->__size_};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));
359 }553 }
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_;
360};563};
564
361} // namespace __format565} // namespace __format
362566
363#endif //_LIBCPP_STD_VER > 17567#endif //_LIBCPP_STD_VER > 17
lib/libcxx/include/__format/concepts.h+37-12
...@@ -15,6 +15,9 @@...@@ -15,6 +15,9 @@
15#include <__config>15#include <__config>
16#include <__format/format_fwd.h>16#include <__format/format_fwd.h>
17#include <__format/format_parse_context.h>17#include <__format/format_parse_context.h>
18#include <__type_traits/is_specialization.h>
19#include <__utility/pair.h>
20#include <tuple>
18#include <type_traits>21#include <type_traits>
1922
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -25,6 +28,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -25,6 +28,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2528
26#if _LIBCPP_STD_VER > 1729#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
28// The output iterator isn't specified. A formatter should accept any40// The output iterator isn't specified. A formatter should accept any
29// output_iterator. This iterator is a minimal iterator to test the concept.41// output_iterator. This iterator is a minimal iterator to test the concept.
30// (Note testing for (w)format_context would be a valid choice, but requires42// (Note testing for (w)format_context would be a valid choice, but requires
...@@ -32,20 +44,33 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -32,20 +44,33 @@ _LIBCPP_BEGIN_NAMESPACE_STD
32template <class _CharT>44template <class _CharT>
33using __fmt_iter_for = _CharT*;45using __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.
39template <class _Tp, class _CharT>47template <class _Tp, class _CharT>
40concept __formattable = (semiregular<formatter<remove_cvref_t<_Tp>, _CharT>>) &&48concept __formattable =
41 requires(formatter<remove_cvref_t<_Tp>, _CharT> __f,49 (semiregular<formatter<remove_cvref_t<_Tp>, _CharT>>) &&
42 formatter<remove_cvref_t<_Tp>, _CharT> __cf, _Tp __t,50 requires(formatter<remove_cvref_t<_Tp>, _CharT> __f,
43 basic_format_context<__fmt_iter_for<_CharT>, _CharT> __fc,51 const formatter<remove_cvref_t<_Tp>, _CharT> __cf,
44 basic_format_parse_context<_CharT> __pc) {52 _Tp __t,
45 { __f.parse(__pc) } -> same_as<typename basic_format_parse_context<_CharT>::iterator>;53 basic_format_context<__fmt_iter_for<_CharT>, _CharT> __fc,
46 { __cf.format(__t, __fc) } -> same_as<__fmt_iter_for<_CharT>>;54 basic_format_parse_context<_CharT> __pc) {
47 };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
49#endif //_LIBCPP_STD_VER > 1774#endif //_LIBCPP_STD_VER > 17
5075
51_LIBCPP_END_NAMESPACE_STD76_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 @@...@@ -8,7 +8,7 @@
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10// WARNING, this entire header is generated by10// WARNING, this entire header is generated by
11// utiles/generate_extended_grapheme_cluster_table.py11// utils/generate_extended_grapheme_cluster_table.py
12// DO NOT MODIFY!12// DO NOT MODIFY!
1313
14// UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE14// UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
...@@ -61,7 +61,7 @@...@@ -61,7 +61,7 @@
61#ifndef _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H61#ifndef _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H
62#define _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H62#define _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H
6363
64#include <__algorithm/upper_bound.h>64#include <__algorithm/ranges_upper_bound.h>
65#include <__config>65#include <__config>
66#include <__iterator/access.h>66#include <__iterator/access.h>
67#include <cstddef>67#include <cstddef>
...@@ -111,7 +111,7 @@ enum class __property : uint8_t {...@@ -111,7 +111,7 @@ enum class __property : uint8_t {
111/// - https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt111/// - https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt
112///112///
113/// The data has 3 values113/// The data has 3 values
114/// - bits [0, 3] The property. One of the values generated form the datafiles114/// - bits [0, 3] The property. One of the values generated from the datafiles
115/// of \ref __property115/// of \ref __property
116/// - bits [4, 10] The size of the range.116/// - bits [4, 10] The size of the range.
117/// - bits [11, 31] The lower bound code point of the range. The upper bound of117/// - bits [11, 31] The lower bound code point of the range. The upper bound of
...@@ -124,177 +124,1506 @@ enum class __property : uint8_t {...@@ -124,177 +124,1506 @@ enum class __property : uint8_t {
124/// this approach uses less space for the data and is about 4% faster in the124/// this approach uses less space for the data and is about 4% faster in the
125/// following benchmark.125/// following benchmark.
126/// libcxx/benchmarks/std_format_spec_string_unicode.bench.cpp126/// libcxx/benchmarks/std_format_spec_string_unicode.bench.cpp
127inline constexpr uint32_t __entries[1480] = {127inline constexpr uint32_t __entries[1496] = {
128 0x00000091, 0x00005005, 0x00005811, 0x00006800, 0x00007111, 0x0003fa01, 0x00054803, 0x00056801, 0x00057003,128 0x00000091,
129 0x001806f2, 0x00241862, 0x002c8ac2, 0x002df802, 0x002e0812, 0x002e2012, 0x002e3802, 0x00300058, 0x003080a2,129 0x00005005,
130 0x0030e001, 0x00325942, 0x00338002, 0x0036b062, 0x0036e808, 0x0036f852, 0x00373812, 0x00375032, 0x00387808,130 0x00005811,
131 0x00388802, 0x003981a2, 0x003d30a2, 0x003f5882, 0x003fe802, 0x0040b032, 0x0040d882, 0x00412822, 0x00414842,131 0x00006800,
132 0x0042c822, 0x00448018, 0x0044c072, 0x00465172, 0x00471008, 0x004719f2, 0x0048180a, 0x0049d002, 0x0049d80a,132 0x00007111,
133 0x0049e002, 0x0049f02a, 0x004a0872, 0x004a483a, 0x004a6802, 0x004a701a, 0x004a8862, 0x004b1012, 0x004c0802,133 0x0003fa01,
134 0x004c101a, 0x004de002, 0x004df002, 0x004df81a, 0x004e0832, 0x004e381a, 0x004e581a, 0x004e6802, 0x004eb802,134 0x00054803,
135 0x004f1012, 0x004ff002, 0x00500812, 0x0050180a, 0x0051e002, 0x0051f02a, 0x00520812, 0x00523812, 0x00525822,135 0x00056801,
136 0x00528802, 0x00538012, 0x0053a802, 0x00540812, 0x0054180a, 0x0055e002, 0x0055f02a, 0x00560842, 0x00563812,136 0x00057003,
137 0x0056480a, 0x0056581a, 0x00566802, 0x00571012, 0x0057d052, 0x00580802, 0x0058101a, 0x0059e002, 0x0059f012,137 0x001806f2,
138 0x005a000a, 0x005a0832, 0x005a381a, 0x005a581a, 0x005a6802, 0x005aa822, 0x005b1012, 0x005c1002, 0x005df002,138 0x00241862,
139 0x005df80a, 0x005e0002, 0x005e081a, 0x005e302a, 0x005e502a, 0x005e6802, 0x005eb802, 0x00600002, 0x0060082a,139 0x002c8ac2,
140 0x00602002, 0x0061e002, 0x0061f022, 0x0062083a, 0x00623022, 0x00625032, 0x0062a812, 0x00631012, 0x00640802,140 0x002df802,
141 0x0064101a, 0x0065e002, 0x0065f00a, 0x0065f802, 0x0066001a, 0x00661002, 0x0066181a, 0x00663002, 0x0066381a,141 0x002e0812,
142 0x0066501a, 0x00666012, 0x0066a812, 0x00671012, 0x00680012, 0x0068101a, 0x0069d812, 0x0069f002, 0x0069f81a,142 0x002e2012,
143 0x006a0832, 0x006a302a, 0x006a502a, 0x006a6802, 0x006a7008, 0x006ab802, 0x006b1012, 0x006c0802, 0x006c101a,143 0x002e3802,
144 0x006e5002, 0x006e7802, 0x006e801a, 0x006e9022, 0x006eb002, 0x006ec06a, 0x006ef802, 0x006f901a, 0x00718802,144 0x00300058,
145 0x0071980a, 0x0071a062, 0x00723872, 0x00758802, 0x0075980a, 0x0075a082, 0x00764052, 0x0078c012, 0x0079a802,145 0x003080a2,
146 0x0079b802, 0x0079c802, 0x0079f01a, 0x007b88d2, 0x007bf80a, 0x007c0042, 0x007c3012, 0x007c68a2, 0x007cca32,146 0x0030e001,
147 0x007e3002, 0x00816832, 0x0081880a, 0x00819052, 0x0081c812, 0x0081d81a, 0x0081e812, 0x0082b01a, 0x0082c012,147 0x00325942,
148 0x0082f022, 0x00838832, 0x00841002, 0x0084200a, 0x00842812, 0x00846802, 0x0084e802, 0x008805f4, 0x008b047c,148 0x00338002,
149 0x008d457b, 0x009ae822, 0x00b89022, 0x00b8a80a, 0x00b99012, 0x00b9a00a, 0x00ba9012, 0x00bb9012, 0x00bda012,149 0x0036b062,
150 0x00bdb00a, 0x00bdb862, 0x00bdf07a, 0x00be3002, 0x00be381a, 0x00be48a2, 0x00bee802, 0x00c05822, 0x00c07001,150 0x0036e808,
151 0x00c07802, 0x00c42812, 0x00c54802, 0x00c90022, 0x00c9183a, 0x00c93812, 0x00c9482a, 0x00c9801a, 0x00c99002,151 0x0036f852,
152 0x00c9985a, 0x00c9c822, 0x00d0b812, 0x00d0c81a, 0x00d0d802, 0x00d2a80a, 0x00d2b002, 0x00d2b80a, 0x00d2c062,152 0x00373812,
153 0x00d30002, 0x00d31002, 0x00d32872, 0x00d3685a, 0x00d39892, 0x00d3f802, 0x00d581e2, 0x00d80032, 0x00d8200a,153 0x00375032,
154 0x00d9a062, 0x00d9d80a, 0x00d9e002, 0x00d9e84a, 0x00da1002, 0x00da181a, 0x00db5882, 0x00dc0012, 0x00dc100a,154 0x00387808,
155 0x00dd080a, 0x00dd1032, 0x00dd301a, 0x00dd4012, 0x00dd500a, 0x00dd5822, 0x00df3002, 0x00df380a, 0x00df4012,155 0x00388802,
156 0x00df502a, 0x00df6802, 0x00df700a, 0x00df7822, 0x00df901a, 0x00e1207a, 0x00e16072, 0x00e1a01a, 0x00e1b012,156 0x003981a2,
157 0x00e68022, 0x00e6a0c2, 0x00e7080a, 0x00e71062, 0x00e76802, 0x00e7a002, 0x00e7b80a, 0x00e7c012, 0x00ee03f2,157 0x003d30a2,
158 0x01005801, 0x01006002, 0x0100680d, 0x01007011, 0x01014061, 0x0101e003, 0x01024803, 0x010300f1, 0x01068202,158 0x003f5882,
159 0x01091003, 0x0109c803, 0x010ca053, 0x010d4813, 0x0118d013, 0x01194003, 0x011c4003, 0x011e7803, 0x011f48a3,159 0x003fe802,
160 0x011fc023, 0x01261003, 0x012d5013, 0x012db003, 0x012e0003, 0x012fd833, 0x01300053, 0x013038b3, 0x0130a713,160 0x0040b032,
161 0x01348753, 0x013840a3, 0x0138a003, 0x0138b003, 0x0138e803, 0x01390803, 0x01394003, 0x01399813, 0x013a2003,161 0x0040d882,
162 0x013a3803, 0x013a6003, 0x013a7003, 0x013a9823, 0x013ab803, 0x013b1843, 0x013ca823, 0x013d0803, 0x013d8003,162 0x00412822,
163 0x013df803, 0x0149a013, 0x01582823, 0x0158d813, 0x015a8003, 0x015aa803, 0x01677822, 0x016bf802, 0x016f01f2,163 0x00414842,
164 0x01815052, 0x01818003, 0x0181e803, 0x0184c812, 0x0194b803, 0x0194c803, 0x05337832, 0x0533a092, 0x0534f012,164 0x0042c822,
165 0x05378012, 0x05401002, 0x05403002, 0x05405802, 0x0541181a, 0x05412812, 0x0541380a, 0x05416002, 0x0544001a,165 0x00448018,
166 0x0545a0fa, 0x05462012, 0x05470112, 0x0547f802, 0x05493072, 0x054a38a2, 0x054a901a, 0x054b01c4, 0x054c0022,166 0x0044c072,
167 0x054c180a, 0x054d9802, 0x054da01a, 0x054db032, 0x054dd01a, 0x054de012, 0x054df02a, 0x054f2802, 0x05514852,167 0x00465172,
168 0x0551781a, 0x05518812, 0x0551981a, 0x0551a812, 0x05521802, 0x05526002, 0x0552680a, 0x0553e002, 0x05558002,168 0x00471008,
169 0x05559022, 0x0555b812, 0x0555f012, 0x05560802, 0x0557580a, 0x05576012, 0x0557701a, 0x0557a80a, 0x0557b002,169 0x004719f2,
170 0x055f181a, 0x055f2802, 0x055f301a, 0x055f4002, 0x055f481a, 0x055f600a, 0x055f6802, 0x05600006, 0x056009a7,170 0x0048180a,
171 0x0560e006, 0x0560e9a7, 0x0561c006, 0x0561c9a7, 0x0562a006, 0x0562a9a7, 0x05638006, 0x056389a7, 0x05646006,171 0x0049d002,
172 0x056469a7, 0x05654006, 0x056549a7, 0x05662006, 0x056629a7, 0x05670006, 0x056709a7, 0x0567e006, 0x0567e9a7,172 0x0049d80a,
173 0x0568c006, 0x0568c9a7, 0x0569a006, 0x0569a9a7, 0x056a8006, 0x056a89a7, 0x056b6006, 0x056b69a7, 0x056c4006,173 0x0049e002,
174 0x056c49a7, 0x056d2006, 0x056d29a7, 0x056e0006, 0x056e09a7, 0x056ee006, 0x056ee9a7, 0x056fc006, 0x056fc9a7,174 0x0049f02a,
175 0x0570a006, 0x0570a9a7, 0x05718006, 0x057189a7, 0x05726006, 0x057269a7, 0x05734006, 0x057349a7, 0x05742006,175 0x004a0872,
176 0x057429a7, 0x05750006, 0x057509a7, 0x0575e006, 0x0575e9a7, 0x0576c006, 0x0576c9a7, 0x0577a006, 0x0577a9a7,176 0x004a483a,
177 0x05788006, 0x057889a7, 0x05796006, 0x057969a7, 0x057a4006, 0x057a49a7, 0x057b2006, 0x057b29a7, 0x057c0006,177 0x004a6802,
178 0x057c09a7, 0x057ce006, 0x057ce9a7, 0x057dc006, 0x057dc9a7, 0x057ea006, 0x057ea9a7, 0x057f8006, 0x057f89a7,178 0x004a701a,
179 0x05806006, 0x058069a7, 0x05814006, 0x058149a7, 0x05822006, 0x058229a7, 0x05830006, 0x058309a7, 0x0583e006,179 0x004a8862,
180 0x0583e9a7, 0x0584c006, 0x0584c9a7, 0x0585a006, 0x0585a9a7, 0x05868006, 0x058689a7, 0x05876006, 0x058769a7,180 0x004b1012,
181 0x05884006, 0x058849a7, 0x05892006, 0x058929a7, 0x058a0006, 0x058a09a7, 0x058ae006, 0x058ae9a7, 0x058bc006,181 0x004c0802,
182 0x058bc9a7, 0x058ca006, 0x058ca9a7, 0x058d8006, 0x058d89a7, 0x058e6006, 0x058e69a7, 0x058f4006, 0x058f49a7,182 0x004c101a,
183 0x05902006, 0x059029a7, 0x05910006, 0x059109a7, 0x0591e006, 0x0591e9a7, 0x0592c006, 0x0592c9a7, 0x0593a006,183 0x004de002,
184 0x0593a9a7, 0x05948006, 0x059489a7, 0x05956006, 0x059569a7, 0x05964006, 0x059649a7, 0x05972006, 0x059729a7,184 0x004df002,
185 0x05980006, 0x059809a7, 0x0598e006, 0x0598e9a7, 0x0599c006, 0x0599c9a7, 0x059aa006, 0x059aa9a7, 0x059b8006,185 0x004df81a,
186 0x059b89a7, 0x059c6006, 0x059c69a7, 0x059d4006, 0x059d49a7, 0x059e2006, 0x059e29a7, 0x059f0006, 0x059f09a7,186 0x004e0832,
187 0x059fe006, 0x059fe9a7, 0x05a0c006, 0x05a0c9a7, 0x05a1a006, 0x05a1a9a7, 0x05a28006, 0x05a289a7, 0x05a36006,187 0x004e381a,
188 0x05a369a7, 0x05a44006, 0x05a449a7, 0x05a52006, 0x05a529a7, 0x05a60006, 0x05a609a7, 0x05a6e006, 0x05a6e9a7,188 0x004e581a,
189 0x05a7c006, 0x05a7c9a7, 0x05a8a006, 0x05a8a9a7, 0x05a98006, 0x05a989a7, 0x05aa6006, 0x05aa69a7, 0x05ab4006,189 0x004e6802,
190 0x05ab49a7, 0x05ac2006, 0x05ac29a7, 0x05ad0006, 0x05ad09a7, 0x05ade006, 0x05ade9a7, 0x05aec006, 0x05aec9a7,190 0x004eb802,
191 0x05afa006, 0x05afa9a7, 0x05b08006, 0x05b089a7, 0x05b16006, 0x05b169a7, 0x05b24006, 0x05b249a7, 0x05b32006,191 0x004f1012,
192 0x05b329a7, 0x05b40006, 0x05b409a7, 0x05b4e006, 0x05b4e9a7, 0x05b5c006, 0x05b5c9a7, 0x05b6a006, 0x05b6a9a7,192 0x004ff002,
193 0x05b78006, 0x05b789a7, 0x05b86006, 0x05b869a7, 0x05b94006, 0x05b949a7, 0x05ba2006, 0x05ba29a7, 0x05bb0006,193 0x00500812,
194 0x05bb09a7, 0x05bbe006, 0x05bbe9a7, 0x05bcc006, 0x05bcc9a7, 0x05bda006, 0x05bda9a7, 0x05be8006, 0x05be89a7,194 0x0050180a,
195 0x05bf6006, 0x05bf69a7, 0x05c04006, 0x05c049a7, 0x05c12006, 0x05c129a7, 0x05c20006, 0x05c209a7, 0x05c2e006,195 0x0051e002,
196 0x05c2e9a7, 0x05c3c006, 0x05c3c9a7, 0x05c4a006, 0x05c4a9a7, 0x05c58006, 0x05c589a7, 0x05c66006, 0x05c669a7,196 0x0051f02a,
197 0x05c74006, 0x05c749a7, 0x05c82006, 0x05c829a7, 0x05c90006, 0x05c909a7, 0x05c9e006, 0x05c9e9a7, 0x05cac006,197 0x00520812,
198 0x05cac9a7, 0x05cba006, 0x05cba9a7, 0x05cc8006, 0x05cc89a7, 0x05cd6006, 0x05cd69a7, 0x05ce4006, 0x05ce49a7,198 0x00523812,
199 0x05cf2006, 0x05cf29a7, 0x05d00006, 0x05d009a7, 0x05d0e006, 0x05d0e9a7, 0x05d1c006, 0x05d1c9a7, 0x05d2a006,199 0x00525822,
200 0x05d2a9a7, 0x05d38006, 0x05d389a7, 0x05d46006, 0x05d469a7, 0x05d54006, 0x05d549a7, 0x05d62006, 0x05d629a7,200 0x00528802,
201 0x05d70006, 0x05d709a7, 0x05d7e006, 0x05d7e9a7, 0x05d8c006, 0x05d8c9a7, 0x05d9a006, 0x05d9a9a7, 0x05da8006,201 0x00538012,
202 0x05da89a7, 0x05db6006, 0x05db69a7, 0x05dc4006, 0x05dc49a7, 0x05dd2006, 0x05dd29a7, 0x05de0006, 0x05de09a7,202 0x0053a802,
203 0x05dee006, 0x05dee9a7, 0x05dfc006, 0x05dfc9a7, 0x05e0a006, 0x05e0a9a7, 0x05e18006, 0x05e189a7, 0x05e26006,203 0x00540812,
204 0x05e269a7, 0x05e34006, 0x05e349a7, 0x05e42006, 0x05e429a7, 0x05e50006, 0x05e509a7, 0x05e5e006, 0x05e5e9a7,204 0x0054180a,
205 0x05e6c006, 0x05e6c9a7, 0x05e7a006, 0x05e7a9a7, 0x05e88006, 0x05e889a7, 0x05e96006, 0x05e969a7, 0x05ea4006,205 0x0055e002,
206 0x05ea49a7, 0x05eb2006, 0x05eb29a7, 0x05ec0006, 0x05ec09a7, 0x05ece006, 0x05ece9a7, 0x05edc006, 0x05edc9a7,206 0x0055f02a,
207 0x05eea006, 0x05eea9a7, 0x05ef8006, 0x05ef89a7, 0x05f06006, 0x05f069a7, 0x05f14006, 0x05f149a7, 0x05f22006,207 0x00560842,
208 0x05f229a7, 0x05f30006, 0x05f309a7, 0x05f3e006, 0x05f3e9a7, 0x05f4c006, 0x05f4c9a7, 0x05f5a006, 0x05f5a9a7,208 0x00563812,
209 0x05f68006, 0x05f689a7, 0x05f76006, 0x05f769a7, 0x05f84006, 0x05f849a7, 0x05f92006, 0x05f929a7, 0x05fa0006,209 0x0056480a,
210 0x05fa09a7, 0x05fae006, 0x05fae9a7, 0x05fbc006, 0x05fbc9a7, 0x05fca006, 0x05fca9a7, 0x05fd8006, 0x05fd89a7,210 0x0056581a,
211 0x05fe6006, 0x05fe69a7, 0x05ff4006, 0x05ff49a7, 0x06002006, 0x060029a7, 0x06010006, 0x060109a7, 0x0601e006,211 0x00566802,
212 0x0601e9a7, 0x0602c006, 0x0602c9a7, 0x0603a006, 0x0603a9a7, 0x06048006, 0x060489a7, 0x06056006, 0x060569a7,212 0x00571012,
213 0x06064006, 0x060649a7, 0x06072006, 0x060729a7, 0x06080006, 0x060809a7, 0x0608e006, 0x0608e9a7, 0x0609c006,213 0x0057d052,
214 0x0609c9a7, 0x060aa006, 0x060aa9a7, 0x060b8006, 0x060b89a7, 0x060c6006, 0x060c69a7, 0x060d4006, 0x060d49a7,214 0x00580802,
215 0x060e2006, 0x060e29a7, 0x060f0006, 0x060f09a7, 0x060fe006, 0x060fe9a7, 0x0610c006, 0x0610c9a7, 0x0611a006,215 0x0058101a,
216 0x0611a9a7, 0x06128006, 0x061289a7, 0x06136006, 0x061369a7, 0x06144006, 0x061449a7, 0x06152006, 0x061529a7,216 0x0059e002,
217 0x06160006, 0x061609a7, 0x0616e006, 0x0616e9a7, 0x0617c006, 0x0617c9a7, 0x0618a006, 0x0618a9a7, 0x06198006,217 0x0059f012,
218 0x061989a7, 0x061a6006, 0x061a69a7, 0x061b4006, 0x061b49a7, 0x061c2006, 0x061c29a7, 0x061d0006, 0x061d09a7,218 0x005a000a,
219 0x061de006, 0x061de9a7, 0x061ec006, 0x061ec9a7, 0x061fa006, 0x061fa9a7, 0x06208006, 0x062089a7, 0x06216006,219 0x005a0832,
220 0x062169a7, 0x06224006, 0x062249a7, 0x06232006, 0x062329a7, 0x06240006, 0x062409a7, 0x0624e006, 0x0624e9a7,220 0x005a381a,
221 0x0625c006, 0x0625c9a7, 0x0626a006, 0x0626a9a7, 0x06278006, 0x062789a7, 0x06286006, 0x062869a7, 0x06294006,221 0x005a581a,
222 0x062949a7, 0x062a2006, 0x062a29a7, 0x062b0006, 0x062b09a7, 0x062be006, 0x062be9a7, 0x062cc006, 0x062cc9a7,222 0x005a6802,
223 0x062da006, 0x062da9a7, 0x062e8006, 0x062e89a7, 0x062f6006, 0x062f69a7, 0x06304006, 0x063049a7, 0x06312006,223 0x005aa822,
224 0x063129a7, 0x06320006, 0x063209a7, 0x0632e006, 0x0632e9a7, 0x0633c006, 0x0633c9a7, 0x0634a006, 0x0634a9a7,224 0x005b1012,
225 0x06358006, 0x063589a7, 0x06366006, 0x063669a7, 0x06374006, 0x063749a7, 0x06382006, 0x063829a7, 0x06390006,225 0x005c1002,
226 0x063909a7, 0x0639e006, 0x0639e9a7, 0x063ac006, 0x063ac9a7, 0x063ba006, 0x063ba9a7, 0x063c8006, 0x063c89a7,226 0x005df002,
227 0x063d6006, 0x063d69a7, 0x063e4006, 0x063e49a7, 0x063f2006, 0x063f29a7, 0x06400006, 0x064009a7, 0x0640e006,227 0x005df80a,
228 0x0640e9a7, 0x0641c006, 0x0641c9a7, 0x0642a006, 0x0642a9a7, 0x06438006, 0x064389a7, 0x06446006, 0x064469a7,228 0x005e0002,
229 0x06454006, 0x064549a7, 0x06462006, 0x064629a7, 0x06470006, 0x064709a7, 0x0647e006, 0x0647e9a7, 0x0648c006,229 0x005e081a,
230 0x0648c9a7, 0x0649a006, 0x0649a9a7, 0x064a8006, 0x064a89a7, 0x064b6006, 0x064b69a7, 0x064c4006, 0x064c49a7,230 0x005e302a,
231 0x064d2006, 0x064d29a7, 0x064e0006, 0x064e09a7, 0x064ee006, 0x064ee9a7, 0x064fc006, 0x064fc9a7, 0x0650a006,231 0x005e502a,
232 0x0650a9a7, 0x06518006, 0x065189a7, 0x06526006, 0x065269a7, 0x06534006, 0x065349a7, 0x06542006, 0x065429a7,232 0x005e6802,
233 0x06550006, 0x065509a7, 0x0655e006, 0x0655e9a7, 0x0656c006, 0x0656c9a7, 0x0657a006, 0x0657a9a7, 0x06588006,233 0x005eb802,
234 0x065889a7, 0x06596006, 0x065969a7, 0x065a4006, 0x065a49a7, 0x065b2006, 0x065b29a7, 0x065c0006, 0x065c09a7,234 0x00600002,
235 0x065ce006, 0x065ce9a7, 0x065dc006, 0x065dc9a7, 0x065ea006, 0x065ea9a7, 0x065f8006, 0x065f89a7, 0x06606006,235 0x0060082a,
236 0x066069a7, 0x06614006, 0x066149a7, 0x06622006, 0x066229a7, 0x06630006, 0x066309a7, 0x0663e006, 0x0663e9a7,236 0x00602002,
237 0x0664c006, 0x0664c9a7, 0x0665a006, 0x0665a9a7, 0x06668006, 0x066689a7, 0x06676006, 0x066769a7, 0x06684006,237 0x0061e002,
238 0x066849a7, 0x06692006, 0x066929a7, 0x066a0006, 0x066a09a7, 0x066ae006, 0x066ae9a7, 0x066bc006, 0x066bc9a7,238 0x0061f022,
239 0x066ca006, 0x066ca9a7, 0x066d8006, 0x066d89a7, 0x066e6006, 0x066e69a7, 0x066f4006, 0x066f49a7, 0x06702006,239 0x0062083a,
240 0x067029a7, 0x06710006, 0x067109a7, 0x0671e006, 0x0671e9a7, 0x0672c006, 0x0672c9a7, 0x0673a006, 0x0673a9a7,240 0x00623022,
241 0x06748006, 0x067489a7, 0x06756006, 0x067569a7, 0x06764006, 0x067649a7, 0x06772006, 0x067729a7, 0x06780006,241 0x00625032,
242 0x067809a7, 0x0678e006, 0x0678e9a7, 0x0679c006, 0x0679c9a7, 0x067aa006, 0x067aa9a7, 0x067b8006, 0x067b89a7,242 0x0062a812,
243 0x067c6006, 0x067c69a7, 0x067d4006, 0x067d49a7, 0x067e2006, 0x067e29a7, 0x067f0006, 0x067f09a7, 0x067fe006,243 0x00631012,
244 0x067fe9a7, 0x0680c006, 0x0680c9a7, 0x0681a006, 0x0681a9a7, 0x06828006, 0x068289a7, 0x06836006, 0x068369a7,244 0x00640802,
245 0x06844006, 0x068449a7, 0x06852006, 0x068529a7, 0x06860006, 0x068609a7, 0x0686e006, 0x0686e9a7, 0x0687c006,245 0x0064101a,
246 0x0687c9a7, 0x0688a006, 0x0688a9a7, 0x06898006, 0x068989a7, 0x068a6006, 0x068a69a7, 0x068b4006, 0x068b49a7,246 0x0065e002,
247 0x068c2006, 0x068c29a7, 0x068d0006, 0x068d09a7, 0x068de006, 0x068de9a7, 0x068ec006, 0x068ec9a7, 0x068fa006,247 0x0065f00a,
248 0x068fa9a7, 0x06908006, 0x069089a7, 0x06916006, 0x069169a7, 0x06924006, 0x069249a7, 0x06932006, 0x069329a7,248 0x0065f802,
249 0x06940006, 0x069409a7, 0x0694e006, 0x0694e9a7, 0x0695c006, 0x0695c9a7, 0x0696a006, 0x0696a9a7, 0x06978006,249 0x0066001a,
250 0x069789a7, 0x06986006, 0x069869a7, 0x06994006, 0x069949a7, 0x069a2006, 0x069a29a7, 0x069b0006, 0x069b09a7,250 0x00661002,
251 0x069be006, 0x069be9a7, 0x069cc006, 0x069cc9a7, 0x069da006, 0x069da9a7, 0x069e8006, 0x069e89a7, 0x069f6006,251 0x0066181a,
252 0x069f69a7, 0x06a04006, 0x06a049a7, 0x06a12006, 0x06a129a7, 0x06a20006, 0x06a209a7, 0x06a2e006, 0x06a2e9a7,252 0x00663002,
253 0x06a3c006, 0x06a3c9a7, 0x06a4a006, 0x06a4a9a7, 0x06a58006, 0x06a589a7, 0x06a66006, 0x06a669a7, 0x06a74006,253 0x0066381a,
254 0x06a749a7, 0x06a82006, 0x06a829a7, 0x06a90006, 0x06a909a7, 0x06a9e006, 0x06a9e9a7, 0x06aac006, 0x06aac9a7,254 0x0066501a,
255 0x06aba006, 0x06aba9a7, 0x06ac8006, 0x06ac89a7, 0x06ad6006, 0x06ad69a7, 0x06ae4006, 0x06ae49a7, 0x06af2006,255 0x00666012,
256 0x06af29a7, 0x06b00006, 0x06b009a7, 0x06b0e006, 0x06b0e9a7, 0x06b1c006, 0x06b1c9a7, 0x06b2a006, 0x06b2a9a7,256 0x0066a812,
257 0x06b38006, 0x06b389a7, 0x06b46006, 0x06b469a7, 0x06b54006, 0x06b549a7, 0x06b62006, 0x06b629a7, 0x06b70006,257 0x00671012,
258 0x06b709a7, 0x06b7e006, 0x06b7e9a7, 0x06b8c006, 0x06b8c9a7, 0x06b9a006, 0x06b9a9a7, 0x06ba8006, 0x06ba89a7,258 0x0067980a,
259 0x06bb6006, 0x06bb69a7, 0x06bc4006, 0x06bc49a7, 0x06bd816c, 0x06be5b0b, 0x07d8f002, 0x07f000f2, 0x07f100f2,259 0x00680012,
260 0x07f7f801, 0x07fcf012, 0x07ff80b1, 0x080fe802, 0x08170002, 0x081bb042, 0x08500822, 0x08502812, 0x08506032,260 0x0068101a,
261 0x0851c022, 0x0851f802, 0x08572812, 0x08692032, 0x08755812, 0x087a30a2, 0x087c1032, 0x0880000a, 0x08800802,261 0x0069d812,
262 0x0880100a, 0x0881c0e2, 0x08838002, 0x08839812, 0x0883f822, 0x0884100a, 0x0885802a, 0x08859832, 0x0885b81a,262 0x0069f002,
263 0x0885c812, 0x0885e808, 0x08861002, 0x08866808, 0x08880022, 0x08893842, 0x0889600a, 0x08896872, 0x088a281a,263 0x0069f81a,
264 0x088b9802, 0x088c0012, 0x088c100a, 0x088d982a, 0x088db082, 0x088df81a, 0x088e1018, 0x088e4832, 0x088e700a,264 0x006a0832,
265 0x088e7802, 0x0891602a, 0x08917822, 0x0891901a, 0x0891a002, 0x0891a80a, 0x0891b012, 0x0891f002, 0x0896f802,265 0x006a302a,
266 0x0897002a, 0x08971872, 0x08980012, 0x0898101a, 0x0899d812, 0x0899f002, 0x0899f80a, 0x089a0002, 0x089a083a,266 0x006a502a,
267 0x089a381a, 0x089a582a, 0x089ab802, 0x089b101a, 0x089b3062, 0x089b8042, 0x08a1a82a, 0x08a1c072, 0x08a2001a,267 0x006a6802,
268 0x08a21022, 0x08a2280a, 0x08a23002, 0x08a2f002, 0x08a58002, 0x08a5881a, 0x08a59852, 0x08a5c80a, 0x08a5d002,268 0x006a7008,
269 0x08a5d81a, 0x08a5e802, 0x08a5f00a, 0x08a5f812, 0x08a6080a, 0x08a61012, 0x08ad7802, 0x08ad801a, 0x08ad9032,269 0x006ab802,
270 0x08adc03a, 0x08ade012, 0x08adf00a, 0x08adf812, 0x08aee012, 0x08b1802a, 0x08b19872, 0x08b1d81a, 0x08b1e802,270 0x006b1012,
271 0x08b1f00a, 0x08b1f812, 0x08b55802, 0x08b5600a, 0x08b56802, 0x08b5701a, 0x08b58052, 0x08b5b00a, 0x08b5b802,271 0x006c0802,
272 0x08b8e822, 0x08b91032, 0x08b9300a, 0x08b93842, 0x08c1602a, 0x08c17882, 0x08c1c00a, 0x08c1c812, 0x08c98002,272 0x006c101a,
273 0x08c9884a, 0x08c9b81a, 0x08c9d812, 0x08c9e80a, 0x08c9f002, 0x08c9f808, 0x08ca000a, 0x08ca0808, 0x08ca100a,273 0x006e5002,
274 0x08ca1802, 0x08ce882a, 0x08cea032, 0x08ced012, 0x08cee03a, 0x08cf0002, 0x08cf200a, 0x08d00892, 0x08d19852,274 0x006e7802,
275 0x08d1c80a, 0x08d1d008, 0x08d1d832, 0x08d23802, 0x08d28852, 0x08d2b81a, 0x08d2c822, 0x08d42058, 0x08d450c2,275 0x006e801a,
276 0x08d4b80a, 0x08d4c012, 0x08e1780a, 0x08e18062, 0x08e1c052, 0x08e1f00a, 0x08e1f802, 0x08e49152, 0x08e5480a,276 0x006e9022,
277 0x08e55062, 0x08e5880a, 0x08e59012, 0x08e5a00a, 0x08e5a812, 0x08e98852, 0x08e9d002, 0x08e9e012, 0x08e9f862,277 0x006eb002,
278 0x08ea3008, 0x08ea3802, 0x08ec504a, 0x08ec8012, 0x08ec981a, 0x08eca802, 0x08ecb00a, 0x08ecb802, 0x08f79812,278 0x006ec06a,
279 0x08f7a81a, 0x09a18081, 0x0b578042, 0x0b598062, 0x0b7a7802, 0x0b7a8b6a, 0x0b7c7832, 0x0b7f2002, 0x0b7f801a,279 0x006ef802,
280 0x0de4e812, 0x0de50031, 0x0e7802d2, 0x0e798162, 0x0e8b2802, 0x0e8b300a, 0x0e8b3822, 0x0e8b680a, 0x0e8b7042,280 0x006f901a,
281 0x0e8b9871, 0x0e8bd872, 0x0e8c2862, 0x0e8d5032, 0x0e921022, 0x0ed00362, 0x0ed1db12, 0x0ed3a802, 0x0ed42002,281 0x00718802,
282 0x0ed4d842, 0x0ed508e2, 0x0f000062, 0x0f004102, 0x0f00d862, 0x0f011812, 0x0f013042, 0x0f098062, 0x0f157002,282 0x0071980a,
283 0x0f176032, 0x0f468062, 0x0f4a2062, 0x0f8007f3, 0x0f8407f3, 0x0f886823, 0x0f897803, 0x0f8b6053, 0x0f8bf013,283 0x0071a062,
284 0x0f8c7003, 0x0f8c8893, 0x0f8d6b83, 0x0f8f3199, 0x0f9008e3, 0x0f90d003, 0x0f917803, 0x0f919083, 0x0f91e033,284 0x00723872,
285 0x0f924ff3, 0x0f964ff3, 0x0f9a4ff3, 0x0f9e4b13, 0x0f9fd842, 0x0fa007f3, 0x0fa407f3, 0x0fa803d3, 0x0faa37f3,285 0x00758802,
286 0x0fae37f3, 0x0fb23093, 0x0fb407f3, 0x0fbba0b3, 0x0fbeaaa3, 0x0fc06033, 0x0fc24073, 0x0fc2d053, 0x0fc44073,286 0x0075980a,
287 0x0fc57513, 0x0fc862e3, 0x0fc9e093, 0x0fca3ff3, 0x0fce3ff3, 0x0fd23ff3, 0x0fd63b83, 0x0fe007f3, 0x0fe407f3,287 0x0075a082,
288 0x0fe807f3, 0x0fec07f3, 0x0ff007f3, 0x0ff407f3, 0x0ff807f3, 0x0ffc07d3, 0x700001f1, 0x700105f2, 0x700407f1,288 0x00764062,
289 0x700807f2, 0x700c06f2, 0x700f87f1, 0x701387f1, 0x701787f1, 0x701b87f1, 0x701f87f1, 0x702387f1, 0x702787f1,289 0x0078c012,
290 0x702b87f1, 0x702f87f1, 0x703387f1, 0x703787f1, 0x703b87f1, 0x703f87f1, 0x704387f1, 0x704787f1, 0x704b87f1,290 0x0079a802,
291 0x704f87f1, 0x705387f1, 0x705787f1, 0x705b87f1, 0x705f87f1, 0x706387f1, 0x706787f1, 0x706b87f1, 0x706f87f1,291 0x0079b802,
292 0x707387f1, 0x707787f1, 0x707b87f1, 0x707f80f1};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
294/// Returns the extended grapheme cluster bondary property of a code point.1625/// Returns the extended grapheme cluster bondary property of a code point.
295[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __property __get_property(const char32_t __code_point) noexcept {1626[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __property __get_property(const char32_t __code_point) noexcept {
296 // TODO FMT use std::ranges::upper_bound.
297
298 // The algorithm searches for the upper bound of the range and, when found,1627 // The algorithm searches for the upper bound of the range and, when found,
299 // steps back one entry. This algorithm is used since the code point can be1628 // steps back one entry. This algorithm is used since the code point can be
300 // anywhere in the range. After a lower bound is found the next step is to1629 // 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] = {...@@ -311,7 +1640,7 @@ inline constexpr uint32_t __entries[1480] = {
311 // size. Then the upper bound for code point 3 will return the entry after1640 // size. Then the upper bound for code point 3 will return the entry after
312 // 0x1810. After moving to the previous entry the algorithm arrives at the1641 // 0x1810. After moving to the previous entry the algorithm arrives at the
313 // correct entry.1642 // 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;
315 if (__i == 0)1644 if (__i == 0)
316 return __property::__none;1645 return __property::__none;
3171646
lib/libcxx/include/__format/format_arg.h+35-5
...@@ -45,16 +45,22 @@ namespace __format {...@@ -45,16 +45,22 @@ namespace __format {
45/// It could be packed in 4-bits but that means a new type directly becomes an45/// It could be packed in 4-bits but that means a new type directly becomes an
46/// ABI break. The packed type is 64-bit so this reduces the maximum number of46/// ABI break. The packed type is 64-bit so this reduces the maximum number of
47/// packed elements from 16 to 12.47/// 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.
48enum class _LIBCPP_ENUM_VIS __arg_t : uint8_t {54enum class _LIBCPP_ENUM_VIS __arg_t : uint8_t {
49 __none,55 __none,
50 __boolean,56 __boolean,
51 __char_type,57 __char_type,
52 __int,58 __int,
53 __long_long,59 __long_long,
54 __i128,60 __i128, // extension
55 __unsigned,61 __unsigned,
56 __unsigned_long_long,62 __unsigned_long_long,
57 __u128,63 __u128, // extension
58 __float,64 __float,
59 __double,65 __double,
60 __long_double,66 __long_double,
...@@ -85,9 +91,11 @@ constexpr __arg_t __get_packed_type(uint64_t __types, size_t __id) {...@@ -85,9 +91,11 @@ constexpr __arg_t __get_packed_type(uint64_t __types, size_t __id) {
8591
86} // namespace __format92} // 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.
88template <class _Visitor, class _Context>96template <class _Visitor, class _Context>
89_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT decltype(auto) visit_format_arg(_Visitor&& __vis,97_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT decltype(auto)
90 basic_format_arg<_Context> __arg) {98__visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) {
91 switch (__arg.__type_) {99 switch (__arg.__type_) {
92 case __format::__arg_t::__none:100 case __format::__arg_t::__none:
93 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__monostate_);101 return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__monostate_);
...@@ -153,7 +161,7 @@ public:...@@ -153,7 +161,7 @@ public:
153 using _Dp = remove_cvref_t<_Tp>;161 using _Dp = remove_cvref_t<_Tp>;
154 using _Formatter = typename _Context::template formatter_type<_Dp>;162 using _Formatter = typename _Context::template formatter_type<_Dp>;
155 constexpr bool __const_formattable =163 constexpr bool __const_formattable =
156 requires { _Formatter().format(declval<const _Dp&>(), declval<_Context&>()); };164 requires { _Formatter().format(std::declval<const _Dp&>(), std::declval<_Context&>()); };
157 using _Qp = conditional_t<__const_formattable, const _Dp, _Dp>;165 using _Qp = conditional_t<__const_formattable, const _Dp, _Dp>;
158166
159 static_assert(__const_formattable || !is_const_v<remove_reference_t<_Tp>>, "Mandated by [format.arg]/18");167 static_assert(__const_formattable || !is_const_v<remove_reference_t<_Tp>>, "Mandated by [format.arg]/18");
...@@ -265,6 +273,28 @@ private:...@@ -265,6 +273,28 @@ private:
265 typename __basic_format_arg_value<_Context>::__handle& __handle_;273 typename __basic_format_arg_value<_Context>::__handle& __handle_;
266};274};
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
268#endif //_LIBCPP_STD_VER > 17298#endif //_LIBCPP_STD_VER > 17
269299
270_LIBCPP_END_NAMESPACE_STD300_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__format/format_arg_store.h+3-2
...@@ -19,6 +19,7 @@...@@ -19,6 +19,7 @@
19#include <__config>19#include <__config>
20#include <__format/concepts.h>20#include <__format/concepts.h>
21#include <__format/format_arg.h>21#include <__format/format_arg.h>
22#include <__utility/forward.h>
22#include <cstring>23#include <cstring>
23#include <string>24#include <string>
24#include <string_view>25#include <string_view>
...@@ -197,7 +198,7 @@ _LIBCPP_HIDE_FROM_ABI void __create_packed_storage(uint64_t& __types, __basic_fo...@@ -197,7 +198,7 @@ _LIBCPP_HIDE_FROM_ABI void __create_packed_storage(uint64_t& __types, __basic_fo
197 int __shift = 0;198 int __shift = 0;
198 (199 (
199 [&] {200 [&] {
200 basic_format_arg<_Context> __arg = __create_format_arg<_Context>(__args);201 basic_format_arg<_Context> __arg = __format::__create_format_arg<_Context>(__args);
201 if (__shift != 0)202 if (__shift != 0)
202 __types |= static_cast<uint64_t>(__arg.__type_) << __shift;203 __types |= static_cast<uint64_t>(__arg.__type_) << __shift;
203 else204 else
...@@ -211,7 +212,7 @@ _LIBCPP_HIDE_FROM_ABI void __create_packed_storage(uint64_t& __types, __basic_fo...@@ -211,7 +212,7 @@ _LIBCPP_HIDE_FROM_ABI void __create_packed_storage(uint64_t& __types, __basic_fo
211212
212template <class _Context, class... _Args>213template <class _Context, class... _Args>
213_LIBCPP_HIDE_FROM_ABI void __store_basic_format_arg(basic_format_arg<_Context>* __data, _Args&&... __args) noexcept {214_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); }(), ...);
215}216}
216217
217template <class _Context, size_t N>218template <class _Context, size_t N>
lib/libcxx/include/__format/format_args.h+1
...@@ -71,6 +71,7 @@ private:...@@ -71,6 +71,7 @@ private:
71 const basic_format_arg<_Context>* __args_;71 const basic_format_arg<_Context>* __args_;
72 };72 };
73};73};
74_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_format_args);
7475
75#endif //_LIBCPP_STD_VER > 1776#endif //_LIBCPP_STD_VER > 17
7677
lib/libcxx/include/__format/format_context.h+80-8
...@@ -11,14 +11,19 @@...@@ -11,14 +11,19 @@
11#define _LIBCPP___FORMAT_FORMAT_CONTEXT_H11#define _LIBCPP___FORMAT_FORMAT_CONTEXT_H
1212
13#include <__availability>13#include <__availability>
14#include <__concepts/same_as.h>
14#include <__config>15#include <__config>
15#include <__format/buffer.h>16#include <__format/buffer.h>
17#include <__format/format_arg.h>
18#include <__format/format_arg_store.h>
16#include <__format/format_args.h>19#include <__format/format_args.h>
20#include <__format/format_error.h>
17#include <__format/format_fwd.h>21#include <__format/format_fwd.h>
18#include <__iterator/back_insert_iterator.h>22#include <__iterator/back_insert_iterator.h>
19#include <__iterator/concepts.h>23#include <__iterator/concepts.h>
24#include <__memory/addressof.h>
20#include <__utility/move.h>25#include <__utility/move.h>
21#include <concepts>26#include <__variant/monostate.h>
22#include <cstddef>27#include <cstddef>
2328
24#ifndef _LIBCPP_HAS_NO_LOCALIZATION29#ifndef _LIBCPP_HAS_NO_LOCALIZATION
...@@ -50,8 +55,7 @@ __format_context_create(...@@ -50,8 +55,7 @@ __format_context_create(
50 _OutIt __out_it,55 _OutIt __out_it,
51 basic_format_args<basic_format_context<_OutIt, _CharT>> __args,56 basic_format_args<basic_format_context<_OutIt, _CharT>> __args,
52 optional<_VSTD::locale>&& __loc = nullopt) {57 optional<_VSTD::locale>&& __loc = nullopt) {
53 return _VSTD::basic_format_context(_VSTD::move(__out_it), __args,58 return _VSTD::basic_format_context(_VSTD::move(__out_it), __args, _VSTD::move(__loc));
54 _VSTD::move(__loc));
55}59}
56#else60#else
57template <class _OutIt, class _CharT>61template <class _OutIt, class _CharT>
...@@ -87,9 +91,6 @@ public:...@@ -87,9 +91,6 @@ public:
87 template <class _Tp>91 template <class _Tp>
88 using formatter_type = formatter<_Tp, _CharT>;92 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
93 _LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context>94 _LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context>
94 arg(size_t __id) const noexcept {95 arg(size_t __id) const noexcept {
95 return __args_.get(__id);96 return __args_.get(__id);
...@@ -101,8 +102,8 @@ public:...@@ -101,8 +102,8 @@ public:
101 return *__loc_;102 return *__loc_;
102 }103 }
103#endif104#endif
104 _LIBCPP_HIDE_FROM_ABI iterator out() { return __out_it_; }105 _LIBCPP_HIDE_FROM_ABI iterator out() { return std::move(__out_it_); }
105 _LIBCPP_HIDE_FROM_ABI void advance_to(iterator __it) { __out_it_ = __it; }106 _LIBCPP_HIDE_FROM_ABI void advance_to(iterator __it) { __out_it_ = std::move(__it); }
106107
107private:108private:
108 iterator __out_it_;109 iterator __out_it_;
...@@ -144,6 +145,77 @@ private:...@@ -144,6 +145,77 @@ private:
144#endif145#endif
145};146};
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);
147#endif //_LIBCPP_STD_VER > 17219#endif //_LIBCPP_STD_VER > 17
148220
149_LIBCPP_END_NAMESPACE_STD221_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__format/format_error.h+9-5
...@@ -11,11 +11,8 @@...@@ -11,11 +11,8 @@
11#define _LIBCPP___FORMAT_FORMAT_ERROR_H11#define _LIBCPP___FORMAT_FORMAT_ERROR_H
1212
13#include <__config>13#include <__config>
14#include <stdexcept>
15
16#ifdef _LIBCPP_NO_EXCEPTIONS
17#include <cstdlib>14#include <cstdlib>
18#endif15#include <stdexcept>
1916
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header18# pragma GCC system_header
...@@ -31,7 +28,14 @@ public:...@@ -31,7 +28,14 @@ public:
31 : runtime_error(__s) {}28 : runtime_error(__s) {}
32 _LIBCPP_HIDE_FROM_ABI explicit format_error(const char* __s)29 _LIBCPP_HIDE_FROM_ABI explicit format_error(const char* __s)
33 : runtime_error(__s) {}30 : 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
35};39};
3640
37_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void41_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:...@@ -54,8 +54,7 @@ public:
5454
55 _LIBCPP_HIDE_FROM_ABI constexpr size_t next_arg_id() {55 _LIBCPP_HIDE_FROM_ABI constexpr size_t next_arg_id() {
56 if (__indexing_ == __manual)56 if (__indexing_ == __manual)
57 __throw_format_error("Using automatic argument numbering in manual "57 std::__throw_format_error("Using automatic argument numbering in manual argument numbering mode");
58 "argument numbering mode");
5958
60 if (__indexing_ == __unknown)59 if (__indexing_ == __unknown)
61 __indexing_ = __automatic;60 __indexing_ = __automatic;
...@@ -63,8 +62,7 @@ public:...@@ -63,8 +62,7 @@ public:
63 }62 }
64 _LIBCPP_HIDE_FROM_ABI constexpr void check_arg_id(size_t __id) {63 _LIBCPP_HIDE_FROM_ABI constexpr void check_arg_id(size_t __id) {
65 if (__indexing_ == __automatic)64 if (__indexing_ == __automatic)
66 __throw_format_error("Using manual argument numbering in automatic "65 std::__throw_format_error("Using manual argument numbering in automatic argument numbering mode");
67 "argument numbering mode");
6866
69 if (__indexing_ == __unknown)67 if (__indexing_ == __unknown)
70 __indexing_ = __manual;68 __indexing_ = __manual;
...@@ -77,7 +75,7 @@ public:...@@ -77,7 +75,7 @@ public:
77 // Note: the Throws clause [format.parse.ctx]/10 doesn't specify the75 // Note: the Throws clause [format.parse.ctx]/10 doesn't specify the
78 // behavior when id >= num_args_.76 // behavior when id >= num_args_.
79 if (is_constant_evaluated() && __id >= __num_args_)77 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");
81 }79 }
8280
83private:81private:
...@@ -88,6 +86,7 @@ private:...@@ -88,6 +86,7 @@ private:
88 size_t __next_arg_id_;86 size_t __next_arg_id_;
89 size_t __num_args_;87 size_t __num_args_;
90};88};
89_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_format_parse_context);
9190
92using format_parse_context = basic_format_parse_context<char>;91using format_parse_context = basic_format_parse_context<char>;
93#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS92#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 {...@@ -32,6 +32,9 @@ struct _LIBCPP_TEMPLATE_VIS __parse_number_result {
32 uint32_t __value;32 uint32_t __value;
33};33};
3434
35template <class _CharT>
36__parse_number_result(const _CharT*, uint32_t) -> __parse_number_result<_CharT>;
37
35template <class _CharT>38template <class _CharT>
36_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT>39_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT>
37__parse_number(const _CharT* __begin, const _CharT* __end);40__parse_number(const _CharT* __begin, const _CharT* __end);
...@@ -70,7 +73,7 @@ __parse_automatic(const _CharT* __begin, const _CharT*, auto& __parse_ctx) {...@@ -70,7 +73,7 @@ __parse_automatic(const _CharT* __begin, const _CharT*, auto& __parse_ctx) {
70template <class _CharT>73template <class _CharT>
71_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT>74_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT>
72__parse_manual(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {75__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);
74 __parse_ctx.check_arg_id(__r.__value);77 __parse_ctx.check_arg_id(__r.__value);
75 return __r;78 return __r;
76}79}
...@@ -117,7 +120,7 @@ __parse_number(const _CharT* __begin, const _CharT* __end_input) {...@@ -117,7 +120,7 @@ __parse_number(const _CharT* __begin, const _CharT* __end_input) {
117 if (__v > __number_max ||120 if (__v > __number_max ||
118 (__begin != __end_input && *__begin >= _CharT('0') &&121 (__begin != __end_input && *__begin >= _CharT('0') &&
119 *__begin <= _CharT('9')))122 *__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
122 __value = __v;125 __value = __v;
123 }126 }
...@@ -146,8 +149,7 @@ __parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {...@@ -146,8 +149,7 @@ __parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
146 return __detail::__parse_automatic(__begin, __end, __parse_ctx);149 return __detail::__parse_automatic(__begin, __end, __parse_ctx);
147 }150 }
148 if (*__begin < _CharT('0') || *__begin > _CharT('9'))151 if (*__begin < _CharT('0') || *__begin > _CharT('9'))
149 __throw_format_error(152 std::__throw_format_error("The arg-id of the format-spec starts with an invalid character");
150 "The arg-id of the format-spec starts with an invalid character");
151153
152 return __detail::__parse_manual(__begin, __end, __parse_ctx);154 return __detail::__parse_manual(__begin, __end, __parse_ctx);
153}155}
lib/libcxx/include/__format/format_to_n_result.h+1
...@@ -26,6 +26,7 @@ struct _LIBCPP_TEMPLATE_VIS format_to_n_result {...@@ -26,6 +26,7 @@ struct _LIBCPP_TEMPLATE_VIS format_to_n_result {
26 _OutIt out;26 _OutIt out;
27 iter_difference_t<_OutIt> size;27 iter_difference_t<_OutIt> size;
28};28};
29_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(format_to_n_result);
2930
30#endif //_LIBCPP_STD_VER > 1731#endif //_LIBCPP_STD_VER > 17
3132
lib/libcxx/include/__format/formatter.h+8-8
...@@ -11,7 +11,6 @@...@@ -11,7 +11,6 @@
11#define _LIBCPP___FORMAT_FORMATTER_H11#define _LIBCPP___FORMAT_FORMATTER_H
1212
13#include <__availability>13#include <__availability>
14#include <__concepts/same_as.h>
15#include <__config>14#include <__config>
16#include <__format/format_fwd.h>15#include <__format/format_fwd.h>
1716
...@@ -39,15 +38,16 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter {...@@ -39,15 +38,16 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter {
39 formatter& operator=(const formatter&) = delete;38 formatter& operator=(const formatter&) = delete;
40};39};
4140
42namespace __formatter {41# if _LIBCPP_STD_VER > 20
4342
44/** The character types that formatters are specialized for. */43template <class _Tp>
45template <class _CharT>44_LIBCPP_HIDE_FROM_ABI constexpr void __set_debug_format(_Tp& __formatter) {
46concept __char_type = same_as<_CharT, char> || same_as<_CharT, wchar_t>;45 if constexpr (requires { __formatter.set_debug_format(); })
46 __formatter.set_debug_format();
47}
4748
48} // namespace __formatter49# endif // _LIBCPP_STD_VER > 20
4950#endif // _LIBCPP_STD_VER > 17
50#endif //_LIBCPP_STD_VER > 17
5151
52_LIBCPP_END_NAMESPACE_STD52_LIBCPP_END_NAMESPACE_STD
5353
lib/libcxx/include/__format/formatter_bool.h+2-2
...@@ -14,8 +14,8 @@...@@ -14,8 +14,8 @@
14#include <__availability>14#include <__availability>
15#include <__config>15#include <__config>
16#include <__debug>16#include <__debug>
17#include <__format/concepts.h>
17#include <__format/format_error.h>18#include <__format/format_error.h>
18#include <__format/format_fwd.h>
19#include <__format/format_parse_context.h>19#include <__format/format_parse_context.h>
20#include <__format/formatter.h>20#include <__format/formatter.h>
21#include <__format/formatter_integral.h>21#include <__format/formatter_integral.h>
...@@ -35,7 +35,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -35,7 +35,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3535
36#if _LIBCPP_STD_VER > 1736#if _LIBCPP_STD_VER > 17
3737
38template <__formatter::__char_type _CharT>38template <__fmt_char_type _CharT>
39struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<bool, _CharT> {39struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<bool, _CharT> {
40public:40public:
41 _LIBCPP_HIDE_FROM_ABI constexpr auto41 _LIBCPP_HIDE_FROM_ABI constexpr auto
lib/libcxx/include/__format/formatter_char.h+11-2
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <__availability>13#include <__availability>
14#include <__concepts/same_as.h>14#include <__concepts/same_as.h>
15#include <__config>15#include <__config>
16#include <__format/format_fwd.h>16#include <__format/concepts.h>
17#include <__format/format_parse_context.h>17#include <__format/format_parse_context.h>
18#include <__format/formatter.h>18#include <__format/formatter.h>
19#include <__format/formatter_integral.h>19#include <__format/formatter_integral.h>
...@@ -30,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -30,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3030
31#if _LIBCPP_STD_VER > 1731#if _LIBCPP_STD_VER > 17
3232
33template <__formatter::__char_type _CharT>33template <__fmt_char_type _CharT>
34struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_char {34struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_char {
35public:35public:
36 _LIBCPP_HIDE_FROM_ABI constexpr auto36 _LIBCPP_HIDE_FROM_ABI constexpr auto
...@@ -44,6 +44,11 @@ public:...@@ -44,6 +44,11 @@ public:
44 if (__parser_.__type_ == __format_spec::__type::__default || __parser_.__type_ == __format_spec::__type::__char)44 if (__parser_.__type_ == __format_spec::__type::__default || __parser_.__type_ == __format_spec::__type::__char)
45 return __formatter::__format_char(__value, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx));45 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
47 if constexpr (sizeof(_CharT) <= sizeof(int))52 if constexpr (sizeof(_CharT) <= sizeof(int))
48 // Promotes _CharT to an integral type. This reduces the number of53 // Promotes _CharT to an integral type. This reduces the number of
49 // instantiations of __format_integer reducing code size.54 // instantiations of __format_integer reducing code size.
...@@ -61,6 +66,10 @@ public:...@@ -61,6 +66,10 @@ public:
61 return format(static_cast<wchar_t>(__value), __ctx);66 return format(static_cast<wchar_t>(__value), __ctx);
62 }67 }
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
64 __format_spec::__parser<_CharT> __parser_;73 __format_spec::__parser<_CharT> __parser_;
65};74};
6675
lib/libcxx/include/__format/formatter_floating_point.h+72-36
...@@ -10,17 +10,16 @@...@@ -10,17 +10,16 @@
10#ifndef _LIBCPP___FORMAT_FORMATTER_FLOATING_POINT_H10#ifndef _LIBCPP___FORMAT_FORMATTER_FLOATING_POINT_H
11#define _LIBCPP___FORMAT_FORMATTER_FLOATING_POINT_H11#define _LIBCPP___FORMAT_FORMATTER_FLOATING_POINT_H
1212
13#include <__algorithm/copy.h>
14#include <__algorithm/copy_n.h>13#include <__algorithm/copy_n.h>
15#include <__algorithm/fill_n.h>
16#include <__algorithm/find.h>14#include <__algorithm/find.h>
15#include <__algorithm/max.h>
17#include <__algorithm/min.h>16#include <__algorithm/min.h>
18#include <__algorithm/rotate.h>17#include <__algorithm/rotate.h>
19#include <__algorithm/transform.h>18#include <__algorithm/transform.h>
20#include <__concepts/arithmetic.h>19#include <__concepts/arithmetic.h>
21#include <__concepts/same_as.h>20#include <__concepts/same_as.h>
22#include <__config>21#include <__config>
23#include <__format/format_fwd.h>22#include <__format/concepts.h>
24#include <__format/format_parse_context.h>23#include <__format/format_parse_context.h>
25#include <__format/formatter.h>24#include <__format/formatter.h>
26#include <__format/formatter_integral.h>25#include <__format/formatter_integral.h>
...@@ -103,7 +102,7 @@ template <class _Tp>...@@ -103,7 +102,7 @@ template <class _Tp>
103struct __traits;102struct __traits;
104103
105template <floating_point _Fp>104template <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) {
107 using _Traits = __traits<_Fp>;106 using _Traits = __traits<_Fp>;
108 return 4 + _Traits::__max_integral + __precision + _Traits::__max_fractional_value;107 return 4 + _Traits::__max_integral + __precision + _Traits::__max_fractional_value;
109}108}
...@@ -183,6 +182,7 @@ public:...@@ -183,6 +182,7 @@ public:
183 _LIBCPP_HIDE_FROM_ABI int __precision() const { return __precision_; }182 _LIBCPP_HIDE_FROM_ABI int __precision() const { return __precision_; }
184 _LIBCPP_HIDE_FROM_ABI int __num_trailing_zeros() const { return __num_trailing_zeros_; }183 _LIBCPP_HIDE_FROM_ABI int __num_trailing_zeros() const { return __num_trailing_zeros_; }
185 _LIBCPP_HIDE_FROM_ABI void __remove_trailing_zeros() { __num_trailing_zeros_ = 0; }184 _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
187private:187private:
188 int __precision_;188 int __precision_;
...@@ -216,7 +216,7 @@ struct __float_result {...@@ -216,7 +216,7 @@ struct __float_result {
216/// \returns a pointer to the exponent or __last when not found.216/// \returns a pointer to the exponent or __last when not found.
217constexpr inline _LIBCPP_HIDE_FROM_ABI char* __find_exponent(char* __first, char* __last) {217constexpr inline _LIBCPP_HIDE_FROM_ABI char* __find_exponent(char* __first, char* __last) {
218 ptrdiff_t __size = __last - __first;218 ptrdiff_t __size = __last - __first;
219 if (__size > 4) {219 if (__size >= 4) {
220 __first = __last - _VSTD::min(__size, ptrdiff_t(6));220 __first = __last - _VSTD::min(__size, ptrdiff_t(6));
221 for (; __first != __last - 3; ++__first) {221 for (; __first != __last - 3; ++__first) {
222 if (*__first == 'e')222 if (*__first == 'e')
...@@ -404,6 +404,7 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_lower_case(__float_...@@ -404,6 +404,7 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_lower_case(__float_
404 // In fixed mode the algorithm truncates trailing spaces and possibly the404 // In fixed mode the algorithm truncates trailing spaces and possibly the
405 // radix point. There's no good guess for the position of the radix point405 // radix point. There's no good guess for the position of the radix point
406 // therefore scan the output after the first digit.406 // therefore scan the output after the first digit.
407
407 __result.__radix_point = _VSTD::find(__first, __result.__last, '.');408 __result.__radix_point = _VSTD::find(__first, __result.__last, '.');
408 }409 }
409 }410 }
...@@ -454,7 +455,10 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer(...@@ -454,7 +455,10 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer(
454 char* __first = __formatter::__insert_sign(__buffer.begin(), __negative, __sign);455 char* __first = __formatter::__insert_sign(__buffer.begin(), __negative, __sign);
455 switch (__type) {456 switch (__type) {
456 case __format_spec::__type::__default:457 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
459 case __format_spec::__type::__hexfloat_lower_case:463 case __format_spec::__type::__hexfloat_lower_case:
460 return __formatter::__format_buffer_hexadecimal_lower_case(464 return __formatter::__format_buffer_hexadecimal_lower_case(
...@@ -494,7 +498,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(...@@ -494,7 +498,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(
494 const __float_result& __result,498 const __float_result& __result,
495 _VSTD::locale __loc,499 _VSTD::locale __loc,
496 __format_spec::__parsed_specifications<_CharT> __specs) {500 __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);
498 string __grouping = __np.grouping();502 string __grouping = __np.grouping();
499 char* __first = __result.__integral;503 char* __first = __result.__integral;
500 // When no radix point or exponent are present __last will be __result.__last.504 // 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(...@@ -528,13 +532,13 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(
528 // sign and (zero padding or alignment)532 // sign and (zero padding or alignment)
529 if (__zero_padding && __first != __buffer.begin())533 if (__zero_padding && __first != __buffer.begin())
530 *__out_it++ = *__buffer.begin();534 *__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_);
532 if (!__zero_padding && __first != __buffer.begin())536 if (!__zero_padding && __first != __buffer.begin())
533 *__out_it++ = *__buffer.begin();537 *__out_it++ = *__buffer.begin();
534538
535 // integral part539 // integral part
536 if (__grouping.empty()) {540 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));
538 } else {542 } else {
539 auto __r = __grouping.rbegin();543 auto __r = __grouping.rbegin();
540 auto __e = __grouping.rend() - 1;544 auto __e = __grouping.rend() - 1;
...@@ -546,7 +550,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(...@@ -546,7 +550,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(
546 // This loop achieves that process by testing the termination condition550 // This loop achieves that process by testing the termination condition
547 // midway in the loop.551 // midway in the loop.
548 while (true) {552 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));
550 __first += *__r;554 __first += *__r;
551555
552 if (__r == __e)556 if (__r == __e)
...@@ -560,16 +564,16 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(...@@ -560,16 +564,16 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(
560 // fractional part564 // fractional part
561 if (__result.__radix_point != __result.__last) {565 if (__result.__radix_point != __result.__last) {
562 *__out_it++ = __np.decimal_point();566 *__out_it++ = __np.decimal_point();
563 __out_it = _VSTD::copy(__result.__radix_point + 1, __result.__exponent, _VSTD::move(__out_it));567 __out_it = __formatter::__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'));568 __out_it = __formatter::__fill(_VSTD::move(__out_it), __buffer.__num_trailing_zeros(), _CharT('0'));
565 }569 }
566570
567 // exponent571 // exponent
568 if (__result.__exponent != __result.__last)572 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
571 // alignment575 // 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_);
573}577}
574# endif // _LIBCPP_HAS_NO_LOCALIZATION578# endif // _LIBCPP_HAS_NO_LOCALIZATION
575579
...@@ -625,20 +629,51 @@ __format_floating_point(_Tp __value, auto& __ctx, __format_spec::__parsed_specif...@@ -625,20 +629,51 @@ __format_floating_point(_Tp __value, auto& __ctx, __format_spec::__parsed_specif
625 __float_result __result = __formatter::__format_buffer(629 __float_result __result = __formatter::__format_buffer(
626 __buffer, __value, __negative, (__specs.__has_precision()), __specs.__std_.__sign_, __specs.__std_.__type_);630 __buffer, __value, __negative, (__specs.__has_precision()), __specs.__std_.__sign_, __specs.__std_.__type_);
627631
628 if (__specs.__std_.__alternate_form_ && __result.__radix_point == __result.__last) {632 if (__specs.__std_.__alternate_form_) {
629 *__result.__last++ = '.';633 if (__result.__radix_point == __result.__last) {
630634 *__result.__last++ = '.';
631 // When there is an exponent the point needs to be moved before the635
632 // exponent. When there's no exponent the rotate does nothing. Since636 // When there is an exponent the point needs to be moved before the
633 // rotate tests whether the operation is a nop, call it unconditionally.637 // exponent. When there's no exponent the rotate does nothing. Since
634 _VSTD::rotate(__result.__exponent, __result.__last - 1, __result.__last);638 // rotate tests whether the operation is a nop, call it unconditionally.
635 __result.__radix_point = __result.__exponent;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.649 // [format.string.std]/6
638 // - No exponent needs to point to the new last.650 // In addition, for g and G conversions, trailing zeros are not removed
639 // - An exponent needs to move one position to the right.651 // from the result.
640 // So it's safe to increment the value unconditionally.652 //
641 ++__result.__exponent;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 }
642 }677 }
643678
644# ifndef _LIBCPP_HAS_NO_LOCALIZATION679# ifndef _LIBCPP_HAS_NO_LOCALIZATION
...@@ -651,14 +686,15 @@ __format_floating_point(_Tp __value, auto& __ctx, __format_spec::__parsed_specif...@@ -651,14 +686,15 @@ __format_floating_point(_Tp __value, auto& __ctx, __format_spec::__parsed_specif
651 if (__size + __num_trailing_zeros >= __specs.__width_) {686 if (__size + __num_trailing_zeros >= __specs.__width_) {
652 if (__num_trailing_zeros && __result.__exponent != __result.__last)687 if (__num_trailing_zeros && __result.__exponent != __result.__last)
653 // Insert trailing zeros before exponent character.688 // Insert trailing zeros before exponent character.
654 return _VSTD::copy(689 return __formatter::__copy(
655 __result.__exponent,690 __result.__exponent,
656 __result.__last,691 __result.__last,
657 _VSTD::fill_n(692 __formatter::__fill(__formatter::__copy(__buffer.begin(), __result.__exponent, __ctx.out()),
658 _VSTD::copy(__buffer.begin(), __result.__exponent, __ctx.out()), __num_trailing_zeros, _CharT('0')));693 __num_trailing_zeros,
694 _CharT('0')));
659695
660 return _VSTD::fill_n(696 return __formatter::__fill(
661 _VSTD::copy(__buffer.begin(), __result.__last, __ctx.out()), __num_trailing_zeros, _CharT('0'));697 __formatter::__copy(__buffer.begin(), __result.__last, __ctx.out()), __num_trailing_zeros, _CharT('0'));
662 }698 }
663699
664 auto __out_it = __ctx.out();700 auto __out_it = __ctx.out();
...@@ -684,7 +720,7 @@ __format_floating_point(_Tp __value, auto& __ctx, __format_spec::__parsed_specif...@@ -684,7 +720,7 @@ __format_floating_point(_Tp __value, auto& __ctx, __format_spec::__parsed_specif
684720
685} // namespace __formatter721} // namespace __formatter
686722
687template <__formatter::__char_type _CharT>723template <__fmt_char_type _CharT>
688struct _LIBCPP_TEMPLATE_VIS __formatter_floating_point {724struct _LIBCPP_TEMPLATE_VIS __formatter_floating_point {
689public:725public:
690 _LIBCPP_HIDE_FROM_ABI constexpr auto726 _LIBCPP_HIDE_FROM_ABI constexpr auto
...@@ -702,13 +738,13 @@ public:...@@ -702,13 +738,13 @@ public:
702 __format_spec::__parser<_CharT> __parser_;738 __format_spec::__parser<_CharT> __parser_;
703};739};
704740
705template <__formatter::__char_type _CharT>741template <__fmt_char_type _CharT>
706struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<float, _CharT>742struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<float, _CharT>
707 : public __formatter_floating_point<_CharT> {};743 : public __formatter_floating_point<_CharT> {};
708template <__formatter::__char_type _CharT>744template <__fmt_char_type _CharT>
709struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<double, _CharT>745struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<double, _CharT>
710 : public __formatter_floating_point<_CharT> {};746 : public __formatter_floating_point<_CharT> {};
711template <__formatter::__char_type _CharT>747template <__fmt_char_type _CharT>
712struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long double, _CharT>748struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long double, _CharT>
713 : public __formatter_floating_point<_CharT> {};749 : public __formatter_floating_point<_CharT> {};
714750
lib/libcxx/include/__format/formatter_integer.h+14-14
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <__availability>13#include <__availability>
14#include <__concepts/arithmetic.h>14#include <__concepts/arithmetic.h>
15#include <__config>15#include <__config>
16#include <__format/format_fwd.h>16#include <__format/concepts.h>
17#include <__format/format_parse_context.h>17#include <__format/format_parse_context.h>
18#include <__format/formatter.h>18#include <__format/formatter.h>
19#include <__format/formatter_integral.h>19#include <__format/formatter_integral.h>
...@@ -30,7 +30,7 @@...@@ -30,7 +30,7 @@
3030
31#if _LIBCPP_STD_VER > 1731#if _LIBCPP_STD_VER > 17
3232
33 template <__formatter::__char_type _CharT>33 template <__fmt_char_type _CharT>
34 struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_integer {34 struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_integer {
3535
36public:36public:
...@@ -59,43 +59,43 @@ public:...@@ -59,43 +59,43 @@ public:
59};59};
6060
61// Signed integral types.61// Signed integral types.
62template <__formatter::__char_type _CharT>62template <__fmt_char_type _CharT>
63struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<signed char, _CharT>63struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<signed char, _CharT>
64 : public __formatter_integer<_CharT> {};64 : public __formatter_integer<_CharT> {};
65template <__formatter::__char_type _CharT>65template <__fmt_char_type _CharT>
66struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<short, _CharT> : public __formatter_integer<_CharT> {66struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<short, _CharT> : public __formatter_integer<_CharT> {
67};67};
68template <__formatter::__char_type _CharT>68template <__fmt_char_type _CharT>
69struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<int, _CharT> : public __formatter_integer<_CharT> {};69struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<int, _CharT> : public __formatter_integer<_CharT> {};
70template <__formatter::__char_type _CharT>70template <__fmt_char_type _CharT>
71struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long, _CharT> : public __formatter_integer<_CharT> {};71struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long, _CharT> : public __formatter_integer<_CharT> {};
72template <__formatter::__char_type _CharT>72template <__fmt_char_type _CharT>
73struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long long, _CharT>73struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long long, _CharT>
74 : public __formatter_integer<_CharT> {};74 : public __formatter_integer<_CharT> {};
75# ifndef _LIBCPP_HAS_NO_INT12875# ifndef _LIBCPP_HAS_NO_INT128
76template <__formatter::__char_type _CharT>76template <__fmt_char_type _CharT>
77struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<__int128_t, _CharT>77struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<__int128_t, _CharT>
78 : public __formatter_integer<_CharT> {};78 : public __formatter_integer<_CharT> {};
79# endif79# endif
8080
81// Unsigned integral types.81// Unsigned integral types.
82template <__formatter::__char_type _CharT>82template <__fmt_char_type _CharT>
83struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned char, _CharT>83struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned char, _CharT>
84 : public __formatter_integer<_CharT> {};84 : public __formatter_integer<_CharT> {};
85template <__formatter::__char_type _CharT>85template <__fmt_char_type _CharT>
86struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned short, _CharT>86struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned short, _CharT>
87 : public __formatter_integer<_CharT> {};87 : public __formatter_integer<_CharT> {};
88template <__formatter::__char_type _CharT>88template <__fmt_char_type _CharT>
89struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned, _CharT>89struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned, _CharT>
90 : public __formatter_integer<_CharT> {};90 : public __formatter_integer<_CharT> {};
91template <__formatter::__char_type _CharT>91template <__fmt_char_type _CharT>
92struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned long, _CharT>92struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned long, _CharT>
93 : public __formatter_integer<_CharT> {};93 : public __formatter_integer<_CharT> {};
94template <__formatter::__char_type _CharT>94template <__fmt_char_type _CharT>
95struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned long long, _CharT>95struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned long long, _CharT>
96 : public __formatter_integer<_CharT> {};96 : public __formatter_integer<_CharT> {};
97# ifndef _LIBCPP_HAS_NO_INT12897# ifndef _LIBCPP_HAS_NO_INT128
98template <__formatter::__char_type _CharT>98template <__fmt_char_type _CharT>
99struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<__uint128_t, _CharT>99struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<__uint128_t, _CharT>
100 : public __formatter_integer<_CharT> {};100 : public __formatter_integer<_CharT> {};
101# endif101# endif
lib/libcxx/include/__format/formatter_integral.h+7-6
...@@ -13,11 +13,12 @@...@@ -13,11 +13,12 @@
13#include <__concepts/arithmetic.h>13#include <__concepts/arithmetic.h>
14#include <__concepts/same_as.h>14#include <__concepts/same_as.h>
15#include <__config>15#include <__config>
16#include <__format/concepts.h>
16#include <__format/format_error.h>17#include <__format/format_error.h>
17#include <__format/formatter.h> // for __char_type TODO FMT Move the concept?
18#include <__format/formatter_output.h>18#include <__format/formatter_output.h>
19#include <__format/parser_std_format_spec.h>19#include <__format/parser_std_format_spec.h>
20#include <__utility/unreachable.h>20#include <__utility/unreachable.h>
21#include <array>
21#include <charconv>22#include <charconv>
22#include <limits>23#include <limits>
23#include <string>24#include <string>
...@@ -112,7 +113,7 @@ _LIBCPP_HIDE_FROM_ABI inline string __determine_grouping(ptrdiff_t __size, const...@@ -112,7 +113,7 @@ _LIBCPP_HIDE_FROM_ABI inline string __determine_grouping(ptrdiff_t __size, const
112// Char113// Char
113//114//
114115
115template <__formatter::__char_type _CharT>116template <__fmt_char_type _CharT>
116_LIBCPP_HIDE_FROM_ABI auto __format_char(117_LIBCPP_HIDE_FROM_ABI auto __format_char(
117 integral auto __value,118 integral auto __value,
118 output_iterator<const _CharT&> auto __out_it,119 output_iterator<const _CharT&> auto __out_it,
...@@ -216,7 +217,7 @@ _LIBCPP_HIDE_FROM_ABI auto __format_integer(...@@ -216,7 +217,7 @@ _LIBCPP_HIDE_FROM_ABI auto __format_integer(
216217
217# ifndef _LIBCPP_HAS_NO_LOCALIZATION218# ifndef _LIBCPP_HAS_NO_LOCALIZATION
218 if (__specs.__std_.__locale_specific_form_) {219 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());
220 string __grouping = __np.grouping();221 string __grouping = __np.grouping();
221 ptrdiff_t __size = __last - __first;222 ptrdiff_t __size = __last - __first;
222 // Writing the grouped form has more overhead than the normal output223 // Writing the grouped form has more overhead than the normal output
...@@ -243,7 +244,7 @@ _LIBCPP_HIDE_FROM_ABI auto __format_integer(...@@ -243,7 +244,7 @@ _LIBCPP_HIDE_FROM_ABI auto __format_integer(
243 // The zero padding is done like:244 // The zero padding is done like:
244 // - Write [sign][prefix]245 // - Write [sign][prefix]
245 // - Write data right aligned with '0' as fill character.246 // - 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));
247 __specs.__alignment_ = __format_spec::__alignment::__right;248 __specs.__alignment_ = __format_spec::__alignment::__right;
248 __specs.__fill_ = _CharT('0');249 __specs.__fill_ = _CharT('0');
249 int32_t __size = __first - __begin;250 int32_t __size = __first - __begin;
...@@ -309,7 +310,7 @@ __format_integer(_Tp __value, auto& __ctx, __format_spec::__parsed_specification...@@ -309,7 +310,7 @@ __format_integer(_Tp __value, auto& __ctx, __format_spec::__parsed_specification
309 auto __r = std::__to_unsigned_like(__value);310 auto __r = std::__to_unsigned_like(__value);
310 bool __negative = __value < 0;311 bool __negative = __value < 0;
311 if (__negative)312 if (__negative)
312 __r = __complement(__r);313 __r = std::__complement(__r);
313314
314 return __formatter::__format_integer(__r, __ctx, __specs, __negative);315 return __formatter::__format_integer(__r, __ctx, __specs, __negative);
315}316}
...@@ -341,7 +342,7 @@ __format_bool(bool __value, auto& __ctx, __format_spec::__parsed_specifications<...@@ -341,7 +342,7 @@ __format_bool(bool __value, auto& __ctx, __format_spec::__parsed_specifications<
341 -> decltype(__ctx.out()) {342 -> decltype(__ctx.out()) {
342# ifndef _LIBCPP_HAS_NO_LOCALIZATION343# ifndef _LIBCPP_HAS_NO_LOCALIZATION
343 if (__specs.__std_.__locale_specific_form_) {344 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());
345 basic_string<_CharT> __str = __value ? __np.truename() : __np.falsename();346 basic_string<_CharT> __str = __value ? __np.truename() : __np.falsename();
346 return __formatter::__write_string_no_precision(basic_string_view<_CharT>{__str}, __ctx.out(), __specs);347 return __formatter::__write_string_no_precision(basic_string_view<_CharT>{__str}, __ctx.out(), __specs);
347 }348 }
lib/libcxx/include/__format/formatter_output.h+308-46
...@@ -10,16 +10,23 @@...@@ -10,16 +10,23 @@
10#ifndef _LIBCPP___FORMAT_FORMATTER_OUTPUT_H10#ifndef _LIBCPP___FORMAT_FORMATTER_OUTPUT_H
11#define _LIBCPP___FORMAT_FORMATTER_OUTPUT_H11#define _LIBCPP___FORMAT_FORMATTER_OUTPUT_H
1212
13#include <__algorithm/copy.h>13#include <__algorithm/ranges_copy.h>
14#include <__algorithm/copy_n.h>14#include <__algorithm/ranges_fill_n.h>
15#include <__algorithm/fill_n.h>15#include <__algorithm/ranges_transform.h>
16#include <__algorithm/transform.h>16#include <__chrono/statically_widen.h>
17#include <__concepts/same_as.h>
17#include <__config>18#include <__config>
19#include <__format/buffer.h>
20#include <__format/concepts.h>
21#include <__format/escaped_output_table.h>
18#include <__format/formatter.h>22#include <__format/formatter.h>
19#include <__format/parser_std_format_spec.h>23#include <__format/parser_std_format_spec.h>
20#include <__format/unicode.h>24#include <__format/unicode.h>
25#include <__iterator/back_insert_iterator.h>
26#include <__type_traits/make_unsigned.h>
21#include <__utility/move.h>27#include <__utility/move.h>
22#include <__utility/unreachable.h>28#include <__utility/unreachable.h>
29#include <charconv>
23#include <cstddef>30#include <cstddef>
24#include <string>31#include <string>
25#include <string_view>32#include <string_view>
...@@ -86,6 +93,74 @@ __padding_size(size_t __size, size_t __width, __format_spec::__alignment __align...@@ -86,6 +93,74 @@ __padding_size(size_t __size, size_t __width, __format_spec::__alignment __align
86 __libcpp_unreachable();93 __libcpp_unreachable();
87}94}
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
89template <class _OutIt, class _CharT>164template <class _OutIt, class _CharT>
90_LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, const char* __begin, const char* __first,165_LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, const char* __begin, const char* __first,
91 const char* __last, string&& __grouping, _CharT __sep,166 const char* __last, string&& __grouping, _CharT __sep,
...@@ -97,22 +172,22 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, c...@@ -97,22 +172,22 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, c
97 __padding_size_result __padding = {0, 0};172 __padding_size_result __padding = {0, 0};
98 if (__specs.__alignment_ == __format_spec::__alignment::__zero_padding) {173 if (__specs.__alignment_ == __format_spec::__alignment::__zero_padding) {
99 // Write [sign][prefix].174 // 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
102 if (__specs.__width_ > __size) {177 if (__specs.__width_ > __size) {
103 // Write zero padding.178 // Write zero padding.
104 __padding.__before_ = __specs.__width_ - __size;179 __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'));
106 }181 }
107 } else {182 } else {
108 if (__specs.__width_ > __size) {183 if (__specs.__width_ > __size) {
109 // Determine padding and write padding.184 // 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_);
113 }188 }
114 // Write [sign][prefix].189 // 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));
116 }191 }
117192
118 auto __r = __grouping.rbegin();193 auto __r = __grouping.rbegin();
...@@ -133,10 +208,10 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, c...@@ -133,10 +208,10 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, c
133 while (true) {208 while (true) {
134 if (__specs.__std_.__type_ == __format_spec::__type::__hexadecimal_upper_case) {209 if (__specs.__std_.__type_ == __format_spec::__type::__hexadecimal_upper_case) {
135 __last = __first + *__r;210 __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);
137 __first = __last;212 __first = __last;
138 } else {213 } else {
139 __out_it = _VSTD::copy_n(__first, *__r, _VSTD::move(__out_it));214 __out_it = __formatter::__copy(__first, *__r, _VSTD::move(__out_it));
140 __first += *__r;215 __first += *__r;
141 }216 }
142217
...@@ -147,7 +222,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, c...@@ -147,7 +222,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, c
147 *__out_it++ = __sep;222 *__out_it++ = __sep;
148 }223 }
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_);
151}226}
152227
153/// Writes the input to the output with the required padding.228/// 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...@@ -155,12 +230,10 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, c
155/// Since the output column width is specified the function can be used for230/// Since the output column width is specified the function can be used for
156/// ASCII and Unicode output.231/// ASCII and Unicode output.
157///232///
158/// \pre [\a __first, \a __last) is a valid range.
159/// \pre \a __size <= \a __width. Using this function when this pre-condition233/// \pre \a __size <= \a __width. Using this function when this pre-condition
160/// doesn't hold incurs an unwanted overhead.234/// doesn't hold incurs an unwanted overhead.
161///235///
162/// \param __first Pointer to the first element to write.236/// \param __str The string to write.
163/// \param __last Pointer beyond the last element to write.
164/// \param __out_it The output iterator to write to.237/// \param __out_it The output iterator to write to.
165/// \param __specs The parsed formatting specifications.238/// \param __specs The parsed formatting specifications.
166/// \param __size The (estimated) output column width. When the elements239/// \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...@@ -174,31 +247,42 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, c
174/// conversion, which means the [\a __first, \a __last) always contains elements247/// conversion, which means the [\a __first, \a __last) always contains elements
175/// of the type \c char.248/// of the type \c char.
176template <class _CharT, class _ParserCharT>249template <class _CharT, class _ParserCharT>
177_LIBCPP_HIDE_FROM_ABI auto __write(250_LIBCPP_HIDE_FROM_ABI auto
178 const _CharT* __first,251__write(basic_string_view<_CharT> __str,
179 const _CharT* __last,252 output_iterator<const _CharT&> auto __out_it,
180 output_iterator<const _CharT&> auto __out_it,253 __format_spec::__parsed_specifications<_ParserCharT> __specs,
181 __format_spec::__parsed_specifications<_ParserCharT> __specs,254 ptrdiff_t __size) -> decltype(__out_it) {
182 ptrdiff_t __size) -> decltype(__out_it) {
183 _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
184
185 if (__size >= __specs.__width_)255 if (__size >= __specs.__width_)
186 return _VSTD::copy(__first, __last, _VSTD::move(__out_it));256 return __formatter::__copy(__str, _VSTD::move(__out_it));
187257
188 __padding_size_result __padding = __formatter::__padding_size(__size, __specs.__width_, __specs.__std_.__alignment_);258 __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_);259 __out_it = __formatter::__fill(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
190 __out_it = _VSTD::copy(__first, __last, _VSTD::move(__out_it));260 __out_it = __formatter::__copy(__str, _VSTD::move(__out_it));
191 return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);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);
192}273}
193274
194/// \overload275/// \overload
195///276///
196/// Calls the function above where \a __size = \a __last - \a __first.277/// Calls the function above where \a __size = \a __last - \a __first.
197template <class _CharT, class _ParserCharT>278template <class _CharT, class _ParserCharT>
198_LIBCPP_HIDE_FROM_ABI auto __write(const _CharT* __first, const _CharT* __last,279_LIBCPP_HIDE_FROM_ABI auto
199 output_iterator<const _CharT&> auto __out_it,280__write(const _CharT* __first,
200 __format_spec::__parsed_specifications<_ParserCharT> __specs) -> decltype(__out_it) {281 const _CharT* __last,
201 return __write(__first, __last, _VSTD::move(__out_it), __specs, __last - __first);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);
202}286}
203287
204template <class _CharT, class _ParserCharT, class _UnaryOperation>288template <class _CharT, class _ParserCharT, class _UnaryOperation>
...@@ -210,12 +294,12 @@ _LIBCPP_HIDE_FROM_ABI auto __write_transformed(const _CharT* __first, const _Cha...@@ -210,12 +294,12 @@ _LIBCPP_HIDE_FROM_ABI auto __write_transformed(const _CharT* __first, const _Cha
210294
211 ptrdiff_t __size = __last - __first;295 ptrdiff_t __size = __last - __first;
212 if (__size >= __specs.__width_)296 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_);299 __padding_size_result __padding = __formatter::__padding_size(__size, __specs.__width_, __specs.__alignment_);
216 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);300 __out_it = __formatter::__fill(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
217 __out_it = _VSTD::transform(__first, __last, _VSTD::move(__out_it), __op);301 __out_it = __formatter::__transform(__first, __last, _VSTD::move(__out_it), __op);
218 return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);302 return __formatter::__fill(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
219}303}
220304
221/// Writes additional zero's for the precision before the exponent.305/// Writes additional zero's for the precision before the exponent.
...@@ -239,12 +323,12 @@ _LIBCPP_HIDE_FROM_ABI auto __write_using_trailing_zeros(...@@ -239,12 +323,12 @@ _LIBCPP_HIDE_FROM_ABI auto __write_using_trailing_zeros(
239 _LIBCPP_ASSERT(__num_trailing_zeros > 0, "The overload not writing trailing zeros should have been used");323 _LIBCPP_ASSERT(__num_trailing_zeros > 0, "The overload not writing trailing zeros should have been used");
240324
241 __padding_size_result __padding =325 __padding_size_result __padding =
242 __padding_size(__size + __num_trailing_zeros, __specs.__width_, __specs.__alignment_);326 __formatter::__padding_size(__size + __num_trailing_zeros, __specs.__width_, __specs.__alignment_);
243 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);327 __out_it = __formatter::__fill(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
244 __out_it = _VSTD::copy(__first, __exponent, _VSTD::move(__out_it));328 __out_it = __formatter::__copy(__first, __exponent, _VSTD::move(__out_it));
245 __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __num_trailing_zeros, _CharT('0'));329 __out_it = __formatter::__fill(_VSTD::move(__out_it), __num_trailing_zeros, _CharT('0'));
246 __out_it = _VSTD::copy(__exponent, __last, _VSTD::move(__out_it));330 __out_it = __formatter::__copy(__exponent, __last, _VSTD::move(__out_it));
247 return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);331 return __formatter::__fill(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
248}332}
249333
250/// Writes a string using format's width estimation algorithm.334/// Writes a string using format's width estimation algorithm.
...@@ -262,7 +346,7 @@ _LIBCPP_HIDE_FROM_ABI auto __write_string_no_precision(...@@ -262,7 +346,7 @@ _LIBCPP_HIDE_FROM_ABI auto __write_string_no_precision(
262346
263 // No padding -> copy the string347 // No padding -> copy the string
264 if (!__specs.__has_width())348 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
267 // Note when the estimated width is larger than size there's no padding. So351 // Note when the estimated width is larger than size there's no padding. So
268 // there's no reason to get the real size when the estimate is larger than or352 // 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(...@@ -270,8 +354,7 @@ _LIBCPP_HIDE_FROM_ABI auto __write_string_no_precision(
270 size_t __size =354 size_t __size =
271 __format_spec::__estimate_column_width(__str, __specs.__width_, __format_spec::__column_width_rounding::__up)355 __format_spec::__estimate_column_width(__str, __specs.__width_, __format_spec::__column_width_rounding::__up)
272 .__width_;356 .__width_;
273357 return __formatter::__write(__str, _VSTD::move(__out_it), __specs, __size);
274 return __formatter::__write(__str.begin(), __str.end(), _VSTD::move(__out_it), __specs, __size);
275}358}
276359
277template <class _CharT>360template <class _CharT>
...@@ -296,9 +379,188 @@ _LIBCPP_HIDE_FROM_ABI auto __write_string(...@@ -296,9 +379,188 @@ _LIBCPP_HIDE_FROM_ABI auto __write_string(
296379
297 int __size = __formatter::__truncate(__str, __specs.__precision_);380 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));
300}496}
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
302} // namespace __formatter564} // namespace __formatter
303565
304#endif //_LIBCPP_STD_VER > 17566#endif //_LIBCPP_STD_VER > 17
lib/libcxx/include/__format/formatter_pointer.h+5-5
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
1212
13#include <__availability>13#include <__availability>
14#include <__config>14#include <__config>
15#include <__format/format_fwd.h>15#include <__format/concepts.h>
16#include <__format/format_parse_context.h>16#include <__format/format_parse_context.h>
17#include <__format/formatter.h>17#include <__format/formatter.h>
18#include <__format/formatter_integral.h>18#include <__format/formatter_integral.h>
...@@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2929
30#if _LIBCPP_STD_VER > 1730#if _LIBCPP_STD_VER > 17
3131
32template <__formatter::__char_type _CharT>32template <__fmt_char_type _CharT>
33struct _LIBCPP_TEMPLATE_VIS __formatter_pointer {33struct _LIBCPP_TEMPLATE_VIS __formatter_pointer {
34public:34public:
35 constexpr __formatter_pointer() { __parser_.__alignment_ = __format_spec::__alignment::__right; }35 constexpr __formatter_pointer() { __parser_.__alignment_ = __format_spec::__alignment::__right; }
...@@ -56,13 +56,13 @@ public:...@@ -56,13 +56,13 @@ public:
56// - struct formatter<nullptr_t, charT>;56// - struct formatter<nullptr_t, charT>;
57// - template<> struct formatter<void*, charT>;57// - template<> struct formatter<void*, charT>;
58// - template<> struct formatter<const void*, charT>;58// - template<> struct formatter<const void*, charT>;
59template <__formatter::__char_type _CharT>59template <__fmt_char_type _CharT>
60struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<nullptr_t, _CharT>60struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<nullptr_t, _CharT>
61 : public __formatter_pointer<_CharT> {};61 : public __formatter_pointer<_CharT> {};
62template <__formatter::__char_type _CharT>62template <__fmt_char_type _CharT>
63struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<void*, _CharT> : public __formatter_pointer<_CharT> {63struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<void*, _CharT> : public __formatter_pointer<_CharT> {
64};64};
65template <__formatter::__char_type _CharT>65template <__fmt_char_type _CharT>
66struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const void*, _CharT>66struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const void*, _CharT>
67 : public __formatter_pointer<_CharT> {};67 : public __formatter_pointer<_CharT> {};
6868
lib/libcxx/include/__format/formatter_string.h+24-10
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
1212
13#include <__availability>13#include <__availability>
14#include <__config>14#include <__config>
15#include <__format/format_fwd.h>15#include <__format/concepts.h>
16#include <__format/format_parse_context.h>16#include <__format/format_parse_context.h>
17#include <__format/formatter.h>17#include <__format/formatter.h>
18#include <__format/formatter_output.h>18#include <__format/formatter_output.h>
...@@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2929
30#if _LIBCPP_STD_VER > 1730#if _LIBCPP_STD_VER > 17
3131
32template <__formatter::__char_type _CharT>32template <__fmt_char_type _CharT>
33struct _LIBCPP_TEMPLATE_VIS __formatter_string {33struct _LIBCPP_TEMPLATE_VIS __formatter_string {
34public:34public:
35 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)35 _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
...@@ -40,14 +40,23 @@ public:...@@ -40,14 +40,23 @@ public:
40 }40 }
4141
42 _LIBCPP_HIDE_FROM_ABI auto format(basic_string_view<_CharT> __str, auto& __ctx) const -> decltype(__ctx.out()) {42 _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
43 return __formatter::__write_string(__str, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx));48 return __formatter::__write_string(__str, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx));
44 }49 }
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};
47};56};
4857
49// Formatter const char*.58// Formatter const char*.
50template <__formatter::__char_type _CharT>59template <__fmt_char_type _CharT>
51struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT*, _CharT>60struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT*, _CharT>
52 : public __formatter_string<_CharT> {61 : public __formatter_string<_CharT> {
53 using _Base = __formatter_string<_CharT>;62 using _Base = __formatter_string<_CharT>;
...@@ -56,6 +65,12 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT*,...@@ -56,6 +65,12 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT*,
56 _LIBCPP_ASSERT(__str, "The basic_format_arg constructor should have "65 _LIBCPP_ASSERT(__str, "The basic_format_arg constructor should have "
57 "prevented an invalid pointer.");66 "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
59 // When using a center or right alignment and the width option the length74 // When using a center or right alignment and the width option the length
60 // of __str must be known to add the padding upfront. This case is handled75 // of __str must be known to add the padding upfront. This case is handled
61 // by the base class by converting the argument to a basic_string_view.76 // 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*,...@@ -67,7 +82,6 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT*,
67 // now these optimizations aren't implemented. Instead the base class82 // now these optimizations aren't implemented. Instead the base class
68 // handles these options.83 // handles these options.
69 // TODO FMT Implement these improvements.84 // TODO FMT Implement these improvements.
70 __format_spec::__parsed_specifications<_CharT> __specs = _Base::__parser_.__get_parsed_std_specifications(__ctx);
71 if (__specs.__has_width() || __specs.__has_precision())85 if (__specs.__has_width() || __specs.__has_precision())
72 return __formatter::__write_string(basic_string_view<_CharT>{__str}, __ctx.out(), __specs);86 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*,...@@ -80,7 +94,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT*,
80};94};
8195
82// Formatter char*.96// Formatter char*.
83template <__formatter::__char_type _CharT>97template <__fmt_char_type _CharT>
84struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT*, _CharT>98struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT*, _CharT>
85 : public formatter<const _CharT*, _CharT> {99 : public formatter<const _CharT*, _CharT> {
86 using _Base = formatter<const _CharT*, _CharT>;100 using _Base = formatter<const _CharT*, _CharT>;
...@@ -91,7 +105,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT*, _Char...@@ -91,7 +105,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT*, _Char
91};105};
92106
93// Formatter char[].107// Formatter char[].
94template <__formatter::__char_type _CharT, size_t _Size>108template <__fmt_char_type _CharT, size_t _Size>
95struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT[_Size], _CharT>109struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT[_Size], _CharT>
96 : public __formatter_string<_CharT> {110 : public __formatter_string<_CharT> {
97 using _Base = __formatter_string<_CharT>;111 using _Base = __formatter_string<_CharT>;
...@@ -102,7 +116,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT[_Size],...@@ -102,7 +116,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT[_Size],
102};116};
103117
104// Formatter const char[].118// Formatter const char[].
105template <__formatter::__char_type _CharT, size_t _Size>119template <__fmt_char_type _CharT, size_t _Size>
106struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT[_Size], _CharT>120struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT[_Size], _CharT>
107 : public __formatter_string<_CharT> {121 : public __formatter_string<_CharT> {
108 using _Base = __formatter_string<_CharT>;122 using _Base = __formatter_string<_CharT>;
...@@ -113,7 +127,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT[_...@@ -113,7 +127,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT[_
113};127};
114128
115// Formatter std::string.129// Formatter std::string.
116template <__formatter::__char_type _CharT, class _Traits, class _Allocator>130template <__fmt_char_type _CharT, class _Traits, class _Allocator>
117struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string<_CharT, _Traits, _Allocator>, _CharT>131struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string<_CharT, _Traits, _Allocator>, _CharT>
118 : public __formatter_string<_CharT> {132 : public __formatter_string<_CharT> {
119 using _Base = __formatter_string<_CharT>;133 using _Base = __formatter_string<_CharT>;
...@@ -126,7 +140,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string<_...@@ -126,7 +140,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string<_
126};140};
127141
128// Formatter std::string_view.142// Formatter std::string_view.
129template <__formatter::__char_type _CharT, class _Traits>143template <__fmt_char_type _CharT, class _Traits>
130struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string_view<_CharT, _Traits>, _CharT>144struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string_view<_CharT, _Traits>, _CharT>
131 : public __formatter_string<_CharT> {145 : public __formatter_string<_CharT> {
132 using _Base = __formatter_string<_CharT>;146 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 @@...@@ -19,6 +19,8 @@
19#include <__algorithm/find_if.h>19#include <__algorithm/find_if.h>
20#include <__algorithm/min.h>20#include <__algorithm/min.h>
21#include <__assert>21#include <__assert>
22#include <__concepts/arithmetic.h>
23#include <__concepts/same_as.h>
22#include <__config>24#include <__config>
23#include <__debug>25#include <__debug>
24#include <__format/format_arg.h>26#include <__format/format_arg.h>
...@@ -28,7 +30,6 @@...@@ -28,7 +30,6 @@
28#include <__format/unicode.h>30#include <__format/unicode.h>
29#include <__variant/monostate.h>31#include <__variant/monostate.h>
30#include <bit>32#include <bit>
31#include <concepts>
32#include <cstdint>33#include <cstdint>
33#include <string_view>34#include <string_view>
34#include <type_traits>35#include <type_traits>
...@@ -52,13 +53,12 @@ __parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {...@@ -52,13 +53,12 @@ __parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
52 // This function is a wrapper to call the real parser. But it does the53 // This function is a wrapper to call the real parser. But it does the
53 // validation for the pre-conditions and post-conditions.54 // validation for the pre-conditions and post-conditions.
54 if (__begin == __end)55 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_number_result __r = __format::__parse_arg_id(__begin, __end, __parse_ctx);
58 __format::__parse_arg_id(__begin, __end, __parse_ctx);
5959
60 if (__r.__ptr == __end || *__r.__ptr != _CharT('}'))60 if (__r.__ptr == __end || *__r.__ptr != _CharT('}'))
61 __throw_format_error("Invalid arg-id");61 std::__throw_format_error("Invalid arg-id");
6262
63 ++__r.__ptr;63 ++__r.__ptr;
64 return __r;64 return __r;
...@@ -67,28 +67,33 @@ __parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {...@@ -67,28 +67,33 @@ __parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
67template <class _Context>67template <class _Context>
68_LIBCPP_HIDE_FROM_ABI constexpr uint32_t68_LIBCPP_HIDE_FROM_ABI constexpr uint32_t
69__substitute_arg_id(basic_format_arg<_Context> __format_arg) {69__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(
71 [](auto __arg) -> uint32_t {79 [](auto __arg) -> uint32_t {
72 using _Type = decltype(__arg);80 using _Type = decltype(__arg);
73 if constexpr (integral<_Type>) {81 if constexpr (integral<_Type>) {
74 if constexpr (signed_integral<_Type>) {82 if constexpr (signed_integral<_Type>) {
75 if (__arg < 0)83 if (__arg < 0)
76 __throw_format_error("A format-spec arg-id replacement shouldn't "84 std::__throw_format_error("A format-spec arg-id replacement shouldn't have a negative value");
77 "have a negative value");
78 }85 }
7986
80 using _CT = common_type_t<_Type, decltype(__format::__number_max)>;87 using _CT = common_type_t<_Type, decltype(__format::__number_max)>;
81 if (static_cast<_CT>(__arg) >88 if (static_cast<_CT>(__arg) >
82 static_cast<_CT>(__format::__number_max))89 static_cast<_CT>(__format::__number_max))
83 __throw_format_error("A format-spec arg-id replacement exceeds "90 std::__throw_format_error("A format-spec arg-id replacement exceeds the maximum supported value");
84 "the maximum supported value");
8591
86 return __arg;92 return __arg;
87 } else if constexpr (same_as<_Type, monostate>)93 } 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");
89 else95 else
90 __throw_format_error("A format-spec arg-id replacement argument "96 std::__throw_format_error("A format-spec arg-id replacement argument isn't an integral type");
91 "isn't an integral type");
92 },97 },
93 __format_arg);98 __format_arg);
94}99}
...@@ -97,6 +102,7 @@ __substitute_arg_id(basic_format_arg<_Context> __format_arg) {...@@ -97,6 +102,7 @@ __substitute_arg_id(basic_format_arg<_Context> __format_arg) {
97///102///
98/// They default to false so when a new field is added it needs to be opted in103/// They default to false so when a new field is added it needs to be opted in
99/// explicitly.104/// explicitly.
105// TODO FMT Use an ABI tag for this struct.
100struct __fields {106struct __fields {
101 uint8_t __sign_ : 1 {false};107 uint8_t __sign_ : 1 {false};
102 uint8_t __alternate_form_ : 1 {false};108 uint8_t __alternate_form_ : 1 {false};
...@@ -104,6 +110,13 @@ struct __fields {...@@ -104,6 +110,13 @@ struct __fields {
104 uint8_t __precision_ : 1 {false};110 uint8_t __precision_ : 1 {false};
105 uint8_t __locale_specific_form_ : 1 {false};111 uint8_t __locale_specific_form_ : 1 {false};
106 uint8_t __type_ : 1 {false};112 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};
107};120};
108121
109// By not placing this constant in the formatter class it's not duplicated for122// By not placing this constant in the formatter class it's not duplicated for
...@@ -124,6 +137,11 @@ inline constexpr __fields __fields_floating_point{...@@ -124,6 +137,11 @@ inline constexpr __fields __fields_floating_point{
124inline constexpr __fields __fields_string{.__precision_ = true, .__type_ = true};137inline constexpr __fields __fields_string{.__precision_ = true, .__type_ = true};
125inline constexpr __fields __fields_pointer{.__type_ = true};138inline 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
127enum class _LIBCPP_ENUM_VIS __alignment : uint8_t {145enum class _LIBCPP_ENUM_VIS __alignment : uint8_t {
128 /// No alignment is set in the format string.146 /// No alignment is set in the format string.
129 __default,147 __default,
...@@ -163,7 +181,8 @@ enum class _LIBCPP_ENUM_VIS __type : uint8_t {...@@ -163,7 +181,8 @@ enum class _LIBCPP_ENUM_VIS __type : uint8_t {
163 __fixed_lower_case,181 __fixed_lower_case,
164 __fixed_upper_case,182 __fixed_upper_case,
165 __general_lower_case,183 __general_lower_case,
166 __general_upper_case184 __general_upper_case,
185 __debug
167};186};
168187
169struct __std {188struct __std {
...@@ -176,7 +195,11 @@ struct __std {...@@ -176,7 +195,11 @@ struct __std {
176195
177struct __chrono {196struct __chrono {
178 __alignment __alignment_ : 3;197 __alignment __alignment_ : 3;
198 bool __locale_specific_form_ : 1;
179 bool __weekday_name_ : 1;199 bool __weekday_name_ : 1;
200 bool __weekday_ : 1;
201 bool __day_of_year_ : 1;
202 bool __week_of_year_ : 1;
180 bool __month_name_ : 1;203 bool __month_name_ : 1;
181};204};
182205
...@@ -250,7 +273,7 @@ public:...@@ -250,7 +273,7 @@ public:
250 if (__begin == __end)273 if (__begin == __end)
251 return __begin;274 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)
254 return __begin;277 return __begin;
255278
256 if (__fields.__sign_ && __parse_sign(__begin) && __begin == __end)279 if (__fields.__sign_ && __parse_sign(__begin) && __begin == __end)
...@@ -278,7 +301,7 @@ public:...@@ -278,7 +301,7 @@ public:
278 // parsing. In that case that parser should do the end of format string301 // parsing. In that case that parser should do the end of format string
279 // validation.302 // validation.
280 if (__begin != __end && *__begin != _CharT('}'))303 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 '}'");
282 }305 }
283306
284 return __begin;307 return __begin;
...@@ -288,12 +311,26 @@ public:...@@ -288,12 +311,26 @@ public:
288 _LIBCPP_HIDE_FROM_ABI311 _LIBCPP_HIDE_FROM_ABI
289 __parsed_specifications<_CharT> __get_parsed_std_specifications(auto& __ctx) const {312 __parsed_specifications<_CharT> __get_parsed_std_specifications(auto& __ctx) const {
290 return __parsed_specifications<_CharT>{313 return __parsed_specifications<_CharT>{
291 .__std_ =314 .__std_ = __std{.__alignment_ = __alignment_,
292 __std{.__alignment_ = __alignment_,315 .__sign_ = __sign_,
293 .__sign_ = __sign_,316 .__alternate_form_ = __alternate_form_,
294 .__alternate_form_ = __alternate_form_,317 .__locale_specific_form_ = __locale_specific_form_,
295 .__locale_specific_form_ = __locale_specific_form_,318 .__type_ = __type_},
296 .__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_},
297 .__width_{__get_width(__ctx)},334 .__width_{__get_width(__ctx)},
298 .__precision_{__get_precision(__ctx)},335 .__precision_{__get_precision(__ctx)},
299 .__fill_{__fill_}};336 .__fill_{__fill_}};
...@@ -306,12 +343,17 @@ public:...@@ -306,12 +343,17 @@ public:
306 bool __reserved_0_ : 1 {false};343 bool __reserved_0_ : 1 {false};
307 __type __type_{__type::__default};344 __type __type_{__type::__default};
308345
309 // These two flags are used for formatting chrono. Since the struct has346 // These flags are only used for formatting chrono. Since the struct has
310 // padding space left it's added to this structure.347 // padding space left it's added to this structure.
311 bool __weekday_name_ : 1 {false};348 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
312 bool __month_name_ : 1 {false};354 bool __month_name_ : 1 {false};
313355
314 uint8_t __reserved_1_ : 6 {0};356 uint8_t __reserved_1_ : 3 {0};
315 uint8_t __reserved_2_ : 6 {0};357 uint8_t __reserved_2_ : 6 {0};
316 // These two flags are only used internally and not part of the358 // These two flags are only used internally and not part of the
317 // __parsed_specifications. Therefore put them at the end.359 // __parsed_specifications. Therefore put them at the end.
...@@ -348,13 +390,17 @@ private:...@@ -348,13 +390,17 @@ private:
348 return false;390 return false;
349 }391 }
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) {
352 _LIBCPP_ASSERT(__begin != __end, "when called with an empty input the function will cause "396 _LIBCPP_ASSERT(__begin != __end, "when called with an empty input the function will cause "
353 "undefined behavior by evaluating data not in the input");397 "undefined behavior by evaluating data not in the input");
354 if (__begin + 1 != __end) {398 if (__begin + 1 != __end) {
355 if (__parse_alignment(*(__begin + 1))) {399 if (__parse_alignment(*(__begin + 1))) {
356 if (*__begin == _CharT('{') || *__begin == _CharT('}'))400 if (__use_range_fill && (*__begin == _CharT('{') || *__begin == _CharT('}') || *__begin == _CharT(':')))
357 __throw_format_error("The format-spec fill field contains an invalid character");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
359 __fill_ = *__begin;405 __fill_ = *__begin;
360 __begin += 2;406 __begin += 2;
...@@ -408,7 +454,7 @@ private:...@@ -408,7 +454,7 @@ private:
408454
409 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_width(const _CharT*& __begin, const _CharT* __end, auto& __parse_ctx) {455 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_width(const _CharT*& __begin, const _CharT* __end, auto& __parse_ctx) {
410 if (*__begin == _CharT('0'))456 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
413 if (*__begin == _CharT('{')) {459 if (*__begin == _CharT('{')) {
414 __format::__parse_number_result __r = __format_spec::__parse_arg_id(++__begin, __end, __parse_ctx);460 __format::__parse_number_result __r = __format_spec::__parse_arg_id(++__begin, __end, __parse_ctx);
...@@ -436,7 +482,7 @@ private:...@@ -436,7 +482,7 @@ private:
436482
437 ++__begin;483 ++__begin;
438 if (__begin == __end)484 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
441 if (*__begin == _CharT('{')) {487 if (*__begin == _CharT('{')) {
442 __format::__parse_number_result __arg_id = __format_spec::__parse_arg_id(++__begin, __end, __parse_ctx);488 __format::__parse_number_result __arg_id = __format_spec::__parse_arg_id(++__begin, __end, __parse_ctx);
...@@ -447,7 +493,7 @@ private:...@@ -447,7 +493,7 @@ private:
447 }493 }
448494
449 if (*__begin < _CharT('0') || *__begin > _CharT('9'))495 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
452 __format::__parse_number_result __r = __format::__parse_number(__begin, __end);498 __format::__parse_number_result __r = __format::__parse_number(__begin, __end);
453 __precision_ = __r.__value;499 __precision_ = __r.__value;
...@@ -523,6 +569,11 @@ private:...@@ -523,6 +569,11 @@ private:
523 case 'x':569 case 'x':
524 __type_ = __type::__hexadecimal_lower_case;570 __type_ = __type::__hexadecimal_lower_case;
525 break;571 break;
572# if _LIBCPP_STD_VER > 20
573 case '?':
574 __type_ = __type::__debug;
575 break;
576# endif
526 default:577 default:
527 return;578 return;
528 }579 }
...@@ -534,10 +585,7 @@ private:...@@ -534,10 +585,7 @@ private:
534 if (!__width_as_arg_)585 if (!__width_as_arg_)
535 return __width_;586 return __width_;
536587
537 int32_t __result = __format_spec::__substitute_arg_id(__ctx.arg(__width_));588 return __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;
541 }589 }
542590
543 _LIBCPP_HIDE_FROM_ABI591 _LIBCPP_HIDE_FROM_ABI
...@@ -559,6 +607,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_string(__format_spec...@@ -559,6 +607,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_string(__format_spec
559 switch (__type) {607 switch (__type) {
560 case __format_spec::__type::__default:608 case __format_spec::__type::__default:
561 case __format_spec::__type::__string:609 case __format_spec::__type::__string:
610 case __format_spec::__type::__debug:
562 break;611 break;
563612
564 default:613 default:
...@@ -612,6 +661,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_char(__parser<_CharT>& __p...@@ -612,6 +661,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_char(__parser<_CharT>& __p
612 switch (__parser.__type_) {661 switch (__parser.__type_) {
613 case __format_spec::__type::__default:662 case __format_spec::__type::__default:
614 case __format_spec::__type::__char:663 case __format_spec::__type::__char:
664 case __format_spec::__type::__debug:
615 __format_spec::__process_display_type_char(__parser);665 __format_spec::__process_display_type_char(__parser);
616 break;666 break;
617667
...@@ -653,11 +703,6 @@ template <class _CharT>...@@ -653,11 +703,6 @@ template <class _CharT>
653_LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_floating_point(__parser<_CharT>& __parser) {703_LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_floating_point(__parser<_CharT>& __parser) {
654 switch (__parser.__type_) {704 switch (__parser.__type_) {
655 case __format_spec::__type::__default:705 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;
661 case __format_spec::__type::__hexfloat_lower_case:706 case __format_spec::__type::__hexfloat_lower_case:
662 case __format_spec::__type::__hexfloat_upper_case:707 case __format_spec::__type::__hexfloat_upper_case:
663 // Precision specific behavior will be handled later.708 // Precision specific behavior will be handled later.
...@@ -699,6 +744,9 @@ struct __column_width_result {...@@ -699,6 +744,9 @@ struct __column_width_result {
699 const _CharT* __last_;744 const _CharT* __last_;
700};745};
701746
747template <class _CharT>
748__column_width_result(size_t, const _CharT*) -> __column_width_result<_CharT>;
749
702/// Since a column width can be two it's possible that the requested column750/// Since a column width can be two it's possible that the requested column
703/// width can't be achieved. Depending on the intended usage the policy can be751/// width can't be achieved. Depending on the intended usage the policy can be
704/// selected.752/// selected.
...@@ -857,7 +905,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> __estimate_column_...@@ -857,7 +905,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> __estimate_column_
857 // unit is non-ASCII we omit the current code unit and let the Grapheme905 // unit is non-ASCII we omit the current code unit and let the Grapheme
858 // clustering algorithm do its work.906 // clustering algorithm do its work.
859 const _CharT* __it = __str.begin();907 const _CharT* __it = __str.begin();
860 if (__is_ascii(*__it)) {908 if (__format_spec::__is_ascii(*__it)) {
861 do {909 do {
862 --__maximum;910 --__maximum;
863 ++__it;911 ++__it;
...@@ -865,12 +913,12 @@ _LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> __estimate_column_...@@ -865,12 +913,12 @@ _LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> __estimate_column_
865 return {__str.size(), __str.end()};913 return {__str.size(), __str.end()};
866914
867 if (__maximum == 0) {915 if (__maximum == 0) {
868 if (__is_ascii(*__it))916 if (__format_spec::__is_ascii(*__it))
869 return {static_cast<size_t>(__it - __str.begin()), __it};917 return {static_cast<size_t>(__it - __str.begin()), __it};
870918
871 break;919 break;
872 }920 }
873 } while (__is_ascii(*__it));921 } while (__format_spec::__is_ascii(*__it));
874 --__it;922 --__it;
875 ++__maximum;923 ++__maximum;
876 }924 }
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 @@...@@ -13,6 +13,7 @@
13#include <__assert>13#include <__assert>
14#include <__config>14#include <__config>
15#include <__format/extended_grapheme_cluster_table.h>15#include <__format/extended_grapheme_cluster_table.h>
16#include <__type_traits/make_unsigned.h>
16#include <__utility/unreachable.h>17#include <__utility/unreachable.h>
17#include <bit>18#include <bit>
1819
...@@ -24,6 +25,26 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -24,6 +25,26 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2425
25#if _LIBCPP_STD_VER > 1726#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
27# ifndef _LIBCPP_HAS_NO_UNICODE48# ifndef _LIBCPP_HAS_NO_UNICODE
2849
29/// Implements the grapheme cluster boundary rules50/// Implements the grapheme cluster boundary rules
...@@ -39,8 +60,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -39,8 +60,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
39/// https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt60/// https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt
40/// https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt (for testing only)61/// https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt (for testing only)
4162
42namespace __unicode {
43
44inline constexpr char32_t __replacement_character = U'\ufffd';63inline constexpr char32_t __replacement_character = U'\ufffd';
4564
46_LIBCPP_HIDE_FROM_ABI constexpr bool __is_continuation(const char* __char, int __count) {65_LIBCPP_HIDE_FROM_ABI constexpr bool __is_continuation(const char* __char, int __count) {
...@@ -123,18 +142,92 @@ public:...@@ -123,18 +142,92 @@ public:
123 return __replacement_character;142 return __replacement_character;
124 }143 }
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
126private:209private:
127 const char* __first_;210 const char* __first_;
128 const char* __last_;211 const char* __last_;
129};212};
130213
131# ifndef TEST_HAS_NO_WIDE_CHARACTERS214# 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
132/// This specialization depends on the size of wchar_t223/// This specialization depends on the size of wchar_t
133/// - 2 UTF-16 (for example Windows and AIX)224/// - 2 UTF-16 (for example Windows and AIX)
134/// - 4 UTF-32 (for example Linux)225/// - 4 UTF-32 (for example Linux)
135template <>226template <>
136class __code_point_view<wchar_t> {227class __code_point_view<wchar_t> {
137public:228public:
229 static_assert(sizeof(wchar_t) == 2 || sizeof(wchar_t) == 4, "sizeof(wchar_t) has a not implemented value");
230
138 _LIBCPP_HIDE_FROM_ABI constexpr explicit __code_point_view(const wchar_t* __first, const wchar_t* __last)231 _LIBCPP_HIDE_FROM_ABI constexpr explicit __code_point_view(const wchar_t* __first, const wchar_t* __last)
139 : __first_(__first), __last_(__last) {}232 : __first_(__first), __last_(__last) {}
140233
...@@ -166,17 +259,43 @@ public:...@@ -166,17 +259,43 @@ public:
166 return __replacement_character;259 return __replacement_character;
167 return __result;260 return __result;
168 } else {261 } 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");
171 __libcpp_unreachable();262 __libcpp_unreachable();
172 }263 }
173 }264 }
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
175private:294private:
176 const wchar_t* __first_;295 const wchar_t* __first_;
177 const wchar_t* __last_;296 const wchar_t* __last_;
178};297};
179# endif298# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
180299
181_LIBCPP_HIDE_FROM_ABI constexpr bool __at_extended_grapheme_cluster_break(300_LIBCPP_HIDE_FROM_ABI constexpr bool __at_extended_grapheme_cluster_break(
182 bool& __ri_break_allowed,301 bool& __ri_break_allowed,
...@@ -251,10 +370,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __at_extended_grapheme_cluster_break(...@@ -251,10 +370,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __at_extended_grapheme_cluster_break(
251370
252 if (__prev == __property::__Regional_Indicator && __next == __property::__Regional_Indicator) { // GB12 + GB13371 if (__prev == __property::__Regional_Indicator && __next == __property::__Regional_Indicator) { // GB12 + GB13
253 __ri_break_allowed = !__ri_break_allowed;372 __ri_break_allowed = !__ri_break_allowed;
254 if (__ri_break_allowed)373 return __ri_break_allowed;
255 return true;
256
257 return false;
258 }374 }
259375
260 // *** Otherwise, break everywhere. ***376 // *** Otherwise, break everywhere. ***
...@@ -328,10 +444,44 @@ private:...@@ -328,10 +444,44 @@ private:
328 }444 }
329};445};
330446
331} // namespace __unicode447template <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
333# endif // _LIBCPP_HAS_NO_UNICODE481# endif // _LIBCPP_HAS_NO_UNICODE
334482
483} // namespace __unicode
484
335#endif //_LIBCPP_STD_VER > 17485#endif //_LIBCPP_STD_VER > 17
336486
337_LIBCPP_END_NAMESPACE_STD487_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...@@ -29,17 +29,17 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 binary_negate
29{29{
30 _Predicate __pred_;30 _Predicate __pred_;
31public:31public:
32 _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX1132 _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_SINCE_CXX14
33 binary_negate(const _Predicate& __pred) : __pred_(__pred) {}33 binary_negate(const _Predicate& __pred) : __pred_(__pred) {}
3434
35 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY35 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
36 bool operator()(const typename _Predicate::first_argument_type& __x,36 bool operator()(const typename _Predicate::first_argument_type& __x,
37 const typename _Predicate::second_argument_type& __y) const37 const typename _Predicate::second_argument_type& __y) const
38 {return !__pred_(__x, __y);}38 {return !__pred_(__x, __y);}
39};39};
4040
41template <class _Predicate>41template <class _Predicate>
42_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY42_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
43binary_negate<_Predicate>43binary_negate<_Predicate>
44not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);}44not2(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...@@ -25,9 +25,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2525
26template<class _Tp>26template<class _Tp>
27struct is_bind_expression : _If<27struct is_bind_expression : _If<
28 _IsSame<_Tp, __uncvref_t<_Tp> >::value,28 _IsSame<_Tp, __remove_cvref_t<_Tp> >::value,
29 false_type,29 false_type,
30 is_bind_expression<__uncvref_t<_Tp> >30 is_bind_expression<__remove_cvref_t<_Tp> >
31> {};31> {};
3232
33#if _LIBCPP_STD_VER > 1433#if _LIBCPP_STD_VER > 14
...@@ -37,9 +37,9 @@ inline constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value;...@@ -37,9 +37,9 @@ inline constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value;
3737
38template<class _Tp>38template<class _Tp>
39struct is_placeholder : _If<39struct is_placeholder : _If<
40 _IsSame<_Tp, __uncvref_t<_Tp> >::value,40 _IsSame<_Tp, __remove_cvref_t<_Tp> >::value,
41 integral_constant<int, 0>,41 integral_constant<int, 0>,
42 is_placeholder<__uncvref_t<_Tp> >42 is_placeholder<__remove_cvref_t<_Tp> >
43> {};43> {};
4444
45#if _LIBCPP_STD_VER > 1445#if _LIBCPP_STD_VER > 14
...@@ -279,16 +279,16 @@ public:...@@ -279,16 +279,16 @@ public:
279 class = typename enable_if279 class = typename enable_if
280 <280 <
281 is_constructible<_Fd, _Gp>::value &&281 is_constructible<_Fd, _Gp>::value &&
282 !is_same<typename remove_reference<_Gp>::type,282 !is_same<__libcpp_remove_reference_t<_Gp>,
283 __bind>::value283 __bind>::value
284 >::type>284 >::type>
285 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17285 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
286 explicit __bind(_Gp&& __f, _BA&& ...__bound_args)286 explicit __bind(_Gp&& __f, _BA&& ...__bound_args)
287 : __f_(_VSTD::forward<_Gp>(__f)),287 : __f_(_VSTD::forward<_Gp>(__f)),
288 __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {}288 __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {}
289289
290 template <class ..._Args>290 template <class ..._Args>
291 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17291 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
292 typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type292 typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type
293 operator()(_Args&& ...__args)293 operator()(_Args&& ...__args)
294 {294 {
...@@ -297,7 +297,7 @@ public:...@@ -297,7 +297,7 @@ public:
297 }297 }
298298
299 template <class ..._Args>299 template <class ..._Args>
300 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17300 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
301 typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type301 typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
302 operator()(_Args&& ...__args) const302 operator()(_Args&& ...__args) const
303 {303 {
...@@ -324,16 +324,16 @@ public:...@@ -324,16 +324,16 @@ public:
324 class = typename enable_if324 class = typename enable_if
325 <325 <
326 is_constructible<_Fd, _Gp>::value &&326 is_constructible<_Fd, _Gp>::value &&
327 !is_same<typename remove_reference<_Gp>::type,327 !is_same<__libcpp_remove_reference_t<_Gp>,
328 __bind_r>::value328 __bind_r>::value
329 >::type>329 >::type>
330 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17330 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
331 explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args)331 explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args)
332 : base(_VSTD::forward<_Gp>(__f),332 : base(_VSTD::forward<_Gp>(__f),
333 _VSTD::forward<_BA>(__bound_args)...) {}333 _VSTD::forward<_BA>(__bound_args)...) {}
334334
335 template <class ..._Args>335 template <class ..._Args>
336 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17336 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
337 typename enable_if337 typename enable_if
338 <338 <
339 is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type,339 is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type,
...@@ -347,7 +347,7 @@ public:...@@ -347,7 +347,7 @@ public:
347 }347 }
348348
349 template <class ..._Args>349 template <class ..._Args>
350 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17350 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
351 typename enable_if351 typename enable_if
352 <352 <
353 is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,353 is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,
...@@ -365,7 +365,7 @@ template<class _Rp, class _Fp, class ..._BoundArgs>...@@ -365,7 +365,7 @@ template<class _Rp, class _Fp, class ..._BoundArgs>
365struct is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {};365struct is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {};
366366
367template<class _Fp, class ..._BoundArgs>367template<class _Fp, class ..._BoundArgs>
368inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17368inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
369__bind<_Fp, _BoundArgs...>369__bind<_Fp, _BoundArgs...>
370bind(_Fp&& __f, _BoundArgs&&... __bound_args)370bind(_Fp&& __f, _BoundArgs&&... __bound_args)
371{371{
...@@ -374,7 +374,7 @@ bind(_Fp&& __f, _BoundArgs&&... __bound_args)...@@ -374,7 +374,7 @@ bind(_Fp&& __f, _BoundArgs&&... __bound_args)
374}374}
375375
376template<class _Rp, class _Fp, class ..._BoundArgs>376template<class _Rp, class _Fp, class ..._BoundArgs>
377inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17377inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
378__bind_r<_Rp, _Fp, _BoundArgs...>378__bind_r<_Rp, _Fp, _BoundArgs...>
379bind(_Fp&& __f, _BoundArgs&&... __bound_args)379bind(_Fp&& __f, _BoundArgs&&... __bound_args)
380{380{
lib/libcxx/include/__functional/boyer_moore_searcher.h+2
...@@ -223,6 +223,7 @@ private:...@@ -223,6 +223,7 @@ private:
223 }223 }
224 }224 }
225};225};
226_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(boyer_moore_searcher);
226227
227template <class _RandomAccessIterator1,228template <class _RandomAccessIterator1,
228 class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,229 class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
...@@ -303,6 +304,7 @@ private:...@@ -303,6 +304,7 @@ private:
303 return std::make_pair(__l, __l);304 return std::make_pair(__l, __l);
304 }305 }
305};306};
307_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(boyer_moore_horspool_searcher);
306308
307_LIBCPP_END_NAMESPACE_STD309_LIBCPP_END_NAMESPACE_STD
308310
lib/libcxx/include/__functional/default_searcher.h+3-2
...@@ -29,13 +29,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -29,13 +29,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD
29template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>29template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
30class _LIBCPP_TEMPLATE_VIS default_searcher {30class _LIBCPP_TEMPLATE_VIS default_searcher {
31public:31public:
32 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1732 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
33 default_searcher(_ForwardIterator __f, _ForwardIterator __l,33 default_searcher(_ForwardIterator __f, _ForwardIterator __l,
34 _BinaryPredicate __p = _BinaryPredicate())34 _BinaryPredicate __p = _BinaryPredicate())
35 : __first_(__f), __last_(__l), __pred_(__p) {}35 : __first_(__f), __last_(__l), __pred_(__p) {}
3636
37 template <typename _ForwardIterator2>37 template <typename _ForwardIterator2>
38 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1738 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
39 pair<_ForwardIterator2, _ForwardIterator2>39 pair<_ForwardIterator2, _ForwardIterator2>
40 operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const40 operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const
41 {41 {
...@@ -48,6 +48,7 @@ private:...@@ -48,6 +48,7 @@ private:
48 _ForwardIterator __last_;48 _ForwardIterator __last_;
49 _BinaryPredicate __pred_;49 _BinaryPredicate __pred_;
50};50};
51_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(default_searcher);
5152
52#endif // _LIBCPP_STD_VER > 1453#endif // _LIBCPP_STD_VER > 14
5354
lib/libcxx/include/__functional/function.h+29-1636
...@@ -17,20 +17,29 @@...@@ -17,20 +17,29 @@
17#include <__functional/unary_function.h>17#include <__functional/unary_function.h>
18#include <__iterator/iterator_traits.h>18#include <__iterator/iterator_traits.h>
19#include <__memory/addressof.h>19#include <__memory/addressof.h>
20#include <__memory/allocator.h>
21#include <__memory/allocator_destructor.h>
20#include <__memory/allocator_traits.h>22#include <__memory/allocator_traits.h>
23#include <__memory/builtin_new_allocator.h>
21#include <__memory/compressed_pair.h>24#include <__memory/compressed_pair.h>
22#include <__memory/shared_ptr.h>25#include <__memory/unique_ptr.h>
26#include <__type_traits/strip_signature.h>
23#include <__utility/forward.h>27#include <__utility/forward.h>
24#include <__utility/move.h>28#include <__utility/move.h>
29#include <__utility/piecewise_construct.h>
25#include <__utility/swap.h>30#include <__utility/swap.h>
26#include <exception>31#include <exception>
27#include <memory> // TODO: replace with <__memory/__builtin_new_allocator.h>32#include <new>
33#include <tuple>
28#include <type_traits>34#include <type_traits>
35#include <typeinfo>
2936
30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)37#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
31# pragma GCC system_header38# pragma GCC system_header
32#endif39#endif
3340
41#ifndef _LIBCPP_CXX03_LANG
42
34_LIBCPP_BEGIN_NAMESPACE_STD43_LIBCPP_BEGIN_NAMESPACE_STD
3544
36// bad_function_call45// bad_function_call
...@@ -45,13 +54,13 @@ public:...@@ -45,13 +54,13 @@ public:
45// bad_function_call will end up containing a weak definition of the vtable and54// bad_function_call will end up containing a weak definition of the vtable and
46// typeinfo.55// typeinfo.
47#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION56#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
48 virtual ~bad_function_call() _NOEXCEPT;57 ~bad_function_call() _NOEXCEPT override;
49#else58#else
50 virtual ~bad_function_call() _NOEXCEPT {}59 ~bad_function_call() _NOEXCEPT override {}
51#endif60#endif
5261
53#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE62#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
54 virtual const char* what() const _NOEXCEPT;63 const char* what() const _NOEXCEPT override;
55#endif64#endif
56};65};
57_LIBCPP_DIAGNOSTIC_POP66_LIBCPP_DIAGNOSTIC_POP
...@@ -66,14 +75,7 @@ void __throw_bad_function_call()...@@ -66,14 +75,7 @@ void __throw_bad_function_call()
66#endif75#endif
67}76}
6877
69#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) && __has_attribute(deprecated)78template<class _Fp> class _LIBCPP_TEMPLATE_VIS function; // undefined
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
7779
78namespace __function80namespace __function
79{81{
...@@ -124,8 +126,6 @@ bool __not_null(_Rp (^__p)(_Args...)) { return __p; }...@@ -124,8 +126,6 @@ bool __not_null(_Rp (^__p)(_Args...)) { return __p; }
124126
125} // namespace __function127} // namespace __function
126128
127#ifndef _LIBCPP_CXX03_LANG
128
129namespace __function {129namespace __function {
130130
131// __alloc_func holds a functor and an allocator.131// __alloc_func holds a functor and an allocator.
...@@ -190,9 +190,7 @@ class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)>...@@ -190,9 +190,7 @@ class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)>
190 __alloc_func* __clone() const190 __alloc_func* __clone() const
191 {191 {
192 typedef allocator_traits<_Alloc> __alloc_traits;192 typedef allocator_traits<_Alloc> __alloc_traits;
193 typedef193 typedef __rebind_alloc<__alloc_traits, __alloc_func> _AA;
194 typename __rebind_alloc_helper<__alloc_traits, __alloc_func>::type
195 _AA;
196 _AA __a(__f_.second());194 _AA __a(__f_.second());
197 typedef __allocator_destructor<_AA> _Dp;195 typedef __allocator_destructor<_AA> _Dp;
198 unique_ptr<__alloc_func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));196 unique_ptr<__alloc_func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
...@@ -205,8 +203,7 @@ class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)>...@@ -205,8 +203,7 @@ class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)>
205203
206 static void __destroy_and_delete(__alloc_func* __f) {204 static void __destroy_and_delete(__alloc_func* __f) {
207 typedef allocator_traits<_Alloc> __alloc_traits;205 typedef allocator_traits<_Alloc> __alloc_traits;
208 typedef typename __rebind_alloc_helper<__alloc_traits, __alloc_func>::type206 typedef __rebind_alloc<__alloc_traits, __alloc_func> _FunAlloc;
209 _FunAlloc;
210 _FunAlloc __a(__f->__get_allocator());207 _FunAlloc __a(__f->__get_allocator());
211 __f->destroy();208 __f->destroy();
212 __a.deallocate(__f, 1);209 __a.deallocate(__f, 1);
...@@ -265,7 +262,7 @@ class __base<_Rp(_ArgTypes...)>...@@ -265,7 +262,7 @@ class __base<_Rp(_ArgTypes...)>
265 __base& operator=(const __base&);262 __base& operator=(const __base&);
266public:263public:
267 _LIBCPP_INLINE_VISIBILITY __base() {}264 _LIBCPP_INLINE_VISIBILITY __base() {}
268 _LIBCPP_INLINE_VISIBILITY virtual ~__base() {}265 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual ~__base() {}
269 virtual __base* __clone() const = 0;266 virtual __base* __clone() const = 0;
270 virtual void __clone(__base*) const = 0;267 virtual void __clone(__base*) const = 0;
271 virtual void destroy() _NOEXCEPT = 0;268 virtual void destroy() _NOEXCEPT = 0;
...@@ -319,7 +316,7 @@ __base<_Rp(_ArgTypes...)>*...@@ -319,7 +316,7 @@ __base<_Rp(_ArgTypes...)>*
319__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const316__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const
320{317{
321 typedef allocator_traits<_Alloc> __alloc_traits;318 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;
323 _Ap __a(__f_.__get_allocator());320 _Ap __a(__f_.__get_allocator());
324 typedef __allocator_destructor<_Ap> _Dp;321 typedef __allocator_destructor<_Ap> _Dp;
325 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));322 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
...@@ -346,7 +343,7 @@ void...@@ -346,7 +343,7 @@ void
346__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT343__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT
347{344{
348 typedef allocator_traits<_Alloc> __alloc_traits;345 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;
350 _Ap __a(__f_.__get_allocator());347 _Ap __a(__f_.__get_allocator());
351 __f_.destroy();348 __f_.destroy();
352 __a.deallocate(this, 1);349 __a.deallocate(this, 1);
...@@ -385,7 +382,9 @@ template <class _Fp> class __value_func;...@@ -385,7 +382,9 @@ template <class _Fp> class __value_func;
385382
386template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>383template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
387{384{
385 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
388 typename aligned_storage<3 * sizeof(void*)>::type __buf_;386 typename aligned_storage<3 * sizeof(void*)>::type __buf_;
387 _LIBCPP_SUPPRESS_DEPRECATED_POP
389388
390 typedef __base<_Rp(_ArgTypes...)> __func;389 typedef __base<_Rp(_ArgTypes...)> __func;
391 __func* __f_;390 __func* __f_;
...@@ -405,8 +404,7 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>...@@ -405,8 +404,7 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
405 {404 {
406 typedef allocator_traits<_Alloc> __alloc_traits;405 typedef allocator_traits<_Alloc> __alloc_traits;
407 typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun;406 typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun;
408 typedef typename __rebind_alloc_helper<__alloc_traits, _Fun>::type407 typedef __rebind_alloc<__alloc_traits, _Fun> _FunAlloc;
409 _FunAlloc;
410408
411 if (__function::__not_null(__f))409 if (__function::__not_null(__f))
412 {410 {
...@@ -519,7 +517,9 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>...@@ -519,7 +517,9 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
519 return;517 return;
520 if ((void*)__f_ == &__buf_ && (void*)__f.__f_ == &__f.__buf_)518 if ((void*)__f_ == &__buf_ && (void*)__f.__f_ == &__f.__buf_)
521 {519 {
520 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
522 typename aligned_storage<sizeof(__buf_)>::type __tempbuf;521 typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
522 _LIBCPP_SUPPRESS_DEPRECATED_POP
523 __func* __t = __as_base(&__tempbuf);523 __func* __t = __as_base(&__tempbuf);
524 __f_->__clone(__t);524 __f_->__clone(__t);
525 __f_->destroy();525 __f_->destroy();
...@@ -670,8 +670,7 @@ struct __policy...@@ -670,8 +670,7 @@ struct __policy
670// Used to choose between perfect forwarding or pass-by-value. Pass-by-value is670// Used to choose between perfect forwarding or pass-by-value. Pass-by-value is
671// faster for types that can be passed in registers.671// faster for types that can be passed in registers.
672template <typename _Tp>672template <typename _Tp>
673using __fast_forward =673using __fast_forward = __conditional_t<is_scalar<_Tp>::value, _Tp, _Tp&&>;
674 typename conditional<is_scalar<_Tp>::value, _Tp, _Tp&&>::type;
675674
676// __policy_invoker calls an instance of __alloc_func held in __policy_storage.675// __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...)>...@@ -747,8 +746,7 @@ template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)>
747 {746 {
748 typedef __alloc_func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun;747 typedef __alloc_func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun;
749 typedef allocator_traits<_Alloc> __alloc_traits;748 typedef allocator_traits<_Alloc> __alloc_traits;
750 typedef typename __rebind_alloc_helper<__alloc_traits, _Fun>::type749 typedef __rebind_alloc<__alloc_traits, _Fun> _FunAlloc;
751 _FunAlloc;
752750
753 if (__function::__not_null(__f))751 if (__function::__not_null(__f))
754 {752 {
...@@ -978,7 +976,7 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>...@@ -978,7 +976,7 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
978 __func __f_;976 __func __f_;
979977
980 template <class _Fp, bool = _And<978 template <class _Fp, bool = _And<
981 _IsNotSame<__uncvref_t<_Fp>, function>,979 _IsNotSame<__remove_cvref_t<_Fp>, function>,
982 __invokable<_Fp, _ArgTypes...>980 __invokable<_Fp, _ArgTypes...>
983 >::value>981 >::value>
984 struct __callable;982 struct __callable;
...@@ -1070,45 +1068,6 @@ public:...@@ -1070,45 +1068,6 @@ public:
1070template<class _Rp, class ..._Ap>1068template<class _Rp, class ..._Ap>
1071function(_Rp(*)(_Ap...)) -> function<_Rp(_Ap...)>;1069function(_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
1112template<class _Fp, class _Stripped = typename __strip_signature<decltype(&_Fp::operator())>::type>1071template<class _Fp, class _Stripped = typename __strip_signature<decltype(&_Fp::operator())>::type>
1113function(_Fp) -> function<_Stripped>;1072function(_Fp) -> function<_Stripped>;
1114#endif // _LIBCPP_STD_VER >= 171073#endif // _LIBCPP_STD_VER >= 17
...@@ -1250,1574 +1209,8 @@ void...@@ -1250,1574 +1209,8 @@ void
1250swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT1209swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT
1251{return __x.swap(__y);}1210{return __x.swap(__y);}
12521211
1253#elif defined(_LIBCPP_ENABLE_CXX03_FUNCTION)1212_LIBCPP_END_NAMESPACE_STD
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);}
28181213
2819#endif // _LIBCPP_CXX03_LANG1214#endif // _LIBCPP_CXX03_LANG
28201215
2821_LIBCPP_END_NAMESPACE_STD
2822
2823#endif // _LIBCPP___FUNCTIONAL_FUNCTION_H1216#endif // _LIBCPP___FUNCTIONAL_FUNCTION_H
lib/libcxx/include/__functional/hash.h+41-35
...@@ -10,8 +10,15 @@...@@ -10,8 +10,15 @@
10#define _LIBCPP___FUNCTIONAL_HASH_H10#define _LIBCPP___FUNCTIONAL_HASH_H
1111
12#include <__config>12#include <__config>
13#include <__functional/invoke.h>
13#include <__functional/unary_function.h>14#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>
15#include <__utility/forward.h>22#include <__utility/forward.h>
16#include <__utility/move.h>23#include <__utility/move.h>
17#include <__utility/pair.h>24#include <__utility/pair.h>
...@@ -20,7 +27,6 @@...@@ -20,7 +27,6 @@
20#include <cstdint>27#include <cstdint>
21#include <cstring>28#include <cstring>
22#include <limits>29#include <limits>
23#include <type_traits>
2430
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)31#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26# pragma GCC system_header32# pragma GCC system_header
...@@ -62,7 +68,7 @@ __murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len)...@@ -62,7 +68,7 @@ __murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len)
62 const unsigned char* __data = static_cast<const unsigned char*>(__key);68 const unsigned char* __data = static_cast<const unsigned char*>(__key);
63 for (; __len >= 4; __data += 4, __len -= 4)69 for (; __len >= 4; __data += 4, __len -= 4)
64 {70 {
65 _Size __k = __loadword<_Size>(__data);71 _Size __k = std::__loadword<_Size>(__data);
66 __k *= __m;72 __k *= __m;
67 __k ^= __k >> __r;73 __k ^= __k >> __r;
68 __k *= __m;74 __k *= __m;
...@@ -127,14 +133,14 @@ struct __murmur2_or_cityhash<_Size, 64>...@@ -127,14 +133,14 @@ struct __murmur2_or_cityhash<_Size, 64>
127 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK133 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
128 {134 {
129 if (__len > 8) {135 if (__len > 8) {
130 const _Size __a = __loadword<_Size>(__s);136 const _Size __a = std::__loadword<_Size>(__s);
131 const _Size __b = __loadword<_Size>(__s + __len - 8);137 const _Size __b = std::__loadword<_Size>(__s + __len - 8);
132 return __hash_len_16(__a, __rotate_by_at_least_1(__b + __len, __len)) ^ __b;138 return __hash_len_16(__a, __rotate_by_at_least_1(__b + __len, __len)) ^ __b;
133 }139 }
134 if (__len >= 4) {140 if (__len >= 4) {
135 const uint32_t __a = __loadword<uint32_t>(__s);141 const uint32_t __a = std::__loadword<uint32_t>(__s);
136 const uint32_t __b = __loadword<uint32_t>(__s + __len - 4);142 const uint32_t __b = std::__loadword<uint32_t>(__s + __len - 4);
137 return __hash_len_16(__len + (__a << 3), __b);143 return __hash_len_16(__len + (static_cast<_Size>(__a) << 3), __b);
138 }144 }
139 if (__len > 0) {145 if (__len > 0) {
140 const unsigned char __a = static_cast<unsigned char>(__s[0]);146 const unsigned char __a = static_cast<unsigned char>(__s[0]);
...@@ -151,10 +157,10 @@ struct __murmur2_or_cityhash<_Size, 64>...@@ -151,10 +157,10 @@ struct __murmur2_or_cityhash<_Size, 64>
151 static _Size __hash_len_17_to_32(const char *__s, _Size __len)157 static _Size __hash_len_17_to_32(const char *__s, _Size __len)
152 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK158 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
153 {159 {
154 const _Size __a = __loadword<_Size>(__s) * __k1;160 const _Size __a = std::__loadword<_Size>(__s) * __k1;
155 const _Size __b = __loadword<_Size>(__s + 8);161 const _Size __b = std::__loadword<_Size>(__s + 8);
156 const _Size __c = __loadword<_Size>(__s + __len - 8) * __k2;162 const _Size __c = std::__loadword<_Size>(__s + __len - 8) * __k2;
157 const _Size __d = __loadword<_Size>(__s + __len - 16) * __k0;163 const _Size __d = std::__loadword<_Size>(__s + __len - 16) * __k0;
158 return __hash_len_16(__rotate(__a - __b, 43) + __rotate(__c, 30) + __d,164 return __hash_len_16(__rotate(__a - __b, 43) + __rotate(__c, 30) + __d,
159 __a + __rotate(__b ^ __k3, 20) - __c + __len);165 __a + __rotate(__b ^ __k3, 20) - __c + __len);
160 }166 }
...@@ -179,10 +185,10 @@ struct __murmur2_or_cityhash<_Size, 64>...@@ -179,10 +185,10 @@ struct __murmur2_or_cityhash<_Size, 64>
179 const char* __s, _Size __a, _Size __b)185 const char* __s, _Size __a, _Size __b)
180 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK186 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
181 {187 {
182 return __weak_hash_len_32_with_seeds(__loadword<_Size>(__s),188 return __weak_hash_len_32_with_seeds(std::__loadword<_Size>(__s),
183 __loadword<_Size>(__s + 8),189 std::__loadword<_Size>(__s + 8),
184 __loadword<_Size>(__s + 16),190 std::__loadword<_Size>(__s + 16),
185 __loadword<_Size>(__s + 24),191 std::__loadword<_Size>(__s + 24),
186 __a,192 __a,
187 __b);193 __b);
188 }194 }
...@@ -191,23 +197,23 @@ struct __murmur2_or_cityhash<_Size, 64>...@@ -191,23 +197,23 @@ struct __murmur2_or_cityhash<_Size, 64>
191 static _Size __hash_len_33_to_64(const char *__s, size_t __len)197 static _Size __hash_len_33_to_64(const char *__s, size_t __len)
192 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK198 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
193 {199 {
194 _Size __z = __loadword<_Size>(__s + 24);200 _Size __z = std::__loadword<_Size>(__s + 24);
195 _Size __a = __loadword<_Size>(__s) +201 _Size __a = std::__loadword<_Size>(__s) +
196 (__len + __loadword<_Size>(__s + __len - 16)) * __k0;202 (__len + std::__loadword<_Size>(__s + __len - 16)) * __k0;
197 _Size __b = __rotate(__a + __z, 52);203 _Size __b = __rotate(__a + __z, 52);
198 _Size __c = __rotate(__a, 37);204 _Size __c = __rotate(__a, 37);
199 __a += __loadword<_Size>(__s + 8);205 __a += std::__loadword<_Size>(__s + 8);
200 __c += __rotate(__a, 7);206 __c += __rotate(__a, 7);
201 __a += __loadword<_Size>(__s + 16);207 __a += std::__loadword<_Size>(__s + 16);
202 _Size __vf = __a + __z;208 _Size __vf = __a + __z;
203 _Size __vs = __b + __rotate(__a, 31) + __c;209 _Size __vs = __b + __rotate(__a, 31) + __c;
204 __a = __loadword<_Size>(__s + 16) + __loadword<_Size>(__s + __len - 32);210 __a = std::__loadword<_Size>(__s + 16) + std::__loadword<_Size>(__s + __len - 32);
205 __z += __loadword<_Size>(__s + __len - 8);211 __z += std::__loadword<_Size>(__s + __len - 8);
206 __b = __rotate(__a + __z, 52);212 __b = __rotate(__a + __z, 52);
207 __c = __rotate(__a, 37);213 __c = __rotate(__a, 37);
208 __a += __loadword<_Size>(__s + __len - 24);214 __a += std::__loadword<_Size>(__s + __len - 24);
209 __c += __rotate(__a, 7);215 __c += __rotate(__a, 7);
210 __a += __loadword<_Size>(__s + __len - 16);216 __a += std::__loadword<_Size>(__s + __len - 16);
211 _Size __wf = __a + __z;217 _Size __wf = __a + __z;
212 _Size __ws = __b + __rotate(__a, 31) + __c;218 _Size __ws = __b + __rotate(__a, 31) + __c;
213 _Size __r = __shift_mix((__vf + __ws) * __k2 + (__wf + __vs) * __k0);219 _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)...@@ -233,26 +239,26 @@ __murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len)
233239
234 // For strings over 64 bytes we hash the end first, and then as we240 // For strings over 64 bytes we hash the end first, and then as we
235 // loop we keep 56 bytes of state: v, w, x, y, and z.241 // loop we keep 56 bytes of state: v, w, x, y, and z.
236 _Size __x = __loadword<_Size>(__s + __len - 40);242 _Size __x = std::__loadword<_Size>(__s + __len - 40);
237 _Size __y = __loadword<_Size>(__s + __len - 16) +243 _Size __y = std::__loadword<_Size>(__s + __len - 16) +
238 __loadword<_Size>(__s + __len - 56);244 std::__loadword<_Size>(__s + __len - 56);
239 _Size __z = __hash_len_16(__loadword<_Size>(__s + __len - 48) + __len,245 _Size __z = __hash_len_16(std::__loadword<_Size>(__s + __len - 48) + __len,
240 __loadword<_Size>(__s + __len - 24));246 std::__loadword<_Size>(__s + __len - 24));
241 pair<_Size, _Size> __v = __weak_hash_len_32_with_seeds(__s + __len - 64, __len, __z);247 pair<_Size, _Size> __v = __weak_hash_len_32_with_seeds(__s + __len - 64, __len, __z);
242 pair<_Size, _Size> __w = __weak_hash_len_32_with_seeds(__s + __len - 32, __y + __k1, __x);248 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
245 // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks.251 // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks.
246 __len = (__len - 1) & ~static_cast<_Size>(63);252 __len = (__len - 1) & ~static_cast<_Size>(63);
247 do {253 do {
248 __x = __rotate(__x + __y + __v.first + __loadword<_Size>(__s + 8), 37) * __k1;254 __x = __rotate(__x + __y + __v.first + std::__loadword<_Size>(__s + 8), 37) * __k1;
249 __y = __rotate(__y + __v.second + __loadword<_Size>(__s + 48), 42) * __k1;255 __y = __rotate(__y + __v.second + std::__loadword<_Size>(__s + 48), 42) * __k1;
250 __x ^= __w.second;256 __x ^= __w.second;
251 __y += __v.first + __loadword<_Size>(__s + 40);257 __y += __v.first + std::__loadword<_Size>(__s + 40);
252 __z = __rotate(__z + __w.first, 33) * __k1;258 __z = __rotate(__z + __w.first, 33) * __k1;
253 __v = __weak_hash_len_32_with_seeds(__s, __v.second * __k1, __x + __w.first);259 __v = __weak_hash_len_32_with_seeds(__s, __v.second * __k1, __x + __w.first);
254 __w = __weak_hash_len_32_with_seeds(__s + 32, __z + __w.second,260 __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));
256 _VSTD::swap(__z, __x);262 _VSTD::swap(__z, __x);
257 __s += 64;263 __s += 64;
258 __len -= 64;264 __len -= 64;
lib/libcxx/include/__functional/invoke.h+16-8
...@@ -248,7 +248,7 @@ struct __member_pointer_traits_imp<_Rp _Class::*, false, true>...@@ -248,7 +248,7 @@ struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
248248
249template <class _MP>249template <class _MP>
250struct __member_pointer_traits250struct __member_pointer_traits
251 : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,251 : public __member_pointer_traits_imp<__remove_cv_t<_MP>,
252 is_member_function_pointer<_MP>::value,252 is_member_function_pointer<_MP>::value,
253 is_member_object_pointer<_MP>::value>253 is_member_object_pointer<_MP>::value>
254{254{
...@@ -398,7 +398,7 @@ template <class _Ret, class _Fp, class ..._Args>...@@ -398,7 +398,7 @@ template <class _Ret, class _Fp, class ..._Args>
398struct __invokable_r398struct __invokable_r
399{399{
400 template <class _XFp, class ..._XArgs>400 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);
402 template <class _XFp, class ..._XArgs>402 template <class _XFp, class ..._XArgs>
403 static __nat __try_call(...);403 static __nat __try_call(...);
404404
...@@ -406,10 +406,10 @@ struct __invokable_r...@@ -406,10 +406,10 @@ struct __invokable_r
406 // or incomplete array types as required by the standard.406 // or incomplete array types as required by the standard.
407 using _Result = decltype(__try_call<_Fp, _Args...>(0));407 using _Result = decltype(__try_call<_Fp, _Args...>(0));
408408
409 using type = typename conditional<409 using type = __conditional_t<
410 _IsNotSame<_Result, __nat>::value,410 _IsNotSame<_Result, __nat>::value,
411 typename conditional< is_void<_Ret>::value, true_type, __is_core_convertible<_Result, _Ret> >::type,411 __conditional_t<is_void<_Ret>::value, true_type, __is_core_convertible<_Result, _Ret> >,
412 false_type >::type;412 false_type>;
413 static const bool value = type::value;413 static const bool value = type::value;
414};414};
415template <class _Fp, class ..._Args>415template <class _Fp, class ..._Args>
...@@ -428,15 +428,23 @@ struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>...@@ -428,15 +428,23 @@ struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
428 template <class _Tp>428 template <class _Tp>
429 static void __test_noexcept(_Tp) _NOEXCEPT;429 static void __test_noexcept(_Tp) _NOEXCEPT;
430430
431#ifdef _LIBCPP_CXX03_LANG
432 static const bool value = false;
433#else
431 static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(434 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
433};437};
434438
435template <class _Ret, class _Fp, class ..._Args>439template <class _Ret, class _Fp, class ..._Args>
436struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>440struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
437{441{
442#ifdef _LIBCPP_CXX03_LANG
443 static const bool value = false;
444#else
438 static const bool value = noexcept(445 static const bool value = noexcept(
439 _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...));446 _VSTD::__invoke(std::declval<_Fp>(), std::declval<_Args>()...));
447#endif
440};448};
441449
442template <class _Ret, class _Fp, class ..._Args>450template <class _Ret, class _Fp, class ..._Args>
...@@ -524,7 +532,7 @@ template <class _Fn, class... _Args>...@@ -524,7 +532,7 @@ template <class _Fn, class... _Args>
524using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;532using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
525533
526template <class _Fn, class ..._Args>534template <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...>
528invoke(_Fn&& __f, _Args&&... __args)536invoke(_Fn&& __f, _Args&&... __args)
529 noexcept(is_nothrow_invocable_v<_Fn, _Args...>)537 noexcept(is_nothrow_invocable_v<_Fn, _Args...>)
530{538{
lib/libcxx/include/__functional/is_transparent.h+1-2
...@@ -25,8 +25,7 @@ template <class _Tp, class, class = void>...@@ -25,8 +25,7 @@ template <class _Tp, class, class = void>
25struct __is_transparent : false_type {};25struct __is_transparent : false_type {};
2626
27template <class _Tp, class _Up>27template <class _Tp, class _Up>
28struct __is_transparent<_Tp, _Up,28struct __is_transparent<_Tp, _Up, __void_t<typename _Tp::is_transparent> >
29 typename __void_t<typename _Tp::is_transparent>::type>
30 : true_type {};29 : true_type {};
3130
32#endif31#endif
lib/libcxx/include/__functional/mem_fn.h+3-3
...@@ -33,12 +33,12 @@ private:...@@ -33,12 +33,12 @@ private:
33 type __f_;33 type __f_;
3434
35public:35public:
36 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1736 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
37 __mem_fn(type __f) _NOEXCEPT : __f_(__f) {}37 __mem_fn(type __f) _NOEXCEPT : __f_(__f) {}
3838
39 // invoke39 // invoke
40 template <class... _ArgTypes>40 template <class... _ArgTypes>
41 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1741 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
4242
43 typename __invoke_return<type, _ArgTypes...>::type43 typename __invoke_return<type, _ArgTypes...>::type
44 operator() (_ArgTypes&&... __args) const {44 operator() (_ArgTypes&&... __args) const {
...@@ -47,7 +47,7 @@ public:...@@ -47,7 +47,7 @@ public:
47};47};
4848
49template<class _Rp, class _Tp>49template<class _Rp, class _Tp>
50inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1750inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
51__mem_fn<_Rp _Tp::*>51__mem_fn<_Rp _Tp::*>
52mem_fn(_Rp _Tp::* __pm) _NOEXCEPT52mem_fn(_Rp _Tp::* __pm) _NOEXCEPT
53{53{
lib/libcxx/include/__functional/not_fn.h+2-2
...@@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
27struct __not_fn_op {27struct __not_fn_op {
28 template <class... _Args>28 template <class... _Args>
29 _LIBCPP_HIDE_FROM_ABI29 _LIBCPP_HIDE_FROM_ABI
30 _LIBCPP_CONSTEXPR_AFTER_CXX17 auto operator()(_Args&&... __args) const30 _LIBCPP_CONSTEXPR_SINCE_CXX20 auto operator()(_Args&&... __args) const
31 noexcept(noexcept(!_VSTD::invoke(_VSTD::forward<_Args>(__args)...)))31 noexcept(noexcept(!_VSTD::invoke(_VSTD::forward<_Args>(__args)...)))
32 -> decltype( !_VSTD::invoke(_VSTD::forward<_Args>(__args)...))32 -> decltype( !_VSTD::invoke(_VSTD::forward<_Args>(__args)...))
33 { return !_VSTD::invoke(_VSTD::forward<_Args>(__args)...); }33 { return !_VSTD::invoke(_VSTD::forward<_Args>(__args)...); }
...@@ -43,7 +43,7 @@ template <class _Fn, class = enable_if_t<...@@ -43,7 +43,7 @@ template <class _Fn, class = enable_if_t<
43 is_move_constructible_v<decay_t<_Fn>>43 is_move_constructible_v<decay_t<_Fn>>
44>>44>>
45_LIBCPP_HIDE_FROM_ABI45_LIBCPP_HIDE_FROM_ABI
46_LIBCPP_CONSTEXPR_AFTER_CXX17 auto not_fn(_Fn&& __f) {46_LIBCPP_CONSTEXPR_SINCE_CXX20 auto not_fn(_Fn&& __f) {
47 return __not_fn_t<decay_t<_Fn>>(_VSTD::forward<_Fn>(__f));47 return __not_fn_t<decay_t<_Fn>>(_VSTD::forward<_Fn>(__f));
48}48}
4949
lib/libcxx/include/__functional/operations.h+57-38
...@@ -32,17 +32,18 @@ struct _LIBCPP_TEMPLATE_VIS plus...@@ -32,17 +32,18 @@ struct _LIBCPP_TEMPLATE_VIS plus
32 : __binary_function<_Tp, _Tp, _Tp>32 : __binary_function<_Tp, _Tp, _Tp>
33{33{
34 typedef _Tp __result_type; // used by valarray34 typedef _Tp __result_type; // used by valarray
35 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY35 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
36 _Tp operator()(const _Tp& __x, const _Tp& __y) const36 _Tp operator()(const _Tp& __x, const _Tp& __y) const
37 {return __x + __y;}37 {return __x + __y;}
38};38};
39_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(plus);
3940
40#if _LIBCPP_STD_VER > 1141#if _LIBCPP_STD_VER > 11
41template <>42template <>
42struct _LIBCPP_TEMPLATE_VIS plus<void>43struct _LIBCPP_TEMPLATE_VIS plus<void>
43{44{
44 template <class _T1, class _T2>45 template <class _T1, class _T2>
45 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY46 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
46 auto operator()(_T1&& __t, _T2&& __u) const47 auto operator()(_T1&& __t, _T2&& __u) const
47 noexcept(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))48 noexcept(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
48 -> decltype( _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))49 -> decltype( _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
...@@ -60,17 +61,18 @@ struct _LIBCPP_TEMPLATE_VIS minus...@@ -60,17 +61,18 @@ struct _LIBCPP_TEMPLATE_VIS minus
60 : __binary_function<_Tp, _Tp, _Tp>61 : __binary_function<_Tp, _Tp, _Tp>
61{62{
62 typedef _Tp __result_type; // used by valarray63 typedef _Tp __result_type; // used by valarray
63 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY64 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
64 _Tp operator()(const _Tp& __x, const _Tp& __y) const65 _Tp operator()(const _Tp& __x, const _Tp& __y) const
65 {return __x - __y;}66 {return __x - __y;}
66};67};
68_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(minus);
6769
68#if _LIBCPP_STD_VER > 1170#if _LIBCPP_STD_VER > 11
69template <>71template <>
70struct _LIBCPP_TEMPLATE_VIS minus<void>72struct _LIBCPP_TEMPLATE_VIS minus<void>
71{73{
72 template <class _T1, class _T2>74 template <class _T1, class _T2>
73 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY75 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
74 auto operator()(_T1&& __t, _T2&& __u) const76 auto operator()(_T1&& __t, _T2&& __u) const
75 noexcept(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)))77 noexcept(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)))
76 -> decltype( _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))78 -> decltype( _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))
...@@ -88,17 +90,18 @@ struct _LIBCPP_TEMPLATE_VIS multiplies...@@ -88,17 +90,18 @@ struct _LIBCPP_TEMPLATE_VIS multiplies
88 : __binary_function<_Tp, _Tp, _Tp>90 : __binary_function<_Tp, _Tp, _Tp>
89{91{
90 typedef _Tp __result_type; // used by valarray92 typedef _Tp __result_type; // used by valarray
91 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY93 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
92 _Tp operator()(const _Tp& __x, const _Tp& __y) const94 _Tp operator()(const _Tp& __x, const _Tp& __y) const
93 {return __x * __y;}95 {return __x * __y;}
94};96};
97_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(multiplies);
9598
96#if _LIBCPP_STD_VER > 1199#if _LIBCPP_STD_VER > 11
97template <>100template <>
98struct _LIBCPP_TEMPLATE_VIS multiplies<void>101struct _LIBCPP_TEMPLATE_VIS multiplies<void>
99{102{
100 template <class _T1, class _T2>103 template <class _T1, class _T2>
101 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY104 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
102 auto operator()(_T1&& __t, _T2&& __u) const105 auto operator()(_T1&& __t, _T2&& __u) const
103 noexcept(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)))106 noexcept(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)))
104 -> decltype( _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))107 -> decltype( _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))
...@@ -116,17 +119,18 @@ struct _LIBCPP_TEMPLATE_VIS divides...@@ -116,17 +119,18 @@ struct _LIBCPP_TEMPLATE_VIS divides
116 : __binary_function<_Tp, _Tp, _Tp>119 : __binary_function<_Tp, _Tp, _Tp>
117{120{
118 typedef _Tp __result_type; // used by valarray121 typedef _Tp __result_type; // used by valarray
119 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY122 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
120 _Tp operator()(const _Tp& __x, const _Tp& __y) const123 _Tp operator()(const _Tp& __x, const _Tp& __y) const
121 {return __x / __y;}124 {return __x / __y;}
122};125};
126_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(divides);
123127
124#if _LIBCPP_STD_VER > 11128#if _LIBCPP_STD_VER > 11
125template <>129template <>
126struct _LIBCPP_TEMPLATE_VIS divides<void>130struct _LIBCPP_TEMPLATE_VIS divides<void>
127{131{
128 template <class _T1, class _T2>132 template <class _T1, class _T2>
129 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY133 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
130 auto operator()(_T1&& __t, _T2&& __u) const134 auto operator()(_T1&& __t, _T2&& __u) const
131 noexcept(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)))135 noexcept(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)))
132 -> decltype( _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))136 -> decltype( _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))
...@@ -144,17 +148,18 @@ struct _LIBCPP_TEMPLATE_VIS modulus...@@ -144,17 +148,18 @@ struct _LIBCPP_TEMPLATE_VIS modulus
144 : __binary_function<_Tp, _Tp, _Tp>148 : __binary_function<_Tp, _Tp, _Tp>
145{149{
146 typedef _Tp __result_type; // used by valarray150 typedef _Tp __result_type; // used by valarray
147 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY151 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
148 _Tp operator()(const _Tp& __x, const _Tp& __y) const152 _Tp operator()(const _Tp& __x, const _Tp& __y) const
149 {return __x % __y;}153 {return __x % __y;}
150};154};
155_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(modulus);
151156
152#if _LIBCPP_STD_VER > 11157#if _LIBCPP_STD_VER > 11
153template <>158template <>
154struct _LIBCPP_TEMPLATE_VIS modulus<void>159struct _LIBCPP_TEMPLATE_VIS modulus<void>
155{160{
156 template <class _T1, class _T2>161 template <class _T1, class _T2>
157 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY162 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
158 auto operator()(_T1&& __t, _T2&& __u) const163 auto operator()(_T1&& __t, _T2&& __u) const
159 noexcept(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)))164 noexcept(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)))
160 -> decltype( _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))165 -> decltype( _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))
...@@ -172,17 +177,18 @@ struct _LIBCPP_TEMPLATE_VIS negate...@@ -172,17 +177,18 @@ struct _LIBCPP_TEMPLATE_VIS negate
172 : __unary_function<_Tp, _Tp>177 : __unary_function<_Tp, _Tp>
173{178{
174 typedef _Tp __result_type; // used by valarray179 typedef _Tp __result_type; // used by valarray
175 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY180 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
176 _Tp operator()(const _Tp& __x) const181 _Tp operator()(const _Tp& __x) const
177 {return -__x;}182 {return -__x;}
178};183};
184_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(negate);
179185
180#if _LIBCPP_STD_VER > 11186#if _LIBCPP_STD_VER > 11
181template <>187template <>
182struct _LIBCPP_TEMPLATE_VIS negate<void>188struct _LIBCPP_TEMPLATE_VIS negate<void>
183{189{
184 template <class _Tp>190 template <class _Tp>
185 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY191 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
186 auto operator()(_Tp&& __x) const192 auto operator()(_Tp&& __x) const
187 noexcept(noexcept(- _VSTD::forward<_Tp>(__x)))193 noexcept(noexcept(- _VSTD::forward<_Tp>(__x)))
188 -> decltype( - _VSTD::forward<_Tp>(__x))194 -> decltype( - _VSTD::forward<_Tp>(__x))
...@@ -202,17 +208,18 @@ struct _LIBCPP_TEMPLATE_VIS bit_and...@@ -202,17 +208,18 @@ struct _LIBCPP_TEMPLATE_VIS bit_and
202 : __binary_function<_Tp, _Tp, _Tp>208 : __binary_function<_Tp, _Tp, _Tp>
203{209{
204 typedef _Tp __result_type; // used by valarray210 typedef _Tp __result_type; // used by valarray
205 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY211 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
206 _Tp operator()(const _Tp& __x, const _Tp& __y) const212 _Tp operator()(const _Tp& __x, const _Tp& __y) const
207 {return __x & __y;}213 {return __x & __y;}
208};214};
215_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_and);
209216
210#if _LIBCPP_STD_VER > 11217#if _LIBCPP_STD_VER > 11
211template <>218template <>
212struct _LIBCPP_TEMPLATE_VIS bit_and<void>219struct _LIBCPP_TEMPLATE_VIS bit_and<void>
213{220{
214 template <class _T1, class _T2>221 template <class _T1, class _T2>
215 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY222 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
216 auto operator()(_T1&& __t, _T2&& __u) const223 auto operator()(_T1&& __t, _T2&& __u) const
217 noexcept(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)))224 noexcept(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)))
218 -> decltype( _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))225 -> decltype( _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))
...@@ -226,16 +233,17 @@ template <class _Tp = void>...@@ -226,16 +233,17 @@ template <class _Tp = void>
226struct _LIBCPP_TEMPLATE_VIS bit_not233struct _LIBCPP_TEMPLATE_VIS bit_not
227 : __unary_function<_Tp, _Tp>234 : __unary_function<_Tp, _Tp>
228{235{
229 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY236 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
230 _Tp operator()(const _Tp& __x) const237 _Tp operator()(const _Tp& __x) const
231 {return ~__x;}238 {return ~__x;}
232};239};
240_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_not);
233241
234template <>242template <>
235struct _LIBCPP_TEMPLATE_VIS bit_not<void>243struct _LIBCPP_TEMPLATE_VIS bit_not<void>
236{244{
237 template <class _Tp>245 template <class _Tp>
238 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY246 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
239 auto operator()(_Tp&& __x) const247 auto operator()(_Tp&& __x) const
240 noexcept(noexcept(~_VSTD::forward<_Tp>(__x)))248 noexcept(noexcept(~_VSTD::forward<_Tp>(__x)))
241 -> decltype( ~_VSTD::forward<_Tp>(__x))249 -> decltype( ~_VSTD::forward<_Tp>(__x))
...@@ -253,17 +261,18 @@ struct _LIBCPP_TEMPLATE_VIS bit_or...@@ -253,17 +261,18 @@ struct _LIBCPP_TEMPLATE_VIS bit_or
253 : __binary_function<_Tp, _Tp, _Tp>261 : __binary_function<_Tp, _Tp, _Tp>
254{262{
255 typedef _Tp __result_type; // used by valarray263 typedef _Tp __result_type; // used by valarray
256 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY264 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
257 _Tp operator()(const _Tp& __x, const _Tp& __y) const265 _Tp operator()(const _Tp& __x, const _Tp& __y) const
258 {return __x | __y;}266 {return __x | __y;}
259};267};
268_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_or);
260269
261#if _LIBCPP_STD_VER > 11270#if _LIBCPP_STD_VER > 11
262template <>271template <>
263struct _LIBCPP_TEMPLATE_VIS bit_or<void>272struct _LIBCPP_TEMPLATE_VIS bit_or<void>
264{273{
265 template <class _T1, class _T2>274 template <class _T1, class _T2>
266 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY275 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
267 auto operator()(_T1&& __t, _T2&& __u) const276 auto operator()(_T1&& __t, _T2&& __u) const
268 noexcept(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)))277 noexcept(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)))
269 -> decltype( _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))278 -> decltype( _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))
...@@ -281,17 +290,18 @@ struct _LIBCPP_TEMPLATE_VIS bit_xor...@@ -281,17 +290,18 @@ struct _LIBCPP_TEMPLATE_VIS bit_xor
281 : __binary_function<_Tp, _Tp, _Tp>290 : __binary_function<_Tp, _Tp, _Tp>
282{291{
283 typedef _Tp __result_type; // used by valarray292 typedef _Tp __result_type; // used by valarray
284 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY293 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
285 _Tp operator()(const _Tp& __x, const _Tp& __y) const294 _Tp operator()(const _Tp& __x, const _Tp& __y) const
286 {return __x ^ __y;}295 {return __x ^ __y;}
287};296};
297_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_xor);
288298
289#if _LIBCPP_STD_VER > 11299#if _LIBCPP_STD_VER > 11
290template <>300template <>
291struct _LIBCPP_TEMPLATE_VIS bit_xor<void>301struct _LIBCPP_TEMPLATE_VIS bit_xor<void>
292{302{
293 template <class _T1, class _T2>303 template <class _T1, class _T2>
294 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY304 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
295 auto operator()(_T1&& __t, _T2&& __u) const305 auto operator()(_T1&& __t, _T2&& __u) const
296 noexcept(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)))306 noexcept(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)))
297 -> decltype( _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))307 -> decltype( _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))
...@@ -311,17 +321,18 @@ struct _LIBCPP_TEMPLATE_VIS equal_to...@@ -311,17 +321,18 @@ struct _LIBCPP_TEMPLATE_VIS equal_to
311 : __binary_function<_Tp, _Tp, bool>321 : __binary_function<_Tp, _Tp, bool>
312{322{
313 typedef bool __result_type; // used by valarray323 typedef bool __result_type; // used by valarray
314 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY324 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
315 bool operator()(const _Tp& __x, const _Tp& __y) const325 bool operator()(const _Tp& __x, const _Tp& __y) const
316 {return __x == __y;}326 {return __x == __y;}
317};327};
328_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(equal_to);
318329
319#if _LIBCPP_STD_VER > 11330#if _LIBCPP_STD_VER > 11
320template <>331template <>
321struct _LIBCPP_TEMPLATE_VIS equal_to<void>332struct _LIBCPP_TEMPLATE_VIS equal_to<void>
322{333{
323 template <class _T1, class _T2>334 template <class _T1, class _T2>
324 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY335 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
325 auto operator()(_T1&& __t, _T2&& __u) const336 auto operator()(_T1&& __t, _T2&& __u) const
326 noexcept(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)))337 noexcept(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)))
327 -> decltype( _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))338 -> decltype( _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))
...@@ -339,17 +350,18 @@ struct _LIBCPP_TEMPLATE_VIS not_equal_to...@@ -339,17 +350,18 @@ struct _LIBCPP_TEMPLATE_VIS not_equal_to
339 : __binary_function<_Tp, _Tp, bool>350 : __binary_function<_Tp, _Tp, bool>
340{351{
341 typedef bool __result_type; // used by valarray352 typedef bool __result_type; // used by valarray
342 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY353 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
343 bool operator()(const _Tp& __x, const _Tp& __y) const354 bool operator()(const _Tp& __x, const _Tp& __y) const
344 {return __x != __y;}355 {return __x != __y;}
345};356};
357_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(not_equal_to);
346358
347#if _LIBCPP_STD_VER > 11359#if _LIBCPP_STD_VER > 11
348template <>360template <>
349struct _LIBCPP_TEMPLATE_VIS not_equal_to<void>361struct _LIBCPP_TEMPLATE_VIS not_equal_to<void>
350{362{
351 template <class _T1, class _T2>363 template <class _T1, class _T2>
352 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY364 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
353 auto operator()(_T1&& __t, _T2&& __u) const365 auto operator()(_T1&& __t, _T2&& __u) const
354 noexcept(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)))366 noexcept(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)))
355 -> decltype( _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))367 -> decltype( _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))
...@@ -367,17 +379,18 @@ struct _LIBCPP_TEMPLATE_VIS less...@@ -367,17 +379,18 @@ struct _LIBCPP_TEMPLATE_VIS less
367 : __binary_function<_Tp, _Tp, bool>379 : __binary_function<_Tp, _Tp, bool>
368{380{
369 typedef bool __result_type; // used by valarray381 typedef bool __result_type; // used by valarray
370 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY382 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
371 bool operator()(const _Tp& __x, const _Tp& __y) const383 bool operator()(const _Tp& __x, const _Tp& __y) const
372 {return __x < __y;}384 {return __x < __y;}
373};385};
386_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less);
374387
375#if _LIBCPP_STD_VER > 11388#if _LIBCPP_STD_VER > 11
376template <>389template <>
377struct _LIBCPP_TEMPLATE_VIS less<void>390struct _LIBCPP_TEMPLATE_VIS less<void>
378{391{
379 template <class _T1, class _T2>392 template <class _T1, class _T2>
380 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY393 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
381 auto operator()(_T1&& __t, _T2&& __u) const394 auto operator()(_T1&& __t, _T2&& __u) const
382 noexcept(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)))395 noexcept(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)))
383 -> decltype( _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))396 -> decltype( _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))
...@@ -395,17 +408,18 @@ struct _LIBCPP_TEMPLATE_VIS less_equal...@@ -395,17 +408,18 @@ struct _LIBCPP_TEMPLATE_VIS less_equal
395 : __binary_function<_Tp, _Tp, bool>408 : __binary_function<_Tp, _Tp, bool>
396{409{
397 typedef bool __result_type; // used by valarray410 typedef bool __result_type; // used by valarray
398 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY411 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
399 bool operator()(const _Tp& __x, const _Tp& __y) const412 bool operator()(const _Tp& __x, const _Tp& __y) const
400 {return __x <= __y;}413 {return __x <= __y;}
401};414};
415_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less_equal);
402416
403#if _LIBCPP_STD_VER > 11417#if _LIBCPP_STD_VER > 11
404template <>418template <>
405struct _LIBCPP_TEMPLATE_VIS less_equal<void>419struct _LIBCPP_TEMPLATE_VIS less_equal<void>
406{420{
407 template <class _T1, class _T2>421 template <class _T1, class _T2>
408 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY422 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
409 auto operator()(_T1&& __t, _T2&& __u) const423 auto operator()(_T1&& __t, _T2&& __u) const
410 noexcept(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)))424 noexcept(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)))
411 -> decltype( _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))425 -> decltype( _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))
...@@ -423,17 +437,18 @@ struct _LIBCPP_TEMPLATE_VIS greater_equal...@@ -423,17 +437,18 @@ struct _LIBCPP_TEMPLATE_VIS greater_equal
423 : __binary_function<_Tp, _Tp, bool>437 : __binary_function<_Tp, _Tp, bool>
424{438{
425 typedef bool __result_type; // used by valarray439 typedef bool __result_type; // used by valarray
426 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY440 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
427 bool operator()(const _Tp& __x, const _Tp& __y) const441 bool operator()(const _Tp& __x, const _Tp& __y) const
428 {return __x >= __y;}442 {return __x >= __y;}
429};443};
444_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater_equal);
430445
431#if _LIBCPP_STD_VER > 11446#if _LIBCPP_STD_VER > 11
432template <>447template <>
433struct _LIBCPP_TEMPLATE_VIS greater_equal<void>448struct _LIBCPP_TEMPLATE_VIS greater_equal<void>
434{449{
435 template <class _T1, class _T2>450 template <class _T1, class _T2>
436 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY451 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
437 auto operator()(_T1&& __t, _T2&& __u) const452 auto operator()(_T1&& __t, _T2&& __u) const
438 noexcept(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)))453 noexcept(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)))
439 -> decltype( _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))454 -> decltype( _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))
...@@ -451,17 +466,18 @@ struct _LIBCPP_TEMPLATE_VIS greater...@@ -451,17 +466,18 @@ struct _LIBCPP_TEMPLATE_VIS greater
451 : __binary_function<_Tp, _Tp, bool>466 : __binary_function<_Tp, _Tp, bool>
452{467{
453 typedef bool __result_type; // used by valarray468 typedef bool __result_type; // used by valarray
454 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY469 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
455 bool operator()(const _Tp& __x, const _Tp& __y) const470 bool operator()(const _Tp& __x, const _Tp& __y) const
456 {return __x > __y;}471 {return __x > __y;}
457};472};
473_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater);
458474
459#if _LIBCPP_STD_VER > 11475#if _LIBCPP_STD_VER > 11
460template <>476template <>
461struct _LIBCPP_TEMPLATE_VIS greater<void>477struct _LIBCPP_TEMPLATE_VIS greater<void>
462{478{
463 template <class _T1, class _T2>479 template <class _T1, class _T2>
464 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY480 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
465 auto operator()(_T1&& __t, _T2&& __u) const481 auto operator()(_T1&& __t, _T2&& __u) const
466 noexcept(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)))482 noexcept(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)))
467 -> decltype( _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))483 -> decltype( _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))
...@@ -481,17 +497,18 @@ struct _LIBCPP_TEMPLATE_VIS logical_and...@@ -481,17 +497,18 @@ struct _LIBCPP_TEMPLATE_VIS logical_and
481 : __binary_function<_Tp, _Tp, bool>497 : __binary_function<_Tp, _Tp, bool>
482{498{
483 typedef bool __result_type; // used by valarray499 typedef bool __result_type; // used by valarray
484 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY500 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
485 bool operator()(const _Tp& __x, const _Tp& __y) const501 bool operator()(const _Tp& __x, const _Tp& __y) const
486 {return __x && __y;}502 {return __x && __y;}
487};503};
504_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_and);
488505
489#if _LIBCPP_STD_VER > 11506#if _LIBCPP_STD_VER > 11
490template <>507template <>
491struct _LIBCPP_TEMPLATE_VIS logical_and<void>508struct _LIBCPP_TEMPLATE_VIS logical_and<void>
492{509{
493 template <class _T1, class _T2>510 template <class _T1, class _T2>
494 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY511 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
495 auto operator()(_T1&& __t, _T2&& __u) const512 auto operator()(_T1&& __t, _T2&& __u) const
496 noexcept(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)))513 noexcept(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)))
497 -> decltype( _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))514 -> decltype( _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))
...@@ -509,17 +526,18 @@ struct _LIBCPP_TEMPLATE_VIS logical_not...@@ -509,17 +526,18 @@ struct _LIBCPP_TEMPLATE_VIS logical_not
509 : __unary_function<_Tp, bool>526 : __unary_function<_Tp, bool>
510{527{
511 typedef bool __result_type; // used by valarray528 typedef bool __result_type; // used by valarray
512 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY529 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
513 bool operator()(const _Tp& __x) const530 bool operator()(const _Tp& __x) const
514 {return !__x;}531 {return !__x;}
515};532};
533_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_not);
516534
517#if _LIBCPP_STD_VER > 11535#if _LIBCPP_STD_VER > 11
518template <>536template <>
519struct _LIBCPP_TEMPLATE_VIS logical_not<void>537struct _LIBCPP_TEMPLATE_VIS logical_not<void>
520{538{
521 template <class _Tp>539 template <class _Tp>
522 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY540 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
523 auto operator()(_Tp&& __x) const541 auto operator()(_Tp&& __x) const
524 noexcept(noexcept(!_VSTD::forward<_Tp>(__x)))542 noexcept(noexcept(!_VSTD::forward<_Tp>(__x)))
525 -> decltype( !_VSTD::forward<_Tp>(__x))543 -> decltype( !_VSTD::forward<_Tp>(__x))
...@@ -537,17 +555,18 @@ struct _LIBCPP_TEMPLATE_VIS logical_or...@@ -537,17 +555,18 @@ struct _LIBCPP_TEMPLATE_VIS logical_or
537 : __binary_function<_Tp, _Tp, bool>555 : __binary_function<_Tp, _Tp, bool>
538{556{
539 typedef bool __result_type; // used by valarray557 typedef bool __result_type; // used by valarray
540 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY558 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
541 bool operator()(const _Tp& __x, const _Tp& __y) const559 bool operator()(const _Tp& __x, const _Tp& __y) const
542 {return __x || __y;}560 {return __x || __y;}
543};561};
562_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_or);
544563
545#if _LIBCPP_STD_VER > 11564#if _LIBCPP_STD_VER > 11
546template <>565template <>
547struct _LIBCPP_TEMPLATE_VIS logical_or<void>566struct _LIBCPP_TEMPLATE_VIS logical_or<void>
548{567{
549 template <class _T1, class _T2>568 template <class _T1, class _T2>
550 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY569 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
551 auto operator()(_T1&& __t, _T2&& __u) const570 auto operator()(_T1&& __t, _T2&& __u) const
552 noexcept(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)))571 noexcept(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)))
553 -> decltype( _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))572 -> decltype( _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))
lib/libcxx/include/__functional/ranges_operations.h+2-1
...@@ -10,9 +10,10 @@...@@ -10,9 +10,10 @@
10#ifndef _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H10#ifndef _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
11#define _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H11#define _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
1212
13#include <__concepts/equality_comparable.h>
14#include <__concepts/totally_ordered.h>
13#include <__config>15#include <__config>
14#include <__utility/forward.h>16#include <__utility/forward.h>
15#include <concepts>
1617
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header19# pragma GCC system_header
lib/libcxx/include/__functional/reference_wrapper.h+14-11
...@@ -11,10 +11,13 @@...@@ -11,10 +11,13 @@
11#define _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H11#define _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H
1212
13#include <__config>13#include <__config>
14#include <__functional/invoke.h>
14#include <__functional/weak_result_type.h>15#include <__functional/weak_result_type.h>
15#include <__memory/addressof.h>16#include <__memory/addressof.h>
17#include <__type_traits/enable_if.h>
18#include <__type_traits/remove_cvref.h>
19#include <__utility/declval.h>
16#include <__utility/forward.h>20#include <__utility/forward.h>
17#include <type_traits>
1821
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header23# pragma GCC system_header
...@@ -35,22 +38,22 @@ private:...@@ -35,22 +38,22 @@ private:
35 static void __fun(_Tp&&) = delete;38 static void __fun(_Tp&&) = delete;
3639
37public:40public:
38 template <class _Up, class = __enable_if_t<!__is_same_uncvref<_Up, reference_wrapper>::value, decltype(__fun(declval<_Up>())) > >41 template <class _Up, class = __enable_if_t<!__is_same_uncvref<_Up, reference_wrapper>::value, decltype(__fun(std::declval<_Up>())) > >
39 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1742 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
40 reference_wrapper(_Up&& __u) _NOEXCEPT_(noexcept(__fun(declval<_Up>()))) {43 reference_wrapper(_Up&& __u) _NOEXCEPT_(noexcept(__fun(std::declval<_Up>()))) {
41 type& __f = static_cast<_Up&&>(__u);44 type& __f = static_cast<_Up&&>(__u);
42 __f_ = _VSTD::addressof(__f);45 __f_ = _VSTD::addressof(__f);
43 }46 }
4447
45 // access48 // access
46 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1749 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
47 operator type&() const _NOEXCEPT {return *__f_;}50 operator type&() const _NOEXCEPT {return *__f_;}
48 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1751 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
49 type& get() const _NOEXCEPT {return *__f_;}52 type& get() const _NOEXCEPT {return *__f_;}
5053
51 // invoke54 // invoke
52 template <class... _ArgTypes>55 template <class... _ArgTypes>
53 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1756 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
54 typename __invoke_of<type&, _ArgTypes...>::type57 typename __invoke_of<type&, _ArgTypes...>::type
55 operator() (_ArgTypes&&... __args) const {58 operator() (_ArgTypes&&... __args) const {
56 return std::__invoke(get(), std::forward<_ArgTypes>(__args)...);59 return std::__invoke(get(), std::forward<_ArgTypes>(__args)...);
...@@ -63,7 +66,7 @@ reference_wrapper(_Tp&) -> reference_wrapper<_Tp>;...@@ -63,7 +66,7 @@ reference_wrapper(_Tp&) -> reference_wrapper<_Tp>;
63#endif66#endif
6467
65template <class _Tp>68template <class _Tp>
66inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1769inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
67reference_wrapper<_Tp>70reference_wrapper<_Tp>
68ref(_Tp& __t) _NOEXCEPT71ref(_Tp& __t) _NOEXCEPT
69{72{
...@@ -71,7 +74,7 @@ ref(_Tp& __t) _NOEXCEPT...@@ -71,7 +74,7 @@ ref(_Tp& __t) _NOEXCEPT
71}74}
7275
73template <class _Tp>76template <class _Tp>
74inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1777inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
75reference_wrapper<_Tp>78reference_wrapper<_Tp>
76ref(reference_wrapper<_Tp> __t) _NOEXCEPT79ref(reference_wrapper<_Tp> __t) _NOEXCEPT
77{80{
...@@ -79,7 +82,7 @@ ref(reference_wrapper<_Tp> __t) _NOEXCEPT...@@ -79,7 +82,7 @@ ref(reference_wrapper<_Tp> __t) _NOEXCEPT
79}82}
8083
81template <class _Tp>84template <class _Tp>
82inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1785inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
83reference_wrapper<const _Tp>86reference_wrapper<const _Tp>
84cref(const _Tp& __t) _NOEXCEPT87cref(const _Tp& __t) _NOEXCEPT
85{88{
...@@ -87,7 +90,7 @@ cref(const _Tp& __t) _NOEXCEPT...@@ -87,7 +90,7 @@ cref(const _Tp& __t) _NOEXCEPT
87}90}
8891
89template <class _Tp>92template <class _Tp>
90inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1793inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
91reference_wrapper<const _Tp>94reference_wrapper<const _Tp>
92cref(reference_wrapper<_Tp> __t) _NOEXCEPT95cref(reference_wrapper<_Tp> __t) _NOEXCEPT
93{96{
lib/libcxx/include/__functional/unary_negate.h+3-3
...@@ -27,16 +27,16 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 unary_negate...@@ -27,16 +27,16 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 unary_negate
27{27{
28 _Predicate __pred_;28 _Predicate __pred_;
29public:29public:
30 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY30 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
31 explicit unary_negate(const _Predicate& __pred)31 explicit unary_negate(const _Predicate& __pred)
32 : __pred_(__pred) {}32 : __pred_(__pred) {}
33 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY33 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
34 bool operator()(const typename _Predicate::argument_type& __x) const34 bool operator()(const typename _Predicate::argument_type& __x) const
35 {return !__pred_(__x);}35 {return !__pred_(__x);}
36};36};
3737
38template <class _Predicate>38template <class _Predicate>
39_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY39_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
40unary_negate<_Predicate>40unary_negate<_Predicate>
41not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);}41not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);}
4242
lib/libcxx/include/__functional/unwrap_ref.h+1
...@@ -10,6 +10,7 @@...@@ -10,6 +10,7 @@
10#define _LIBCPP___FUNCTIONAL_UNWRAP_REF_H10#define _LIBCPP___FUNCTIONAL_UNWRAP_REF_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/decay.h>
1314
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# pragma GCC system_header16# pragma GCC system_header
lib/libcxx/include/__functional/weak_result_type.h+5-2
...@@ -12,8 +12,11 @@...@@ -12,8 +12,11 @@
1212
13#include <__config>13#include <__config>
14#include <__functional/binary_function.h>14#include <__functional/binary_function.h>
15#include <__functional/invoke.h>
15#include <__functional/unary_function.h>16#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
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header22# pragma GCC system_header
...@@ -283,7 +286,7 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>...@@ -283,7 +286,7 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>
283template <class _Tp, class ..._Args>286template <class _Tp, class ..._Args>
284struct __invoke_return287struct __invoke_return
285{288{
286 typedef decltype(_VSTD::__invoke(declval<_Tp>(), declval<_Args>()...)) type;289 typedef decltype(_VSTD::__invoke(std::declval<_Tp>(), std::declval<_Args>()...)) type;
287};290};
288291
289_LIBCPP_END_NAMESPACE_STD292_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 @@...@@ -7,8 +7,8 @@
7//7//
8//===---------------------------------------------------------------------===//8//===---------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_FWD_SPAN_H10#ifndef _LIBCPP___FWD_SPAN_H
11#define _LIBCPP_FWD_SPAN_H11#define _LIBCPP___FWD_SPAN_H
1212
13#include <__config>13#include <__config>
14#include <cstddef>14#include <cstddef>
...@@ -34,4 +34,4 @@ _LIBCPP_END_NAMESPACE_STD...@@ -34,4 +34,4 @@ _LIBCPP_END_NAMESPACE_STD
3434
35_LIBCPP_POP_MACROS35_LIBCPP_POP_MACROS
3636
37#endif // _LIBCPP_FWD_SPAN_H37#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 @@...@@ -7,8 +7,8 @@
7//7//
8//===---------------------------------------------------------------------===//8//===---------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_FWD_STRING_VIEW_H10#ifndef _LIBCPP___FWD_STRING_VIEW_H
11#define _LIBCPP_FWD_STRING_VIEW_H11#define _LIBCPP___FWD_STRING_VIEW_H
1212
13#include <__config>13#include <__config>
14#include <iosfwd> // char_traits14#include <iosfwd> // char_traits
...@@ -32,6 +32,19 @@ typedef basic_string_view<char32_t> u32string_view;...@@ -32,6 +32,19 @@ typedef basic_string_view<char32_t> u32string_view;
32typedef basic_string_view<wchar_t> wstring_view;32typedef basic_string_view<wchar_t> wstring_view;
33#endif33#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
35_LIBCPP_END_NAMESPACE_STD48_LIBCPP_END_NAMESPACE_STD
3649
37#endif // _LIBCPP_FWD_STRING_VIEW_H50#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 @@...@@ -13,16 +13,25 @@
13#include <__algorithm/max.h>13#include <__algorithm/max.h>
14#include <__algorithm/min.h>14#include <__algorithm/min.h>
15#include <__assert>15#include <__assert>
16#include <__bits> // __libcpp_clz16#include <__bit/countl.h>
17#include <__config>17#include <__config>
18#include <__debug>18#include <__debug>
19#include <__functional/hash.h>19#include <__functional/hash.h>
20#include <__iterator/iterator_traits.h>20#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>
21#include <__memory/swap_allocator.h>25#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>
22#include <__utility/swap.h>31#include <__utility/swap.h>
23#include <cmath>32#include <cmath>
33#include <cstring>
24#include <initializer_list>34#include <initializer_list>
25#include <memory>
26#include <type_traits>35#include <type_traits>
2736
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)37#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -48,7 +57,7 @@ template <class ..._Args>...@@ -48,7 +57,7 @@ template <class ..._Args>
48struct __is_hash_value_type : false_type {};57struct __is_hash_value_type : false_type {};
4958
50template <class _One>59template <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
53_LIBCPP_FUNC_VIS62_LIBCPP_FUNC_VIS
54size_t __next_prime(size_t __n);63size_t __next_prime(size_t __n);
...@@ -58,16 +67,13 @@ struct __hash_node_base...@@ -58,16 +67,13 @@ struct __hash_node_base
58{67{
59 typedef typename pointer_traits<_NodePtr>::element_type __node_type;68 typedef typename pointer_traits<_NodePtr>::element_type __node_type;
60 typedef __hash_node_base __first_node;69 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;
62 typedef _NodePtr __node_pointer;71 typedef _NodePtr __node_pointer;
6372
64#if defined(_LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB)73#if defined(_LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB)
65 typedef __node_base_pointer __next_pointer;74 typedef __node_base_pointer __next_pointer;
66#else75#else
67 typedef typename conditional<76 typedef __conditional_t<is_pointer<__node_pointer>::value, __node_base_pointer, __node_pointer> __next_pointer;
68 is_pointer<__node_pointer>::value,
69 __node_base_pointer,
70 __node_pointer>::type __next_pointer;
71#endif77#endif
7278
73 __next_pointer __next_;79 __next_pointer __next_;
...@@ -96,7 +102,7 @@ template <class _Tp, class _VoidPtr>...@@ -96,7 +102,7 @@ template <class _Tp, class _VoidPtr>
96struct _LIBCPP_STANDALONE_DEBUG __hash_node102struct _LIBCPP_STANDALONE_DEBUG __hash_node
97 : public __hash_node_base103 : public __hash_node_base
98 <104 <
99 typename __rebind_pointer<_VoidPtr, __hash_node<_Tp, _VoidPtr> >::type105 __rebind_pointer_t<_VoidPtr, __hash_node<_Tp, _VoidPtr> >
100 >106 >
101{107{
102 typedef _Tp __node_value_type;108 typedef _Tp __node_value_type;
...@@ -208,9 +214,9 @@ struct __hash_map_pointer_types {};...@@ -208,9 +214,9 @@ struct __hash_map_pointer_types {};
208template <class _Tp, class _AllocPtr, class _KVTypes>214template <class _Tp, class _AllocPtr, class _KVTypes>
209struct __hash_map_pointer_types<_Tp, _AllocPtr, _KVTypes, true> {215struct __hash_map_pointer_types<_Tp, _AllocPtr, _KVTypes, true> {
210 typedef typename _KVTypes::__map_value_type _Mv;216 typedef typename _KVTypes::__map_value_type _Mv;
211 typedef typename __rebind_pointer<_AllocPtr, _Mv>::type217 typedef __rebind_pointer_t<_AllocPtr, _Mv>
212 __map_value_type_pointer;218 __map_value_type_pointer;
213 typedef typename __rebind_pointer<_AllocPtr, const _Mv>::type219 typedef __rebind_pointer_t<_AllocPtr, const _Mv>
214 __const_map_value_type_pointer;220 __const_map_value_type_pointer;
215};221};
216222
...@@ -228,21 +234,21 @@ public:...@@ -228,21 +234,21 @@ public:
228 typedef ptrdiff_t difference_type;234 typedef ptrdiff_t difference_type;
229 typedef size_t size_type;235 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
233 typedef typename pointer_traits<_NodePtr>::element_type __node_type;239 typedef typename pointer_traits<_NodePtr>::element_type __node_type;
234 typedef _NodePtr __node_pointer;240 typedef _NodePtr __node_pointer;
235241
236 typedef __hash_node_base<__node_pointer> __node_base_type;242 typedef __hash_node_base<__node_pointer> __node_base_type;
237 typedef typename __rebind_pointer<_NodePtr, __node_base_type>::type243 typedef __rebind_pointer_t<_NodePtr, __node_base_type>
238 __node_base_pointer;244 __node_base_pointer;
239245
240 typedef typename __node_base_type::__next_pointer __next_pointer;246 typedef typename __node_base_type::__next_pointer __next_pointer;
241247
242 typedef _Tp __node_value_type;248 typedef _Tp __node_value_type;
243 typedef typename __rebind_pointer<_VoidPtr, __node_value_type>::type249 typedef __rebind_pointer_t<_VoidPtr, __node_value_type>
244 __node_value_type_pointer;250 __node_value_type_pointer;
245 typedef typename __rebind_pointer<_VoidPtr, const __node_value_type>::type251 typedef __rebind_pointer_t<_VoidPtr, const __node_value_type>
246 __const_node_value_type_pointer;252 __const_node_value_type_pointer;
247253
248private:254private:
...@@ -250,7 +256,7 @@ private:...@@ -250,7 +256,7 @@ private:
250 "_NodePtr should never be a pointer to const");256 "_NodePtr should never be a pointer to const");
251 static_assert((is_same<typename pointer_traits<_VoidPtr>::element_type, void>::value),257 static_assert((is_same<typename pointer_traits<_VoidPtr>::element_type, void>::value),
252 "_VoidPtr does not point to unqualified void type");258 "_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>,
254 _NodePtr>::value), "_VoidPtr does not rebind to _NodePtr.");260 _NodePtr>::value), "_VoidPtr does not rebind to _NodePtr.");
255};261};
256262
...@@ -269,7 +275,7 @@ struct __hash_node_types_from_iterator<__hash_const_local_iterator<_NodePtr> > :...@@ -269,7 +275,7 @@ struct __hash_node_types_from_iterator<__hash_const_local_iterator<_NodePtr> > :
269template <class _NodeValueTp, class _VoidPtr>275template <class _NodeValueTp, class _VoidPtr>
270struct __make_hash_node_types {276struct __make_hash_node_types {
271 typedef __hash_node<_NodeValueTp, _VoidPtr> _NodeTp;277 typedef __hash_node<_NodeValueTp, _VoidPtr> _NodeTp;
272 typedef typename __rebind_pointer<_VoidPtr, _NodeTp>::type _NodePtr;278 typedef __rebind_pointer_t<_VoidPtr, _NodeTp> _NodePtr;
273 typedef __hash_node_types<_NodePtr> type;279 typedef __hash_node_types<_NodePtr> type;
274};280};
275281
...@@ -559,7 +565,7 @@ public:...@@ -559,7 +565,7 @@ public:
559 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),565 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
560 "Attempted to increment a non-incrementable unordered container local_iterator");566 "Attempted to increment a non-incrementable unordered container local_iterator");
561 __node_ = __node_->__next_;567 __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_)
563 __node_ = nullptr;569 __node_ = nullptr;
564 return *this;570 return *this;
565 }571 }
...@@ -614,8 +620,8 @@ class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator...@@ -614,8 +620,8 @@ class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator
614620
615 typedef pointer_traits<__node_pointer> __pointer_traits;621 typedef pointer_traits<__node_pointer> __pointer_traits;
616 typedef typename __pointer_traits::element_type __node;622 typedef typename __pointer_traits::element_type __node;
617 typedef typename remove_const<__node>::type __non_const_node;623 typedef __remove_const_t<__node> __non_const_node;
618 typedef typename __rebind_pointer<__node_pointer, __non_const_node>::type624 typedef __rebind_pointer_t<__node_pointer, __non_const_node>
619 __non_const_node_pointer;625 __non_const_node_pointer;
620public:626public:
621 typedef __hash_local_iterator<__non_const_node_pointer>627 typedef __hash_local_iterator<__non_const_node_pointer>
...@@ -692,7 +698,7 @@ public:...@@ -692,7 +698,7 @@ public:
692 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),698 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
693 "Attempted to increment a non-incrementable unordered container const_local_iterator");699 "Attempted to increment a non-incrementable unordered container const_local_iterator");
694 __node_ = __node_->__next_;700 __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_)
696 __node_ = nullptr;702 __node_ = nullptr;
697 return *this;703 return *this;
698 }704 }
...@@ -892,7 +898,7 @@ public:...@@ -892,7 +898,7 @@ public:
892 // Create __node898 // Create __node
893899
894 typedef typename _NodeTypes::__node_type __node;900 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;
896 typedef allocator_traits<__node_allocator> __node_traits;902 typedef allocator_traits<__node_allocator> __node_traits;
897 typedef typename _NodeTypes::__void_pointer __void_pointer;903 typedef typename _NodeTypes::__void_pointer __void_pointer;
898 typedef typename _NodeTypes::__node_pointer __node_pointer;904 typedef typename _NodeTypes::__node_pointer __node_pointer;
...@@ -907,15 +913,14 @@ private:...@@ -907,15 +913,14 @@ private:
907 // the pointer using 'pointer_traits'.913 // the pointer using 'pointer_traits'.
908 static_assert((is_same<__node_pointer, typename __node_traits::pointer>::value),914 static_assert((is_same<__node_pointer, typename __node_traits::pointer>::value),
909 "Allocator does not rebind pointers in a sane manner.");915 "Allocator does not rebind pointers in a sane manner.");
910 typedef typename __rebind_alloc_helper<__node_traits, __first_node>::type916 typedef __rebind_alloc<__node_traits, __first_node> __node_base_allocator;
911 __node_base_allocator;
912 typedef allocator_traits<__node_base_allocator> __node_base_traits;917 typedef allocator_traits<__node_base_allocator> __node_base_traits;
913 static_assert((is_same<__node_base_pointer, typename __node_base_traits::pointer>::value),918 static_assert((is_same<__node_base_pointer, typename __node_base_traits::pointer>::value),
914 "Allocator does not rebind pointers in a sane manner.");919 "Allocator does not rebind pointers in a sane manner.");
915920
916private:921private:
917922
918 typedef typename __rebind_alloc_helper<__node_traits, __next_pointer>::type __pointer_allocator;923 typedef __rebind_alloc<__node_traits, __next_pointer> __pointer_allocator;
919 typedef __bucket_list_deallocator<__pointer_allocator> __bucket_list_deleter;924 typedef __bucket_list_deallocator<__pointer_allocator> __bucket_list_deleter;
920 typedef unique_ptr<__next_pointer[], __bucket_list_deleter> __bucket_list;925 typedef unique_ptr<__next_pointer[], __bucket_list_deleter> __bucket_list;
921 typedef allocator_traits<__pointer_allocator> __pointer_alloc_traits;926 typedef allocator_traits<__pointer_allocator> __pointer_alloc_traits;
...@@ -1151,11 +1156,11 @@ public:...@@ -1151,11 +1156,11 @@ public:
1151 _LIBCPP_INLINE_VISIBILITY void __rehash_multi(size_type __n) { __rehash<false>(__n); }1156 _LIBCPP_INLINE_VISIBILITY void __rehash_multi(size_type __n) { __rehash<false>(__n); }
1152 _LIBCPP_INLINE_VISIBILITY void __reserve_unique(size_type __n)1157 _LIBCPP_INLINE_VISIBILITY void __reserve_unique(size_type __n)
1153 {1158 {
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())));
1155 }1160 }
1156 _LIBCPP_INLINE_VISIBILITY void __reserve_multi(size_type __n)1161 _LIBCPP_INLINE_VISIBILITY void __reserve_multi(size_type __n)
1157 {1162 {
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())));
1159 }1164 }
11601165
1161 _LIBCPP_INLINE_VISIBILITY1166 _LIBCPP_INLINE_VISIBILITY
...@@ -1179,7 +1184,7 @@ public:...@@ -1179,7 +1184,7 @@ public:
1179 {1184 {
1180 _LIBCPP_ASSERT(bucket_count() > 0,1185 _LIBCPP_ASSERT(bucket_count() > 0,
1181 "unordered container::bucket(key) called when bucket_count() == 0");1186 "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());
1183 }1188 }
11841189
1185 template <class _Key>1190 template <class _Key>
...@@ -1428,7 +1433,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u)...@@ -1428,7 +1433,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u)
1428{1433{
1429 if (size() > 0)1434 if (size() > 0)
1430 {1435 {
1431 __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =1436 __bucket_list_[std::__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
1432 __p1_.first().__ptr();1437 __p1_.first().__ptr();
1433 __u.__p1_.first().__next_ = nullptr;1438 __u.__p1_.first().__next_ = nullptr;
1434 __u.size() = 0;1439 __u.size() = 0;
...@@ -1452,7 +1457,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u,...@@ -1452,7 +1457,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u,
1452 {1457 {
1453 __p1_.first().__next_ = __u.__p1_.first().__next_;1458 __p1_.first().__next_ = __u.__p1_.first().__next_;
1454 __u.__p1_.first().__next_ = nullptr;1459 __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())] =
1456 __p1_.first().__ptr();1461 __p1_.first().__ptr();
1457 size() = __u.size();1462 size() = __u.size();
1458 __u.size() = 0;1463 __u.size() = 0;
...@@ -1569,7 +1574,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(...@@ -1569,7 +1574,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
1569 __p1_.first().__next_ = __u.__p1_.first().__next_;1574 __p1_.first().__next_ = __u.__p1_.first().__next_;
1570 if (size() > 0)1575 if (size() > 0)
1571 {1576 {
1572 __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =1577 __bucket_list_[std::__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] =
1573 __p1_.first().__ptr();1578 __p1_.first().__ptr();
1574 __u.__p1_.first().__next_ = nullptr;1579 __u.__p1_.first().__next_ = nullptr;
1575 __u.size() = 0;1580 __u.size() = 0;
...@@ -1784,12 +1789,12 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare(...@@ -1784,12 +1789,12 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare(
17841789
1785 if (__bc != 0)1790 if (__bc != 0)
1786 {1791 {
1787 size_t __chash = __constrain_hash(__hash, __bc);1792 size_t __chash = std::__constrain_hash(__hash, __bc);
1788 __next_pointer __ndptr = __bucket_list_[__chash];1793 __next_pointer __ndptr = __bucket_list_[__chash];
1789 if (__ndptr != nullptr)1794 if (__ndptr != nullptr)
1790 {1795 {
1791 for (__ndptr = __ndptr->__next_; __ndptr != nullptr &&1796 for (__ndptr = __ndptr->__next_; __ndptr != nullptr &&
1792 __constrain_hash(__ndptr->__hash(), __bc) == __chash;1797 std::__constrain_hash(__ndptr->__hash(), __bc) == __chash;
1793 __ndptr = __ndptr->__next_)1798 __ndptr = __ndptr->__next_)
1794 {1799 {
1795 if (key_eq()(__ndptr->__upcast()->__value_, __value))1800 if (key_eq()(__ndptr->__upcast()->__value_, __value))
...@@ -1799,8 +1804,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare(...@@ -1799,8 +1804,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare(
1799 }1804 }
1800 if (size()+1 > __bc * max_load_factor() || __bc == 0)1805 if (size()+1 > __bc * max_load_factor() || __bc == 0)
1801 {1806 {
1802 __rehash_unique(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),1807 __rehash_unique(_VSTD::max<size_type>(2 * __bc + !std::__is_hash_power2(__bc),
1803 size_type(ceil(float(size() + 1) / max_load_factor()))));1808 size_type(std::ceil(float(size() + 1) / max_load_factor()))));
1804 }1809 }
1805 return nullptr;1810 return nullptr;
1806}1811}
...@@ -1816,7 +1821,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_perform(...@@ -1816,7 +1821,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_perform(
1816 __node_pointer __nd) _NOEXCEPT1821 __node_pointer __nd) _NOEXCEPT
1817{1822{
1818 size_type __bc = bucket_count();1823 size_type __bc = bucket_count();
1819 size_t __chash = __constrain_hash(__nd->__hash(), __bc);1824 size_t __chash = std::__constrain_hash(__nd->__hash(), __bc);
1820 // insert_after __bucket_list_[__chash], or __first_node if bucket is null1825 // insert_after __bucket_list_[__chash], or __first_node if bucket is null
1821 __next_pointer __pn = __bucket_list_[__chash];1826 __next_pointer __pn = __bucket_list_[__chash];
1822 if (__pn == nullptr)1827 if (__pn == nullptr)
...@@ -1827,7 +1832,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_perform(...@@ -1827,7 +1832,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_perform(
1827 // fix up __bucket_list_1832 // fix up __bucket_list_
1828 __bucket_list_[__chash] = __pn;1833 __bucket_list_[__chash] = __pn;
1829 if (__nd->__next_ != nullptr)1834 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();
1831 }1836 }
1832 else1837 else
1833 {1838 {
...@@ -1871,16 +1876,16 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_prepare(...@@ -1871,16 +1876,16 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_prepare(
1871 size_type __bc = bucket_count();1876 size_type __bc = bucket_count();
1872 if (size()+1 > __bc * max_load_factor() || __bc == 0)1877 if (size()+1 > __bc * max_load_factor() || __bc == 0)
1873 {1878 {
1874 __rehash_multi(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),1879 __rehash_multi(_VSTD::max<size_type>(2 * __bc + !std::__is_hash_power2(__bc),
1875 size_type(ceil(float(size() + 1) / max_load_factor()))));1880 size_type(std::ceil(float(size() + 1) / max_load_factor()))));
1876 __bc = bucket_count();1881 __bc = bucket_count();
1877 }1882 }
1878 size_t __chash = __constrain_hash(__cp_hash, __bc);1883 size_t __chash = std::__constrain_hash(__cp_hash, __bc);
1879 __next_pointer __pn = __bucket_list_[__chash];1884 __next_pointer __pn = __bucket_list_[__chash];
1880 if (__pn != nullptr)1885 if (__pn != nullptr)
1881 {1886 {
1882 for (bool __found = false; __pn->__next_ != nullptr &&1887 for (bool __found = false; __pn->__next_ != nullptr &&
1883 __constrain_hash(__pn->__next_->__hash(), __bc) == __chash;1888 std::__constrain_hash(__pn->__next_->__hash(), __bc) == __chash;
1884 __pn = __pn->__next_)1889 __pn = __pn->__next_)
1885 {1890 {
1886 // __found key_eq() action1891 // __found key_eq() action
...@@ -1912,7 +1917,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_perform(...@@ -1912,7 +1917,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_perform(
1912 __node_pointer __cp, __next_pointer __pn) _NOEXCEPT1917 __node_pointer __cp, __next_pointer __pn) _NOEXCEPT
1913{1918{
1914 size_type __bc = bucket_count();1919 size_type __bc = bucket_count();
1915 size_t __chash = __constrain_hash(__cp->__hash_, __bc);1920 size_t __chash = std::__constrain_hash(__cp->__hash_, __bc);
1916 if (__pn == nullptr)1921 if (__pn == nullptr)
1917 {1922 {
1918 __pn =__p1_.first().__ptr();1923 __pn =__p1_.first().__ptr();
...@@ -1921,7 +1926,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_perform(...@@ -1921,7 +1926,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_perform(
1921 // fix up __bucket_list_1926 // fix up __bucket_list_
1922 __bucket_list_[__chash] = __pn;1927 __bucket_list_[__chash] = __pn;
1923 if (__cp->__next_ != nullptr)1928 if (__cp->__next_ != nullptr)
1924 __bucket_list_[__constrain_hash(__cp->__next_->__hash(), __bc)]1929 __bucket_list_[std::__constrain_hash(__cp->__next_->__hash(), __bc)]
1925 = __cp->__ptr();1930 = __cp->__ptr();
1926 }1931 }
1927 else1932 else
...@@ -1930,7 +1935,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_perform(...@@ -1930,7 +1935,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_perform(
1930 __pn->__next_ = __cp->__ptr();1935 __pn->__next_ = __cp->__ptr();
1931 if (__cp->__next_ != nullptr)1936 if (__cp->__next_ != nullptr)
1932 {1937 {
1933 size_t __nhash = __constrain_hash(__cp->__next_->__hash(), __bc);1938 size_t __nhash = std::__constrain_hash(__cp->__next_->__hash(), __bc);
1934 if (__nhash != __chash)1939 if (__nhash != __chash)
1935 __bucket_list_[__nhash] = __cp->__ptr();1940 __bucket_list_[__nhash] = __cp->__ptr();
1936 }1941 }
...@@ -1965,11 +1970,11 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(...@@ -1965,11 +1970,11 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(
1965 size_type __bc = bucket_count();1970 size_type __bc = bucket_count();
1966 if (size()+1 > __bc * max_load_factor() || __bc == 0)1971 if (size()+1 > __bc * max_load_factor() || __bc == 0)
1967 {1972 {
1968 __rehash_multi(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),1973 __rehash_multi(_VSTD::max<size_type>(2 * __bc + !std::__is_hash_power2(__bc),
1969 size_type(ceil(float(size() + 1) / max_load_factor()))));1974 size_type(std::ceil(float(size() + 1) / max_load_factor()))));
1970 __bc = bucket_count();1975 __bc = bucket_count();
1971 }1976 }
1972 size_t __chash = __constrain_hash(__cp->__hash_, __bc);1977 size_t __chash = std::__constrain_hash(__cp->__hash_, __bc);
1973 __next_pointer __pp = __bucket_list_[__chash];1978 __next_pointer __pp = __bucket_list_[__chash];
1974 while (__pp->__next_ != __np)1979 while (__pp->__next_ != __np)
1975 __pp = __pp->__next_;1980 __pp = __pp->__next_;
...@@ -1996,12 +2001,12 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&...@@ -1996,12 +2001,12 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&
1996 size_t __chash;2001 size_t __chash;
1997 if (__bc != 0)2002 if (__bc != 0)
1998 {2003 {
1999 __chash = __constrain_hash(__hash, __bc);2004 __chash = std::__constrain_hash(__hash, __bc);
2000 __nd = __bucket_list_[__chash];2005 __nd = __bucket_list_[__chash];
2001 if (__nd != nullptr)2006 if (__nd != nullptr)
2002 {2007 {
2003 for (__nd = __nd->__next_; __nd != nullptr &&2008 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);
2005 __nd = __nd->__next_)2010 __nd = __nd->__next_)
2006 {2011 {
2007 if (key_eq()(__nd->__upcast()->__value_, __k))2012 if (key_eq()(__nd->__upcast()->__value_, __k))
...@@ -2013,10 +2018,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&...@@ -2013,10 +2018,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&
2013 __node_holder __h = __construct_node_hash(__hash, _VSTD::forward<_Args>(__args)...);2018 __node_holder __h = __construct_node_hash(__hash, _VSTD::forward<_Args>(__args)...);
2014 if (size()+1 > __bc * max_load_factor() || __bc == 0)2019 if (size()+1 > __bc * max_load_factor() || __bc == 0)
2015 {2020 {
2016 __rehash_unique(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),2021 __rehash_unique(_VSTD::max<size_type>(2 * __bc + !std::__is_hash_power2(__bc),
2017 size_type(ceil(float(size() + 1) / max_load_factor()))));2022 size_type(std::ceil(float(size() + 1) / max_load_factor()))));
2018 __bc = bucket_count();2023 __bc = bucket_count();
2019 __chash = __constrain_hash(__hash, __bc);2024 __chash = std::__constrain_hash(__hash, __bc);
2020 }2025 }
2021 // insert_after __bucket_list_[__chash], or __first_node if bucket is null2026 // insert_after __bucket_list_[__chash], or __first_node if bucket is null
2022 __next_pointer __pn = __bucket_list_[__chash];2027 __next_pointer __pn = __bucket_list_[__chash];
...@@ -2028,7 +2033,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&...@@ -2028,7 +2033,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&
2028 // fix up __bucket_list_2033 // fix up __bucket_list_
2029 __bucket_list_[__chash] = __pn;2034 __bucket_list_[__chash] = __pn;
2030 if (__h->__next_ != nullptr)2035 if (__h->__next_ != nullptr)
2031 __bucket_list_[__constrain_hash(__h->__next_->__hash(), __bc)]2036 __bucket_list_[std::__constrain_hash(__h->__next_->__hash(), __bc)]
2032 = __h.get()->__ptr();2037 = __h.get()->__ptr();
2033 }2038 }
2034 else2039 else
...@@ -2224,7 +2229,7 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK...@@ -2224,7 +2229,7 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
2224 if (__n == 1)2229 if (__n == 1)
2225 __n = 2;2230 __n = 2;
2226 else if (__n & (__n - 1))2231 else if (__n & (__n - 1))
2227 __n = __next_prime(__n);2232 __n = std::__next_prime(__n);
2228 size_type __bc = bucket_count();2233 size_type __bc = bucket_count();
2229 if (__n > __bc)2234 if (__n > __bc)
2230 __do_rehash<_UniqueKeys>(__n);2235 __do_rehash<_UniqueKeys>(__n);
...@@ -2233,8 +2238,8 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK...@@ -2233,8 +2238,8 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
2233 __n = _VSTD::max<size_type>2238 __n = _VSTD::max<size_type>
2234 (2239 (
2235 __n,2240 __n,
2236 __is_hash_power2(__bc) ? __next_hash_pow2(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()))) :
2237 __next_prime(size_t(ceil(float(size()) / max_load_factor())))2242 std::__next_prime(size_t(std::ceil(float(size()) / max_load_factor())))
2238 );2243 );
2239 if (__n < __bc)2244 if (__n < __bc)
2240 __do_rehash<_UniqueKeys>(__n);2245 __do_rehash<_UniqueKeys>(__n);
...@@ -2259,13 +2264,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__do_rehash(size_type __nbc)...@@ -2259,13 +2264,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__do_rehash(size_type __nbc)
2259 __next_pointer __cp = __pp->__next_;2264 __next_pointer __cp = __pp->__next_;
2260 if (__cp != nullptr)2265 if (__cp != nullptr)
2261 {2266 {
2262 size_type __chash = __constrain_hash(__cp->__hash(), __nbc);2267 size_type __chash = std::__constrain_hash(__cp->__hash(), __nbc);
2263 __bucket_list_[__chash] = __pp;2268 __bucket_list_[__chash] = __pp;
2264 size_type __phash = __chash;2269 size_type __phash = __chash;
2265 for (__pp = __cp, void(), __cp = __cp->__next_; __cp != nullptr;2270 for (__pp = __cp, void(), __cp = __cp->__next_; __cp != nullptr;
2266 __cp = __pp->__next_)2271 __cp = __pp->__next_)
2267 {2272 {
2268 __chash = __constrain_hash(__cp->__hash(), __nbc);2273 __chash = std::__constrain_hash(__cp->__hash(), __nbc);
2269 if (__chash == __phash)2274 if (__chash == __phash)
2270 __pp = __cp;2275 __pp = __cp;
2271 else2276 else
...@@ -2279,7 +2284,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__do_rehash(size_type __nbc)...@@ -2279,7 +2284,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__do_rehash(size_type __nbc)
2279 else2284 else
2280 {2285 {
2281 __next_pointer __np = __cp;2286 __next_pointer __np = __cp;
2282 if _LIBCPP_CONSTEXPR_AFTER_CXX14 (!_UniqueKeys)2287 if _LIBCPP_CONSTEXPR_SINCE_CXX17 (!_UniqueKeys)
2283 {2288 {
2284 for (; __np->__next_ != nullptr &&2289 for (; __np->__next_ != nullptr &&
2285 key_eq()(__cp->__upcast()->__value_,2290 key_eq()(__cp->__upcast()->__value_,
...@@ -2307,13 +2312,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k)...@@ -2307,13 +2312,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k)
2307 size_type __bc = bucket_count();2312 size_type __bc = bucket_count();
2308 if (__bc != 0)2313 if (__bc != 0)
2309 {2314 {
2310 size_t __chash = __constrain_hash(__hash, __bc);2315 size_t __chash = std::__constrain_hash(__hash, __bc);
2311 __next_pointer __nd = __bucket_list_[__chash];2316 __next_pointer __nd = __bucket_list_[__chash];
2312 if (__nd != nullptr)2317 if (__nd != nullptr)
2313 {2318 {
2314 for (__nd = __nd->__next_; __nd != nullptr &&2319 for (__nd = __nd->__next_; __nd != nullptr &&
2315 (__nd->__hash() == __hash2320 (__nd->__hash() == __hash
2316 || __constrain_hash(__nd->__hash(), __bc) == __chash);2321 || std::__constrain_hash(__nd->__hash(), __bc) == __chash);
2317 __nd = __nd->__next_)2322 __nd = __nd->__next_)
2318 {2323 {
2319 if ((__nd->__hash() == __hash)2324 if ((__nd->__hash() == __hash)
...@@ -2334,13 +2339,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const...@@ -2334,13 +2339,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const
2334 size_type __bc = bucket_count();2339 size_type __bc = bucket_count();
2335 if (__bc != 0)2340 if (__bc != 0)
2336 {2341 {
2337 size_t __chash = __constrain_hash(__hash, __bc);2342 size_t __chash = std::__constrain_hash(__hash, __bc);
2338 __next_pointer __nd = __bucket_list_[__chash];2343 __next_pointer __nd = __bucket_list_[__chash];
2339 if (__nd != nullptr)2344 if (__nd != nullptr)
2340 {2345 {
2341 for (__nd = __nd->__next_; __nd != nullptr &&2346 for (__nd = __nd->__next_; __nd != nullptr &&
2342 (__hash == __nd->__hash()2347 (__hash == __nd->__hash()
2343 || __constrain_hash(__nd->__hash(), __bc) == __chash);2348 || std::__constrain_hash(__nd->__hash(), __bc) == __chash);
2344 __nd = __nd->__next_)2349 __nd = __nd->__next_)
2345 {2350 {
2346 if ((__nd->__hash() == __hash)2351 if ((__nd->__hash() == __hash)
...@@ -2462,7 +2467,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT...@@ -2462,7 +2467,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT
2462 // current node2467 // current node
2463 __next_pointer __cn = __p.__node_;2468 __next_pointer __cn = __p.__node_;
2464 size_type __bc = bucket_count();2469 size_type __bc = bucket_count();
2465 size_t __chash = __constrain_hash(__cn->__hash(), __bc);2470 size_t __chash = std::__constrain_hash(__cn->__hash(), __bc);
2466 // find previous node2471 // find previous node
2467 __next_pointer __pn = __bucket_list_[__chash];2472 __next_pointer __pn = __bucket_list_[__chash];
2468 for (; __pn->__next_ != __cn; __pn = __pn->__next_)2473 for (; __pn->__next_ != __cn; __pn = __pn->__next_)
...@@ -2471,16 +2476,16 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT...@@ -2471,16 +2476,16 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT
2471 // if __pn is not in same bucket (before begin is not in same bucket) &&2476 // if __pn is not in same bucket (before begin is not in same bucket) &&
2472 // if __cn->__next_ is not in same bucket (nullptr is not in same bucket)2477 // if __cn->__next_ is not in same bucket (nullptr is not in same bucket)
2473 if (__pn == __p1_.first().__ptr()2478 if (__pn == __p1_.first().__ptr()
2474 || __constrain_hash(__pn->__hash(), __bc) != __chash)2479 || std::__constrain_hash(__pn->__hash(), __bc) != __chash)
2475 {2480 {
2476 if (__cn->__next_ == nullptr2481 if (__cn->__next_ == nullptr
2477 || __constrain_hash(__cn->__next_->__hash(), __bc) != __chash)2482 || std::__constrain_hash(__cn->__next_->__hash(), __bc) != __chash)
2478 __bucket_list_[__chash] = nullptr;2483 __bucket_list_[__chash] = nullptr;
2479 }2484 }
2480 // if __cn->__next_ is not in same bucket (nullptr is in same bucket)2485 // if __cn->__next_ is not in same bucket (nullptr is in same bucket)
2481 if (__cn->__next_ != nullptr)2486 if (__cn->__next_ != nullptr)
2482 {2487 {
2483 size_t __nhash = __constrain_hash(__cn->__next_->__hash(), __bc);2488 size_t __nhash = std::__constrain_hash(__cn->__next_->__hash(), __bc);
2484 if (__nhash != __chash)2489 if (__nhash != __chash)
2485 __bucket_list_[__nhash] = __pn;2490 __bucket_list_[__nhash] = __pn;
2486 }2491 }
...@@ -2634,10 +2639,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)...@@ -2634,10 +2639,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
2634 __p2_.swap(__u.__p2_);2639 __p2_.swap(__u.__p2_);
2635 __p3_.swap(__u.__p3_);2640 __p3_.swap(__u.__p3_);
2636 if (size() > 0)2641 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())] =
2638 __p1_.first().__ptr();2643 __p1_.first().__ptr();
2639 if (__u.size() > 0)2644 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())] =
2641 __u.__p1_.first().__ptr();2646 __u.__p1_.first().__ptr();
2642 std::__debug_db_swap(this, std::addressof(__u));2647 std::__debug_db_swap(this, std::addressof(__u));
2643}2648}
...@@ -2654,8 +2659,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::bucket_size(size_type __n) const...@@ -2654,8 +2659,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::bucket_size(size_type __n) const
2654 if (__np != nullptr)2659 if (__np != nullptr)
2655 {2660 {
2656 for (__np = __np->__next_; __np != nullptr &&2661 for (__np = __np->__next_; __np != nullptr &&
2657 __constrain_hash(__np->__hash(), __bc) == __n;2662 std::__constrain_hash(__np->__hash(), __bc) == __n;
2658 __np = __np->__next_, (void) ++__r)2663 __np = __np->__next_, (void) ++__r)
2659 ;2664 ;
2660 }2665 }
2661 return __r;2666 return __r;
lib/libcxx/include/__iterator/access.h+8-8
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <class _Tp, size_t _Np>22template <class _Tp, size_t _Np>
23_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1123_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
24_Tp*24_Tp*
25begin(_Tp (&__array)[_Np])25begin(_Tp (&__array)[_Np])
26{26{
...@@ -28,7 +28,7 @@ begin(_Tp (&__array)[_Np])...@@ -28,7 +28,7 @@ begin(_Tp (&__array)[_Np])
28}28}
2929
30template <class _Tp, size_t _Np>30template <class _Tp, size_t _Np>
31_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1131_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
32_Tp*32_Tp*
33end(_Tp (&__array)[_Np])33end(_Tp (&__array)[_Np])
34{34{
...@@ -38,7 +38,7 @@ end(_Tp (&__array)[_Np])...@@ -38,7 +38,7 @@ end(_Tp (&__array)[_Np])
38#if !defined(_LIBCPP_CXX03_LANG)38#if !defined(_LIBCPP_CXX03_LANG)
3939
40template <class _Cp>40template <class _Cp>
41_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1441_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
42auto42auto
43begin(_Cp& __c) -> decltype(__c.begin())43begin(_Cp& __c) -> decltype(__c.begin())
44{44{
...@@ -46,7 +46,7 @@ begin(_Cp& __c) -> decltype(__c.begin())...@@ -46,7 +46,7 @@ begin(_Cp& __c) -> decltype(__c.begin())
46}46}
4747
48template <class _Cp>48template <class _Cp>
49_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1449_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
50auto50auto
51begin(const _Cp& __c) -> decltype(__c.begin())51begin(const _Cp& __c) -> decltype(__c.begin())
52{52{
...@@ -54,7 +54,7 @@ begin(const _Cp& __c) -> decltype(__c.begin())...@@ -54,7 +54,7 @@ begin(const _Cp& __c) -> decltype(__c.begin())
54}54}
5555
56template <class _Cp>56template <class _Cp>
57_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1457_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
58auto58auto
59end(_Cp& __c) -> decltype(__c.end())59end(_Cp& __c) -> decltype(__c.end())
60{60{
...@@ -62,7 +62,7 @@ end(_Cp& __c) -> decltype(__c.end())...@@ -62,7 +62,7 @@ end(_Cp& __c) -> decltype(__c.end())
62}62}
6363
64template <class _Cp>64template <class _Cp>
65_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1465_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
66auto66auto
67end(const _Cp& __c) -> decltype(__c.end())67end(const _Cp& __c) -> decltype(__c.end())
68{68{
...@@ -72,14 +72,14 @@ end(const _Cp& __c) -> decltype(__c.end())...@@ -72,14 +72,14 @@ end(const _Cp& __c) -> decltype(__c.end())
72#if _LIBCPP_STD_VER > 1172#if _LIBCPP_STD_VER > 11
7373
74template <class _Cp>74template <class _Cp>
75_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1175_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
76auto cbegin(const _Cp& __c) -> decltype(_VSTD::begin(__c))76auto cbegin(const _Cp& __c) -> decltype(_VSTD::begin(__c))
77{77{
78 return _VSTD::begin(__c);78 return _VSTD::begin(__c);
79}79}
8080
81template <class _Cp>81template <class _Cp>
82_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1182_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
83auto cend(const _Cp& __c) -> decltype(_VSTD::end(__c))83auto cend(const _Cp& __c) -> decltype(_VSTD::end(__c))
84{84{
85 return _VSTD::end(__c);85 return _VSTD::end(__c);
lib/libcxx/include/__iterator/advance.h+13-9
...@@ -11,16 +11,20 @@...@@ -11,16 +11,20 @@
11#define _LIBCPP___ITERATOR_ADVANCE_H11#define _LIBCPP___ITERATOR_ADVANCE_H
1212
13#include <__assert>13#include <__assert>
14#include <__concepts/assignable.h>
15#include <__concepts/same_as.h>
14#include <__config>16#include <__config>
15#include <__iterator/concepts.h>17#include <__iterator/concepts.h>
16#include <__iterator/incrementable_traits.h>18#include <__iterator/incrementable_traits.h>
17#include <__iterator/iterator_traits.h>19#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>
18#include <__utility/move.h>24#include <__utility/move.h>
19#include <__utility/unreachable.h>25#include <__utility/unreachable.h>
20#include <concepts>
21#include <cstdlib>26#include <cstdlib>
22#include <limits>27#include <limits>
23#include <type_traits>
2428
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26# pragma GCC system_header30# pragma GCC system_header
...@@ -29,14 +33,14 @@...@@ -29,14 +33,14 @@
29_LIBCPP_BEGIN_NAMESPACE_STD33_LIBCPP_BEGIN_NAMESPACE_STD
3034
31template <class _InputIter>35template <class _InputIter>
32_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1436_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
33void __advance(_InputIter& __i, typename iterator_traits<_InputIter>::difference_type __n, input_iterator_tag) {37void __advance(_InputIter& __i, typename iterator_traits<_InputIter>::difference_type __n, input_iterator_tag) {
34 for (; __n > 0; --__n)38 for (; __n > 0; --__n)
35 ++__i;39 ++__i;
36}40}
3741
38template <class _BiDirIter>42template <class _BiDirIter>
39_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1443_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
40void __advance(_BiDirIter& __i, typename iterator_traits<_BiDirIter>::difference_type __n, bidirectional_iterator_tag) {44void __advance(_BiDirIter& __i, typename iterator_traits<_BiDirIter>::difference_type __n, bidirectional_iterator_tag) {
41 if (__n >= 0)45 if (__n >= 0)
42 for (; __n > 0; --__n)46 for (; __n > 0; --__n)
...@@ -47,16 +51,16 @@ void __advance(_BiDirIter& __i, typename iterator_traits<_BiDirIter>::difference...@@ -47,16 +51,16 @@ void __advance(_BiDirIter& __i, typename iterator_traits<_BiDirIter>::difference
47}51}
4852
49template <class _RandIter>53template <class _RandIter>
50_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1454_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
51void __advance(_RandIter& __i, typename iterator_traits<_RandIter>::difference_type __n, random_access_iterator_tag) {55void __advance(_RandIter& __i, typename iterator_traits<_RandIter>::difference_type __n, random_access_iterator_tag) {
52 __i += __n;56 __i += __n;
53}57}
5458
55template <59template <
56 class _InputIter, class _Distance,60 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>())),
58 class = __enable_if_t<is_integral<_IntegralDistance>::value> >62 class = __enable_if_t<is_integral<_IntegralDistance>::value> >
59_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1463_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
60void advance(_InputIter& __i, _Distance __orig_n) {64void advance(_InputIter& __i, _Distance __orig_n) {
61 typedef typename iterator_traits<_InputIter>::difference_type _Difference;65 typedef typename iterator_traits<_InputIter>::difference_type _Difference;
62 _Difference __n = static_cast<_Difference>(_VSTD::__convert_to_integral(__orig_n));66 _Difference __n = static_cast<_Difference>(_VSTD::__convert_to_integral(__orig_n));
...@@ -65,7 +69,7 @@ void advance(_InputIter& __i, _Distance __orig_n) {...@@ -65,7 +69,7 @@ void advance(_InputIter& __i, _Distance __orig_n) {
65 _VSTD::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());69 _VSTD::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());
66}70}
6771
68#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)72#if _LIBCPP_STD_VER > 17
6973
70// [range.iter.op.advance]74// [range.iter.op.advance]
7175
...@@ -192,7 +196,7 @@ inline namespace __cpo {...@@ -192,7 +196,7 @@ inline namespace __cpo {
192} // namespace __cpo196} // namespace __cpo
193} // namespace ranges197} // namespace ranges
194198
195#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)199#endif // _LIBCPP_STD_VER > 17
196200
197_LIBCPP_END_NAMESPACE_STD201_LIBCPP_END_NAMESPACE_STD
198202
lib/libcxx/include/__iterator/back_insert_iterator.h+9-8
...@@ -45,22 +45,23 @@ public:...@@ -45,22 +45,23 @@ public:
45 typedef void reference;45 typedef void reference;
46 typedef _Container container_type;46 typedef _Container container_type;
4747
48 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}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_AFTER_CXX17 back_insert_iterator& operator=(const typename _Container::value_type& __value)49 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator& operator=(const typename _Container::value_type& __value)
50 {container->push_back(__value); return *this;}50 {container->push_back(__value); return *this;}
51#ifndef _LIBCPP_CXX03_LANG51#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)
53 {container->push_back(_VSTD::move(__value)); return *this;}53 {container->push_back(_VSTD::move(__value)); return *this;}
54#endif // _LIBCPP_CXX03_LANG54#endif // _LIBCPP_CXX03_LANG
55 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator*() {return *this;}55 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator& operator*() {return *this;}
56 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 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_AFTER_CXX17 back_insert_iterator operator++(int) {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; }
60};60};
61_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(back_insert_iterator);
6162
62template <class _Container>63template <class _Container>
63inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1764inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
64back_insert_iterator<_Container>65back_insert_iterator<_Container>
65back_inserter(_Container& __x)66back_inserter(_Container& __x)
66{67{
lib/libcxx/include/__iterator/bounded_iter.h+17-15
...@@ -14,8 +14,10 @@...@@ -14,8 +14,10 @@
14#include <__config>14#include <__config>
15#include <__iterator/iterator_traits.h>15#include <__iterator/iterator_traits.h>
16#include <__memory/pointer_traits.h>16#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>
17#include <__utility/move.h>20#include <__utility/move.h>
18#include <type_traits>
1921
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header23# pragma GCC system_header
...@@ -73,7 +75,7 @@ private:...@@ -73,7 +75,7 @@ private:
73 //75 //
74 // Since it is non-standard for iterators to have this constructor, __bounded_iter must76 // Since it is non-standard for iterators to have this constructor, __bounded_iter must
75 // be created via `std::__make_bounded_iter`.77 // 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(
77 _Iterator __current, _Iterator __begin, _Iterator __end)79 _Iterator __current, _Iterator __begin, _Iterator __end)
78 : __current_(__current), __begin_(__begin), __end_(__end) {80 : __current_(__current), __begin_(__begin), __end_(__end) {
79 _LIBCPP_ASSERT(__begin <= __end, "__bounded_iter(current, begin, end): [begin, end) is not a valid range");81 _LIBCPP_ASSERT(__begin <= __end, "__bounded_iter(current, begin, end): [begin, end) is not a valid range");
...@@ -86,19 +88,19 @@ public:...@@ -86,19 +88,19 @@ public:
86 // Dereference and indexing operations.88 // Dereference and indexing operations.
87 //89 //
88 // These operations check that the iterator is dereferenceable, that is within [begin, end).90 // 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 {
90 _LIBCPP_ASSERT(92 _LIBCPP_ASSERT(
91 __in_bounds(__current_), "__bounded_iter::operator*: Attempt to dereference an out-of-range iterator");93 __in_bounds(__current_), "__bounded_iter::operator*: Attempt to dereference an out-of-range iterator");
92 return *__current_;94 return *__current_;
93 }95 }
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 {
96 _LIBCPP_ASSERT(98 _LIBCPP_ASSERT(
97 __in_bounds(__current_), "__bounded_iter::operator->: Attempt to dereference an out-of-range iterator");99 __in_bounds(__current_), "__bounded_iter::operator->: Attempt to dereference an out-of-range iterator");
98 return std::__to_address(__current_);100 return std::__to_address(__current_);
99 }101 }
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 {
102 _LIBCPP_ASSERT(104 _LIBCPP_ASSERT(
103 __in_bounds(__current_ + __n), "__bounded_iter::operator[]: Attempt to index an iterator out-of-range");105 __in_bounds(__current_ + __n), "__bounded_iter::operator[]: Attempt to index an iterator out-of-range");
104 return __current_[__n];106 return __current_[__n];
...@@ -108,54 +110,54 @@ public:...@@ -108,54 +110,54 @@ public:
108 //110 //
109 // These operations do not check that the resulting iterator is within the bounds, since that111 // These operations do not check that the resulting iterator is within the bounds, since that
110 // would make it impossible to create a past-the-end iterator.112 // 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 {
112 ++__current_;114 ++__current_;
113 return *this;115 return *this;
114 }116 }
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 {
116 __bounded_iter __tmp(*this);118 __bounded_iter __tmp(*this);
117 ++*this;119 ++*this;
118 return __tmp;120 return __tmp;
119 }121 }
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 {
122 --__current_;124 --__current_;
123 return *this;125 return *this;
124 }126 }
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 {
126 __bounded_iter __tmp(*this);128 __bounded_iter __tmp(*this);
127 --*this;129 --*this;
128 return __tmp;130 return __tmp;
129 }131 }
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 {
132 __current_ += __n;134 __current_ += __n;
133 return *this;135 return *this;
134 }136 }
135 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend __bounded_iter137 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __bounded_iter
136 operator+(__bounded_iter const& __self, difference_type __n) _NOEXCEPT {138 operator+(__bounded_iter const& __self, difference_type __n) _NOEXCEPT {
137 __bounded_iter __tmp(__self);139 __bounded_iter __tmp(__self);
138 __tmp += __n;140 __tmp += __n;
139 return __tmp;141 return __tmp;
140 }142 }
141 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend __bounded_iter143 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __bounded_iter
142 operator+(difference_type __n, __bounded_iter const& __self) _NOEXCEPT {144 operator+(difference_type __n, __bounded_iter const& __self) _NOEXCEPT {
143 __bounded_iter __tmp(__self);145 __bounded_iter __tmp(__self);
144 __tmp += __n;146 __tmp += __n;
145 return __tmp;147 return __tmp;
146 }148 }
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 {
149 __current_ -= __n;151 __current_ -= __n;
150 return *this;152 return *this;
151 }153 }
152 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend __bounded_iter154 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __bounded_iter
153 operator-(__bounded_iter const& __self, difference_type __n) _NOEXCEPT {155 operator-(__bounded_iter const& __self, difference_type __n) _NOEXCEPT {
154 __bounded_iter __tmp(__self);156 __bounded_iter __tmp(__self);
155 __tmp -= __n;157 __tmp -= __n;
156 return __tmp;158 return __tmp;
157 }159 }
158 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend difference_type160 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend difference_type
159 operator-(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {161 operator-(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
160 return __x.__current_ - __y.__current_;162 return __x.__current_ - __y.__current_;
161 }163 }
lib/libcxx/include/__iterator/common_iterator.h+25-14
...@@ -11,6 +11,13 @@...@@ -11,6 +11,13 @@
11#define _LIBCPP___ITERATOR_COMMON_ITERATOR_H11#define _LIBCPP___ITERATOR_COMMON_ITERATOR_H
1212
13#include <__assert>13#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>
14#include <__config>21#include <__config>
15#include <__iterator/concepts.h>22#include <__iterator/concepts.h>
16#include <__iterator/incrementable_traits.h>23#include <__iterator/incrementable_traits.h>
...@@ -18,7 +25,8 @@...@@ -18,7 +25,8 @@
18#include <__iterator/iter_swap.h>25#include <__iterator/iter_swap.h>
19#include <__iterator/iterator_traits.h>26#include <__iterator/iterator_traits.h>
20#include <__iterator/readable_traits.h>27#include <__iterator/readable_traits.h>
21#include <concepts>28#include <__type_traits/is_pointer.h>
29#include <__utility/declval.h>
22#include <variant>30#include <variant>
2331
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)32#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -95,14 +103,14 @@ public:...@@ -95,14 +103,14 @@ public:
95103
96 constexpr decltype(auto) operator*()104 constexpr decltype(auto) operator*()
97 {105 {
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");
99 return *_VSTD::__unchecked_get<_Iter>(__hold_);107 return *_VSTD::__unchecked_get<_Iter>(__hold_);
100 }108 }
101109
102 constexpr decltype(auto) operator*() const110 constexpr decltype(auto) operator*() const
103 requires __dereferenceable<const _Iter>111 requires __dereferenceable<const _Iter>
104 {112 {
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");
106 return *_VSTD::__unchecked_get<_Iter>(__hold_);114 return *_VSTD::__unchecked_get<_Iter>(__hold_);
107 }115 }
108116
...@@ -113,7 +121,7 @@ public:...@@ -113,7 +121,7 @@ public:
113 is_reference_v<iter_reference_t<_I2>> ||121 is_reference_v<iter_reference_t<_I2>> ||
114 constructible_from<iter_value_t<_I2>, iter_reference_t<_I2>>)122 constructible_from<iter_value_t<_I2>, iter_reference_t<_I2>>)
115 {123 {
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");
117 if constexpr (is_pointer_v<_Iter> || requires(const _Iter& __i) { __i.operator->(); }) {125 if constexpr (is_pointer_v<_Iter> || requires(const _Iter& __i) { __i.operator->(); }) {
118 return _VSTD::__unchecked_get<_Iter>(__hold_);126 return _VSTD::__unchecked_get<_Iter>(__hold_);
119 } else if constexpr (is_reference_v<iter_reference_t<_Iter>>) {127 } else if constexpr (is_reference_v<iter_reference_t<_Iter>>) {
...@@ -125,12 +133,12 @@ public:...@@ -125,12 +133,12 @@ public:
125 }133 }
126134
127 common_iterator& operator++() {135 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");
129 ++_VSTD::__unchecked_get<_Iter>(__hold_); return *this;137 ++_VSTD::__unchecked_get<_Iter>(__hold_); return *this;
130 }138 }
131139
132 decltype(auto) operator++(int) {140 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");
134 if constexpr (forward_iterator<_Iter>) {142 if constexpr (forward_iterator<_Iter>) {
135 auto __tmp = *this;143 auto __tmp = *this;
136 ++*this;144 ++*this;
...@@ -147,6 +155,7 @@ public:...@@ -147,6 +155,7 @@ public:
147155
148 template<class _I2, sentinel_for<_Iter> _S2>156 template<class _I2, sentinel_for<_Iter> _S2>
149 requires sentinel_for<_Sent, _I2>157 requires sentinel_for<_Sent, _I2>
158 _LIBCPP_HIDE_FROM_ABI
150 friend constexpr bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) {159 friend constexpr bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) {
151 _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");160 _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");
152 _LIBCPP_ASSERT(!__y.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");161 _LIBCPP_ASSERT(!__y.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");
...@@ -165,6 +174,7 @@ public:...@@ -165,6 +174,7 @@ public:
165174
166 template<class _I2, sentinel_for<_Iter> _S2>175 template<class _I2, sentinel_for<_Iter> _S2>
167 requires sentinel_for<_Sent, _I2> && equality_comparable_with<_Iter, _I2>176 requires sentinel_for<_Sent, _I2> && equality_comparable_with<_Iter, _I2>
177 _LIBCPP_HIDE_FROM_ABI
168 friend constexpr bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) {178 friend constexpr bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) {
169 _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");179 _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");
170 _LIBCPP_ASSERT(!__y.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");180 _LIBCPP_ASSERT(!__y.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");
...@@ -186,6 +196,7 @@ public:...@@ -186,6 +196,7 @@ public:
186196
187 template<sized_sentinel_for<_Iter> _I2, sized_sentinel_for<_Iter> _S2>197 template<sized_sentinel_for<_Iter> _I2, sized_sentinel_for<_Iter> _S2>
188 requires sized_sentinel_for<_Sent, _I2>198 requires sized_sentinel_for<_Sent, _I2>
199 _LIBCPP_HIDE_FROM_ABI
189 friend constexpr iter_difference_t<_I2> operator-(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) {200 friend constexpr iter_difference_t<_I2> operator-(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) {
190 _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception(), "Attempted to subtract from a valueless common_iterator");201 _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception(), "Attempted to subtract from a valueless common_iterator");
191 _LIBCPP_ASSERT(!__y.__hold_.valueless_by_exception(), "Attempted to subtract a valueless common_iterator");202 _LIBCPP_ASSERT(!__y.__hold_.valueless_by_exception(), "Attempted to subtract a valueless common_iterator");
...@@ -205,20 +216,20 @@ public:...@@ -205,20 +216,20 @@ public:
205 return _VSTD::__unchecked_get<_Sent>(__x.__hold_) - _VSTD::__unchecked_get<_I2>(__y.__hold_);216 return _VSTD::__unchecked_get<_Sent>(__x.__hold_) - _VSTD::__unchecked_get<_I2>(__y.__hold_);
206 }217 }
207218
208 friend constexpr iter_rvalue_reference_t<_Iter> iter_move(const common_iterator& __i)219 _LIBCPP_HIDE_FROM_ABI friend constexpr iter_rvalue_reference_t<_Iter> iter_move(const common_iterator& __i)
209 noexcept(noexcept(ranges::iter_move(declval<const _Iter&>())))220 noexcept(noexcept(ranges::iter_move(std::declval<const _Iter&>())))
210 requires input_iterator<_Iter>221 requires input_iterator<_Iter>
211 {222 {
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");
213 return ranges::iter_move( _VSTD::__unchecked_get<_Iter>(__i.__hold_));224 return ranges::iter_move( _VSTD::__unchecked_get<_Iter>(__i.__hold_));
214 }225 }
215226
216 template<indirectly_swappable<_Iter> _I2, class _S2>227 template<indirectly_swappable<_Iter> _I2, class _S2>
217 friend constexpr void iter_swap(const common_iterator& __x, const common_iterator<_I2, _S2>& __y)228 _LIBCPP_HIDE_FROM_ABI 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&>())))229 noexcept(noexcept(ranges::iter_swap(std::declval<const _Iter&>(), std::declval<const _I2&>())))
219 {230 {
220 _LIBCPP_ASSERT(holds_alternative<_Iter>(__x.__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");
221 _LIBCPP_ASSERT(holds_alternative<_I2>(__y.__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");
222 return ranges::iter_swap(_VSTD::__unchecked_get<_Iter>(__x.__hold_), _VSTD::__unchecked_get<_I2>(__y.__hold_));233 return ranges::iter_swap(_VSTD::__unchecked_get<_Iter>(__x.__hold_), _VSTD::__unchecked_get<_I2>(__y.__hold_));
223 }234 }
224};235};
...@@ -246,7 +257,7 @@ struct __arrow_type_or_void {...@@ -246,7 +257,7 @@ struct __arrow_type_or_void {
246template<class _Iter, class _Sent>257template<class _Iter, class _Sent>
247 requires __common_iter_has_ptr_op<_Iter, _Sent>258 requires __common_iter_has_ptr_op<_Iter, _Sent>
248struct __arrow_type_or_void<_Iter, _Sent> {259struct __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->());
250};261};
251262
252template<input_iterator _Iter, class _Sent>263template<input_iterator _Iter, class _Sent>
lib/libcxx/include/__iterator/concepts.h+22-2
...@@ -10,15 +10,35 @@...@@ -10,15 +10,35 @@
10#ifndef _LIBCPP___ITERATOR_CONCEPTS_H10#ifndef _LIBCPP___ITERATOR_CONCEPTS_H
11#define _LIBCPP___ITERATOR_CONCEPTS_H11#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>
13#include <__config>28#include <__config>
29#include <__functional/invoke.h>
14#include <__iterator/incrementable_traits.h>30#include <__iterator/incrementable_traits.h>
15#include <__iterator/iter_move.h>31#include <__iterator/iter_move.h>
16#include <__iterator/iterator_traits.h>32#include <__iterator/iterator_traits.h>
17#include <__iterator/readable_traits.h>33#include <__iterator/readable_traits.h>
18#include <__memory/pointer_traits.h>34#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>
19#include <__utility/forward.h>41#include <__utility/forward.h>
20#include <concepts>
21#include <type_traits>
2242
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)43#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header44# pragma GCC system_header
lib/libcxx/include/__iterator/counted_iterator.h+10-3
...@@ -6,10 +6,16 @@...@@ -6,10 +6,16 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___ITERATOR_COUNTED_ITERATOR_H10#ifndef _LIBCPP___ITERATOR_COUNTED_ITERATOR_H
10#define _LIBCPP___ITERATOR_COUNTED_ITERATOR_H11#define _LIBCPP___ITERATOR_COUNTED_ITERATOR_H
1112
12#include <__assert>13#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>
13#include <__config>19#include <__config>
14#include <__iterator/concepts.h>20#include <__iterator/concepts.h>
15#include <__iterator/default_sentinel.h>21#include <__iterator/default_sentinel.h>
...@@ -19,10 +25,10 @@...@@ -19,10 +25,10 @@
19#include <__iterator/iterator_traits.h>25#include <__iterator/iterator_traits.h>
20#include <__iterator/readable_traits.h>26#include <__iterator/readable_traits.h>
21#include <__memory/pointer_traits.h>27#include <__memory/pointer_traits.h>
28#include <__type_traits/add_pointer.h>
29#include <__type_traits/conditional.h>
22#include <__utility/move.h>30#include <__utility/move.h>
23#include <compare>31#include <compare>
24#include <concepts>
25#include <type_traits>
2632
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)33#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header34# pragma GCC system_header
...@@ -263,7 +269,7 @@ public:...@@ -263,7 +269,7 @@ public:
263 }269 }
264270
265 template<common_with<_Iter> _I2>271 template<common_with<_Iter> _I2>
266 friend constexpr strong_ordering operator<=>(272 _LIBCPP_HIDE_FROM_ABI friend constexpr strong_ordering operator<=>(
267 const counted_iterator& __lhs, const counted_iterator<_I2>& __rhs)273 const counted_iterator& __lhs, const counted_iterator<_I2>& __rhs)
268 {274 {
269 return __rhs.__count_ <=> __lhs.__count_;275 return __rhs.__count_ <=> __lhs.__count_;
...@@ -288,6 +294,7 @@ public:...@@ -288,6 +294,7 @@ public:
288 return ranges::iter_swap(__x.__current_, __y.__current_);294 return ranges::iter_swap(__x.__current_, __y.__current_);
289 }295 }
290};296};
297_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(counted_iterator);
291298
292template<input_iterator _Iter>299template<input_iterator _Iter>
293 requires same_as<_ITER_TRAITS<_Iter>, iterator_traits<_Iter>>300 requires same_as<_ITER_TRAITS<_Iter>, iterator_traits<_Iter>>
lib/libcxx/include/__iterator/distance.h+8-7
...@@ -17,7 +17,8 @@...@@ -17,7 +17,8 @@
17#include <__ranges/access.h>17#include <__ranges/access.h>
18#include <__ranges/concepts.h>18#include <__ranges/concepts.h>
19#include <__ranges/size.h>19#include <__ranges/size.h>
20#include <type_traits>20#include <__type_traits/decay.h>
21#include <__type_traits/remove_cvref.h>
2122
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header24# pragma GCC system_header
...@@ -26,7 +27,7 @@...@@ -26,7 +27,7 @@
26_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2728
28template <class _InputIter>29template <class _InputIter>
29inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1430inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
30typename iterator_traits<_InputIter>::difference_type31typename iterator_traits<_InputIter>::difference_type
31__distance(_InputIter __first, _InputIter __last, input_iterator_tag)32__distance(_InputIter __first, _InputIter __last, input_iterator_tag)
32{33{
...@@ -37,7 +38,7 @@ __distance(_InputIter __first, _InputIter __last, input_iterator_tag)...@@ -37,7 +38,7 @@ __distance(_InputIter __first, _InputIter __last, input_iterator_tag)
37}38}
3839
39template <class _RandIter>40template <class _RandIter>
40inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1441inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
41typename iterator_traits<_RandIter>::difference_type42typename iterator_traits<_RandIter>::difference_type
42__distance(_RandIter __first, _RandIter __last, random_access_iterator_tag)43__distance(_RandIter __first, _RandIter __last, random_access_iterator_tag)
43{44{
...@@ -45,14 +46,14 @@ __distance(_RandIter __first, _RandIter __last, random_access_iterator_tag)...@@ -45,14 +46,14 @@ __distance(_RandIter __first, _RandIter __last, random_access_iterator_tag)
45}46}
4647
47template <class _InputIter>48template <class _InputIter>
48inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1449inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
49typename iterator_traits<_InputIter>::difference_type50typename iterator_traits<_InputIter>::difference_type
50distance(_InputIter __first, _InputIter __last)51distance(_InputIter __first, _InputIter __last)
51{52{
52 return _VSTD::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());53 return _VSTD::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());
53}54}
5455
55#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)56#if _LIBCPP_STD_VER > 17
5657
57// [range.iter.op.distance]58// [range.iter.op.distance]
5859
...@@ -75,7 +76,7 @@ struct __fn {...@@ -75,7 +76,7 @@ struct __fn {
75 template<class _Ip, sized_sentinel_for<decay_t<_Ip>> _Sp>76 template<class _Ip, sized_sentinel_for<decay_t<_Ip>> _Sp>
76 _LIBCPP_HIDE_FROM_ABI77 _LIBCPP_HIDE_FROM_ABI
77 constexpr iter_difference_t<_Ip> operator()(_Ip&& __first, _Sp __last) const {78 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>>) {
79 return __last - __first;80 return __last - __first;
80 } else {81 } else {
81 return __last - decay_t<_Ip>(__first);82 return __last - decay_t<_Ip>(__first);
...@@ -100,7 +101,7 @@ inline namespace __cpo {...@@ -100,7 +101,7 @@ inline namespace __cpo {
100} // namespace __cpo101} // namespace __cpo
101} // namespace ranges102} // namespace ranges
102103
103#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)104#endif // _LIBCPP_STD_VER > 17
104105
105_LIBCPP_END_NAMESPACE_STD106_LIBCPP_END_NAMESPACE_STD
106107
lib/libcxx/include/__iterator/front_insert_iterator.h+8-7
...@@ -45,20 +45,21 @@ public:...@@ -45,20 +45,21 @@ public:
45 typedef void reference;45 typedef void reference;
46 typedef _Container container_type;46 typedef _Container container_type;
4747
48 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit front_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}48 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 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)49 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 front_insert_iterator& operator=(const typename _Container::value_type& __value)
50 {container->push_front(__value); return *this;}50 {container->push_front(__value); return *this;}
51#ifndef _LIBCPP_CXX03_LANG51#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)
53 {container->push_front(_VSTD::move(__value)); return *this;}53 {container->push_front(_VSTD::move(__value)); return *this;}
54#endif // _LIBCPP_CXX03_LANG54#endif // _LIBCPP_CXX03_LANG
55 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator*() {return *this;}55 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 front_insert_iterator& operator*() {return *this;}
56 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 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_AFTER_CXX17 front_insert_iterator operator++(int) {return *this;}57 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 front_insert_iterator operator++(int) {return *this;}
58};58};
59_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(front_insert_iterator);
5960
60template <class _Container>61template <class _Container>
61inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1762inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
62front_insert_iterator<_Container>63front_insert_iterator<_Container>
63front_inserter(_Container& __x)64front_inserter(_Container& __x)
64{65{
lib/libcxx/include/__iterator/incrementable_traits.h+7-3
...@@ -10,11 +10,15 @@...@@ -10,11 +10,15 @@
10#ifndef _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H10#ifndef _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H
11#define _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H11#define _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H
1212
13#include <__concepts/arithmetic.h>
13#include <__config>14#include <__config>
15#include <__type_traits/conditional.h>
16#include <__type_traits/is_object.h>
14#include <__type_traits/is_primary_template.h>17#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>
16#include <cstddef>21#include <cstddef>
17#include <type_traits>
1822
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header24# pragma GCC system_header
...@@ -53,7 +57,7 @@ concept __has_integral_minus =...@@ -53,7 +57,7 @@ concept __has_integral_minus =
53template<__has_integral_minus _Tp>57template<__has_integral_minus _Tp>
54requires (!__has_member_difference_type<_Tp>)58requires (!__has_member_difference_type<_Tp>)
55struct incrementable_traits<_Tp> {59struct 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>())>;
57};61};
5862
59template <class>63template <class>
lib/libcxx/include/__iterator/insert_iterator.h+8-8
...@@ -24,7 +24,7 @@...@@ -24,7 +24,7 @@
2424
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)27#if _LIBCPP_STD_VER > 17
28template <class _Container>28template <class _Container>
29using __insert_iterator_iter_t = ranges::iterator_t<_Container>;29using __insert_iterator_iter_t = ranges::iterator_t<_Container>;
30#else30#else
...@@ -55,21 +55,21 @@ public:...@@ -55,21 +55,21 @@ public:
55 typedef void reference;55 typedef void reference;
56 typedef _Container container_type;56 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)
59 : container(_VSTD::addressof(__x)), iter(__i) {}59 : 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)
61 {iter = container->insert(iter, __value); ++iter; return *this;}61 {iter = container->insert(iter, __value); ++iter; return *this;}
62#ifndef _LIBCPP_CXX03_LANG62#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)
64 {iter = container->insert(iter, _VSTD::move(__value)); ++iter; return *this;}64 {iter = container->insert(iter, _VSTD::move(__value)); ++iter; return *this;}
65#endif // _LIBCPP_CXX03_LANG65#endif // _LIBCPP_CXX03_LANG
66 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator*() {return *this;}66 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 insert_iterator& operator*() {return *this;}
67 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator++() {return *this;}67 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 insert_iterator& operator++() {return *this;}
68 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator++(int) {return *this;}68 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 insert_iterator& operator++(int) {return *this;}
69};69};
7070
71template <class _Container>71template <class _Container>
72inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1772inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
73insert_iterator<_Container>73insert_iterator<_Container>
74inserter(_Container& __x, __insert_iterator_iter_t<_Container> __i)74inserter(_Container& __x, __insert_iterator_iter_t<_Container> __i)
75{75{
lib/libcxx/include/__iterator/iter_move.h+7-2
...@@ -13,9 +13,11 @@...@@ -13,9 +13,11 @@
13#include <__concepts/class_or_enum.h>13#include <__concepts/class_or_enum.h>
14#include <__config>14#include <__config>
15#include <__iterator/iterator_traits.h>15#include <__iterator/iterator_traits.h>
16#include <__type_traits/is_reference.h>
17#include <__type_traits/remove_cvref.h>
18#include <__utility/declval.h>
16#include <__utility/forward.h>19#include <__utility/forward.h>
17#include <__utility/move.h>20#include <__utility/move.h>
18#include <type_traits>
1921
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header23# pragma GCC system_header
...@@ -36,6 +38,7 @@ template <class _Tp>...@@ -36,6 +38,7 @@ template <class _Tp>
36concept __unqualified_iter_move =38concept __unqualified_iter_move =
37 __class_or_enum<remove_cvref_t<_Tp>> &&39 __class_or_enum<remove_cvref_t<_Tp>> &&
38 requires (_Tp&& __t) {40 requires (_Tp&& __t) {
41 // NOLINTNEXTLINE(libcpp-robust-against-adl) iter_swap ADL calls should only be made through ranges::iter_swap
39 iter_move(std::forward<_Tp>(__t));42 iter_move(std::forward<_Tp>(__t));
40 };43 };
4144
...@@ -59,6 +62,7 @@ concept __just_deref =...@@ -59,6 +62,7 @@ concept __just_deref =
59// [iterator.cust.move]62// [iterator.cust.move]
6063
61struct __fn {64struct __fn {
65 // NOLINTBEGIN(libcpp-robust-against-adl) iter_move ADL calls should only be made through ranges::iter_move
62 template<class _Ip>66 template<class _Ip>
63 requires __unqualified_iter_move<_Ip>67 requires __unqualified_iter_move<_Ip>
64 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Ip&& __i) const68 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Ip&& __i) const
...@@ -66,6 +70,7 @@ struct __fn {...@@ -66,6 +70,7 @@ struct __fn {
66 {70 {
67 return iter_move(std::forward<_Ip>(__i));71 return iter_move(std::forward<_Ip>(__i));
68 }72 }
73 // NOLINTEND(libcpp-robust-against-adl)
6974
70 template<class _Ip>75 template<class _Ip>
71 requires __move_deref<_Ip>76 requires __move_deref<_Ip>
...@@ -90,7 +95,7 @@ inline namespace __cpo {...@@ -90,7 +95,7 @@ inline namespace __cpo {
9095
91template<__dereferenceable _Tp>96template<__dereferenceable _Tp>
92 requires requires(_Tp& __t) { { ranges::iter_move(__t) } -> __can_reference; }97 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
95#endif // _LIBCPP_STD_VER > 17100#endif // _LIBCPP_STD_VER > 17
96101
lib/libcxx/include/__iterator/iter_swap.h+10-3
...@@ -6,18 +6,21 @@...@@ -6,18 +6,21 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___ITERATOR_ITER_SWAP_H10#ifndef _LIBCPP___ITERATOR_ITER_SWAP_H
10#define _LIBCPP___ITERATOR_ITER_SWAP_H11#define _LIBCPP___ITERATOR_ITER_SWAP_H
1112
13#include <__concepts/class_or_enum.h>
14#include <__concepts/swappable.h>
12#include <__config>15#include <__config>
13#include <__iterator/concepts.h>16#include <__iterator/concepts.h>
14#include <__iterator/iter_move.h>17#include <__iterator/iter_move.h>
15#include <__iterator/iterator_traits.h>18#include <__iterator/iterator_traits.h>
16#include <__iterator/readable_traits.h>19#include <__iterator/readable_traits.h>
20#include <__type_traits/remove_cvref.h>
21#include <__utility/declval.h>
17#include <__utility/forward.h>22#include <__utility/forward.h>
18#include <__utility/move.h>23#include <__utility/move.h>
19#include <concepts>
20#include <type_traits>
2124
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header26# pragma GCC system_header
...@@ -38,6 +41,7 @@ namespace __iter_swap {...@@ -38,6 +41,7 @@ namespace __iter_swap {
38 concept __unqualified_iter_swap =41 concept __unqualified_iter_swap =
39 (__class_or_enum<remove_cvref_t<_T1>> || __class_or_enum<remove_cvref_t<_T2>>) &&42 (__class_or_enum<remove_cvref_t<_T1>> || __class_or_enum<remove_cvref_t<_T2>>) &&
40 requires (_T1&& __x, _T2&& __y) {43 requires (_T1&& __x, _T2&& __y) {
44 // NOLINTNEXTLINE(libcpp-robust-against-adl) iter_swap ADL calls should only be made through ranges::iter_swap
41 iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y));45 iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y));
42 };46 };
4347
...@@ -46,7 +50,9 @@ namespace __iter_swap {...@@ -46,7 +50,9 @@ namespace __iter_swap {
46 indirectly_readable<_T1> && indirectly_readable<_T2> &&50 indirectly_readable<_T1> && indirectly_readable<_T2> &&
47 swappable_with<iter_reference_t<_T1>, iter_reference_t<_T2>>;51 swappable_with<iter_reference_t<_T1>, iter_reference_t<_T2>>;
4852
53
49 struct __fn {54 struct __fn {
55 // NOLINTBEGIN(libcpp-robust-against-adl) iter_swap ADL calls should only be made through ranges::iter_swap
50 template <class _T1, class _T2>56 template <class _T1, class _T2>
51 requires __unqualified_iter_swap<_T1, _T2>57 requires __unqualified_iter_swap<_T1, _T2>
52 _LIBCPP_HIDE_FROM_ABI58 _LIBCPP_HIDE_FROM_ABI
...@@ -55,6 +61,7 @@ namespace __iter_swap {...@@ -55,6 +61,7 @@ namespace __iter_swap {
55 {61 {
56 (void)iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y));62 (void)iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y));
57 }63 }
64 // NOLINTEND(libcpp-robust-against-adl)
5865
59 template <class _T1, class _T2>66 template <class _T1, class _T2>
60 requires (!__unqualified_iter_swap<_T1, _T2>) &&67 requires (!__unqualified_iter_swap<_T1, _T2>) &&
...@@ -75,7 +82,7 @@ namespace __iter_swap {...@@ -75,7 +82,7 @@ namespace __iter_swap {
75 constexpr void operator()(_T1&& __x, _T2&& __y) const82 constexpr void operator()(_T1&& __x, _T2&& __y) const
76 noexcept(noexcept(iter_value_t<_T2>(ranges::iter_move(__y))) &&83 noexcept(noexcept(iter_value_t<_T2>(ranges::iter_move(__y))) &&
77 noexcept(*__y = ranges::iter_move(__x)) &&84 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>>()))
79 {86 {
80 iter_value_t<_T2> __old(ranges::iter_move(__y));87 iter_value_t<_T2> __old(ranges::iter_move(__y));
81 *__y = ranges::iter_move(__x);88 *__y = ranges::iter_move(__x);
lib/libcxx/include/__iterator/iterator_traits.h+31-11
...@@ -10,12 +10,32 @@...@@ -10,12 +10,32 @@
10#ifndef _LIBCPP___ITERATOR_ITERATOR_TRAITS_H10#ifndef _LIBCPP___ITERATOR_ITERATOR_TRAITS_H
11#define _LIBCPP___ITERATOR_ITERATOR_TRAITS_H11#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>
13#include <__config>20#include <__config>
21#include <__fwd/pair.h>
14#include <__iterator/incrementable_traits.h>22#include <__iterator/incrementable_traits.h>
15#include <__iterator/readable_traits.h>23#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>
17#include <cstddef>38#include <cstddef>
18#include <type_traits>
1939
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)40#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header41# pragma GCC system_header
...@@ -40,7 +60,7 @@ concept __dereferenceable = requires(_Tp& __t) {...@@ -40,7 +60,7 @@ concept __dereferenceable = requires(_Tp& __t) {
4060
41// [iterator.traits]61// [iterator.traits]
42template<__dereferenceable _Tp>62template<__dereferenceable _Tp>
43using iter_reference_t = decltype(*declval<_Tp&>());63using iter_reference_t = decltype(*std::declval<_Tp&>());
4464
45#endif // _LIBCPP_STD_VER > 1765#endif // _LIBCPP_STD_VER > 17
4666
...@@ -107,11 +127,11 @@ struct __has_iterator_typedefs...@@ -107,11 +127,11 @@ struct __has_iterator_typedefs
107{127{
108private:128private:
109 template <class _Up> static false_type __test(...);129 template <class _Up> static false_type __test(...);
110 template <class _Up> static true_type __test(typename __void_t<typename _Up::iterator_category>::type* = 0,130 template <class _Up> static true_type __test(__void_t<typename _Up::iterator_category>* = nullptr,
111 typename __void_t<typename _Up::difference_type>::type* = 0,131 __void_t<typename _Up::difference_type>* = nullptr,
112 typename __void_t<typename _Up::value_type>::type* = 0,132 __void_t<typename _Up::value_type>* = nullptr,
113 typename __void_t<typename _Up::reference>::type* = 0,133 __void_t<typename _Up::reference>* = nullptr,
114 typename __void_t<typename _Up::pointer>::type* = 0);134 __void_t<typename _Up::pointer>* = nullptr);
115public:135public:
116 static const bool value = decltype(__test<_Tp>(0,0,0,0,0))::value;136 static const bool value = decltype(__test<_Tp>(0,0,0,0,0))::value;
117};137};
...@@ -253,7 +273,7 @@ struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> { using type = typ...@@ -253,7 +273,7 @@ struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> { using type = typ
253template<class _Ip>273template<class _Ip>
254 requires requires(_Ip& __i) { __i.operator->(); } && (!__has_member_pointer<_Ip>)274 requires requires(_Ip& __i) { __i.operator->(); } && (!__has_member_pointer<_Ip>)
255struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> {275struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> {
256 using type = decltype(declval<_Ip&>().operator->());276 using type = decltype(std::declval<_Ip&>().operator->());
257};277};
258278
259// Otherwise, `reference` names `iter-reference-t<I>`.279// Otherwise, `reference` names `iter-reference-t<I>`.
...@@ -407,7 +427,7 @@ requires is_object_v<_Tp>...@@ -407,7 +427,7 @@ requires is_object_v<_Tp>
407struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*>427struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*>
408{428{
409 typedef ptrdiff_t difference_type;429 typedef ptrdiff_t difference_type;
410 typedef typename remove_cv<_Tp>::type value_type;430 typedef __remove_cv_t<_Tp> value_type;
411 typedef _Tp* pointer;431 typedef _Tp* pointer;
412 typedef _Tp& reference;432 typedef _Tp& reference;
413 typedef random_access_iterator_tag iterator_category;433 typedef random_access_iterator_tag iterator_category;
...@@ -492,7 +512,7 @@ template<class _InputIterator>...@@ -492,7 +512,7 @@ template<class _InputIterator>
492using __iter_value_type = typename iterator_traits<_InputIterator>::value_type;512using __iter_value_type = typename iterator_traits<_InputIterator>::value_type;
493513
494template<class _InputIterator>514template<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
497template<class _InputIterator>517template<class _InputIterator>
498using __iter_mapped_type = typename iterator_traits<_InputIterator>::value_type::second_type;518using __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 @@...@@ -24,8 +24,16 @@
24#include <__iterator/iterator_traits.h>24#include <__iterator/iterator_traits.h>
25#include <__iterator/move_sentinel.h>25#include <__iterator/move_sentinel.h>
26#include <__iterator/readable_traits.h>26#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>
27#include <__utility/move.h>36#include <__utility/move.h>
28#include <type_traits>
2937
30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)38#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
31# pragma GCC system_header39# pragma GCC system_header
...@@ -49,7 +57,7 @@ struct __move_iter_category_base<_Iter> {...@@ -49,7 +57,7 @@ struct __move_iter_category_base<_Iter> {
4957
50template<class _Iter, class _Sent>58template<class _Iter, class _Sent>
51concept __move_iter_comparable = requires {59concept __move_iter_comparable = requires {
52 { declval<const _Iter&>() == declval<_Sent>() } -> convertible_to<bool>;60 { std::declval<const _Iter&>() == std::declval<_Sent>() } -> convertible_to<bool>;
53};61};
54#endif // _LIBCPP_STD_VER > 1762#endif // _LIBCPP_STD_VER > 17
5563
...@@ -82,18 +90,18 @@ public:...@@ -82,18 +90,18 @@ public:
82 typedef typename iterator_traits<iterator_type>::reference __reference;90 typedef typename iterator_traits<iterator_type>::reference __reference;
83 typedef typename conditional<91 typedef typename conditional<
84 is_reference<__reference>::value,92 is_reference<__reference>::value,
85 typename remove_reference<__reference>::type&&,93 __libcpp_remove_reference_t<__reference>&&,
86 __reference94 __reference
87 >::type reference;95 >::type reference;
88#endif // _LIBCPP_STD_VER > 1796#endif // _LIBCPP_STD_VER > 17
8997
90 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1498 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
91 explicit move_iterator(_Iter __i) : __current_(std::move(__i)) {}99 explicit move_iterator(_Iter __i) : __current_(std::move(__i)) {}
92100
93 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14101 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
94 move_iterator& operator++() { ++__current_; return *this; }102 move_iterator& operator++() { ++__current_; return *this; }
95103
96 _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14104 _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
97 pointer operator->() const { return __current_; }105 pointer operator->() const { return __current_; }
98106
99#if _LIBCPP_STD_VER > 17107#if _LIBCPP_STD_VER > 17
...@@ -133,13 +141,13 @@ public:...@@ -133,13 +141,13 @@ public:
133 _LIBCPP_HIDE_FROM_ABI constexpr141 _LIBCPP_HIDE_FROM_ABI constexpr
134 void operator++(int) { ++__current_; }142 void operator++(int) { ++__current_; }
135#else143#else
136 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14144 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
137 move_iterator() : __current_() {}145 move_iterator() : __current_() {}
138146
139 template <class _Up, class = __enable_if_t<147 template <class _Up, class = __enable_if_t<
140 !is_same<_Up, _Iter>::value && is_convertible<const _Up&, _Iter>::value148 !is_same<_Up, _Iter>::value && is_convertible<const _Up&, _Iter>::value
141 > >149 > >
142 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14150 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
143 move_iterator(const move_iterator<_Up>& __u) : __current_(__u.base()) {}151 move_iterator(const move_iterator<_Up>& __u) : __current_(__u.base()) {}
144152
145 template <class _Up, class = __enable_if_t<153 template <class _Up, class = __enable_if_t<
...@@ -147,35 +155,35 @@ public:...@@ -147,35 +155,35 @@ public:
147 is_convertible<const _Up&, _Iter>::value &&155 is_convertible<const _Up&, _Iter>::value &&
148 is_assignable<_Iter&, const _Up&>::value156 is_assignable<_Iter&, const _Up&>::value
149 > >157 > >
150 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14158 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
151 move_iterator& operator=(const move_iterator<_Up>& __u) {159 move_iterator& operator=(const move_iterator<_Up>& __u) {
152 __current_ = __u.base();160 __current_ = __u.base();
153 return *this;161 return *this;
154 }162 }
155163
156 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14164 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
157 _Iter base() const { return __current_; }165 _Iter base() const { return __current_; }
158166
159 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14167 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
160 reference operator*() const { return static_cast<reference>(*__current_); }168 reference operator*() const { return static_cast<reference>(*__current_); }
161 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14169 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
162 reference operator[](difference_type __n) const { return static_cast<reference>(__current_[__n]); }170 reference operator[](difference_type __n) const { return static_cast<reference>(__current_[__n]); }
163171
164 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14172 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
165 move_iterator operator++(int) { move_iterator __tmp(*this); ++__current_; return __tmp; }173 move_iterator operator++(int) { move_iterator __tmp(*this); ++__current_; return __tmp; }
166#endif // _LIBCPP_STD_VER > 17174#endif // _LIBCPP_STD_VER > 17
167175
168 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14176 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
169 move_iterator& operator--() { --__current_; return *this; }177 move_iterator& operator--() { --__current_; return *this; }
170 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14178 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
171 move_iterator operator--(int) { move_iterator __tmp(*this); --__current_; return __tmp; }179 move_iterator operator--(int) { move_iterator __tmp(*this); --__current_; return __tmp; }
172 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14180 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
173 move_iterator operator+(difference_type __n) const { return move_iterator(__current_ + __n); }181 move_iterator operator+(difference_type __n) const { return move_iterator(__current_ + __n); }
174 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14182 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
175 move_iterator& operator+=(difference_type __n) { __current_ += __n; return *this; }183 move_iterator& operator+=(difference_type __n) { __current_ += __n; return *this; }
176 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14184 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
177 move_iterator operator-(difference_type __n) const { return move_iterator(__current_ - __n); }185 move_iterator operator-(difference_type __n) const { return move_iterator(__current_ - __n); }
178 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14186 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
179 move_iterator& operator-=(difference_type __n) { __current_ -= __n; return *this; }187 move_iterator& operator-=(difference_type __n) { __current_ -= __n; return *this; }
180188
181#if _LIBCPP_STD_VER > 17189#if _LIBCPP_STD_VER > 17
...@@ -222,9 +230,10 @@ private:...@@ -222,9 +230,10 @@ private:
222230
223 _Iter __current_;231 _Iter __current_;
224};232};
233_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(move_iterator);
225234
226template <class _Iter1, class _Iter2>235template <class _Iter1, class _Iter2>
227inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14236inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
228bool operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)237bool operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
229{238{
230 return __x.base() == __y.base();239 return __x.base() == __y.base();
...@@ -232,7 +241,7 @@ bool operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& _...@@ -232,7 +241,7 @@ bool operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& _
232241
233#if _LIBCPP_STD_VER <= 17242#if _LIBCPP_STD_VER <= 17
234template <class _Iter1, class _Iter2>243template <class _Iter1, class _Iter2>
235inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14244inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
236bool operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)245bool operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
237{246{
238 return __x.base() != __y.base();247 return __x.base() != __y.base();
...@@ -240,28 +249,28 @@ bool operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& _...@@ -240,28 +249,28 @@ bool operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& _
240#endif // _LIBCPP_STD_VER <= 17249#endif // _LIBCPP_STD_VER <= 17
241250
242template <class _Iter1, class _Iter2>251template <class _Iter1, class _Iter2>
243inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14252inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
244bool operator<(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)253bool operator<(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
245{254{
246 return __x.base() < __y.base();255 return __x.base() < __y.base();
247}256}
248257
249template <class _Iter1, class _Iter2>258template <class _Iter1, class _Iter2>
250inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14259inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
251bool operator>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)260bool operator>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
252{261{
253 return __x.base() > __y.base();262 return __x.base() > __y.base();
254}263}
255264
256template <class _Iter1, class _Iter2>265template <class _Iter1, class _Iter2>
257inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14266inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
258bool operator<=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)267bool operator<=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
259{268{
260 return __x.base() <= __y.base();269 return __x.base() <= __y.base();
261}270}
262271
263template <class _Iter1, class _Iter2>272template <class _Iter1, class _Iter2>
264inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14273inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
265bool operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)274bool operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
266{275{
267 return __x.base() >= __y.base();276 return __x.base() >= __y.base();
...@@ -279,7 +288,7 @@ auto operator<=>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>&...@@ -279,7 +288,7 @@ auto operator<=>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>&
279288
280#ifndef _LIBCPP_CXX03_LANG289#ifndef _LIBCPP_CXX03_LANG
281template <class _Iter1, class _Iter2>290template <class _Iter1, class _Iter2>
282inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14291inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
283auto operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)292auto operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
284 -> decltype(__x.base() - __y.base())293 -> decltype(__x.base() - __y.base())
285{294{
...@@ -305,7 +314,7 @@ move_iterator<_Iter> operator+(iter_difference_t<_Iter> __n, const move_iterator...@@ -305,7 +314,7 @@ move_iterator<_Iter> operator+(iter_difference_t<_Iter> __n, const move_iterator
305}314}
306#else315#else
307template <class _Iter>316template <class _Iter>
308inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14317inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
309move_iterator<_Iter>318move_iterator<_Iter>
310operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterator<_Iter>& __x)319operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterator<_Iter>& __x)
311{320{
...@@ -314,7 +323,7 @@ operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterato...@@ -314,7 +323,7 @@ operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterato
314#endif // _LIBCPP_STD_VER > 17323#endif // _LIBCPP_STD_VER > 17
315324
316template <class _Iter>325template <class _Iter>
317inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14326inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
318move_iterator<_Iter>327move_iterator<_Iter>
319make_move_iterator(_Iter __i)328make_move_iterator(_Iter __i)
320{329{
lib/libcxx/include/__iterator/move_sentinel.h+2
...@@ -50,6 +50,8 @@ private:...@@ -50,6 +50,8 @@ private:
50 _Sent __last_ = _Sent();50 _Sent __last_ = _Sent();
51};51};
5252
53_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(move_sentinel);
54
53#endif // _LIBCPP_STD_VER > 1755#endif // _LIBCPP_STD_VER > 17
5456
55_LIBCPP_END_NAMESPACE_STD57_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/next.h+4-4
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16#include <__iterator/concepts.h>16#include <__iterator/concepts.h>
17#include <__iterator/incrementable_traits.h>17#include <__iterator/incrementable_traits.h>
18#include <__iterator/iterator_traits.h>18#include <__iterator/iterator_traits.h>
19#include <type_traits>19#include <__type_traits/enable_if.h>
2020
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header22# pragma GCC system_header
...@@ -25,7 +25,7 @@...@@ -25,7 +25,7 @@
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27template <class _InputIter>27template <class _InputIter>
28inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1428inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
29 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value, _InputIter>::type29 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value, _InputIter>::type
30 next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) {30 next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) {
31 _LIBCPP_ASSERT(__n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value,31 _LIBCPP_ASSERT(__n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value,
...@@ -35,7 +35,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14...@@ -35,7 +35,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
35 return __x;35 return __x;
36}36}
3737
38#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)38#if _LIBCPP_STD_VER > 17
3939
40// [range.iter.op.next]40// [range.iter.op.next]
4141
...@@ -77,7 +77,7 @@ inline namespace __cpo {...@@ -77,7 +77,7 @@ inline namespace __cpo {
77} // namespace __cpo77} // namespace __cpo
78} // namespace ranges78} // namespace ranges
7979
80#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)80#endif // _LIBCPP_STD_VER > 17
8181
82_LIBCPP_END_NAMESPACE_STD82_LIBCPP_END_NAMESPACE_STD
8383
lib/libcxx/include/__iterator/ostreambuf_iterator.h+1-1
...@@ -65,7 +65,7 @@ public:...@@ -65,7 +65,7 @@ public:
6565
66 template <class _Ch, class _Tr>66 template <class _Ch, class _Tr>
67 friend67 friend
68 _LIBCPP_HIDDEN68 _LIBCPP_HIDE_FROM_ABI
69 ostreambuf_iterator<_Ch, _Tr>69 ostreambuf_iterator<_Ch, _Tr>
70 __pad_and_output(ostreambuf_iterator<_Ch, _Tr> __s,70 __pad_and_output(ostreambuf_iterator<_Ch, _Tr> __s,
71 const _Ch* __ob, const _Ch* __op, const _Ch* __oe,71 const _Ch* __ob, const _Ch* __op, const _Ch* __oe,
lib/libcxx/include/__iterator/prev.h+4-4
...@@ -16,7 +16,7 @@...@@ -16,7 +16,7 @@
16#include <__iterator/concepts.h>16#include <__iterator/concepts.h>
17#include <__iterator/incrementable_traits.h>17#include <__iterator/incrementable_traits.h>
18#include <__iterator/iterator_traits.h>18#include <__iterator/iterator_traits.h>
19#include <type_traits>19#include <__type_traits/enable_if.h>
2020
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header22# pragma GCC system_header
...@@ -25,7 +25,7 @@...@@ -25,7 +25,7 @@
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27template <class _InputIter>27template <class _InputIter>
28inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1428inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
29 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value, _InputIter>::type29 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value, _InputIter>::type
30 prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) {30 prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) {
31 _LIBCPP_ASSERT(__n <= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value,31 _LIBCPP_ASSERT(__n <= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value,
...@@ -34,7 +34,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14...@@ -34,7 +34,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
34 return __x;34 return __x;
35}35}
3636
37#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)37#if _LIBCPP_STD_VER > 17
3838
39// [range.iter.op.prev]39// [range.iter.op.prev]
4040
...@@ -70,7 +70,7 @@ inline namespace __cpo {...@@ -70,7 +70,7 @@ inline namespace __cpo {
70} // namespace __cpo70} // namespace __cpo
71} // namespace ranges71} // namespace ranges
7272
73#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)73#endif // _LIBCPP_STD_VER > 17
7474
75_LIBCPP_END_NAMESPACE_STD75_LIBCPP_END_NAMESPACE_STD
7676
lib/libcxx/include/__iterator/projected.h+2-1
...@@ -6,13 +6,14 @@...@@ -6,13 +6,14 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___ITERATOR_PROJECTED_H10#ifndef _LIBCPP___ITERATOR_PROJECTED_H
10#define _LIBCPP___ITERATOR_PROJECTED_H11#define _LIBCPP___ITERATOR_PROJECTED_H
1112
12#include <__config>13#include <__config>
13#include <__iterator/concepts.h>14#include <__iterator/concepts.h>
14#include <__iterator/incrementable_traits.h>15#include <__iterator/incrementable_traits.h>
15#include <type_traits>16#include <__type_traits/remove_cvref.h>
1617
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header19# pragma GCC system_header
lib/libcxx/include/__iterator/readable_traits.h+8-2
...@@ -10,9 +10,15 @@...@@ -10,9 +10,15 @@
10#ifndef _LIBCPP___ITERATOR_READABLE_TRAITS_H10#ifndef _LIBCPP___ITERATOR_READABLE_TRAITS_H
11#define _LIBCPP___ITERATOR_READABLE_TRAITS_H11#define _LIBCPP___ITERATOR_READABLE_TRAITS_H
1212
13#include <__concepts/same_as.h>
13#include <__config>14#include <__config>
14#include <concepts>15#include <__type_traits/conditional.h>
15#include <type_traits>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
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header24# pragma GCC system_header
lib/libcxx/include/__iterator/reverse_access.h+10-10
...@@ -24,70 +24,70 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -24,70 +24,70 @@ _LIBCPP_BEGIN_NAMESPACE_STD
24#if _LIBCPP_STD_VER > 1124#if _LIBCPP_STD_VER > 11
2525
26template <class _Tp, size_t _Np>26template <class _Tp, size_t _Np>
27_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1427_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
28reverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np])28reverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np])
29{29{
30 return reverse_iterator<_Tp*>(__array + _Np);30 return reverse_iterator<_Tp*>(__array + _Np);
31}31}
3232
33template <class _Tp, size_t _Np>33template <class _Tp, size_t _Np>
34_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1434_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
35reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np])35reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np])
36{36{
37 return reverse_iterator<_Tp*>(__array);37 return reverse_iterator<_Tp*>(__array);
38}38}
3939
40template <class _Ep>40template <class _Ep>
41_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1441_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
42reverse_iterator<const _Ep*> rbegin(initializer_list<_Ep> __il)42reverse_iterator<const _Ep*> rbegin(initializer_list<_Ep> __il)
43{43{
44 return reverse_iterator<const _Ep*>(__il.end());44 return reverse_iterator<const _Ep*>(__il.end());
45}45}
4646
47template <class _Ep>47template <class _Ep>
48_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1448_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
49reverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il)49reverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il)
50{50{
51 return reverse_iterator<const _Ep*>(__il.begin());51 return reverse_iterator<const _Ep*>(__il.begin());
52}52}
5353
54template <class _Cp>54template <class _Cp>
55_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1455_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
56auto rbegin(_Cp& __c) -> decltype(__c.rbegin())56auto rbegin(_Cp& __c) -> decltype(__c.rbegin())
57{57{
58 return __c.rbegin();58 return __c.rbegin();
59}59}
6060
61template <class _Cp>61template <class _Cp>
62_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1462_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
63auto rbegin(const _Cp& __c) -> decltype(__c.rbegin())63auto rbegin(const _Cp& __c) -> decltype(__c.rbegin())
64{64{
65 return __c.rbegin();65 return __c.rbegin();
66}66}
6767
68template <class _Cp>68template <class _Cp>
69_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1469_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
70auto rend(_Cp& __c) -> decltype(__c.rend())70auto rend(_Cp& __c) -> decltype(__c.rend())
71{71{
72 return __c.rend();72 return __c.rend();
73}73}
7474
75template <class _Cp>75template <class _Cp>
76_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1476_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
77auto rend(const _Cp& __c) -> decltype(__c.rend())77auto rend(const _Cp& __c) -> decltype(__c.rend())
78{78{
79 return __c.rend();79 return __c.rend();
80}80}
8181
82template <class _Cp>82template <class _Cp>
83_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1483_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
84auto crbegin(const _Cp& __c) -> decltype(_VSTD::rbegin(__c))84auto crbegin(const _Cp& __c) -> decltype(_VSTD::rbegin(__c))
85{85{
86 return _VSTD::rbegin(__c);86 return _VSTD::rbegin(__c);
87}87}
8888
89template <class _Cp>89template <class _Cp>
90_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1490_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
91auto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c))91auto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c))
92{92{
93 return _VSTD::rend(__c);93 return _VSTD::rend(__c);
lib/libcxx/include/__iterator/reverse_iterator.h+47-48
...@@ -25,12 +25,20 @@...@@ -25,12 +25,20 @@
25#include <__iterator/next.h>25#include <__iterator/next.h>
26#include <__iterator/prev.h>26#include <__iterator/prev.h>
27#include <__iterator/readable_traits.h>27#include <__iterator/readable_traits.h>
28#include <__iterator/segmented_iterator.h>
28#include <__memory/addressof.h>29#include <__memory/addressof.h>
29#include <__ranges/access.h>30#include <__ranges/access.h>
30#include <__ranges/concepts.h>31#include <__ranges/concepts.h>
31#include <__ranges/subrange.h>32#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>
32#include <__utility/move.h>41#include <__utility/move.h>
33#include <type_traits>
3442
35#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)43#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
36# pragma GCC system_header44# pragma GCC system_header
...@@ -52,7 +60,7 @@ class _LIBCPP_TEMPLATE_VIS reverse_iterator...@@ -52,7 +60,7 @@ class _LIBCPP_TEMPLATE_VIS reverse_iterator
52_LIBCPP_SUPPRESS_DEPRECATED_POP60_LIBCPP_SUPPRESS_DEPRECATED_POP
53private:61private:
54#ifndef _LIBCPP_ABI_NO_ITERATOR_BASES62#ifndef _LIBCPP_ABI_NO_ITERATOR_BASES
55 _Iter __t; // no longer used as of LWG #2360, not removed due to ABI break63 _Iter __t_; // no longer used as of LWG #2360, not removed due to ABI break
56#endif64#endif
5765
58#if _LIBCPP_STD_VER > 1766#if _LIBCPP_STD_VER > 17
...@@ -81,18 +89,18 @@ public:...@@ -81,18 +89,18 @@ public:
81#endif89#endif
8290
83#ifndef _LIBCPP_ABI_NO_ITERATOR_BASES91#ifndef _LIBCPP_ABI_NO_ITERATOR_BASES
84 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1492 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
85 reverse_iterator() : __t(), current() {}93 reverse_iterator() : __t_(), current() {}
8694
87 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1495 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
88 explicit reverse_iterator(_Iter __x) : __t(__x), current(__x) {}96 explicit reverse_iterator(_Iter __x) : __t_(__x), current(__x) {}
8997
90 template <class _Up, class = __enable_if_t<98 template <class _Up, class = __enable_if_t<
91 !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value99 !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value
92 > >100 > >
93 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14101 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
94 reverse_iterator(const reverse_iterator<_Up>& __u)102 reverse_iterator(const reverse_iterator<_Up>& __u)
95 : __t(__u.base()), current(__u.base())103 : __t_(__u.base()), current(__u.base())
96 { }104 { }
97105
98 template <class _Up, class = __enable_if_t<106 template <class _Up, class = __enable_if_t<
...@@ -100,22 +108,22 @@ public:...@@ -100,22 +108,22 @@ public:
100 is_convertible<_Up const&, _Iter>::value &&108 is_convertible<_Up const&, _Iter>::value &&
101 is_assignable<_Iter&, _Up const&>::value109 is_assignable<_Iter&, _Up const&>::value
102 > >110 > >
103 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14111 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
104 reverse_iterator& operator=(const reverse_iterator<_Up>& __u) {112 reverse_iterator& operator=(const reverse_iterator<_Up>& __u) {
105 __t = current = __u.base();113 __t_ = current = __u.base();
106 return *this;114 return *this;
107 }115 }
108#else116#else
109 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14117 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
110 reverse_iterator() : current() {}118 reverse_iterator() : current() {}
111119
112 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14120 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
113 explicit reverse_iterator(_Iter __x) : current(__x) {}121 explicit reverse_iterator(_Iter __x) : current(__x) {}
114122
115 template <class _Up, class = __enable_if_t<123 template <class _Up, class = __enable_if_t<
116 !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value124 !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value
117 > >125 > >
118 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14126 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
119 reverse_iterator(const reverse_iterator<_Up>& __u)127 reverse_iterator(const reverse_iterator<_Up>& __u)
120 : current(__u.base())128 : current(__u.base())
121 { }129 { }
...@@ -125,15 +133,15 @@ public:...@@ -125,15 +133,15 @@ public:
125 is_convertible<_Up const&, _Iter>::value &&133 is_convertible<_Up const&, _Iter>::value &&
126 is_assignable<_Iter&, _Up const&>::value134 is_assignable<_Iter&, _Up const&>::value
127 > >135 > >
128 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14136 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
129 reverse_iterator& operator=(const reverse_iterator<_Up>& __u) {137 reverse_iterator& operator=(const reverse_iterator<_Up>& __u) {
130 current = __u.base();138 current = __u.base();
131 return *this;139 return *this;
132 }140 }
133#endif141#endif
134 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14142 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
135 _Iter base() const {return current;}143 _Iter base() const {return current;}
136 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14144 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
137 reference operator*() const {_Iter __tmp = current; return *--__tmp;}145 reference operator*() const {_Iter __tmp = current; return *--__tmp;}
138146
139#if _LIBCPP_STD_VER > 17147#if _LIBCPP_STD_VER > 17
...@@ -148,36 +156,36 @@ public:...@@ -148,36 +156,36 @@ public:
148 }156 }
149 }157 }
150#else158#else
151 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14159 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
152 pointer operator->() const {160 pointer operator->() const {
153 return std::addressof(operator*());161 return std::addressof(operator*());
154 }162 }
155#endif // _LIBCPP_STD_VER > 17163#endif // _LIBCPP_STD_VER > 17
156164
157 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14165 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
158 reverse_iterator& operator++() {--current; return *this;}166 reverse_iterator& operator++() {--current; return *this;}
159 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14167 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
160 reverse_iterator operator++(int) {reverse_iterator __tmp(*this); --current; return __tmp;}168 reverse_iterator operator++(int) {reverse_iterator __tmp(*this); --current; return __tmp;}
161 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14169 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
162 reverse_iterator& operator--() {++current; return *this;}170 reverse_iterator& operator--() {++current; return *this;}
163 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14171 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
164 reverse_iterator operator--(int) {reverse_iterator __tmp(*this); ++current; return __tmp;}172 reverse_iterator operator--(int) {reverse_iterator __tmp(*this); ++current; return __tmp;}
165 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14173 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
166 reverse_iterator operator+(difference_type __n) const {return reverse_iterator(current - __n);}174 reverse_iterator operator+(difference_type __n) const {return reverse_iterator(current - __n);}
167 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14175 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
168 reverse_iterator& operator+=(difference_type __n) {current -= __n; return *this;}176 reverse_iterator& operator+=(difference_type __n) {current -= __n; return *this;}
169 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14177 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
170 reverse_iterator operator-(difference_type __n) const {return reverse_iterator(current + __n);}178 reverse_iterator operator-(difference_type __n) const {return reverse_iterator(current + __n);}
171 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14179 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
172 reverse_iterator& operator-=(difference_type __n) {current += __n; return *this;}180 reverse_iterator& operator-=(difference_type __n) {current += __n; return *this;}
173 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14181 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
174 reference operator[](difference_type __n) const {return *(*this + __n);}182 reference operator[](difference_type __n) const {return *(*this + __n);}
175183
176#if _LIBCPP_STD_VER > 17184#if _LIBCPP_STD_VER > 17
177 _LIBCPP_HIDE_FROM_ABI friend constexpr185 _LIBCPP_HIDE_FROM_ABI friend constexpr
178 iter_rvalue_reference_t<_Iter> iter_move(const reverse_iterator& __i)186 iter_rvalue_reference_t<_Iter> iter_move(const reverse_iterator& __i)
179 noexcept(is_nothrow_copy_constructible_v<_Iter> &&187 noexcept(is_nothrow_copy_constructible_v<_Iter> &&
180 noexcept(ranges::iter_move(--declval<_Iter&>()))) {188 noexcept(ranges::iter_move(--std::declval<_Iter&>()))) {
181 auto __tmp = __i.base();189 auto __tmp = __i.base();
182 return ranges::iter_move(--__tmp);190 return ranges::iter_move(--__tmp);
183 }191 }
...@@ -187,7 +195,7 @@ public:...@@ -187,7 +195,7 @@ public:
187 void iter_swap(const reverse_iterator& __x, const reverse_iterator<_Iter2>& __y)195 void iter_swap(const reverse_iterator& __x, const reverse_iterator<_Iter2>& __y)
188 noexcept(is_nothrow_copy_constructible_v<_Iter> &&196 noexcept(is_nothrow_copy_constructible_v<_Iter> &&
189 is_nothrow_copy_constructible_v<_Iter2> &&197 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&>()))) {
191 auto __xtmp = __x.base();199 auto __xtmp = __x.base();
192 auto __ytmp = __y.base();200 auto __ytmp = __y.base();
193 ranges::iter_swap(--__xtmp, --__ytmp);201 ranges::iter_swap(--__xtmp, --__ytmp);
...@@ -195,14 +203,8 @@ public:...@@ -195,14 +203,8 @@ public:
195#endif // _LIBCPP_STD_VER > 17203#endif // _LIBCPP_STD_VER > 17
196};204};
197205
198template <class _Iter>
199struct __is_reverse_iterator : false_type {};
200
201template <class _Iter>
202struct __is_reverse_iterator<reverse_iterator<_Iter> > : true_type {};
203
204template <class _Iter1, class _Iter2>206template <class _Iter1, class _Iter2>
205inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14207inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
206bool208bool
207operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)209operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
208#if _LIBCPP_STD_VER > 17210#if _LIBCPP_STD_VER > 17
...@@ -215,7 +217,7 @@ operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>&...@@ -215,7 +217,7 @@ operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>&
215}217}
216218
217template <class _Iter1, class _Iter2>219template <class _Iter1, class _Iter2>
218inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14220inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
219bool221bool
220operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)222operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
221#if _LIBCPP_STD_VER > 17223#if _LIBCPP_STD_VER > 17
...@@ -228,7 +230,7 @@ operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& _...@@ -228,7 +230,7 @@ operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& _
228}230}
229231
230template <class _Iter1, class _Iter2>232template <class _Iter1, class _Iter2>
231inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14233inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
232bool234bool
233operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)235operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
234#if _LIBCPP_STD_VER > 17236#if _LIBCPP_STD_VER > 17
...@@ -241,7 +243,7 @@ operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>&...@@ -241,7 +243,7 @@ operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>&
241}243}
242244
243template <class _Iter1, class _Iter2>245template <class _Iter1, class _Iter2>
244inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14246inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
245bool247bool
246operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)248operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
247#if _LIBCPP_STD_VER > 17249#if _LIBCPP_STD_VER > 17
...@@ -254,7 +256,7 @@ operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& _...@@ -254,7 +256,7 @@ operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& _
254}256}
255257
256template <class _Iter1, class _Iter2>258template <class _Iter1, class _Iter2>
257inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14259inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
258bool260bool
259operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)261operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
260#if _LIBCPP_STD_VER > 17262#if _LIBCPP_STD_VER > 17
...@@ -267,7 +269,7 @@ operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>&...@@ -267,7 +269,7 @@ operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>&
267}269}
268270
269template <class _Iter1, class _Iter2>271template <class _Iter1, class _Iter2>
270inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14272inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
271bool273bool
272operator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)274operator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
273#if _LIBCPP_STD_VER > 17275#if _LIBCPP_STD_VER > 17
...@@ -291,7 +293,7 @@ operator<=>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>&...@@ -291,7 +293,7 @@ operator<=>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>&
291293
292#ifndef _LIBCPP_CXX03_LANG294#ifndef _LIBCPP_CXX03_LANG
293template <class _Iter1, class _Iter2>295template <class _Iter1, class _Iter2>
294inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14296inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
295auto297auto
296operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)298operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
297-> decltype(__y.base() - __x.base())299-> decltype(__y.base() - __x.base())
...@@ -309,7 +311,7 @@ operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& _...@@ -309,7 +311,7 @@ operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& _
309#endif311#endif
310312
311template <class _Iter>313template <class _Iter>
312inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14314inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
313reverse_iterator<_Iter>315reverse_iterator<_Iter>
314operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_iterator<_Iter>& __x)316operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_iterator<_Iter>& __x)
315{317{
...@@ -324,7 +326,7 @@ inline constexpr bool disable_sized_sentinel_for<reverse_iterator<_Iter1>, rever...@@ -324,7 +326,7 @@ inline constexpr bool disable_sized_sentinel_for<reverse_iterator<_Iter1>, rever
324326
325#if _LIBCPP_STD_VER > 11327#if _LIBCPP_STD_VER > 11
326template <class _Iter>328template <class _Iter>
327inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14329inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
328reverse_iterator<_Iter> make_reverse_iterator(_Iter __i)330reverse_iterator<_Iter> make_reverse_iterator(_Iter __i)
329{331{
330 return reverse_iterator<_Iter>(__i);332 return reverse_iterator<_Iter>(__i);
...@@ -394,7 +396,7 @@ public:...@@ -394,7 +396,7 @@ public:
394 _LIBCPP_HIDE_FROM_ABI friend constexpr396 _LIBCPP_HIDE_FROM_ABI friend constexpr
395 iter_rvalue_reference_t<_Iter> iter_move(const __unconstrained_reverse_iterator& __i)397 iter_rvalue_reference_t<_Iter> iter_move(const __unconstrained_reverse_iterator& __i)
396 noexcept(is_nothrow_copy_constructible_v<_Iter> &&398 noexcept(is_nothrow_copy_constructible_v<_Iter> &&
397 noexcept(ranges::iter_move(--declval<_Iter&>()))) {399 noexcept(ranges::iter_move(--std::declval<_Iter&>()))) {
398 auto __tmp = __i.base();400 auto __tmp = __i.base();
399 return ranges::iter_move(--__tmp);401 return ranges::iter_move(--__tmp);
400 }402 }
...@@ -478,9 +480,6 @@ public:...@@ -478,9 +480,6 @@ public:
478 }480 }
479};481};
480482
481template <class _Iter>
482struct __is_reverse_iterator<__unconstrained_reverse_iterator<_Iter>> : true_type {};
483
484#endif // _LIBCPP_STD_VER <= 17483#endif // _LIBCPP_STD_VER <= 17
485484
486template <template <class> class _RevIter1, template <class> class _RevIter2, class _Iter>485template <template <class> class _RevIter1, template <class> class _RevIter2, class _Iter>
...@@ -499,7 +498,7 @@ struct __unwrap_reverse_iter_impl {...@@ -499,7 +498,7 @@ struct __unwrap_reverse_iter_impl {
499 }498 }
500};499};
501500
502#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)501#if _LIBCPP_STD_VER > 17
503template <ranges::bidirectional_range _Range>502template <ranges::bidirectional_range _Range>
504_LIBCPP_HIDE_FROM_ABI constexpr ranges::503_LIBCPP_HIDE_FROM_ABI constexpr ranges::
505 subrange<reverse_iterator<ranges::iterator_t<_Range>>, reverse_iterator<ranges::iterator_t<_Range>>>504 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 @@...@@ -11,8 +11,9 @@
11#define _LIBCPP___ITERATOR_SIZE_H11#define _LIBCPP___ITERATOR_SIZE_H
1212
13#include <__config>13#include <__config>
14#include <__type_traits/common_type.h>
15#include <__type_traits/make_signed.h>
14#include <cstddef>16#include <cstddef>
15#include <type_traits>
1617
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header19# pragma GCC system_header
lib/libcxx/include/__iterator/wrap_iter.h+36-35
...@@ -15,7 +15,8 @@...@@ -15,7 +15,8 @@
15#include <__iterator/iterator_traits.h>15#include <__iterator/iterator_traits.h>
16#include <__memory/addressof.h>16#include <__memory/addressof.h>
17#include <__memory/pointer_traits.h>17#include <__memory/pointer_traits.h>
18#include <type_traits>18#include <__type_traits/enable_if.h>
19#include <__type_traits/is_convertible.h>
1920
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header22# pragma GCC system_header
...@@ -38,17 +39,17 @@ public:...@@ -38,17 +39,17 @@ public:
38#endif39#endif
3940
40private:41private:
41 iterator_type __i;42 iterator_type __i_;
42public:43public:
43 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter() _NOEXCEPT44 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter() _NOEXCEPT
44 : __i()45 : __i_()
45 {46 {
46 _VSTD::__debug_db_insert_i(this);47 _VSTD::__debug_db_insert_i(this);
47 }48 }
48 template <class _Up> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1149 template <class _Up> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
49 __wrap_iter(const __wrap_iter<_Up>& __u,50 __wrap_iter(const __wrap_iter<_Up>& __u,
50 typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = nullptr) _NOEXCEPT51 typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = nullptr) _NOEXCEPT
51 : __i(__u.base())52 : __i_(__u.base())
52 {53 {
53#ifdef _LIBCPP_ENABLE_DEBUG_MODE54#ifdef _LIBCPP_ENABLE_DEBUG_MODE
54 if (!__libcpp_is_constant_evaluated())55 if (!__libcpp_is_constant_evaluated())
...@@ -56,87 +57,87 @@ public:...@@ -56,87 +57,87 @@ public:
56#endif57#endif
57 }58 }
58#ifdef _LIBCPP_ENABLE_DEBUG_MODE59#ifdef _LIBCPP_ENABLE_DEBUG_MODE
59 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1160 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
60 __wrap_iter(const __wrap_iter& __x)61 __wrap_iter(const __wrap_iter& __x)
61 : __i(__x.base())62 : __i_(__x.base())
62 {63 {
63 if (!__libcpp_is_constant_evaluated())64 if (!__libcpp_is_constant_evaluated())
64 __get_db()->__iterator_copy(this, _VSTD::addressof(__x));65 __get_db()->__iterator_copy(this, _VSTD::addressof(__x));
65 }66 }
66 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1167 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
67 __wrap_iter& operator=(const __wrap_iter& __x)68 __wrap_iter& operator=(const __wrap_iter& __x)
68 {69 {
69 if (this != _VSTD::addressof(__x))70 if (this != _VSTD::addressof(__x))
70 {71 {
71 if (!__libcpp_is_constant_evaluated())72 if (!__libcpp_is_constant_evaluated())
72 __get_db()->__iterator_copy(this, _VSTD::addressof(__x));73 __get_db()->__iterator_copy(this, _VSTD::addressof(__x));
73 __i = __x.__i;74 __i_ = __x.__i_;
74 }75 }
75 return *this;76 return *this;
76 }77 }
77 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1778 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
78 ~__wrap_iter()79 ~__wrap_iter()
79 {80 {
80 if (!__libcpp_is_constant_evaluated())81 if (!__libcpp_is_constant_evaluated())
81 __get_db()->__erase_i(this);82 __get_db()->__erase_i(this);
82 }83 }
83#endif84#endif
84 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference operator*() const _NOEXCEPT85 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT
85 {86 {
86 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),87 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
87 "Attempted to dereference a non-dereferenceable iterator");88 "Attempted to dereference a non-dereferenceable iterator");
88 return *__i;89 return *__i_;
89 }90 }
90 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 pointer operator->() const _NOEXCEPT91 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pointer operator->() const _NOEXCEPT
91 {92 {
92 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),93 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
93 "Attempted to dereference a non-dereferenceable iterator");94 "Attempted to dereference a non-dereferenceable iterator");
94 return _VSTD::__to_address(__i);95 return _VSTD::__to_address(__i_);
95 }96 }
96 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter& operator++() _NOEXCEPT97 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter& operator++() _NOEXCEPT
97 {98 {
98 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),99 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this),
99 "Attempted to increment a non-incrementable iterator");100 "Attempted to increment a non-incrementable iterator");
100 ++__i;101 ++__i_;
101 return *this;102 return *this;
102 }103 }
103 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter operator++(int) _NOEXCEPT104 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter operator++(int) _NOEXCEPT
104 {__wrap_iter __tmp(*this); ++(*this); return __tmp;}105 {__wrap_iter __tmp(*this); ++(*this); return __tmp;}
105106
106 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter& operator--() _NOEXCEPT107 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter& operator--() _NOEXCEPT
107 {108 {
108 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__decrementable(this),109 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__decrementable(this),
109 "Attempted to decrement a non-decrementable iterator");110 "Attempted to decrement a non-decrementable iterator");
110 --__i;111 --__i_;
111 return *this;112 return *this;
112 }113 }
113 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter operator--(int) _NOEXCEPT114 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter operator--(int) _NOEXCEPT
114 {__wrap_iter __tmp(*this); --(*this); return __tmp;}115 {__wrap_iter __tmp(*this); --(*this); return __tmp;}
115 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter operator+ (difference_type __n) const _NOEXCEPT116 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter operator+ (difference_type __n) const _NOEXCEPT
116 {__wrap_iter __w(*this); __w += __n; return __w;}117 {__wrap_iter __w(*this); __w += __n; return __w;}
117 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter& operator+=(difference_type __n) _NOEXCEPT118 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter& operator+=(difference_type __n) _NOEXCEPT
118 {119 {
119 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__addable(this, __n),120 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__addable(this, __n),
120 "Attempted to add/subtract an iterator outside its valid range");121 "Attempted to add/subtract an iterator outside its valid range");
121 __i += __n;122 __i_ += __n;
122 return *this;123 return *this;
123 }124 }
124 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter operator- (difference_type __n) const _NOEXCEPT125 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter operator- (difference_type __n) const _NOEXCEPT
125 {return *this + (-__n);}126 {return *this + (-__n);}
126 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter& operator-=(difference_type __n) _NOEXCEPT127 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter& operator-=(difference_type __n) _NOEXCEPT
127 {*this += -__n; return *this;}128 {*this += -__n; return *this;}
128 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference operator[](difference_type __n) const _NOEXCEPT129 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator[](difference_type __n) const _NOEXCEPT
129 {130 {
130 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__subscriptable(this, __n),131 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__subscriptable(this, __n),
131 "Attempted to subscript an iterator outside its valid range");132 "Attempted to subscript an iterator outside its valid range");
132 return __i[__n];133 return __i_[__n];
133 }134 }
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
137private:138private:
138 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11139 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
139 explicit __wrap_iter(const void* __p, iterator_type __x) _NOEXCEPT : __i(__x)140 explicit __wrap_iter(const void* __p, iterator_type __x) _NOEXCEPT : __i_(__x)
140 {141 {
141 (void)__p;142 (void)__p;
142#ifdef _LIBCPP_ENABLE_DEBUG_MODE143#ifdef _LIBCPP_ENABLE_DEBUG_MODE
...@@ -166,7 +167,7 @@ bool operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y)...@@ -166,7 +167,7 @@ bool operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y)
166}167}
167168
168template <class _Iter1>169template <class _Iter1>
169_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11170_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
170bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT171bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
171{172{
172 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__less_than_comparable(_VSTD::addressof(__x), _VSTD::addressof(__y)),173 _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) _...@@ -175,7 +176,7 @@ bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _
175}176}
176177
177template <class _Iter1, class _Iter2>178template <class _Iter1, class _Iter2>
178_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11179_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
179bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT180bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
180{181{
181 _LIBCPP_DEBUG_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),182 _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)...@@ -240,7 +241,7 @@ bool operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y)
240}241}
241242
242template <class _Iter1, class _Iter2>243template <class _Iter1, class _Iter2>
243_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11244_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
244#ifndef _LIBCPP_CXX03_LANG245#ifndef _LIBCPP_CXX03_LANG
245auto operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT246auto operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
246 -> decltype(__x.base() - __y.base())247 -> decltype(__x.base() - __y.base())
...@@ -255,7 +256,7 @@ operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXC...@@ -255,7 +256,7 @@ operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXC
255}256}
256257
257template <class _Iter1>258template <class _Iter1>
258_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11259_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
259__wrap_iter<_Iter1> operator+(typename __wrap_iter<_Iter1>::difference_type __n, __wrap_iter<_Iter1> __x) _NOEXCEPT260__wrap_iter<_Iter1> operator+(typename __wrap_iter<_Iter1>::difference_type __n, __wrap_iter<_Iter1> __x) _NOEXCEPT
260{261{
261 __x += __n;262 __x += __n;
lib/libcxx/include/__locale+76-72
...@@ -15,13 +15,15 @@...@@ -15,13 +15,15 @@
15#include <cctype>15#include <cctype>
16#include <cstdint>16#include <cstdint>
17#include <locale.h>17#include <locale.h>
18#include <memory>
19#include <mutex>18#include <mutex>
20#include <string>19#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
22#if defined(_LIBCPP_MSVCRT_LIKE)25#if defined(_LIBCPP_MSVCRT_LIKE)
23# include <__support/win32/locale_win32.h>26# include <__support/win32/locale_win32.h>
24# include <cstring>
25#elif defined(_AIX) || defined(__MVS__)27#elif defined(_AIX) || defined(__MVS__)
26# include <__support/ibm/xlocale.h>28# include <__support/ibm/xlocale.h>
27#elif defined(__ANDROID__)29#elif defined(__ANDROID__)
...@@ -33,7 +35,7 @@...@@ -33,7 +35,7 @@
33# include <__support/newlib/xlocale.h>35# include <__support/newlib/xlocale.h>
34#elif defined(__OpenBSD__)36#elif defined(__OpenBSD__)
35# include <__support/openbsd/xlocale.h>37# include <__support/openbsd/xlocale.h>
36#elif (defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__))38#elif (defined(__APPLE__) || defined(__FreeBSD__))
37# include <xlocale.h>39# include <xlocale.h>
38#elif defined(__Fuchsia__)40#elif defined(__Fuchsia__)
39# include <__support/fuchsia/xlocale.h>41# include <__support/fuchsia/xlocale.h>
...@@ -191,12 +193,12 @@ protected:...@@ -191,12 +193,12 @@ protected:
191 explicit facet(size_t __refs = 0)193 explicit facet(size_t __refs = 0)
192 : __shared_count(static_cast<long>(__refs)-1) {}194 : __shared_count(static_cast<long>(__refs)-1) {}
193195
194 virtual ~facet();196 ~facet() override;
195197
196// facet(const facet&) = delete; // effectively done in __shared_count198// facet(const facet&) = delete; // effectively done in __shared_count
197// void operator=(const facet&) = delete;199// void operator=(const facet&) = delete;
198private:200private:
199 virtual void __on_zero_shared() _NOEXCEPT;201 void __on_zero_shared() _NOEXCEPT override;
200};202};
201203
202class _LIBCPP_TYPE_VIS locale::id204class _LIBCPP_TYPE_VIS locale::id
...@@ -291,7 +293,7 @@ public:...@@ -291,7 +293,7 @@ public:
291 static locale::id id;293 static locale::id id;
292294
293protected:295protected:
294 ~collate();296 ~collate() override;
295 virtual int do_compare(const char_type* __lo1, const char_type* __hi1,297 virtual int do_compare(const char_type* __lo1, const char_type* __hi1,
296 const char_type* __lo2, const char_type* __hi2) const;298 const char_type* __lo2, const char_type* __hi2) const;
297 virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const299 virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const
...@@ -350,7 +352,7 @@ template <>...@@ -350,7 +352,7 @@ template <>
350class _LIBCPP_TYPE_VIS collate_byname<char>352class _LIBCPP_TYPE_VIS collate_byname<char>
351 : public collate<char>353 : public collate<char>
352{354{
353 locale_t __l;355 locale_t __l_;
354public:356public:
355 typedef char char_type;357 typedef char char_type;
356 typedef basic_string<char_type> string_type;358 typedef basic_string<char_type> string_type;
...@@ -359,10 +361,10 @@ public:...@@ -359,10 +361,10 @@ public:
359 explicit collate_byname(const string& __n, size_t __refs = 0);361 explicit collate_byname(const string& __n, size_t __refs = 0);
360362
361protected:363protected:
362 ~collate_byname();364 ~collate_byname() override;
363 virtual int do_compare(const char_type* __lo1, const char_type* __hi1,365 int do_compare(const char_type* __lo1, const char_type* __hi1,
364 const char_type* __lo2, const char_type* __hi2) const;366 const char_type* __lo2, const char_type* __hi2) const override;
365 virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const;367 string_type do_transform(const char_type* __lo, const char_type* __hi) const override;
366};368};
367369
368#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS370#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
...@@ -370,7 +372,7 @@ template <>...@@ -370,7 +372,7 @@ template <>
370class _LIBCPP_TYPE_VIS collate_byname<wchar_t>372class _LIBCPP_TYPE_VIS collate_byname<wchar_t>
371 : public collate<wchar_t>373 : public collate<wchar_t>
372{374{
373 locale_t __l;375 locale_t __l_;
374public:376public:
375 typedef wchar_t char_type;377 typedef wchar_t char_type;
376 typedef basic_string<char_type> string_type;378 typedef basic_string<char_type> string_type;
...@@ -379,11 +381,11 @@ public:...@@ -379,11 +381,11 @@ public:
379 explicit collate_byname(const string& __n, size_t __refs = 0);381 explicit collate_byname(const string& __n, size_t __refs = 0);
380382
381protected:383protected:
382 ~collate_byname();384 ~collate_byname() override;
383385
384 virtual int do_compare(const char_type* __lo1, const char_type* __hi1,386 int do_compare(const char_type* __lo1, const char_type* __hi1,
385 const char_type* __lo2, const char_type* __hi2) const;387 const char_type* __lo2, const char_type* __hi2) const override;
386 virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const;388 string_type do_transform(const char_type* __lo, const char_type* __hi) const override;
387};389};
388#endif390#endif
389391
...@@ -453,10 +455,10 @@ public:...@@ -453,10 +455,10 @@ public:
453 static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used455 static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used
454# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT456# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
455# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA457# 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__)
457# ifdef __APPLE__459# ifdef __APPLE__
458 typedef __uint32_t mask;460 typedef __uint32_t mask;
459# elif defined(__FreeBSD__) || defined(__DragonFly__)461# elif defined(__FreeBSD__)
460 typedef unsigned long mask;462 typedef unsigned long mask;
461# elif defined(__EMSCRIPTEN__) || defined(__NetBSD__)463# elif defined(__EMSCRIPTEN__) || defined(__NetBSD__)
462 typedef unsigned short mask;464 typedef unsigned short mask;
...@@ -510,7 +512,8 @@ public:...@@ -510,7 +512,8 @@ public:
510 static const mask punct = _P;512 static const mask punct = _P;
511 static const mask xdigit = _X | _N;513 static const mask xdigit = _X | _N;
512 static const mask blank = _B;514 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;
514# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT517# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
515# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA518# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
516# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT519# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT
...@@ -549,7 +552,8 @@ public:...@@ -549,7 +552,8 @@ public:
549552
550 _LIBCPP_INLINE_VISIBILITY ctype_base() {}553 _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,
553 "__regex_word can't overlap other bits");557 "__regex_word can't overlap other bits");
554};558};
555559
...@@ -643,7 +647,7 @@ public:...@@ -643,7 +647,7 @@ public:
643 static locale::id id;647 static locale::id id;
644648
645protected:649protected:
646 ~ctype();650 ~ctype() override;
647 virtual bool do_is(mask __m, char_type __c) const;651 virtual bool do_is(mask __m, char_type __c) const;
648 virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const;652 virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const;
649 virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const;653 virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const;
...@@ -697,7 +701,7 @@ public:...@@ -697,7 +701,7 @@ public:
697 const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const701 const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const
698 {702 {
699 for (; __low != __high; ++__low)703 for (; __low != __high; ++__low)
700 if (!(isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m)))704 if (!isascii(*__low) || !(__tab_[static_cast<int>(*__low)] & __m))
701 break;705 break;
702 return __low;706 return __low;
703 }707 }
...@@ -773,7 +777,7 @@ public:...@@ -773,7 +777,7 @@ public:
773#endif777#endif
774778
775protected:779protected:
776 ~ctype();780 ~ctype() override;
777 virtual char_type do_toupper(char_type __c) const;781 virtual char_type do_toupper(char_type __c) const;
778 virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;782 virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
779 virtual char_type do_tolower(char_type __c) const;783 virtual char_type do_tolower(char_type __c) const;
...@@ -792,18 +796,18 @@ template <>...@@ -792,18 +796,18 @@ template <>
792class _LIBCPP_TYPE_VIS ctype_byname<char>796class _LIBCPP_TYPE_VIS ctype_byname<char>
793 : public ctype<char>797 : public ctype<char>
794{798{
795 locale_t __l;799 locale_t __l_;
796800
797public:801public:
798 explicit ctype_byname(const char*, size_t = 0);802 explicit ctype_byname(const char*, size_t = 0);
799 explicit ctype_byname(const string&, size_t = 0);803 explicit ctype_byname(const string&, size_t = 0);
800804
801protected:805protected:
802 ~ctype_byname();806 ~ctype_byname() override;
803 virtual char_type do_toupper(char_type) const;807 char_type do_toupper(char_type) const override;
804 virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;808 const char_type* do_toupper(char_type* __low, const char_type* __high) const override;
805 virtual char_type do_tolower(char_type) const;809 char_type do_tolower(char_type) const override;
806 virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;810 const char_type* do_tolower(char_type* __low, const char_type* __high) const override;
807};811};
808812
809#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS813#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
...@@ -811,26 +815,26 @@ template <>...@@ -811,26 +815,26 @@ template <>
811class _LIBCPP_TYPE_VIS ctype_byname<wchar_t>815class _LIBCPP_TYPE_VIS ctype_byname<wchar_t>
812 : public ctype<wchar_t>816 : public ctype<wchar_t>
813{817{
814 locale_t __l;818 locale_t __l_;
815819
816public:820public:
817 explicit ctype_byname(const char*, size_t = 0);821 explicit ctype_byname(const char*, size_t = 0);
818 explicit ctype_byname(const string&, size_t = 0);822 explicit ctype_byname(const string&, size_t = 0);
819823
820protected:824protected:
821 ~ctype_byname();825 ~ctype_byname() override;
822 virtual bool do_is(mask __m, char_type __c) const;826 bool do_is(mask __m, char_type __c) const override;
823 virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const;827 const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const override;
824 virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const;828 const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const override;
825 virtual const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const;829 const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const override;
826 virtual char_type do_toupper(char_type) const;830 char_type do_toupper(char_type) const override;
827 virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;831 const char_type* do_toupper(char_type* __low, const char_type* __high) const override;
828 virtual char_type do_tolower(char_type) const;832 char_type do_tolower(char_type) const override;
829 virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;833 const char_type* do_tolower(char_type* __low, const char_type* __high) const override;
830 virtual char_type do_widen(char) const;834 char_type do_widen(char) const override;
831 virtual const char* do_widen(const char* __low, const char* __high, char_type* __dest) const;835 const char* do_widen(const char* __low, const char* __high, char_type* __dest) const override;
832 virtual char do_narrow(char_type, char __dfault) const;836 char do_narrow(char_type, char __dfault) const override;
833 virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const;837 const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const override;
834};838};
835#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS839#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
836840
...@@ -839,7 +843,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -839,7 +843,7 @@ inline _LIBCPP_INLINE_VISIBILITY
839bool843bool
840isspace(_CharT __c, const locale& __loc)844isspace(_CharT __c, const locale& __loc)
841{845{
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);
843}847}
844848
845template <class _CharT>849template <class _CharT>
...@@ -847,7 +851,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -847,7 +851,7 @@ inline _LIBCPP_INLINE_VISIBILITY
847bool851bool
848isprint(_CharT __c, const locale& __loc)852isprint(_CharT __c, const locale& __loc)
849{853{
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);
851}855}
852856
853template <class _CharT>857template <class _CharT>
...@@ -855,7 +859,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -855,7 +859,7 @@ inline _LIBCPP_INLINE_VISIBILITY
855bool859bool
856iscntrl(_CharT __c, const locale& __loc)860iscntrl(_CharT __c, const locale& __loc)
857{861{
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);
859}863}
860864
861template <class _CharT>865template <class _CharT>
...@@ -863,7 +867,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -863,7 +867,7 @@ inline _LIBCPP_INLINE_VISIBILITY
863bool867bool
864isupper(_CharT __c, const locale& __loc)868isupper(_CharT __c, const locale& __loc)
865{869{
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);
867}871}
868872
869template <class _CharT>873template <class _CharT>
...@@ -871,7 +875,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -871,7 +875,7 @@ inline _LIBCPP_INLINE_VISIBILITY
871bool875bool
872islower(_CharT __c, const locale& __loc)876islower(_CharT __c, const locale& __loc)
873{877{
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);
875}879}
876880
877template <class _CharT>881template <class _CharT>
...@@ -879,7 +883,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -879,7 +883,7 @@ inline _LIBCPP_INLINE_VISIBILITY
879bool883bool
880isalpha(_CharT __c, const locale& __loc)884isalpha(_CharT __c, const locale& __loc)
881{885{
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);
883}887}
884888
885template <class _CharT>889template <class _CharT>
...@@ -887,7 +891,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -887,7 +891,7 @@ inline _LIBCPP_INLINE_VISIBILITY
887bool891bool
888isdigit(_CharT __c, const locale& __loc)892isdigit(_CharT __c, const locale& __loc)
889{893{
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);
891}895}
892896
893template <class _CharT>897template <class _CharT>
...@@ -895,7 +899,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -895,7 +899,7 @@ inline _LIBCPP_INLINE_VISIBILITY
895bool899bool
896ispunct(_CharT __c, const locale& __loc)900ispunct(_CharT __c, const locale& __loc)
897{901{
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);
899}903}
900904
901template <class _CharT>905template <class _CharT>
...@@ -903,7 +907,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -903,7 +907,7 @@ inline _LIBCPP_INLINE_VISIBILITY
903bool907bool
904isxdigit(_CharT __c, const locale& __loc)908isxdigit(_CharT __c, const locale& __loc)
905{909{
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);
907}911}
908912
909template <class _CharT>913template <class _CharT>
...@@ -911,7 +915,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -911,7 +915,7 @@ inline _LIBCPP_INLINE_VISIBILITY
911bool915bool
912isalnum(_CharT __c, const locale& __loc)916isalnum(_CharT __c, const locale& __loc)
913{917{
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);
915}919}
916920
917template <class _CharT>921template <class _CharT>
...@@ -919,7 +923,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -919,7 +923,7 @@ inline _LIBCPP_INLINE_VISIBILITY
919bool923bool
920isgraph(_CharT __c, const locale& __loc)924isgraph(_CharT __c, const locale& __loc)
921{925{
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);
923}927}
924928
925template <class _CharT>929template <class _CharT>
...@@ -927,7 +931,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -927,7 +931,7 @@ inline _LIBCPP_INLINE_VISIBILITY
927_CharT931_CharT
928toupper(_CharT __c, const locale& __loc)932toupper(_CharT __c, const locale& __loc)
929{933{
930 return use_facet<ctype<_CharT> >(__loc).toupper(__c);934 return std::use_facet<ctype<_CharT> >(__loc).toupper(__c);
931}935}
932936
933template <class _CharT>937template <class _CharT>
...@@ -935,7 +939,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -935,7 +939,7 @@ inline _LIBCPP_INLINE_VISIBILITY
935_CharT939_CharT
936tolower(_CharT __c, const locale& __loc)940tolower(_CharT __c, const locale& __loc)
937{941{
938 return use_facet<ctype<_CharT> >(__loc).tolower(__c);942 return std::use_facet<ctype<_CharT> >(__loc).tolower(__c);
939}943}
940944
941// codecvt_base945// codecvt_base
...@@ -1021,7 +1025,7 @@ protected:...@@ -1021,7 +1025,7 @@ protected:
1021 explicit codecvt(const char*, size_t __refs = 0)1025 explicit codecvt(const char*, size_t __refs = 0)
1022 : locale::facet(__refs) {}1026 : locale::facet(__refs) {}
10231027
1024 ~codecvt();1028 ~codecvt() override;
10251029
1026 virtual result do_out(state_type& __st,1030 virtual result do_out(state_type& __st,
1027 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,1031 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>...@@ -1045,7 +1049,7 @@ class _LIBCPP_TYPE_VIS codecvt<wchar_t, char, mbstate_t>
1045 : public locale::facet,1049 : public locale::facet,
1046 public codecvt_base1050 public codecvt_base
1047{1051{
1048 locale_t __l;1052 locale_t __l_;
1049public:1053public:
1050 typedef wchar_t intern_type;1054 typedef wchar_t intern_type;
1051 typedef char extern_type;1055 typedef char extern_type;
...@@ -1105,7 +1109,7 @@ public:...@@ -1105,7 +1109,7 @@ public:
1105protected:1109protected:
1106 explicit codecvt(const char*, size_t __refs = 0);1110 explicit codecvt(const char*, size_t __refs = 0);
11071111
1108 ~codecvt();1112 ~codecvt() override;
11091113
1110 virtual result do_out(state_type& __st,1114 virtual result do_out(state_type& __st,
1111 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,1115 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
...@@ -1192,7 +1196,7 @@ protected:...@@ -1192,7 +1196,7 @@ protected:
1192 explicit codecvt(const char*, size_t __refs = 0)1196 explicit codecvt(const char*, size_t __refs = 0)
1193 : locale::facet(__refs) {}1197 : locale::facet(__refs) {}
11941198
1195 ~codecvt();1199 ~codecvt() override;
11961200
1197 virtual result do_out(state_type& __st,1201 virtual result do_out(state_type& __st,
1198 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,1202 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
...@@ -1280,7 +1284,7 @@ protected:...@@ -1280,7 +1284,7 @@ protected:
1280 explicit codecvt(const char*, size_t __refs = 0)1284 explicit codecvt(const char*, size_t __refs = 0)
1281 : locale::facet(__refs) {}1285 : locale::facet(__refs) {}
12821286
1283 ~codecvt();1287 ~codecvt() override;
12841288
1285 virtual result do_out(state_type& __st,1289 virtual result do_out(state_type& __st,
1286 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,1290 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
...@@ -1368,7 +1372,7 @@ protected:...@@ -1368,7 +1372,7 @@ protected:
1368 explicit codecvt(const char*, size_t __refs = 0)1372 explicit codecvt(const char*, size_t __refs = 0)
1369 : locale::facet(__refs) {}1373 : locale::facet(__refs) {}
13701374
1371 ~codecvt();1375 ~codecvt() override;
13721376
1373 virtual result do_out(state_type& __st,1377 virtual result do_out(state_type& __st,
1374 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,1378 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
...@@ -1456,7 +1460,7 @@ protected:...@@ -1456,7 +1460,7 @@ protected:
1456 explicit codecvt(const char*, size_t __refs = 0)1460 explicit codecvt(const char*, size_t __refs = 0)
1457 : locale::facet(__refs) {}1461 : locale::facet(__refs) {}
14581462
1459 ~codecvt();1463 ~codecvt() override;
14601464
1461 virtual result do_out(state_type& __st,1465 virtual result do_out(state_type& __st,
1462 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,1466 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
...@@ -1488,7 +1492,7 @@ public:...@@ -1488,7 +1492,7 @@ public:
1488 explicit codecvt_byname(const string& __nm, size_t __refs = 0)1492 explicit codecvt_byname(const string& __nm, size_t __refs = 0)
1489 : codecvt<_InternT, _ExternT, _StateT>(__nm.c_str(), __refs) {}1493 : codecvt<_InternT, _ExternT, _StateT>(__nm.c_str(), __refs) {}
1490protected:1494protected:
1491 ~codecvt_byname();1495 ~codecvt_byname() override;
1492};1496};
14931497
1494_LIBCPP_SUPPRESS_DEPRECATED_PUSH1498_LIBCPP_SUPPRESS_DEPRECATED_PUSH
...@@ -1540,7 +1544,7 @@ struct _LIBCPP_TYPE_VIS __narrow_to_utf8<16>...@@ -1540,7 +1544,7 @@ struct _LIBCPP_TYPE_VIS __narrow_to_utf8<16>
1540 __narrow_to_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}1544 __narrow_to_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
1541_LIBCPP_SUPPRESS_DEPRECATED_POP1545_LIBCPP_SUPPRESS_DEPRECATED_POP
15421546
1543 ~__narrow_to_utf8();1547 ~__narrow_to_utf8() override;
15441548
1545 template <class _OutputIterator, class _CharT>1549 template <class _OutputIterator, class _CharT>
1546 _LIBCPP_INLINE_VISIBILITY1550 _LIBCPP_INLINE_VISIBILITY
...@@ -1576,7 +1580,7 @@ struct _LIBCPP_TYPE_VIS __narrow_to_utf8<32>...@@ -1576,7 +1580,7 @@ struct _LIBCPP_TYPE_VIS __narrow_to_utf8<32>
1576 __narrow_to_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}1580 __narrow_to_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
1577_LIBCPP_SUPPRESS_DEPRECATED_POP1581_LIBCPP_SUPPRESS_DEPRECATED_POP
15781582
1579 ~__narrow_to_utf8();1583 ~__narrow_to_utf8() override;
15801584
1581 template <class _OutputIterator, class _CharT>1585 template <class _OutputIterator, class _CharT>
1582 _LIBCPP_INLINE_VISIBILITY1586 _LIBCPP_INLINE_VISIBILITY
...@@ -1634,7 +1638,7 @@ struct _LIBCPP_TYPE_VIS __widen_from_utf8<16>...@@ -1634,7 +1638,7 @@ struct _LIBCPP_TYPE_VIS __widen_from_utf8<16>
1634 __widen_from_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}1638 __widen_from_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
1635_LIBCPP_SUPPRESS_DEPRECATED_POP1639_LIBCPP_SUPPRESS_DEPRECATED_POP
16361640
1637 ~__widen_from_utf8();1641 ~__widen_from_utf8() override;
16381642
1639 template <class _OutputIterator>1643 template <class _OutputIterator>
1640 _LIBCPP_INLINE_VISIBILITY1644 _LIBCPP_INLINE_VISIBILITY
...@@ -1670,7 +1674,7 @@ struct _LIBCPP_TYPE_VIS __widen_from_utf8<32>...@@ -1670,7 +1674,7 @@ struct _LIBCPP_TYPE_VIS __widen_from_utf8<32>
1670 __widen_from_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}1674 __widen_from_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
1671_LIBCPP_SUPPRESS_DEPRECATED_POP1675_LIBCPP_SUPPRESS_DEPRECATED_POP
16721676
1673 ~__widen_from_utf8();1677 ~__widen_from_utf8() override;
16741678
1675 template <class _OutputIterator>1679 template <class _OutputIterator>
1676 _LIBCPP_INLINE_VISIBILITY1680 _LIBCPP_INLINE_VISIBILITY
...@@ -1720,7 +1724,7 @@ public:...@@ -1720,7 +1724,7 @@ public:
1720 static locale::id id;1724 static locale::id id;
17211725
1722protected:1726protected:
1723 ~numpunct();1727 ~numpunct() override;
1724 virtual char_type do_decimal_point() const;1728 virtual char_type do_decimal_point() const;
1725 virtual char_type do_thousands_sep() const;1729 virtual char_type do_thousands_sep() const;
1726 virtual string do_grouping() const;1730 virtual string do_grouping() const;
...@@ -1752,7 +1756,7 @@ public:...@@ -1752,7 +1756,7 @@ public:
1752 static locale::id id;1756 static locale::id id;
17531757
1754protected:1758protected:
1755 ~numpunct();1759 ~numpunct() override;
1756 virtual char_type do_decimal_point() const;1760 virtual char_type do_decimal_point() const;
1757 virtual char_type do_thousands_sep() const;1761 virtual char_type do_thousands_sep() const;
1758 virtual string do_grouping() const;1762 virtual string do_grouping() const;
...@@ -1781,7 +1785,7 @@ public:...@@ -1781,7 +1785,7 @@ public:
1781 explicit numpunct_byname(const string& __nm, size_t __refs = 0);1785 explicit numpunct_byname(const string& __nm, size_t __refs = 0);
17821786
1783protected:1787protected:
1784 ~numpunct_byname();1788 ~numpunct_byname() override;
17851789
1786private:1790private:
1787 void __init(const char*);1791 void __init(const char*);
...@@ -1800,7 +1804,7 @@ public:...@@ -1800,7 +1804,7 @@ public:
1800 explicit numpunct_byname(const string& __nm, size_t __refs = 0);1804 explicit numpunct_byname(const string& __nm, size_t __refs = 0);
18011805
1802protected:1806protected:
1803 ~numpunct_byname();1807 ~numpunct_byname() override;
18041808
1805private:1809private:
1806 void __init(const char*);1810 void __init(const char*);
lib/libcxx/include/__memory/addressof.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22inline _LIBCPP_CONSTEXPR_AFTER_CXX1422inline _LIBCPP_CONSTEXPR_SINCE_CXX17
23_LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY23_LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
24_Tp*24_Tp*
25addressof(_Tp& __x) _NOEXCEPT25addressof(_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 {...@@ -25,6 +25,7 @@ struct allocation_result {
25 _Pointer ptr;25 _Pointer ptr;
26 size_t count;26 size_t count;
27};27};
28_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result);
2829
29template <class _Alloc>30template <class _Alloc>
30[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr31[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr
lib/libcxx/include/__memory/allocator.h+14-11
...@@ -13,11 +13,14 @@...@@ -13,11 +13,14 @@
13#include <__config>13#include <__config>
14#include <__memory/allocate_at_least.h>14#include <__memory/allocate_at_least.h>
15#include <__memory/allocator_traits.h>15#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>
16#include <__utility/forward.h>20#include <__utility/forward.h>
17#include <cstddef>21#include <cstddef>
18#include <new>22#include <new>
19#include <stdexcept>23#include <stdexcept>
20#include <type_traits>
2124
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header26# pragma GCC system_header
...@@ -95,14 +98,14 @@ public:...@@ -95,14 +98,14 @@ public:
95 typedef true_type propagate_on_container_move_assignment;98 typedef true_type propagate_on_container_move_assignment;
96 typedef true_type is_always_equal;99 typedef true_type is_always_equal;
97100
98 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17101 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
99 allocator() _NOEXCEPT = default;102 allocator() _NOEXCEPT = default;
100103
101 template <class _Up>104 template <class _Up>
102 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17105 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
103 allocator(const allocator<_Up>&) _NOEXCEPT { }106 allocator(const allocator<_Up>&) _NOEXCEPT { }
104107
105 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17108 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
106 _Tp* allocate(size_t __n) {109 _Tp* allocate(size_t __n) {
107 if (__n > allocator_traits<allocator>::max_size(*this))110 if (__n > allocator_traits<allocator>::max_size(*this))
108 __throw_bad_array_new_length();111 __throw_bad_array_new_length();
...@@ -120,7 +123,7 @@ public:...@@ -120,7 +123,7 @@ public:
120 }123 }
121#endif124#endif
122125
123 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17126 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
124 void deallocate(_Tp* __p, size_t __n) _NOEXCEPT {127 void deallocate(_Tp* __p, size_t __n) _NOEXCEPT {
125 if (__libcpp_is_constant_evaluated()) {128 if (__libcpp_is_constant_evaluated()) {
126 ::operator delete(__p);129 ::operator delete(__p);
...@@ -184,14 +187,14 @@ public:...@@ -184,14 +187,14 @@ public:
184 typedef true_type propagate_on_container_move_assignment;187 typedef true_type propagate_on_container_move_assignment;
185 typedef true_type is_always_equal;188 typedef true_type is_always_equal;
186189
187 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17190 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
188 allocator() _NOEXCEPT = default;191 allocator() _NOEXCEPT = default;
189192
190 template <class _Up>193 template <class _Up>
191 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17194 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
192 allocator(const allocator<_Up>&) _NOEXCEPT { }195 allocator(const allocator<_Up>&) _NOEXCEPT { }
193196
194 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17197 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
195 const _Tp* allocate(size_t __n) {198 const _Tp* allocate(size_t __n) {
196 if (__n > allocator_traits<allocator>::max_size(*this))199 if (__n > allocator_traits<allocator>::max_size(*this))
197 __throw_bad_array_new_length();200 __throw_bad_array_new_length();
...@@ -209,7 +212,7 @@ public:...@@ -209,7 +212,7 @@ public:
209 }212 }
210#endif213#endif
211214
212 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17215 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
213 void deallocate(const _Tp* __p, size_t __n) {216 void deallocate(const _Tp* __p, size_t __n) {
214 if (__libcpp_is_constant_evaluated()) {217 if (__libcpp_is_constant_evaluated()) {
215 ::operator delete(const_cast<_Tp*>(__p));218 ::operator delete(const_cast<_Tp*>(__p));
...@@ -258,11 +261,11 @@ public:...@@ -258,11 +261,11 @@ public:
258};261};
259262
260template <class _Tp, class _Up>263template <class _Tp, class _Up>
261inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17264inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
262bool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return true;}265bool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return true;}
263266
264template <class _Tp, class _Up>267template <class _Tp, class _Up>
265inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17268inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
266bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;}269bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;}
267270
268_LIBCPP_END_NAMESPACE_STD271_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__memory/allocator_arg_t.h+4-2
...@@ -12,8 +12,10 @@...@@ -12,8 +12,10 @@
1212
13#include <__config>13#include <__config>
14#include <__memory/uses_allocator.h>14#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>
15#include <__utility/forward.h>18#include <__utility/forward.h>
16#include <type_traits>
1719
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header21# pragma GCC system_header
...@@ -36,7 +38,7 @@ extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg;...@@ -36,7 +38,7 @@ extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg;
36template <class _Tp, class _Alloc, class ..._Args>38template <class _Tp, class _Alloc, class ..._Args>
37struct __uses_alloc_ctor_imp39struct __uses_alloc_ctor_imp
38{40{
39 typedef _LIBCPP_NODEBUG __uncvref_t<_Alloc> _RawAlloc;41 typedef _LIBCPP_NODEBUG __remove_cvref_t<_Alloc> _RawAlloc;
40 static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;42 static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;
41 static const bool __ic =43 static const bool __ic =
42 is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;44 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 @@...@@ -13,9 +13,16 @@
13#include <__config>13#include <__config>
14#include <__memory/construct_at.h>14#include <__memory/construct_at.h>
15#include <__memory/pointer_traits.h>15#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>
16#include <__utility/forward.h>24#include <__utility/forward.h>
17#include <limits>25#include <limits>
18#include <type_traits>
1926
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header28# pragma GCC system_header
...@@ -28,12 +35,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -28,12 +35,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2835
29#define _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(NAME, PROPERTY) \36#define _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(NAME, PROPERTY) \
30 template <class _Tp, class = void> struct NAME : false_type { }; \37 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
33// __pointer40// __pointer
34_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_pointer, pointer);41_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_pointer, pointer);
35template <class _Tp, class _Alloc,42template <class _Tp, class _Alloc,
36 class _RawAlloc = typename remove_reference<_Alloc>::type,43 class _RawAlloc = __libcpp_remove_reference_t<_Alloc>,
37 bool = __has_pointer<_RawAlloc>::value>44 bool = __has_pointer<_RawAlloc>::value>
38struct __pointer {45struct __pointer {
39 using type _LIBCPP_NODEBUG = typename _RawAlloc::pointer;46 using type _LIBCPP_NODEBUG = typename _RawAlloc::pointer;
...@@ -152,13 +159,12 @@ _LIBCPP_SUPPRESS_DEPRECATED_PUSH...@@ -152,13 +159,12 @@ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
152template <class _Tp, class _Up, class = void>159template <class _Tp, class _Up, class = void>
153struct __has_rebind_other : false_type { };160struct __has_rebind_other : false_type { };
154template <class _Tp, class _Up>161template <class _Tp, class _Up>
155struct __has_rebind_other<_Tp, _Up, typename __void_t<162struct __has_rebind_other<_Tp, _Up, __void_t<typename _Tp::template rebind<_Up>::other> > : true_type { };
156 typename _Tp::template rebind<_Up>::other
157>::type> : true_type { };
158163
159template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value>164template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value>
160struct __allocator_traits_rebind {165struct __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;
162};168};
163template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>169template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
164struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true> {170struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true> {
...@@ -181,7 +187,7 @@ struct __has_allocate_hint : false_type { };...@@ -181,7 +187,7 @@ struct __has_allocate_hint : false_type { };
181187
182template <class _Alloc, class _SizeType, class _ConstVoidPtr>188template <class _Alloc, class _SizeType, class _ConstVoidPtr>
183struct __has_allocate_hint<_Alloc, _SizeType, _ConstVoidPtr, decltype(189struct __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>())
185)> : true_type { };191)> : true_type { };
186192
187// __has_construct193// __has_construct
...@@ -190,7 +196,7 @@ struct __has_construct_impl : false_type { };...@@ -190,7 +196,7 @@ struct __has_construct_impl : false_type { };
190196
191template <class _Alloc, class ..._Args>197template <class _Alloc, class ..._Args>
192struct __has_construct_impl<decltype(198struct __has_construct_impl<decltype(
193 (void)declval<_Alloc>().construct(declval<_Args>()...)199 (void)std::declval<_Alloc>().construct(std::declval<_Args>()...)
194), _Alloc, _Args...> : true_type { };200), _Alloc, _Args...> : true_type { };
195201
196template <class _Alloc, class ..._Args>202template <class _Alloc, class ..._Args>
...@@ -202,7 +208,7 @@ struct __has_destroy : false_type { };...@@ -202,7 +208,7 @@ struct __has_destroy : false_type { };
202208
203template <class _Alloc, class _Pointer>209template <class _Alloc, class _Pointer>
204struct __has_destroy<_Alloc, _Pointer, decltype(210struct __has_destroy<_Alloc, _Pointer, decltype(
205 (void)declval<_Alloc>().destroy(declval<_Pointer>())211 (void)std::declval<_Alloc>().destroy(std::declval<_Pointer>())
206)> : true_type { };212)> : true_type { };
207213
208// __has_max_size214// __has_max_size
...@@ -211,7 +217,7 @@ struct __has_max_size : false_type { };...@@ -211,7 +217,7 @@ struct __has_max_size : false_type { };
211217
212template <class _Alloc>218template <class _Alloc>
213struct __has_max_size<_Alloc, decltype(219struct __has_max_size<_Alloc, decltype(
214 (void)declval<_Alloc&>().max_size()220 (void)std::declval<_Alloc&>().max_size()
215)> : true_type { };221)> : true_type { };
216222
217// __has_select_on_container_copy_construction223// __has_select_on_container_copy_construction
...@@ -220,7 +226,7 @@ struct __has_select_on_container_copy_construction : false_type { };...@@ -220,7 +226,7 @@ struct __has_select_on_container_copy_construction : false_type { };
220226
221template <class _Alloc>227template <class _Alloc>
222struct __has_select_on_container_copy_construction<_Alloc, decltype(228struct __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()
224)> : true_type { };230)> : true_type { };
225231
226_LIBCPP_SUPPRESS_DEPRECATED_POP232_LIBCPP_SUPPRESS_DEPRECATED_POP
...@@ -257,14 +263,14 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits...@@ -257,14 +263,14 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
257 };263 };
258#endif // _LIBCPP_CXX03_LANG264#endif // _LIBCPP_CXX03_LANG
259265
260 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17266 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
261 static pointer allocate(allocator_type& __a, size_type __n) {267 static pointer allocate(allocator_type& __a, size_type __n) {
262 return __a.allocate(__n);268 return __a.allocate(__n);
263 }269 }
264270
265 template <class _Ap = _Alloc, class =271 template <class _Ap = _Alloc, class =
266 __enable_if_t<__has_allocate_hint<_Ap, size_type, const_void_pointer>::value> >272 __enable_if_t<__has_allocate_hint<_Ap, size_type, const_void_pointer>::value> >
267 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17273 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
268 static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) {274 static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) {
269 _LIBCPP_SUPPRESS_DEPRECATED_PUSH275 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
270 return __a.allocate(__n, __hint);276 return __a.allocate(__n, __hint);
...@@ -272,19 +278,19 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits...@@ -272,19 +278,19 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
272 }278 }
273 template <class _Ap = _Alloc, class = void, class =279 template <class _Ap = _Alloc, class = void, class =
274 __enable_if_t<!__has_allocate_hint<_Ap, size_type, const_void_pointer>::value> >280 __enable_if_t<!__has_allocate_hint<_Ap, size_type, const_void_pointer>::value> >
275 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17281 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
276 static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer) {282 static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer) {
277 return __a.allocate(__n);283 return __a.allocate(__n);
278 }284 }
279285
280 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17286 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
281 static void deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT {287 static void deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT {
282 __a.deallocate(__p, __n);288 __a.deallocate(__p, __n);
283 }289 }
284290
285 template <class _Tp, class... _Args, class =291 template <class _Tp, class... _Args, class =
286 __enable_if_t<__has_construct<allocator_type, _Tp*, _Args...>::value> >292 __enable_if_t<__has_construct<allocator_type, _Tp*, _Args...>::value> >
287 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17293 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
288 static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args) {294 static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args) {
289 _LIBCPP_SUPPRESS_DEPRECATED_PUSH295 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
290 __a.construct(__p, _VSTD::forward<_Args>(__args)...);296 __a.construct(__p, _VSTD::forward<_Args>(__args)...);
...@@ -292,7 +298,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits...@@ -292,7 +298,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
292 }298 }
293 template <class _Tp, class... _Args, class = void, class =299 template <class _Tp, class... _Args, class = void, class =
294 __enable_if_t<!__has_construct<allocator_type, _Tp*, _Args...>::value> >300 __enable_if_t<!__has_construct<allocator_type, _Tp*, _Args...>::value> >
295 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17301 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
296 static void construct(allocator_type&, _Tp* __p, _Args&&... __args) {302 static void construct(allocator_type&, _Tp* __p, _Args&&... __args) {
297#if _LIBCPP_STD_VER > 17303#if _LIBCPP_STD_VER > 17
298 _VSTD::construct_at(__p, _VSTD::forward<_Args>(__args)...);304 _VSTD::construct_at(__p, _VSTD::forward<_Args>(__args)...);
...@@ -303,7 +309,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits...@@ -303,7 +309,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
303309
304 template <class _Tp, class =310 template <class _Tp, class =
305 __enable_if_t<__has_destroy<allocator_type, _Tp*>::value> >311 __enable_if_t<__has_destroy<allocator_type, _Tp*>::value> >
306 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17312 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
307 static void destroy(allocator_type& __a, _Tp* __p) {313 static void destroy(allocator_type& __a, _Tp* __p) {
308 _LIBCPP_SUPPRESS_DEPRECATED_PUSH314 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
309 __a.destroy(__p);315 __a.destroy(__p);
...@@ -311,7 +317,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits...@@ -311,7 +317,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
311 }317 }
312 template <class _Tp, class = void, class =318 template <class _Tp, class = void, class =
313 __enable_if_t<!__has_destroy<allocator_type, _Tp*>::value> >319 __enable_if_t<!__has_destroy<allocator_type, _Tp*>::value> >
314 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17320 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
315 static void destroy(allocator_type&, _Tp* __p) {321 static void destroy(allocator_type&, _Tp* __p) {
316#if _LIBCPP_STD_VER > 17322#if _LIBCPP_STD_VER > 17
317 _VSTD::destroy_at(__p);323 _VSTD::destroy_at(__p);
...@@ -322,7 +328,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits...@@ -322,7 +328,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
322328
323 template <class _Ap = _Alloc, class =329 template <class _Ap = _Alloc, class =
324 __enable_if_t<__has_max_size<const _Ap>::value> >330 __enable_if_t<__has_max_size<const _Ap>::value> >
325 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17331 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
326 static size_type max_size(const allocator_type& __a) _NOEXCEPT {332 static size_type max_size(const allocator_type& __a) _NOEXCEPT {
327 _LIBCPP_SUPPRESS_DEPRECATED_PUSH333 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
328 return __a.max_size();334 return __a.max_size();
...@@ -330,33 +336,32 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits...@@ -330,33 +336,32 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
330 }336 }
331 template <class _Ap = _Alloc, class = void, class =337 template <class _Ap = _Alloc, class = void, class =
332 __enable_if_t<!__has_max_size<const _Ap>::value> >338 __enable_if_t<!__has_max_size<const _Ap>::value> >
333 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17339 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
334 static size_type max_size(const allocator_type&) _NOEXCEPT {340 static size_type max_size(const allocator_type&) _NOEXCEPT {
335 return numeric_limits<size_type>::max() / sizeof(value_type);341 return numeric_limits<size_type>::max() / sizeof(value_type);
336 }342 }
337343
338 template <class _Ap = _Alloc, class =344 template <class _Ap = _Alloc, class =
339 __enable_if_t<__has_select_on_container_copy_construction<const _Ap>::value> >345 __enable_if_t<__has_select_on_container_copy_construction<const _Ap>::value> >
340 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17346 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
341 static allocator_type select_on_container_copy_construction(const allocator_type& __a) {347 static allocator_type select_on_container_copy_construction(const allocator_type& __a) {
342 return __a.select_on_container_copy_construction();348 return __a.select_on_container_copy_construction();
343 }349 }
344 template <class _Ap = _Alloc, class = void, class =350 template <class _Ap = _Alloc, class = void, class =
345 __enable_if_t<!__has_select_on_container_copy_construction<const _Ap>::value> >351 __enable_if_t<!__has_select_on_container_copy_construction<const _Ap>::value> >
346 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17352 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
347 static allocator_type select_on_container_copy_construction(const allocator_type& __a) {353 static allocator_type select_on_container_copy_construction(const allocator_type& __a) {
348 return __a;354 return __a;
349 }355 }
350};356};
351357
352template <class _Traits, class _Tp>
353struct __rebind_alloc_helper {
354#ifndef _LIBCPP_CXX03_LANG358#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>;
356#else361#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;
358#endif364#endif
359};
360365
361// __is_default_allocator366// __is_default_allocator
362template <class _Tp>367template <class _Tp>
lib/libcxx/include/__memory/assume_aligned.h+1-1
...@@ -12,9 +12,9 @@...@@ -12,9 +12,9 @@
1212
13#include <__assert>13#include <__assert>
14#include <__config>14#include <__config>
15#include <__type_traits/is_constant_evaluated.h>
15#include <cstddef>16#include <cstddef>
16#include <cstdint>17#include <cstdint>
17#include <type_traits> // for is_constant_evaluated()
1818
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header20# 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 @@...@@ -11,10 +11,21 @@
11#define _LIBCPP___MEMORY_COMPRESSED_PAIR_H11#define _LIBCPP___MEMORY_COMPRESSED_PAIR_H
1212
13#include <__config>13#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>
14#include <__utility/forward.h>25#include <__utility/forward.h>
15#include <__utility/move.h>26#include <__utility/move.h>
16#include <tuple> // needed in c++03 for some constructors27#include <__utility/piecewise_construct.h>
17#include <type_traits>28#include <cstddef>
1829
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header31# pragma GCC system_header
...@@ -41,12 +52,12 @@ struct __compressed_pair_elem {...@@ -41,12 +52,12 @@ struct __compressed_pair_elem {
4152
42#ifndef _LIBCPP_CXX03_LANG53#ifndef _LIBCPP_CXX03_LANG
43 template <class... _Args, size_t... _Indices>54 template <class... _Args, size_t... _Indices>
44 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1455 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
45 explicit __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indices...>)56 explicit __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indices...>)
46 : __value_(std::forward<_Args>(std::get<_Indices>(__args))...) {}57 : __value_(std::forward<_Args>(std::get<_Indices>(__args))...) {}
47#endif58#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_; }
50 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return __value_; }61 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return __value_; }
5162
52private:63private:
...@@ -70,12 +81,12 @@ struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp {...@@ -70,12 +81,12 @@ struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp {
7081
71#ifndef _LIBCPP_CXX03_LANG82#ifndef _LIBCPP_CXX03_LANG
72 template <class... _Args, size_t... _Indices>83 template <class... _Args, size_t... _Indices>
73 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1484 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
74 __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indices...>)85 __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indices...>)
75 : __value_type(std::forward<_Args>(std::get<_Indices>(__args))...) {}86 : __value_type(std::forward<_Args>(std::get<_Indices>(__args))...) {}
76#endif87#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; }
79 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return *this; }90 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return *this; }
80};91};
8192
...@@ -109,14 +120,14 @@ public:...@@ -109,14 +120,14 @@ public:
109120
110#ifndef _LIBCPP_CXX03_LANG121#ifndef _LIBCPP_CXX03_LANG
111 template <class... _Args1, class... _Args2>122 template <class... _Args1, class... _Args2>
112 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14123 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
113 explicit __compressed_pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args,124 explicit __compressed_pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args,
114 tuple<_Args2...> __second_args)125 tuple<_Args2...> __second_args)
115 : _Base1(__pc, std::move(__first_args), typename __make_tuple_indices<sizeof...(_Args1)>::type()),126 : _Base1(__pc, std::move(__first_args), typename __make_tuple_indices<sizeof...(_Args1)>::type()),
116 _Base2(__pc, std::move(__second_args), typename __make_tuple_indices<sizeof...(_Args2)>::type()) {}127 _Base2(__pc, std::move(__second_args), typename __make_tuple_indices<sizeof...(_Args2)>::type()) {}
117#endif128#endif
118129
119 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11130 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
120 typename _Base1::reference first() _NOEXCEPT {131 typename _Base1::reference first() _NOEXCEPT {
121 return static_cast<_Base1&>(*this).__get();132 return static_cast<_Base1&>(*this).__get();
122 }133 }
...@@ -126,7 +137,7 @@ public:...@@ -126,7 +137,7 @@ public:
126 return static_cast<_Base1 const&>(*this).__get();137 return static_cast<_Base1 const&>(*this).__get();
127 }138 }
128139
129 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11140 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
130 typename _Base2::reference second() _NOEXCEPT {141 typename _Base2::reference second() _NOEXCEPT {
131 return static_cast<_Base2&>(*this).__get();142 return static_cast<_Base2&>(*this).__get();
132 }143 }
...@@ -145,7 +156,7 @@ public:...@@ -145,7 +156,7 @@ public:
145 return static_cast<_Base2*>(__pair);156 return static_cast<_Base2*>(__pair);
146 }157 }
147158
148 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11159 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
149 void swap(__compressed_pair& __x)160 void swap(__compressed_pair& __x)
150 _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value) {161 _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value) {
151 using std::swap;162 using std::swap;
...@@ -155,7 +166,7 @@ public:...@@ -155,7 +166,7 @@ public:
155};166};
156167
157template <class _T1, class _T2>168template <class _T1, class _T2>
158inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11169inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
159void swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y)170void swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y)
160 _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value) {171 _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value) {
161 __x.swap(__y);172 __x.swap(__y);
lib/libcxx/include/__memory/concepts.h+5-4
...@@ -10,14 +10,15 @@...@@ -10,14 +10,15 @@
10#ifndef _LIBCPP___MEMORY_CONCEPTS_H10#ifndef _LIBCPP___MEMORY_CONCEPTS_H
11#define _LIBCPP___MEMORY_CONCEPTS_H11#define _LIBCPP___MEMORY_CONCEPTS_H
1212
13#include <__concepts/same_as.h>
13#include <__config>14#include <__config>
14#include <__iterator/concepts.h>15#include <__iterator/concepts.h>
15#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
16#include <__iterator/readable_traits.h>17#include <__iterator/readable_traits.h>
17#include <__ranges/access.h>18#include <__ranges/access.h>
18#include <__ranges/concepts.h>19#include <__ranges/concepts.h>
19#include <concepts>20#include <__type_traits/is_reference.h>
20#include <type_traits>21#include <__type_traits/remove_cvref.h>
2122
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header24# pragma GCC system_header
...@@ -25,7 +26,7 @@...@@ -25,7 +26,7 @@
2526
26_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2728
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)29#if _LIBCPP_STD_VER > 17
2930
30namespace ranges {31namespace ranges {
3132
...@@ -61,7 +62,7 @@ concept __nothrow_forward_range =...@@ -61,7 +62,7 @@ concept __nothrow_forward_range =
6162
62} // namespace ranges63} // namespace ranges
6364
64#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)65#endif // _LIBCPP_STD_VER > 17
6566
66_LIBCPP_END_NAMESPACE_STD67_LIBCPP_END_NAMESPACE_STD
6768
lib/libcxx/include/__memory/construct_at.h+14-11
...@@ -15,9 +15,12 @@...@@ -15,9 +15,12 @@
15#include <__iterator/access.h>15#include <__iterator/access.h>
16#include <__memory/addressof.h>16#include <__memory/addressof.h>
17#include <__memory/voidify.h>17#include <__memory/voidify.h>
18#include <__type_traits/enable_if.h>
19#include <__type_traits/is_array.h>
20#include <__utility/declval.h>
18#include <__utility/forward.h>21#include <__utility/forward.h>
19#include <__utility/move.h>22#include <__utility/move.h>
20#include <type_traits>23#include <new>
2124
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header26# pragma GCC system_header
...@@ -29,7 +32,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -29,7 +32,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2932
30#if _LIBCPP_STD_VER > 1733#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>()...))>
33_LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __args) {36_LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __args) {
34 _LIBCPP_ASSERT(__location != nullptr, "null pointer given to construct_at");37 _LIBCPP_ASSERT(__location != nullptr, "null pointer given to construct_at");
35 return ::new (_VSTD::__voidify(*__location)) _Tp(_VSTD::forward<_Args>(__args)...);38 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&&... __...@@ -37,7 +40,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __
3740
38#endif41#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>()...))>
41_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __construct_at(_Tp* __location, _Args&&... __args) {44_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __construct_at(_Tp* __location, _Args&&... __args) {
42#if _LIBCPP_STD_VER > 1745#if _LIBCPP_STD_VER > 17
43 return std::construct_at(__location, std::forward<_Args>(__args)...);46 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...@@ -53,11 +56,11 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __construct_at(_Tp* __location, _Ar
53// taking an array).56// taking an array).
5457
55template <class _ForwardIterator>58template <class _ForwardIterator>
56_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1759_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
57_ForwardIterator __destroy(_ForwardIterator, _ForwardIterator);60_ForwardIterator __destroy(_ForwardIterator, _ForwardIterator);
5861
59template <class _Tp, typename enable_if<!is_array<_Tp>::value, int>::type = 0>62template <class _Tp, typename enable_if<!is_array<_Tp>::value, int>::type = 0>
60_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1763_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
61void __destroy_at(_Tp* __loc) {64void __destroy_at(_Tp* __loc) {
62 _LIBCPP_ASSERT(__loc != nullptr, "null pointer given to destroy_at");65 _LIBCPP_ASSERT(__loc != nullptr, "null pointer given to destroy_at");
63 __loc->~_Tp();66 __loc->~_Tp();
...@@ -65,7 +68,7 @@ void __destroy_at(_Tp* __loc) {...@@ -65,7 +68,7 @@ void __destroy_at(_Tp* __loc) {
6568
66#if _LIBCPP_STD_VER > 1769#if _LIBCPP_STD_VER > 17
67template <class _Tp, typename enable_if<is_array<_Tp>::value, int>::type = 0>70template <class _Tp, typename enable_if<is_array<_Tp>::value, int>::type = 0>
68_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1771_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
69void __destroy_at(_Tp* __loc) {72void __destroy_at(_Tp* __loc) {
70 _LIBCPP_ASSERT(__loc != nullptr, "null pointer given to destroy_at");73 _LIBCPP_ASSERT(__loc != nullptr, "null pointer given to destroy_at");
71 _VSTD::__destroy(_VSTD::begin(*__loc), _VSTD::end(*__loc));74 _VSTD::__destroy(_VSTD::begin(*__loc), _VSTD::end(*__loc));
...@@ -73,7 +76,7 @@ void __destroy_at(_Tp* __loc) {...@@ -73,7 +76,7 @@ void __destroy_at(_Tp* __loc) {
73#endif76#endif
7477
75template <class _ForwardIterator>78template <class _ForwardIterator>
76_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1779_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
77_ForwardIterator __destroy(_ForwardIterator __first, _ForwardIterator __last) {80_ForwardIterator __destroy(_ForwardIterator __first, _ForwardIterator __last) {
78 for (; __first != __last; ++__first)81 for (; __first != __last; ++__first)
79 _VSTD::__destroy_at(_VSTD::addressof(*__first));82 _VSTD::__destroy_at(_VSTD::addressof(*__first));
...@@ -83,27 +86,27 @@ _ForwardIterator __destroy(_ForwardIterator __first, _ForwardIterator __last) {...@@ -83,27 +86,27 @@ _ForwardIterator __destroy(_ForwardIterator __first, _ForwardIterator __last) {
83#if _LIBCPP_STD_VER > 1486#if _LIBCPP_STD_VER > 14
8487
85template <class _Tp, enable_if_t<!is_array_v<_Tp>, int> = 0>88template <class _Tp, enable_if_t<!is_array_v<_Tp>, int> = 0>
86_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1789_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
87void destroy_at(_Tp* __loc) {90void destroy_at(_Tp* __loc) {
88 _VSTD::__destroy_at(__loc);91 _VSTD::__destroy_at(__loc);
89}92}
9093
91#if _LIBCPP_STD_VER > 1794#if _LIBCPP_STD_VER > 17
92template <class _Tp, enable_if_t<is_array_v<_Tp>, int> = 0>95template <class _Tp, enable_if_t<is_array_v<_Tp>, int> = 0>
93_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX1796_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
94void destroy_at(_Tp* __loc) {97void destroy_at(_Tp* __loc) {
95 _VSTD::__destroy_at(__loc);98 _VSTD::__destroy_at(__loc);
96}99}
97#endif100#endif
98101
99template <class _ForwardIterator>102template <class _ForwardIterator>
100_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17103_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
101void destroy(_ForwardIterator __first, _ForwardIterator __last) {104void destroy(_ForwardIterator __first, _ForwardIterator __last) {
102 (void)_VSTD::__destroy(_VSTD::move(__first), _VSTD::move(__last));105 (void)_VSTD::__destroy(_VSTD::move(__first), _VSTD::move(__last));
103}106}
104107
105template <class _ForwardIterator, class _Size>108template <class _ForwardIterator, class _Size>
106_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17109_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
107_ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) {110_ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) {
108 for (; __n > 0; (void)++__first, --__n)111 for (; __n > 0; (void)++__first, --__n)
109 _VSTD::__destroy_at(_VSTD::addressof(*__first));112 _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 @@...@@ -12,8 +12,15 @@
1212
13#include <__config>13#include <__config>
14#include <__memory/addressof.h>14#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>
15#include <cstddef>23#include <cstddef>
16#include <type_traits>
1724
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header26# pragma GCC system_header
...@@ -25,8 +32,7 @@ template <class _Tp, class = void>...@@ -25,8 +32,7 @@ template <class _Tp, class = void>
25struct __has_element_type : false_type {};32struct __has_element_type : false_type {};
2633
27template <class _Tp>34template <class _Tp>
28struct __has_element_type<_Tp,35struct __has_element_type<_Tp, __void_t<typename _Tp::element_type> > : true_type {};
29 typename __void_t<typename _Tp::element_type>::type> : true_type {};
3036
31template <class _Ptr, bool = __has_element_type<_Ptr>::value>37template <class _Ptr, bool = __has_element_type<_Ptr>::value>
32struct __pointer_traits_element_type;38struct __pointer_traits_element_type;
...@@ -53,8 +59,7 @@ template <class _Tp, class = void>...@@ -53,8 +59,7 @@ template <class _Tp, class = void>
53struct __has_difference_type : false_type {};59struct __has_difference_type : false_type {};
5460
55template <class _Tp>61template <class _Tp>
56struct __has_difference_type<_Tp,62struct __has_difference_type<_Tp, __void_t<typename _Tp::difference_type> > : true_type {};
57 typename __void_t<typename _Tp::difference_type>::type> : true_type {};
5863
59template <class _Ptr, bool = __has_difference_type<_Ptr>::value>64template <class _Ptr, bool = __has_difference_type<_Ptr>::value>
60struct __pointer_traits_difference_type65struct __pointer_traits_difference_type
...@@ -123,9 +128,8 @@ struct _LIBCPP_TEMPLATE_VIS pointer_traits...@@ -123,9 +128,8 @@ struct _LIBCPP_TEMPLATE_VIS pointer_traits
123private:128private:
124 struct __nat {};129 struct __nat {};
125public:130public:
126 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17131 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
127 static pointer pointer_to(typename conditional<is_void<element_type>::value,132 static pointer pointer_to(__conditional_t<is_void<element_type>::value, __nat, element_type>& __r)
128 __nat, element_type>::type& __r)
129 {return pointer::pointer_to(__r);}133 {return pointer::pointer_to(__r);}
130};134};
131135
...@@ -145,20 +149,18 @@ struct _LIBCPP_TEMPLATE_VIS pointer_traits<_Tp*>...@@ -145,20 +149,18 @@ struct _LIBCPP_TEMPLATE_VIS pointer_traits<_Tp*>
145private:149private:
146 struct __nat {};150 struct __nat {};
147public:151public:
148 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17152 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
149 static pointer pointer_to(typename conditional<is_void<element_type>::value,153 static pointer pointer_to(__conditional_t<is_void<element_type>::value, __nat, element_type>& __r) _NOEXCEPT
150 __nat, element_type>::type& __r) _NOEXCEPT
151 {return _VSTD::addressof(__r);}154 {return _VSTD::addressof(__r);}
152};155};
153156
154template <class _From, class _To>
155struct __rebind_pointer {
156#ifndef _LIBCPP_CXX03_LANG157#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>;
158#else160#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;
160#endif163#endif
161};
162164
163// to_address165// to_address
164166
...@@ -177,7 +179,7 @@ struct _HasToAddress : false_type {};...@@ -177,7 +179,7 @@ struct _HasToAddress : false_type {};
177179
178template <class _Pointer>180template <class _Pointer>
179struct _HasToAddress<_Pointer,181struct _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&>()))
181> : true_type {};183> : true_type {};
182184
183template <class _Pointer, class = void>185template <class _Pointer, class = void>
...@@ -185,7 +187,7 @@ struct _HasArrow : false_type {};...@@ -185,7 +187,7 @@ struct _HasArrow : false_type {};
185187
186template <class _Pointer>188template <class _Pointer>
187struct _HasArrow<_Pointer,189struct _HasArrow<_Pointer,
188 decltype((void)declval<const _Pointer&>().operator->())190 decltype((void)std::declval<const _Pointer&>().operator->())
189> : true_type {};191> : true_type {};
190192
191template <class _Pointer>193template <class _Pointer>
...@@ -198,7 +200,7 @@ template <class _Pointer, class = __enable_if_t<...@@ -198,7 +200,7 @@ template <class _Pointer, class = __enable_if_t<
198 _And<is_class<_Pointer>, _IsFancyPointer<_Pointer> >::value200 _And<is_class<_Pointer>, _IsFancyPointer<_Pointer> >::value
199> >201> >
200_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR202_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
201typename decay<decltype(__to_address_helper<_Pointer>::__call(declval<const _Pointer&>()))>::type203typename decay<decltype(__to_address_helper<_Pointer>::__call(std::declval<const _Pointer&>()))>::type
202__to_address(const _Pointer& __p) _NOEXCEPT {204__to_address(const _Pointer& __p) _NOEXCEPT {
203 return __to_address_helper<_Pointer>::__call(__p);205 return __to_address_helper<_Pointer>::__call(__p);
204}206}
...@@ -206,16 +208,16 @@ __to_address(const _Pointer& __p) _NOEXCEPT {...@@ -206,16 +208,16 @@ __to_address(const _Pointer& __p) _NOEXCEPT {
206template <class _Pointer, class>208template <class _Pointer, class>
207struct __to_address_helper {209struct __to_address_helper {
208 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR210 _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->()))
210 __call(const _Pointer& __p) _NOEXCEPT {212 __call(const _Pointer& __p) _NOEXCEPT {
211 return _VSTD::__to_address(__p.operator->());213 return _VSTD::__to_address(__p.operator->());
212 }214 }
213};215};
214216
215template <class _Pointer>217template <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&>()))> {
217 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR219 _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&>()))
219 __call(const _Pointer& __p) _NOEXCEPT {221 __call(const _Pointer& __p) _NOEXCEPT {
220 return pointer_traits<_Pointer>::to_address(__p);222 return pointer_traits<_Pointer>::to_address(__p);
221 }223 }
lib/libcxx/include/__memory/ranges_construct_at.h+4-3
...@@ -22,6 +22,7 @@...@@ -22,6 +22,7 @@
22#include <__utility/declval.h>22#include <__utility/declval.h>
23#include <__utility/forward.h>23#include <__utility/forward.h>
24#include <__utility/move.h>24#include <__utility/move.h>
25#include <new>
2526
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header28# pragma GCC system_header
...@@ -29,7 +30,7 @@...@@ -29,7 +30,7 @@
2930
30_LIBCPP_BEGIN_NAMESPACE_STD31_LIBCPP_BEGIN_NAMESPACE_STD
3132
32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)33#if _LIBCPP_STD_VER > 17
33namespace ranges {34namespace ranges {
3435
35// construct_at36// construct_at
...@@ -38,7 +39,7 @@ namespace __construct_at {...@@ -38,7 +39,7 @@ namespace __construct_at {
3839
39struct __fn {40struct __fn {
40 template<class _Tp, class... _Args, class = decltype(41 template<class _Tp, class... _Args, class = decltype(
41 ::new (declval<void*>()) _Tp(declval<_Args>()...)42 ::new (std::declval<void*>()) _Tp(std::declval<_Args>()...)
42 )>43 )>
43 _LIBCPP_HIDE_FROM_ABI44 _LIBCPP_HIDE_FROM_ABI
44 constexpr _Tp* operator()(_Tp* __location, _Args&& ...__args) const {45 constexpr _Tp* operator()(_Tp* __location, _Args&& ...__args) const {
...@@ -117,7 +118,7 @@ inline namespace __cpo {...@@ -117,7 +118,7 @@ inline namespace __cpo {
117118
118} // namespace ranges119} // namespace ranges
119120
120#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)121#endif // _LIBCPP_STD_VER > 17
121122
122_LIBCPP_END_NAMESPACE_STD123_LIBCPP_END_NAMESPACE_STD
123124
lib/libcxx/include/__memory/ranges_uninitialized_algorithms.h+7-6
...@@ -23,8 +23,9 @@...@@ -23,8 +23,9 @@
23#include <__ranges/access.h>23#include <__ranges/access.h>
24#include <__ranges/concepts.h>24#include <__ranges/concepts.h>
25#include <__ranges/dangling.h>25#include <__ranges/dangling.h>
26#include <__type_traits/remove_reference.h>
26#include <__utility/move.h>27#include <__utility/move.h>
27#include <type_traits>28#include <new>
2829
29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
30# pragma GCC system_header31# pragma GCC system_header
...@@ -32,7 +33,7 @@...@@ -32,7 +33,7 @@
3233
33_LIBCPP_BEGIN_NAMESPACE_STD34_LIBCPP_BEGIN_NAMESPACE_STD
3435
35#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)36#if _LIBCPP_STD_VER > 17
3637
37namespace ranges {38namespace ranges {
3839
...@@ -255,7 +256,7 @@ struct __fn {...@@ -255,7 +256,7 @@ struct __fn {
255 sentinel_for<_InputIterator> _Sentinel1,256 sentinel_for<_InputIterator> _Sentinel1,
256 __nothrow_forward_iterator _OutputIterator,257 __nothrow_forward_iterator _OutputIterator,
257 __nothrow_sentinel_for<_OutputIterator> _Sentinel2>258 __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>>
259 uninitialized_move_result<_InputIterator, _OutputIterator>260 uninitialized_move_result<_InputIterator, _OutputIterator>
260 operator()(_InputIterator __ifirst, _Sentinel1 __ilast, _OutputIterator __ofirst, _Sentinel2 __olast) const {261 operator()(_InputIterator __ifirst, _Sentinel1 __ilast, _OutputIterator __ofirst, _Sentinel2 __olast) const {
261 using _ValueType = remove_reference_t<iter_reference_t<_OutputIterator>>;262 using _ValueType = remove_reference_t<iter_reference_t<_OutputIterator>>;
...@@ -266,7 +267,7 @@ struct __fn {...@@ -266,7 +267,7 @@ struct __fn {
266 }267 }
267268
268 template <input_range _InputRange, __nothrow_forward_range _OutputRange>269 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>>
270 uninitialized_move_result<borrowed_iterator_t<_InputRange>, borrowed_iterator_t<_OutputRange>>271 uninitialized_move_result<borrowed_iterator_t<_InputRange>, borrowed_iterator_t<_OutputRange>>
271 operator()(_InputRange&& __in_range, _OutputRange&& __out_range) const {272 operator()(_InputRange&& __in_range, _OutputRange&& __out_range) const {
272 return (*this)(ranges::begin(__in_range), ranges::end(__in_range),273 return (*this)(ranges::begin(__in_range), ranges::end(__in_range),
...@@ -291,7 +292,7 @@ struct __fn {...@@ -291,7 +292,7 @@ struct __fn {
291 template <input_iterator _InputIterator,292 template <input_iterator _InputIterator,
292 __nothrow_forward_iterator _OutputIterator,293 __nothrow_forward_iterator _OutputIterator,
293 __nothrow_sentinel_for<_OutputIterator> _Sentinel>294 __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>>
295 uninitialized_move_n_result<_InputIterator, _OutputIterator>296 uninitialized_move_n_result<_InputIterator, _OutputIterator>
296 operator()(_InputIterator __ifirst, iter_difference_t<_InputIterator> __n,297 operator()(_InputIterator __ifirst, iter_difference_t<_InputIterator> __n,
297 _OutputIterator __ofirst, _Sentinel __olast) const {298 _OutputIterator __ofirst, _Sentinel __olast) const {
...@@ -311,7 +312,7 @@ inline namespace __cpo {...@@ -311,7 +312,7 @@ inline namespace __cpo {
311312
312} // namespace ranges313} // namespace ranges
313314
314#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)315#endif // _LIBCPP_STD_VER > 17
315316
316_LIBCPP_END_NAMESPACE_STD317_LIBCPP_END_NAMESPACE_STD
317318
lib/libcxx/include/__memory/raw_storage_iterator.h+1
...@@ -16,6 +16,7 @@...@@ -16,6 +16,7 @@
16#include <__memory/addressof.h>16#include <__memory/addressof.h>
17#include <__utility/move.h>17#include <__utility/move.h>
18#include <cstddef>18#include <cstddef>
19#include <new>
1920
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header22# pragma GCC system_header
lib/libcxx/include/__memory/shared_ptr.h+159-65
...@@ -11,6 +11,8 @@...@@ -11,6 +11,8 @@
11#define _LIBCPP___MEMORY_SHARED_PTR_H11#define _LIBCPP___MEMORY_SHARED_PTR_H
1212
13#include <__availability>13#include <__availability>
14#include <__compare/compare_three_way.h>
15#include <__compare/ordering.h>
14#include <__config>16#include <__config>
15#include <__functional/binary_function.h>17#include <__functional/binary_function.h>
16#include <__functional/operations.h>18#include <__functional/operations.h>
...@@ -19,6 +21,7 @@...@@ -19,6 +21,7 @@
19#include <__memory/addressof.h>21#include <__memory/addressof.h>
20#include <__memory/allocation_guard.h>22#include <__memory/allocation_guard.h>
21#include <__memory/allocator.h>23#include <__memory/allocator.h>
24#include <__memory/allocator_destructor.h>
22#include <__memory/allocator_traits.h>25#include <__memory/allocator_traits.h>
23#include <__memory/auto_ptr.h>26#include <__memory/auto_ptr.h>
24#include <__memory/compressed_pair.h>27#include <__memory/compressed_pair.h>
...@@ -32,39 +35,19 @@...@@ -32,39 +35,19 @@
32#include <cstddef>35#include <cstddef>
33#include <cstdlib> // abort36#include <cstdlib> // abort
34#include <iosfwd>37#include <iosfwd>
38#include <new>
35#include <stdexcept>39#include <stdexcept>
36#include <type_traits>
37#include <typeinfo>40#include <typeinfo>
38#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)41#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
39# include <atomic>42# include <atomic>
40#endif43#endif
4144
42
43#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)45#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
44# pragma GCC system_header46# pragma GCC system_header
45#endif47#endif
4648
47_LIBCPP_BEGIN_NAMESPACE_STD49_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
68// NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively)51// NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively)
69// should be sufficient for thread safety.52// should be sufficient for thread safety.
70// See https://llvm.org/PR2280353// See https://llvm.org/PR22803
...@@ -128,8 +111,8 @@ class _LIBCPP_EXCEPTION_ABI bad_weak_ptr...@@ -128,8 +111,8 @@ class _LIBCPP_EXCEPTION_ABI bad_weak_ptr
128public:111public:
129 bad_weak_ptr() _NOEXCEPT = default;112 bad_weak_ptr() _NOEXCEPT = default;
130 bad_weak_ptr(const bad_weak_ptr&) _NOEXCEPT = default;113 bad_weak_ptr(const bad_weak_ptr&) _NOEXCEPT = default;
131 virtual ~bad_weak_ptr() _NOEXCEPT;114 ~bad_weak_ptr() _NOEXCEPT override;
132 virtual const char* what() const _NOEXCEPT;115 const char* what() const _NOEXCEPT override;
133};116};
134117
135_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY118_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
...@@ -194,7 +177,7 @@ public:...@@ -194,7 +177,7 @@ public:
194 : __shared_count(__refs),177 : __shared_count(__refs),
195 __shared_weak_owners_(__refs) {}178 __shared_weak_owners_(__refs) {}
196protected:179protected:
197 virtual ~__shared_weak_count();180 ~__shared_weak_count() override;
198181
199public:182public:
200#if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS)183#if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS)
...@@ -237,12 +220,12 @@ public:...@@ -237,12 +220,12 @@ public:
237 : __data_(__compressed_pair<_Tp, _Dp>(__p, _VSTD::move(__d)), _VSTD::move(__a)) {}220 : __data_(__compressed_pair<_Tp, _Dp>(__p, _VSTD::move(__d)), _VSTD::move(__a)) {}
238221
239#ifndef _LIBCPP_NO_RTTI222#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;
241#endif224#endif
242225
243private:226private:
244 virtual void __on_zero_shared() _NOEXCEPT;227 void __on_zero_shared() _NOEXCEPT override;
245 virtual void __on_zero_shared_weak() _NOEXCEPT;228 void __on_zero_shared_weak() _NOEXCEPT override;
246};229};
247230
248#ifndef _LIBCPP_NO_RTTI231#ifndef _LIBCPP_NO_RTTI
...@@ -277,6 +260,8 @@ __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT...@@ -277,6 +260,8 @@ __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT
277 __a.deallocate(_PTraits::pointer_to(*this), 1);260 __a.deallocate(_PTraits::pointer_to(*this), 1);
278}261}
279262
263struct __default_initialize_tag {};
264
280template <class _Tp, class _Alloc>265template <class _Tp, class _Alloc>
281struct __shared_ptr_emplace266struct __shared_ptr_emplace
282 : __shared_weak_count267 : __shared_weak_count
...@@ -295,6 +280,16 @@ struct __shared_ptr_emplace...@@ -295,6 +280,16 @@ struct __shared_ptr_emplace
295#endif280#endif
296 }281 }
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
298 _LIBCPP_HIDE_FROM_ABI293 _LIBCPP_HIDE_FROM_ABI
299 _Alloc* __get_alloc() _NOEXCEPT { return __storage_.__get_alloc(); }294 _Alloc* __get_alloc() _NOEXCEPT { return __storage_.__get_alloc(); }
300295
...@@ -302,7 +297,7 @@ struct __shared_ptr_emplace...@@ -302,7 +297,7 @@ struct __shared_ptr_emplace
302 _Tp* __get_elem() _NOEXCEPT { return __storage_.__get_elem(); }297 _Tp* __get_elem() _NOEXCEPT { return __storage_.__get_elem(); }
303298
304private:299private:
305 virtual void __on_zero_shared() _NOEXCEPT {300 void __on_zero_shared() _NOEXCEPT override {
306#if _LIBCPP_STD_VER > 17301#if _LIBCPP_STD_VER > 17
307 using _TpAlloc = typename __allocator_traits_rebind<_Alloc, _Tp>::type;302 using _TpAlloc = typename __allocator_traits_rebind<_Alloc, _Tp>::type;
308 _TpAlloc __tmp(*__get_alloc());303 _TpAlloc __tmp(*__get_alloc());
...@@ -312,7 +307,7 @@ private:...@@ -312,7 +307,7 @@ private:
312#endif307#endif
313 }308 }
314309
315 virtual void __on_zero_shared_weak() _NOEXCEPT {310 void __on_zero_shared_weak() _NOEXCEPT override {
316 using _ControlBlockAlloc = typename __allocator_traits_rebind<_Alloc, __shared_ptr_emplace>::type;311 using _ControlBlockAlloc = typename __allocator_traits_rebind<_Alloc, __shared_ptr_emplace>::type;
317 using _ControlBlockPointer = typename allocator_traits<_ControlBlockAlloc>::pointer;312 using _ControlBlockPointer = typename allocator_traits<_ControlBlockAlloc>::pointer;
318 _ControlBlockAlloc __tmp(*__get_alloc());313 _ControlBlockAlloc __tmp(*__get_alloc());
...@@ -383,22 +378,22 @@ struct __compatible_with...@@ -383,22 +378,22 @@ struct __compatible_with
383template <class _Ptr, class = void>378template <class _Ptr, class = void>
384struct __is_deletable : false_type { };379struct __is_deletable : false_type { };
385template <class _Ptr>380template <class _Ptr>
386struct __is_deletable<_Ptr, decltype(delete declval<_Ptr>())> : true_type { };381struct __is_deletable<_Ptr, decltype(delete std::declval<_Ptr>())> : true_type { };
387382
388template <class _Ptr, class = void>383template <class _Ptr, class = void>
389struct __is_array_deletable : false_type { };384struct __is_array_deletable : false_type { };
390template <class _Ptr>385template <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
393template <class _Dp, class _Pt,388template <class _Dp, class _Pt,
394 class = decltype(declval<_Dp>()(declval<_Pt>()))>389 class = decltype(std::declval<_Dp>()(std::declval<_Pt>()))>
395static true_type __well_formed_deleter_test(int);390static true_type __well_formed_deleter_test(int);
396391
397template <class, class>392template <class, class>
398static false_type __well_formed_deleter_test(...);393static false_type __well_formed_deleter_test(...);
399394
400template <class _Dp, class _Pt>395template <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
403template<class _Dp, class _Tp, class _Yp>398template<class _Dp, class _Tp, class _Yp>
404struct __shared_ptr_deleter_ctor_reqs399struct __shared_ptr_deleter_ctor_reqs
...@@ -687,7 +682,7 @@ public:...@@ -687,7 +682,7 @@ public:
687 {682 {
688 typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;683 typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
689 typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer,684 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> >,
691 _AllocT> _CntrlBlk;686 _AllocT> _CntrlBlk;
692 __cntrl_ = new _CntrlBlk(__r.get(), _VSTD::ref(__r.get_deleter()), _AllocT());687 __cntrl_ = new _CntrlBlk(__r.get(), _VSTD::ref(__r.get_deleter()), _AllocT());
693 __enable_weak_this(__r.get(), __r.get());688 __enable_weak_this(__r.get(), __r.get());
...@@ -802,7 +797,7 @@ public:...@@ -802,7 +797,7 @@ public:
802 }797 }
803798
804 _LIBCPP_HIDE_FROM_ABI799 _LIBCPP_HIDE_FROM_ABI
805 typename add_lvalue_reference<element_type>::type operator*() const _NOEXCEPT800 __add_lvalue_reference_t<element_type> operator*() const _NOEXCEPT
806 {801 {
807 return *__ptr_;802 return *__ptr_;
808 }803 }
...@@ -855,7 +850,7 @@ public:...@@ -855,7 +850,7 @@ public:
855850
856#if _LIBCPP_STD_VER > 14851#if _LIBCPP_STD_VER > 14
857 _LIBCPP_HIDE_FROM_ABI852 _LIBCPP_HIDE_FROM_ABI
858 typename add_lvalue_reference<element_type>::type operator[](ptrdiff_t __i) const853 __add_lvalue_reference_t<element_type> operator[](ptrdiff_t __i) const
859 {854 {
860 static_assert(is_array<_Tp>::value,855 static_assert(is_array<_Tp>::value,
861 "std::shared_ptr<T>::operator[] is only valid when T is an array type.");856 "std::shared_ptr<T>::operator[] is only valid when T is an array type.");
...@@ -904,7 +899,7 @@ private:...@@ -904,7 +899,7 @@ private:
904 _LIBCPP_HIDE_FROM_ABI899 _LIBCPP_HIDE_FROM_ABI
905 void __enable_weak_this(const enable_shared_from_this<_Yp>* __e, _OrigPtr* __ptr) _NOEXCEPT900 void __enable_weak_this(const enable_shared_from_this<_Yp>* __e, _OrigPtr* __ptr) _NOEXCEPT
906 {901 {
907 typedef typename remove_cv<_Yp>::type _RawYp;902 typedef __remove_cv_t<_Yp> _RawYp;
908 if (__e && __e->__weak_this_.expired())903 if (__e && __e->__weak_this_.expired())
909 {904 {
910 __e->__weak_this_ = shared_ptr<_RawYp>(*this,905 __e->__weak_this_ = shared_ptr<_RawYp>(*this,
...@@ -962,6 +957,29 @@ shared_ptr<_Tp> make_shared(_Args&& ...__args)...@@ -962,6 +957,29 @@ shared_ptr<_Tp> make_shared(_Args&& ...__args)
962 return _VSTD::allocate_shared<_Tp>(allocator<_Tp>(), _VSTD::forward<_Args>(__args)...);957 return _VSTD::allocate_shared<_Tp>(allocator<_Tp>(), _VSTD::forward<_Args>(__args)...);
963}958}
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
965#if _LIBCPP_STD_VER > 14983#if _LIBCPP_STD_VER > 14
966984
967template <size_t _Alignment>985template <size_t _Alignment>
...@@ -992,6 +1010,17 @@ struct __unbounded_array_control_block<_Tp[], _Alloc> : __shared_weak_count...@@ -992,6 +1010,17 @@ struct __unbounded_array_control_block<_Tp[], _Alloc> : __shared_weak_count
992 std::__uninitialized_allocator_value_construct_n(__alloc_, std::begin(__data_), __count_);1010 std::__uninitialized_allocator_value_construct_n(__alloc_, std::begin(__data_), __count_);
993 }1011 }
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
995 // Returns the number of bytes required to store a control block followed by the given number1024 // Returns the number of bytes required to store a control block followed by the given number
996 // of elements of _Tp, with the whole storage being aligned to a multiple of _Tp's alignment.1025 // of elements of _Tp, with the whole storage being aligned to a multiple of _Tp's alignment.
997 _LIBCPP_HIDE_FROM_ABI1026 _LIBCPP_HIDE_FROM_ABI
...@@ -1008,7 +1037,7 @@ struct __unbounded_array_control_block<_Tp[], _Alloc> : __shared_weak_count...@@ -1008,7 +1037,7 @@ struct __unbounded_array_control_block<_Tp[], _Alloc> : __shared_weak_count
1008 return (__bytes + __align - 1) & ~(__align - 1);1037 return (__bytes + __align - 1) & ~(__align - 1);
1009 }1038 }
10101039
1011 _LIBCPP_HIDE_FROM_ABI1040 _LIBCPP_HIDE_FROM_ABI_VIRTUAL
1012 ~__unbounded_array_control_block() override { } // can't be `= default` because of the sometimes-non-trivial union member __data_1041 ~__unbounded_array_control_block() override { } // can't be `= default` because of the sometimes-non-trivial union member __data_
10131042
1014private:1043private:
...@@ -1075,7 +1104,16 @@ struct __bounded_array_control_block<_Tp[_Count], _Alloc>...@@ -1075,7 +1104,16 @@ struct __bounded_array_control_block<_Tp[_Count], _Alloc>
1075 std::__uninitialized_allocator_value_construct_n(__alloc_, std::addressof(__data_[0]), _Count);1104 std::__uninitialized_allocator_value_construct_n(__alloc_, std::addressof(__data_[0]), _Count);
1076 }1105 }
10771106
1107#if _LIBCPP_STD_VER >= 20
1078 _LIBCPP_HIDE_FROM_ABI1108 _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
1079 ~__bounded_array_control_block() override { } // can't be `= default` because of the sometimes-non-trivial union member __data_1117 ~__bounded_array_control_block() override { } // can't be `= default` because of the sometimes-non-trivial union member __data_
10801118
1081private:1119private:
...@@ -1118,6 +1156,7 @@ shared_ptr<_Array> __allocate_shared_bounded_array(const _Alloc& __a, _Arg&& ......@@ -1118,6 +1156,7 @@ shared_ptr<_Array> __allocate_shared_bounded_array(const _Alloc& __a, _Arg&& ...
11181156
1119#if _LIBCPP_STD_VER > 171157#if _LIBCPP_STD_VER > 17
11201158
1159// bounded array variants
1121template<class _Tp, class _Alloc, class = __enable_if_t<is_bounded_array<_Tp>::value>>1160template<class _Tp, class _Alloc, class = __enable_if_t<is_bounded_array<_Tp>::value>>
1122_LIBCPP_HIDE_FROM_ABI1161_LIBCPP_HIDE_FROM_ABI
1123shared_ptr<_Tp> allocate_shared(const _Alloc& __a)1162shared_ptr<_Tp> allocate_shared(const _Alloc& __a)
...@@ -1132,18 +1171,11 @@ shared_ptr<_Tp> allocate_shared(const _Alloc& __a, const remove_extent_t<_Tp>& _...@@ -1132,18 +1171,11 @@ shared_ptr<_Tp> allocate_shared(const _Alloc& __a, const remove_extent_t<_Tp>& _
1132 return std::__allocate_shared_bounded_array<_Tp>(__a, __u);1171 return std::__allocate_shared_bounded_array<_Tp>(__a, __u);
1133}1172}
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>
1136_LIBCPP_HIDE_FROM_ABI1175_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)
1138{1177{
1139 return std::__allocate_shared_unbounded_array<_Tp>(__a, __n);1178 return std::__allocate_shared_bounded_array<_Tp>(__a, __default_initialize_tag{});
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);
1147}1179}
11481180
1149template<class _Tp, class = __enable_if_t<is_bounded_array<_Tp>::value>>1181template<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)...@@ -1160,6 +1192,35 @@ shared_ptr<_Tp> make_shared(const remove_extent_t<_Tp>& __u)
1160 return std::__allocate_shared_bounded_array<_Tp>(allocator<_Tp>(), __u);1192 return std::__allocate_shared_bounded_array<_Tp>(allocator<_Tp>(), __u);
1161}1193}
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
1163template<class _Tp, class = __enable_if_t<is_unbounded_array<_Tp>::value>>1224template<class _Tp, class = __enable_if_t<is_unbounded_array<_Tp>::value>>
1164_LIBCPP_HIDE_FROM_ABI1225_LIBCPP_HIDE_FROM_ABI
1165shared_ptr<_Tp> make_shared(size_t __n)1226shared_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)...@@ -1174,6 +1235,13 @@ shared_ptr<_Tp> make_shared(size_t __n, const remove_extent_t<_Tp>& __u)
1174 return std::__allocate_shared_unbounded_array<_Tp>(allocator<_Tp>(), __n, __u);1235 return std::__allocate_shared_unbounded_array<_Tp>(allocator<_Tp>(), __n, __u);
1175}1236}
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
1177#endif // _LIBCPP_STD_VER > 171245#endif // _LIBCPP_STD_VER > 17
11781246
1179template<class _Tp, class _Up>1247template<class _Tp, class _Up>
...@@ -1184,6 +1252,8 @@ operator==(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT...@@ -1184,6 +1252,8 @@ operator==(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
1184 return __x.get() == __y.get();1252 return __x.get() == __y.get();
1185}1253}
11861254
1255#if _LIBCPP_STD_VER <= 17
1256
1187template<class _Tp, class _Up>1257template<class _Tp, class _Up>
1188inline _LIBCPP_INLINE_VISIBILITY1258inline _LIBCPP_INLINE_VISIBILITY
1189bool1259bool
...@@ -1230,6 +1300,17 @@ operator>=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT...@@ -1230,6 +1300,17 @@ operator>=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
1230 return !(__x < __y);1300 return !(__x < __y);
1231}1301}
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
1233template<class _Tp>1314template<class _Tp>
1234inline _LIBCPP_INLINE_VISIBILITY1315inline _LIBCPP_INLINE_VISIBILITY
1235bool1316bool
...@@ -1238,6 +1319,8 @@ operator==(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT...@@ -1238,6 +1319,8 @@ operator==(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
1238 return !__x;1319 return !__x;
1239}1320}
12401321
1322#if _LIBCPP_STD_VER <= 17
1323
1241template<class _Tp>1324template<class _Tp>
1242inline _LIBCPP_INLINE_VISIBILITY1325inline _LIBCPP_INLINE_VISIBILITY
1243bool1326bool
...@@ -1326,6 +1409,17 @@ operator>=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT...@@ -1326,6 +1409,17 @@ operator>=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
1326 return !(nullptr < __x);1409 return !(nullptr < __x);
1327}1410}
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
1329template<class _Tp>1423template<class _Tp>
1330inline _LIBCPP_INLINE_VISIBILITY1424inline _LIBCPP_INLINE_VISIBILITY
1331void1425void
...@@ -1355,7 +1449,7 @@ dynamic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT...@@ -1355,7 +1449,7 @@ dynamic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
1355}1449}
13561450
1357template<class _Tp, class _Up>1451template<class _Tp, class _Up>
1358shared_ptr<_Tp>1452_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>
1359const_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT1453const_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
1360{1454{
1361 typedef typename shared_ptr<_Tp>::element_type _RTp;1455 typedef typename shared_ptr<_Tp>::element_type _RTp;
...@@ -1363,7 +1457,7 @@ const_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT...@@ -1363,7 +1457,7 @@ const_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
1363}1457}
13641458
1365template<class _Tp, class _Up>1459template<class _Tp, class _Up>
1366shared_ptr<_Tp>1460_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>
1367reinterpret_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT1461reinterpret_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
1368{1462{
1369 return shared_ptr<_Tp>(__r,1463 return shared_ptr<_Tp>(__r,
...@@ -1771,7 +1865,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p);...@@ -1771,7 +1865,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p);
17711865
1772class _LIBCPP_TYPE_VIS __sp_mut1866class _LIBCPP_TYPE_VIS __sp_mut
1773{1867{
1774 void* __lx;1868 void* __lx_;
1775public:1869public:
1776 void lock() _NOEXCEPT;1870 void lock() _NOEXCEPT;
1777 void unlock() _NOEXCEPT;1871 void unlock() _NOEXCEPT;
...@@ -1797,10 +1891,10 @@ atomic_is_lock_free(const shared_ptr<_Tp>*)...@@ -1797,10 +1891,10 @@ atomic_is_lock_free(const shared_ptr<_Tp>*)
17971891
1798template <class _Tp>1892template <class _Tp>
1799_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR1893_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
1800shared_ptr<_Tp>1894_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>
1801atomic_load(const shared_ptr<_Tp>* __p)1895atomic_load(const shared_ptr<_Tp>* __p)
1802{1896{
1803 __sp_mut& __m = __get_sp_mut(__p);1897 __sp_mut& __m = std::__get_sp_mut(__p);
1804 __m.lock();1898 __m.lock();
1805 shared_ptr<_Tp> __q = *__p;1899 shared_ptr<_Tp> __q = *__p;
1806 __m.unlock();1900 __m.unlock();
...@@ -1813,15 +1907,15 @@ _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR...@@ -1813,15 +1907,15 @@ _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
1813shared_ptr<_Tp>1907shared_ptr<_Tp>
1814atomic_load_explicit(const shared_ptr<_Tp>* __p, memory_order)1908atomic_load_explicit(const shared_ptr<_Tp>* __p, memory_order)
1815{1909{
1816 return atomic_load(__p);1910 return std::atomic_load(__p);
1817}1911}
18181912
1819template <class _Tp>1913template <class _Tp>
1820_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR1914_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
1821void1915_LIBCPP_HIDE_FROM_ABI void
1822atomic_store(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r)1916atomic_store(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r)
1823{1917{
1824 __sp_mut& __m = __get_sp_mut(__p);1918 __sp_mut& __m = std::__get_sp_mut(__p);
1825 __m.lock();1919 __m.lock();
1826 __p->swap(__r);1920 __p->swap(__r);
1827 __m.unlock();1921 __m.unlock();
...@@ -1833,15 +1927,15 @@ _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR...@@ -1833,15 +1927,15 @@ _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
1833void1927void
1834atomic_store_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order)1928atomic_store_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order)
1835{1929{
1836 atomic_store(__p, __r);1930 std::atomic_store(__p, __r);
1837}1931}
18381932
1839template <class _Tp>1933template <class _Tp>
1840_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR1934_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
1841shared_ptr<_Tp>1935_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>
1842atomic_exchange(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r)1936atomic_exchange(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r)
1843{1937{
1844 __sp_mut& __m = __get_sp_mut(__p);1938 __sp_mut& __m = std::__get_sp_mut(__p);
1845 __m.lock();1939 __m.lock();
1846 __p->swap(__r);1940 __p->swap(__r);
1847 __m.unlock();1941 __m.unlock();
...@@ -1854,16 +1948,16 @@ _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR...@@ -1854,16 +1948,16 @@ _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
1854shared_ptr<_Tp>1948shared_ptr<_Tp>
1855atomic_exchange_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order)1949atomic_exchange_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order)
1856{1950{
1857 return atomic_exchange(__p, __r);1951 return std::atomic_exchange(__p, __r);
1858}1952}
18591953
1860template <class _Tp>1954template <class _Tp>
1861_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR1955_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
1862bool1956_LIBCPP_HIDE_FROM_ABI bool
1863atomic_compare_exchange_strong(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w)1957atomic_compare_exchange_strong(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w)
1864{1958{
1865 shared_ptr<_Tp> __temp;1959 shared_ptr<_Tp> __temp;
1866 __sp_mut& __m = __get_sp_mut(__p);1960 __sp_mut& __m = std::__get_sp_mut(__p);
1867 __m.lock();1961 __m.lock();
1868 if (__p->__owner_equivalent(*__v))1962 if (__p->__owner_equivalent(*__v))
1869 {1963 {
...@@ -1884,7 +1978,7 @@ _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR...@@ -1884,7 +1978,7 @@ _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
1884bool1978bool
1885atomic_compare_exchange_weak(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w)1979atomic_compare_exchange_weak(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w)
1886{1980{
1887 return atomic_compare_exchange_strong(__p, __v, __w);1981 return std::atomic_compare_exchange_strong(__p, __v, __w);
1888}1982}
18891983
1890template <class _Tp>1984template <class _Tp>
...@@ -1894,7 +1988,7 @@ bool...@@ -1894,7 +1988,7 @@ bool
1894atomic_compare_exchange_strong_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v,1988atomic_compare_exchange_strong_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v,
1895 shared_ptr<_Tp> __w, memory_order, memory_order)1989 shared_ptr<_Tp> __w, memory_order, memory_order)
1896{1990{
1897 return atomic_compare_exchange_strong(__p, __v, __w);1991 return std::atomic_compare_exchange_strong(__p, __v, __w);
1898}1992}
18991993
1900template <class _Tp>1994template <class _Tp>
...@@ -1904,7 +1998,7 @@ bool...@@ -1904,7 +1998,7 @@ bool
1904atomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v,1998atomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v,
1905 shared_ptr<_Tp> __w, memory_order, memory_order)1999 shared_ptr<_Tp> __w, memory_order, memory_order)
1906{2000{
1907 return atomic_compare_exchange_weak(__p, __v, __w);2001 return std::atomic_compare_exchange_weak(__p, __v, __w);
1908}2002}
19092003
1910#endif // !defined(_LIBCPP_HAS_NO_THREADS)2004#endif // !defined(_LIBCPP_HAS_NO_THREADS)
lib/libcxx/include/__memory/swap_allocator.h+4-3
...@@ -12,6 +12,7 @@...@@ -12,6 +12,7 @@
12#include <__config>12#include <__config>
13#include <__memory/allocator_traits.h>13#include <__memory/allocator_traits.h>
14#include <__type_traits/integral_constant.h>14#include <__type_traits/integral_constant.h>
15#include <__type_traits/is_swappable.h>
15#include <__utility/swap.h>16#include <__utility/swap.h>
1617
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -21,7 +22,7 @@...@@ -21,7 +22,7 @@
21_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2223
23template <typename _Alloc>24template <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)
25#if _LIBCPP_STD_VER > 1126#if _LIBCPP_STD_VER > 11
26 _NOEXCEPT27 _NOEXCEPT
27#else28#else
...@@ -33,11 +34,11 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void __swap_allocator(_Alloc...@@ -33,11 +34,11 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void __swap_allocator(_Alloc
33}34}
3435
35template <typename _Alloc>36template <typename _Alloc>
36inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void37inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
37__swap_allocator(_Alloc&, _Alloc&, false_type) _NOEXCEPT {}38__swap_allocator(_Alloc&, _Alloc&, false_type) _NOEXCEPT {}
3839
39template <typename _Alloc>40template <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)
41#if _LIBCPP_STD_VER > 1142#if _LIBCPP_STD_VER > 11
42 _NOEXCEPT43 _NOEXCEPT
43#else44#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 @@...@@ -23,7 +23,7 @@
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2424
25template <class _Tp>25template <class _Tp>
26_LIBCPP_NODISCARD_EXT _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX1726_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX17
27pair<_Tp*, ptrdiff_t>27pair<_Tp*, ptrdiff_t>
28get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT28get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT
29{29{
lib/libcxx/include/__memory/uninitialized_algorithms.h+37-33
...@@ -20,11 +20,21 @@...@@ -20,11 +20,21 @@
20#include <__memory/construct_at.h>20#include <__memory/construct_at.h>
21#include <__memory/pointer_traits.h>21#include <__memory/pointer_traits.h>
22#include <__memory/voidify.h>22#include <__memory/voidify.h>
23#include <__type_traits/extent.h>
24#include <__type_traits/is_array.h>
23#include <__type_traits/is_constant_evaluated.h>25#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>
24#include <__utility/move.h>35#include <__utility/move.h>
25#include <__utility/pair.h>36#include <__utility/pair.h>
26#include <__utility/transaction.h>37#include <new>
27#include <type_traits>
2838
29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)39#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
30# pragma GCC system_header40# pragma GCC system_header
...@@ -64,6 +74,7 @@ __uninitialized_copy(_InputIterator __ifirst, _Sentinel1 __ilast,...@@ -64,6 +74,7 @@ __uninitialized_copy(_InputIterator __ifirst, _Sentinel1 __ilast,
64}74}
6575
66template <class _InputIterator, class _ForwardIterator>76template <class _InputIterator, class _ForwardIterator>
77_LIBCPP_HIDE_FROM_ABI
67_ForwardIterator uninitialized_copy(_InputIterator __ifirst, _InputIterator __ilast,78_ForwardIterator uninitialized_copy(_InputIterator __ifirst, _InputIterator __ilast,
68 _ForwardIterator __ofirst) {79 _ForwardIterator __ofirst) {
69 typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType;80 typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType;
...@@ -282,7 +293,7 @@ template <class _ForwardIterator, class _Size>...@@ -282,7 +293,7 @@ template <class _ForwardIterator, class _Size>
282inline _LIBCPP_HIDE_FROM_ABI293inline _LIBCPP_HIDE_FROM_ABI
283_ForwardIterator uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) {294_ForwardIterator uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) {
284 using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;295 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);
286}297}
287298
288// uninitialized_move299// uninitialized_move
...@@ -410,7 +421,10 @@ constexpr void __allocator_construct_at(_Alloc& __alloc, _Tp* __loc) {...@@ -410,7 +421,10 @@ constexpr void __allocator_construct_at(_Alloc& __alloc, _Tp* __loc) {
410 _Tp& __array = *__loc;421 _Tp& __array = *__loc;
411422
412 // If an exception is thrown, destroy what we have constructed so far in reverse order.423 // 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
414 for (; __i != extent_v<_Tp>; ++__i) {428 for (; __i != extent_v<_Tp>; ++__i) {
415 std::__allocator_construct_at(__elem_alloc, std::addressof(__array[__i]));429 std::__allocator_construct_at(__elem_alloc, std::addressof(__array[__i]));
416 }430 }
...@@ -447,7 +461,9 @@ constexpr void __allocator_construct_at(_Alloc& __alloc, _Tp* __loc, _Arg const&...@@ -447,7 +461,9 @@ constexpr void __allocator_construct_at(_Alloc& __alloc, _Tp* __loc, _Arg const&
447 _Tp& __array = *__loc;461 _Tp& __array = *__loc;
448462
449 // If an exception is thrown, destroy what we have constructed so far in reverse order.463 // 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 });
451 for (; __i != extent_v<_Tp>; ++__i) {467 for (; __i != extent_v<_Tp>; ++__i) {
452 std::__allocator_construct_at(__elem_alloc, std::addressof(__array[__i]), __arg[__i]);468 std::__allocator_construct_at(__elem_alloc, std::addressof(__array[__i]), __arg[__i]);
453 }469 }
...@@ -472,7 +488,7 @@ constexpr void __uninitialized_allocator_fill_n(_Alloc& __alloc, _BidirIter __it...@@ -472,7 +488,7 @@ constexpr void __uninitialized_allocator_fill_n(_Alloc& __alloc, _BidirIter __it
472 _BidirIter __begin = __it;488 _BidirIter __begin = __it;
473489
474 // If an exception is thrown, destroy what we have constructed so far in reverse order.490 // 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); });
476 for (; __n != 0; --__n, ++__it) {492 for (; __n != 0; --__n, ++__it) {
477 std::__allocator_construct_at(__value_alloc, std::addressof(*__it), __value);493 std::__allocator_construct_at(__value_alloc, std::addressof(*__it), __value);
478 }494 }
...@@ -489,7 +505,7 @@ constexpr void __uninitialized_allocator_value_construct_n(_Alloc& __alloc, _Bid...@@ -489,7 +505,7 @@ constexpr void __uninitialized_allocator_value_construct_n(_Alloc& __alloc, _Bid
489 _BidirIter __begin = __it;505 _BidirIter __begin = __it;
490506
491 // If an exception is thrown, destroy what we have constructed so far in reverse order.507 // 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); });
493 for (; __n != 0; --__n, ++__it) {509 for (; __n != 0; --__n, ++__it) {
494 std::__allocator_construct_at(__value_alloc, std::addressof(*__it));510 std::__allocator_construct_at(__value_alloc, std::addressof(*__it));
495 }511 }
...@@ -500,7 +516,7 @@ constexpr void __uninitialized_allocator_value_construct_n(_Alloc& __alloc, _Bid...@@ -500,7 +516,7 @@ constexpr void __uninitialized_allocator_value_construct_n(_Alloc& __alloc, _Bid
500516
501// Destroy all elements in [__first, __last) from left to right using allocator destruction.517// Destroy all elements in [__first, __last) from left to right using allocator destruction.
502template <class _Alloc, class _Iter, class _Sent>518template <class _Alloc, class _Iter, class _Sent>
503_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void519_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
504__allocator_destroy(_Alloc& __alloc, _Iter __first, _Sent __last) {520__allocator_destroy(_Alloc& __alloc, _Iter __first, _Sent __last) {
505 for (; __first != __last; ++__first)521 for (; __first != __last; ++__first)
506 allocator_traits<_Alloc>::destroy(__alloc, std::__to_address(__first));522 allocator_traits<_Alloc>::destroy(__alloc, std::__to_address(__first));
...@@ -509,11 +525,11 @@ __allocator_destroy(_Alloc& __alloc, _Iter __first, _Sent __last) {...@@ -509,11 +525,11 @@ __allocator_destroy(_Alloc& __alloc, _Iter __first, _Sent __last) {
509template <class _Alloc, class _Iter>525template <class _Alloc, class _Iter>
510class _AllocatorDestroyRangeReverse {526class _AllocatorDestroyRangeReverse {
511public:527public:
512 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11528 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
513 _AllocatorDestroyRangeReverse(_Alloc& __alloc, _Iter& __first, _Iter& __last)529 _AllocatorDestroyRangeReverse(_Alloc& __alloc, _Iter& __first, _Iter& __last)
514 : __alloc_(__alloc), __first_(__first), __last_(__last) {}530 : __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 {
517 std::__allocator_destroy(__alloc_, std::reverse_iterator<_Iter>(__last_), std::reverse_iterator<_Iter>(__first_));533 std::__allocator_destroy(__alloc_, std::reverse_iterator<_Iter>(__last_), std::reverse_iterator<_Iter>(__first_));
518 }534 }
519535
...@@ -528,23 +544,17 @@ private:...@@ -528,23 +544,17 @@ private:
528// The caller has to ensure that __first2 can hold at least N uninitialized elements. If an exception is thrown the544// The caller has to ensure that __first2 can hold at least N uninitialized elements. If an exception is thrown the
529// already copied elements are destroyed in reverse order of their construction.545// already copied elements are destroyed in reverse order of their construction.
530template <class _Alloc, class _Iter1, class _Sent1, class _Iter2>546template <class _Alloc, class _Iter1, class _Sent1, class _Iter2>
531_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2547_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter2
532__uninitialized_allocator_copy(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) {548__uninitialized_allocator_copy(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) {
533#ifndef _LIBCPP_NO_EXCEPTIONS
534 auto __destruct_first = __first2;549 auto __destruct_first = __first2;
535 try {550 auto __guard =
536#endif551 std::__make_exception_guard(_AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2));
537 while (__first1 != __last1) {552 while (__first1 != __last1) {
538 allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), *__first1);553 allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), *__first1);
539 ++__first1;554 ++__first1;
540 ++__first2;555 ++__first2;
541 }556 }
542#ifndef _LIBCPP_NO_EXCEPTIONS557 __guard.__complete();
543 } catch (...) {
544 _AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2)();
545 throw;
546 }
547#endif
548 return __first2;558 return __first2;
549}559}
550560
...@@ -556,12 +566,12 @@ struct __allocator_has_trivial_copy_construct<allocator<_Type>, _Type> : true_ty...@@ -556,12 +566,12 @@ struct __allocator_has_trivial_copy_construct<allocator<_Type>, _Type> : true_ty
556566
557template <class _Alloc,567template <class _Alloc,
558 class _Type,568 class _Type,
559 class _RawType = typename remove_const<_Type>::type,569 class _RawType = __remove_const_t<_Type>,
560 __enable_if_t<570 __enable_if_t<
561 // using _RawType because of the allocator<T const> extension571 // using _RawType because of the allocator<T const> extension
562 is_trivially_copy_constructible<_RawType>::value && is_trivially_copy_assignable<_RawType>::value &&572 is_trivially_copy_constructible<_RawType>::value && is_trivially_copy_assignable<_RawType>::value &&
563 __allocator_has_trivial_copy_construct<_Alloc, _RawType>::value>* = nullptr>573 __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*
565__uninitialized_allocator_copy(_Alloc&, const _Type* __first1, const _Type* __last1, _Type* __first2) {575__uninitialized_allocator_copy(_Alloc&, const _Type* __first1, const _Type* __last1, _Type* __first2) {
566 // TODO: Remove the const_cast once we drop support for std::allocator<T const>576 // TODO: Remove the const_cast once we drop support for std::allocator<T const>
567 if (__libcpp_is_constant_evaluated()) {577 if (__libcpp_is_constant_evaluated()) {
...@@ -582,14 +592,13 @@ __uninitialized_allocator_copy(_Alloc&, const _Type* __first1, const _Type* __la...@@ -582,14 +592,13 @@ __uninitialized_allocator_copy(_Alloc&, const _Type* __first1, const _Type* __la
582// Otherwise try to copy all elements. If an exception is thrown the already copied592// Otherwise try to copy all elements. If an exception is thrown the already copied
583// elements are destroyed in reverse order of their construction.593// elements are destroyed in reverse order of their construction.
584template <class _Alloc, class _Iter1, class _Sent1, class _Iter2>594template <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(
586 _Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) {596 _Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) {
587 static_assert(__is_cpp17_move_insertable<_Alloc>::value,597 static_assert(__is_cpp17_move_insertable<_Alloc>::value,
588 "The specified type does not meet the requirements of Cpp17MoveInsertable");598 "The specified type does not meet the requirements of Cpp17MoveInsertable");
589#ifndef _LIBCPP_NO_EXCEPTIONS
590 auto __destruct_first = __first2;599 auto __destruct_first = __first2;
591 try {600 auto __guard =
592#endif601 std::__make_exception_guard(_AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2));
593 while (__first1 != __last1) {602 while (__first1 != __last1) {
594#ifndef _LIBCPP_NO_EXCEPTIONS603#ifndef _LIBCPP_NO_EXCEPTIONS
595 allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), std::move_if_noexcept(*__first1));604 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...@@ -599,12 +608,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2 __uninitialized_alloc
599 ++__first1;608 ++__first1;
600 ++__first2;609 ++__first2;
601 }610 }
602#ifndef _LIBCPP_NO_EXCEPTIONS611 __guard.__complete();
603 } catch (...) {
604 _AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2)();
605 throw;
606 }
607#endif
608 return __first2;612 return __first2;
609}613}
610614
...@@ -622,7 +626,7 @@ template <...@@ -622,7 +626,7 @@ template <
622 class _Type = typename iterator_traits<_Iter1>::value_type,626 class _Type = typename iterator_traits<_Iter1>::value_type,
623 class = __enable_if_t<is_trivially_move_constructible<_Type>::value && is_trivially_move_assignable<_Type>::value &&627 class = __enable_if_t<is_trivially_move_constructible<_Type>::value && is_trivially_move_assignable<_Type>::value &&
624 __allocator_has_trivial_move_construct<_Alloc, _Type>::value> >628 __allocator_has_trivial_move_construct<_Alloc, _Type>::value> >
625_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2629_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter2
626__uninitialized_allocator_move_if_noexcept(_Alloc&, _Iter1 __first1, _Iter1 __last1, _Iter2 __first2) {630__uninitialized_allocator_move_if_noexcept(_Alloc&, _Iter1 __first1, _Iter1 __last1, _Iter2 __first2) {
627 if (__libcpp_is_constant_evaluated()) {631 if (__libcpp_is_constant_evaluated()) {
628 while (__first1 != __last1) {632 while (__first1 != __last1) {
lib/libcxx/include/__memory/unique_ptr.h+197-208
...@@ -10,16 +10,35 @@...@@ -10,16 +10,35 @@
10#ifndef _LIBCPP___MEMORY_UNIQUE_PTR_H10#ifndef _LIBCPP___MEMORY_UNIQUE_PTR_H
11#define _LIBCPP___MEMORY_UNIQUE_PTR_H11#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>
13#include <__config>16#include <__config>
14#include <__functional/hash.h>17#include <__functional/hash.h>
15#include <__functional/operations.h>18#include <__functional/operations.h>
16#include <__memory/allocator_traits.h> // __pointer19#include <__memory/allocator_traits.h> // __pointer
17#include <__memory/auto_ptr.h>20#include <__memory/auto_ptr.h>
18#include <__memory/compressed_pair.h>21#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>
19#include <__utility/forward.h>39#include <__utility/forward.h>
20#include <__utility/move.h>40#include <__utility/move.h>
21#include <cstddef>41#include <cstddef>
22#include <type_traits>
2342
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)43#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header44# pragma GCC system_header
...@@ -37,12 +56,10 @@ struct _LIBCPP_TEMPLATE_VIS default_delete {...@@ -37,12 +56,10 @@ struct _LIBCPP_TEMPLATE_VIS default_delete {
37 _LIBCPP_INLINE_VISIBILITY default_delete() {}56 _LIBCPP_INLINE_VISIBILITY default_delete() {}
38#endif57#endif
39 template <class _Up>58 template <class _Up>
40 _LIBCPP_INLINE_VISIBILITY59 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 default_delete(
41 default_delete(const default_delete<_Up>&,60 const default_delete<_Up>&, typename enable_if<is_convertible<_Up*, _Tp*>::value>::type* = 0) _NOEXCEPT {}
42 typename enable_if<is_convertible<_Up*, _Tp*>::value>::type* =
43 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 {
46 static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type");63 static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type");
47 static_assert(!is_void<_Tp>::value, "cannot delete an incomplete type");64 static_assert(!is_void<_Tp>::value, "cannot delete an incomplete type");
48 delete __ptr;65 delete __ptr;
...@@ -64,13 +81,11 @@ public:...@@ -64,13 +81,11 @@ public:
64#endif81#endif
6582
66 template <class _Up>83 template <class _Up>
67 _LIBCPP_INLINE_VISIBILITY84 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
68 default_delete(const default_delete<_Up[]>&,85 default_delete(const default_delete<_Up[]>&, typename _EnableIfConvertible<_Up>::type* = 0) _NOEXCEPT {}
69 typename _EnableIfConvertible<_Up>::type* = 0) _NOEXCEPT {}
7086
71 template <class _Up>87 template <class _Up>
72 _LIBCPP_INLINE_VISIBILITY88 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 typename _EnableIfConvertible<_Up>::type
73 typename _EnableIfConvertible<_Up>::type
74 operator()(_Up* __ptr) const _NOEXCEPT {89 operator()(_Up* __ptr) const _NOEXCEPT {
75 static_assert(sizeof(_Up) >= 0, "cannot delete an incomplete type");90 static_assert(sizeof(_Up) >= 0, "cannot delete an incomplete type");
76 delete[] __ptr;91 delete[] __ptr;
...@@ -172,22 +187,17 @@ public:...@@ -172,22 +187,17 @@ public:
172 _LIBCPP_INLINE_VISIBILITY187 _LIBCPP_INLINE_VISIBILITY
173 _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {}188 _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {}
174189
175 template <bool _Dummy = true,190 template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >
176 class = _EnableIfDeleterDefaultConstructible<_Dummy> >191 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(pointer __p) _NOEXCEPT
177 _LIBCPP_INLINE_VISIBILITY192 : __ptr_(__p, __value_init_tag()) {}
178 explicit unique_ptr(pointer __p) _NOEXCEPT : __ptr_(__p, __value_init_tag()) {}
179193
180 template <bool _Dummy = true,194 template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >
181 class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >195 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, _LValRefType<_Dummy> __d) _NOEXCEPT
182 _LIBCPP_INLINE_VISIBILITY
183 unique_ptr(pointer __p, _LValRefType<_Dummy> __d) _NOEXCEPT
184 : __ptr_(__p, __d) {}196 : __ptr_(__p, __d) {}
185197
186 template <bool _Dummy = true,198 template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >
187 class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >199 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
188 _LIBCPP_INLINE_VISIBILITY200 unique_ptr(pointer __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT : __ptr_(__p, _VSTD::move(__d)) {
189 unique_ptr(pointer __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
190 : __ptr_(__p, _VSTD::move(__d)) {
191 static_assert(!is_reference<deleter_type>::value,201 static_assert(!is_reference<deleter_type>::value,
192 "rvalue deleter bound to reference");202 "rvalue deleter bound to reference");
193 }203 }
...@@ -197,17 +207,14 @@ public:...@@ -197,17 +207,14 @@ public:
197 _LIBCPP_INLINE_VISIBILITY207 _LIBCPP_INLINE_VISIBILITY
198 unique_ptr(pointer __p, _BadRValRefType<_Dummy> __d) = delete;208 unique_ptr(pointer __p, _BadRValRefType<_Dummy> __d) = delete;
199209
200 _LIBCPP_INLINE_VISIBILITY210 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) _NOEXCEPT
201 unique_ptr(unique_ptr&& __u) _NOEXCEPT211 : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {}
202 : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {
203 }
204212
205 template <class _Up, class _Ep,213 template <class _Up,
206 class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,214 class _Ep,
207 class = _EnableIfDeleterConvertible<_Ep>215 class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
208 >216 class = _EnableIfDeleterConvertible<_Ep> >
209 _LIBCPP_INLINE_VISIBILITY217 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT
210 unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT
211 : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {}218 : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {}
212219
213#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)220#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
...@@ -220,19 +227,17 @@ public:...@@ -220,19 +227,17 @@ public:
220 : __ptr_(__p.release(), __value_init_tag()) {}227 : __ptr_(__p.release(), __value_init_tag()) {}
221#endif228#endif
222229
223 _LIBCPP_INLINE_VISIBILITY230 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {
224 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {
225 reset(__u.release());231 reset(__u.release());
226 __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter());232 __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter());
227 return *this;233 return *this;
228 }234 }
229235
230 template <class _Up, class _Ep,236 template <class _Up,
231 class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,237 class _Ep,
232 class = _EnableIfDeleterAssignable<_Ep>238 class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
233 >239 class = _EnableIfDeleterAssignable<_Ep> >
234 _LIBCPP_INLINE_VISIBILITY240 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT {
235 unique_ptr& operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT {
236 reset(__u.release());241 reset(__u.release());
237 __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter());242 __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter());
238 return *this;243 return *this;
...@@ -255,58 +260,44 @@ public:...@@ -255,58 +260,44 @@ public:
255 unique_ptr& operator=(unique_ptr const&) = delete;260 unique_ptr& operator=(unique_ptr const&) = delete;
256#endif261#endif
257262
258 _LIBCPP_INLINE_VISIBILITY263 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }
259 ~unique_ptr() { reset(); }
260264
261 _LIBCPP_INLINE_VISIBILITY265 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(nullptr_t) _NOEXCEPT {
262 unique_ptr& operator=(nullptr_t) _NOEXCEPT {
263 reset();266 reset();
264 return *this;267 return *this;
265 }268 }
266269
267 _LIBCPP_INLINE_VISIBILITY270 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator*() const {
268 typename add_lvalue_reference<_Tp>::type
269 operator*() const {
270 return *__ptr_.first();271 return *__ptr_.first();
271 }272 }
272 _LIBCPP_INLINE_VISIBILITY273 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer operator->() const _NOEXCEPT {
273 pointer operator->() const _NOEXCEPT {
274 return __ptr_.first();
275 }
276 _LIBCPP_INLINE_VISIBILITY
277 pointer get() const _NOEXCEPT {
278 return __ptr_.first();274 return __ptr_.first();
279 }275 }
280 _LIBCPP_INLINE_VISIBILITY276 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_.first(); }
281 deleter_type& get_deleter() _NOEXCEPT {277 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT {
282 return __ptr_.second();278 return __ptr_.second();
283 }279 }
284 _LIBCPP_INLINE_VISIBILITY280 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 const deleter_type& get_deleter() const _NOEXCEPT {
285 const deleter_type& get_deleter() const _NOEXCEPT {
286 return __ptr_.second();281 return __ptr_.second();
287 }282 }
288 _LIBCPP_INLINE_VISIBILITY283 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit operator bool() const _NOEXCEPT {
289 explicit operator bool() const _NOEXCEPT {
290 return __ptr_.first() != nullptr;284 return __ptr_.first() != nullptr;
291 }285 }
292286
293 _LIBCPP_INLINE_VISIBILITY287 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer release() _NOEXCEPT {
294 pointer release() _NOEXCEPT {
295 pointer __t = __ptr_.first();288 pointer __t = __ptr_.first();
296 __ptr_.first() = pointer();289 __ptr_.first() = pointer();
297 return __t;290 return __t;
298 }291 }
299292
300 _LIBCPP_INLINE_VISIBILITY293 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(pointer __p = pointer()) _NOEXCEPT {
301 void reset(pointer __p = pointer()) _NOEXCEPT {
302 pointer __tmp = __ptr_.first();294 pointer __tmp = __ptr_.first();
303 __ptr_.first() = __p;295 __ptr_.first() = __p;
304 if (__tmp)296 if (__tmp)
305 __ptr_.second()(__tmp);297 __ptr_.second()(__tmp);
306 }298 }
307299
308 _LIBCPP_INLINE_VISIBILITY300 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT {
309 void swap(unique_ptr& __u) _NOEXCEPT {
310 __ptr_.swap(__u.__ptr_);301 __ptr_.swap(__u.__ptr_);
311 }302 }
312};303};
...@@ -394,40 +385,36 @@ public:...@@ -394,40 +385,36 @@ public:
394 _LIBCPP_INLINE_VISIBILITY385 _LIBCPP_INLINE_VISIBILITY
395 _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {}386 _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {}
396387
397 template <class _Pp, bool _Dummy = true,388 template <class _Pp,
398 class = _EnableIfDeleterDefaultConstructible<_Dummy>,389 bool _Dummy = true,
399 class = _EnableIfPointerConvertible<_Pp> >390 class = _EnableIfDeleterDefaultConstructible<_Dummy>,
400 _LIBCPP_INLINE_VISIBILITY391 class = _EnableIfPointerConvertible<_Pp> >
401 explicit unique_ptr(_Pp __p) _NOEXCEPT392 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(_Pp __p) _NOEXCEPT
402 : __ptr_(__p, __value_init_tag()) {}393 : __ptr_(__p, __value_init_tag()) {}
403394
404 template <class _Pp, bool _Dummy = true,395 template <class _Pp,
405 class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> >,396 bool _Dummy = true,
406 class = _EnableIfPointerConvertible<_Pp> >397 class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> >,
407 _LIBCPP_INLINE_VISIBILITY398 class = _EnableIfPointerConvertible<_Pp> >
408 unique_ptr(_Pp __p, _LValRefType<_Dummy> __d) _NOEXCEPT399 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(_Pp __p, _LValRefType<_Dummy> __d) _NOEXCEPT
409 : __ptr_(__p, __d) {}400 : __ptr_(__p, __d) {}
410401
411 template <bool _Dummy = true,402 template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >
412 class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >403 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(nullptr_t, _LValRefType<_Dummy> __d) _NOEXCEPT
413 _LIBCPP_INLINE_VISIBILITY
414 unique_ptr(nullptr_t, _LValRefType<_Dummy> __d) _NOEXCEPT
415 : __ptr_(nullptr, __d) {}404 : __ptr_(nullptr, __d) {}
416405
417 template <class _Pp, bool _Dummy = true,406 template <class _Pp,
418 class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> >,407 bool _Dummy = true,
419 class = _EnableIfPointerConvertible<_Pp> >408 class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> >,
420 _LIBCPP_INLINE_VISIBILITY409 class = _EnableIfPointerConvertible<_Pp> >
421 unique_ptr(_Pp __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT410 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(_Pp __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
422 : __ptr_(__p, _VSTD::move(__d)) {411 : __ptr_(__p, _VSTD::move(__d)) {
423 static_assert(!is_reference<deleter_type>::value,412 static_assert(!is_reference<deleter_type>::value,
424 "rvalue deleter bound to reference");413 "rvalue deleter bound to reference");
425 }414 }
426415
427 template <bool _Dummy = true,416 template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >
428 class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >417 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(nullptr_t, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
429 _LIBCPP_INLINE_VISIBILITY
430 unique_ptr(nullptr_t, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
431 : __ptr_(nullptr, _VSTD::move(__d)) {418 : __ptr_(nullptr, _VSTD::move(__d)) {
432 static_assert(!is_reference<deleter_type>::value,419 static_assert(!is_reference<deleter_type>::value,
433 "rvalue deleter bound to reference");420 "rvalue deleter bound to reference");
...@@ -439,34 +426,27 @@ public:...@@ -439,34 +426,27 @@ public:
439 _LIBCPP_INLINE_VISIBILITY426 _LIBCPP_INLINE_VISIBILITY
440 unique_ptr(_Pp __p, _BadRValRefType<_Dummy> __d) = delete;427 unique_ptr(_Pp __p, _BadRValRefType<_Dummy> __d) = delete;
441428
442 _LIBCPP_INLINE_VISIBILITY429 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) _NOEXCEPT
443 unique_ptr(unique_ptr&& __u) _NOEXCEPT430 : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {}
444 : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {
445 }
446431
447 _LIBCPP_INLINE_VISIBILITY432 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {
448 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {
449 reset(__u.release());433 reset(__u.release());
450 __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter());434 __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter());
451 return *this;435 return *this;
452 }436 }
453437
454 template <class _Up, class _Ep,438 template <class _Up,
455 class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,439 class _Ep,
456 class = _EnableIfDeleterConvertible<_Ep>440 class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
457 >441 class = _EnableIfDeleterConvertible<_Ep> >
458 _LIBCPP_INLINE_VISIBILITY442 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT
459 unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT443 : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {}
460 : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {
461 }
462444
463 template <class _Up, class _Ep,445 template <class _Up,
464 class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,446 class _Ep,
465 class = _EnableIfDeleterAssignable<_Ep>447 class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>,
466 >448 class = _EnableIfDeleterAssignable<_Ep> >
467 _LIBCPP_INLINE_VISIBILITY449 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT {
468 unique_ptr&
469 operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT {
470 reset(__u.release());450 reset(__u.release());
471 __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter());451 __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter());
472 return *this;452 return *this;
...@@ -477,90 +457,77 @@ public:...@@ -477,90 +457,77 @@ public:
477 unique_ptr& operator=(unique_ptr const&) = delete;457 unique_ptr& operator=(unique_ptr const&) = delete;
478#endif458#endif
479public:459public:
480 _LIBCPP_INLINE_VISIBILITY460 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 ~unique_ptr() { reset(); }
481 ~unique_ptr() { reset(); }
482461
483 _LIBCPP_INLINE_VISIBILITY462 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(nullptr_t) _NOEXCEPT {
484 unique_ptr& operator=(nullptr_t) _NOEXCEPT {
485 reset();463 reset();
486 return *this;464 return *this;
487 }465 }
488466
489 _LIBCPP_INLINE_VISIBILITY467 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp>
490 typename add_lvalue_reference<_Tp>::type
491 operator[](size_t __i) const {468 operator[](size_t __i) const {
492 return __ptr_.first()[__i];469 return __ptr_.first()[__i];
493 }470 }
494 _LIBCPP_INLINE_VISIBILITY471 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_.first(); }
495 pointer get() const _NOEXCEPT {
496 return __ptr_.first();
497 }
498472
499 _LIBCPP_INLINE_VISIBILITY473 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT {
500 deleter_type& get_deleter() _NOEXCEPT {
501 return __ptr_.second();474 return __ptr_.second();
502 }475 }
503476
504 _LIBCPP_INLINE_VISIBILITY477 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 const deleter_type& get_deleter() const _NOEXCEPT {
505 const deleter_type& get_deleter() const _NOEXCEPT {
506 return __ptr_.second();478 return __ptr_.second();
507 }479 }
508 _LIBCPP_INLINE_VISIBILITY480 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit operator bool() const _NOEXCEPT {
509 explicit operator bool() const _NOEXCEPT {
510 return __ptr_.first() != nullptr;481 return __ptr_.first() != nullptr;
511 }482 }
512483
513 _LIBCPP_INLINE_VISIBILITY484 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer release() _NOEXCEPT {
514 pointer release() _NOEXCEPT {
515 pointer __t = __ptr_.first();485 pointer __t = __ptr_.first();
516 __ptr_.first() = pointer();486 __ptr_.first() = pointer();
517 return __t;487 return __t;
518 }488 }
519489
520 template <class _Pp>490 template <class _Pp>
521 _LIBCPP_INLINE_VISIBILITY491 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
522 typename enable_if<492 typename enable_if< _CheckArrayPointerConversion<_Pp>::value >::type
523 _CheckArrayPointerConversion<_Pp>::value493 reset(_Pp __p) _NOEXCEPT {
524 >::type
525 reset(_Pp __p) _NOEXCEPT {
526 pointer __tmp = __ptr_.first();494 pointer __tmp = __ptr_.first();
527 __ptr_.first() = __p;495 __ptr_.first() = __p;
528 if (__tmp)496 if (__tmp)
529 __ptr_.second()(__tmp);497 __ptr_.second()(__tmp);
530 }498 }
531499
532 _LIBCPP_INLINE_VISIBILITY500 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(nullptr_t = nullptr) _NOEXCEPT {
533 void reset(nullptr_t = nullptr) _NOEXCEPT {
534 pointer __tmp = __ptr_.first();501 pointer __tmp = __ptr_.first();
535 __ptr_.first() = nullptr;502 __ptr_.first() = nullptr;
536 if (__tmp)503 if (__tmp)
537 __ptr_.second()(__tmp);504 __ptr_.second()(__tmp);
538 }505 }
539506
540 _LIBCPP_INLINE_VISIBILITY507 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT {
541 void swap(unique_ptr& __u) _NOEXCEPT {
542 __ptr_.swap(__u.__ptr_);508 __ptr_.swap(__u.__ptr_);
543 }509 }
544
545};510};
546511
547template <class _Tp, class _Dp>512template <class _Tp, class _Dp>
548inline _LIBCPP_INLINE_VISIBILITY513inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
549typename enable_if<514 typename enable_if< __is_swappable<_Dp>::value, void >::type
550 __is_swappable<_Dp>::value,515 swap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT {
551 void516 __x.swap(__y);
552>::type517}
553swap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT {__x.swap(__y);}
554518
555template <class _T1, class _D1, class _T2, class _D2>519template <class _T1, class _D1, class _T2, class _D2>
556inline _LIBCPP_INLINE_VISIBILITY520inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
557bool521operator==(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {
558operator==(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __x.get() == __y.get();}522 return __x.get() == __y.get();
523}
559524
525#if _LIBCPP_STD_VER <= 17
560template <class _T1, class _D1, class _T2, class _D2>526template <class _T1, class _D1, class _T2, class _D2>
561inline _LIBCPP_INLINE_VISIBILITY527inline _LIBCPP_INLINE_VISIBILITY
562bool528bool
563operator!=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x == __y);}529operator!=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x == __y);}
530#endif
564531
565template <class _T1, class _D1, class _T2, class _D2>532template <class _T1, class _D1, class _T2, class _D2>
566inline _LIBCPP_INLINE_VISIBILITY533inline _LIBCPP_INLINE_VISIBILITY
...@@ -588,14 +555,26 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -588,14 +555,26 @@ inline _LIBCPP_INLINE_VISIBILITY
588bool555bool
589operator>=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x < __y);}556operator>=(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
591template <class _T1, class _D1>571template <class _T1, class _D1>
592inline _LIBCPP_INLINE_VISIBILITY572inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
593bool573operator==(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT {
594operator==(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT574 return !__x;
595{
596 return !__x;
597}575}
598576
577#if _LIBCPP_STD_VER <= 17
599template <class _T1, class _D1>578template <class _T1, class _D1>
600inline _LIBCPP_INLINE_VISIBILITY579inline _LIBCPP_INLINE_VISIBILITY
601bool580bool
...@@ -619,72 +598,67 @@ operator!=(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT...@@ -619,72 +598,67 @@ operator!=(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT
619{598{
620 return static_cast<bool>(__x);599 return static_cast<bool>(__x);
621}600}
601#endif // _LIBCPP_STD_VER <= 17
622602
623template <class _T1, class _D1>603template <class _T1, class _D1>
624inline _LIBCPP_INLINE_VISIBILITY604inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
625bool605operator<(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
626operator<(const unique_ptr<_T1, _D1>& __x, nullptr_t)606 typedef typename unique_ptr<_T1, _D1>::pointer _P1;
627{607 return less<_P1>()(__x.get(), nullptr);
628 typedef typename unique_ptr<_T1, _D1>::pointer _P1;
629 return less<_P1>()(__x.get(), nullptr);
630}608}
631609
632template <class _T1, class _D1>610template <class _T1, class _D1>
633inline _LIBCPP_INLINE_VISIBILITY611inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
634bool612operator<(nullptr_t, const unique_ptr<_T1, _D1>& __x) {
635operator<(nullptr_t, const unique_ptr<_T1, _D1>& __x)613 typedef typename unique_ptr<_T1, _D1>::pointer _P1;
636{614 return less<_P1>()(nullptr, __x.get());
637 typedef typename unique_ptr<_T1, _D1>::pointer _P1;
638 return less<_P1>()(nullptr, __x.get());
639}615}
640616
641template <class _T1, class _D1>617template <class _T1, class _D1>
642inline _LIBCPP_INLINE_VISIBILITY618inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
643bool619operator>(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
644operator>(const unique_ptr<_T1, _D1>& __x, nullptr_t)620 return nullptr < __x;
645{
646 return nullptr < __x;
647}621}
648622
649template <class _T1, class _D1>623template <class _T1, class _D1>
650inline _LIBCPP_INLINE_VISIBILITY624inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
651bool625operator>(nullptr_t, const unique_ptr<_T1, _D1>& __x) {
652operator>(nullptr_t, const unique_ptr<_T1, _D1>& __x)626 return __x < nullptr;
653{
654 return __x < nullptr;
655}627}
656628
657template <class _T1, class _D1>629template <class _T1, class _D1>
658inline _LIBCPP_INLINE_VISIBILITY630inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
659bool631operator<=(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
660operator<=(const unique_ptr<_T1, _D1>& __x, nullptr_t)632 return !(nullptr < __x);
661{
662 return !(nullptr < __x);
663}633}
664634
665template <class _T1, class _D1>635template <class _T1, class _D1>
666inline _LIBCPP_INLINE_VISIBILITY636inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
667bool637operator<=(nullptr_t, const unique_ptr<_T1, _D1>& __x) {
668operator<=(nullptr_t, const unique_ptr<_T1, _D1>& __x)638 return !(__x < nullptr);
669{
670 return !(__x < nullptr);
671}639}
672640
673template <class _T1, class _D1>641template <class _T1, class _D1>
674inline _LIBCPP_INLINE_VISIBILITY642inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
675bool643operator>=(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
676operator>=(const unique_ptr<_T1, _D1>& __x, nullptr_t)644 return !(__x < nullptr);
677{
678 return !(__x < nullptr);
679}645}
680646
681template <class _T1, class _D1>647template <class _T1, class _D1>
682inline _LIBCPP_INLINE_VISIBILITY648inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
683bool649operator>=(nullptr_t, const unique_ptr<_T1, _D1>& __x) {
684operator>=(nullptr_t, const unique_ptr<_T1, _D1>& __x)650 return !(nullptr < __x);
685{651}
686 return !(nullptr < __x);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));
687}660}
661#endif
688662
689#if _LIBCPP_STD_VER > 11663#if _LIBCPP_STD_VER > 11
690664
...@@ -706,21 +680,17 @@ struct __unique_if<_Tp[_Np]>...@@ -706,21 +680,17 @@ struct __unique_if<_Tp[_Np]>
706 typedef void __unique_array_known_bound;680 typedef void __unique_array_known_bound;
707};681};
708682
709template<class _Tp, class... _Args>683template <class _Tp, class... _Args>
710inline _LIBCPP_INLINE_VISIBILITY684inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_single
711typename __unique_if<_Tp>::__unique_single685make_unique(_Args&&... __args) {
712make_unique(_Args&&... __args)686 return unique_ptr<_Tp>(new _Tp(_VSTD::forward<_Args>(__args)...));
713{
714 return unique_ptr<_Tp>(new _Tp(_VSTD::forward<_Args>(__args)...));
715}687}
716688
717template<class _Tp>689template <class _Tp>
718inline _LIBCPP_INLINE_VISIBILITY690inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_array_unknown_bound
719typename __unique_if<_Tp>::__unique_array_unknown_bound691make_unique(size_t __n) {
720make_unique(size_t __n)692 typedef __remove_extent_t<_Tp> _Up;
721{693 return unique_ptr<_Tp>(new _Up[__n]());
722 typedef typename remove_extent<_Tp>::type _Up;
723 return unique_ptr<_Tp>(new _Up[__n]());
724}694}
725695
726template<class _Tp, class... _Args>696template<class _Tp, class... _Args>
...@@ -729,6 +699,25 @@ template<class _Tp, class... _Args>...@@ -729,6 +699,25 @@ template<class _Tp, class... _Args>
729699
730#endif // _LIBCPP_STD_VER > 11700#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
732template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;721template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
733722
734template <class _Tp, class _Dp>723template <class _Tp, class _Dp>
lib/libcxx/include/__memory/uses_allocator.h+1-1
...@@ -11,8 +11,8 @@...@@ -11,8 +11,8 @@
11#define _LIBCPP___MEMORY_USES_ALLOCATOR_H11#define _LIBCPP___MEMORY_USES_ALLOCATOR_H
1212
13#include <__config>13#include <__config>
14#include <__type_traits/is_convertible.h>
14#include <cstddef>15#include <cstddef>
15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header18# 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 @@...@@ -20,7 +20,7 @@
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <typename _Tp>22template <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) {
24 // Cast away cv-qualifiers to allow modifying elements of a range through const iterators.24 // Cast away cv-qualifiers to allow modifying elements of a range through const iterators.
25 return const_cast<void*>(static_cast<const volatile void*>(_VSTD::addressof(__from)));25 return const_cast<void*>(static_cast<const volatile void*>(_VSTD::addressof(__from)));
26}26}
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:...@@ -103,6 +103,7 @@ private:
103 lock_guard(lock_guard const&) = delete;103 lock_guard(lock_guard const&) = delete;
104 lock_guard& operator=(lock_guard const&) = delete;104 lock_guard& operator=(lock_guard const&) = delete;
105};105};
106_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(lock_guard);
106107
107template <class _Mutex>108template <class _Mutex>
108class _LIBCPP_TEMPLATE_VIS unique_lock109class _LIBCPP_TEMPLATE_VIS unique_lock
...@@ -195,6 +196,7 @@ public:...@@ -195,6 +196,7 @@ public:
195 _LIBCPP_INLINE_VISIBILITY196 _LIBCPP_INLINE_VISIBILITY
196 mutex_type* mutex() const _NOEXCEPT {return __m_;}197 mutex_type* mutex() const _NOEXCEPT {return __m_;}
197};198};
199_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(unique_lock);
198200
199template <class _Mutex>201template <class _Mutex>
200void202void
lib/libcxx/include/__node_handle+4-3
...@@ -60,7 +60,8 @@ public:...@@ -60,7 +60,8 @@ public:
6060
61#include <__assert>61#include <__assert>
62#include <__config>62#include <__config>
63#include <memory>63#include <__memory/allocator_traits.h>
64#include <__memory/pointer_traits.h>
64#include <optional>65#include <optional>
6566
66#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)67#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -90,8 +91,8 @@ class _LIBCPP_TEMPLATE_VIS __basic_node_handle...@@ -90,8 +91,8 @@ class _LIBCPP_TEMPLATE_VIS __basic_node_handle
90 _NodeType, __basic_node_handle<_NodeType, _Alloc, _MapOrSetSpecifics>>;91 _NodeType, __basic_node_handle<_NodeType, _Alloc, _MapOrSetSpecifics>>;
9192
92 typedef allocator_traits<_Alloc> __alloc_traits;93 typedef allocator_traits<_Alloc> __alloc_traits;
93 typedef typename __rebind_pointer<typename __alloc_traits::void_pointer,94 typedef __rebind_pointer_t<typename __alloc_traits::void_pointer,
94 _NodeType>::type95 _NodeType>
95 __node_pointer_type;96 __node_pointer_type;
9697
97public:98public:
lib/libcxx/include/__numeric/accumulate.h+2-2
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <class _InputIterator, class _Tp>22template <class _InputIterator, class _Tp>
23_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1723_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
24_Tp24_Tp
25accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)25accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
26{26{
...@@ -34,7 +34,7 @@ accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)...@@ -34,7 +34,7 @@ accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
34}34}
3535
36template <class _InputIterator, class _Tp, class _BinaryOperation>36template <class _InputIterator, class _Tp, class _BinaryOperation>
37_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1737_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
38_Tp38_Tp
39accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOperation __binary_op)39accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOperation __binary_op)
40{40{
lib/libcxx/include/__numeric/adjacent_difference.h+2-2
...@@ -21,7 +21,7 @@...@@ -21,7 +21,7 @@
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _InputIterator, class _OutputIterator>23template <class _InputIterator, class _OutputIterator>
24_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1724_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
25_OutputIterator25_OutputIterator
26adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result)26adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
27{27{
...@@ -44,7 +44,7 @@ adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterat...@@ -44,7 +44,7 @@ adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterat
44}44}
4545
46template <class _InputIterator, class _OutputIterator, class _BinaryOperation>46template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
47_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1747_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
48_OutputIterator48_OutputIterator
49adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result,49adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
50 _BinaryOperation __binary_op)50 _BinaryOperation __binary_op)
lib/libcxx/include/__numeric/exclusive_scan.h+2-2
...@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
23#if _LIBCPP_STD_VER > 1423#if _LIBCPP_STD_VER > 14
2424
25template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>25template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>
26_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator26_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
27exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp __init, _BinaryOp __b) {27exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp __init, _BinaryOp __b) {
28 if (__first != __last) {28 if (__first != __last) {
29 _Tp __tmp(__b(__init, *__first));29 _Tp __tmp(__b(__init, *__first));
...@@ -41,7 +41,7 @@ exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __...@@ -41,7 +41,7 @@ exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __
41}41}
4242
43template <class _InputIterator, class _OutputIterator, class _Tp>43template <class _InputIterator, class _OutputIterator, class _Tp>
44_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator44_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
45exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp __init) {45exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp __init) {
46 return _VSTD::exclusive_scan(__first, __last, __result, __init, _VSTD::plus<>());46 return _VSTD::exclusive_scan(__first, __last, __result, __init, _VSTD::plus<>());
47}47}
lib/libcxx/include/__numeric/gcd_lcm.h+9-5
...@@ -12,8 +12,12 @@...@@ -12,8 +12,12 @@
1212
13#include <__assert>13#include <__assert>
14#include <__config>14#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>
15#include <limits>20#include <limits>
16#include <type_traits>
1721
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header23# pragma GCC system_header
...@@ -60,8 +64,8 @@ common_type_t<_Tp,_Up>...@@ -60,8 +64,8 @@ common_type_t<_Tp,_Up>
60gcd(_Tp __m, _Up __n)64gcd(_Tp __m, _Up __n)
61{65{
62 static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to gcd must be integer types");66 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" );67 static_assert((!is_same<__remove_cv_t<_Tp>, 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" );68 static_assert((!is_same<__remove_cv_t<_Up>, bool>::value), "Second argument to gcd cannot be bool" );
65 using _Rp = common_type_t<_Tp,_Up>;69 using _Rp = common_type_t<_Tp,_Up>;
66 using _Wp = make_unsigned_t<_Rp>;70 using _Wp = make_unsigned_t<_Rp>;
67 return static_cast<_Rp>(_VSTD::__gcd(71 return static_cast<_Rp>(_VSTD::__gcd(
...@@ -75,8 +79,8 @@ common_type_t<_Tp,_Up>...@@ -75,8 +79,8 @@ common_type_t<_Tp,_Up>
75lcm(_Tp __m, _Up __n)79lcm(_Tp __m, _Up __n)
76{80{
77 static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to lcm must be integer types");81 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" );82 static_assert((!is_same<__remove_cv_t<_Tp>, 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" );83 static_assert((!is_same<__remove_cv_t<_Up>, bool>::value), "Second argument to lcm cannot be bool" );
80 if (__m == 0 || __n == 0)84 if (__m == 0 || __n == 0)
81 return 0;85 return 0;
8286
lib/libcxx/include/__numeric/inclusive_scan.h+3-3
...@@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
24#if _LIBCPP_STD_VER > 1424#if _LIBCPP_STD_VER > 14
2525
26template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>26template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>
27_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator27_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
28inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOp __b, _Tp __init) {28inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOp __b, _Tp __init) {
29 for (; __first != __last; ++__first, (void)++__result) {29 for (; __first != __last; ++__first, (void)++__result) {
30 __init = __b(__init, *__first);30 __init = __b(__init, *__first);
...@@ -34,7 +34,7 @@ inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __...@@ -34,7 +34,7 @@ inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __
34}34}
3535
36template <class _InputIterator, class _OutputIterator, class _BinaryOp>36template <class _InputIterator, class _OutputIterator, class _BinaryOp>
37_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator37_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
38inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOp __b) {38inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOp __b) {
39 if (__first != __last) {39 if (__first != __last) {
40 typename iterator_traits<_InputIterator>::value_type __init = *__first;40 typename iterator_traits<_InputIterator>::value_type __init = *__first;
...@@ -47,7 +47,7 @@ inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __...@@ -47,7 +47,7 @@ inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __
47}47}
4848
49template <class _InputIterator, class _OutputIterator>49template <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,
51 _InputIterator __last,51 _InputIterator __last,
52 _OutputIterator __result) {52 _OutputIterator __result) {
53 return _VSTD::inclusive_scan(__first, __last, __result, _VSTD::plus<>());53 return _VSTD::inclusive_scan(__first, __last, __result, _VSTD::plus<>());
lib/libcxx/include/__numeric/inner_product.h+2-2
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <class _InputIterator1, class _InputIterator2, class _Tp>22template <class _InputIterator1, class _InputIterator2, class _Tp>
23_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1723_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
24_Tp24_Tp
25inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init)25inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init)
26{26{
...@@ -34,7 +34,7 @@ inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2...@@ -34,7 +34,7 @@ inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2
34}34}
3535
36template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOperation1, class _BinaryOperation2>36template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOperation1, class _BinaryOperation2>
37_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1737_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
38_Tp38_Tp
39inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,39inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,
40 _Tp __init, _BinaryOperation1 __binary_op1, _BinaryOperation2 __binary_op2)40 _Tp __init, _BinaryOperation1 __binary_op1, _BinaryOperation2 __binary_op2)
lib/libcxx/include/__numeric/iota.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _ForwardIterator, class _Tp>21template <class _ForwardIterator, class _Tp>
22_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1722_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
23void23void
24iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)24iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
25{25{
lib/libcxx/include/__numeric/midpoint.h+16-6
...@@ -11,8 +11,18 @@...@@ -11,8 +11,18 @@
11#define _LIBCPP___NUMERIC_MIDPOINT_H11#define _LIBCPP___NUMERIC_MIDPOINT_H
1212
13#include <__config>13#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>
14#include <limits>25#include <limits>
15#include <type_traits>
1626
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header28# pragma GCC system_header
...@@ -55,12 +65,12 @@ midpoint(_TPtr __a, _TPtr __b) noexcept...@@ -55,12 +65,12 @@ midpoint(_TPtr __a, _TPtr __b) noexcept
5565
5666
57template <typename _Tp>67template <typename _Tp>
58constexpr int __sign(_Tp __val) {68_LIBCPP_HIDE_FROM_ABI constexpr int __sign(_Tp __val) {
59 return (_Tp(0) < __val) - (__val < _Tp(0));69 return (_Tp(0) < __val) - (__val < _Tp(0));
60}70}
6171
62template <typename _Fp>72template <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
65template <class _Fp>75template <class _Fp>
66_LIBCPP_INLINE_VISIBILITY constexpr76_LIBCPP_INLINE_VISIBILITY constexpr
...@@ -69,10 +79,10 @@ midpoint(_Fp __a, _Fp __b) noexcept...@@ -69,10 +79,10 @@ midpoint(_Fp __a, _Fp __b) noexcept
69{79{
70 constexpr _Fp __lo = numeric_limits<_Fp>::min()*2;80 constexpr _Fp __lo = numeric_limits<_Fp>::min()*2;
71 constexpr _Fp __hi = numeric_limits<_Fp>::max()/2;81 constexpr _Fp __hi = numeric_limits<_Fp>::max()/2;
72 return __fp_abs(__a) <= __hi && __fp_abs(__b) <= __hi ? // typical case: overflow is impossible82 return std::__fp_abs(__a) <= __hi && std::__fp_abs(__b) <= __hi ? // typical case: overflow is impossible
73 (__a + __b)/2 : // always correctly rounded83 (__a + __b)/2 : // always correctly rounded
74 __fp_abs(__a) < __lo ? __a + __b/2 : // not safe to halve a84 std::__fp_abs(__a) < __lo ? __a + __b/2 : // not safe to halve a
75 __fp_abs(__b) < __lo ? __a/2 + __b : // not safe to halve b85 std::__fp_abs(__b) < __lo ? __a/2 + __b : // not safe to halve b
76 __a/2 + __b/2; // otherwise correctly rounded86 __a/2 + __b/2; // otherwise correctly rounded
77}87}
7888
lib/libcxx/include/__numeric/partial_sum.h+2-2
...@@ -21,7 +21,7 @@...@@ -21,7 +21,7 @@
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _InputIterator, class _OutputIterator>23template <class _InputIterator, class _OutputIterator>
24_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1724_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
25_OutputIterator25_OutputIterator
26partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result)26partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
27{27{
...@@ -43,7 +43,7 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res...@@ -43,7 +43,7 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res
43}43}
4444
45template <class _InputIterator, class _OutputIterator, class _BinaryOperation>45template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
46_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1746_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
47_OutputIterator47_OutputIterator
48partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result,48partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
49 _BinaryOperation __binary_op)49 _BinaryOperation __binary_op)
lib/libcxx/include/__numeric/reduce.h+3-3
...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if _LIBCPP_STD_VER > 1423#if _LIBCPP_STD_VER > 14
24template <class _InputIterator, class _Tp, class _BinaryOp>24template <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,
26 _Tp __init, _BinaryOp __b) {26 _Tp __init, _BinaryOp __b) {
27 for (; __first != __last; ++__first)27 for (; __first != __last; ++__first)
28 __init = __b(__init, *__first);28 __init = __b(__init, *__first);
...@@ -30,13 +30,13 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp reduce(_InputIterato...@@ -30,13 +30,13 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp reduce(_InputIterato
30}30}
3131
32template <class _InputIterator, class _Tp>32template <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,
34 _Tp __init) {34 _Tp __init) {
35 return _VSTD::reduce(__first, __last, __init, _VSTD::plus<>());35 return _VSTD::reduce(__first, __last, __init, _VSTD::plus<>());
36}36}
3737
38template <class _InputIterator>38template <class _InputIterator>
39_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 typename iterator_traits<_InputIterator>::value_type39_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 typename iterator_traits<_InputIterator>::value_type
40reduce(_InputIterator __first, _InputIterator __last) {40reduce(_InputIterator __first, _InputIterator __last) {
41 return _VSTD::reduce(__first, __last, typename iterator_traits<_InputIterator>::value_type{});41 return _VSTD::reduce(__first, __last, typename iterator_traits<_InputIterator>::value_type{});
42}42}
lib/libcxx/include/__numeric/transform_exclusive_scan.h+1-1
...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _InputIterator, class _OutputIterator, class _Tp,23template <class _InputIterator, class _OutputIterator, class _Tp,
24 class _BinaryOp, class _UnaryOp>24 class _BinaryOp, class _UnaryOp>
25_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1725_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
26_OutputIterator26_OutputIterator
27transform_exclusive_scan(_InputIterator __first, _InputIterator __last,27transform_exclusive_scan(_InputIterator __first, _InputIterator __last,
28 _OutputIterator __result, _Tp __init,28 _OutputIterator __result, _Tp __init,
lib/libcxx/include/__numeric/transform_inclusive_scan.h+2-2
...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22#if _LIBCPP_STD_VER > 1422#if _LIBCPP_STD_VER > 14
2323
24template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp, class _UnaryOp>24template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp, class _UnaryOp>
25_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1725_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
26_OutputIterator26_OutputIterator
27transform_inclusive_scan(_InputIterator __first, _InputIterator __last,27transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
28 _OutputIterator __result, _BinaryOp __b, _UnaryOp __u, _Tp __init)28 _OutputIterator __result, _BinaryOp __b, _UnaryOp __u, _Tp __init)
...@@ -36,7 +36,7 @@ transform_inclusive_scan(_InputIterator __first, _InputIterator __last,...@@ -36,7 +36,7 @@ transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
36}36}
3737
38template <class _InputIterator, class _OutputIterator, class _BinaryOp, class _UnaryOp>38template <class _InputIterator, class _OutputIterator, class _BinaryOp, class _UnaryOp>
39_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1739_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
40_OutputIterator40_OutputIterator
41transform_inclusive_scan(_InputIterator __first, _InputIterator __last,41transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
42 _OutputIterator __result, _BinaryOp __b, _UnaryOp __u)42 _OutputIterator __result, _BinaryOp __b, _UnaryOp __u)
lib/libcxx/include/__numeric/transform_reduce.h+3-3
...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if _LIBCPP_STD_VER > 1423#if _LIBCPP_STD_VER > 14
24template <class _InputIterator, class _Tp, class _BinaryOp, class _UnaryOp>24template <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,
26 _InputIterator __last, _Tp __init,26 _InputIterator __last, _Tp __init,
27 _BinaryOp __b, _UnaryOp __u) {27 _BinaryOp __b, _UnaryOp __u) {
28 for (; __first != __last; ++__first)28 for (; __first != __last; ++__first)
...@@ -31,7 +31,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp transform_reduce(_In...@@ -31,7 +31,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp transform_reduce(_In
31}31}
3232
33template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOp1, class _BinaryOp2>33template <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,
35 _InputIterator1 __last1,35 _InputIterator1 __last1,
36 _InputIterator2 __first2, _Tp __init,36 _InputIterator2 __first2, _Tp __init,
37 _BinaryOp1 __b1, _BinaryOp2 __b2) {37 _BinaryOp1 __b1, _BinaryOp2 __b2) {
...@@ -41,7 +41,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp transform_reduce(_In...@@ -41,7 +41,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp transform_reduce(_In
41}41}
4242
43template <class _InputIterator1, class _InputIterator2, class _Tp>43template <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,
45 _InputIterator1 __last1,45 _InputIterator1 __last1,
46 _InputIterator2 __first2, _Tp __init) {46 _InputIterator2 __first2, _Tp __init) {
47 return _VSTD::transform_reduce(__first1, __last1, __first2, _VSTD::move(__init), _VSTD::plus<>(),47 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)...@@ -110,7 +110,7 @@ bernoulli_distribution::operator()(_URNG& __g, const param_type& __p)
110}110}
111111
112template <class _CharT, class _Traits>112template <class _CharT, class _Traits>
113basic_ostream<_CharT, _Traits>&113_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
114operator<<(basic_ostream<_CharT, _Traits>& __os, const bernoulli_distribution& __x)114operator<<(basic_ostream<_CharT, _Traits>& __os, const bernoulli_distribution& __x)
115{115{
116 __save_flags<_CharT, _Traits> __lx(__os);116 __save_flags<_CharT, _Traits> __lx(__os);
...@@ -123,7 +123,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bernoulli_distribution& _...@@ -123,7 +123,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bernoulli_distribution& _
123}123}
124124
125template <class _CharT, class _Traits>125template <class _CharT, class _Traits>
126basic_istream<_CharT, _Traits>&126_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
127operator>>(basic_istream<_CharT, _Traits>& __is, bernoulli_distribution& __x)127operator>>(basic_istream<_CharT, _Traits>& __is, bernoulli_distribution& __x)
128{128{
129 typedef bernoulli_distribution _Eng;129 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...@@ -133,9 +133,9 @@ binomial_distribution<_IntType>::param_type::param_type(result_type __t, double
133 if (0 < __p_ && __p_ < 1)133 if (0 < __p_ && __p_ < 1)
134 {134 {
135 __r0_ = static_cast<result_type>((__t_ + 1) * __p_);135 __r0_ = static_cast<result_type>((__t_ + 1) * __p_);
136 __pr_ = _VSTD::exp(__libcpp_lgamma(__t_ + 1.) -136 __pr_ = _VSTD::exp(std::__libcpp_lgamma(__t_ + 1.) -
137 __libcpp_lgamma(__r0_ + 1.) -137 std::__libcpp_lgamma(__r0_ + 1.) -
138 __libcpp_lgamma(__t_ - __r0_ + 1.) + __r0_ * _VSTD::log(__p_) +138 std::__libcpp_lgamma(__t_ - __r0_ + 1.) + __r0_ * _VSTD::log(__p_) +
139 (__t_ - __r0_) * _VSTD::log(1 - __p_));139 (__t_ - __r0_) * _VSTD::log(1 - __p_));
140 __odds_ratio_ = __p_ / (1 - __p_);140 __odds_ratio_ = __p_ / (1 - __p_);
141 }141 }
...@@ -189,7 +189,7 @@ binomial_distribution<_IntType>::operator()(_URNG& __g, const param_type& __pr)...@@ -189,7 +189,7 @@ binomial_distribution<_IntType>::operator()(_URNG& __g, const param_type& __pr)
189}189}
190190
191template <class _CharT, class _Traits, class _IntType>191template <class _CharT, class _Traits, class _IntType>
192basic_ostream<_CharT, _Traits>&192_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
193operator<<(basic_ostream<_CharT, _Traits>& __os,193operator<<(basic_ostream<_CharT, _Traits>& __os,
194 const binomial_distribution<_IntType>& __x)194 const binomial_distribution<_IntType>& __x)
195{195{
...@@ -203,7 +203,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -203,7 +203,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
203}203}
204204
205template <class _CharT, class _Traits, class _IntType>205template <class _CharT, class _Traits, class _IntType>
206basic_istream<_CharT, _Traits>&206_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
207operator>>(basic_istream<_CharT, _Traits>& __is,207operator>>(basic_istream<_CharT, _Traits>& __is,
208 binomial_distribution<_IntType>& __x)208 binomial_distribution<_IntType>& __x)
209{209{
lib/libcxx/include/__random/cauchy_distribution.h+2-2
...@@ -124,7 +124,7 @@ cauchy_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)...@@ -124,7 +124,7 @@ cauchy_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
124}124}
125125
126template <class _CharT, class _Traits, class _RT>126template <class _CharT, class _Traits, class _RT>
127basic_ostream<_CharT, _Traits>&127_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
128operator<<(basic_ostream<_CharT, _Traits>& __os,128operator<<(basic_ostream<_CharT, _Traits>& __os,
129 const cauchy_distribution<_RT>& __x)129 const cauchy_distribution<_RT>& __x)
130{130{
...@@ -139,7 +139,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -139,7 +139,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
139}139}
140140
141template <class _CharT, class _Traits, class _RT>141template <class _CharT, class _Traits, class _RT>
142basic_istream<_CharT, _Traits>&142_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
143operator>>(basic_istream<_CharT, _Traits>& __is,143operator>>(basic_istream<_CharT, _Traits>& __is,
144 cauchy_distribution<_RT>& __x)144 cauchy_distribution<_RT>& __x)
145{145{
lib/libcxx/include/__random/chi_squared_distribution.h+2-2
...@@ -107,7 +107,7 @@ public:...@@ -107,7 +107,7 @@ public:
107};107};
108108
109template <class _CharT, class _Traits, class _RT>109template <class _CharT, class _Traits, class _RT>
110basic_ostream<_CharT, _Traits>&110_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
111operator<<(basic_ostream<_CharT, _Traits>& __os,111operator<<(basic_ostream<_CharT, _Traits>& __os,
112 const chi_squared_distribution<_RT>& __x)112 const chi_squared_distribution<_RT>& __x)
113{113{
...@@ -120,7 +120,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -120,7 +120,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
120}120}
121121
122template <class _CharT, class _Traits, class _RT>122template <class _CharT, class _Traits, class _RT>
123basic_istream<_CharT, _Traits>&123_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
124operator>>(basic_istream<_CharT, _Traits>& __is,124operator>>(basic_istream<_CharT, _Traits>& __is,
125 chi_squared_distribution<_RT>& __x)125 chi_squared_distribution<_RT>& __x)
126{126{
lib/libcxx/include/__random/discard_block_engine.h+6-4
...@@ -12,8 +12,8 @@...@@ -12,8 +12,8 @@
12#include <__config>12#include <__config>
13#include <__random/is_seed_sequence.h>13#include <__random/is_seed_sequence.h>
14#include <__utility/move.h>14#include <__utility/move.h>
15#include <climits>
16#include <iosfwd>15#include <iosfwd>
16#include <limits>
17#include <type_traits>17#include <type_traits>
1818
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -33,7 +33,9 @@ class _LIBCPP_TEMPLATE_VIS discard_block_engine...@@ -33,7 +33,9 @@ class _LIBCPP_TEMPLATE_VIS discard_block_engine
3333
34 static_assert( 0 < __r, "discard_block_engine invalid parameters");34 static_assert( 0 < __r, "discard_block_engine invalid parameters");
35 static_assert(__r <= __p, "discard_block_engine invalid parameters");35 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
37public:39public:
38 // types40 // types
39 typedef typename _Engine::result_type result_type;41 typedef typename _Engine::result_type result_type;
...@@ -164,7 +166,7 @@ operator!=(const discard_block_engine<_Eng, _Pp, _Rp>& __x,...@@ -164,7 +166,7 @@ operator!=(const discard_block_engine<_Eng, _Pp, _Rp>& __x,
164166
165template <class _CharT, class _Traits,167template <class _CharT, class _Traits,
166 class _Eng, size_t _Pp, size_t _Rp>168 class _Eng, size_t _Pp, size_t _Rp>
167basic_ostream<_CharT, _Traits>&169_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
168operator<<(basic_ostream<_CharT, _Traits>& __os,170operator<<(basic_ostream<_CharT, _Traits>& __os,
169 const discard_block_engine<_Eng, _Pp, _Rp>& __x)171 const discard_block_engine<_Eng, _Pp, _Rp>& __x)
170{172{
...@@ -178,7 +180,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -178,7 +180,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
178180
179template <class _CharT, class _Traits,181template <class _CharT, class _Traits,
180 class _Eng, size_t _Pp, size_t _Rp>182 class _Eng, size_t _Pp, size_t _Rp>
181basic_istream<_CharT, _Traits>&183_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
182operator>>(basic_istream<_CharT, _Traits>& __is,184operator>>(basic_istream<_CharT, _Traits>& __is,
183 discard_block_engine<_Eng, _Pp, _Rp>& __x)185 discard_block_engine<_Eng, _Pp, _Rp>& __x)
184{186{
lib/libcxx/include/__random/discrete_distribution.h+2-2
...@@ -221,7 +221,7 @@ discrete_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p)...@@ -221,7 +221,7 @@ discrete_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p)
221}221}
222222
223template <class _CharT, class _Traits, class _IT>223template <class _CharT, class _Traits, class _IT>
224basic_ostream<_CharT, _Traits>&224_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
225operator<<(basic_ostream<_CharT, _Traits>& __os,225operator<<(basic_ostream<_CharT, _Traits>& __os,
226 const discrete_distribution<_IT>& __x)226 const discrete_distribution<_IT>& __x)
227{227{
...@@ -239,7 +239,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -239,7 +239,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
239}239}
240240
241template <class _CharT, class _Traits, class _IT>241template <class _CharT, class _Traits, class _IT>
242basic_istream<_CharT, _Traits>&242_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
243operator>>(basic_istream<_CharT, _Traits>& __is,243operator>>(basic_istream<_CharT, _Traits>& __is,
244 discrete_distribution<_IT>& __x)244 discrete_distribution<_IT>& __x)
245{245{
lib/libcxx/include/__random/exponential_distribution.h+2-2
...@@ -121,7 +121,7 @@ exponential_distribution<_RealType>::operator()(_URNG& __g, const param_type& __...@@ -121,7 +121,7 @@ exponential_distribution<_RealType>::operator()(_URNG& __g, const param_type& __
121}121}
122122
123template <class _CharT, class _Traits, class _RealType>123template <class _CharT, class _Traits, class _RealType>
124basic_ostream<_CharT, _Traits>&124_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
125operator<<(basic_ostream<_CharT, _Traits>& __os,125operator<<(basic_ostream<_CharT, _Traits>& __os,
126 const exponential_distribution<_RealType>& __x)126 const exponential_distribution<_RealType>& __x)
127{127{
...@@ -133,7 +133,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -133,7 +133,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
133}133}
134134
135template <class _CharT, class _Traits, class _RealType>135template <class _CharT, class _Traits, class _RealType>
136basic_istream<_CharT, _Traits>&136_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
137operator>>(basic_istream<_CharT, _Traits>& __is,137operator>>(basic_istream<_CharT, _Traits>& __is,
138 exponential_distribution<_RealType>& __x)138 exponential_distribution<_RealType>& __x)
139{139{
lib/libcxx/include/__random/extreme_value_distribution.h+2-2
...@@ -123,7 +123,7 @@ extreme_value_distribution<_RealType>::operator()(_URNG& __g, const param_type&...@@ -123,7 +123,7 @@ extreme_value_distribution<_RealType>::operator()(_URNG& __g, const param_type&
123}123}
124124
125template <class _CharT, class _Traits, class _RT>125template <class _CharT, class _Traits, class _RT>
126basic_ostream<_CharT, _Traits>&126_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
127operator<<(basic_ostream<_CharT, _Traits>& __os,127operator<<(basic_ostream<_CharT, _Traits>& __os,
128 const extreme_value_distribution<_RT>& __x)128 const extreme_value_distribution<_RT>& __x)
129{129{
...@@ -138,7 +138,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -138,7 +138,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
138}138}
139139
140template <class _CharT, class _Traits, class _RT>140template <class _CharT, class _Traits, class _RT>
141basic_istream<_CharT, _Traits>&141_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
142operator>>(basic_istream<_CharT, _Traits>& __is,142operator>>(basic_istream<_CharT, _Traits>& __is,
143 extreme_value_distribution<_RT>& __x)143 extreme_value_distribution<_RT>& __x)
144{144{
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)...@@ -122,7 +122,7 @@ fisher_f_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
122}122}
123123
124template <class _CharT, class _Traits, class _RT>124template <class _CharT, class _Traits, class _RT>
125basic_ostream<_CharT, _Traits>&125_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
126operator<<(basic_ostream<_CharT, _Traits>& __os,126operator<<(basic_ostream<_CharT, _Traits>& __os,
127 const fisher_f_distribution<_RT>& __x)127 const fisher_f_distribution<_RT>& __x)
128{128{
...@@ -137,7 +137,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -137,7 +137,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
137}137}
138138
139template <class _CharT, class _Traits, class _RT>139template <class _CharT, class _Traits, class _RT>
140basic_istream<_CharT, _Traits>&140_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
141operator>>(basic_istream<_CharT, _Traits>& __is,141operator>>(basic_istream<_CharT, _Traits>& __is,
142 fisher_f_distribution<_RT>& __x)142 fisher_f_distribution<_RT>& __x)
143{143{
lib/libcxx/include/__random/gamma_distribution.h+2-2
...@@ -175,7 +175,7 @@ gamma_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)...@@ -175,7 +175,7 @@ gamma_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
175}175}
176176
177template <class _CharT, class _Traits, class _RT>177template <class _CharT, class _Traits, class _RT>
178basic_ostream<_CharT, _Traits>&178_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
179operator<<(basic_ostream<_CharT, _Traits>& __os,179operator<<(basic_ostream<_CharT, _Traits>& __os,
180 const gamma_distribution<_RT>& __x)180 const gamma_distribution<_RT>& __x)
181{181{
...@@ -190,7 +190,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -190,7 +190,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
190}190}
191191
192template <class _CharT, class _Traits, class _RT>192template <class _CharT, class _Traits, class _RT>
193basic_istream<_CharT, _Traits>&193_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
194operator>>(basic_istream<_CharT, _Traits>& __is,194operator>>(basic_istream<_CharT, _Traits>& __is,
195 gamma_distribution<_RT>& __x)195 gamma_distribution<_RT>& __x)
196{196{
lib/libcxx/include/__random/generate_canonical.h+1-1
...@@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
27// generate_canonical27// generate_canonical
2828
29template<class _RealType, size_t __bits, class _URNG>29template<class _RealType, size_t __bits, class _URNG>
30_RealType30_LIBCPP_HIDE_FROM_ABI _RealType
31generate_canonical(_URNG& __g)31generate_canonical(_URNG& __g)
32{32{
33 const size_t _Dt = numeric_limits<_RealType>::digits;33 const size_t _Dt = numeric_limits<_RealType>::digits;
lib/libcxx/include/__random/geometric_distribution.h+2-2
...@@ -108,7 +108,7 @@ public:...@@ -108,7 +108,7 @@ public:
108};108};
109109
110template <class _CharT, class _Traits, class _IntType>110template <class _CharT, class _Traits, class _IntType>
111basic_ostream<_CharT, _Traits>&111_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
112operator<<(basic_ostream<_CharT, _Traits>& __os,112operator<<(basic_ostream<_CharT, _Traits>& __os,
113 const geometric_distribution<_IntType>& __x)113 const geometric_distribution<_IntType>& __x)
114{114{
...@@ -120,7 +120,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -120,7 +120,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
120}120}
121121
122template <class _CharT, class _Traits, class _IntType>122template <class _CharT, class _Traits, class _IntType>
123basic_istream<_CharT, _Traits>&123_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
124operator>>(basic_istream<_CharT, _Traits>& __is,124operator>>(basic_istream<_CharT, _Traits>& __is,
125 geometric_distribution<_IntType>& __x)125 geometric_distribution<_IntType>& __x)
126{126{
lib/libcxx/include/__random/independent_bits_engine.h+4-8
...@@ -51,12 +51,8 @@ private:...@@ -51,12 +51,8 @@ private:
51 static_assert(__w <= _Dt, "independent_bits_engine invalid parameters");51 static_assert(__w <= _Dt, "independent_bits_engine invalid parameters");
5252
53 typedef typename _Engine::result_type _Engine_result_type;53 typedef typename _Engine::result_type _Engine_result_type;
54 typedef typename conditional54 typedef __conditional_t<sizeof(_Engine_result_type) <= sizeof(result_type), result_type, _Engine_result_type>
55 <55 _Working_result_type;
56 sizeof(_Engine_result_type) <= sizeof(result_type),
57 result_type,
58 _Engine_result_type
59 >::type _Working_result_type;
60#ifdef _LIBCPP_CXX03_LANG56#ifdef _LIBCPP_CXX03_LANG
61 static const _Working_result_type _Rp = _Engine::_Max - _Engine::_Min57 static const _Working_result_type _Rp = _Engine::_Max - _Engine::_Min
62 + _Working_result_type(1);58 + _Working_result_type(1);
...@@ -244,7 +240,7 @@ operator!=(...@@ -244,7 +240,7 @@ operator!=(
244240
245template <class _CharT, class _Traits,241template <class _CharT, class _Traits,
246 class _Eng, size_t _Wp, class _UInt>242 class _Eng, size_t _Wp, class _UInt>
247basic_ostream<_CharT, _Traits>&243_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
248operator<<(basic_ostream<_CharT, _Traits>& __os,244operator<<(basic_ostream<_CharT, _Traits>& __os,
249 const independent_bits_engine<_Eng, _Wp, _UInt>& __x)245 const independent_bits_engine<_Eng, _Wp, _UInt>& __x)
250{246{
...@@ -253,7 +249,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -253,7 +249,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
253249
254template <class _CharT, class _Traits,250template <class _CharT, class _Traits,
255 class _Eng, size_t _Wp, class _UInt>251 class _Eng, size_t _Wp, class _UInt>
256basic_istream<_CharT, _Traits>&252_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
257operator>>(basic_istream<_CharT, _Traits>& __is,253operator>>(basic_istream<_CharT, _Traits>& __is,
258 independent_bits_engine<_Eng, _Wp, _UInt>& __x)254 independent_bits_engine<_Eng, _Wp, _UInt>& __x)
259{255{
lib/libcxx/include/__random/is_seed_sequence.h+1-1
...@@ -23,7 +23,7 @@ struct __is_seed_sequence...@@ -23,7 +23,7 @@ struct __is_seed_sequence
23{23{
24 static _LIBCPP_CONSTEXPR const bool value =24 static _LIBCPP_CONSTEXPR const bool value =
25 !is_convertible<_Sseq, typename _Engine::result_type>::value &&25 !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;
27};27};
2828
29_LIBCPP_END_NAMESPACE_STD29_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 {};...@@ -53,7 +53,7 @@ template<> struct __libcpp_random_is_valid_inttype<__uint128_t> : true_type {};
53template<class, class = void> struct __libcpp_random_is_valid_urng : false_type {};53template<class, class = void> struct __libcpp_random_is_valid_urng : false_type {};
54template<class _Gp> struct __libcpp_random_is_valid_urng<_Gp, __enable_if_t<54template<class _Gp> struct __libcpp_random_is_valid_urng<_Gp, __enable_if_t<
55 is_unsigned<typename _Gp::result_type>::value &&55 is_unsigned<typename _Gp::result_type>::value &&
56 _IsSame<decltype(declval<_Gp&>()()), typename _Gp::result_type>::value56 _IsSame<decltype(std::declval<_Gp&>()()), typename _Gp::result_type>::value
57> > : true_type {};57> > : true_type {};
5858
59_LIBCPP_END_NAMESPACE_STD59_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__random/linear_congruential_engine.h+2-2
...@@ -198,7 +198,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -198,7 +198,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
198198
199template <class _CharT, class _Traits,199template <class _CharT, class _Traits,
200 class _Up, _Up _Ap, _Up _Cp, _Up _Np>200 class _Up, _Up _Ap, _Up _Cp, _Up _Np>
201basic_istream<_CharT, _Traits>&201_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
202operator>>(basic_istream<_CharT, _Traits>& __is,202operator>>(basic_istream<_CharT, _Traits>& __is,
203 linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x);203 linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x);
204204
...@@ -372,7 +372,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -372,7 +372,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
372372
373template <class _CharT, class _Traits,373template <class _CharT, class _Traits,
374 class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>374 class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
375basic_istream<_CharT, _Traits>&375_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
376operator>>(basic_istream<_CharT, _Traits>& __is,376operator>>(basic_istream<_CharT, _Traits>& __is,
377 linear_congruential_engine<_UIntType, __a, __c, __m>& __x)377 linear_congruential_engine<_UIntType, __a, __c, __m>& __x)
378{378{
lib/libcxx/include/__random/log2.h+3-6
...@@ -58,15 +58,12 @@ struct __log2...@@ -58,15 +58,12 @@ struct __log2
58{58{
59 static const size_t value = __log2_imp<59 static const size_t value = __log2_imp<
60#ifndef _LIBCPP_HAS_NO_INT12860#ifndef _LIBCPP_HAS_NO_INT128
61 typename conditional<61 __conditional_t<sizeof(_UIntType) <= sizeof(unsigned long long), unsigned long long, __uint128_t>,
62 sizeof(_UIntType) <= sizeof(unsigned long long),
63 unsigned long long,
64 __uint128_t
65 >::type,
66#else62#else
67 unsigned long long,63 unsigned long long,
68#endif // _LIBCPP_HAS_NO_INT12864#endif // _LIBCPP_HAS_NO_INT128
69 _Xp, sizeof(_UIntType) * __CHAR_BIT__ - 1>::value;65 _Xp,
66 sizeof(_UIntType) * __CHAR_BIT__ - 1>::value;
70};67};
7168
72_LIBCPP_END_NAMESPACE_STD69_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;...@@ -36,7 +36,7 @@ class _LIBCPP_TEMPLATE_VIS mersenne_twister_engine;
36template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,36template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
37 _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,37 _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
38 _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>38 _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>
39bool39_LIBCPP_HIDE_FROM_ABI bool
40operator==(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,40operator==(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
41 _Bp, _Tp, _Cp, _Lp, _Fp>& __x,41 _Bp, _Tp, _Cp, _Lp, _Fp>& __x,
42 const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,42 const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
...@@ -56,7 +56,7 @@ template <class _CharT, class _Traits,...@@ -56,7 +56,7 @@ template <class _CharT, class _Traits,
56 class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,56 class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
57 _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,57 _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
58 _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>58 _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>&
60operator<<(basic_ostream<_CharT, _Traits>& __os,60operator<<(basic_ostream<_CharT, _Traits>& __os,
61 const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,61 const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
62 _Bp, _Tp, _Cp, _Lp, _Fp>& __x);62 _Bp, _Tp, _Cp, _Lp, _Fp>& __x);
...@@ -65,7 +65,7 @@ template <class _CharT, class _Traits,...@@ -65,7 +65,7 @@ template <class _CharT, class _Traits,
65 class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,65 class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
66 _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,66 _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
67 _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>67 _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>&
69operator>>(basic_istream<_CharT, _Traits>& __is,69operator>>(basic_istream<_CharT, _Traits>& __is,
70 mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,70 mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
71 _Bp, _Tp, _Cp, _Lp, _Fp>& __x);71 _Bp, _Tp, _Cp, _Lp, _Fp>& __x);
...@@ -416,7 +416,7 @@ mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b,...@@ -416,7 +416,7 @@ mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b,
416template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,416template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
417 _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,417 _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
418 _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>418 _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>
419bool419_LIBCPP_HIDE_FROM_ABI bool
420operator==(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,420operator==(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
421 _Bp, _Tp, _Cp, _Lp, _Fp>& __x,421 _Bp, _Tp, _Cp, _Lp, _Fp>& __x,
422 const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,422 const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
...@@ -474,7 +474,7 @@ template <class _CharT, class _Traits,...@@ -474,7 +474,7 @@ template <class _CharT, class _Traits,
474 class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,474 class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
475 _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,475 _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
476 _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>476 _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>&
478operator<<(basic_ostream<_CharT, _Traits>& __os,478operator<<(basic_ostream<_CharT, _Traits>& __os,
479 const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,479 const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
480 _Bp, _Tp, _Cp, _Lp, _Fp>& __x)480 _Bp, _Tp, _Cp, _Lp, _Fp>& __x)
...@@ -496,7 +496,7 @@ template <class _CharT, class _Traits,...@@ -496,7 +496,7 @@ template <class _CharT, class _Traits,
496 class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,496 class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
497 _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,497 _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp,
498 _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp>498 _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>&
500operator>>(basic_istream<_CharT, _Traits>& __is,500operator>>(basic_istream<_CharT, _Traits>& __is,
501 mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,501 mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
502 _Bp, _Tp, _Cp, _Lp, _Fp>& __x)502 _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_...@@ -144,7 +144,7 @@ negative_binomial_distribution<_IntType>::operator()(_URNG& __urng, const param_
144}144}
145145
146template <class _CharT, class _Traits, class _IntType>146template <class _CharT, class _Traits, class _IntType>
147basic_ostream<_CharT, _Traits>&147_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
148operator<<(basic_ostream<_CharT, _Traits>& __os,148operator<<(basic_ostream<_CharT, _Traits>& __os,
149 const negative_binomial_distribution<_IntType>& __x)149 const negative_binomial_distribution<_IntType>& __x)
150{150{
...@@ -158,7 +158,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -158,7 +158,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
158}158}
159159
160template <class _CharT, class _Traits, class _IntType>160template <class _CharT, class _Traits, class _IntType>
161basic_istream<_CharT, _Traits>&161_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
162operator>>(basic_istream<_CharT, _Traits>& __is,162operator>>(basic_istream<_CharT, _Traits>& __is,
163 negative_binomial_distribution<_IntType>& __x)163 negative_binomial_distribution<_IntType>& __x)
164{164{
lib/libcxx/include/__random/normal_distribution.h+20-20
...@@ -58,8 +58,8 @@ public:...@@ -58,8 +58,8 @@ public:
5858
59private:59private:
60 param_type __p_;60 param_type __p_;
61 result_type _V_;61 result_type __v_;
62 bool _V_hot_;62 bool __v_hot_;
6363
64public:64public:
65 // constructors and reset functions65 // constructors and reset functions
...@@ -68,18 +68,18 @@ public:...@@ -68,18 +68,18 @@ public:
68 normal_distribution() : normal_distribution(0) {}68 normal_distribution() : normal_distribution(0) {}
69 _LIBCPP_INLINE_VISIBILITY69 _LIBCPP_INLINE_VISIBILITY
70 explicit normal_distribution(result_type __mean, result_type __stddev = 1)70 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) {}
72#else72#else
73 _LIBCPP_INLINE_VISIBILITY73 _LIBCPP_INLINE_VISIBILITY
74 explicit normal_distribution(result_type __mean = 0,74 explicit normal_distribution(result_type __mean = 0,
75 result_type __stddev = 1)75 result_type __stddev = 1)
76 : __p_(param_type(__mean, __stddev)), _V_hot_(false) {}76 : __p_(param_type(__mean, __stddev)), __v_hot_(false) {}
77#endif77#endif
78 _LIBCPP_INLINE_VISIBILITY78 _LIBCPP_INLINE_VISIBILITY
79 explicit normal_distribution(const param_type& __p)79 explicit normal_distribution(const param_type& __p)
80 : __p_(__p), _V_hot_(false) {}80 : __p_(__p), __v_hot_(false) {}
81 _LIBCPP_INLINE_VISIBILITY81 _LIBCPP_INLINE_VISIBILITY
82 void reset() {_V_hot_ = false;}82 void reset() {__v_hot_ = false;}
8383
84 // generating functions84 // generating functions
85 template<class _URNG>85 template<class _URNG>
...@@ -107,8 +107,8 @@ public:...@@ -107,8 +107,8 @@ public:
107 friend _LIBCPP_INLINE_VISIBILITY107 friend _LIBCPP_INLINE_VISIBILITY
108 bool operator==(const normal_distribution& __x,108 bool operator==(const normal_distribution& __x,
109 const normal_distribution& __y)109 const normal_distribution& __y)
110 {return __x.__p_ == __y.__p_ && __x._V_hot_ == __y._V_hot_ &&110 {return __x.__p_ == __y.__p_ && __x.__v_hot_ == __y.__v_hot_ &&
111 (!__x._V_hot_ || __x._V_ == __y._V_);}111 (!__x.__v_hot_ || __x.__v_ == __y.__v_);}
112 friend _LIBCPP_INLINE_VISIBILITY112 friend _LIBCPP_INLINE_VISIBILITY
113 bool operator!=(const normal_distribution& __x,113 bool operator!=(const normal_distribution& __x,
114 const normal_distribution& __y)114 const normal_distribution& __y)
...@@ -134,10 +134,10 @@ normal_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)...@@ -134,10 +134,10 @@ normal_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
134{134{
135 static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");135 static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
136 result_type _Up;136 result_type _Up;
137 if (_V_hot_)137 if (__v_hot_)
138 {138 {
139 _V_hot_ = false;139 __v_hot_ = false;
140 _Up = _V_;140 _Up = __v_;
141 }141 }
142 else142 else
143 {143 {
...@@ -152,15 +152,15 @@ normal_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)...@@ -152,15 +152,15 @@ normal_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
152 __s = __u * __u + __v * __v;152 __s = __u * __u + __v * __v;
153 } while (__s > 1 || __s == 0);153 } while (__s > 1 || __s == 0);
154 result_type _Fp = _VSTD::sqrt(-2 * _VSTD::log(__s) / __s);154 result_type _Fp = _VSTD::sqrt(-2 * _VSTD::log(__s) / __s);
155 _V_ = __v * _Fp;155 __v_ = __v * _Fp;
156 _V_hot_ = true;156 __v_hot_ = true;
157 _Up = __u * _Fp;157 _Up = __u * _Fp;
158 }158 }
159 return _Up * __p.stddev() + __p.mean();159 return _Up * __p.stddev() + __p.mean();
160}160}
161161
162template <class _CharT, class _Traits, class _RT>162template <class _CharT, class _Traits, class _RT>
163basic_ostream<_CharT, _Traits>&163_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
164operator<<(basic_ostream<_CharT, _Traits>& __os,164operator<<(basic_ostream<_CharT, _Traits>& __os,
165 const normal_distribution<_RT>& __x)165 const normal_distribution<_RT>& __x)
166{166{
...@@ -170,14 +170,14 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -170,14 +170,14 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
170 _OStream::scientific);170 _OStream::scientific);
171 _CharT __sp = __os.widen(' ');171 _CharT __sp = __os.widen(' ');
172 __os.fill(__sp);172 __os.fill(__sp);
173 __os << __x.mean() << __sp << __x.stddev() << __sp << __x._V_hot_;173 __os << __x.mean() << __sp << __x.stddev() << __sp << __x.__v_hot_;
174 if (__x._V_hot_)174 if (__x.__v_hot_)
175 __os << __sp << __x._V_;175 __os << __sp << __x.__v_;
176 return __os;176 return __os;
177}177}
178178
179template <class _CharT, class _Traits, class _RT>179template <class _CharT, class _Traits, class _RT>
180basic_istream<_CharT, _Traits>&180_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
181operator>>(basic_istream<_CharT, _Traits>& __is,181operator>>(basic_istream<_CharT, _Traits>& __is,
182 normal_distribution<_RT>& __x)182 normal_distribution<_RT>& __x)
183{183{
...@@ -197,8 +197,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -197,8 +197,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
197 if (!__is.fail())197 if (!__is.fail())
198 {198 {
199 __x.param(param_type(__mean, __stddev));199 __x.param(param_type(__mean, __stddev));
200 __x._V_hot_ = _V_hot;200 __x.__v_hot_ = _V_hot;
201 __x._V_ = _Vp;201 __x.__v_ = _Vp;
202 }202 }
203 return __is;203 return __is;
204}204}
lib/libcxx/include/__random/piecewise_constant_distribution.h+2-2
...@@ -294,7 +294,7 @@ piecewise_constant_distribution<_RealType>::operator()(_URNG& __g, const param_t...@@ -294,7 +294,7 @@ piecewise_constant_distribution<_RealType>::operator()(_URNG& __g, const param_t
294}294}
295295
296template <class _CharT, class _Traits, class _RT>296template <class _CharT, class _Traits, class _RT>
297basic_ostream<_CharT, _Traits>&297_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
298operator<<(basic_ostream<_CharT, _Traits>& __os,298operator<<(basic_ostream<_CharT, _Traits>& __os,
299 const piecewise_constant_distribution<_RT>& __x)299 const piecewise_constant_distribution<_RT>& __x)
300{300{
...@@ -320,7 +320,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -320,7 +320,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
320}320}
321321
322template <class _CharT, class _Traits, class _RT>322template <class _CharT, class _Traits, class _RT>
323basic_istream<_CharT, _Traits>&323_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
324operator>>(basic_istream<_CharT, _Traits>& __is,324operator>>(basic_istream<_CharT, _Traits>& __is,
325 piecewise_constant_distribution<_RT>& __x)325 piecewise_constant_distribution<_RT>& __x)
326{326{
lib/libcxx/include/__random/piecewise_linear_distribution.h+2-2
...@@ -310,7 +310,7 @@ piecewise_linear_distribution<_RealType>::operator()(_URNG& __g, const param_typ...@@ -310,7 +310,7 @@ piecewise_linear_distribution<_RealType>::operator()(_URNG& __g, const param_typ
310}310}
311311
312template <class _CharT, class _Traits, class _RT>312template <class _CharT, class _Traits, class _RT>
313basic_ostream<_CharT, _Traits>&313_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
314operator<<(basic_ostream<_CharT, _Traits>& __os,314operator<<(basic_ostream<_CharT, _Traits>& __os,
315 const piecewise_linear_distribution<_RT>& __x)315 const piecewise_linear_distribution<_RT>& __x)
316{316{
...@@ -336,7 +336,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -336,7 +336,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
336}336}
337337
338template <class _CharT, class _Traits, class _RT>338template <class _CharT, class _Traits, class _RT>
339basic_istream<_CharT, _Traits>&339_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
340operator>>(basic_istream<_CharT, _Traits>& __is,340operator>>(basic_istream<_CharT, _Traits>& __is,
341 piecewise_linear_distribution<_RT>& __x)341 piecewise_linear_distribution<_RT>& __x)
342{342{
lib/libcxx/include/__random/poisson_distribution.h+2-2
...@@ -245,7 +245,7 @@ poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr...@@ -245,7 +245,7 @@ poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr
245}245}
246246
247template <class _CharT, class _Traits, class _IntType>247template <class _CharT, class _Traits, class _IntType>
248basic_ostream<_CharT, _Traits>&248_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
249operator<<(basic_ostream<_CharT, _Traits>& __os,249operator<<(basic_ostream<_CharT, _Traits>& __os,
250 const poisson_distribution<_IntType>& __x)250 const poisson_distribution<_IntType>& __x)
251{251{
...@@ -257,7 +257,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -257,7 +257,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
257}257}
258258
259template <class _CharT, class _Traits, class _IntType>259template <class _CharT, class _Traits, class _IntType>
260basic_istream<_CharT, _Traits>&260_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
261operator>>(basic_istream<_CharT, _Traits>& __is,261operator>>(basic_istream<_CharT, _Traits>& __is,
262 poisson_distribution<_IntType>& __x)262 poisson_distribution<_IntType>& __x)
263{263{
lib/libcxx/include/__random/shuffle_order_engine.h+21-21
...@@ -60,8 +60,8 @@ public:...@@ -60,8 +60,8 @@ public:
6060
61private:61private:
62 _Engine __e_;62 _Engine __e_;
63 result_type _V_[__k];63 result_type __v_[__k];
64 result_type _Y_;64 result_type __y_;
6565
66public:66public:
67 // engine characteristics67 // engine characteristics
...@@ -157,8 +157,8 @@ private:...@@ -157,8 +157,8 @@ private:
157 void __init()157 void __init()
158 {158 {
159 for (size_t __i = 0; __i < __k; ++__i)159 for (size_t __i = 0; __i < __k; ++__i)
160 _V_[__i] = __e_();160 __v_[__i] = __e_();
161 _Y_ = __e_();161 __y_ = __e_();
162 }162 }
163163
164 _LIBCPP_INLINE_VISIBILITY164 _LIBCPP_INLINE_VISIBILITY
...@@ -190,11 +190,11 @@ private:...@@ -190,11 +190,11 @@ private:
190 >::type190 >::type
191 __eval(__uratio<_Np, _Dp>)191 __eval(__uratio<_Np, _Dp>)
192 {192 {
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)
194 / __uratio<_Np, _Dp>::den);194 / __uratio<_Np, _Dp>::den);
195 _Y_ = _V_[__j];195 __y_ = __v_[__j];
196 _V_[__j] = __e_();196 __v_[__j] = __e_();
197 return _Y_;197 return __y_;
198 }198 }
199199
200 template <uint64_t __n, uint64_t __d>200 template <uint64_t __n, uint64_t __d>
...@@ -204,10 +204,10 @@ private:...@@ -204,10 +204,10 @@ private:
204 const double _Fp = __d == 0 ?204 const double _Fp = __d == 0 ?
205 __n / (2. * 0x8000000000000000ull) :205 __n / (2. * 0x8000000000000000ull) :
206 __n / (double)__d;206 __n / (double)__d;
207 const size_t __j = static_cast<size_t>(_Fp * (_Y_ - _Min));207 const size_t __j = static_cast<size_t>(_Fp * (__y_ - _Min));
208 _Y_ = _V_[__j];208 __y_ = __v_[__j];
209 _V_[__j] = __e_();209 __v_[__j] = __e_();
210 return _Y_;210 return __y_;
211 }211 }
212};212};
213213
...@@ -215,12 +215,12 @@ template<class _Engine, size_t __k>...@@ -215,12 +215,12 @@ template<class _Engine, size_t __k>
215 _LIBCPP_CONSTEXPR const size_t shuffle_order_engine<_Engine, __k>::table_size;215 _LIBCPP_CONSTEXPR const size_t shuffle_order_engine<_Engine, __k>::table_size;
216216
217template<class _Eng, size_t _Kp>217template<class _Eng, size_t _Kp>
218bool218_LIBCPP_HIDE_FROM_ABI bool
219operator==(219operator==(
220 const shuffle_order_engine<_Eng, _Kp>& __x,220 const shuffle_order_engine<_Eng, _Kp>& __x,
221 const shuffle_order_engine<_Eng, _Kp>& __y)221 const shuffle_order_engine<_Eng, _Kp>& __y)
222{222{
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_) &&
224 __x.__e_ == __y.__e_;224 __x.__e_ == __y.__e_;
225}225}
226226
...@@ -236,7 +236,7 @@ operator!=(...@@ -236,7 +236,7 @@ operator!=(
236236
237template <class _CharT, class _Traits,237template <class _CharT, class _Traits,
238 class _Eng, size_t _Kp>238 class _Eng, size_t _Kp>
239basic_ostream<_CharT, _Traits>&239_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
240operator<<(basic_ostream<_CharT, _Traits>& __os,240operator<<(basic_ostream<_CharT, _Traits>& __os,
241 const shuffle_order_engine<_Eng, _Kp>& __x)241 const shuffle_order_engine<_Eng, _Kp>& __x)
242{242{
...@@ -245,15 +245,15 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -245,15 +245,15 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
245 __os.flags(_Ostream::dec | _Ostream::left);245 __os.flags(_Ostream::dec | _Ostream::left);
246 _CharT __sp = __os.widen(' ');246 _CharT __sp = __os.widen(' ');
247 __os.fill(__sp);247 __os.fill(__sp);
248 __os << __x.__e_ << __sp << __x._V_[0];248 __os << __x.__e_ << __sp << __x.__v_[0];
249 for (size_t __i = 1; __i < _Kp; ++__i)249 for (size_t __i = 1; __i < _Kp; ++__i)
250 __os << __sp << __x._V_[__i];250 __os << __sp << __x.__v_[__i];
251 return __os << __sp << __x._Y_;251 return __os << __sp << __x.__y_;
252}252}
253253
254template <class _CharT, class _Traits,254template <class _CharT, class _Traits,
255 class _Eng, size_t _Kp>255 class _Eng, size_t _Kp>
256basic_istream<_CharT, _Traits>&256_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
257operator>>(basic_istream<_CharT, _Traits>& __is,257operator>>(basic_istream<_CharT, _Traits>& __is,
258 shuffle_order_engine<_Eng, _Kp>& __x)258 shuffle_order_engine<_Eng, _Kp>& __x)
259{259{
...@@ -270,8 +270,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -270,8 +270,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
270 {270 {
271 __x.__e_ = __e;271 __x.__e_ = __e;
272 for (size_t __i = 0; __i < _Kp; ++__i)272 for (size_t __i = 0; __i < _Kp; ++__i)
273 __x._V_[__i] = _Vp[__i];273 __x.__v_[__i] = _Vp[__i];
274 __x._Y_ = _Vp[_Kp];274 __x.__y_ = _Vp[_Kp];
275 }275 }
276 return __is;276 return __is;
277}277}
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)...@@ -118,7 +118,7 @@ student_t_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
118}118}
119119
120template <class _CharT, class _Traits, class _RT>120template <class _CharT, class _Traits, class _RT>
121basic_ostream<_CharT, _Traits>&121_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
122operator<<(basic_ostream<_CharT, _Traits>& __os,122operator<<(basic_ostream<_CharT, _Traits>& __os,
123 const student_t_distribution<_RT>& __x)123 const student_t_distribution<_RT>& __x)
124{124{
...@@ -131,7 +131,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -131,7 +131,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
131}131}
132132
133template <class _CharT, class _Traits, class _RT>133template <class _CharT, class _Traits, class _RT>
134basic_istream<_CharT, _Traits>&134_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
135operator>>(basic_istream<_CharT, _Traits>& __is,135operator>>(basic_istream<_CharT, _Traits>& __is,
136 student_t_distribution<_RT>& __x)136 student_t_distribution<_RT>& __x)
137{137{
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>...@@ -33,7 +33,7 @@ template<class _UIntType, size_t __w, size_t __s, size_t __r>
33class _LIBCPP_TEMPLATE_VIS subtract_with_carry_engine;33class _LIBCPP_TEMPLATE_VIS subtract_with_carry_engine;
3434
35template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>35template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
36bool36_LIBCPP_HIDE_FROM_ABI bool
37operator==(37operator==(
38 const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x,38 const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x,
39 const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y);39 const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y);
...@@ -47,13 +47,13 @@ operator!=(...@@ -47,13 +47,13 @@ operator!=(
4747
48template <class _CharT, class _Traits,48template <class _CharT, class _Traits,
49 class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>49 class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
50basic_ostream<_CharT, _Traits>&50_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
51operator<<(basic_ostream<_CharT, _Traits>& __os,51operator<<(basic_ostream<_CharT, _Traits>& __os,
52 const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x);52 const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x);
5353
54template <class _CharT, class _Traits,54template <class _CharT, class _Traits,
55 class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>55 class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
56basic_istream<_CharT, _Traits>&56_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
57operator>>(basic_istream<_CharT, _Traits>& __is,57operator>>(basic_istream<_CharT, _Traits>& __is,
58 subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x);58 subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x);
5959
...@@ -251,7 +251,7 @@ subtract_with_carry_engine<_UIntType, __w, __s, __r>::operator()()...@@ -251,7 +251,7 @@ subtract_with_carry_engine<_UIntType, __w, __s, __r>::operator()()
251}251}
252252
253template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>253template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
254bool254_LIBCPP_HIDE_FROM_ABI bool
255operator==(255operator==(
256 const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x,256 const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x,
257 const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y)257 const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y)
...@@ -305,7 +305,7 @@ operator!=(...@@ -305,7 +305,7 @@ operator!=(
305305
306template <class _CharT, class _Traits,306template <class _CharT, class _Traits,
307 class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>307 class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
308basic_ostream<_CharT, _Traits>&308_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
309operator<<(basic_ostream<_CharT, _Traits>& __os,309operator<<(basic_ostream<_CharT, _Traits>& __os,
310 const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x)310 const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x)
311{311{
...@@ -325,7 +325,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -325,7 +325,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
325325
326template <class _CharT, class _Traits,326template <class _CharT, class _Traits,
327 class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>327 class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
328basic_istream<_CharT, _Traits>&328_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
329operator>>(basic_istream<_CharT, _Traits>& __is,329operator>>(basic_istream<_CharT, _Traits>& __is,
330 subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x)330 subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x)
331{331{
lib/libcxx/include/__random/uniform_int_distribution.h+11-12
...@@ -9,7 +9,6 @@...@@ -9,7 +9,6 @@
9#ifndef _LIBCPP___RANDOM_UNIFORM_INT_DISTRIBUTION_H9#ifndef _LIBCPP___RANDOM_UNIFORM_INT_DISTRIBUTION_H
10#define _LIBCPP___RANDOM_UNIFORM_INT_DISTRIBUTION_H10#define _LIBCPP___RANDOM_UNIFORM_INT_DISTRIBUTION_H
1111
12#include <__bits>
13#include <__config>12#include <__config>
14#include <__random/is_valid.h>13#include <__random/is_valid.h>
15#include <__random/log2.h>14#include <__random/log2.h>
...@@ -38,12 +37,8 @@ public:...@@ -38,12 +37,8 @@ public:
3837
39private:38private:
40 typedef typename _Engine::result_type _Engine_result_type;39 typedef typename _Engine::result_type _Engine_result_type;
41 typedef typename conditional40 typedef __conditional_t<sizeof(_Engine_result_type) <= sizeof(result_type), result_type, _Engine_result_type>
42 <41 _Working_result_type;
43 sizeof(_Engine_result_type) <= sizeof(result_type),
44 result_type,
45 _Engine_result_type
46 >::type _Working_result_type;
4742
48 _Engine& __e_;43 _Engine& __e_;
49 size_t __w_;44 size_t __w_;
...@@ -178,8 +173,10 @@ public:...@@ -178,8 +173,10 @@ public:
178 result_type a() const {return __a_;}173 result_type a() const {return __a_;}
179 result_type b() const {return __b_;}174 result_type b() const {return __b_;}
180175
176 _LIBCPP_HIDE_FROM_ABI
181 friend bool operator==(const param_type& __x, const param_type& __y)177 friend bool operator==(const param_type& __x, const param_type& __y)
182 {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;}178 {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;}
179 _LIBCPP_HIDE_FROM_ABI
183 friend bool operator!=(const param_type& __x, const param_type& __y)180 friend bool operator!=(const param_type& __x, const param_type& __y)
184 {return !(__x == __y);}181 {return !(__x == __y);}
185 };182 };
...@@ -218,9 +215,11 @@ public:...@@ -218,9 +215,11 @@ public:
218 result_type min() const {return a();}215 result_type min() const {return a();}
219 result_type max() const {return b();}216 result_type max() const {return b();}
220217
218 _LIBCPP_HIDE_FROM_ABI
221 friend bool operator==(const uniform_int_distribution& __x,219 friend bool operator==(const uniform_int_distribution& __x,
222 const uniform_int_distribution& __y)220 const uniform_int_distribution& __y)
223 {return __x.__p_ == __y.__p_;}221 {return __x.__p_ == __y.__p_;}
222 _LIBCPP_HIDE_FROM_ABI
224 friend bool operator!=(const uniform_int_distribution& __x,223 friend bool operator!=(const uniform_int_distribution& __x,
225 const uniform_int_distribution& __y)224 const uniform_int_distribution& __y)
226 {return !(__x == __y);}225 {return !(__x == __y);}
...@@ -233,8 +232,8 @@ uniform_int_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p...@@ -233,8 +232,8 @@ uniform_int_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p
233_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK232_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
234{233{
235 static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");234 static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
236 typedef typename conditional<sizeof(result_type) <= sizeof(uint32_t), uint32_t,235 typedef __conditional_t<sizeof(result_type) <= sizeof(uint32_t), uint32_t, __make_unsigned_t<result_type> >
237 typename make_unsigned<result_type>::type>::type _UIntType;236 _UIntType;
238 const _UIntType _Rp = _UIntType(__p.b()) - _UIntType(__p.a()) + _UIntType(1);237 const _UIntType _Rp = _UIntType(__p.b()) - _UIntType(__p.a()) + _UIntType(1);
239 if (_Rp == 1)238 if (_Rp == 1)
240 return __p.a();239 return __p.a();
...@@ -242,7 +241,7 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK...@@ -242,7 +241,7 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
242 typedef __independent_bits_engine<_URNG, _UIntType> _Eng;241 typedef __independent_bits_engine<_URNG, _UIntType> _Eng;
243 if (_Rp == 0)242 if (_Rp == 0)
244 return static_cast<result_type>(_Eng(__g, _Dt)());243 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;
246 if ((_Rp & (numeric_limits<_UIntType>::max() >> (_Dt - __w))) != 0)245 if ((_Rp & (numeric_limits<_UIntType>::max() >> (_Dt - __w))) != 0)
247 ++__w;246 ++__w;
248 _Eng __e(__g, __w);247 _Eng __e(__g, __w);
...@@ -255,7 +254,7 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK...@@ -255,7 +254,7 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
255}254}
256255
257template <class _CharT, class _Traits, class _IT>256template <class _CharT, class _Traits, class _IT>
258basic_ostream<_CharT, _Traits>&257_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
259operator<<(basic_ostream<_CharT, _Traits>& __os,258operator<<(basic_ostream<_CharT, _Traits>& __os,
260 const uniform_int_distribution<_IT>& __x)259 const uniform_int_distribution<_IT>& __x)
261{260{
...@@ -268,7 +267,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -268,7 +267,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
268}267}
269268
270template <class _CharT, class _Traits, class _IT>269template <class _CharT, class _Traits, class _IT>
271basic_istream<_CharT, _Traits>&270_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
272operator>>(basic_istream<_CharT, _Traits>& __is,271operator>>(basic_istream<_CharT, _Traits>& __is,
273 uniform_int_distribution<_IT>& __x)272 uniform_int_distribution<_IT>& __x)
274{273{
lib/libcxx/include/__random/uniform_real_distribution.h+2-2
...@@ -123,7 +123,7 @@ uniform_real_distribution<_RealType>::operator()(_URNG& __g, const param_type& _...@@ -123,7 +123,7 @@ uniform_real_distribution<_RealType>::operator()(_URNG& __g, const param_type& _
123}123}
124124
125template <class _CharT, class _Traits, class _RT>125template <class _CharT, class _Traits, class _RT>
126basic_ostream<_CharT, _Traits>&126_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
127operator<<(basic_ostream<_CharT, _Traits>& __os,127operator<<(basic_ostream<_CharT, _Traits>& __os,
128 const uniform_real_distribution<_RT>& __x)128 const uniform_real_distribution<_RT>& __x)
129{129{
...@@ -137,7 +137,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -137,7 +137,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
137}137}
138138
139template <class _CharT, class _Traits, class _RT>139template <class _CharT, class _Traits, class _RT>
140basic_istream<_CharT, _Traits>&140_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
141operator>>(basic_istream<_CharT, _Traits>& __is,141operator>>(basic_istream<_CharT, _Traits>& __is,
142 uniform_real_distribution<_RT>& __x)142 uniform_real_distribution<_RT>& __x)
143{143{
lib/libcxx/include/__random/weibull_distribution.h+2-2
...@@ -115,7 +115,7 @@ public:...@@ -115,7 +115,7 @@ public:
115};115};
116116
117template <class _CharT, class _Traits, class _RT>117template <class _CharT, class _Traits, class _RT>
118basic_ostream<_CharT, _Traits>&118_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
119operator<<(basic_ostream<_CharT, _Traits>& __os,119operator<<(basic_ostream<_CharT, _Traits>& __os,
120 const weibull_distribution<_RT>& __x)120 const weibull_distribution<_RT>& __x)
121{121{
...@@ -130,7 +130,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -130,7 +130,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
130}130}
131131
132template <class _CharT, class _Traits, class _RT>132template <class _CharT, class _Traits, class _RT>
133basic_istream<_CharT, _Traits>&133_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
134operator>>(basic_istream<_CharT, _Traits>& __is,134operator>>(basic_istream<_CharT, _Traits>& __is,
135 weibull_distribution<_RT>& __x)135 weibull_distribution<_RT>& __x)
136{136{
lib/libcxx/include/__ranges/access.h+8-2
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_ACCESS_H10#ifndef _LIBCPP___RANGES_ACCESS_H
10#define _LIBCPP___RANGES_ACCESS_H11#define _LIBCPP___RANGES_ACCESS_H
1112
...@@ -14,8 +15,13 @@...@@ -14,8 +15,13 @@
14#include <__iterator/concepts.h>15#include <__iterator/concepts.h>
15#include <__iterator/readable_traits.h>16#include <__iterator/readable_traits.h>
16#include <__ranges/enable_borrowed_range.h>17#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>
17#include <__utility/auto_cast.h>22#include <__utility/auto_cast.h>
18#include <type_traits>23#include <__utility/declval.h>
24#include <cstddef>
1925
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header27# pragma GCC system_header
...@@ -99,7 +105,7 @@ inline namespace __cpo {...@@ -99,7 +105,7 @@ inline namespace __cpo {
99105
100namespace ranges {106namespace ranges {
101 template <class _Tp>107 template <class _Tp>
102 using iterator_t = decltype(ranges::begin(declval<_Tp&>()));108 using iterator_t = decltype(ranges::begin(std::declval<_Tp&>()));
103} // namespace ranges109} // namespace ranges
104110
105// [range.access.end]111// [range.access.end]
lib/libcxx/include/__ranges/all.h+4-3
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_ALL_H10#ifndef _LIBCPP___RANGES_ALL_H
10#define _LIBCPP___RANGES_ALL_H11#define _LIBCPP___RANGES_ALL_H
1112
...@@ -28,7 +29,7 @@...@@ -28,7 +29,7 @@
2829
29_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
3031
31#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)32#if _LIBCPP_STD_VER > 17
3233
33namespace ranges::views {34namespace ranges::views {
3435
...@@ -72,11 +73,11 @@ inline namespace __cpo {...@@ -72,11 +73,11 @@ inline namespace __cpo {
72} // namespace __cpo73} // namespace __cpo
7374
74template<ranges::viewable_range _Range>75template<ranges::viewable_range _Range>
75using all_t = decltype(views::all(declval<_Range>()));76using all_t = decltype(views::all(std::declval<_Range>()));
7677
77} // namespace ranges::views78} // namespace ranges::views
7879
79#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)80#endif // _LIBCPP_STD_VER > 17
8081
81_LIBCPP_END_NAMESPACE_STD82_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 @@...@@ -6,9 +6,12 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_COMMON_VIEW_H10#ifndef _LIBCPP___RANGES_COMMON_VIEW_H
10#define _LIBCPP___RANGES_COMMON_VIEW_H11#define _LIBCPP___RANGES_COMMON_VIEW_H
1112
13#include <__concepts/constructible.h>
14#include <__concepts/copyable.h>
12#include <__config>15#include <__config>
13#include <__iterator/common_iterator.h>16#include <__iterator/common_iterator.h>
14#include <__iterator/iterator_traits.h>17#include <__iterator/iterator_traits.h>
...@@ -21,7 +24,6 @@...@@ -21,7 +24,6 @@
21#include <__ranges/view_interface.h>24#include <__ranges/view_interface.h>
22#include <__utility/forward.h>25#include <__utility/forward.h>
23#include <__utility/move.h>26#include <__utility/move.h>
24#include <concepts>
25#include <type_traits>27#include <type_traits>
2628
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -30,7 +32,7 @@...@@ -30,7 +32,7 @@
3032
31_LIBCPP_BEGIN_NAMESPACE_STD33_LIBCPP_BEGIN_NAMESPACE_STD
3234
33#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)35#if _LIBCPP_STD_VER > 17
3436
35namespace ranges {37namespace ranges {
3638
...@@ -128,7 +130,7 @@ inline namespace __cpo {...@@ -128,7 +130,7 @@ inline namespace __cpo {
128} // namespace views130} // namespace views
129} // namespace ranges131} // namespace ranges
130132
131#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)133#endif // _LIBCPP_STD_VER > 17
132134
133_LIBCPP_END_NAMESPACE_STD135_LIBCPP_END_NAMESPACE_STD
134136
lib/libcxx/include/__ranges/concepts.h+8-3
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_CONCEPTS_H10#ifndef _LIBCPP___RANGES_CONCEPTS_H
10#define _LIBCPP___RANGES_CONCEPTS_H11#define _LIBCPP___RANGES_CONCEPTS_H
1112
...@@ -23,8 +24,12 @@...@@ -23,8 +24,12 @@
23#include <__ranges/enable_borrowed_range.h>24#include <__ranges/enable_borrowed_range.h>
24#include <__ranges/enable_view.h>25#include <__ranges/enable_view.h>
25#include <__ranges/size.h>26#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>
26#include <initializer_list>32#include <initializer_list>
27#include <type_traits>
2833
29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)34#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
30# pragma GCC system_header35# pragma GCC system_header
...@@ -54,7 +59,7 @@ namespace ranges {...@@ -54,7 +59,7 @@ namespace ranges {
54 // `iterator_t` defined in <__ranges/access.h>59 // `iterator_t` defined in <__ranges/access.h>
5560
56 template <range _Rp>61 template <range _Rp>
57 using sentinel_t = decltype(ranges::end(declval<_Rp&>()));62 using sentinel_t = decltype(ranges::end(std::declval<_Rp&>()));
5863
59 template <range _Rp>64 template <range _Rp>
60 using range_difference_t = iter_difference_t<iterator_t<_Rp>>;65 using range_difference_t = iter_difference_t<iterator_t<_Rp>>;
...@@ -73,7 +78,7 @@ namespace ranges {...@@ -73,7 +78,7 @@ namespace ranges {
73 concept sized_range = range<_Tp> && requires(_Tp& __t) { ranges::size(__t); };78 concept sized_range = range<_Tp> && requires(_Tp& __t) { ranges::size(__t); };
7479
75 template<sized_range _Rp>80 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
78 // `disable_sized_range` defined in `<__ranges/size.h>`83 // `disable_sized_range` defined in `<__ranges/size.h>`
7984
lib/libcxx/include/__ranges/copyable_box.h+5-3
...@@ -10,11 +10,13 @@...@@ -10,11 +10,13 @@
10#ifndef _LIBCPP___RANGES_COPYABLE_BOX_H10#ifndef _LIBCPP___RANGES_COPYABLE_BOX_H
11#define _LIBCPP___RANGES_COPYABLE_BOX_H11#define _LIBCPP___RANGES_COPYABLE_BOX_H
1212
13#include <__concepts/constructible.h>
14#include <__concepts/copyable.h>
15#include <__concepts/movable.h>
13#include <__config>16#include <__config>
14#include <__memory/addressof.h>17#include <__memory/addressof.h>
15#include <__memory/construct_at.h>18#include <__memory/construct_at.h>
16#include <__utility/move.h>19#include <__utility/move.h>
17#include <concepts>
18#include <optional>20#include <optional>
19#include <type_traits>21#include <type_traits>
2022
...@@ -24,7 +26,7 @@...@@ -24,7 +26,7 @@
2426
25_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2628
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)29#if _LIBCPP_STD_VER > 17
2830
29// __copyable_box allows turning a type that is copy-constructible (but maybe not copy-assignable) into31// __copyable_box allows turning a type that is copy-constructible (but maybe not copy-assignable) into
30// a type that is both copy-constructible and copy-assignable. It does that by introducing an empty state32// a type that is both copy-constructible and copy-assignable. It does that by introducing an empty state
...@@ -171,7 +173,7 @@ namespace ranges {...@@ -171,7 +173,7 @@ namespace ranges {
171 };173 };
172} // namespace ranges174} // namespace ranges
173175
174#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)176#endif // _LIBCPP_STD_VER > 17
175177
176_LIBCPP_END_NAMESPACE_STD178_LIBCPP_END_NAMESPACE_STD
177179
lib/libcxx/include/__ranges/counted.h+3-2
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_COUNTED_H10#ifndef _LIBCPP___RANGES_COUNTED_H
10#define _LIBCPP___RANGES_COUNTED_H11#define _LIBCPP___RANGES_COUNTED_H
1112
...@@ -29,7 +30,7 @@...@@ -29,7 +30,7 @@
2930
30_LIBCPP_BEGIN_NAMESPACE_STD31_LIBCPP_BEGIN_NAMESPACE_STD
3132
32#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)33#if _LIBCPP_STD_VER > 17
3334
34namespace ranges::views {35namespace ranges::views {
3536
...@@ -74,7 +75,7 @@ inline namespace __cpo {...@@ -74,7 +75,7 @@ inline namespace __cpo {
7475
75} // namespace ranges::views76} // namespace ranges::views
7677
77#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)78#endif // _LIBCPP_STD_VER > 17
7879
79_LIBCPP_END_NAMESPACE_STD80_LIBCPP_END_NAMESPACE_STD
8081
lib/libcxx/include/__ranges/dangling.h+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <__config>13#include <__config>
14#include <__ranges/access.h>14#include <__ranges/access.h>
15#include <__ranges/concepts.h>15#include <__ranges/concepts.h>
16#include <type_traits>16#include <__type_traits/conditional.h>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header19# pragma GCC system_header
lib/libcxx/include/__ranges/data.h+7-1
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_DATA_H10#ifndef _LIBCPP___RANGES_DATA_H
10#define _LIBCPP___RANGES_DATA_H11#define _LIBCPP___RANGES_DATA_H
1112
...@@ -15,8 +16,13 @@...@@ -15,8 +16,13 @@
15#include <__iterator/iterator_traits.h>16#include <__iterator/iterator_traits.h>
16#include <__memory/pointer_traits.h>17#include <__memory/pointer_traits.h>
17#include <__ranges/access.h>18#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>
18#include <__utility/auto_cast.h>25#include <__utility/auto_cast.h>
19#include <type_traits>
2026
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header28# pragma GCC system_header
lib/libcxx/include/__ranges/drop_view.h+5-3
...@@ -6,11 +6,14 @@...@@ -6,11 +6,14 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_DROP_VIEW_H10#ifndef _LIBCPP___RANGES_DROP_VIEW_H
10#define _LIBCPP___RANGES_DROP_VIEW_H11#define _LIBCPP___RANGES_DROP_VIEW_H
1112
12#include <__algorithm/min.h>13#include <__algorithm/min.h>
13#include <__assert>14#include <__assert>
15#include <__concepts/constructible.h>
16#include <__concepts/convertible_to.h>
14#include <__config>17#include <__config>
15#include <__functional/bind_back.h>18#include <__functional/bind_back.h>
16#include <__fwd/span.h>19#include <__fwd/span.h>
...@@ -33,7 +36,6 @@...@@ -33,7 +36,6 @@
33#include <__utility/auto_cast.h>36#include <__utility/auto_cast.h>
34#include <__utility/forward.h>37#include <__utility/forward.h>
35#include <__utility/move.h>38#include <__utility/move.h>
36#include <concepts>
37#include <type_traits>39#include <type_traits>
3840
39#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)41#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -45,7 +47,7 @@ _LIBCPP_PUSH_MACROS...@@ -45,7 +47,7 @@ _LIBCPP_PUSH_MACROS
4547
46_LIBCPP_BEGIN_NAMESPACE_STD48_LIBCPP_BEGIN_NAMESPACE_STD
4749
48#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)50#if _LIBCPP_STD_VER > 17
4951
50namespace ranges {52namespace ranges {
51 template<view _View>53 template<view _View>
...@@ -297,7 +299,7 @@ inline namespace __cpo {...@@ -297,7 +299,7 @@ inline namespace __cpo {
297299
298} // namespace ranges300} // namespace ranges
299301
300#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)302#endif // _LIBCPP_STD_VER > 17
301303
302_LIBCPP_END_NAMESPACE_STD304_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 @@...@@ -6,6 +6,7 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_EMPTY_H10#ifndef _LIBCPP___RANGES_EMPTY_H
10#define _LIBCPP___RANGES_EMPTY_H11#define _LIBCPP___RANGES_EMPTY_H
1112
...@@ -14,7 +15,6 @@...@@ -14,7 +15,6 @@
14#include <__iterator/concepts.h>15#include <__iterator/concepts.h>
15#include <__ranges/access.h>16#include <__ranges/access.h>
16#include <__ranges/size.h>17#include <__ranges/size.h>
17#include <type_traits>
1818
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header20# pragma GCC system_header
...@@ -22,7 +22,7 @@...@@ -22,7 +22,7 @@
2222
23_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2424
25#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)25#if _LIBCPP_STD_VER > 17
2626
27// [range.prim.empty]27// [range.prim.empty]
2828
...@@ -75,7 +75,7 @@ inline namespace __cpo {...@@ -75,7 +75,7 @@ inline namespace __cpo {
75} // namespace __cpo75} // namespace __cpo
76} // namespace ranges76} // namespace ranges
7777
78#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)78#endif // _LIBCPP_STD_VER > 17
7979
80_LIBCPP_END_NAMESPACE_STD80_LIBCPP_END_NAMESPACE_STD
8181
lib/libcxx/include/__ranges/empty_view.h+3-2
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_EMPTY_VIEW_H10#ifndef _LIBCPP___RANGES_EMPTY_VIEW_H
10#define _LIBCPP___RANGES_EMPTY_VIEW_H11#define _LIBCPP___RANGES_EMPTY_VIEW_H
1112
...@@ -20,7 +21,7 @@...@@ -20,7 +21,7 @@
2021
21_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2223
23#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)24#if _LIBCPP_STD_VER > 17
2425
25namespace ranges {26namespace ranges {
26 template<class _Tp>27 template<class _Tp>
...@@ -45,7 +46,7 @@ namespace ranges {...@@ -45,7 +46,7 @@ namespace ranges {
45 } // namespace views46 } // namespace views
46} // namespace ranges47} // namespace ranges
4748
48#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)49#endif // _LIBCPP_STD_VER > 17
4950
50_LIBCPP_END_NAMESPACE_STD51_LIBCPP_END_NAMESPACE_STD
5152
lib/libcxx/include/__ranges/enable_view.h+5-2
...@@ -10,9 +10,12 @@...@@ -10,9 +10,12 @@
10#ifndef _LIBCPP___RANGES_ENABLE_VIEW_H10#ifndef _LIBCPP___RANGES_ENABLE_VIEW_H
11#define _LIBCPP___RANGES_ENABLE_VIEW_H11#define _LIBCPP___RANGES_ENABLE_VIEW_H
1212
13#include <__concepts/derived_from.h>
14#include <__concepts/same_as.h>
13#include <__config>15#include <__config>
14#include <concepts>16#include <__type_traits/is_class.h>
15#include <type_traits>17#include <__type_traits/is_convertible.h>
18#include <__type_traits/remove_cv.h>
1619
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header21# pragma GCC system_header
lib/libcxx/include/__ranges/filter_view.h+42-21
...@@ -6,10 +6,15 @@...@@ -6,10 +6,15 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_FILTER_VIEW_H10#ifndef _LIBCPP___RANGES_FILTER_VIEW_H
10#define _LIBCPP___RANGES_FILTER_VIEW_H11#define _LIBCPP___RANGES_FILTER_VIEW_H
1112
12#include <__algorithm/ranges_find_if.h>13#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>
13#include <__config>18#include <__config>
14#include <__debug>19#include <__debug>
15#include <__functional/bind_back.h>20#include <__functional/bind_back.h>
...@@ -30,7 +35,6 @@...@@ -30,7 +35,6 @@
30#include <__utility/forward.h>35#include <__utility/forward.h>
31#include <__utility/in_place.h>36#include <__utility/in_place.h>
32#include <__utility/move.h>37#include <__utility/move.h>
33#include <concepts>
34#include <type_traits>38#include <type_traits>
3539
36#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)40#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -39,9 +43,18 @@...@@ -39,9 +43,18 @@
3943
40_LIBCPP_BEGIN_NAMESPACE_STD44_LIBCPP_BEGIN_NAMESPACE_STD
4145
42#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)46#if _LIBCPP_STD_VER > 17
4347
44namespace ranges {48namespace 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
45 template<input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred>58 template<input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred>
46 requires view<_View> && is_object_v<_Pred>59 requires view<_View> && is_object_v<_Pred>
47 class filter_view : public view_interface<filter_view<_View, _Pred>> {60 class filter_view : public view_interface<filter_view<_View, _Pred>> {
...@@ -54,8 +67,11 @@ namespace ranges {...@@ -54,8 +67,11 @@ namespace ranges {
54 using _Cache = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;67 using _Cache = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;
55 _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache();68 _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache();
5669
57 class __iterator;70 using __iterator = __filter_view_iterator<_View, _Pred>;
58 class __sentinel;71 using __sentinel = __filter_view_sentinel<_View, _Pred>;
72
73 friend __iterator;
74 friend __sentinel;
5975
60 public:76 public:
61 _LIBCPP_HIDE_FROM_ABI77 _LIBCPP_HIDE_FROM_ABI
...@@ -115,10 +131,13 @@ namespace ranges {...@@ -115,10 +131,13 @@ namespace ranges {
115131
116 template<input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred>132 template<input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred>
117 requires view<_View> && is_object_v<_Pred>133 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
119 public:138 public:
120 _LIBCPP_NO_UNIQUE_ADDRESS iterator_t<_View> __current_ = iterator_t<_View>();139 _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
123 using iterator_concept =142 using iterator_concept =
124 _If<bidirectional_range<_View>, bidirectional_iterator_tag,143 _If<bidirectional_range<_View>, bidirectional_iterator_tag,
...@@ -130,10 +149,10 @@ namespace ranges {...@@ -130,10 +149,10 @@ namespace ranges {
130 using difference_type = range_difference_t<_View>;149 using difference_type = range_difference_t<_View>;
131150
132 _LIBCPP_HIDE_FROM_ABI151 _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
135 _LIBCPP_HIDE_FROM_ABI154 _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)
137 : __current_(std::move(__current)), __parent_(std::addressof(__parent))156 : __current_(std::move(__current)), __parent_(std::addressof(__parent))
138 { }157 { }
139158
...@@ -152,7 +171,7 @@ namespace ranges {...@@ -152,7 +171,7 @@ namespace ranges {
152 }171 }
153172
154 _LIBCPP_HIDE_FROM_ABI173 _LIBCPP_HIDE_FROM_ABI
155 constexpr __iterator& operator++() {174 constexpr __filter_view_iterator& operator++() {
156 __current_ = ranges::find_if(std::move(++__current_), ranges::end(__parent_->__base_),175 __current_ = ranges::find_if(std::move(++__current_), ranges::end(__parent_->__base_),
157 std::ref(*__parent_->__pred_));176 std::ref(*__parent_->__pred_));
158 return *this;177 return *this;
...@@ -160,42 +179,42 @@ namespace ranges {...@@ -160,42 +179,42 @@ namespace ranges {
160 _LIBCPP_HIDE_FROM_ABI179 _LIBCPP_HIDE_FROM_ABI
161 constexpr void operator++(int) { ++*this; }180 constexpr void operator++(int) { ++*this; }
162 _LIBCPP_HIDE_FROM_ABI181 _LIBCPP_HIDE_FROM_ABI
163 constexpr __iterator operator++(int) requires forward_range<_View> {182 constexpr __filter_view_iterator operator++(int) requires forward_range<_View> {
164 auto __tmp = *this;183 auto __tmp = *this;
165 ++*this;184 ++*this;
166 return __tmp;185 return __tmp;
167 }186 }
168187
169 _LIBCPP_HIDE_FROM_ABI188 _LIBCPP_HIDE_FROM_ABI
170 constexpr __iterator& operator--() requires bidirectional_range<_View> {189 constexpr __filter_view_iterator& operator--() requires bidirectional_range<_View> {
171 do {190 do {
172 --__current_;191 --__current_;
173 } while (!std::invoke(*__parent_->__pred_, *__current_));192 } while (!std::invoke(*__parent_->__pred_, *__current_));
174 return *this;193 return *this;
175 }194 }
176 _LIBCPP_HIDE_FROM_ABI195 _LIBCPP_HIDE_FROM_ABI
177 constexpr __iterator operator--(int) requires bidirectional_range<_View> {196 constexpr __filter_view_iterator operator--(int) requires bidirectional_range<_View> {
178 auto tmp = *this;197 auto tmp = *this;
179 --*this;198 --*this;
180 return tmp;199 return tmp;
181 }200 }
182201
183 _LIBCPP_HIDE_FROM_ABI202 _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)
185 requires equality_comparable<iterator_t<_View>>204 requires equality_comparable<iterator_t<_View>>
186 {205 {
187 return __x.__current_ == __y.__current_;206 return __x.__current_ == __y.__current_;
188 }207 }
189208
190 _LIBCPP_HIDE_FROM_ABI209 _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)
192 noexcept(noexcept(ranges::iter_move(__it.__current_)))211 noexcept(noexcept(ranges::iter_move(__it.__current_)))
193 {212 {
194 return ranges::iter_move(__it.__current_);213 return ranges::iter_move(__it.__current_);
195 }214 }
196215
197 _LIBCPP_HIDE_FROM_ABI216 _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)
199 noexcept(noexcept(ranges::iter_swap(__x.__current_, __y.__current_)))218 noexcept(noexcept(ranges::iter_swap(__x.__current_, __y.__current_)))
200 requires indirectly_swappable<iterator_t<_View>>219 requires indirectly_swappable<iterator_t<_View>>
201 {220 {
...@@ -205,23 +224,25 @@ namespace ranges {...@@ -205,23 +224,25 @@ namespace ranges {
205224
206 template<input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred>225 template<input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred>
207 requires view<_View> && is_object_v<_Pred>226 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
209 public:230 public:
210 sentinel_t<_View> __end_ = sentinel_t<_View>();231 sentinel_t<_View> __end_ = sentinel_t<_View>();
211232
212 _LIBCPP_HIDE_FROM_ABI233 _LIBCPP_HIDE_FROM_ABI
213 __sentinel() = default;234 __filter_view_sentinel() = default;
214235
215 _LIBCPP_HIDE_FROM_ABI236 _LIBCPP_HIDE_FROM_ABI
216 constexpr explicit __sentinel(filter_view& __parent)237 constexpr explicit __filter_view_sentinel(__filter_view& __parent)
217 : __end_(ranges::end(__parent.__base_))238 : __end_(ranges::end(__parent.__base_))
218 { }239 { }
219240
220 _LIBCPP_HIDE_FROM_ABI241 _LIBCPP_HIDE_FROM_ABI
221 constexpr sentinel_t<_View> base() const { return __end_; }242 constexpr sentinel_t<_View> base() const { return __end_; }
222243
223 _LIBCPP_HIDE_FROM_ABI244 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
224 friend constexpr bool operator==(__iterator const& __x, __sentinel const& __y) {245 operator==(__filter_view_iterator<_View, _Pred> const& __x, __filter_view_sentinel const& __y) {
225 return __x.__current_ == __y.__end_;246 return __x.__current_ == __y.__end_;
226 }247 }
227 };248 };
...@@ -252,7 +273,7 @@ inline namespace __cpo {...@@ -252,7 +273,7 @@ inline namespace __cpo {
252273
253} // namespace ranges274} // namespace ranges
254275
255#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)276#endif // _LIBCPP_STD_VER > 17
256277
257_LIBCPP_END_NAMESPACE_STD278_LIBCPP_END_NAMESPACE_STD
258279
lib/libcxx/include/__ranges/iota_view.h+231-205
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_IOTA_VIEW_H10#ifndef _LIBCPP___RANGES_IOTA_VIEW_H
10#define _LIBCPP___RANGES_IOTA_VIEW_H11#define _LIBCPP___RANGES_IOTA_VIEW_H
1112
...@@ -39,7 +40,7 @@...@@ -39,7 +40,7 @@
3940
40_LIBCPP_BEGIN_NAMESPACE_STD41_LIBCPP_BEGIN_NAMESPACE_STD
4142
42#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)43#if _LIBCPP_STD_VER > 17
4344
44namespace ranges {45namespace ranges {
45 template<class _Int>46 template<class _Int>
...@@ -82,6 +83,14 @@ namespace ranges {...@@ -82,6 +83,14 @@ namespace ranges {
82 { __j - __j } -> convertible_to<_IotaDiffT<_Iter>>;83 { __j - __j } -> convertible_to<_IotaDiffT<_Iter>>;
83 };84 };
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
85 template<class>94 template<class>
86 struct __iota_iterator_category {};95 struct __iota_iterator_category {};
8796
...@@ -93,210 +102,9 @@ namespace ranges {...@@ -93,210 +102,9 @@ namespace ranges {
93 template <weakly_incrementable _Start, semiregular _BoundSentinel = unreachable_sentinel_t>102 template <weakly_incrementable _Start, semiregular _BoundSentinel = unreachable_sentinel_t>
94 requires __weakly_equality_comparable_with<_Start, _BoundSentinel> && copyable<_Start>103 requires __weakly_equality_comparable_with<_Start, _BoundSentinel> && copyable<_Start>
95 class iota_view : public view_interface<iota_view<_Start, _BoundSentinel>> {104 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_ABI106 using __iterator = __iota_view_iterator<_Start>;
231 friend constexpr __iterator operator+(__iterator __i, difference_type __n)107 using __sentinel = __iota_view_sentinel<_Start, _BoundSentinel>;
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 };
300108
301 _Start __value_ = _Start();109 _Start __value_ = _Start();
302 _BoundSentinel __bound_sentinel_ = _BoundSentinel();110 _BoundSentinel __bound_sentinel_ = _BoundSentinel();
...@@ -377,6 +185,224 @@ namespace ranges {...@@ -377,6 +185,224 @@ namespace ranges {
377 template <class _Start, class _BoundSentinel>185 template <class _Start, class _BoundSentinel>
378 inline constexpr bool enable_borrowed_range<iota_view<_Start, _BoundSentinel>> = true;186 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
380 namespace views {406 namespace views {
381 namespace __iota {407 namespace __iota {
382 struct __fn {408 struct __fn {
...@@ -401,7 +427,7 @@ inline namespace __cpo {...@@ -401,7 +427,7 @@ inline namespace __cpo {
401} // namespace views427} // namespace views
402} // namespace ranges428} // namespace ranges
403429
404#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)430#endif // _LIBCPP_STD_VER > 17
405431
406_LIBCPP_END_NAMESPACE_STD432_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 @@...@@ -6,6 +6,7 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_JOIN_VIEW_H10#ifndef _LIBCPP___RANGES_JOIN_VIEW_H
10#define _LIBCPP___RANGES_JOIN_VIEW_H11#define _LIBCPP___RANGES_JOIN_VIEW_H
1112
...@@ -19,12 +20,16 @@...@@ -19,12 +20,16 @@
19#include <__iterator/iter_move.h>20#include <__iterator/iter_move.h>
20#include <__iterator/iter_swap.h>21#include <__iterator/iter_swap.h>
21#include <__iterator/iterator_traits.h>22#include <__iterator/iterator_traits.h>
23#include <__iterator/iterator_with_data.h>
24#include <__iterator/segmented_iterator.h>
22#include <__ranges/access.h>25#include <__ranges/access.h>
23#include <__ranges/all.h>26#include <__ranges/all.h>
24#include <__ranges/concepts.h>27#include <__ranges/concepts.h>
28#include <__ranges/empty.h>
25#include <__ranges/non_propagating_cache.h>29#include <__ranges/non_propagating_cache.h>
26#include <__ranges/range_adaptor.h>30#include <__ranges/range_adaptor.h>
27#include <__ranges/view_interface.h>31#include <__ranges/view_interface.h>
32#include <__type_traits/maybe_const.h>
28#include <__utility/forward.h>33#include <__utility/forward.h>
29#include <optional>34#include <optional>
30#include <type_traits>35#include <type_traits>
...@@ -35,7 +40,7 @@...@@ -35,7 +40,7 @@
3540
36_LIBCPP_BEGIN_NAMESPACE_STD41_LIBCPP_BEGIN_NAMESPACE_STD
3742
38#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)43#if _LIBCPP_STD_VER > 17
3944
40namespace ranges {45namespace ranges {
41 template<class>46 template<class>
...@@ -61,6 +66,14 @@ namespace ranges {...@@ -61,6 +66,14 @@ namespace ranges {
61 >;66 >;
62 };67 };
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
64 template<input_range _View>77 template<input_range _View>
65 requires view<_View> && input_range<range_reference_t<_View>>78 requires view<_View> && input_range<range_reference_t<_View>>
66 class join_view79 class join_view
...@@ -68,8 +81,22 @@ namespace ranges {...@@ -68,8 +81,22 @@ namespace ranges {
68 private:81 private:
69 using _InnerRange = range_reference_t<_View>;82 using _InnerRange = range_reference_t<_View>;
7083
71 template<bool> struct __iterator;84 template<bool _Const>
72 template<bool> struct __sentinel;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
74 static constexpr bool _UseCache = !is_reference_v<_InnerRange>;101 static constexpr bool _UseCache = !is_reference_v<_InnerRange>;
75 using _Cache = _If<_UseCache, __non_propagating_cache<remove_cvref_t<_InnerRange>>, __empty_cache>;102 using _Cache = _If<_UseCache, __non_propagating_cache<remove_cvref_t<_InnerRange>>, __empty_cache>;
...@@ -137,49 +164,57 @@ namespace ranges {...@@ -137,49 +164,57 @@ namespace ranges {
137 }164 }
138 };165 };
139166
140 template<input_range _View>167 template<input_range _View, bool _Const>
141 requires view<_View> && input_range<range_reference_t<_View>>168 requires view<_View> && input_range<range_reference_t<_View>>
142 template<bool _Const> struct join_view<_View>::__sentinel {169 struct __join_view_sentinel {
143 template<bool> friend struct __sentinel;170 template<input_range _View2, bool>
171 requires view<_View2> && input_range<range_reference_t<_View2>>
172 friend struct __join_view_sentinel;
144173
145 private:174 private:
146 using _Parent = __maybe_const<_Const, join_view>;175 using _Parent = __maybe_const<_Const, join_view<_View>>;
147 using _Base = __maybe_const<_Const, _View>;176 using _Base = __maybe_const<_Const, _View>;
148 sentinel_t<_Base> __end_ = sentinel_t<_Base>();177 sentinel_t<_Base> __end_ = sentinel_t<_Base>();
149178
150 public:179 public:
151 _LIBCPP_HIDE_FROM_ABI180 _LIBCPP_HIDE_FROM_ABI
152 __sentinel() = default;181 __join_view_sentinel() = default;
153182
154 _LIBCPP_HIDE_FROM_ABI183 _LIBCPP_HIDE_FROM_ABI
155 constexpr explicit __sentinel(_Parent& __parent)184 constexpr explicit __join_view_sentinel(_Parent& __parent)
156 : __end_(ranges::end(__parent.__base_)) {}185 : __end_(ranges::end(__parent.__base_)) {}
157186
158 _LIBCPP_HIDE_FROM_ABI187 _LIBCPP_HIDE_FROM_ABI
159 constexpr __sentinel(__sentinel<!_Const> __s)188 constexpr __join_view_sentinel(__join_view_sentinel<_View, !_Const> __s)
160 requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>189 requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
161 : __end_(std::move(__s.__end_)) {}190 : __end_(std::move(__s.__end_)) {}
162191
163 template<bool _OtherConst>192 template<bool _OtherConst>
164 requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>193 requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
165 _LIBCPP_HIDE_FROM_ABI194 _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) {
167 return __x.__outer_ == __y.__end_;196 return __x.__outer_ == __y.__end_;
168 }197 }
169 };198 };
170199
171 template<input_range _View>200 template<input_range _View, bool _Const>
172 requires view<_View> && input_range<range_reference_t<_View>>201 requires view<_View> && input_range<range_reference_t<_View>>
173 template<bool _Const> struct join_view<_View>::__iterator202 struct __join_view_iterator
174 : public __join_view_iterator_category<__maybe_const<_Const, _View>> {203 : 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
178 private:212 private:
179 using _Parent = __maybe_const<_Const, join_view>;213 using _Parent = __maybe_const<_Const, join_view<_View>>;
180 using _Base = __maybe_const<_Const, _View>;214 using _Base = __maybe_const<_Const, _View>;
181 using _Outer = iterator_t<_Base>;215 using _Outer = iterator_t<_Base>;
182 using _Inner = iterator_t<range_reference_t<_Base>>;216 using _Inner = iterator_t<range_reference_t<_Base>>;
217 using _InnerRange = range_reference_t<_View>;
183218
184 static constexpr bool __ref_is_glvalue = is_reference_v<range_reference_t<_Base>>;219 static constexpr bool __ref_is_glvalue = is_reference_v<range_reference_t<_Base>>;
185220
...@@ -208,9 +243,12 @@ namespace ranges {...@@ -208,9 +243,12 @@ namespace ranges {
208 __inner_.reset();243 __inner_.reset();
209 }244 }
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
211 public:249 public:
212 using iterator_concept = _If<250 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>> &&
214 common_range<range_reference_t<_Base>>,252 common_range<range_reference_t<_Base>>,
215 bidirectional_iterator_tag,253 bidirectional_iterator_tag,
216 _If<254 _If<
...@@ -226,17 +264,17 @@ namespace ranges {...@@ -226,17 +264,17 @@ namespace ranges {
226 range_difference_t<_Base>, range_difference_t<range_reference_t<_Base>>>;264 range_difference_t<_Base>, range_difference_t<range_reference_t<_Base>>>;
227265
228 _LIBCPP_HIDE_FROM_ABI266 _LIBCPP_HIDE_FROM_ABI
229 __iterator() requires default_initializable<_Outer> = default;267 __join_view_iterator() requires default_initializable<_Outer> = default;
230268
231 _LIBCPP_HIDE_FROM_ABI269 _LIBCPP_HIDE_FROM_ABI
232 constexpr __iterator(_Parent& __parent, _Outer __outer)270 constexpr __join_view_iterator(_Parent& __parent, _Outer __outer)
233 : __outer_(std::move(__outer))271 : __outer_(std::move(__outer))
234 , __parent_(std::addressof(__parent)) {272 , __parent_(std::addressof(__parent)) {
235 __satisfy();273 __satisfy();
236 }274 }
237275
238 _LIBCPP_HIDE_FROM_ABI276 _LIBCPP_HIDE_FROM_ABI
239 constexpr __iterator(__iterator<!_Const> __i)277 constexpr __join_view_iterator(__join_view_iterator<_View, !_Const> __i)
240 requires _Const &&278 requires _Const &&
241 convertible_to<iterator_t<_View>, _Outer> &&279 convertible_to<iterator_t<_View>, _Outer> &&
242 convertible_to<iterator_t<_InnerRange>, _Inner>280 convertible_to<iterator_t<_InnerRange>, _Inner>
...@@ -257,7 +295,7 @@ namespace ranges {...@@ -257,7 +295,7 @@ namespace ranges {
257 }295 }
258296
259 _LIBCPP_HIDE_FROM_ABI297 _LIBCPP_HIDE_FROM_ABI
260 constexpr __iterator& operator++() {298 constexpr __join_view_iterator& operator++() {
261 auto&& __inner = [&]() -> auto&& {299 auto&& __inner = [&]() -> auto&& {
262 if constexpr (__ref_is_glvalue)300 if constexpr (__ref_is_glvalue)
263 return *__outer_;301 return *__outer_;
...@@ -277,7 +315,7 @@ namespace ranges {...@@ -277,7 +315,7 @@ namespace ranges {
277 }315 }
278316
279 _LIBCPP_HIDE_FROM_ABI317 _LIBCPP_HIDE_FROM_ABI
280 constexpr __iterator operator++(int)318 constexpr __join_view_iterator operator++(int)
281 requires __ref_is_glvalue &&319 requires __ref_is_glvalue &&
282 forward_range<_Base> &&320 forward_range<_Base> &&
283 forward_range<range_reference_t<_Base>>321 forward_range<range_reference_t<_Base>>
...@@ -288,7 +326,7 @@ namespace ranges {...@@ -288,7 +326,7 @@ namespace ranges {
288 }326 }
289327
290 _LIBCPP_HIDE_FROM_ABI328 _LIBCPP_HIDE_FROM_ABI
291 constexpr __iterator& operator--()329 constexpr __join_view_iterator& operator--()
292 requires __ref_is_glvalue &&330 requires __ref_is_glvalue &&
293 bidirectional_range<_Base> &&331 bidirectional_range<_Base> &&
294 bidirectional_range<range_reference_t<_Base>> &&332 bidirectional_range<range_reference_t<_Base>> &&
...@@ -307,7 +345,7 @@ namespace ranges {...@@ -307,7 +345,7 @@ namespace ranges {
307 }345 }
308346
309 _LIBCPP_HIDE_FROM_ABI347 _LIBCPP_HIDE_FROM_ABI
310 constexpr __iterator operator--(int)348 constexpr __join_view_iterator operator--(int)
311 requires __ref_is_glvalue &&349 requires __ref_is_glvalue &&
312 bidirectional_range<_Base> &&350 bidirectional_range<_Base> &&
313 bidirectional_range<range_reference_t<_Base>> &&351 bidirectional_range<range_reference_t<_Base>> &&
...@@ -319,7 +357,7 @@ namespace ranges {...@@ -319,7 +357,7 @@ namespace ranges {
319 }357 }
320358
321 _LIBCPP_HIDE_FROM_ABI359 _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)
323 requires __ref_is_glvalue &&361 requires __ref_is_glvalue &&
324 equality_comparable<iterator_t<_Base>> &&362 equality_comparable<iterator_t<_Base>> &&
325 equality_comparable<iterator_t<range_reference_t<_Base>>>363 equality_comparable<iterator_t<range_reference_t<_Base>>>
...@@ -328,14 +366,14 @@ namespace ranges {...@@ -328,14 +366,14 @@ namespace ranges {
328 }366 }
329367
330 _LIBCPP_HIDE_FROM_ABI368 _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)
332 noexcept(noexcept(ranges::iter_move(*__i.__inner_)))370 noexcept(noexcept(ranges::iter_move(*__i.__inner_)))
333 {371 {
334 return ranges::iter_move(*__i.__inner_);372 return ranges::iter_move(*__i.__inner_);
335 }373 }
336374
337 _LIBCPP_HIDE_FROM_ABI375 _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)
339 noexcept(noexcept(ranges::iter_swap(*__x.__inner_, *__y.__inner_)))377 noexcept(noexcept(ranges::iter_swap(*__x.__inner_, *__y.__inner_)))
340 requires indirectly_swappable<_Inner>378 requires indirectly_swappable<_Inner>
341 {379 {
...@@ -345,7 +383,7 @@ namespace ranges {...@@ -345,7 +383,7 @@ namespace ranges {
345383
346 template<class _Range>384 template<class _Range>
347 explicit join_view(_Range&&) -> join_view<views::all_t<_Range>>;385 explicit join_view(_Range&&) -> join_view<views::all_t<_Range>>;
348 386
349namespace views {387namespace views {
350namespace __join_view {388namespace __join_view {
351struct __fn : __range_adaptor_closure<__fn> {389struct __fn : __range_adaptor_closure<__fn> {
...@@ -363,7 +401,51 @@ inline namespace __cpo {...@@ -363,7 +401,51 @@ inline namespace __cpo {
363} // namespace views401} // namespace views
364} // namespace ranges402} // 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
368_LIBCPP_END_NAMESPACE_STD450_LIBCPP_END_NAMESPACE_STD
369451
lib/libcxx/include/__ranges/lazy_split_view.h+3-3
...@@ -10,7 +10,6 @@...@@ -10,7 +10,6 @@
10#ifndef _LIBCPP___RANGES_LAZY_SPLIT_VIEW_H10#ifndef _LIBCPP___RANGES_LAZY_SPLIT_VIEW_H
11#define _LIBCPP___RANGES_LAZY_SPLIT_VIEW_H11#define _LIBCPP___RANGES_LAZY_SPLIT_VIEW_H
1212
13#include <__algorithm/in_in_result.h>
14#include <__algorithm/ranges_find.h>13#include <__algorithm/ranges_find.h>
15#include <__algorithm/ranges_mismatch.h>14#include <__algorithm/ranges_mismatch.h>
16#include <__concepts/constructible.h>15#include <__concepts/constructible.h>
...@@ -35,6 +34,7 @@...@@ -35,6 +34,7 @@
35#include <__ranges/single_view.h>34#include <__ranges/single_view.h>
36#include <__ranges/subrange.h>35#include <__ranges/subrange.h>
37#include <__ranges/view_interface.h>36#include <__ranges/view_interface.h>
37#include <__type_traits/maybe_const.h>
38#include <__utility/forward.h>38#include <__utility/forward.h>
39#include <__utility/move.h>39#include <__utility/move.h>
40#include <type_traits>40#include <type_traits>
...@@ -45,7 +45,7 @@...@@ -45,7 +45,7 @@
4545
46_LIBCPP_BEGIN_NAMESPACE_STD46_LIBCPP_BEGIN_NAMESPACE_STD
4747
48#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)48#if _LIBCPP_STD_VER > 17
4949
50namespace ranges {50namespace ranges {
5151
...@@ -458,7 +458,7 @@ inline namespace __cpo {...@@ -458,7 +458,7 @@ inline namespace __cpo {
458458
459} // namespace ranges459} // namespace ranges
460460
461#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)461#endif // _LIBCPP_STD_VER > 17
462462
463_LIBCPP_END_NAMESPACE_STD463_LIBCPP_END_NAMESPACE_STD
464464
lib/libcxx/include/__ranges/non_propagating_cache.h+3-3
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_NON_PROPAGATING_CACHE_H10#ifndef _LIBCPP___RANGES_NON_PROPAGATING_CACHE_H
10#define _LIBCPP___RANGES_NON_PROPAGATING_CACHE_H11#define _LIBCPP___RANGES_NON_PROPAGATING_CACHE_H
1112
...@@ -14,7 +15,6 @@...@@ -14,7 +15,6 @@
14#include <__iterator/iterator_traits.h> // iter_reference_t15#include <__iterator/iterator_traits.h> // iter_reference_t
15#include <__memory/addressof.h>16#include <__memory/addressof.h>
16#include <__utility/forward.h>17#include <__utility/forward.h>
17#include <concepts> // constructible_from
18#include <optional>18#include <optional>
19#include <type_traits>19#include <type_traits>
2020
...@@ -24,7 +24,7 @@...@@ -24,7 +24,7 @@
2424
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)27#if _LIBCPP_STD_VER > 17
2828
29namespace ranges {29namespace ranges {
30 // __non_propagating_cache is a helper type that allows storing an optional value in it,30 // __non_propagating_cache is a helper type that allows storing an optional value in it,
...@@ -107,7 +107,7 @@ namespace ranges {...@@ -107,7 +107,7 @@ namespace ranges {
107 struct __empty_cache { };107 struct __empty_cache { };
108} // namespace ranges108} // namespace ranges
109109
110#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)110#endif // _LIBCPP_STD_VER > 17
111111
112_LIBCPP_END_NAMESPACE_STD112_LIBCPP_END_NAMESPACE_STD
113113
lib/libcxx/include/__ranges/owning_view.h+4-2
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_OWNING_VIEW_H10#ifndef _LIBCPP___RANGES_OWNING_VIEW_H
10#define _LIBCPP___RANGES_OWNING_VIEW_H11#define _LIBCPP___RANGES_OWNING_VIEW_H
1112
...@@ -28,7 +29,7 @@...@@ -28,7 +29,7 @@
2829
29_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
3031
31#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)32#if _LIBCPP_STD_VER > 17
3233
33namespace ranges {34namespace ranges {
34 template<range _Rp>35 template<range _Rp>
...@@ -68,13 +69,14 @@ public:...@@ -68,13 +69,14 @@ public:
68 _LIBCPP_HIDE_FROM_ABI constexpr auto data() const requires contiguous_range<const _Rp>69 _LIBCPP_HIDE_FROM_ABI constexpr auto data() const requires contiguous_range<const _Rp>
69 { return ranges::data(__r_); }70 { return ranges::data(__r_); }
70 };71 };
72 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(owning_view);
7173
72 template<class _Tp>74 template<class _Tp>
73 inline constexpr bool enable_borrowed_range<owning_view<_Tp>> = enable_borrowed_range<_Tp>;75 inline constexpr bool enable_borrowed_range<owning_view<_Tp>> = enable_borrowed_range<_Tp>;
7476
75} // namespace ranges77} // namespace ranges
7678
77#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)79#endif // _LIBCPP_STD_VER > 17
7880
79_LIBCPP_END_NAMESPACE_STD81_LIBCPP_END_NAMESPACE_STD
8082
lib/libcxx/include/__ranges/range_adaptor.h+7-3
...@@ -10,13 +10,16 @@...@@ -10,13 +10,16 @@
10#ifndef _LIBCPP___RANGES_RANGE_ADAPTOR_H10#ifndef _LIBCPP___RANGES_RANGE_ADAPTOR_H
11#define _LIBCPP___RANGES_RANGE_ADAPTOR_H11#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>
13#include <__config>17#include <__config>
14#include <__functional/compose.h>18#include <__functional/compose.h>
15#include <__functional/invoke.h>19#include <__functional/invoke.h>
16#include <__ranges/concepts.h>20#include <__ranges/concepts.h>
17#include <__utility/forward.h>21#include <__utility/forward.h>
18#include <__utility/move.h>22#include <__utility/move.h>
19#include <concepts>
20#include <type_traits>23#include <type_traits>
2124
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -25,7 +28,7 @@...@@ -25,7 +28,7 @@
2528
26_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
2730
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)31#if _LIBCPP_STD_VER > 17
2932
30// CRTP base that one can derive from in order to be considered a range adaptor closure33// CRTP base that one can derive from in order to be considered a range adaptor closure
31// by the library. When deriving from this class, a pipe operator will be provided to34// by the library. When deriving from this class, a pipe operator will be provided to
...@@ -41,6 +44,7 @@ template <class _Fn>...@@ -41,6 +44,7 @@ template <class _Fn>
41struct __range_adaptor_closure_t : _Fn, __range_adaptor_closure<__range_adaptor_closure_t<_Fn>> {44struct __range_adaptor_closure_t : _Fn, __range_adaptor_closure<__range_adaptor_closure_t<_Fn>> {
42 constexpr explicit __range_adaptor_closure_t(_Fn&& __f) : _Fn(std::move(__f)) { }45 constexpr explicit __range_adaptor_closure_t(_Fn&& __f) : _Fn(std::move(__f)) { }
43};46};
47_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__range_adaptor_closure_t);
4448
45template <class _Tp>49template <class _Tp>
46concept _RangeAdaptorClosure = derived_from<remove_cvref_t<_Tp>, __range_adaptor_closure<remove_cvref_t<_Tp>>>;50concept _RangeAdaptorClosure = derived_from<remove_cvref_t<_Tp>, __range_adaptor_closure<remove_cvref_t<_Tp>>>;
...@@ -66,7 +70,7 @@ struct __range_adaptor_closure {...@@ -66,7 +70,7 @@ struct __range_adaptor_closure {
66 { return __range_adaptor_closure_t(std::__compose(std::forward<_OtherClosure>(__c2), std::forward<_Closure>(__c1))); }70 { return __range_adaptor_closure_t(std::__compose(std::forward<_OtherClosure>(__c2), std::forward<_Closure>(__c1))); }
67};71};
6872
69#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)73#endif // _LIBCPP_STD_VER > 17
7074
71_LIBCPP_END_NAMESPACE_STD75_LIBCPP_END_NAMESPACE_STD
7276
lib/libcxx/include/__ranges/rbegin.h+3-2
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_RBEGIN_H10#ifndef _LIBCPP___RANGES_RBEGIN_H
10#define _LIBCPP___RANGES_RBEGIN_H11#define _LIBCPP___RANGES_RBEGIN_H
1112
...@@ -25,7 +26,7 @@...@@ -25,7 +26,7 @@
2526
26_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2728
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)29#if _LIBCPP_STD_VER > 17
2930
30// [ranges.access.rbegin]31// [ranges.access.rbegin]
3132
...@@ -123,7 +124,7 @@ inline namespace __cpo {...@@ -123,7 +124,7 @@ inline namespace __cpo {
123} // namespace __cpo124} // namespace __cpo
124} // namespace ranges125} // namespace ranges
125126
126#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)127#endif // _LIBCPP_STD_VER > 17
127128
128_LIBCPP_END_NAMESPACE_STD129_LIBCPP_END_NAMESPACE_STD
129130
lib/libcxx/include/__ranges/ref_view.h+6-4
...@@ -6,9 +6,12 @@...@@ -6,9 +6,12 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_REF_VIEW_H10#ifndef _LIBCPP___RANGES_REF_VIEW_H
10#define _LIBCPP___RANGES_REF_VIEW_H11#define _LIBCPP___RANGES_REF_VIEW_H
1112
13#include <__concepts/convertible_to.h>
14#include <__concepts/different_from.h>
12#include <__config>15#include <__config>
13#include <__iterator/concepts.h>16#include <__iterator/concepts.h>
14#include <__iterator/incrementable_traits.h>17#include <__iterator/incrementable_traits.h>
...@@ -22,7 +25,6 @@...@@ -22,7 +25,6 @@
22#include <__ranges/size.h>25#include <__ranges/size.h>
23#include <__ranges/view_interface.h>26#include <__ranges/view_interface.h>
24#include <__utility/forward.h>27#include <__utility/forward.h>
25#include <concepts>
26#include <type_traits>28#include <type_traits>
2729
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -31,7 +33,7 @@...@@ -31,7 +33,7 @@
3133
32_LIBCPP_BEGIN_NAMESPACE_STD34_LIBCPP_BEGIN_NAMESPACE_STD
3335
34#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)36#if _LIBCPP_STD_VER > 17
3537
36namespace ranges {38namespace ranges {
37 template<range _Range>39 template<range _Range>
...@@ -45,7 +47,7 @@ namespace ranges {...@@ -45,7 +47,7 @@ namespace ranges {
45public:47public:
46 template<class _Tp>48 template<class _Tp>
47 requires __different_from<_Tp, ref_view> &&49 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>()); }
49 _LIBCPP_HIDE_FROM_ABI51 _LIBCPP_HIDE_FROM_ABI
50 constexpr ref_view(_Tp&& __t)52 constexpr ref_view(_Tp&& __t)
51 : __range_(std::addressof(static_cast<_Range&>(std::forward<_Tp>(__t))))53 : __range_(std::addressof(static_cast<_Range&>(std::forward<_Tp>(__t))))
...@@ -79,7 +81,7 @@ public:...@@ -79,7 +81,7 @@ public:
79 inline constexpr bool enable_borrowed_range<ref_view<_Tp>> = true;81 inline constexpr bool enable_borrowed_range<ref_view<_Tp>> = true;
80} // namespace ranges82} // namespace ranges
8183
82#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)84#endif // _LIBCPP_STD_VER > 17
8385
84_LIBCPP_END_NAMESPACE_STD86_LIBCPP_END_NAMESPACE_STD
8587
lib/libcxx/include/__ranges/rend.h+3-2
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_REND_H10#ifndef _LIBCPP___RANGES_REND_H
10#define _LIBCPP___RANGES_REND_H11#define _LIBCPP___RANGES_REND_H
1112
...@@ -26,7 +27,7 @@...@@ -26,7 +27,7 @@
2627
27_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2829
29#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)30#if _LIBCPP_STD_VER > 17
3031
31// [range.access.rend]32// [range.access.rend]
3233
...@@ -127,7 +128,7 @@ inline namespace __cpo {...@@ -127,7 +128,7 @@ inline namespace __cpo {
127} // namespace __cpo128} // namespace __cpo
128} // namespace ranges129} // namespace ranges
129130
130#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)131#endif // _LIBCPP_STD_VER > 17
131132
132_LIBCPP_END_NAMESPACE_STD133_LIBCPP_END_NAMESPACE_STD
133134
lib/libcxx/include/__ranges/reverse_view.h+3-2
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_REVERSE_VIEW_H10#ifndef _LIBCPP___RANGES_REVERSE_VIEW_H
10#define _LIBCPP___RANGES_REVERSE_VIEW_H11#define _LIBCPP___RANGES_REVERSE_VIEW_H
1112
...@@ -33,7 +34,7 @@...@@ -33,7 +34,7 @@
3334
34_LIBCPP_BEGIN_NAMESPACE_STD35_LIBCPP_BEGIN_NAMESPACE_STD
3536
36#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)37#if _LIBCPP_STD_VER > 17
3738
38namespace ranges {39namespace ranges {
39 template<view _View>40 template<view _View>
...@@ -183,7 +184,7 @@ namespace ranges {...@@ -183,7 +184,7 @@ namespace ranges {
183 } // namespace views184 } // namespace views
184} // namespace ranges185} // namespace ranges
185186
186#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)187#endif // _LIBCPP_STD_VER > 17
187188
188_LIBCPP_END_NAMESPACE_STD189_LIBCPP_END_NAMESPACE_STD
189190
lib/libcxx/include/__ranges/single_view.h+4-3
...@@ -6,9 +6,11 @@...@@ -6,9 +6,11 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_SINGLE_VIEW_H10#ifndef _LIBCPP___RANGES_SINGLE_VIEW_H
10#define _LIBCPP___RANGES_SINGLE_VIEW_H11#define _LIBCPP___RANGES_SINGLE_VIEW_H
1112
13#include <__concepts/constructible.h>
12#include <__config>14#include <__config>
13#include <__ranges/copyable_box.h>15#include <__ranges/copyable_box.h>
14#include <__ranges/range_adaptor.h>16#include <__ranges/range_adaptor.h>
...@@ -16,7 +18,6 @@...@@ -16,7 +18,6 @@
16#include <__utility/forward.h>18#include <__utility/forward.h>
17#include <__utility/in_place.h>19#include <__utility/in_place.h>
18#include <__utility/move.h>20#include <__utility/move.h>
19#include <concepts>
20#include <type_traits>21#include <type_traits>
2122
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -25,7 +26,7 @@...@@ -25,7 +26,7 @@
2526
26_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2728
28#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)29#if _LIBCPP_STD_VER > 17
2930
30namespace ranges {31namespace ranges {
31 template<copy_constructible _Tp>32 template<copy_constructible _Tp>
...@@ -94,7 +95,7 @@ inline namespace __cpo {...@@ -94,7 +95,7 @@ inline namespace __cpo {
94} // namespace views95} // namespace views
95} // namespace ranges96} // namespace ranges
9697
97#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)98#endif // _LIBCPP_STD_VER > 17
9899
99_LIBCPP_END_NAMESPACE_STD100_LIBCPP_END_NAMESPACE_STD
100101
lib/libcxx/include/__ranges/size.h+8-3
...@@ -6,18 +6,23 @@...@@ -6,18 +6,23 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_SIZE_H10#ifndef _LIBCPP___RANGES_SIZE_H
10#define _LIBCPP___RANGES_SIZE_H11#define _LIBCPP___RANGES_SIZE_H
1112
13#include <__concepts/arithmetic.h>
12#include <__concepts/class_or_enum.h>14#include <__concepts/class_or_enum.h>
13#include <__config>15#include <__config>
14#include <__iterator/concepts.h>16#include <__iterator/concepts.h>
15#include <__iterator/iterator_traits.h>17#include <__iterator/iterator_traits.h>
16#include <__ranges/access.h>18#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>
17#include <__utility/auto_cast.h>23#include <__utility/auto_cast.h>
18#include <concepts>24#include <__utility/declval.h>
19#include <cstddef>25#include <cstddef>
20#include <type_traits>
2126
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header28# pragma GCC system_header
...@@ -66,7 +71,7 @@ concept __difference =...@@ -66,7 +71,7 @@ concept __difference =
66 __class_or_enum<remove_cvref_t<_Tp>> &&71 __class_or_enum<remove_cvref_t<_Tp>> &&
67 requires(_Tp&& __t) {72 requires(_Tp&& __t) {
68 { ranges::begin(__t) } -> forward_iterator;73 { 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>()))>;
70 };75 };
7176
72struct __fn {77struct __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 @@...@@ -6,6 +6,7 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_SUBRANGE_H10#ifndef _LIBCPP___RANGES_SUBRANGE_H
10#define _LIBCPP___RANGES_SUBRANGE_H11#define _LIBCPP___RANGES_SUBRANGE_H
1112
...@@ -16,6 +17,8 @@...@@ -16,6 +17,8 @@
16#include <__concepts/derived_from.h>17#include <__concepts/derived_from.h>
17#include <__concepts/different_from.h>18#include <__concepts/different_from.h>
18#include <__config>19#include <__config>
20#include <__fwd/get.h>
21#include <__fwd/subrange.h>
19#include <__iterator/advance.h>22#include <__iterator/advance.h>
20#include <__iterator/concepts.h>23#include <__iterator/concepts.h>
21#include <__iterator/incrementable_traits.h>24#include <__iterator/incrementable_traits.h>
...@@ -26,9 +29,18 @@...@@ -26,9 +29,18 @@
26#include <__ranges/enable_borrowed_range.h>29#include <__ranges/enable_borrowed_range.h>
27#include <__ranges/size.h>30#include <__ranges/size.h>
28#include <__ranges/view_interface.h>31#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>
30#include <__utility/move.h>42#include <__utility/move.h>
31#include <type_traits>43#include <cstddef>
3244
33#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)45#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
34# pragma GCC system_header46# pragma GCC system_header
...@@ -36,7 +48,7 @@...@@ -36,7 +48,7 @@
3648
37_LIBCPP_BEGIN_NAMESPACE_STD49_LIBCPP_BEGIN_NAMESPACE_STD
3850
39#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)51#if _LIBCPP_STD_VER > 17
4052
41namespace ranges {53namespace ranges {
42 template<class _From, class _To>54 template<class _From, class _To>
...@@ -49,17 +61,6 @@ namespace ranges {...@@ -49,17 +61,6 @@ namespace ranges {
49 convertible_to<_From, _To> &&61 convertible_to<_From, _To> &&
50 !__uses_nonqualification_pointer_conversion<decay_t<_From>, decay_t<_To>>;62 !__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
63 template<class _Pair, class _Iter, class _Sent>64 template<class _Pair, class _Iter, class _Sent>
64 concept __pair_like_convertible_from =65 concept __pair_like_convertible_from =
65 !range<_Pair> && __pair_like<_Pair> &&66 !range<_Pair> && __pair_like<_Pair> &&
...@@ -67,8 +68,6 @@ namespace ranges {...@@ -67,8 +68,6 @@ namespace ranges {
67 __convertible_to_non_slicing<_Iter, tuple_element_t<0, _Pair>> &&68 __convertible_to_non_slicing<_Iter, tuple_element_t<0, _Pair>> &&
68 convertible_to<_Sent, tuple_element_t<1, _Pair>>;69 convertible_to<_Sent, tuple_element_t<1, _Pair>>;
6970
70 enum class _LIBCPP_ENUM_VIS subrange_kind : bool { unsized, sized };
71
72 template<input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent = _Iter,71 template<input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent = _Iter,
73 subrange_kind _Kind = sized_sentinel_for<_Sent, _Iter>72 subrange_kind _Kind = sized_sentinel_for<_Sent, _Iter>
74 ? subrange_kind::sized73 ? subrange_kind::sized
...@@ -285,7 +284,7 @@ struct tuple_element<1, const ranges::subrange<_Ip, _Sp, _Kp>> {...@@ -285,7 +284,7 @@ struct tuple_element<1, const ranges::subrange<_Ip, _Sp, _Kp>> {
285 using type = _Sp;284 using type = _Sp;
286};285};
287286
288#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)287#endif // _LIBCPP_STD_VER > 17
289288
290_LIBCPP_END_NAMESPACE_STD289_LIBCPP_END_NAMESPACE_STD
291290
lib/libcxx/include/__ranges/take_view.h+12-6
...@@ -6,11 +6,15 @@...@@ -6,11 +6,15 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_TAKE_VIEW_H10#ifndef _LIBCPP___RANGES_TAKE_VIEW_H
10#define _LIBCPP___RANGES_TAKE_VIEW_H11#define _LIBCPP___RANGES_TAKE_VIEW_H
1112
12#include <__algorithm/min.h>13#include <__algorithm/min.h>
13#include <__algorithm/ranges_min.h>14#include <__algorithm/ranges_min.h>
15#include <__assert>
16#include <__concepts/constructible.h>
17#include <__concepts/convertible_to.h>
14#include <__config>18#include <__config>
15#include <__functional/bind_back.h>19#include <__functional/bind_back.h>
16#include <__fwd/span.h>20#include <__fwd/span.h>
...@@ -30,10 +34,10 @@...@@ -30,10 +34,10 @@
30#include <__ranges/size.h>34#include <__ranges/size.h>
31#include <__ranges/subrange.h>35#include <__ranges/subrange.h>
32#include <__ranges/view_interface.h>36#include <__ranges/view_interface.h>
37#include <__type_traits/maybe_const.h>
33#include <__utility/auto_cast.h>38#include <__utility/auto_cast.h>
34#include <__utility/forward.h>39#include <__utility/forward.h>
35#include <__utility/move.h>40#include <__utility/move.h>
36#include <concepts>
37#include <type_traits>41#include <type_traits>
3842
39#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)43#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -45,7 +49,7 @@ _LIBCPP_PUSH_MACROS...@@ -45,7 +49,7 @@ _LIBCPP_PUSH_MACROS
4549
46_LIBCPP_BEGIN_NAMESPACE_STD50_LIBCPP_BEGIN_NAMESPACE_STD
4751
48#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)52#if _LIBCPP_STD_VER > 17
4953
50namespace ranges {54namespace ranges {
5155
...@@ -60,9 +64,10 @@ public:...@@ -60,9 +64,10 @@ public:
60 _LIBCPP_HIDE_FROM_ABI64 _LIBCPP_HIDE_FROM_ABI
61 take_view() requires default_initializable<_View> = default;65 take_view() requires default_initializable<_View> = default;
6266
63 _LIBCPP_HIDE_FROM_ABI67 _LIBCPP_HIDE_FROM_ABI constexpr take_view(_View __base, range_difference_t<_View> __count)
64 constexpr take_view(_View __base, range_difference_t<_View> __count)68 : __base_(std::move(__base)), __count_(__count) {
65 : __base_(std::move(__base)), __count_(__count) {}69 _LIBCPP_ASSERT(__count >= 0, "count has to be greater than or equal to zero");
70 }
6671
67 _LIBCPP_HIDE_FROM_ABI72 _LIBCPP_HIDE_FROM_ABI
68 constexpr _View base() const& requires copy_constructible<_View> { return __base_; }73 constexpr _View base() const& requires copy_constructible<_View> { return __base_; }
...@@ -225,6 +230,7 @@ struct __passthrough_type<basic_string_view<_CharT, _Traits>> {...@@ -225,6 +230,7 @@ struct __passthrough_type<basic_string_view<_CharT, _Traits>> {
225};230};
226231
227template <class _Iter, class _Sent, subrange_kind _Kind>232template <class _Iter, class _Sent, subrange_kind _Kind>
233 requires requires{typename subrange<_Iter>;}
228struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> {234struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> {
229 using type = subrange<_Iter>;235 using type = subrange<_Iter>;
230};236};
...@@ -328,7 +334,7 @@ inline namespace __cpo {...@@ -328,7 +334,7 @@ inline namespace __cpo {
328334
329} // namespace ranges335} // namespace ranges
330336
331#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)337#endif // _LIBCPP_STD_VER > 17
332338
333_LIBCPP_END_NAMESPACE_STD339_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 @@...@@ -6,6 +6,7 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_TRANSFORM_VIEW_H10#ifndef _LIBCPP___RANGES_TRANSFORM_VIEW_H
10#define _LIBCPP___RANGES_TRANSFORM_VIEW_H11#define _LIBCPP___RANGES_TRANSFORM_VIEW_H
1112
...@@ -30,6 +31,7 @@...@@ -30,6 +31,7 @@
30#include <__ranges/range_adaptor.h>31#include <__ranges/range_adaptor.h>
31#include <__ranges/size.h>32#include <__ranges/size.h>
32#include <__ranges/view_interface.h>33#include <__ranges/view_interface.h>
34#include <__type_traits/maybe_const.h>
33#include <__utility/forward.h>35#include <__utility/forward.h>
34#include <__utility/in_place.h>36#include <__utility/in_place.h>
35#include <__utility/move.h>37#include <__utility/move.h>
...@@ -41,7 +43,7 @@...@@ -41,7 +43,7 @@
4143
42_LIBCPP_BEGIN_NAMESPACE_STD44_LIBCPP_BEGIN_NAMESPACE_STD
4345
44#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)46#if _LIBCPP_STD_VER > 17
4547
46namespace ranges {48namespace ranges {
4749
...@@ -55,11 +57,31 @@ concept __transform_view_constraints =...@@ -55,11 +57,31 @@ concept __transform_view_constraints =
55 regular_invocable<_Fn&, range_reference_t<_View>> &&57 regular_invocable<_Fn&, range_reference_t<_View>> &&
56 __can_reference<invoke_result_t<_Fn&, range_reference_t<_View>>>;58 __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
58template<input_range _View, copy_constructible _Fn>68template<input_range _View, copy_constructible _Fn>
59 requires __transform_view_constraints<_View, _Fn>69 requires __transform_view_constraints<_View, _Fn>
60class transform_view : public view_interface<transform_view<_View, _Fn>> {70class transform_view : public view_interface<transform_view<_View, _Fn>> {
61 template<bool> class __iterator;71
62 template<bool> class __sentinel;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
64 _LIBCPP_NO_UNIQUE_ADDRESS __copyable_box<_Fn> __func_;86 _LIBCPP_NO_UNIQUE_ADDRESS __copyable_box<_Fn> __func_;
65 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();87 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
...@@ -154,22 +176,23 @@ struct __transform_view_iterator_category_base<_View, _Fn> {...@@ -154,22 +176,23 @@ struct __transform_view_iterator_category_base<_View, _Fn> {
154 >;176 >;
155};177};
156178
157template<input_range _View, copy_constructible _Fn>179template<input_range _View, copy_constructible _Fn, bool _Const>
158 requires __transform_view_constraints<_View, _Fn>180 requires __transform_view_constraints<_View, _Fn>
159template<bool _Const>181class __transform_view_iterator
160class transform_view<_View, _Fn>::__iterator
161 : public __transform_view_iterator_category_base<_View, _Fn> {182 : 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>>;
164 using _Base = __maybe_const<_Const, _View>;185 using _Base = __maybe_const<_Const, _View>;
165186
166 _Parent *__parent_ = nullptr;187 _Parent *__parent_ = nullptr;
167188
168 template<bool>189 template<input_range _ViewType, copy_constructible _FunctionType, bool _IsConst>
169 friend class transform_view<_View, _Fn>::__iterator;190 requires __transform_view_constraints<_ViewType, _FunctionType>
191 friend class __transform_view_iterator;
170192
171 template<bool>193 template<input_range _ViewType, copy_constructible _FunctionType, bool _IsConst>
172 friend class transform_view<_View, _Fn>::__sentinel;194 requires __transform_view_constraints<_ViewType, _FunctionType>
195 friend class __transform_view_sentinel;
173196
174public:197public:
175 iterator_t<_Base> __current_ = iterator_t<_Base>();198 iterator_t<_Base> __current_ = iterator_t<_Base>();
...@@ -179,17 +202,17 @@ public:...@@ -179,17 +202,17 @@ public:
179 using difference_type = range_difference_t<_Base>;202 using difference_type = range_difference_t<_Base>;
180203
181 _LIBCPP_HIDE_FROM_ABI204 _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
184 _LIBCPP_HIDE_FROM_ABI207 _LIBCPP_HIDE_FROM_ABI
185 constexpr __iterator(_Parent& __parent, iterator_t<_Base> __current)208 constexpr __transform_view_iterator(_Parent& __parent, iterator_t<_Base> __current)
186 : __parent_(std::addressof(__parent)), __current_(std::move(__current)) {}209 : __parent_(std::addressof(__parent)), __current_(std::move(__current)) {}
187210
188 // Note: `__i` should always be `__iterator<false>`, but directly using211 // Note: `__i` should always be `__transform_view_iterator<false>`, but directly using
189 // `__iterator<false>` is ill-formed when `_Const` is false212 // `__transform_view_iterator<false>` is ill-formed when `_Const` is false
190 // (see http://wg21.link/class.copy.ctor#5).213 // (see http://wg21.link/class.copy.ctor#5).
191 _LIBCPP_HIDE_FROM_ABI214 _LIBCPP_HIDE_FROM_ABI
192 constexpr __iterator(__iterator<!_Const> __i)215 constexpr __transform_view_iterator(__transform_view_iterator<_View, _Fn, !_Const> __i)
193 requires _Const && convertible_to<iterator_t<_View>, iterator_t<_Base>>216 requires _Const && convertible_to<iterator_t<_View>, iterator_t<_Base>>
194 : __parent_(__i.__parent_), __current_(std::move(__i.__current_)) {}217 : __parent_(__i.__parent_), __current_(std::move(__i.__current_)) {}
195218
...@@ -211,7 +234,7 @@ public:...@@ -211,7 +234,7 @@ public:
211 }234 }
212235
213 _LIBCPP_HIDE_FROM_ABI236 _LIBCPP_HIDE_FROM_ABI
214 constexpr __iterator& operator++() {237 constexpr __transform_view_iterator& operator++() {
215 ++__current_;238 ++__current_;
216 return *this;239 return *this;
217 }240 }
...@@ -220,7 +243,7 @@ public:...@@ -220,7 +243,7 @@ public:
220 constexpr void operator++(int) { ++__current_; }243 constexpr void operator++(int) { ++__current_; }
221244
222 _LIBCPP_HIDE_FROM_ABI245 _LIBCPP_HIDE_FROM_ABI
223 constexpr __iterator operator++(int)246 constexpr __transform_view_iterator operator++(int)
224 requires forward_range<_Base>247 requires forward_range<_Base>
225 {248 {
226 auto __tmp = *this;249 auto __tmp = *this;
...@@ -229,7 +252,7 @@ public:...@@ -229,7 +252,7 @@ public:
229 }252 }
230253
231 _LIBCPP_HIDE_FROM_ABI254 _LIBCPP_HIDE_FROM_ABI
232 constexpr __iterator& operator--()255 constexpr __transform_view_iterator& operator--()
233 requires bidirectional_range<_Base>256 requires bidirectional_range<_Base>
234 {257 {
235 --__current_;258 --__current_;
...@@ -237,7 +260,7 @@ public:...@@ -237,7 +260,7 @@ public:
237 }260 }
238261
239 _LIBCPP_HIDE_FROM_ABI262 _LIBCPP_HIDE_FROM_ABI
240 constexpr __iterator operator--(int)263 constexpr __transform_view_iterator operator--(int)
241 requires bidirectional_range<_Base>264 requires bidirectional_range<_Base>
242 {265 {
243 auto __tmp = *this;266 auto __tmp = *this;
...@@ -246,7 +269,7 @@ public:...@@ -246,7 +269,7 @@ public:
246 }269 }
247270
248 _LIBCPP_HIDE_FROM_ABI271 _LIBCPP_HIDE_FROM_ABI
249 constexpr __iterator& operator+=(difference_type __n)272 constexpr __transform_view_iterator& operator+=(difference_type __n)
250 requires random_access_range<_Base>273 requires random_access_range<_Base>
251 {274 {
252 __current_ += __n;275 __current_ += __n;
...@@ -254,7 +277,7 @@ public:...@@ -254,7 +277,7 @@ public:
254 }277 }
255278
256 _LIBCPP_HIDE_FROM_ABI279 _LIBCPP_HIDE_FROM_ABI
257 constexpr __iterator& operator-=(difference_type __n)280 constexpr __transform_view_iterator& operator-=(difference_type __n)
258 requires random_access_range<_Base>281 requires random_access_range<_Base>
259 {282 {
260 __current_ -= __n;283 __current_ -= __n;
...@@ -270,77 +293,77 @@ public:...@@ -270,77 +293,77 @@ public:
270 }293 }
271294
272 _LIBCPP_HIDE_FROM_ABI295 _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)
274 requires equality_comparable<iterator_t<_Base>>297 requires equality_comparable<iterator_t<_Base>>
275 {298 {
276 return __x.__current_ == __y.__current_;299 return __x.__current_ == __y.__current_;
277 }300 }
278301
279 _LIBCPP_HIDE_FROM_ABI302 _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)
281 requires random_access_range<_Base>304 requires random_access_range<_Base>
282 {305 {
283 return __x.__current_ < __y.__current_;306 return __x.__current_ < __y.__current_;
284 }307 }
285308
286 _LIBCPP_HIDE_FROM_ABI309 _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)
288 requires random_access_range<_Base>311 requires random_access_range<_Base>
289 {312 {
290 return __x.__current_ > __y.__current_;313 return __x.__current_ > __y.__current_;
291 }314 }
292315
293 _LIBCPP_HIDE_FROM_ABI316 _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)
295 requires random_access_range<_Base>318 requires random_access_range<_Base>
296 {319 {
297 return __x.__current_ <= __y.__current_;320 return __x.__current_ <= __y.__current_;
298 }321 }
299322
300 _LIBCPP_HIDE_FROM_ABI323 _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)
302 requires random_access_range<_Base>325 requires random_access_range<_Base>
303 {326 {
304 return __x.__current_ >= __y.__current_;327 return __x.__current_ >= __y.__current_;
305 }328 }
306329
307 _LIBCPP_HIDE_FROM_ABI330 _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)
309 requires random_access_range<_Base> && three_way_comparable<iterator_t<_Base>>332 requires random_access_range<_Base> && three_way_comparable<iterator_t<_Base>>
310 {333 {
311 return __x.__current_ <=> __y.__current_;334 return __x.__current_ <=> __y.__current_;
312 }335 }
313336
314 _LIBCPP_HIDE_FROM_ABI337 _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)
316 requires random_access_range<_Base>339 requires random_access_range<_Base>
317 {340 {
318 return __iterator{*__i.__parent_, __i.__current_ + __n};341 return __transform_view_iterator{*__i.__parent_, __i.__current_ + __n};
319 }342 }
320343
321 _LIBCPP_HIDE_FROM_ABI344 _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)
323 requires random_access_range<_Base>346 requires random_access_range<_Base>
324 {347 {
325 return __iterator{*__i.__parent_, __i.__current_ + __n};348 return __transform_view_iterator{*__i.__parent_, __i.__current_ + __n};
326 }349 }
327350
328 _LIBCPP_HIDE_FROM_ABI351 _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)
330 requires random_access_range<_Base>353 requires random_access_range<_Base>
331 {354 {
332 return __iterator{*__i.__parent_, __i.__current_ - __n};355 return __transform_view_iterator{*__i.__parent_, __i.__current_ - __n};
333 }356 }
334357
335 _LIBCPP_HIDE_FROM_ABI358 _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)
337 requires sized_sentinel_for<iterator_t<_Base>, iterator_t<_Base>>360 requires sized_sentinel_for<iterator_t<_Base>, iterator_t<_Base>>
338 {361 {
339 return __x.__current_ - __y.__current_;362 return __x.__current_ - __y.__current_;
340 }363 }
341364
342 _LIBCPP_HIDE_FROM_ABI365 _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)
344 noexcept(noexcept(*__i))367 noexcept(noexcept(*__i))
345 {368 {
346 if constexpr (is_lvalue_reference_v<decltype(*__i)>)369 if constexpr (is_lvalue_reference_v<decltype(*__i)>)
...@@ -350,33 +373,37 @@ public:...@@ -350,33 +373,37 @@ public:
350 }373 }
351};374};
352375
353template<input_range _View, copy_constructible _Fn>376template<input_range _View, copy_constructible _Fn, bool _Const>
354 requires __transform_view_constraints<_View, _Fn>377 requires __transform_view_constraints<_View, _Fn>
355template<bool _Const>378class __transform_view_sentinel {
356class transform_view<_View, _Fn>::__sentinel {379 using _Parent = __maybe_const<_Const, transform_view<_View, _Fn>>;
357 using _Parent = __maybe_const<_Const, transform_view>;
358 using _Base = __maybe_const<_Const, _View>;380 using _Base = __maybe_const<_Const, _View>;
359381
382 template <bool _IsConst>
383 using __iterator = __transform_view_iterator<_View, _Fn, _IsConst>;
384
360 sentinel_t<_Base> __end_ = sentinel_t<_Base>();385 sentinel_t<_Base> __end_ = sentinel_t<_Base>();
361386
362 template<bool>387 template<input_range _ViewType, copy_constructible _FunctionType, bool _IsConst>
363 friend class transform_view<_View, _Fn>::__iterator;388 requires __transform_view_constraints<_ViewType, _FunctionType>
389 friend class __transform_view_iterator;
364390
365 template<bool>391 template<input_range _ViewType, copy_constructible _FunctionType, bool _IsConst>
366 friend class transform_view<_View, _Fn>::__sentinel;392 requires __transform_view_constraints<_ViewType, _FunctionType>
393 friend class __transform_view_sentinel;
367394
368public:395public:
369 _LIBCPP_HIDE_FROM_ABI396 _LIBCPP_HIDE_FROM_ABI
370 __sentinel() = default;397 __transform_view_sentinel() = default;
371398
372 _LIBCPP_HIDE_FROM_ABI399 _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 using402 // Note: `__i` should always be `__transform_view_sentinel<false>`, but directly using
376 // `__sentinel<false>` is ill-formed when `_Const` is false403 // `__transform_view_sentinel<false>` is ill-formed when `_Const` is false
377 // (see http://wg21.link/class.copy.ctor#5).404 // (see http://wg21.link/class.copy.ctor#5).
378 _LIBCPP_HIDE_FROM_ABI405 _LIBCPP_HIDE_FROM_ABI
379 constexpr __sentinel(__sentinel<!_Const> __i)406 constexpr __transform_view_sentinel(__transform_view_sentinel<_View, _Fn, !_Const> __i)
380 requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>407 requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
381 : __end_(std::move(__i.__end_)) {}408 : __end_(std::move(__i.__end_)) {}
382409
...@@ -386,7 +413,7 @@ public:...@@ -386,7 +413,7 @@ public:
386 template<bool _OtherConst>413 template<bool _OtherConst>
387 requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>414 requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
388 _LIBCPP_HIDE_FROM_ABI415 _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) {
390 return __x.__current_ == __y.__end_;417 return __x.__current_ == __y.__end_;
391 }418 }
392419
...@@ -394,7 +421,7 @@ public:...@@ -394,7 +421,7 @@ public:
394 requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>421 requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
395 _LIBCPP_HIDE_FROM_ABI422 _LIBCPP_HIDE_FROM_ABI
396 friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>>423 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) {
398 return __x.__current_ - __y.__end_;425 return __x.__current_ - __y.__end_;
399 }426 }
400427
...@@ -402,7 +429,7 @@ public:...@@ -402,7 +429,7 @@ public:
402 requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>429 requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
403 _LIBCPP_HIDE_FROM_ABI430 _LIBCPP_HIDE_FROM_ABI
404 friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>>431 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) {
406 return __x.__end_ - __y.__current_;433 return __x.__end_ - __y.__current_;
407 }434 }
408};435};
...@@ -433,7 +460,7 @@ inline namespace __cpo {...@@ -433,7 +460,7 @@ inline namespace __cpo {
433460
434} // namespace ranges461} // namespace ranges
435462
436#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)463#endif // _LIBCPP_STD_VER > 17
437464
438_LIBCPP_END_NAMESPACE_STD465_LIBCPP_END_NAMESPACE_STD
439466
lib/libcxx/include/__ranges/view_interface.h+8-5
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_VIEW_INTERFACE_H10#ifndef _LIBCPP___RANGES_VIEW_INTERFACE_H
10#define _LIBCPP___RANGES_VIEW_INTERFACE_H11#define _LIBCPP___RANGES_VIEW_INTERFACE_H
1112
...@@ -20,7 +21,9 @@...@@ -20,7 +21,9 @@
20#include <__ranges/access.h>21#include <__ranges/access.h>
21#include <__ranges/concepts.h>22#include <__ranges/concepts.h>
22#include <__ranges/empty.h>23#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
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26# pragma GCC system_header29# pragma GCC system_header
...@@ -28,7 +31,7 @@...@@ -28,7 +31,7 @@
2831
29_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
3033
31#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)34#if _LIBCPP_STD_VER > 17
3235
33namespace ranges {36namespace ranges {
3437
...@@ -99,7 +102,7 @@ public:...@@ -99,7 +102,7 @@ public:
99 constexpr auto size()102 constexpr auto size()
100 requires forward_range<_D2> && sized_sentinel_for<sentinel_t<_D2>, iterator_t<_D2>>103 requires forward_range<_D2> && sized_sentinel_for<sentinel_t<_D2>, iterator_t<_D2>>
101 {104 {
102 return ranges::end(__derived()) - ranges::begin(__derived());105 return std::__to_unsigned_like(ranges::end(__derived()) - ranges::begin(__derived()));
103 }106 }
104107
105 template<class _D2 = _Derived>108 template<class _D2 = _Derived>
...@@ -107,7 +110,7 @@ public:...@@ -107,7 +110,7 @@ public:
107 constexpr auto size() const110 constexpr auto size() const
108 requires forward_range<const _D2> && sized_sentinel_for<sentinel_t<const _D2>, iterator_t<const _D2>>111 requires forward_range<const _D2> && sized_sentinel_for<sentinel_t<const _D2>, iterator_t<const _D2>>
109 {112 {
110 return ranges::end(__derived()) - ranges::begin(__derived());113 return std::__to_unsigned_like(ranges::end(__derived()) - ranges::begin(__derived()));
111 }114 }
112115
113 template<class _D2 = _Derived>116 template<class _D2 = _Derived>
...@@ -167,7 +170,7 @@ public:...@@ -167,7 +170,7 @@ public:
167170
168} // namespace ranges171} // namespace ranges
169172
170#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)173#endif // _LIBCPP_STD_VER > 17
171174
172_LIBCPP_END_NAMESPACE_STD175_LIBCPP_END_NAMESPACE_STD
173176
lib/libcxx/include/__ranges/views.h+2-2
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)21#if _LIBCPP_STD_VER > 17
2222
23namespace ranges {23namespace ranges {
2424
...@@ -28,7 +28,7 @@ namespace views { }...@@ -28,7 +28,7 @@ namespace views { }
2828
29namespace views = ranges::views;29namespace views = ranges::views;
3030
31#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)31#endif // _LIBCPP_STD_VER > 17
3232
33_LIBCPP_END_NAMESPACE_STD33_LIBCPP_END_NAMESPACE_STD
3434
lib/libcxx/include/__ranges/zip_view.h+6-5
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___RANGES_ZIP_VIEW_H10#ifndef _LIBCPP___RANGES_ZIP_VIEW_H
10#define _LIBCPP___RANGES_ZIP_VIEW_H11#define _LIBCPP___RANGES_ZIP_VIEW_H
1112
...@@ -44,7 +45,7 @@ _LIBCPP_PUSH_MACROS...@@ -44,7 +45,7 @@ _LIBCPP_PUSH_MACROS
4445
45_LIBCPP_BEGIN_NAMESPACE_STD46_LIBCPP_BEGIN_NAMESPACE_STD
4647
47#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)48#if _LIBCPP_STD_VER > 20
4849
49namespace ranges {50namespace ranges {
5051
...@@ -402,15 +403,15 @@ public:...@@ -402,15 +403,15 @@ public:
402403
403 _LIBCPP_HIDE_FROM_ABI404 _LIBCPP_HIDE_FROM_ABI
404 friend constexpr auto iter_move(const __iterator& __i) noexcept(405 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>>&>())) && ...) &&
406 (is_nothrow_move_constructible_v<range_rvalue_reference_t<__maybe_const<_Const, _Views>>> && ...)) {407 (is_nothrow_move_constructible_v<range_rvalue_reference_t<__maybe_const<_Const, _Views>>> && ...)) {
407 return ranges::__tuple_transform(ranges::iter_move, __i.__current_);408 return ranges::__tuple_transform(ranges::iter_move, __i.__current_);
408 }409 }
409410
410 _LIBCPP_HIDE_FROM_ABI411 _LIBCPP_HIDE_FROM_ABI
411 friend constexpr void iter_swap(const __iterator& __l, const __iterator& __r) noexcept(412 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 (noexcept(ranges::iter_swap(std::declval<const iterator_t<__maybe_const<_Const, _Views>>&>(),
413 declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) &&414 std::declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) &&
414 ...))415 ...))
415 requires(indirectly_swappable<iterator_t<__maybe_const<_Const, _Views>>> && ...) {416 requires(indirectly_swappable<iterator_t<__maybe_const<_Const, _Views>>> && ...) {
416 ranges::__tuple_zip_for_each(ranges::iter_swap, __l.__current_, __r.__current_);417 ranges::__tuple_zip_for_each(ranges::iter_swap, __l.__current_, __r.__current_);
...@@ -502,7 +503,7 @@ inline namespace __cpo {...@@ -502,7 +503,7 @@ inline namespace __cpo {
502} // namespace views503} // namespace views
503} // namespace ranges504} // namespace ranges
504505
505#endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)506#endif // _LIBCPP_STD_VER > 20
506507
507_LIBCPP_END_NAMESPACE_STD508_LIBCPP_END_NAMESPACE_STD
508509
lib/libcxx/include/__split_buffer+99-92
...@@ -17,11 +17,14 @@...@@ -17,11 +17,14 @@
17#include <__iterator/distance.h>17#include <__iterator/distance.h>
18#include <__iterator/iterator_traits.h>18#include <__iterator/iterator_traits.h>
19#include <__iterator/move_iterator.h>19#include <__iterator/move_iterator.h>
20#include <__memory/allocate_at_least.h>
20#include <__memory/allocator.h>21#include <__memory/allocator.h>
22#include <__memory/allocator_traits.h>
21#include <__memory/compressed_pair.h>23#include <__memory/compressed_pair.h>
24#include <__memory/pointer_traits.h>
22#include <__memory/swap_allocator.h>25#include <__memory/swap_allocator.h>
23#include <__utility/forward.h>26#include <__utility/forward.h>
24#include <memory>27#include <__utility/move.h>
25#include <type_traits>28#include <type_traits>
2629
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -34,6 +37,10 @@ _LIBCPP_PUSH_MACROS...@@ -34,6 +37,10 @@ _LIBCPP_PUSH_MACROS
3437
35_LIBCPP_BEGIN_NAMESPACE_STD38_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
37template <class _Tp, class _Allocator = allocator<_Tp> >44template <class _Tp, class _Allocator = allocator<_Tp> >
38struct __split_buffer45struct __split_buffer
39{46{
...@@ -43,7 +50,7 @@ private:...@@ -43,7 +50,7 @@ private:
43public:50public:
44 typedef _Tp value_type;51 typedef _Tp value_type;
45 typedef _Allocator allocator_type;52 typedef _Allocator allocator_type;
46 typedef typename remove_reference<allocator_type>::type __alloc_rr;53 typedef __libcpp_remove_reference_t<allocator_type> __alloc_rr;
47 typedef allocator_traits<__alloc_rr> __alloc_traits;54 typedef allocator_traits<__alloc_rr> __alloc_traits;
48 typedef value_type& reference;55 typedef value_type& reference;
49 typedef const value_type& const_reference;56 typedef const value_type& const_reference;
...@@ -59,110 +66,110 @@ public:...@@ -59,110 +66,110 @@ public:
59 pointer __end_;66 pointer __end_;
60 __compressed_pair<pointer, allocator_type> __end_cap_;67 __compressed_pair<pointer, allocator_type> __end_cap_;
6168
62 typedef typename add_lvalue_reference<allocator_type>::type __alloc_ref;69 typedef __add_lvalue_reference_t<allocator_type> __alloc_ref;
63 typedef typename add_lvalue_reference<allocator_type>::type __alloc_const_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();}72 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __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();}73 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI 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();}74 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI 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();}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_VISIBILITY77 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
71 __split_buffer()78 __split_buffer()
72 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);79 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
73 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY80 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
74 explicit __split_buffer(__alloc_rr& __a);81 explicit __split_buffer(__alloc_rr& __a);
75 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY82 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
76 explicit __split_buffer(const __alloc_rr& __a);83 explicit __split_buffer(const __alloc_rr& __a);
77 _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);84 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
78 _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__split_buffer();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)
81 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);88 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
82 _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(__split_buffer&& __c, const __alloc_rr& __a);89 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer(__split_buffer&& __c, const __alloc_rr& __a);
83 _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer& operator=(__split_buffer&& __c)90 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer& operator=(__split_buffer&& __c)
84 _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&91 _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
85 is_nothrow_move_assignable<allocator_type>::value) ||92 is_nothrow_move_assignable<allocator_type>::value) ||
86 !__alloc_traits::propagate_on_container_move_assignment::value);93 !__alloc_traits::propagate_on_container_move_assignment::value);
8794
88 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;}95 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT {return __begin_;}
89 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;}96 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT {return __begin_;}
90 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return __end_;}97 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT {return __end_;}
91 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator end() const _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_VISIBILITY100 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
94 void clear() _NOEXCEPT101 void clear() _NOEXCEPT
95 {__destruct_at_end(__begin_);}102 {__destruct_at_end(__begin_);}
96 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast<size_type>(__end_ - __begin_);}103 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI 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_;}104 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI 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_);}105 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI 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_);}106 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI 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_);}107 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __back_spare() const {return static_cast<size_type>(__end_cap() - __end_);}
101108
102 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference front() {return *__begin_;}109 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() {return *__begin_;}
103 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference front() const {return *__begin_;}110 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const {return *__begin_;}
104 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference back() {return *(__end_ - 1);}111 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() {return *(__end_ - 1);}
105 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference back() const {return *(__end_ - 1);}112 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const {return *(__end_ - 1);}
106113
107 _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n);114 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n);
108 _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT;115 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT;
109 _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_front(const_reference __x);116 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_front(const_reference __x);
110 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);117 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(const_reference __x);
111 _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_front(value_type&& __x);118 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __x);
112 _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(value_type&& __x);119 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x);
113 template <class... _Args>120 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);}123 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_front() {__destruct_at_begin(__begin_+1);}
117 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-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);126 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n);
120 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n, const_reference __x);127 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n, const_reference __x);
121 template <class _InputIter>128 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>
123 __construct_at_end(_InputIter __first, _InputIter __last);130 __construct_at_end(_InputIter __first, _InputIter __last);
124 template <class _ForwardIterator>131 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>
126 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);133 __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)
129 {__destruct_at_begin(__new_begin, is_trivially_destructible<value_type>());}136 {__destruct_at_begin(__new_begin, is_trivially_destructible<value_type>());}
130 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY137 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
131 void __destruct_at_begin(pointer __new_begin, false_type);138 void __destruct_at_begin(pointer __new_begin, false_type);
132 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY139 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
133 void __destruct_at_begin(pointer __new_begin, true_type);140 void __destruct_at_begin(pointer __new_begin, true_type);
134141
135 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY142 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
136 void __destruct_at_end(pointer __new_last) _NOEXCEPT143 void __destruct_at_end(pointer __new_last) _NOEXCEPT
137 {__destruct_at_end(__new_last, false_type());}144 {__destruct_at_end(__new_last, false_type());}
138 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY145 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
139 void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT;146 void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT;
140 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY147 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
141 void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT;148 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)
144 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||151 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
145 __is_nothrow_swappable<__alloc_rr>::value);152 __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
149private:156private:
150 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY157 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
151 void __move_assign_alloc(__split_buffer& __c, true_type)158 void __move_assign_alloc(__split_buffer& __c, true_type)
152 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)159 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
153 {160 {
154 __alloc() = _VSTD::move(__c.__alloc());161 __alloc() = _VSTD::move(__c.__alloc());
155 }162 }
156163
157 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY164 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
158 void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT165 void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT
159 {}166 {}
160167
161 struct _ConstructTransaction {168 struct _ConstructTransaction {
162 _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT169 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT
163 : __pos_(*__p), __end_(*__p + __n), __dest_(__p) {170 : __pos_(*__p), __end_(*__p + __n), __dest_(__p) {
164 }171 }
165 _LIBCPP_CONSTEXPR_AFTER_CXX17 ~_ConstructTransaction() {172 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() {
166 *__dest_ = __pos_;173 *__dest_ = __pos_;
167 }174 }
168 pointer __pos_;175 pointer __pos_;
...@@ -173,7 +180,7 @@ private:...@@ -173,7 +180,7 @@ private:
173};180};
174181
175template <class _Tp, class _Allocator>182template <class _Tp, class _Allocator>
176_LIBCPP_CONSTEXPR_AFTER_CXX17183_LIBCPP_CONSTEXPR_SINCE_CXX20
177bool184bool
178__split_buffer<_Tp, _Allocator>::__invariants() const185__split_buffer<_Tp, _Allocator>::__invariants() const
179{186{
...@@ -204,7 +211,7 @@ __split_buffer<_Tp, _Allocator>::__invariants() const...@@ -204,7 +211,7 @@ __split_buffer<_Tp, _Allocator>::__invariants() const
204// Precondition: size() + __n <= capacity()211// Precondition: size() + __n <= capacity()
205// Postcondition: size() == size() + __n212// Postcondition: size() == size() + __n
206template <class _Tp, class _Allocator>213template <class _Tp, class _Allocator>
207_LIBCPP_CONSTEXPR_AFTER_CXX17214_LIBCPP_CONSTEXPR_SINCE_CXX20
208void215void
209__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)216__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)
210{217{
...@@ -221,7 +228,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)...@@ -221,7 +228,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)
221// Postcondition: size() == old size() + __n228// Postcondition: size() == old size() + __n
222// Postcondition: [i] == __x for all i in [size() - __n, __n)229// Postcondition: [i] == __x for all i in [size() - __n, __n)
223template <class _Tp, class _Allocator>230template <class _Tp, class _Allocator>
224_LIBCPP_CONSTEXPR_AFTER_CXX17231_LIBCPP_CONSTEXPR_SINCE_CXX20
225void232void
226__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)233__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
227{234{
...@@ -234,7 +241,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_referen...@@ -234,7 +241,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_referen
234241
235template <class _Tp, class _Allocator>242template <class _Tp, class _Allocator>
236template <class _InputIter>243template <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>
238__split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last)245__split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last)
239{246{
240 __alloc_rr& __a = this->__alloc();247 __alloc_rr& __a = this->__alloc();
...@@ -257,7 +264,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIt...@@ -257,7 +264,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIt
257264
258template <class _Tp, class _Allocator>265template <class _Tp, class _Allocator>
259template <class _ForwardIterator>266template <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>
261__split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)268__split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
262{269{
263 _ConstructTransaction __tx(&this->__end_, _VSTD::distance(__first, __last));270 _ConstructTransaction __tx(&this->__end_, _VSTD::distance(__first, __last));
...@@ -268,7 +275,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _F...@@ -268,7 +275,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _F
268}275}
269276
270template <class _Tp, class _Allocator>277template <class _Tp, class _Allocator>
271_LIBCPP_CONSTEXPR_AFTER_CXX17278_LIBCPP_CONSTEXPR_SINCE_CXX20
272inline279inline
273void280void
274__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type)281__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_...@@ -278,7 +285,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_
278}285}
279286
280template <class _Tp, class _Allocator>287template <class _Tp, class _Allocator>
281_LIBCPP_CONSTEXPR_AFTER_CXX17288_LIBCPP_CONSTEXPR_SINCE_CXX20
282inline289inline
283void290void
284__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type)291__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...@@ -287,8 +294,8 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_t
287}294}
288295
289template <class _Tp, class _Allocator>296template <class _Tp, class _Allocator>
290_LIBCPP_CONSTEXPR_AFTER_CXX17297_LIBCPP_CONSTEXPR_SINCE_CXX20
291inline _LIBCPP_INLINE_VISIBILITY298inline _LIBCPP_HIDE_FROM_ABI
292void299void
293__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT300__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT
294{301{
...@@ -297,8 +304,8 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_typ...@@ -297,8 +304,8 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_typ
297}304}
298305
299template <class _Tp, class _Allocator>306template <class _Tp, class _Allocator>
300_LIBCPP_CONSTEXPR_AFTER_CXX17307_LIBCPP_CONSTEXPR_SINCE_CXX20
301inline _LIBCPP_INLINE_VISIBILITY308inline _LIBCPP_HIDE_FROM_ABI
302void309void
303__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT310__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT
304{311{
...@@ -306,7 +313,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type...@@ -306,7 +313,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type
306}313}
307314
308template <class _Tp, class _Allocator>315template <class _Tp, class _Allocator>
309_LIBCPP_CONSTEXPR_AFTER_CXX17316_LIBCPP_CONSTEXPR_SINCE_CXX20
310__split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a)317__split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a)
311 : __end_cap_(nullptr, __a)318 : __end_cap_(nullptr, __a)
312{319{
...@@ -322,7 +329,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __sta...@@ -322,7 +329,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __sta
322}329}
323330
324template <class _Tp, class _Allocator>331template <class _Tp, class _Allocator>
325_LIBCPP_CONSTEXPR_AFTER_CXX17332_LIBCPP_CONSTEXPR_SINCE_CXX20
326inline333inline
327__split_buffer<_Tp, _Allocator>::__split_buffer()334__split_buffer<_Tp, _Allocator>::__split_buffer()
328 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)335 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
...@@ -331,7 +338,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer()...@@ -331,7 +338,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer()
331}338}
332339
333template <class _Tp, class _Allocator>340template <class _Tp, class _Allocator>
334_LIBCPP_CONSTEXPR_AFTER_CXX17341_LIBCPP_CONSTEXPR_SINCE_CXX20
335inline342inline
336__split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)343__split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
337 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)344 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
...@@ -339,7 +346,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)...@@ -339,7 +346,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
339}346}
340347
341template <class _Tp, class _Allocator>348template <class _Tp, class _Allocator>
342_LIBCPP_CONSTEXPR_AFTER_CXX17349_LIBCPP_CONSTEXPR_SINCE_CXX20
343inline350inline
344__split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)351__split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
345 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)352 : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
...@@ -347,7 +354,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)...@@ -347,7 +354,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
347}354}
348355
349template <class _Tp, class _Allocator>356template <class _Tp, class _Allocator>
350_LIBCPP_CONSTEXPR_AFTER_CXX17357_LIBCPP_CONSTEXPR_SINCE_CXX20
351__split_buffer<_Tp, _Allocator>::~__split_buffer()358__split_buffer<_Tp, _Allocator>::~__split_buffer()
352{359{
353 clear();360 clear();
...@@ -356,7 +363,7 @@ __split_buffer<_Tp, _Allocator>::~__split_buffer()...@@ -356,7 +363,7 @@ __split_buffer<_Tp, _Allocator>::~__split_buffer()
356}363}
357364
358template <class _Tp, class _Allocator>365template <class _Tp, class _Allocator>
359_LIBCPP_CONSTEXPR_AFTER_CXX17366_LIBCPP_CONSTEXPR_SINCE_CXX20
360__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)367__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
361 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)368 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
362 : __first_(_VSTD::move(__c.__first_)),369 : __first_(_VSTD::move(__c.__first_)),
...@@ -371,7 +378,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)...@@ -371,7 +378,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
371}378}
372379
373template <class _Tp, class _Allocator>380template <class _Tp, class _Allocator>
374_LIBCPP_CONSTEXPR_AFTER_CXX17381_LIBCPP_CONSTEXPR_SINCE_CXX20
375__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a)382__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a)
376 : __end_cap_(nullptr, __a)383 : __end_cap_(nullptr, __a)
377{384{
...@@ -398,7 +405,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __al...@@ -398,7 +405,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __al
398}405}
399406
400template <class _Tp, class _Allocator>407template <class _Tp, class _Allocator>
401_LIBCPP_CONSTEXPR_AFTER_CXX17408_LIBCPP_CONSTEXPR_SINCE_CXX20
402__split_buffer<_Tp, _Allocator>&409__split_buffer<_Tp, _Allocator>&
403__split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)410__split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
404 _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&411 _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
...@@ -419,7 +426,7 @@ __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)...@@ -419,7 +426,7 @@ __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
419}426}
420427
421template <class _Tp, class _Allocator>428template <class _Tp, class _Allocator>
422_LIBCPP_CONSTEXPR_AFTER_CXX17429_LIBCPP_CONSTEXPR_SINCE_CXX20
423void430void
424__split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)431__split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
425 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||432 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
...@@ -433,7 +440,7 @@ __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)...@@ -433,7 +440,7 @@ __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
433}440}
434441
435template <class _Tp, class _Allocator>442template <class _Tp, class _Allocator>
436_LIBCPP_CONSTEXPR_AFTER_CXX17443_LIBCPP_CONSTEXPR_SINCE_CXX20
437void444void
438__split_buffer<_Tp, _Allocator>::reserve(size_type __n)445__split_buffer<_Tp, _Allocator>::reserve(size_type __n)
439{446{
...@@ -450,7 +457,7 @@ __split_buffer<_Tp, _Allocator>::reserve(size_type __n)...@@ -450,7 +457,7 @@ __split_buffer<_Tp, _Allocator>::reserve(size_type __n)
450}457}
451458
452template <class _Tp, class _Allocator>459template <class _Tp, class _Allocator>
453_LIBCPP_CONSTEXPR_AFTER_CXX17460_LIBCPP_CONSTEXPR_SINCE_CXX20
454void461void
455__split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT462__split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
456{463{
...@@ -478,7 +485,7 @@ __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT...@@ -478,7 +485,7 @@ __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
478}485}
479486
480template <class _Tp, class _Allocator>487template <class _Tp, class _Allocator>
481_LIBCPP_CONSTEXPR_AFTER_CXX17488_LIBCPP_CONSTEXPR_SINCE_CXX20
482void489void
483__split_buffer<_Tp, _Allocator>::push_front(const_reference __x)490__split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
484{491{
...@@ -493,7 +500,7 @@ __split_buffer<_Tp, _Allocator>::push_front(const_reference __x)...@@ -493,7 +500,7 @@ __split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
493 }500 }
494 else501 else
495 {502 {
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);
497 __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc());504 __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc());
498 __t.__construct_at_end(move_iterator<pointer>(__begin_),505 __t.__construct_at_end(move_iterator<pointer>(__begin_),
499 move_iterator<pointer>(__end_));506 move_iterator<pointer>(__end_));
...@@ -508,7 +515,7 @@ __split_buffer<_Tp, _Allocator>::push_front(const_reference __x)...@@ -508,7 +515,7 @@ __split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
508}515}
509516
510template <class _Tp, class _Allocator>517template <class _Tp, class _Allocator>
511_LIBCPP_CONSTEXPR_AFTER_CXX17518_LIBCPP_CONSTEXPR_SINCE_CXX20
512void519void
513__split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)520__split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
514{521{
...@@ -523,7 +530,7 @@ __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)...@@ -523,7 +530,7 @@ __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
523 }530 }
524 else531 else
525 {532 {
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);
527 __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc());534 __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc());
528 __t.__construct_at_end(move_iterator<pointer>(__begin_),535 __t.__construct_at_end(move_iterator<pointer>(__begin_),
529 move_iterator<pointer>(__end_));536 move_iterator<pointer>(__end_));
...@@ -539,8 +546,8 @@ __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)...@@ -539,8 +546,8 @@ __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
539}546}
540547
541template <class _Tp, class _Allocator>548template <class _Tp, class _Allocator>
542_LIBCPP_CONSTEXPR_AFTER_CXX17549_LIBCPP_CONSTEXPR_SINCE_CXX20
543inline _LIBCPP_INLINE_VISIBILITY550inline _LIBCPP_HIDE_FROM_ABI
544void551void
545__split_buffer<_Tp, _Allocator>::push_back(const_reference __x)552__split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
546{553{
...@@ -555,7 +562,7 @@ __split_buffer<_Tp, _Allocator>::push_back(const_reference __x)...@@ -555,7 +562,7 @@ __split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
555 }562 }
556 else563 else
557 {564 {
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);
559 __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());566 __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());
560 __t.__construct_at_end(move_iterator<pointer>(__begin_),567 __t.__construct_at_end(move_iterator<pointer>(__begin_),
561 move_iterator<pointer>(__end_));568 move_iterator<pointer>(__end_));
...@@ -570,7 +577,7 @@ __split_buffer<_Tp, _Allocator>::push_back(const_reference __x)...@@ -570,7 +577,7 @@ __split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
570}577}
571578
572template <class _Tp, class _Allocator>579template <class _Tp, class _Allocator>
573_LIBCPP_CONSTEXPR_AFTER_CXX17580_LIBCPP_CONSTEXPR_SINCE_CXX20
574void581void
575__split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)582__split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
576{583{
...@@ -585,7 +592,7 @@ __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)...@@ -585,7 +592,7 @@ __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
585 }592 }
586 else593 else
587 {594 {
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);
589 __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());596 __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());
590 __t.__construct_at_end(move_iterator<pointer>(__begin_),597 __t.__construct_at_end(move_iterator<pointer>(__begin_),
591 move_iterator<pointer>(__end_));598 move_iterator<pointer>(__end_));
...@@ -602,7 +609,7 @@ __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)...@@ -602,7 +609,7 @@ __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
602609
603template <class _Tp, class _Allocator>610template <class _Tp, class _Allocator>
604template <class... _Args>611template <class... _Args>
605_LIBCPP_CONSTEXPR_AFTER_CXX17612_LIBCPP_CONSTEXPR_SINCE_CXX20
606void613void
607__split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)614__split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
608{615{
...@@ -617,7 +624,7 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)...@@ -617,7 +624,7 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
617 }624 }
618 else625 else
619 {626 {
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);
621 __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());628 __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());
622 __t.__construct_at_end(move_iterator<pointer>(__begin_),629 __t.__construct_at_end(move_iterator<pointer>(__begin_),
623 move_iterator<pointer>(__end_));630 move_iterator<pointer>(__end_));
...@@ -633,8 +640,8 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)...@@ -633,8 +640,8 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
633}640}
634641
635template <class _Tp, class _Allocator>642template <class _Tp, class _Allocator>
636_LIBCPP_CONSTEXPR_AFTER_CXX17643_LIBCPP_CONSTEXPR_SINCE_CXX20
637inline _LIBCPP_INLINE_VISIBILITY644inline _LIBCPP_HIDE_FROM_ABI
638void645void
639swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y)646swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y)
640 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))647 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
lib/libcxx/include/__string/char_traits.h+229-320
...@@ -14,14 +14,16 @@...@@ -14,14 +14,16 @@
14#include <__algorithm/find_end.h>14#include <__algorithm/find_end.h>
15#include <__algorithm/find_first_of.h>15#include <__algorithm/find_first_of.h>
16#include <__algorithm/min.h>16#include <__algorithm/min.h>
17#include <__compare/ordering.h>
17#include <__config>18#include <__config>
18#include <__functional/hash.h>19#include <__functional/hash.h>
19#include <__iterator/iterator_traits.h>20#include <__iterator/iterator_traits.h>
21#include <__type_traits/is_constant_evaluated.h>
22#include <cstddef>
20#include <cstdint>23#include <cstdint>
21#include <cstdio>24#include <cstdio>
22#include <cstring>25#include <cstring>
23#include <iosfwd>26#include <iosfwd>
24#include <type_traits>
2527
26#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS28#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
27# include <cwchar> // for wmemcpy29# include <cwchar> // for wmemcpy
...@@ -37,35 +39,124 @@ _LIBCPP_PUSH_MACROS...@@ -37,35 +39,124 @@ _LIBCPP_PUSH_MACROS
37_LIBCPP_BEGIN_NAMESPACE_STD39_LIBCPP_BEGIN_NAMESPACE_STD
3840
39template <class _CharT>41template <class _CharT>
40struct _LIBCPP_TEMPLATE_VIS char_traits42struct 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
41{81{
42 typedef _CharT char_type;82 using char_type = _CharT;
43 typedef int int_type;83 using int_type = int;
44 typedef streamoff off_type;84 using off_type = streamoff;
45 typedef streampos pos_type;85 using pos_type = streampos;
46 typedef mbstate_t state_type;86 using state_type = mbstate_t;
4787
48 static inline void _LIBCPP_CONSTEXPR_AFTER_CXX1488 static inline void _LIBCPP_CONSTEXPR_SINCE_CXX17
49 assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}89 assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
50 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT90 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
51 {return __c1 == __c2;}91 {return __c1 == __c2;}
52 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT92 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
53 {return __c1 < __c2;}93 {return __c1 < __c2;}
5494
55 static _LIBCPP_CONSTEXPR_AFTER_CXX1495 static _LIBCPP_CONSTEXPR_SINCE_CXX17
56 int compare(const char_type* __s1, const char_type* __s2, size_t __n);96 int compare(const char_type* __s1, const char_type* __s2, size_t __n) {
57 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX1497 for (; __n; --__n, ++__s1, ++__s2)
58 size_t length(const char_type* __s);98 {
59 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX1499 if (lt(*__s1, *__s2))
60 const char_type* find(const char_type* __s, size_t __n, const char_type& __a);100 return -1;
61 static _LIBCPP_CONSTEXPR_AFTER_CXX17101 if (lt(*__s2, *__s1))
62 char_type* move(char_type* __s1, const char_type* __s2, size_t __n);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 }
63 _LIBCPP_INLINE_VISIBILITY141 _LIBCPP_INLINE_VISIBILITY
64 static _LIBCPP_CONSTEXPR_AFTER_CXX17142 static _LIBCPP_CONSTEXPR_SINCE_CXX20
65 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n);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 }
66 _LIBCPP_INLINE_VISIBILITY152 _LIBCPP_INLINE_VISIBILITY
67 static _LIBCPP_CONSTEXPR_AFTER_CXX17153 static _LIBCPP_CONSTEXPR_SINCE_CXX20
68 char_type* assign(char_type* __s, size_t __n, char_type __a);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
70 static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT161 static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
71 {return eq_int_type(__c, eof()) ? ~eof() : __c;}162 {return eq_int_type(__c, eof()) ? ~eof() : __c;}
...@@ -80,92 +171,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits...@@ -80,92 +171,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits
80};171};
81172
82template <class _CharT>173template <class _CharT>
83_LIBCPP_CONSTEXPR_AFTER_CXX14 int174_LIBCPP_HIDE_FROM_ABI static inline _LIBCPP_CONSTEXPR_SINCE_CXX20
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
169_CharT* __char_traits_move(_CharT* __dest, const _CharT* __source, size_t __n) _NOEXCEPT175_CharT* __char_traits_move(_CharT* __dest, const _CharT* __source, size_t __n) _NOEXCEPT
170{176{
171#ifdef _LIBCPP_COMPILER_GCC177#ifdef _LIBCPP_COMPILER_GCC
...@@ -188,45 +194,45 @@ _CharT* __char_traits_move(_CharT* __dest, const _CharT* __source, size_t __n) _...@@ -188,45 +194,45 @@ _CharT* __char_traits_move(_CharT* __dest, const _CharT* __source, size_t __n) _
188template <>194template <>
189struct _LIBCPP_TEMPLATE_VIS char_traits<char>195struct _LIBCPP_TEMPLATE_VIS char_traits<char>
190{196{
191 typedef char char_type;197 using char_type = char;
192 typedef int int_type;198 using int_type = int;
193 typedef streamoff off_type;199 using off_type = streamoff;
194 typedef streampos pos_type;200 using pos_type = streampos;
195 typedef mbstate_t state_type;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_CXX14206 static inline _LIBCPP_CONSTEXPR_SINCE_CXX17
198 void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}207 void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
199 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT208 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
200 {return __c1 == __c2;}209 {return __c1 == __c2;}
201 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT210 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
202 {return (unsigned char)__c1 < (unsigned char)__c2;}211 {return (unsigned char)__c1 < (unsigned char)__c2;}
203212
204 static _LIBCPP_CONSTEXPR_AFTER_CXX14213 static _LIBCPP_CONSTEXPR_SINCE_CXX17 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
205 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 {219 static inline size_t _LIBCPP_CONSTEXPR_SINCE_CXX17 length(const char_type* __s) _NOEXCEPT {
208 // GCC currently does not support __builtin_strlen during constant evaluation.220 return std::__constexpr_strlen(__s);
209 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70816221 }
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 }
220222
221 static _LIBCPP_CONSTEXPR_AFTER_CXX14223 static _LIBCPP_CONSTEXPR_SINCE_CXX17
222 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;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_CXX17230 static inline _LIBCPP_CONSTEXPR_SINCE_CXX20
225 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {231 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
226 return std::__char_traits_move(__s1, __s2, __n);232 return std::__char_traits_move(__s1, __s2, __n);
227 }233 }
228234
229 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17235 static inline _LIBCPP_CONSTEXPR_SINCE_CXX20
230 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {236 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
231 if (!__libcpp_is_constant_evaluated())237 if (!__libcpp_is_constant_evaluated())
232 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");238 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
...@@ -234,7 +240,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char>...@@ -234,7 +240,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char>
234 return __s1;240 return __s1;
235 }241 }
236242
237 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17243 static inline _LIBCPP_CONSTEXPR_SINCE_CXX20
238 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {244 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
239 std::fill_n(__s, __n, __a);245 std::fill_n(__s, __n, __a);
240 return __s;246 return __s;
...@@ -252,82 +258,51 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char>...@@ -252,82 +258,51 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char>
252 {return int_type(EOF);}258 {return int_type(EOF);}
253};259};
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
299// char_traits<wchar_t>261// char_traits<wchar_t>
300262
301#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS263#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
302template <>264template <>
303struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t>265struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t>
304{266{
305 typedef wchar_t char_type;267 using char_type = wchar_t;
306 typedef wint_t int_type;268 using int_type = wint_t;
307 typedef streamoff off_type;269 using off_type = streamoff;
308 typedef streampos pos_type;270 using pos_type = streampos;
309 typedef mbstate_t state_type;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_CXX14276 static inline _LIBCPP_CONSTEXPR_SINCE_CXX17
312 void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}277 void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
313 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT278 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
314 {return __c1 == __c2;}279 {return __c1 == __c2;}
315 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT280 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
316 {return __c1 < __c2;}281 {return __c1 < __c2;}
317282
318 static _LIBCPP_CONSTEXPR_AFTER_CXX14283 static _LIBCPP_CONSTEXPR_SINCE_CXX17 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
319 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;284 if (__n == 0)
320 static _LIBCPP_CONSTEXPR_AFTER_CXX14285 return 0;
321 size_t length(const char_type* __s) _NOEXCEPT;286 return std::__constexpr_wmemcmp(__s1, __s2, __n);
322 static _LIBCPP_CONSTEXPR_AFTER_CXX14287 }
323 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;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_CXX17300 static inline _LIBCPP_CONSTEXPR_SINCE_CXX20
326 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {301 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
327 return std::__char_traits_move(__s1, __s2, __n);302 return std::__char_traits_move(__s1, __s2, __n);
328 }303 }
329304
330 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17305 static inline _LIBCPP_CONSTEXPR_SINCE_CXX20
331 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {306 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
332 if (!__libcpp_is_constant_evaluated())307 if (!__libcpp_is_constant_evaluated())
333 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");308 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
...@@ -335,7 +310,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t>...@@ -335,7 +310,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t>
335 return __s1;310 return __s1;
336 }311 }
337312
338 static inline _LIBCPP_CONSTEXPR_AFTER_CXX17313 static inline _LIBCPP_CONSTEXPR_SINCE_CXX20
339 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {314 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
340 std::fill_n(__s, __n, __a);315 std::fill_n(__s, __n, __a);
341 return __s;316 return __s;
...@@ -352,65 +327,6 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t>...@@ -352,65 +327,6 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t>
352 static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT327 static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
353 {return int_type(WEOF);}328 {return int_type(WEOF);}
354};329};
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}
414#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS330#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
415331
416#ifndef _LIBCPP_HAS_NO_CHAR8_T332#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& __...@@ -418,11 +334,14 @@ char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __
418template <>334template <>
419struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>335struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
420{336{
421 typedef char8_t char_type;337 using char_type = char8_t;
422 typedef unsigned int int_type;338 using int_type = unsigned int;
423 typedef streamoff off_type;339 using off_type = streamoff;
424 typedef u8streampos pos_type;340 using pos_type = u8streampos;
425 typedef mbstate_t state_type;341 using state_type = mbstate_t;
342#if _LIBCPP_STD_VER > 17
343 using comparison_category = strong_ordering;
344#endif
426345
427 static inline constexpr void assign(char_type& __c1, const char_type& __c2) noexcept346 static inline constexpr void assign(char_type& __c1, const char_type& __c2) noexcept
428 {__c1 = __c2;}347 {__c1 = __c2;}
...@@ -431,8 +350,10 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>...@@ -431,8 +350,10 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
431 static inline constexpr bool lt(char_type __c1, char_type __c2) noexcept350 static inline constexpr bool lt(char_type __c1, char_type __c2) noexcept
432 {return __c1 < __c2;}351 {return __c1 < __c2;}
433352
434 static constexpr353 static _LIBCPP_HIDE_FROM_ABI constexpr int
435 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;354 compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
355 return std::__constexpr_memcmp(__s1, __s2, __n);
356 }
436357
437 static constexpr358 static constexpr
438 size_t length(const char_type* __s) _NOEXCEPT;359 size_t length(const char_type* __s) _NOEXCEPT;
...@@ -440,12 +361,12 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>...@@ -440,12 +361,12 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
440 _LIBCPP_INLINE_VISIBILITY static constexpr361 _LIBCPP_INLINE_VISIBILITY static constexpr
441 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;362 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
442363
443 static _LIBCPP_CONSTEXPR_AFTER_CXX17364 static _LIBCPP_CONSTEXPR_SINCE_CXX20
444 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {365 char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
445 return std::__char_traits_move(__s1, __s2, __n);366 return std::__char_traits_move(__s1, __s2, __n);
446 }367 }
447368
448 static _LIBCPP_CONSTEXPR_AFTER_CXX17369 static _LIBCPP_CONSTEXPR_SINCE_CXX20
449 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {370 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
450 if (!__libcpp_is_constant_evaluated())371 if (!__libcpp_is_constant_evaluated())
451 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");372 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
...@@ -453,7 +374,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>...@@ -453,7 +374,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
453 return __s1;374 return __s1;
454 }375 }
455376
456 static _LIBCPP_CONSTEXPR_AFTER_CXX17377 static _LIBCPP_CONSTEXPR_SINCE_CXX20
457 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {378 char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
458 std::fill_n(__s, __n, __a);379 std::fill_n(__s, __n, __a);
459 return __s;380 return __s;
...@@ -482,24 +403,6 @@ char_traits<char8_t>::length(const char_type* __s) _NOEXCEPT...@@ -482,24 +403,6 @@ char_traits<char8_t>::length(const char_type* __s) _NOEXCEPT
482 return __len;403 return __len;
483}404}
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
503// TODO use '__builtin_char_memchr' if it ever supports char8_t ??406// TODO use '__builtin_char_memchr' if it ever supports char8_t ??
504inline constexpr407inline constexpr
505const char8_t*408const char8_t*
...@@ -519,32 +422,35 @@ char_traits<char8_t>::find(const char_type* __s, size_t __n, const char_type& __...@@ -519,32 +422,35 @@ char_traits<char8_t>::find(const char_type* __s, size_t __n, const char_type& __
519template <>422template <>
520struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>423struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>
521{424{
522 typedef char16_t char_type;425 using char_type = char16_t;
523 typedef uint_least16_t int_type;426 using int_type = uint_least16_t;
524 typedef streamoff off_type;427 using off_type = streamoff;
525 typedef u16streampos pos_type;428 using pos_type = u16streampos;
526 typedef mbstate_t state_type;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_CXX14434 static inline _LIBCPP_CONSTEXPR_SINCE_CXX17
529 void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}435 void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
530 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT436 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
531 {return __c1 == __c2;}437 {return __c1 == __c2;}
532 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT438 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
533 {return __c1 < __c2;}439 {return __c1 < __c2;}
534440
535 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14441 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_SINCE_CXX17
536 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;442 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
537 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14443 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_SINCE_CXX17
538 size_t length(const char_type* __s) _NOEXCEPT;444 size_t length(const char_type* __s) _NOEXCEPT;
539 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14445 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_SINCE_CXX17
540 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;446 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
541447
542 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17448 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
543 static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {449 static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
544 return std::__char_traits_move(__s1, __s2, __n);450 return std::__char_traits_move(__s1, __s2, __n);
545 }451 }
546452
547 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17453 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
548 static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {454 static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
549 if (!__libcpp_is_constant_evaluated())455 if (!__libcpp_is_constant_evaluated())
550 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");456 _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
...@@ -552,7 +458,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>...@@ -552,7 +458,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>
552 return __s1;458 return __s1;
553 }459 }
554460
555 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17461 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
556 static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {462 static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
557 std::fill_n(__s, __n, __a);463 std::fill_n(__s, __n, __a);
558 return __s;464 return __s;
...@@ -570,7 +476,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>...@@ -570,7 +476,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>
570 {return int_type(0xFFFF);}476 {return int_type(0xFFFF);}
571};477};
572478
573inline _LIBCPP_CONSTEXPR_AFTER_CXX14479inline _LIBCPP_CONSTEXPR_SINCE_CXX17
574int480int
575char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT481char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
576{482{
...@@ -584,7 +490,7 @@ char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, siz...@@ -584,7 +490,7 @@ char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, siz
584 return 0;490 return 0;
585}491}
586492
587inline _LIBCPP_CONSTEXPR_AFTER_CXX14493inline _LIBCPP_CONSTEXPR_SINCE_CXX17
588size_t494size_t
589char_traits<char16_t>::length(const char_type* __s) _NOEXCEPT495char_traits<char16_t>::length(const char_type* __s) _NOEXCEPT
590{496{
...@@ -594,7 +500,7 @@ char_traits<char16_t>::length(const char_type* __s) _NOEXCEPT...@@ -594,7 +500,7 @@ char_traits<char16_t>::length(const char_type* __s) _NOEXCEPT
594 return __len;500 return __len;
595}501}
596502
597inline _LIBCPP_CONSTEXPR_AFTER_CXX14503inline _LIBCPP_CONSTEXPR_SINCE_CXX17
598const char16_t*504const char16_t*
599char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT505char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
600{506{
...@@ -610,38 +516,41 @@ char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& _...@@ -610,38 +516,41 @@ char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& _
610template <>516template <>
611struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t>517struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t>
612{518{
613 typedef char32_t char_type;519 using char_type = char32_t;
614 typedef uint_least32_t int_type;520 using int_type = uint_least32_t;
615 typedef streamoff off_type;521 using off_type = streamoff;
616 typedef u32streampos pos_type;522 using pos_type = u32streampos;
617 typedef mbstate_t state_type;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_CXX14528 static inline _LIBCPP_CONSTEXPR_SINCE_CXX17
620 void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}529 void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
621 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT530 static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
622 {return __c1 == __c2;}531 {return __c1 == __c2;}
623 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT532 static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
624 {return __c1 < __c2;}533 {return __c1 < __c2;}
625534
626 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14535 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_SINCE_CXX17
627 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;536 int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
628 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14537 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_SINCE_CXX17
629 size_t length(const char_type* __s) _NOEXCEPT;538 size_t length(const char_type* __s) _NOEXCEPT;
630 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14539 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_SINCE_CXX17
631 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;540 const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
632541
633 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17542 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
634 static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {543 static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
635 return std::__char_traits_move(__s1, __s2, __n);544 return std::__char_traits_move(__s1, __s2, __n);
636 }545 }
637546
638 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17547 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
639 static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {548 static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
640 std::copy_n(__s2, __n, __s1);549 std::copy_n(__s2, __n, __s1);
641 return __s1;550 return __s1;
642 }551 }
643552
644 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17553 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
645 static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {554 static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
646 std::fill_n(__s, __n, __a);555 std::fill_n(__s, __n, __a);
647 return __s;556 return __s;
...@@ -659,7 +568,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t>...@@ -659,7 +568,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t>
659 {return int_type(0xFFFFFFFF);}568 {return int_type(0xFFFFFFFF);}
660};569};
661570
662inline _LIBCPP_CONSTEXPR_AFTER_CXX14571inline _LIBCPP_CONSTEXPR_SINCE_CXX17
663int572int
664char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT573char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
665{574{
...@@ -673,7 +582,7 @@ char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, siz...@@ -673,7 +582,7 @@ char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, siz
673 return 0;582 return 0;
674}583}
675584
676inline _LIBCPP_CONSTEXPR_AFTER_CXX14585inline _LIBCPP_CONSTEXPR_SINCE_CXX17
677size_t586size_t
678char_traits<char32_t>::length(const char_type* __s) _NOEXCEPT587char_traits<char32_t>::length(const char_type* __s) _NOEXCEPT
679{588{
...@@ -683,7 +592,7 @@ char_traits<char32_t>::length(const char_type* __s) _NOEXCEPT...@@ -683,7 +592,7 @@ char_traits<char32_t>::length(const char_type* __s) _NOEXCEPT
683 return __len;592 return __len;
684}593}
685594
686inline _LIBCPP_CONSTEXPR_AFTER_CXX14595inline _LIBCPP_CONSTEXPR_SINCE_CXX17
687const char32_t*596const char32_t*
688char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT597char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
689{598{
...@@ -700,7 +609,7 @@ char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& _...@@ -700,7 +609,7 @@ char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& _
700609
701// __str_find610// __str_find
702template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>611template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
703inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY612inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
704__str_find(const _CharT *__p, _SizeT __sz,613__str_find(const _CharT *__p, _SizeT __sz,
705 _CharT __c, _SizeT __pos) _NOEXCEPT614 _CharT __c, _SizeT __pos) _NOEXCEPT
706{615{
...@@ -713,7 +622,7 @@ __str_find(const _CharT *__p, _SizeT __sz,...@@ -713,7 +622,7 @@ __str_find(const _CharT *__p, _SizeT __sz,
713}622}
714623
715template <class _CharT, class _Traits>624template <class _CharT, class _Traits>
716inline _LIBCPP_CONSTEXPR_AFTER_CXX11 const _CharT *625_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_SINCE_CXX14 const _CharT *
717__search_substring(const _CharT *__first1, const _CharT *__last1,626__search_substring(const _CharT *__first1, const _CharT *__last1,
718 const _CharT *__first2, const _CharT *__last2) _NOEXCEPT {627 const _CharT *__first2, const _CharT *__last2) _NOEXCEPT {
719 // Take advantage of knowing source and pattern lengths.628 // Take advantage of knowing source and pattern lengths.
...@@ -752,7 +661,7 @@ __search_substring(const _CharT *__first1, const _CharT *__last1,...@@ -752,7 +661,7 @@ __search_substring(const _CharT *__first1, const _CharT *__last1,
752}661}
753662
754template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>663template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
755inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY664inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
756__str_find(const _CharT *__p, _SizeT __sz,665__str_find(const _CharT *__p, _SizeT __sz,
757 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT666 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
758{667{
...@@ -762,7 +671,7 @@ __str_find(const _CharT *__p, _SizeT __sz,...@@ -762,7 +671,7 @@ __str_find(const _CharT *__p, _SizeT __sz,
762 if (__n == 0) // There is nothing to search, just return __pos.671 if (__n == 0) // There is nothing to search, just return __pos.
763 return __pos;672 return __pos;
764673
765 const _CharT *__r = __search_substring<_CharT, _Traits>(674 const _CharT *__r = std::__search_substring<_CharT, _Traits>(
766 __p + __pos, __p + __sz, __s, __s + __n);675 __p + __pos, __p + __sz, __s, __s + __n);
767676
768 if (__r == __p + __sz)677 if (__r == __p + __sz)
...@@ -774,7 +683,7 @@ __str_find(const _CharT *__p, _SizeT __sz,...@@ -774,7 +683,7 @@ __str_find(const _CharT *__p, _SizeT __sz,
774// __str_rfind683// __str_rfind
775684
776template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>685template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
777inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY686inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
778__str_rfind(const _CharT *__p, _SizeT __sz,687__str_rfind(const _CharT *__p, _SizeT __sz,
779 _CharT __c, _SizeT __pos) _NOEXCEPT688 _CharT __c, _SizeT __pos) _NOEXCEPT
780{689{
...@@ -793,7 +702,7 @@ __str_rfind(const _CharT *__p, _SizeT __sz,...@@ -793,7 +702,7 @@ __str_rfind(const _CharT *__p, _SizeT __sz,
793}702}
794703
795template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>704template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
796inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY705inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
797__str_rfind(const _CharT *__p, _SizeT __sz,706__str_rfind(const _CharT *__p, _SizeT __sz,
798 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT707 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
799{708{
...@@ -810,7 +719,7 @@ __str_rfind(const _CharT *__p, _SizeT __sz,...@@ -810,7 +719,7 @@ __str_rfind(const _CharT *__p, _SizeT __sz,
810719
811// __str_find_first_of720// __str_find_first_of
812template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>721template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
813inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY722inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
814__str_find_first_of(const _CharT *__p, _SizeT __sz,723__str_find_first_of(const _CharT *__p, _SizeT __sz,
815 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT724 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
816{725{
...@@ -826,7 +735,7 @@ __str_find_first_of(const _CharT *__p, _SizeT __sz,...@@ -826,7 +735,7 @@ __str_find_first_of(const _CharT *__p, _SizeT __sz,
826735
827// __str_find_last_of736// __str_find_last_of
828template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>737template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
829inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY738inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
830__str_find_last_of(const _CharT *__p, _SizeT __sz,739__str_find_last_of(const _CharT *__p, _SizeT __sz,
831 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT740 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
832 {741 {
...@@ -849,7 +758,7 @@ __str_find_last_of(const _CharT *__p, _SizeT __sz,...@@ -849,7 +758,7 @@ __str_find_last_of(const _CharT *__p, _SizeT __sz,
849758
850// __str_find_first_not_of759// __str_find_first_not_of
851template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>760template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
852inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY761inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
853__str_find_first_not_of(const _CharT *__p, _SizeT __sz,762__str_find_first_not_of(const _CharT *__p, _SizeT __sz,
854 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT763 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
855{764{
...@@ -865,7 +774,7 @@ __str_find_first_not_of(const _CharT *__p, _SizeT __sz,...@@ -865,7 +774,7 @@ __str_find_first_not_of(const _CharT *__p, _SizeT __sz,
865774
866775
867template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>776template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
868inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY777inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
869__str_find_first_not_of(const _CharT *__p, _SizeT __sz,778__str_find_first_not_of(const _CharT *__p, _SizeT __sz,
870 _CharT __c, _SizeT __pos) _NOEXCEPT779 _CharT __c, _SizeT __pos) _NOEXCEPT
871{780{
...@@ -882,7 +791,7 @@ __str_find_first_not_of(const _CharT *__p, _SizeT __sz,...@@ -882,7 +791,7 @@ __str_find_first_not_of(const _CharT *__p, _SizeT __sz,
882791
883// __str_find_last_not_of792// __str_find_last_not_of
884template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>793template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
885inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY794inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
886__str_find_last_not_of(const _CharT *__p, _SizeT __sz,795__str_find_last_not_of(const _CharT *__p, _SizeT __sz,
887 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT796 const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
888{797{
...@@ -898,7 +807,7 @@ __str_find_last_not_of(const _CharT *__p, _SizeT __sz,...@@ -898,7 +807,7 @@ __str_find_last_not_of(const _CharT *__p, _SizeT __sz,
898807
899808
900template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>809template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
901inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY810inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
902__str_find_last_not_of(const _CharT *__p, _SizeT __sz,811__str_find_last_not_of(const _CharT *__p, _SizeT __sz,
903 _CharT __c, _SizeT __pos) _NOEXCEPT812 _CharT __c, _SizeT __pos) _NOEXCEPT
904{813{
lib/libcxx/include/__support/android/locale_bionic.h+3-3
...@@ -7,8 +7,8 @@...@@ -7,8 +7,8 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H10#ifndef _LIBCPP___SUPPORT_ANDROID_LOCALE_BIONIC_H
11#define _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H11#define _LIBCPP___SUPPORT_ANDROID_LOCALE_BIONIC_H
1212
13#if defined(__BIONIC__)13#if defined(__BIONIC__)
1414
...@@ -72,4 +72,4 @@ strtol_l(const char* __nptr, char** __endptr, int __base, locale_t) {...@@ -72,4 +72,4 @@ strtol_l(const char* __nptr, char** __endptr, int __base, locale_t) {
72#endif // defined(__ANDROID__)72#endif // defined(__ANDROID__)
7373
74#endif // defined(__BIONIC__)74#endif // defined(__BIONIC__)
75#endif // _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H75#endif // _LIBCPP___SUPPORT_ANDROID_LOCALE_BIONIC_H
lib/libcxx/include/__support/fuchsia/xlocale.h+3-3
...@@ -7,8 +7,8 @@...@@ -7,8 +7,8 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_SUPPORT_FUCHSIA_XLOCALE_H10#ifndef _LIBCPP___SUPPORT_FUCHSIA_XLOCALE_H
11#define _LIBCPP_SUPPORT_FUCHSIA_XLOCALE_H11#define _LIBCPP___SUPPORT_FUCHSIA_XLOCALE_H
1212
13#if defined(__Fuchsia__)13#if defined(__Fuchsia__)
1414
...@@ -19,4 +19,4 @@...@@ -19,4 +19,4 @@
1919
20#endif // defined(__Fuchsia__)20#endif // defined(__Fuchsia__)
2121
22#endif // _LIBCPP_SUPPORT_FUCHSIA_XLOCALE_H22#endif // _LIBCPP___SUPPORT_FUCHSIA_XLOCALE_H
lib/libcxx/include/__support/ibm/gettod_zos.h+3-3
...@@ -7,8 +7,8 @@...@@ -7,8 +7,8 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_SUPPORT_IBM_GETTOD_ZOS_H10#ifndef _LIBCPP___SUPPORT_IBM_GETTOD_ZOS_H
11#define _LIBCPP_SUPPORT_IBM_GETTOD_ZOS_H11#define _LIBCPP___SUPPORT_IBM_GETTOD_ZOS_H
1212
13#include <time.h>13#include <time.h>
1414
...@@ -51,4 +51,4 @@ gettimeofdayMonotonic(struct timespec64* Output) {...@@ -51,4 +51,4 @@ gettimeofdayMonotonic(struct timespec64* Output) {
51 return 0;51 return 0;
52}52}
5353
54#endif // _LIBCPP_SUPPORT_IBM_GETTOD_ZOS_H54#endif // _LIBCPP___SUPPORT_IBM_GETTOD_ZOS_H
lib/libcxx/include/__support/ibm/locale_mgmt_zos.h+3-3
...@@ -7,8 +7,8 @@...@@ -7,8 +7,8 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_ZOS_H10#ifndef _LIBCPP___SUPPORT_IBM_LOCALE_MGMT_ZOS_H
11#define _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_ZOS_H11#define _LIBCPP___SUPPORT_IBM_LOCALE_MGMT_ZOS_H
1212
13#if defined(__MVS__)13#if defined(__MVS__)
14#include <locale.h>14#include <locale.h>
...@@ -50,4 +50,4 @@ locale_t uselocale(locale_t newloc);...@@ -50,4 +50,4 @@ locale_t uselocale(locale_t newloc);
50}50}
51#endif51#endif
52#endif // defined(__MVS__)52#endif // defined(__MVS__)
53#endif // _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_ZOS_H53#endif // _LIBCPP___SUPPORT_IBM_LOCALE_MGMT_ZOS_H
lib/libcxx/include/__support/ibm/nanosleep.h+3-3
...@@ -7,8 +7,8 @@...@@ -7,8 +7,8 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_SUPPORT_IBM_NANOSLEEP_H10#ifndef _LIBCPP___SUPPORT_IBM_NANOSLEEP_H
11#define _LIBCPP_SUPPORT_IBM_NANOSLEEP_H11#define _LIBCPP___SUPPORT_IBM_NANOSLEEP_H
1212
13#include <unistd.h>13#include <unistd.h>
1414
...@@ -52,4 +52,4 @@ inline int nanosleep(const struct timespec* __req, struct timespec* __rem) {...@@ -52,4 +52,4 @@ inline int nanosleep(const struct timespec* __req, struct timespec* __rem) {
52 return 0;52 return 0;
53}53}
5454
55#endif // _LIBCPP_SUPPORT_IBM_NANOSLEEP_H55#endif // _LIBCPP___SUPPORT_IBM_NANOSLEEP_H
lib/libcxx/include/__support/ibm/xlocale.h+3-3
...@@ -7,8 +7,8 @@...@@ -7,8 +7,8 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_SUPPORT_IBM_XLOCALE_H10#ifndef _LIBCPP___SUPPORT_IBM_XLOCALE_H
11#define _LIBCPP_SUPPORT_IBM_XLOCALE_H11#define _LIBCPP___SUPPORT_IBM_XLOCALE_H
1212
13#if defined(__MVS__)13#if defined(__MVS__)
14#include <__support/ibm/locale_mgmt_zos.h>14#include <__support/ibm/locale_mgmt_zos.h>
...@@ -126,4 +126,4 @@ vasprintf(char **strp, const char *fmt, va_list ap) {...@@ -126,4 +126,4 @@ vasprintf(char **strp, const char *fmt, va_list ap) {
126#ifdef __cplusplus126#ifdef __cplusplus
127}127}
128#endif128#endif
129#endif // _LIBCPP_SUPPORT_IBM_XLOCALE_H129#endif // _LIBCPP___SUPPORT_IBM_XLOCALE_H
lib/libcxx/include/__support/musl/xlocale.h+4-4
...@@ -14,8 +14,8 @@...@@ -14,8 +14,8 @@
14// in Musl.14// in Musl.
15//===----------------------------------------------------------------------===//15//===----------------------------------------------------------------------===//
1616
17#ifndef _LIBCPP_SUPPORT_MUSL_XLOCALE_H17#ifndef _LIBCPP___SUPPORT_MUSL_XLOCALE_H
18#define _LIBCPP_SUPPORT_MUSL_XLOCALE_H18#define _LIBCPP___SUPPORT_MUSL_XLOCALE_H
1919
20#include <cstdlib>20#include <cstdlib>
21#include <cwchar>21#include <cwchar>
...@@ -39,7 +39,7 @@ wcstoll_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {...@@ -39,7 +39,7 @@ wcstoll_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {
39 return ::wcstoll(__nptr, __endptr, __base);39 return ::wcstoll(__nptr, __endptr, __base);
40}40}
4141
42inline _LIBCPP_HIDE_FROM_ABI long long42inline _LIBCPP_HIDE_FROM_ABI unsigned long long
43wcstoull_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {43wcstoull_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {
44 return ::wcstoull(__nptr, __endptr, __base);44 return ::wcstoull(__nptr, __endptr, __base);
45}45}
...@@ -53,4 +53,4 @@ wcstold_l(const wchar_t *__nptr, wchar_t **__endptr, locale_t) {...@@ -53,4 +53,4 @@ wcstold_l(const wchar_t *__nptr, wchar_t **__endptr, locale_t) {
53}53}
54#endif54#endif
5555
56#endif // _LIBCPP_SUPPORT_MUSL_XLOCALE_H56#endif // _LIBCPP___SUPPORT_MUSL_XLOCALE_H
lib/libcxx/include/__support/newlib/xlocale.h+2-6
...@@ -6,15 +6,11 @@...@@ -6,15 +6,11 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#ifndef _LIBCPP_SUPPORT_NEWLIB_XLOCALE_H9#ifndef _LIBCPP___SUPPORT_NEWLIB_XLOCALE_H
10#define _LIBCPP_SUPPORT_NEWLIB_XLOCALE_H10#define _LIBCPP___SUPPORT_NEWLIB_XLOCALE_H
1111
12#if defined(_NEWLIB_VERSION)12#if defined(_NEWLIB_VERSION)
1313
14#include <cstdlib>
15#include <clocale>
16#include <cwctype>
17#include <ctype.h>
18#if !defined(__NEWLIB__) || __NEWLIB__ < 2 || \14#if !defined(__NEWLIB__) || __NEWLIB__ < 2 || \
19 __NEWLIB__ == 2 && __NEWLIB_MINOR__ < 515 __NEWLIB__ == 2 && __NEWLIB_MINOR__ < 5
20#include <__support/xlocale/__nop_locale_mgmt.h>16#include <__support/xlocale/__nop_locale_mgmt.h>
lib/libcxx/include/__support/openbsd/xlocale.h+2-2
...@@ -7,8 +7,8 @@...@@ -7,8 +7,8 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_SUPPORT_OPENBSD_XLOCALE_H10#ifndef _LIBCPP___SUPPORT_OPENBSD_XLOCALE_H
11#define _LIBCPP_SUPPORT_OPENBSD_XLOCALE_H11#define _LIBCPP___SUPPORT_OPENBSD_XLOCALE_H
1212
13#include <__support/xlocale/__strtonum_fallback.h>13#include <__support/xlocale/__strtonum_fallback.h>
14#include <clocale>14#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) {...@@ -43,7 +43,7 @@ strtol_l(const char *__nptr, char **__endptr, int __base, locale_t __loc) {
43}43}
4444
45inline _LIBCPP_HIDE_FROM_ABI unsigned long long45inline _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)
47 return ::strtoull(__nptr, __endptr, __base);47 return ::strtoull(__nptr, __endptr, __base);
48}48}
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 @@...@@ -7,13 +7,14 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H10#ifndef _LIBCPP___SUPPORT_WIN32_LOCALE_WIN32_H
11#define _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H11#define _LIBCPP___SUPPORT_WIN32_LOCALE_WIN32_H
1212
13#include <__config>13#include <__config>
14#include <cstddef>14#include <cstddef>
15#include <locale.h> // _locale_t15#include <locale.h> // _locale_t
16#include <stdio.h>16#include <stdio.h>
17#include <string>
1718
18#define _X_ALL LC_ALL19#define _X_ALL LC_ALL
19#define _X_COLLATE LC_COLLATE20#define _X_COLLATE LC_COLLATE
...@@ -50,92 +51,92 @@...@@ -50,92 +51,92 @@
50class __lconv_storage {51class __lconv_storage {
51public:52public:
52 __lconv_storage(const lconv *__lc_input) {53 __lconv_storage(const lconv *__lc_input) {
53 __lc = *__lc_input;54 __lc_ = *__lc_input;
5455
55 __decimal_point = __lc_input->decimal_point;56 __decimal_point_ = __lc_input->decimal_point;
56 __thousands_sep = __lc_input->thousands_sep;57 __thousands_sep_ = __lc_input->thousands_sep;
57 __grouping = __lc_input->grouping;58 __grouping_ = __lc_input->grouping;
58 __int_curr_symbol = __lc_input->int_curr_symbol;59 __int_curr_symbol_ = __lc_input->int_curr_symbol;
59 __currency_symbol = __lc_input->currency_symbol;60 __currency_symbol_ = __lc_input->currency_symbol;
60 __mon_decimal_point = __lc_input->mon_decimal_point;61 __mon_decimal_point_ = __lc_input->mon_decimal_point;
61 __mon_thousands_sep = __lc_input->mon_thousands_sep;62 __mon_thousands_sep_ = __lc_input->mon_thousands_sep;
62 __mon_grouping = __lc_input->mon_grouping;63 __mon_grouping_ = __lc_input->mon_grouping;
63 __positive_sign = __lc_input->positive_sign;64 __positive_sign_ = __lc_input->positive_sign;
64 __negative_sign = __lc_input->negative_sign;65 __negative_sign_ = __lc_input->negative_sign;
6566
66 __lc.decimal_point = const_cast<char *>(__decimal_point.c_str());67 __lc_.decimal_point = const_cast<char *>(__decimal_point_.c_str());
67 __lc.thousands_sep = const_cast<char *>(__thousands_sep.c_str());68 __lc_.thousands_sep = const_cast<char *>(__thousands_sep_.c_str());
68 __lc.grouping = const_cast<char *>(__grouping.c_str());69 __lc_.grouping = const_cast<char *>(__grouping_.c_str());
69 __lc.int_curr_symbol = const_cast<char *>(__int_curr_symbol.c_str());70 __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_.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_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_thousands_sep = const_cast<char *>(__mon_thousands_sep_.c_str());
73 __lc.mon_grouping = const_cast<char *>(__mon_grouping.c_str());74 __lc_.mon_grouping = const_cast<char *>(__mon_grouping_.c_str());
74 __lc.positive_sign = const_cast<char *>(__positive_sign.c_str());75 __lc_.positive_sign = const_cast<char *>(__positive_sign_.c_str());
75 __lc.negative_sign = const_cast<char *>(__negative_sign.c_str());76 __lc_.negative_sign = const_cast<char *>(__negative_sign_.c_str());
76 }77 }
7778
78 lconv *__get() {79 lconv *__get() {
79 return &__lc;80 return &__lc_;
80 }81 }
81private:82private:
82 lconv __lc;83 lconv __lc_;
83 std::string __decimal_point;84 std::string __decimal_point_;
84 std::string __thousands_sep;85 std::string __thousands_sep_;
85 std::string __grouping;86 std::string __grouping_;
86 std::string __int_curr_symbol;87 std::string __int_curr_symbol_;
87 std::string __currency_symbol;88 std::string __currency_symbol_;
88 std::string __mon_decimal_point;89 std::string __mon_decimal_point_;
89 std::string __mon_thousands_sep;90 std::string __mon_thousands_sep_;
90 std::string __mon_grouping;91 std::string __mon_grouping_;
91 std::string __positive_sign;92 std::string __positive_sign_;
92 std::string __negative_sign;93 std::string __negative_sign_;
93};94};
9495
95class locale_t {96class locale_t {
96public:97public:
97 locale_t()98 locale_t()
98 : __locale(nullptr), __locale_str(nullptr), __lc(nullptr) {}99 : __locale_(nullptr), __locale_str_(nullptr), __lc_(nullptr) {}
99 locale_t(std::nullptr_t)100 locale_t(std::nullptr_t)
100 : __locale(nullptr), __locale_str(nullptr), __lc(nullptr) {}101 : __locale_(nullptr), __locale_str_(nullptr), __lc_(nullptr) {}
101 locale_t(_locale_t __xlocale, const char* __xlocale_str)102 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) {}
103 locale_t(const locale_t &__l)104 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
106 ~locale_t() {107 ~locale_t() {
107 delete __lc;108 delete __lc_;
108 }109 }
109110
110 locale_t &operator =(const locale_t &__l) {111 locale_t &operator =(const locale_t &__l) {
111 __locale = __l.__locale;112 __locale_ = __l.__locale_;
112 __locale_str = __l.__locale_str;113 __locale_str_ = __l.__locale_str_;
113 // __lc not copied114 // __lc_ not copied
114 return *this;115 return *this;
115 }116 }
116117
117 friend bool operator==(const locale_t& __left, const locale_t& __right) {118 friend bool operator==(const locale_t& __left, const locale_t& __right) {
118 return __left.__locale == __right.__locale;119 return __left.__locale_ == __right.__locale_;
119 }120 }
120121
121 friend bool operator==(const locale_t& __left, int __right) {122 friend bool operator==(const locale_t& __left, int __right) {
122 return __left.__locale == nullptr && __right == 0;123 return __left.__locale_ == nullptr && __right == 0;
123 }124 }
124125
125 friend bool operator==(const locale_t& __left, long long __right) {126 friend bool operator==(const locale_t& __left, long long __right) {
126 return __left.__locale == nullptr && __right == 0;127 return __left.__locale_ == nullptr && __right == 0;
127 }128 }
128129
129 friend bool operator==(const locale_t& __left, std::nullptr_t) {130 friend bool operator==(const locale_t& __left, std::nullptr_t) {
130 return __left.__locale == nullptr;131 return __left.__locale_ == nullptr;
131 }132 }
132133
133 friend bool operator==(int __left, const locale_t& __right) {134 friend bool operator==(int __left, const locale_t& __right) {
134 return __left == 0 && nullptr == __right.__locale;135 return __left == 0 && nullptr == __right.__locale_;
135 }136 }
136137
137 friend bool operator==(std::nullptr_t, const locale_t& __right) {138 friend bool operator==(std::nullptr_t, const locale_t& __right) {
138 return nullptr == __right.__locale;139 return nullptr == __right.__locale_;
139 }140 }
140141
141 friend bool operator!=(const locale_t& __left, const locale_t& __right) {142 friend bool operator!=(const locale_t& __left, const locale_t& __right) {
...@@ -163,24 +164,24 @@ public:...@@ -163,24 +164,24 @@ public:
163 }164 }
164165
165 operator bool() const {166 operator bool() const {
166 return __locale != nullptr;167 return __locale_ != nullptr;
167 }168 }
168169
169 const char* __get_locale() const { return __locale_str; }170 const char* __get_locale() const { return __locale_str_; }
170171
171 operator _locale_t() const {172 operator _locale_t() const {
172 return __locale;173 return __locale_;
173 }174 }
174175
175 lconv *__store_lconv(const lconv *__input_lc) {176 lconv *__store_lconv(const lconv *__input_lc) {
176 delete __lc;177 delete __lc_;
177 __lc = new __lconv_storage(__input_lc);178 __lc_ = new __lconv_storage(__input_lc);
178 return __lc->__get();179 return __lc_->__get();
179 }180 }
180private:181private:
181 _locale_t __locale;182 _locale_t __locale_;
182 const char* __locale_str;183 const char* __locale_str_;
183 __lconv_storage *__lc = nullptr;184 __lconv_storage *__lc_ = nullptr;
184};185};
185186
186// Locale management functions187// Locale management functions
...@@ -278,4 +279,4 @@ inline int iswblank_l( wint_t __c, locale_t /*loc*/ )...@@ -278,4 +279,4 @@ inline int iswblank_l( wint_t __c, locale_t /*loc*/ )
278 return ( __c == L' ' || __c == L'\t' );279 return ( __c == L' ' || __c == L'\t' );
279}280}
280281
281#endif // _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H282#endif // _LIBCPP___SUPPORT_WIN32_LOCALE_WIN32_H
lib/libcxx/include/__support/xlocale/__nop_locale_mgmt.h+5-3
...@@ -7,8 +7,10 @@...@@ -7,8 +7,10 @@
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
99
10#ifndef _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H10#ifndef _LIBCPP___SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
11#define _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H11#define _LIBCPP___SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
12
13#include <__config>
1214
13#ifdef __cplusplus15#ifdef __cplusplus
14extern "C" {16extern "C" {
...@@ -53,4 +55,4 @@ uselocale(locale_t) {...@@ -53,4 +55,4 @@ uselocale(locale_t) {
53} // extern "C"55} // extern "C"
54#endif56#endif
5557
56#endif // _LIBCPP_SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H58#endif // _LIBCPP___SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
lib/libcxx/include/__support/xlocale/__posix_l_fallback.h+23-11
...@@ -12,8 +12,16 @@...@@ -12,8 +12,16 @@
12// Android's bionic and Newlib).12// Android's bionic and Newlib).
13//===----------------------------------------------------------------------===//13//===----------------------------------------------------------------------===//
1414
15#ifndef _LIBCPP_SUPPORT_XLOCALE_POSIX_L_FALLBACK_H15#ifndef _LIBCPP___SUPPORT_XLOCALE_POSIX_L_FALLBACK_H
16#define _LIBCPP_SUPPORT_XLOCALE_POSIX_L_FALLBACK_H16#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
18#ifdef __cplusplus26#ifdef __cplusplus
19extern "C" {27extern "C" {
...@@ -67,6 +75,15 @@ inline _LIBCPP_HIDE_FROM_ABI int isxdigit_l(int __c, locale_t) {...@@ -67,6 +75,15 @@ inline _LIBCPP_HIDE_FROM_ABI int isxdigit_l(int __c, locale_t) {
67 return ::isxdigit(__c);75 return ::isxdigit(__c);
68}76}
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
70inline _LIBCPP_HIDE_FROM_ABI int iswalnum_l(wint_t __c, locale_t) {87inline _LIBCPP_HIDE_FROM_ABI int iswalnum_l(wint_t __c, locale_t) {
71 return ::iswalnum(__c);88 return ::iswalnum(__c);
72}89}
...@@ -115,14 +132,6 @@ inline _LIBCPP_HIDE_FROM_ABI int iswxdigit_l(wint_t __c, locale_t) {...@@ -115,14 +132,6 @@ inline _LIBCPP_HIDE_FROM_ABI int iswxdigit_l(wint_t __c, locale_t) {
115 return ::iswxdigit(__c);132 return ::iswxdigit(__c);
116}133}
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
126inline _LIBCPP_HIDE_FROM_ABI wint_t towupper_l(wint_t __c, locale_t) {135inline _LIBCPP_HIDE_FROM_ABI wint_t towupper_l(wint_t __c, locale_t) {
127 return ::towupper(__c);136 return ::towupper(__c);
128}137}
...@@ -130,6 +139,7 @@ inline _LIBCPP_HIDE_FROM_ABI wint_t towupper_l(wint_t __c, locale_t) {...@@ -130,6 +139,7 @@ inline _LIBCPP_HIDE_FROM_ABI wint_t towupper_l(wint_t __c, locale_t) {
130inline _LIBCPP_HIDE_FROM_ABI wint_t towlower_l(wint_t __c, locale_t) {139inline _LIBCPP_HIDE_FROM_ABI wint_t towlower_l(wint_t __c, locale_t) {
131 return ::towlower(__c);140 return ::towlower(__c);
132}141}
142#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
133143
134inline _LIBCPP_HIDE_FROM_ABI int144inline _LIBCPP_HIDE_FROM_ABI int
135strcoll_l(const char *__s1, const char *__s2, locale_t) {145strcoll_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,...@@ -147,6 +157,7 @@ strftime_l(char *__s, size_t __max, const char *__format, const struct tm *__tm,
147 return ::strftime(__s, __max, __format, __tm);157 return ::strftime(__s, __max, __format, __tm);
148}158}
149159
160#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
150inline _LIBCPP_HIDE_FROM_ABI int161inline _LIBCPP_HIDE_FROM_ABI int
151wcscoll_l(const wchar_t *__ws1, const wchar_t *__ws2, locale_t) {162wcscoll_l(const wchar_t *__ws1, const wchar_t *__ws2, locale_t) {
152 return ::wcscoll(__ws1, __ws2);163 return ::wcscoll(__ws1, __ws2);
...@@ -156,9 +167,10 @@ inline _LIBCPP_HIDE_FROM_ABI size_t...@@ -156,9 +167,10 @@ inline _LIBCPP_HIDE_FROM_ABI size_t
156wcsxfrm_l(wchar_t *__dest, const wchar_t *__src, size_t __n, locale_t) {167wcsxfrm_l(wchar_t *__dest, const wchar_t *__src, size_t __n, locale_t) {
157 return ::wcsxfrm(__dest, __src, __n);168 return ::wcsxfrm(__dest, __src, __n);
158}169}
170#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
159171
160#ifdef __cplusplus172#ifdef __cplusplus
161}173}
162#endif174#endif
163175
164#endif // _LIBCPP_SUPPORT_XLOCALE_POSIX_L_FALLBACK_H176#endif // _LIBCPP___SUPPORT_XLOCALE_POSIX_L_FALLBACK_H
lib/libcxx/include/__support/xlocale/__strtonum_fallback.h+12-3
...@@ -12,8 +12,15 @@...@@ -12,8 +12,15 @@
12// convert strings to some numeric type.12// convert strings to some numeric type.
13//===----------------------------------------------------------------------===//13//===----------------------------------------------------------------------===//
1414
15#ifndef _LIBCPP_SUPPORT_XLOCALE_STRTONUM_FALLBACK_H15#ifndef _LIBCPP___SUPPORT_XLOCALE_STRTONUM_FALLBACK_H
16#define _LIBCPP_SUPPORT_XLOCALE_STRTONUM_FALLBACK_H16#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
18#ifdef __cplusplus25#ifdef __cplusplus
19extern "C" {26extern "C" {
...@@ -44,6 +51,7 @@ strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t) {...@@ -44,6 +51,7 @@ strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t) {
44 return ::strtoull(__nptr, __endptr, __base);51 return ::strtoull(__nptr, __endptr, __base);
45}52}
4653
54#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
47inline _LIBCPP_HIDE_FROM_ABI long long55inline _LIBCPP_HIDE_FROM_ABI long long
48wcstoll_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {56wcstoll_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) {
49 return ::wcstoll(__nptr, __endptr, __base);57 return ::wcstoll(__nptr, __endptr, __base);
...@@ -58,9 +66,10 @@ inline _LIBCPP_HIDE_FROM_ABI long double...@@ -58,9 +66,10 @@ inline _LIBCPP_HIDE_FROM_ABI long double
58wcstold_l(const wchar_t *__nptr, wchar_t **__endptr, locale_t) {66wcstold_l(const wchar_t *__nptr, wchar_t **__endptr, locale_t) {
59 return ::wcstold(__nptr, __endptr);67 return ::wcstold(__nptr, __endptr);
60}68}
69#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
6170
62#ifdef __cplusplus71#ifdef __cplusplus
63}72}
64#endif73#endif
6574
66#endif // _LIBCPP_SUPPORT_XLOCALE_STRTONUM_FALLBACK_H75#endif // _LIBCPP___SUPPORT_XLOCALE_STRTONUM_FALLBACK_H
lib/libcxx/include/__thread/poll_with_backoff.h+1-3
...@@ -6,16 +6,14 @@...@@ -6,16 +6,14 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___THREAD_POLL_WITH_BACKOFF_H10#ifndef _LIBCPP___THREAD_POLL_WITH_BACKOFF_H
10#define _LIBCPP___THREAD_POLL_WITH_BACKOFF_H11#define _LIBCPP___THREAD_POLL_WITH_BACKOFF_H
1112
12#include <__availability>13#include <__availability>
13#include <__chrono/duration.h>14#include <__chrono/duration.h>
14#include <__chrono/high_resolution_clock.h>15#include <__chrono/high_resolution_clock.h>
15#include <__chrono/steady_clock.h>
16#include <__chrono/time_point.h>
17#include <__config>16#include <__config>
18#include <__filesystem/file_time_type.h>
1917
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header19# pragma GCC system_header
lib/libcxx/include/__thread/timed_backoff_policy.h+1
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP___THREAD_TIMED_BACKOFF_POLICY_H10#ifndef _LIBCPP___THREAD_TIMED_BACKOFF_POLICY_H
10#define _LIBCPP___THREAD_TIMED_BACKOFF_POLICY_H11#define _LIBCPP___THREAD_TIMED_BACKOFF_POLICY_H
1112
lib/libcxx/include/__threading_support+54-25
...@@ -13,7 +13,9 @@...@@ -13,7 +13,9 @@
13#include <__availability>13#include <__availability>
14#include <__chrono/convert_to_timespec.h>14#include <__chrono/convert_to_timespec.h>
15#include <__chrono/duration.h>15#include <__chrono/duration.h>
16#include <__compare/ordering.h>
16#include <__config>17#include <__config>
18#include <__fwd/hash.h>
17#include <__thread/poll_with_backoff.h>19#include <__thread/poll_with_backoff.h>
18#include <errno.h>20#include <errno.h>
19#include <iosfwd>21#include <iosfwd>
...@@ -609,40 +611,28 @@ class _LIBCPP_TEMPLATE_VIS __thread_id...@@ -609,40 +611,28 @@ class _LIBCPP_TEMPLATE_VIS __thread_id
609 // on other platforms. We assume 0 works everywhere for now.611 // on other platforms. We assume 0 works everywhere for now.
610 __libcpp_thread_id __id_;612 __libcpp_thread_id __id_;
611613
612public:614 static _LIBCPP_HIDE_FROM_ABI
613 _LIBCPP_INLINE_VISIBILITY615 bool __lt_impl(__thread_id __x, __thread_id __y) _NOEXCEPT
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
628 { // id==0 is always less than any other thread_id616 { // id==0 is always less than any other thread_id
629 if (__x.__id_ == 0) return __y.__id_ != 0;617 if (__x.__id_ == 0) return __y.__id_ != 0;
630 if (__y.__id_ == 0) return false;618 if (__y.__id_ == 0) return false;
631 return __libcpp_thread_id_less(__x.__id_, __y.__id_);619 return __libcpp_thread_id_less(__x.__id_, __y.__id_);
632 }620 }
633 friend _LIBCPP_INLINE_VISIBILITY621
634 bool operator<=(__thread_id __x, __thread_id __y) _NOEXCEPT622public:
635 {return !(__y < __x);}623 _LIBCPP_INLINE_VISIBILITY
636 friend _LIBCPP_INLINE_VISIBILITY624 __thread_id() _NOEXCEPT : __id_(0) {}
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);}
642625
643 _LIBCPP_INLINE_VISIBILITY626 _LIBCPP_INLINE_VISIBILITY
644 void __reset() { __id_ = 0; }627 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
646 template<class _CharT, class _Traits>636 template<class _CharT, class _Traits>
647 friend637 friend
648 _LIBCPP_INLINE_VISIBILITY638 _LIBCPP_INLINE_VISIBILITY
...@@ -658,6 +648,45 @@ private:...@@ -658,6 +648,45 @@ private:
658 friend struct _LIBCPP_TEMPLATE_VIS hash<__thread_id>;648 friend struct _LIBCPP_TEMPLATE_VIS hash<__thread_id>;
659};649};
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
661namespace this_thread690namespace this_thread
662{691{
663692
lib/libcxx/include/__tree+43-30
...@@ -14,14 +14,32 @@...@@ -14,14 +14,32 @@
14#include <__assert>14#include <__assert>
15#include <__config>15#include <__config>
16#include <__debug>16#include <__debug>
17#include <__functional/invoke.h>
17#include <__iterator/distance.h>18#include <__iterator/distance.h>
18#include <__iterator/iterator_traits.h>19#include <__iterator/iterator_traits.h>
19#include <__iterator/next.h>20#include <__iterator/next.h>
21#include <__memory/allocator_traits.h>
22#include <__memory/compressed_pair.h>
23#include <__memory/pointer_traits.h>
20#include <__memory/swap_allocator.h>24#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>
21#include <__utility/forward.h>38#include <__utility/forward.h>
39#include <__utility/move.h>
40#include <__utility/pair.h>
22#include <__utility/swap.h>41#include <__utility/swap.h>
23#include <limits>42#include <limits>
24#include <memory>
25#include <stdexcept>43#include <stdexcept>
2644
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)45#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -126,7 +144,7 @@ __tree_sub_invariant(_NodePtr __x)...@@ -126,7 +144,7 @@ __tree_sub_invariant(_NodePtr __x)
126// __root == nullptr is a proper tree. Returns true is __root is a proper144// __root == nullptr is a proper tree. Returns true is __root is a proper
127// red black tree, else returns false.145// red black tree, else returns false.
128template <class _NodePtr>146template <class _NodePtr>
129bool147_LIBCPP_HIDE_FROM_ABI bool
130__tree_invariant(_NodePtr __root)148__tree_invariant(_NodePtr __root)
131{149{
132 if (__root == nullptr)150 if (__root == nullptr)
...@@ -169,7 +187,7 @@ __tree_max(_NodePtr __x) _NOEXCEPT...@@ -169,7 +187,7 @@ __tree_max(_NodePtr __x) _NOEXCEPT
169187
170// Returns: pointer to the next in-order node after __x.188// Returns: pointer to the next in-order node after __x.
171template <class _NodePtr>189template <class _NodePtr>
172_NodePtr190_LIBCPP_HIDE_FROM_ABI _NodePtr
173__tree_next(_NodePtr __x) _NOEXCEPT191__tree_next(_NodePtr __x) _NOEXCEPT
174{192{
175 _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");193 _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
...@@ -211,7 +229,7 @@ __tree_prev_iter(_EndNodePtr __x) _NOEXCEPT...@@ -211,7 +229,7 @@ __tree_prev_iter(_EndNodePtr __x) _NOEXCEPT
211229
212// Returns: pointer to a node which has no children230// Returns: pointer to a node which has no children
213template <class _NodePtr>231template <class _NodePtr>
214_NodePtr232_LIBCPP_HIDE_FROM_ABI _NodePtr
215__tree_leaf(_NodePtr __x) _NOEXCEPT233__tree_leaf(_NodePtr __x) _NOEXCEPT
216{234{
217 _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");235 _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
...@@ -235,7 +253,7 @@ __tree_leaf(_NodePtr __x) _NOEXCEPT...@@ -235,7 +253,7 @@ __tree_leaf(_NodePtr __x) _NOEXCEPT
235// Effects: Makes __x->__right_ the subtree root with __x as its left child253// Effects: Makes __x->__right_ the subtree root with __x as its left child
236// while preserving in-order order.254// while preserving in-order order.
237template <class _NodePtr>255template <class _NodePtr>
238void256_LIBCPP_HIDE_FROM_ABI void
239__tree_left_rotate(_NodePtr __x) _NOEXCEPT257__tree_left_rotate(_NodePtr __x) _NOEXCEPT
240{258{
241 _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");259 _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
...@@ -256,7 +274,7 @@ __tree_left_rotate(_NodePtr __x) _NOEXCEPT...@@ -256,7 +274,7 @@ __tree_left_rotate(_NodePtr __x) _NOEXCEPT
256// Effects: Makes __x->__left_ the subtree root with __x as its right child274// Effects: Makes __x->__left_ the subtree root with __x as its right child
257// while preserving in-order order.275// while preserving in-order order.
258template <class _NodePtr>276template <class _NodePtr>
259void277_LIBCPP_HIDE_FROM_ABI void
260__tree_right_rotate(_NodePtr __x) _NOEXCEPT278__tree_right_rotate(_NodePtr __x) _NOEXCEPT
261{279{
262 _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");280 _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null");
...@@ -282,7 +300,7 @@ __tree_right_rotate(_NodePtr __x) _NOEXCEPT...@@ -282,7 +300,7 @@ __tree_right_rotate(_NodePtr __x) _NOEXCEPT
282// Postcondition: __tree_invariant(end_node->__left_) == true. end_node->__left_300// Postcondition: __tree_invariant(end_node->__left_) == true. end_node->__left_
283// may be different than the value passed in as __root.301// may be different than the value passed in as __root.
284template <class _NodePtr>302template <class _NodePtr>
285void303_LIBCPP_HIDE_FROM_ABI void
286__tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT304__tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT
287{305{
288 _LIBCPP_ASSERT(__root != nullptr, "Root of the tree shouldn't be null");306 _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...@@ -352,7 +370,7 @@ __tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT
352// nor any of its children refer to __z. end_node->__left_370// nor any of its children refer to __z. end_node->__left_
353// may be different than the value passed in as __root.371// may be different than the value passed in as __root.
354template <class _NodePtr>372template <class _NodePtr>
355void373_LIBCPP_HIDE_FROM_ABI void
356__tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT374__tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT
357{375{
358 _LIBCPP_ASSERT(__root != nullptr, "Root node should not be null");376 _LIBCPP_ASSERT(__root != nullptr, "Root node should not be null");
...@@ -554,7 +572,7 @@ template <class ..._Args>...@@ -554,7 +572,7 @@ template <class ..._Args>
554struct __is_tree_value_type : false_type {};572struct __is_tree_value_type : false_type {};
555573
556template <class _One>574template <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
559template <class _Tp>577template <class _Tp>
560struct __tree_key_value_types {578struct __tree_key_value_types {
...@@ -632,19 +650,17 @@ struct __tree_node_base_types {...@@ -632,19 +650,17 @@ struct __tree_node_base_types {
632 typedef _VoidPtr __void_pointer;650 typedef _VoidPtr __void_pointer;
633651
634 typedef __tree_node_base<__void_pointer> __node_base_type;652 typedef __tree_node_base<__void_pointer> __node_base_type;
635 typedef typename __rebind_pointer<_VoidPtr, __node_base_type>::type653 typedef __rebind_pointer_t<_VoidPtr, __node_base_type>
636 __node_base_pointer;654 __node_base_pointer;
637655
638 typedef __tree_end_node<__node_base_pointer> __end_node_type;656 typedef __tree_end_node<__node_base_pointer> __end_node_type;
639 typedef typename __rebind_pointer<_VoidPtr, __end_node_type>::type657 typedef __rebind_pointer_t<_VoidPtr, __end_node_type>
640 __end_node_pointer;658 __end_node_pointer;
641#if defined(_LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB)659#if defined(_LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB)
642 typedef __end_node_pointer __parent_pointer;660 typedef __end_node_pointer __parent_pointer;
643#else661#else
644 typedef typename conditional<662 typedef __conditional_t< is_pointer<__end_node_pointer>::value, __end_node_pointer, __node_base_pointer>
645 is_pointer<__end_node_pointer>::value,663 __parent_pointer;
646 __end_node_pointer,
647 __node_base_pointer>::type __parent_pointer;
648#endif664#endif
649665
650private:666private:
...@@ -659,9 +675,9 @@ struct __tree_map_pointer_types {};...@@ -659,9 +675,9 @@ struct __tree_map_pointer_types {};
659template <class _Tp, class _AllocPtr, class _KVTypes>675template <class _Tp, class _AllocPtr, class _KVTypes>
660struct __tree_map_pointer_types<_Tp, _AllocPtr, _KVTypes, true> {676struct __tree_map_pointer_types<_Tp, _AllocPtr, _KVTypes, true> {
661 typedef typename _KVTypes::__map_value_type _Mv;677 typedef typename _KVTypes::__map_value_type _Mv;
662 typedef typename __rebind_pointer<_AllocPtr, _Mv>::type678 typedef __rebind_pointer_t<_AllocPtr, _Mv>
663 __map_value_type_pointer;679 __map_value_type_pointer;
664 typedef typename __rebind_pointer<_AllocPtr, const _Mv>::type680 typedef __rebind_pointer_t<_AllocPtr, const _Mv>
665 __const_map_value_type_pointer;681 __const_map_value_type_pointer;
666};682};
667683
...@@ -683,28 +699,26 @@ public:...@@ -683,28 +699,26 @@ public:
683 typedef _NodePtr __node_pointer;699 typedef _NodePtr __node_pointer;
684700
685 typedef _Tp __node_value_type;701 typedef _Tp __node_value_type;
686 typedef typename __rebind_pointer<_VoidPtr, __node_value_type>::type702 typedef __rebind_pointer_t<_VoidPtr, __node_value_type>
687 __node_value_type_pointer;703 __node_value_type_pointer;
688 typedef typename __rebind_pointer<_VoidPtr, const __node_value_type>::type704 typedef __rebind_pointer_t<_VoidPtr, const __node_value_type>
689 __const_node_value_type_pointer;705 __const_node_value_type_pointer;
690#if defined(_LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB)706#if defined(_LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB)
691 typedef typename __base::__end_node_pointer __iter_pointer;707 typedef typename __base::__end_node_pointer __iter_pointer;
692#else708#else
693 typedef typename conditional<709 typedef __conditional_t< is_pointer<__node_pointer>::value, typename __base::__end_node_pointer, __node_pointer>
694 is_pointer<__node_pointer>::value,710 __iter_pointer;
695 typename __base::__end_node_pointer,
696 __node_pointer>::type __iter_pointer;
697#endif711#endif
698private:712private:
699 static_assert(!is_const<__node_type>::value,713 static_assert(!is_const<__node_type>::value,
700 "_NodePtr should never be a pointer to const");714 "_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>,
702 _NodePtr>::value), "_VoidPtr does not rebind to _NodePtr.");716 _NodePtr>::value), "_VoidPtr does not rebind to _NodePtr.");
703};717};
704718
705template <class _ValueTp, class _VoidPtr>719template <class _ValueTp, class _VoidPtr>
706struct __make_tree_node_types {720struct __make_tree_node_types {
707 typedef typename __rebind_pointer<_VoidPtr, __tree_node<_ValueTp, _VoidPtr> >::type721 typedef __rebind_pointer_t<_VoidPtr, __tree_node<_ValueTp, _VoidPtr> >
708 _NodePtr;722 _NodePtr;
709 typedef __tree_node_types<_NodePtr> type;723 typedef __tree_node_types<_NodePtr> type;
710};724};
...@@ -1019,7 +1033,7 @@ public:...@@ -1019,7 +1033,7 @@ public:
1019 typedef typename _NodeTypes::__parent_pointer __parent_pointer;1033 typedef typename _NodeTypes::__parent_pointer __parent_pointer;
1020 typedef typename _NodeTypes::__iter_pointer __iter_pointer;1034 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;
1023 typedef allocator_traits<__node_allocator> __node_traits;1037 typedef allocator_traits<__node_allocator> __node_traits;
10241038
1025private:1039private:
...@@ -1028,8 +1042,7 @@ private:...@@ -1028,8 +1042,7 @@ private:
1028 // the pointer using 'pointer_traits'.1042 // the pointer using 'pointer_traits'.
1029 static_assert((is_same<__node_pointer, typename __node_traits::pointer>::value),1043 static_assert((is_same<__node_pointer, typename __node_traits::pointer>::value),
1030 "Allocator does not rebind pointers in a sane manner.");1044 "Allocator does not rebind pointers in a sane manner.");
1031 typedef typename __rebind_alloc_helper<__node_traits, __node_base>::type1045 typedef __rebind_alloc<__node_traits, __node_base> __node_base_allocator;
1032 __node_base_allocator;
1033 typedef allocator_traits<__node_base_allocator> __node_base_traits;1046 typedef allocator_traits<__node_base_allocator> __node_base_traits;
1034 static_assert((is_same<__node_base_pointer, typename __node_base_traits::pointer>::value),1047 static_assert((is_same<__node_base_pointer, typename __node_base_traits::pointer>::value),
1035 "Allocator does not rebind pointers in a sane manner.");1048 "Allocator does not rebind pointers in a sane manner.");
...@@ -1271,14 +1284,14 @@ public:...@@ -1271,14 +1284,14 @@ public:
1271 }1284 }
12721285
1273 template <class _Vp,1286 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> >
1275 _LIBCPP_INLINE_VISIBILITY1288 _LIBCPP_INLINE_VISIBILITY
1276 pair<iterator, bool> __insert_unique(_Vp&& __v) {1289 pair<iterator, bool> __insert_unique(_Vp&& __v) {
1277 return __emplace_unique(_VSTD::forward<_Vp>(__v));1290 return __emplace_unique(_VSTD::forward<_Vp>(__v));
1278 }1291 }
12791292
1280 template <class _Vp,1293 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> >
1282 _LIBCPP_INLINE_VISIBILITY1295 _LIBCPP_INLINE_VISIBILITY
1283 iterator __insert_unique(const_iterator __p, _Vp&& __v) {1296 iterator __insert_unique(const_iterator __p, _Vp&& __v) {
1284 return __emplace_hint_unique(__p, _VSTD::forward<_Vp>(__v));1297 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 @@...@@ -18,14 +18,34 @@
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; };21#if __has_builtin(__add_lvalue_reference)
22template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp& type; };
2322
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference23template <class _Tp>
25{typedef _LIBCPP_NODEBUG typename __add_lvalue_reference_impl<_Tp>::type type;};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
27#if _LIBCPP_STD_VER > 1147#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>;
29#endif49#endif
3050
31_LIBCPP_END_NAMESPACE_STD51_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/add_pointer.h+21-7
...@@ -12,6 +12,7 @@...@@ -12,6 +12,7 @@
12#include <__config>12#include <__config>
13#include <__type_traits/is_referenceable.h>13#include <__type_traits/is_referenceable.h>
14#include <__type_traits/is_same.h>14#include <__type_traits/is_same.h>
15#include <__type_traits/is_void.h>
15#include <__type_traits/remove_cv.h>16#include <__type_traits/remove_cv.h>
16#include <__type_traits/remove_reference.h>17#include <__type_traits/remove_reference.h>
1718
...@@ -21,19 +22,32 @@...@@ -21,19 +22,32 @@
2122
22_LIBCPP_BEGIN_NAMESPACE_STD23_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
24template <class _Tp,31template <class _Tp,
25 bool = __is_referenceable<_Tp>::value ||32 bool = __libcpp_is_referenceable<_Tp>::value || is_void<_Tp>::value>
26 _IsSame<typename remove_cv<_Tp>::type, void>::value>33struct __add_pointer_impl {
27struct __add_pointer_impl34 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tp>* type;
28 {typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type* type;};35};
29template <class _Tp> struct __add_pointer_impl<_Tp, false>36template <class _Tp> struct __add_pointer_impl<_Tp, false>
30 {typedef _LIBCPP_NODEBUG _Tp type;};37 {typedef _LIBCPP_NODEBUG _Tp type;};
3138
32template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer39template <class _Tp>
33 {typedef _LIBCPP_NODEBUG typename __add_pointer_impl<_Tp>::type type;};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
35#if _LIBCPP_STD_VER > 1149#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>;
37#endif51#endif
3852
39_LIBCPP_END_NAMESPACE_STD53_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/add_rvalue_reference.h+26-5
...@@ -18,14 +18,35 @@...@@ -18,14 +18,35 @@
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; };21#if __has_builtin(__add_rvalue_reference)
22template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp&& type; };
2322
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference23template <class _Tp>
25{typedef _LIBCPP_NODEBUG typename __add_rvalue_reference_impl<_Tp>::type type;};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
27#if _LIBCPP_STD_VER > 1147#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>;
29#endif50#endif
3051
31_LIBCPP_END_NAMESPACE_STD52_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;...@@ -54,21 +54,13 @@ template <class _TL, size_t _Align> struct __find_pod;
54template <class _Hp, size_t _Align>54template <class _Hp, size_t _Align>
55struct __find_pod<__type_list<_Hp, __nat>, _Align>55struct __find_pod<__type_list<_Hp, __nat>, _Align>
56{56{
57 typedef typename conditional<57 typedef __conditional_t<_Align == _Hp::value, typename _Hp::type, __fallback_overaligned<_Align> > type;
58 _Align == _Hp::value,
59 typename _Hp::type,
60 __fallback_overaligned<_Align>
61 >::type type;
62};58};
6359
64template <class _Hp, class _Tp, size_t _Align>60template <class _Hp, class _Tp, size_t _Align>
65struct __find_pod<__type_list<_Hp, _Tp>, _Align>61struct __find_pod<__type_list<_Hp, _Tp>, _Align>
66{62{
67 typedef typename conditional<63 typedef __conditional_t<_Align == _Hp::value, typename _Hp::type, typename __find_pod<_Tp, _Align>::type> type;
68 _Align == _Hp::value,
69 typename _Hp::type,
70 typename __find_pod<_Tp, _Align>::type
71 >::type type;
72};64};
7365
74template <class _TL, size_t _Len> struct __find_max_align;66template <class _TL, size_t _Len> struct __find_max_align;
...@@ -91,7 +83,7 @@ struct __find_max_align<__type_list<_Hp, _Tp>, _Len>...@@ -91,7 +83,7 @@ struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
91 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};83 : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
9284
93template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>85template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
94struct _LIBCPP_TEMPLATE_VIS aligned_storage86struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_TEMPLATE_VIS aligned_storage
95{87{
96 typedef typename __find_pod<__all_types, _Align>::type _Aligner;88 typedef typename __find_pod<__all_types, _Align>::type _Aligner;
97 union type89 union type
...@@ -102,13 +94,17 @@ struct _LIBCPP_TEMPLATE_VIS aligned_storage...@@ -102,13 +94,17 @@ struct _LIBCPP_TEMPLATE_VIS aligned_storage
102};94};
10395
104#if _LIBCPP_STD_VER > 1196#if _LIBCPP_STD_VER > 11
97
98 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
105template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>99template <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
107#endif103#endif
108104
109#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \105#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
110template <size_t _Len>\106template <size_t _Len>\
111struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\107struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\
112{\108{\
113 struct _ALIGNAS(n) type\109 struct _ALIGNAS(n) type\
114 {\110 {\
lib/libcxx/include/__type_traits/aligned_union.h+3-2
...@@ -37,7 +37,7 @@ struct __static_max<_I0, _I1, _In...>...@@ -37,7 +37,7 @@ struct __static_max<_I0, _I1, _In...>
37};37};
3838
39template <size_t _Len, class _Type0, class ..._Types>39template <size_t _Len, class _Type0, class ..._Types>
40struct aligned_union40struct _LIBCPP_DEPRECATED_IN_CXX23 aligned_union
41{41{
42 static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0),42 static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0),
43 _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value;43 _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value;
...@@ -47,7 +47,8 @@ struct aligned_union...@@ -47,7 +47,8 @@ struct aligned_union
47};47};
4848
49#if _LIBCPP_STD_VER > 1149#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;
51#endif52#endif
5253
53_LIBCPP_END_NAMESPACE_STD54_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...@@ -24,7 +24,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of
2424
25#if _LIBCPP_STD_VER > 1425#if _LIBCPP_STD_VER > 14
26template <class _Tp>26template <class _Tp>
27inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value;27inline constexpr size_t alignment_of_v = _LIBCPP_ALIGNOF(_Tp);
28#endif28#endif
2929
30_LIBCPP_END_NAMESPACE_STD30_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/apply_cv.h+2-3
...@@ -10,7 +10,6 @@...@@ -10,7 +10,6 @@
10#define _LIBCPP___TYPE_TRAITS_APPLY_CV_H10#define _LIBCPP___TYPE_TRAITS_APPLY_CV_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_const.h>13#include <__type_traits/is_const.h>
15#include <__type_traits/is_volatile.h>14#include <__type_traits/is_volatile.h>
16#include <__type_traits/remove_reference.h>15#include <__type_traits/remove_reference.h>
...@@ -22,8 +21,8 @@...@@ -22,8 +21,8 @@
2221
23_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2423
25template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,24template <class _Tp, class _Up, bool = is_const<__libcpp_remove_reference_t<_Tp> >::value,
26 bool = is_volatile<typename remove_reference<_Tp>::type>::value>25 bool = is_volatile<__libcpp_remove_reference_t<_Tp> >::value>
27struct __apply_cv26struct __apply_cv
28{27{
29 typedef _LIBCPP_NODEBUG _Up type;28 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...@@ -31,7 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
31// Let COND_RES(X, Y) be:31// Let COND_RES(X, Y) be:
32template <class _Xp, class _Yp>32template <class _Xp, class _Yp>
33using __cond_res =33using __cond_res =
34 decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()());34 decltype(false ? std::declval<_Xp(&)()>()() : std::declval<_Yp(&)()>()());
3535
36// Let `XREF(A)` denote a unary alias template `T` such that `T<U>` denotes the same type as `U`36// Let `XREF(A)` denote a unary alias template `T` such that `T<U>` denotes the same type as `U`
37// with the addition of `A`'s cv and reference qualifiers, for a non-reference cv-unqualified type37// 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...@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
26#if _LIBCPP_STD_VER > 1726#if _LIBCPP_STD_VER > 17
27// Let COND_RES(X, Y) be:27// Let COND_RES(X, Y) be:
28template <class _Tp, class _Up>28template <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
31template <class _Tp, class _Up, class = void>31template <class _Tp, class _Up, class = void>
32struct __common_type3 {};32struct __common_type3 {};
...@@ -47,13 +47,10 @@ struct __common_type2_imp {};...@@ -47,13 +47,10 @@ struct __common_type2_imp {};
4747
48// sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..."48// sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..."
49template <class _Tp, class _Up>49template <class _Tp, class _Up>
50struct __common_type2_imp<_Tp, _Up,50struct __common_type2_imp<_Tp, _Up, __void_t<decltype(true ? std::declval<_Tp>() : std::declval<_Up>())> >
51 typename __void_t<decltype(
52 true ? declval<_Tp>() : declval<_Up>()
53 )>::type>
54{51{
55 typedef _LIBCPP_NODEBUG typename decay<decltype(52 typedef _LIBCPP_NODEBUG typename decay<decltype(
56 true ? declval<_Tp>() : declval<_Up>()53 true ? std::declval<_Tp>() : std::declval<_Up>()
57 )>::type type;54 )>::type type;
58};55};
5956
...@@ -82,8 +79,7 @@ struct common_type {...@@ -82,8 +79,7 @@ struct common_type {
8279
83template <class _Tp, class _Up>80template <class _Tp, class _Up>
84struct __common_type_impl<81struct __common_type_impl<
85 __common_types<_Tp, _Up>,82 __common_types<_Tp, _Up>, __void_t<typename common_type<_Tp, _Up>::type> >
86 typename __void_t<typename common_type<_Tp, _Up>::type>::type>
87{83{
88 typedef typename common_type<_Tp, _Up>::type type;84 typedef typename common_type<_Tp, _Up>::type type;
89};85};
...@@ -91,7 +87,7 @@ struct __common_type_impl<...@@ -91,7 +87,7 @@ struct __common_type_impl<
91template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>87template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)>
92struct __common_type_impl<88struct __common_type_impl<
93 __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>,89 __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> >
95 : __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type,91 : __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type,
96 _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {92 _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {
97};93};
lib/libcxx/include/__type_traits/conditional.h+9-4
...@@ -36,17 +36,22 @@ template <bool _Cond, class _IfRes, class _ElseRes>...@@ -36,17 +36,22 @@ template <bool _Cond, class _IfRes, class _ElseRes>
36using _If _LIBCPP_NODEBUG = typename _IfImpl<_Cond>::template _Select<_IfRes, _ElseRes>;36using _If _LIBCPP_NODEBUG = typename _IfImpl<_Cond>::template _Select<_IfRes, _ElseRes>;
3737
38template <bool _Bp, class _If, class _Then>38template <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};
40template <class _If, class _Then>42template <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
43#if _LIBCPP_STD_VER > 1147#if _LIBCPP_STD_VER > 11
44template <bool _Bp, class _IfRes, class _ElseRes>48template <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;
46#endif50#endif
4751
48// Helper so we can use "conditional_t" in all language versions.52// 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
51_LIBCPP_END_NAMESPACE_STD56_LIBCPP_END_NAMESPACE_STD
5257
lib/libcxx/include/__type_traits/conjunction.h+22-21
...@@ -20,26 +20,6 @@...@@ -20,26 +20,6 @@
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_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
43template <class...>23template <class...>
44using __expand_to_true = true_type;24using __expand_to_true = true_type;
4525
...@@ -49,8 +29,29 @@ __expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int);...@@ -49,8 +29,29 @@ __expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int);
49template <class...>29template <class...>
50false_type __and_helper(...);30false_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...>`.
52template <class... _Pred>37template <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
55_LIBCPP_END_NAMESPACE_STD56_LIBCPP_END_NAMESPACE_STD
5657
lib/libcxx/include/__type_traits/copy_cvref.h+2-2
...@@ -29,13 +29,13 @@ struct __copy_cvref...@@ -29,13 +29,13 @@ struct __copy_cvref
29template <class _From, class _To>29template <class _From, class _To>
30struct __copy_cvref<_From&, _To>30struct __copy_cvref<_From&, _To>
31{31{
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> >;
33};33};
3434
35template <class _From, class _To>35template <class _From, class _To>
36struct __copy_cvref<_From&&, _To>36struct __copy_cvref<_From&&, _To>
37{37{
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> >;
39};39};
4040
41template <class _From, class _To>41template <class _From, class _To>
lib/libcxx/include/__type_traits/decay.h+12-6
...@@ -12,7 +12,6 @@...@@ -12,7 +12,6 @@
12#include <__config>12#include <__config>
13#include <__type_traits/add_pointer.h>13#include <__type_traits/add_pointer.h>
14#include <__type_traits/conditional.h>14#include <__type_traits/conditional.h>
15#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_array.h>15#include <__type_traits/is_array.h>
17#include <__type_traits/is_function.h>16#include <__type_traits/is_function.h>
18#include <__type_traits/is_referenceable.h>17#include <__type_traits/is_referenceable.h>
...@@ -26,9 +25,15 @@...@@ -26,9 +25,15 @@
2625
27_LIBCPP_BEGIN_NAMESPACE_STD26_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
29template <class _Up, bool>34template <class _Up, bool>
30struct __decay {35struct __decay {
31 typedef _LIBCPP_NODEBUG typename remove_cv<_Up>::type type;36 typedef _LIBCPP_NODEBUG __remove_cv_t<_Up> type;
32};37};
3338
34template <class _Up>39template <class _Up>
...@@ -37,12 +42,12 @@ public:...@@ -37,12 +42,12 @@ public:
37 typedef _LIBCPP_NODEBUG typename conditional42 typedef _LIBCPP_NODEBUG typename conditional
38 <43 <
39 is_array<_Up>::value,44 is_array<_Up>::value,
40 typename remove_extent<_Up>::type*,45 __add_pointer_t<__remove_extent_t<_Up> >,
41 typename conditional46 typename conditional
42 <47 <
43 is_function<_Up>::value,48 is_function<_Up>::value,
44 typename add_pointer<_Up>::type,49 typename add_pointer<_Up>::type,
45 typename remove_cv<_Up>::type50 __remove_cv_t<_Up>
46 >::type51 >::type
47 >::type type;52 >::type type;
48};53};
...@@ -51,10 +56,11 @@ template <class _Tp>...@@ -51,10 +56,11 @@ template <class _Tp>
51struct _LIBCPP_TEMPLATE_VIS decay56struct _LIBCPP_TEMPLATE_VIS decay
52{57{
53private:58private:
54 typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type _Up;59 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tp> _Up;
55public:60public:
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;
57};62};
63#endif // __has_builtin(__decay)
5864
59#if _LIBCPP_STD_VER > 1165#if _LIBCPP_STD_VER > 11
60template <class _Tp> using decay_t = typename decay<_Tp>::type;66template <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 @@...@@ -10,7 +10,6 @@
10#define _LIBCPP___TYPE_TRAITS_DISJUNCTION_H10#define _LIBCPP___TYPE_TRAITS_DISJUNCTION_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/conditional.h>
14#include <__type_traits/integral_constant.h>13#include <__type_traits/integral_constant.h>
1514
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -35,6 +34,12 @@ struct _OrImpl<false> {...@@ -35,6 +34,12 @@ struct _OrImpl<false> {
35 using _Result = _Res;34 using _Result = _Res;
36};35};
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.
38template <class... _Args>43template <class... _Args>
39using _Or _LIBCPP_NODEBUG = typename _OrImpl<sizeof...(_Args) != 0>::template _Result<false_type, _Args...>;44using _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 @@...@@ -18,21 +18,12 @@
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if __has_builtin(__has_virtual_destructor)
22
23template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor
24 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};22 : 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
33#if _LIBCPP_STD_VER > 1424#if _LIBCPP_STD_VER > 14
34template <class _Tp>25template <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);
36#endif27#endif
3728
38_LIBCPP_END_NAMESPACE_STD29_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 @@...@@ -18,10 +18,6 @@
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_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
25template<class _Tp, class _Up>21template<class _Tp, class _Up>
26struct _LIBCPP_TEMPLATE_VIS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> { };22struct _LIBCPP_TEMPLATE_VIS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> { };
2723
...@@ -30,37 +26,6 @@ template <class _Tp, class _Arg>...@@ -30,37 +26,6 @@ template <class _Tp, class _Arg>
30inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Arg);26inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Arg);
31#endif27#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
64_LIBCPP_END_NAMESPACE_STD29_LIBCPP_END_NAMESPACE_STD
6530
66#endif // _LIBCPP___TYPE_TRAITS_IS_ASSIGNABLE_H31#endif // _LIBCPP___TYPE_TRAITS_IS_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_callable.h+1-1
...@@ -25,7 +25,7 @@ template<class...>...@@ -25,7 +25,7 @@ template<class...>
25false_type __is_callable_helper(...);25false_type __is_callable_helper(...);
2626
27template<class _Func, class... _Args>27template<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
30_LIBCPP_END_NAMESPACE_STD30_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 @@...@@ -11,8 +11,6 @@
1111
12#include <__config>12#include <__config>
13#include <__type_traits/integral_constant.h>13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_union.h>
15#include <__type_traits/remove_cv.h>
1614
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header16# 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 {...@@ -24,7 +24,7 @@ inline constexpr bool is_constant_evaluated() noexcept {
24}24}
25#endif25#endif
2626
27inline _LIBCPP_CONSTEXPR27_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR
28bool __libcpp_is_constant_evaluated() _NOEXCEPT { return __builtin_is_constant_evaluated(); }28bool __libcpp_is_constant_evaluated() _NOEXCEPT { return __builtin_is_constant_evaluated(); }
2929
30_LIBCPP_END_NAMESPACE_STD30_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_constructible.h+1-1
...@@ -25,7 +25,7 @@ struct _LIBCPP_TEMPLATE_VIS is_constructible...@@ -25,7 +25,7 @@ struct _LIBCPP_TEMPLATE_VIS is_constructible
2525
26#if _LIBCPP_STD_VER > 1426#if _LIBCPP_STD_VER > 14
27template <class _Tp, class ..._Args>27template <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...);
29#endif29#endif
3030
31_LIBCPP_END_NAMESPACE_STD31_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 {};...@@ -40,7 +40,7 @@ struct __is_convertible_test : public false_type {};
4040
41template <class _From, class _To>41template <class _From, class _To>
42struct __is_convertible_test<_From, _To,42struct __is_convertible_test<_From, _To,
43 decltype(__is_convertible_imp::__test_convert<_To>(declval<_From>()))> : public true_type43 decltype(__is_convertible_imp::__test_convert<_To>(std::declval<_From>()))> : public true_type
44{};44{};
4545
46template <class _Tp, bool _IsArray = is_array<_Tp>::value,46template <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>...@@ -53,7 +53,7 @@ template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true>
53}53}
5454
55template <class _Tp,55template <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>
57struct __is_convertible_check57struct __is_convertible_check
58{58{
59 static const size_t __v = 0;59 static const size_t __v = 0;
lib/libcxx/include/__type_traits/is_copy_assignable.h+6-4
...@@ -13,7 +13,6 @@...@@ -13,7 +13,6 @@
13#include <__type_traits/add_const.h>13#include <__type_traits/add_const.h>
14#include <__type_traits/add_lvalue_reference.h>14#include <__type_traits/add_lvalue_reference.h>
15#include <__type_traits/integral_constant.h>15#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_assignable.h>
1716
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header18# pragma GCC system_header
...@@ -21,9 +20,12 @@...@@ -21,9 +20,12 @@
2120
22_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2322
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable23template <class _Tp>
25 : public is_assignable<typename add_lvalue_reference<_Tp>::type,24struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
26 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};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
28#if _LIBCPP_STD_VER > 1430#if _LIBCPP_STD_VER > 14
29template <class _Tp>31template <class _Tp>
lib/libcxx/include/__type_traits/is_copy_constructible.h+3-3
...@@ -13,7 +13,6 @@...@@ -13,7 +13,6 @@
13#include <__type_traits/add_const.h>13#include <__type_traits/add_const.h>
14#include <__type_traits/add_lvalue_reference.h>14#include <__type_traits/add_lvalue_reference.h>
15#include <__type_traits/integral_constant.h>15#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_constructible.h>
1716
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header18# pragma GCC system_header
...@@ -23,8 +22,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,8 +22,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2322
24template <class _Tp>23template <class _Tp>
25struct _LIBCPP_TEMPLATE_VIS is_copy_constructible24struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
26 : public is_constructible<_Tp,25 : public integral_constant<
27 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};26 bool,
27 __is_constructible(_Tp, __add_lvalue_reference_t<typename add_const<_Tp>::type>)> {};
2828
29#if _LIBCPP_STD_VER > 1429#if _LIBCPP_STD_VER > 14
30template <class _Tp>30template <class _Tp>
lib/libcxx/include/__type_traits/is_default_constructible.h+2-3
...@@ -11,7 +11,6 @@...@@ -11,7 +11,6 @@
1111
12#include <__config>12#include <__config>
13#include <__type_traits/integral_constant.h>13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_constructible.h>
1514
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header16# pragma GCC system_header
...@@ -21,12 +20,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -21,12 +20,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2120
22template <class _Tp>21template <class _Tp>
23struct _LIBCPP_TEMPLATE_VIS is_default_constructible22struct _LIBCPP_TEMPLATE_VIS is_default_constructible
24 : public is_constructible<_Tp>23 : public integral_constant<bool, __is_constructible(_Tp)>
25 {};24 {};
2625
27#if _LIBCPP_STD_VER > 1426#if _LIBCPP_STD_VER > 14
28template <class _Tp>27template <class _Tp>
29inline constexpr bool is_default_constructible_v = is_default_constructible<_Tp>::value;28inline constexpr bool is_default_constructible_v = __is_constructible(_Tp);
30#endif29#endif
3130
32_LIBCPP_END_NAMESPACE_STD31_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_destructible.h+2-2
...@@ -48,7 +48,7 @@ template <typename _Tp>...@@ -48,7 +48,7 @@ template <typename _Tp>
48struct __is_destructor_wellformed {48struct __is_destructor_wellformed {
49 template <typename _Tp1>49 template <typename _Tp1>
50 static true_type __test (50 static true_type __test (
51 typename __is_destructible_apply<decltype(declval<_Tp1&>().~_Tp1())>::type51 typename __is_destructible_apply<decltype(std::declval<_Tp1&>().~_Tp1())>::type
52 );52 );
5353
54 template <typename _Tp1>54 template <typename _Tp1>
...@@ -63,7 +63,7 @@ struct __destructible_imp;...@@ -63,7 +63,7 @@ struct __destructible_imp;
63template <class _Tp>63template <class _Tp>
64struct __destructible_imp<_Tp, false>64struct __destructible_imp<_Tp, false>
65 : public integral_constant<bool,65 : 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
68template <class _Tp>68template <class _Tp>
69struct __destructible_imp<_Tp, true>69struct __destructible_imp<_Tp, true>
lib/libcxx/include/__type_traits/is_enum.h-1
...@@ -11,7 +11,6 @@...@@ -11,7 +11,6 @@
1111
12#include <__config>12#include <__config>
13#include <__type_traits/integral_constant.h>13#include <__type_traits/integral_constant.h>
14#include <__type_traits/remove_cv.h>
1514
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header16# 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...@@ -25,7 +25,7 @@ template <> struct __libcpp_is_floating_point<double> : public tru
25template <> struct __libcpp_is_floating_point<long double> : public true_type {};25template <> struct __libcpp_is_floating_point<long double> : public true_type {};
2626
27template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point27template <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
30#if _LIBCPP_STD_VER > 1430#if _LIBCPP_STD_VER > 14
31template <class _Tp>31template <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);...@@ -58,7 +58,7 @@ inline constexpr bool is_integral_v = __is_integral(_Tp);
58#else58#else
5959
60template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral60template <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
63#if _LIBCPP_STD_VER > 1463#if _LIBCPP_STD_VER > 14
64template <class _Tp>64template <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_...@@ -25,7 +25,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 is_
2525
26#if _LIBCPP_STD_VER > 1426#if _LIBCPP_STD_VER > 14
27template <class _Tp>27template <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);
29#endif // _LIBCPP_STD_VER > 1429#endif // _LIBCPP_STD_VER > 14
30#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)30#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...@@ -50,7 +50,7 @@ inline constexpr bool is_member_function_pointer_v = __is_member_function_pointe
50#else // __has_builtin(__is_member_function_pointer)50#else // __has_builtin(__is_member_function_pointer)
5151
52template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer52template <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
55#if _LIBCPP_STD_VER > 1455#if _LIBCPP_STD_VER > 14
56template <class _Tp>56template <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...@@ -32,7 +32,7 @@ inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_T
32#else // __has_builtin(__is_member_object_pointer)32#else // __has_builtin(__is_member_object_pointer)
3333
34template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer34template <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
37#if _LIBCPP_STD_VER > 1437#if _LIBCPP_STD_VER > 14
38template <class _Tp>38template <class _Tp>
lib/libcxx/include/__type_traits/is_member_pointer.h+2-1
...@@ -11,6 +11,7 @@...@@ -11,6 +11,7 @@
1111
12#include <__config>12#include <__config>
13#include <__type_traits/integral_constant.h>13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_member_function_pointer.h>
1415
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header17# pragma GCC system_header
...@@ -31,7 +32,7 @@ inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp);...@@ -31,7 +32,7 @@ inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp);
31#else // __has_builtin(__is_member_pointer)32#else // __has_builtin(__is_member_pointer)
3233
33template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer34template <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
36#if _LIBCPP_STD_VER > 1437#if _LIBCPP_STD_VER > 14
37template <class _Tp>38template <class _Tp>
lib/libcxx/include/__type_traits/is_move_assignable.h+5-5
...@@ -10,11 +10,9 @@...@@ -10,11 +10,9 @@
10#define _LIBCPP___TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H10#define _LIBCPP___TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/add_const.h>
14#include <__type_traits/add_lvalue_reference.h>13#include <__type_traits/add_lvalue_reference.h>
15#include <__type_traits/add_rvalue_reference.h>14#include <__type_traits/add_rvalue_reference.h>
16#include <__type_traits/integral_constant.h>15#include <__type_traits/integral_constant.h>
17#include <__type_traits/is_assignable.h>
1816
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header18# pragma GCC system_header
...@@ -22,9 +20,11 @@...@@ -22,9 +20,11 @@
2220
23_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2422
25template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable23template <class _Tp>
26 : public is_assignable<typename add_lvalue_reference<_Tp>::type,24struct _LIBCPP_TEMPLATE_VIS is_move_assignable
27 typename add_rvalue_reference<_Tp>::type> {};25 : public integral_constant<
26 bool,
27 __is_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {};
2828
29#if _LIBCPP_STD_VER > 1429#if _LIBCPP_STD_VER > 14
30template <class _Tp>30template <class _Tp>
lib/libcxx/include/__type_traits/is_move_constructible.h+1-2
...@@ -12,7 +12,6 @@...@@ -12,7 +12,6 @@
12#include <__config>12#include <__config>
13#include <__type_traits/add_rvalue_reference.h>13#include <__type_traits/add_rvalue_reference.h>
14#include <__type_traits/integral_constant.h>14#include <__type_traits/integral_constant.h>
15#include <__type_traits/is_constructible.h>
1615
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header17# pragma GCC system_header
...@@ -22,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2221
23template <class _Tp>22template <class _Tp>
24struct _LIBCPP_TEMPLATE_VIS is_move_constructible23struct _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>)>
26 {};25 {};
2726
28#if _LIBCPP_STD_VER > 1427#if _LIBCPP_STD_VER > 14
lib/libcxx/include/__type_traits/is_nothrow_assignable.h+1-28
...@@ -10,7 +10,6 @@...@@ -10,7 +10,6 @@
10#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H10#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/add_const.h>
14#include <__type_traits/integral_constant.h>13#include <__type_traits/integral_constant.h>
1514
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -19,39 +18,13 @@...@@ -19,39 +18,13 @@
1918
20_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2120
22#if __has_builtin(__is_nothrow_assignable)
23
24template <class _Tp, class _Arg>21template <class _Tp, class _Arg>
25struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable22struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable
26 : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {};23 : 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
52#if _LIBCPP_STD_VER > 1425#if _LIBCPP_STD_VER > 14
53template <class _Tp, class _Arg>26template <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);
55#endif28#endif
5629
57_LIBCPP_END_NAMESPACE_STD30_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_nothrow_constructible.h+7-4
...@@ -11,7 +11,10 @@...@@ -11,7 +11,10 @@
1111
12#include <__config>12#include <__config>
13#include <__type_traits/integral_constant.h>13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_constructible.h>
15#include <__type_traits/is_reference.h>
14#include <__utility/declval.h>16#include <__utility/declval.h>
17#include <cstddef>
1518
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header20# pragma GCC system_header
...@@ -21,17 +24,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -21,17 +24,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2124
22#if __has_builtin(__is_nothrow_constructible)25#if __has_builtin(__is_nothrow_constructible)
2326
24template <class _Tp, class... _Args>27template <
28 class _Tp, class... _Args>
25struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible29struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
26 : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {};30 : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {};
27
28#else31#else
2932
30template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;33template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
3134
32template <class _Tp, class... _Args>35template <class _Tp, class... _Args>
33struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>36struct __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>()...))>
35{38{
36};39};
3740
...@@ -40,7 +43,7 @@ void __implicit_conversion_to(_Tp) noexcept { }...@@ -40,7 +43,7 @@ void __implicit_conversion_to(_Tp) noexcept { }
4043
41template <class _Tp, class _Arg>44template <class _Tp, class _Arg>
42struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>45struct __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>()))>
44{47{
45};48};
4649
lib/libcxx/include/__type_traits/is_nothrow_convertible.h+1-1
...@@ -30,7 +30,7 @@ template <typename _Tp>...@@ -30,7 +30,7 @@ template <typename _Tp>
30static void __test_noexcept(_Tp) noexcept;30static void __test_noexcept(_Tp) noexcept;
3131
32template<typename _Fm, typename _To>32template<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>()))>
34__is_nothrow_convertible_test();34__is_nothrow_convertible_test();
3535
36template <typename _Fm, typename _To>36template <typename _Fm, typename _To>
lib/libcxx/include/__type_traits/is_nothrow_copy_assignable.h+7-4
...@@ -13,7 +13,6 @@...@@ -13,7 +13,6 @@
13#include <__type_traits/add_const.h>13#include <__type_traits/add_const.h>
14#include <__type_traits/add_lvalue_reference.h>14#include <__type_traits/add_lvalue_reference.h>
15#include <__type_traits/integral_constant.h>15#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_nothrow_assignable.h>
1716
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header18# pragma GCC system_header
...@@ -21,9 +20,13 @@...@@ -21,9 +20,13 @@
2120
22_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2322
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable23template <class _Tp>
25 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,24struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
26 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};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
28#if _LIBCPP_STD_VER > 1431#if _LIBCPP_STD_VER > 14
29template <class _Tp>32template <class _Tp>
lib/libcxx/include/__type_traits/is_nothrow_copy_constructible.h+14-1
...@@ -21,9 +21,22 @@...@@ -21,9 +21,22 @@
2121
22_LIBCPP_BEGIN_NAMESPACE_STD22_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
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible27template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
25 : public is_nothrow_constructible<_Tp,28 : 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
28#if _LIBCPP_STD_VER > 1441#if _LIBCPP_STD_VER > 14
29template <class _Tp>42template <class _Tp>
lib/libcxx/include/__type_traits/is_nothrow_default_constructible.h+2-3
...@@ -11,7 +11,6 @@...@@ -11,7 +11,6 @@
1111
12#include <__config>12#include <__config>
13#include <__type_traits/integral_constant.h>13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_nothrow_constructible.h>
1514
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header16# pragma GCC system_header
...@@ -20,12 +19,12 @@...@@ -20,12 +19,12 @@
20_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2120
22template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible21template <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)>
24 {};23 {};
2524
26#if _LIBCPP_STD_VER > 1425#if _LIBCPP_STD_VER > 14
27template <class _Tp>26template <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);
29#endif28#endif
3029
31_LIBCPP_END_NAMESPACE_STD30_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_nothrow_destructible.h+2-3
...@@ -10,7 +10,6 @@...@@ -10,7 +10,6 @@
10#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DESTRUCTIBLE_H10#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DESTRUCTIBLE_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/add_const.h>
14#include <__type_traits/integral_constant.h>13#include <__type_traits/integral_constant.h>
15#include <__type_traits/is_destructible.h>14#include <__type_traits/is_destructible.h>
16#include <__type_traits/is_reference.h>15#include <__type_traits/is_reference.h>
...@@ -37,7 +36,7 @@ struct __libcpp_is_nothrow_destructible<false, _Tp>...@@ -37,7 +36,7 @@ struct __libcpp_is_nothrow_destructible<false, _Tp>
3736
38template <class _Tp>37template <class _Tp>
39struct __libcpp_is_nothrow_destructible<true, _Tp>38struct __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()) >
41{40{
42};41};
4342
...@@ -72,7 +71,7 @@ template <class _Tp> struct __libcpp_nothrow_destructor...@@ -72,7 +71,7 @@ template <class _Tp> struct __libcpp_nothrow_destructor
72 is_reference<_Tp>::value> {};71 is_reference<_Tp>::value> {};
7372
74template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible73template <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
77template <class _Tp>76template <class _Tp>
78struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>77struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]>
lib/libcxx/include/__type_traits/is_nothrow_move_assignable.h+6-5
...@@ -13,7 +13,6 @@...@@ -13,7 +13,6 @@
13#include <__type_traits/add_lvalue_reference.h>13#include <__type_traits/add_lvalue_reference.h>
14#include <__type_traits/add_rvalue_reference.h>14#include <__type_traits/add_rvalue_reference.h>
15#include <__type_traits/integral_constant.h>15#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_nothrow_assignable.h>
1716
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header18# pragma GCC system_header
...@@ -21,10 +20,12 @@...@@ -21,10 +20,12 @@
2120
22_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2322
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable23template <class _Tp>
25 : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,24struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
26 typename add_rvalue_reference<_Tp>::type>25 : public integral_constant<
27 {};26 bool,
27 __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {
28};
2829
29#if _LIBCPP_STD_VER > 1430#if _LIBCPP_STD_VER > 14
30template <class _Tp>31template <class _Tp>
lib/libcxx/include/__type_traits/is_nothrow_move_constructible.h+12-1
...@@ -20,10 +20,21 @@...@@ -20,10 +20,21 @@
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_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
23template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible32template <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> >
25 {};34 {};
2635
36#endif // _LIBCPP_COMPILER_GCC
37
27#if _LIBCPP_STD_VER > 1438#if _LIBCPP_STD_VER > 14
28template <class _Tp>39template <class _Tp>
29inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value;40inline 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 {};...@@ -24,11 +24,11 @@ template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
24template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};24template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
2525
26template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t26template <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
29#if _LIBCPP_STD_VER > 1129#if _LIBCPP_STD_VER > 11
30template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer30template <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
33#if _LIBCPP_STD_VER > 1433#if _LIBCPP_STD_VER > 14
34template <class _Tp>34template <class _Tp>
lib/libcxx/include/__type_traits/is_pod.h+1-13
...@@ -18,24 +18,12 @@...@@ -18,24 +18,12 @@
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if __has_builtin(__is_pod)
22
23template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod
24 : public integral_constant<bool, __is_pod(_Tp)> {};22 : 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
36#if _LIBCPP_STD_VER > 1424#if _LIBCPP_STD_VER > 14
37template <class _Tp>25template <class _Tp>
38inline constexpr bool is_pod_v = is_pod<_Tp>::value;26inline constexpr bool is_pod_v = __is_pod(_Tp);
39#endif27#endif
4028
41_LIBCPP_END_NAMESPACE_STD29_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...@@ -43,7 +43,7 @@ template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretai
43#endif43#endif
4444
45template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer45template <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
48#if _LIBCPP_STD_VER > 1448#if _LIBCPP_STD_VER > 14
49template <class _Tp>49template <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;...@@ -24,7 +24,7 @@ template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper;
24template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};24template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
25template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};25template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
26template <class _Tp> struct __is_reference_wrapper26template <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
29_LIBCPP_END_NAMESPACE_STD29_LIBCPP_END_NAMESPACE_STD
3030
lib/libcxx/include/__type_traits/is_referenceable.h+13-5
...@@ -19,14 +19,22 @@...@@ -19,14 +19,22 @@
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22struct __is_referenceable_impl {22#if __has_builtin(__is_referenceable)
23 template <class _Tp> static _Tp& __test(int);23template <class _Tp>
24 template <class _Tp> static false_type __test(...);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(...);
25};31};
2632
27template <class _Tp>33template <class _Tp>
28struct __is_referenceable : integral_constant<bool,34struct __libcpp_is_referenceable
29 _IsNotSame<decltype(__is_referenceable_impl::__test<_Tp>(0)), false_type>::value> {};35 : integral_constant<bool, _IsNotSame<decltype(__libcpp_is_referenceable_impl::__test<_Tp>(0)), false_type>::value> {
36};
37#endif // __has_builtin(__is_referenceable)
3038
31_LIBCPP_END_NAMESPACE_STD39_LIBCPP_END_NAMESPACE_STD
3240
lib/libcxx/include/__type_traits/is_scalar.h+1
...@@ -14,6 +14,7 @@...@@ -14,6 +14,7 @@
14#include <__type_traits/is_arithmetic.h>14#include <__type_traits/is_arithmetic.h>
15#include <__type_traits/is_enum.h>15#include <__type_traits/is_enum.h>
16#include <__type_traits/is_member_pointer.h>16#include <__type_traits/is_member_pointer.h>
17#include <__type_traits/is_null_pointer.h>
17#include <__type_traits/is_pointer.h>18#include <__type_traits/is_pointer.h>
1819
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__type_traits/is_signed.h+2
...@@ -11,6 +11,8 @@...@@ -11,6 +11,8 @@
1111
12#include <__config>12#include <__config>
13#include <__type_traits/integral_constant.h>13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_arithmetic.h>
15#include <__type_traits/is_integral.h>
1416
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header18# 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 @@...@@ -19,16 +19,12 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout
22#if __has_builtin(__is_standard_layout)
23 : public integral_constant<bool, __is_standard_layout(_Tp)>22 : 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
27 {};23 {};
2824
29#if _LIBCPP_STD_VER > 1425#if _LIBCPP_STD_VER > 14
30template <class _Tp>26template <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);
32#endif28#endif
3329
34_LIBCPP_END_NAMESPACE_STD30_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 @@...@@ -19,17 +19,12 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial
22#if __has_builtin(__is_trivial)
23 : public integral_constant<bool, __is_trivial(_Tp)>22 : 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
28 {};23 {};
2924
30#if _LIBCPP_STD_VER > 1425#if _LIBCPP_STD_VER > 14
31template <class _Tp>26template <class _Tp>
32inline constexpr bool is_trivial_v = is_trivial<_Tp>::value;27inline constexpr bool is_trivial_v = __is_trivial(_Tp);
33#endif28#endif
3429
35_LIBCPP_END_NAMESPACE_STD30_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_trivially_assignable.h+1-1
...@@ -25,7 +25,7 @@ struct is_trivially_assignable...@@ -25,7 +25,7 @@ struct is_trivially_assignable
2525
26#if _LIBCPP_STD_VER > 1426#if _LIBCPP_STD_VER > 14
27template <class _Tp, class _Arg>27template <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);
29#endif29#endif
3030
31_LIBCPP_END_NAMESPACE_STD31_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...@@ -26,7 +26,7 @@ struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible
2626
27#if _LIBCPP_STD_VER > 1427#if _LIBCPP_STD_VER > 14
28template <class _Tp, class... _Args>28template <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...);
30#endif30#endif
3131
32_LIBCPP_END_NAMESPACE_STD32_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_trivially_copy_assignable.h+7-4
...@@ -13,7 +13,6 @@...@@ -13,7 +13,6 @@
13#include <__type_traits/add_const.h>13#include <__type_traits/add_const.h>
14#include <__type_traits/add_lvalue_reference.h>14#include <__type_traits/add_lvalue_reference.h>
15#include <__type_traits/integral_constant.h>15#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_trivially_assignable.h>
1716
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header18# pragma GCC system_header
...@@ -21,9 +20,13 @@...@@ -21,9 +20,13 @@
2120
22_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2322
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable23template <class _Tp>
25 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,24struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
26 typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};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
28#if _LIBCPP_STD_VER > 1431#if _LIBCPP_STD_VER > 14
29template <class _Tp>32template <class _Tp>
lib/libcxx/include/__type_traits/is_trivially_copy_constructible.h+1-2
...@@ -12,7 +12,6 @@...@@ -12,7 +12,6 @@
12#include <__config>12#include <__config>
13#include <__type_traits/add_lvalue_reference.h>13#include <__type_traits/add_lvalue_reference.h>
14#include <__type_traits/integral_constant.h>14#include <__type_traits/integral_constant.h>
15#include <__type_traits/is_trivially_constructible.h>
1615
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header17# pragma GCC system_header
...@@ -21,7 +20,7 @@...@@ -21,7 +20,7 @@
21_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2221
23template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible22template <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>)>
25 {};24 {};
2625
27#if _LIBCPP_STD_VER > 1426#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...@@ -24,7 +24,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable
2424
25#if _LIBCPP_STD_VER > 1425#if _LIBCPP_STD_VER > 14
26template <class _Tp>26template <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);
28#endif28#endif
2929
30_LIBCPP_END_NAMESPACE_STD30_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_trivially_default_constructible.h+2-3
...@@ -11,7 +11,6 @@...@@ -11,7 +11,6 @@
1111
12#include <__config>12#include <__config>
13#include <__type_traits/integral_constant.h>13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_trivially_constructible.h>
1514
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header16# pragma GCC system_header
...@@ -20,12 +19,12 @@...@@ -20,12 +19,12 @@
20_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2120
22template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible21template <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)>
24 {};23 {};
2524
26#if _LIBCPP_STD_VER > 1425#if _LIBCPP_STD_VER > 14
27template <class _Tp>26template <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);
29#endif28#endif
3029
31_LIBCPP_END_NAMESPACE_STD30_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_trivially_destructible.h+2-9
...@@ -11,6 +11,7 @@...@@ -11,6 +11,7 @@
1111
12#include <__config>12#include <__config>
13#include <__type_traits/integral_constant.h>13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_destructible.h>
1415
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header17# pragma GCC system_header
...@@ -30,15 +31,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible...@@ -30,15 +31,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
3031
31#else32#else
3233
33template <class _Tp> struct __libcpp_trivial_destructor34#error is_trivially_destructible is not implemented
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 {};
4235
43#endif // __has_builtin(__is_trivially_destructible)36#endif // __has_builtin(__is_trivially_destructible)
4437
lib/libcxx/include/__type_traits/is_trivially_move_assignable.h+5-5
...@@ -13,7 +13,6 @@...@@ -13,7 +13,6 @@
13#include <__type_traits/add_lvalue_reference.h>13#include <__type_traits/add_lvalue_reference.h>
14#include <__type_traits/add_rvalue_reference.h>14#include <__type_traits/add_rvalue_reference.h>
15#include <__type_traits/integral_constant.h>15#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_trivially_assignable.h>
1716
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header18# pragma GCC system_header
...@@ -21,10 +20,11 @@...@@ -21,10 +20,11 @@
2120
22_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2322
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable23template <class _Tp>
25 : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,24struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
26 typename add_rvalue_reference<_Tp>::type>25 : public integral_constant<
27 {};26 bool,
27 __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {};
2828
29#if _LIBCPP_STD_VER > 1429#if _LIBCPP_STD_VER > 14
30template <class _Tp>30template <class _Tp>
lib/libcxx/include/__type_traits/is_trivially_move_constructible.h+3-4
...@@ -12,7 +12,6 @@...@@ -12,7 +12,6 @@
12#include <__config>12#include <__config>
13#include <__type_traits/add_rvalue_reference.h>13#include <__type_traits/add_rvalue_reference.h>
14#include <__type_traits/integral_constant.h>14#include <__type_traits/integral_constant.h>
15#include <__type_traits/is_trivially_constructible.h>
1615
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header17# pragma GCC system_header
...@@ -20,9 +19,9 @@...@@ -20,9 +19,9 @@
2019
21_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2221
23template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible22template <class _Tp>
24 : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>23struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
25 {};24 : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {};
2625
27#if _LIBCPP_STD_VER > 1426#if _LIBCPP_STD_VER > 14
28template <class _Tp>27template <class _Tp>
lib/libcxx/include/__type_traits/is_union.h-1
...@@ -11,7 +11,6 @@...@@ -11,7 +11,6 @@
1111
12#include <__config>12#include <__config>
13#include <__type_traits/integral_constant.h>13#include <__type_traits/integral_constant.h>
14#include <__type_traits/remove_cv.h>
1514
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header16# pragma GCC system_header
lib/libcxx/include/__type_traits/is_unsigned.h+1-2
...@@ -20,8 +20,7 @@...@@ -20,8 +20,7 @@
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23// Before AppleClang 14, __is_unsigned returned true for enums with signed underlying type.23#if __has_builtin(__is_unsigned)
24#if __has_builtin(__is_unsigned) && !(defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1400)
2524
26template<class _Tp>25template<class _Tp>
27struct _LIBCPP_TEMPLATE_VIS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> { };26struct _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 ...>...@@ -24,7 +24,7 @@ template <template <class...> class, class ...>
24false_type __sfinae_test_impl(...);24false_type __sfinae_test_impl(...);
2525
26template <template <class ...> class _Templ, class ..._Args>26template <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
29_LIBCPP_END_NAMESPACE_STD29_LIBCPP_END_NAMESPACE_STD
3030
lib/libcxx/include/__type_traits/is_void.h+3-1
...@@ -11,6 +11,8 @@...@@ -11,6 +11,8 @@
1111
12#include <__config>12#include <__config>
13#include <__type_traits/integral_constant.h>13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_same.h>
15#include <__type_traits/remove_cv.h>
1416
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header18# pragma GCC system_header
...@@ -31,7 +33,7 @@ inline constexpr bool is_void_v = __is_void(_Tp);...@@ -31,7 +33,7 @@ inline constexpr bool is_void_v = __is_void(_Tp);
31#else33#else
3234
33template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void35template <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
36#if _LIBCPP_STD_VER > 1438#if _LIBCPP_STD_VER > 14
37template <class _Tp>39template <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 @@...@@ -23,19 +23,25 @@
2323
24_LIBCPP_BEGIN_NAMESPACE_STD24_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
26typedef32typedef
27 __type_list<signed char,33 __type_list<signed char,
28 __type_list<signed short,34 __type_list<signed short,
29 __type_list<signed int,35 __type_list<signed int,
30 __type_list<signed long,36 __type_list<signed long,
31 __type_list<signed long long,37 __type_list<signed long long,
32#ifndef _LIBCPP_HAS_NO_INT12838# ifndef _LIBCPP_HAS_NO_INT128
33 __type_list<__int128_t,39 __type_list<__int128_t,
34#endif40# endif
35 __nat41 __nat
36#ifndef _LIBCPP_HAS_NO_INT12842# ifndef _LIBCPP_HAS_NO_INT128
37 >43 >
38#endif44# endif
39 > > > > > __signed_types;45 > > > > > __signed_types;
4046
41template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>47template <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...@@ -56,19 +62,23 @@ template <> struct __make_signed< signed long, true> {typedef long ty
56template <> struct __make_signed<unsigned long, true> {typedef long type;};62template <> struct __make_signed<unsigned long, true> {typedef long type;};
57template <> struct __make_signed< signed long long, true> {typedef long long type;};63template <> struct __make_signed< signed long long, true> {typedef long long type;};
58template <> struct __make_signed<unsigned long long, true> {typedef long long type;};64template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
59#ifndef _LIBCPP_HAS_NO_INT12865# ifndef _LIBCPP_HAS_NO_INT128
60template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};66template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;};
61template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};67template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;};
62#endif68# endif
6369
64template <class _Tp>70template <class _Tp>
65struct _LIBCPP_TEMPLATE_VIS make_signed71using __make_signed_t = typename __apply_cv<_Tp, typename __make_signed<__remove_cv_t<_Tp> >::type>::type;
66{72
67 typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;73#endif // __has_builtin(__make_signed)
74
75template <class _Tp>
76struct make_signed {
77 using type _LIBCPP_NODEBUG = __make_signed_t<_Tp>;
68};78};
6979
70#if _LIBCPP_STD_VER > 1180#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>;
72#endif82#endif
7383
74_LIBCPP_END_NAMESPACE_STD84_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/make_unsigned.h+23-13
...@@ -25,19 +25,25 @@...@@ -25,19 +25,25 @@
2525
26_LIBCPP_BEGIN_NAMESPACE_STD26_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
28typedef34typedef
29 __type_list<unsigned char,35 __type_list<unsigned char,
30 __type_list<unsigned short,36 __type_list<unsigned short,
31 __type_list<unsigned int,37 __type_list<unsigned int,
32 __type_list<unsigned long,38 __type_list<unsigned long,
33 __type_list<unsigned long long,39 __type_list<unsigned long long,
34#ifndef _LIBCPP_HAS_NO_INT12840# ifndef _LIBCPP_HAS_NO_INT128
35 __type_list<__uint128_t,41 __type_list<__uint128_t,
36#endif42# endif
37 __nat43 __nat
38#ifndef _LIBCPP_HAS_NO_INT12844# ifndef _LIBCPP_HAS_NO_INT128
39 >45 >
40#endif46# endif
41 > > > > > __unsigned_types;47 > > > > > __unsigned_types;
4248
43template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>49template <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...@@ -58,31 +64,35 @@ template <> struct __make_unsigned< signed long, true> {typedef unsigned l
58template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};64template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
59template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};65template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
60template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};66template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
61#ifndef _LIBCPP_HAS_NO_INT12867# ifndef _LIBCPP_HAS_NO_INT128
62template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};68template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;};
63template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};69template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;};
64#endif70# endif
6571
66template <class _Tp>72template <class _Tp>
67struct _LIBCPP_TEMPLATE_VIS make_unsigned73using __make_unsigned_t = typename __apply_cv<_Tp, typename __make_unsigned<__remove_cv_t<_Tp> >::type>::type;
68{74
69 typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;75#endif // __has_builtin(__make_unsigned)
76
77template <class _Tp>
78struct make_unsigned {
79 using type _LIBCPP_NODEBUG = __make_unsigned_t<_Tp>;
70};80};
7181
72#if _LIBCPP_STD_VER > 1182#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>;
74#endif84#endif
7585
76#ifndef _LIBCPP_CXX03_LANG86#ifndef _LIBCPP_CXX03_LANG
77template <class _Tp>87template <class _Tp>
78_LIBCPP_HIDE_FROM_ABI constexpr88_LIBCPP_HIDE_FROM_ABI constexpr
79typename make_unsigned<_Tp>::type __to_unsigned_like(_Tp __x) noexcept {89__make_unsigned_t<_Tp> __to_unsigned_like(_Tp __x) noexcept {
80 return static_cast<typename make_unsigned<_Tp>::type>(__x);90 return static_cast<__make_unsigned_t<_Tp> >(__x);
81}91}
82#endif92#endif
8393
84template <class _Tp, class _Up>94template <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
87_LIBCPP_END_NAMESPACE_STD97_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> {};...@@ -25,7 +25,7 @@ struct _Not : _BoolConstant<!_Pred::value> {};
25template <class _Tp>25template <class _Tp>
26struct negation : _Not<_Tp> {};26struct negation : _Not<_Tp> {};
27template<class _Tp>27template<class _Tp>
28inline constexpr bool negation_v = negation<_Tp>::value;28inline constexpr bool negation_v = !_Tp::value;
29#endif // _LIBCPP_STD_VER > 1429#endif // _LIBCPP_STD_VER > 14
3030
31_LIBCPP_END_NAMESPACE_STD31_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...@@ -33,10 +33,14 @@ struct __numeric_type
33 static double __test(unsigned long);33 static double __test(unsigned long);
34 static double __test(long long);34 static double __test(long long);
35 static double __test(unsigned long long);35 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
36 static double __test(double);40 static double __test(double);
37 static long double __test(long double);41 static long double __test(long double);
3842
39 typedef decltype(__test(declval<_Tp>())) type;43 typedef decltype(__test(std::declval<_Tp>())) type;
40 static const bool value = _IsNotSame<type, void>::value;44 static const bool value = _IsNotSame<type, void>::value;
41};45};
4246
lib/libcxx/include/__type_traits/rank.h+10
...@@ -19,6 +19,14 @@...@@ -19,6 +19,14 @@
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_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
22template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank30template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank
23 : public integral_constant<size_t, 0> {};31 : public integral_constant<size_t, 0> {};
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>32template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
...@@ -26,6 +34,8 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>...@@ -26,6 +34,8 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]>
26template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]>34template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]>
27 : public integral_constant<size_t, rank<_Tp>::value + 1> {};35 : public integral_constant<size_t, rank<_Tp>::value + 1> {};
2836
37#endif // __has_builtin(__array_rank)
38
29#if _LIBCPP_STD_VER > 1439#if _LIBCPP_STD_VER > 14
30template <class _Tp>40template <class _Tp>
31inline constexpr size_t rank_v = rank<_Tp>::value;41inline constexpr size_t rank_v = rank<_Tp>::value;
lib/libcxx/include/__type_traits/remove_all_extents.h+14-1
...@@ -18,6 +18,15 @@...@@ -18,6 +18,15 @@
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_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
21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents30template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents
22 {typedef _Tp type;};31 {typedef _Tp type;};
23template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>32template <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[]>...@@ -25,8 +34,12 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]>
25template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]>34template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]>
26 {typedef typename remove_all_extents<_Tp>::type type;};35 {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
28#if _LIBCPP_STD_VER > 1141#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>;
30#endif43#endif
3144
32_LIBCPP_END_NAMESPACE_STD45_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/remove_const.h+15-1
...@@ -17,10 +17,24 @@...@@ -17,10 +17,24 @@
1717
18_LIBCPP_BEGIN_NAMESPACE_STD18_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
20template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;};29template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;};
21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;};30template <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
22#if _LIBCPP_STD_VER > 1136#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>;
24#endif38#endif
2539
26_LIBCPP_END_NAMESPACE_STD40_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 @@...@@ -19,10 +19,24 @@
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_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
22template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv31template <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
24#if _LIBCPP_STD_VER > 1138#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>;
26#endif40#endif
2741
28_LIBCPP_END_NAMESPACE_STD42_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/remove_cvref.h+9-5
...@@ -20,20 +20,24 @@...@@ -20,20 +20,24 @@
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if __has_builtin(__remove_cvref)
23template <class _Tp>24template <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
26template <class _Tp, class _Up>31template <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
29#if _LIBCPP_STD_VER > 1734#if _LIBCPP_STD_VER > 17
30// remove_cvref - same as __uncvref
31template <class _Tp>35template <class _Tp>
32struct remove_cvref {36struct remove_cvref {
33 using type _LIBCPP_NODEBUG = __uncvref_t<_Tp>;37 using type _LIBCPP_NODEBUG = __remove_cvref_t<_Tp>;
34};38};
3539
36template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;40template <class _Tp> using remove_cvref_t = __remove_cvref_t<_Tp>;
37#endif41#endif
3842
39_LIBCPP_END_NAMESPACE_STD43_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/remove_extent.h+14-1
...@@ -18,6 +18,15 @@...@@ -18,6 +18,15 @@
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_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
21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent30template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent
22 {typedef _Tp type;};31 {typedef _Tp type;};
23template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>32template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
...@@ -25,8 +34,12 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>...@@ -25,8 +34,12 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]>
25template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]>34template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]>
26 {typedef _Tp type;};35 {typedef _Tp type;};
2736
37template <class _Tp>
38using __remove_extent_t = typename remove_extent<_Tp>::type;
39#endif // __has_builtin(__remove_extent)
40
28#if _LIBCPP_STD_VER > 1141#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>;
30#endif43#endif
3144
32_LIBCPP_END_NAMESPACE_STD45_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/remove_pointer.h+14-1
...@@ -17,14 +17,27 @@...@@ -17,14 +17,27 @@
1717
18_LIBCPP_BEGIN_NAMESPACE_STD18_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
20template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG _Tp type;};29template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG _Tp type;};
21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _LIBCPP_NODEBUG _Tp type;};30template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _LIBCPP_NODEBUG _Tp type;};
22template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _LIBCPP_NODEBUG _Tp type;};31template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _LIBCPP_NODEBUG _Tp type;};
23template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _LIBCPP_NODEBUG _Tp type;};32template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _LIBCPP_NODEBUG _Tp type;};
24template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _LIBCPP_NODEBUG _Tp type;};33template <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
26#if _LIBCPP_STD_VER > 1139#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>;
28#endif41#endif
2942
30_LIBCPP_END_NAMESPACE_STD43_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/remove_reference.h+14-1
...@@ -18,12 +18,25 @@...@@ -18,12 +18,25 @@
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_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
21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG _Tp type;};30template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG _Tp type;};
22template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG _Tp type;};31template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG _Tp type;};
23template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG _Tp type;};32template <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
25#if _LIBCPP_STD_VER > 1138#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>;
27#endif40#endif
2841
29_LIBCPP_END_NAMESPACE_STD42_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/remove_volatile.h+15-1
...@@ -17,10 +17,24 @@...@@ -17,10 +17,24 @@
1717
18_LIBCPP_BEGIN_NAMESPACE_STD18_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
20template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;};29template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;};
21template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};30template <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
22#if _LIBCPP_STD_VER > 1136#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>;
24#endif38#endif
2539
26_LIBCPP_END_NAMESPACE_STD40_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...@@ -21,8 +21,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
21template <class...> using void_t = void;21template <class...> using void_t = void;
22#endif22#endif
2323
24template <class>24template <class...>
25struct __void_t { typedef void type; };25using __void_t = void;
2626
27_LIBCPP_END_NAMESPACE_STD27_LIBCPP_END_NAMESPACE_STD
2828
lib/libcxx/include/__utility/as_const.h+2-2
...@@ -10,9 +10,9 @@...@@ -10,9 +10,9 @@
10#define _LIBCPP___UTILITY_AS_CONST_H10#define _LIBCPP___UTILITY_AS_CONST_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/add_const.h>
13#include <__utility/forward.h>14#include <__utility/forward.h>
14#include <__utility/move.h>15#include <__utility/move.h>
15#include <type_traits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header18# pragma GCC system_header
...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if _LIBCPP_STD_VER > 1423#if _LIBCPP_STD_VER > 14
24template <class _Tp>24template <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
27template <class _Tp>27template <class _Tp>
28void as_const(const _Tp&&) = delete;28void as_const(const _Tp&&) = delete;
lib/libcxx/include/__utility/auto_cast.h+1-1
...@@ -11,7 +11,7 @@...@@ -11,7 +11,7 @@
11#define _LIBCPP___UTILITY_AUTO_CAST_H11#define _LIBCPP___UTILITY_AUTO_CAST_H
1212
13#include <__config>13#include <__config>
14#include <type_traits>14#include <__type_traits/decay.h>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header17# pragma GCC system_header
lib/libcxx/include/__utility/cmp.h+5-1
...@@ -10,10 +10,14 @@...@@ -10,10 +10,14 @@
10#define _LIBCPP___UTILITY_CMP_H10#define _LIBCPP___UTILITY_CMP_H
1111
12#include <__config>12#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>
13#include <__utility/forward.h>18#include <__utility/forward.h>
14#include <__utility/move.h>19#include <__utility/move.h>
15#include <limits>20#include <limits>
16#include <type_traits>
1721
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header23# 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);...@@ -27,7 +27,7 @@ _Tp __declval(long);
27_LIBCPP_SUPPRESS_DEPRECATED_POP27_LIBCPP_SUPPRESS_DEPRECATED_POP
2828
29template <class _Tp>29template <class _Tp>
30decltype(__declval<_Tp>(0)) declval() _NOEXCEPT;30decltype(std::__declval<_Tp>(0)) declval() _NOEXCEPT;
3131
32_LIBCPP_END_NAMESPACE_STD32_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 @@...@@ -10,9 +10,10 @@
10#define _LIBCPP___UTILITY_EXCHANGE_H10#define _LIBCPP___UTILITY_EXCHANGE_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/is_nothrow_assignable.h>
14#include <__type_traits/is_nothrow_move_constructible.h>
13#include <__utility/forward.h>15#include <__utility/forward.h>
14#include <__utility/move.h>16#include <__utility/move.h>
15#include <type_traits>
1617
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header19# pragma GCC system_header
...@@ -22,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2223
23#if _LIBCPP_STD_VER > 1124#if _LIBCPP_STD_VER > 11
24template<class _T1, class _T2 = _T1>25template<class _T1, class _T2 = _T1>
25inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX1726inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
26_T1 exchange(_T1& __obj, _T2&& __new_value)27_T1 exchange(_T1& __obj, _T2&& __new_value)
27 noexcept(is_nothrow_move_constructible<_T1>::value && is_nothrow_assignable<_T1&, _T2>::value)28 noexcept(is_nothrow_move_constructible<_T1>::value && is_nothrow_assignable<_T1&, _T2>::value)
28{29{
lib/libcxx/include/__utility/forward.h+4-4
...@@ -21,14 +21,14 @@...@@ -21,14 +21,14 @@
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _Tp>23template <class _Tp>
24_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR _Tp&&24_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&&
25forward(typename remove_reference<_Tp>::type& __t) _NOEXCEPT {25forward(_LIBCPP_LIFETIMEBOUND __libcpp_remove_reference_t<_Tp>& __t) _NOEXCEPT {
26 return static_cast<_Tp&&>(__t);26 return static_cast<_Tp&&>(__t);
27}27}
2828
29template <class _Tp>29template <class _Tp>
30_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR _Tp&&30_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&&
31forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT {31forward(_LIBCPP_LIFETIMEBOUND __libcpp_remove_reference_t<_Tp>&& __t) _NOEXCEPT {
32 static_assert(!is_lvalue_reference<_Tp>::value, "cannot forward an rvalue as an lvalue");32 static_assert(!is_lvalue_reference<_Tp>::value, "cannot forward an rvalue as an lvalue");
33 return static_cast<_Tp&&>(__t);33 return static_cast<_Tp&&>(__t);
34}34}
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 @@...@@ -10,7 +10,8 @@
10#define _LIBCPP___UTILITY_IN_PLACE_H10#define _LIBCPP___UTILITY_IN_PLACE_H
1111
12#include <__config>12#include <__config>
13#include <type_traits>13#include <__type_traits/remove_cvref.h>
14#include <cstddef>
1415
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header17# pragma GCC system_header
...@@ -43,13 +44,13 @@ template <class _Tp> struct __is_inplace_type_imp : false_type {};...@@ -43,13 +44,13 @@ template <class _Tp> struct __is_inplace_type_imp : false_type {};
43template <class _Tp> struct __is_inplace_type_imp<in_place_type_t<_Tp>> : true_type {};44template <class _Tp> struct __is_inplace_type_imp<in_place_type_t<_Tp>> : true_type {};
4445
45template <class _Tp>46template <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
48template <class _Tp> struct __is_inplace_index_imp : false_type {};49template <class _Tp> struct __is_inplace_index_imp : false_type {};
49template <size_t _Idx> struct __is_inplace_index_imp<in_place_index_t<_Idx>> : true_type {};50template <size_t _Idx> struct __is_inplace_index_imp<in_place_index_t<_Idx>> : true_type {};
5051
51template <class _Tp>52template <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
54#endif // _LIBCPP_STD_VER > 1455#endif // _LIBCPP_STD_VER > 14
5556
lib/libcxx/include/__utility/integer_sequence.h+76-1
...@@ -10,7 +10,8 @@...@@ -10,7 +10,8 @@
10#define _LIBCPP___UTILITY_INTEGER_SEQUENCE_H10#define _LIBCPP___UTILITY_INTEGER_SEQUENCE_H
1111
12#include <__config>12#include <__config>
13#include <type_traits>13#include <__type_traits/is_integral.h>
14#include <cstddef>
1415
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header17# pragma GCC system_header
...@@ -18,6 +19,72 @@...@@ -18,6 +19,72 @@
1819
19_LIBCPP_BEGIN_NAMESPACE_STD20_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
21#if _LIBCPP_STD_VER > 1188#if _LIBCPP_STD_VER > 11
2289
23template<class _Tp, _Tp... _Ip>90template<class _Tp, _Tp... _Ip>
...@@ -71,6 +138,14 @@ template<size_t _Np>...@@ -71,6 +138,14 @@ template<size_t _Np>
71template<class... _Tp>138template<class... _Tp>
72 using index_sequence_for = make_index_sequence<sizeof...(_Tp)>;139 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
74#endif // _LIBCPP_STD_VER > 11149#endif // _LIBCPP_STD_VER > 11
75150
76_LIBCPP_END_NAMESPACE_STD151_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__utility/move.h+11-9
...@@ -11,7 +11,10 @@...@@ -11,7 +11,10 @@
11#define _LIBCPP___UTILITY_MOVE_H11#define _LIBCPP___UTILITY_MOVE_H
1212
13#include <__config>13#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
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header20# pragma GCC system_header
...@@ -20,21 +23,20 @@...@@ -20,21 +23,20 @@
20_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2124
22template <class _Tp>25template <class _Tp>
23_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename remove_reference<_Tp>::type&&26_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __libcpp_remove_reference_t<_Tp>&&
24move(_Tp&& __t) _NOEXCEPT {27move(_LIBCPP_LIFETIMEBOUND _Tp&& __t) _NOEXCEPT {
25 typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type _Up;28 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tp> _Up;
26 return static_cast<_Up&&>(__t);29 return static_cast<_Up&&>(__t);
27}30}
2831
29template <class _Tp>32template <class _Tp>
30using __move_if_noexcept_result_t =33using __move_if_noexcept_result_t =
31 typename conditional<!is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value, const _Tp&,34 __conditional_t<!is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value, const _Tp&, _Tp&&>;
32 _Tp&&>::type;
3335
34template <class _Tp>36template <class _Tp>
35_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 __move_if_noexcept_result_t<_Tp>37_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __move_if_noexcept_result_t<_Tp>
36move_if_noexcept(_Tp& __x) _NOEXCEPT {38move_if_noexcept(_LIBCPP_LIFETIMEBOUND _Tp& __x) _NOEXCEPT {
37 return _VSTD::move(__x);39 return std::move(__x);
38}40}
3941
40_LIBCPP_END_NAMESPACE_STD42_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__utility/pair.h+173-77
...@@ -13,12 +13,35 @@...@@ -13,12 +13,35 @@
13#include <__compare/synth_three_way.h>13#include <__compare/synth_three_way.h>
14#include <__config>14#include <__config>
15#include <__functional/unwrap_ref.h>15#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>
17#include <__utility/forward.h>41#include <__utility/forward.h>
18#include <__utility/move.h>42#include <__utility/move.h>
19#include <__utility/piecewise_construct.h>43#include <__utility/piecewise_construct.h>
20#include <cstddef>44#include <cstddef>
21#include <type_traits>
2245
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)46#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header47# pragma GCC system_header
...@@ -31,7 +54,7 @@ template <class, class>...@@ -31,7 +54,7 @@ template <class, class>
31struct __non_trivially_copyable_base {54struct __non_trivially_copyable_base {
32 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY55 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
33 __non_trivially_copyable_base() _NOEXCEPT {}56 __non_trivially_copyable_base() _NOEXCEPT {}
34 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY57 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
35 __non_trivially_copyable_base(__non_trivially_copyable_base const&) _NOEXCEPT {}58 __non_trivially_copyable_base(__non_trivially_copyable_base const&) _NOEXCEPT {}
36};59};
37#endif60#endif
...@@ -48,12 +71,8 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -48,12 +71,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
48 _T1 first;71 _T1 first;
49 _T2 second;72 _T2 second;
5073
51#if !defined(_LIBCPP_CXX03_LANG)
52 pair(pair const&) = default;74 pair(pair const&) = default;
53 pair(pair&&) = default;75 pair(pair&&) = default;
54#else
55 // Use the implicitly declared copy constructor in C++03
56#endif
5776
58#ifdef _LIBCPP_CXX03_LANG77#ifdef _LIBCPP_CXX03_LANG
59 _LIBCPP_INLINE_VISIBILITY78 _LIBCPP_INLINE_VISIBILITY
...@@ -88,20 +107,26 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -88,20 +107,26 @@ struct _LIBCPP_TEMPLATE_VIS pair
88 }107 }
89108
90 template <class _U1, class _U2>109 template <class _U1, class _U2>
91 static constexpr bool __enable_explicit() {110 static constexpr bool __is_pair_constructible() {
92 return is_constructible<first_type, _U1>::value111 return is_constructible<first_type, _U1>::value
93 && is_constructible<second_type, _U2>::value112 && is_constructible<second_type, _U2>::value;
94 && (!is_convertible<_U1, first_type>::value
95 || !is_convertible<_U2, second_type>::value);
96 }113 }
97114
98 template <class _U1, class _U2>115 template <class _U1, class _U2>
99 static constexpr bool __enable_implicit() {116 static constexpr bool __is_implicit() {
100 return is_constructible<first_type, _U1>::value117 return is_convertible<_U1, first_type>::value
101 && is_constructible<second_type, _U2>::value
102 && is_convertible<_U1, first_type>::value
103 && is_convertible<_U2, second_type>::value;118 && is_convertible<_U2, second_type>::value;
104 }119 }
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 }
105 };130 };
106131
107 template <bool _MaybeEnable>132 template <bool _MaybeEnable>
...@@ -127,12 +152,12 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -127,12 +152,12 @@ struct _LIBCPP_TEMPLATE_VIS pair
127 };152 };
128153
129 template <class _Tuple>154 template <class _Tuple>
130 using _CheckTLC _LIBCPP_NODEBUG = typename conditional<155 using _CheckTLC _LIBCPP_NODEBUG = __conditional_t<
131 __tuple_like_with_size<_Tuple, 2>::value156 __tuple_like_with_size<_Tuple, 2>::value
132 && !is_same<typename decay<_Tuple>::type, pair>::value,157 && !is_same<typename decay<_Tuple>::type, pair>::value,
133 _CheckTupleLikeConstructor,158 _CheckTupleLikeConstructor,
134 __check_tuple_constructor_fail159 __check_tuple_constructor_fail
135 >::type;160 >;
136161
137 template<bool _Dummy = true, typename enable_if<162 template<bool _Dummy = true, typename enable_if<
138 _CheckArgsDep<_Dummy>::__enable_explicit_default()163 _CheckArgsDep<_Dummy>::__enable_explicit_default()
...@@ -153,7 +178,7 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -153,7 +178,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
153 template <bool _Dummy = true, typename enable_if<178 template <bool _Dummy = true, typename enable_if<
154 _CheckArgsDep<_Dummy>::template __enable_explicit<_T1 const&, _T2 const&>()179 _CheckArgsDep<_Dummy>::template __enable_explicit<_T1 const&, _T2 const&>()
155 >::type* = nullptr>180 >::type* = nullptr>
156 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11181 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
157 explicit pair(_T1 const& __t1, _T2 const& __t2)182 explicit pair(_T1 const& __t1, _T2 const& __t2)
158 _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&183 _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
159 is_nothrow_copy_constructible<second_type>::value)184 is_nothrow_copy_constructible<second_type>::value)
...@@ -162,7 +187,7 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -162,7 +187,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
162 template<bool _Dummy = true, typename enable_if<187 template<bool _Dummy = true, typename enable_if<
163 _CheckArgsDep<_Dummy>::template __enable_implicit<_T1 const&, _T2 const&>()188 _CheckArgsDep<_Dummy>::template __enable_implicit<_T1 const&, _T2 const&>()
164 >::type* = nullptr>189 >::type* = nullptr>
165 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11190 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
166 pair(_T1 const& __t1, _T2 const& __t2)191 pair(_T1 const& __t1, _T2 const& __t2)
167 _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&192 _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
168 is_nothrow_copy_constructible<second_type>::value)193 is_nothrow_copy_constructible<second_type>::value)
...@@ -176,7 +201,7 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -176,7 +201,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
176#endif201#endif
177 typename enable_if<_CheckArgs::template __enable_explicit<_U1, _U2>()>::type* = nullptr202 typename enable_if<_CheckArgs::template __enable_explicit<_U1, _U2>()>::type* = nullptr
178 >203 >
179 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11204 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
180 explicit pair(_U1&& __u1, _U2&& __u2)205 explicit pair(_U1&& __u1, _U2&& __u2)
181 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value &&206 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value &&
182 is_nothrow_constructible<second_type, _U2>::value))207 is_nothrow_constructible<second_type, _U2>::value))
...@@ -190,16 +215,27 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -190,16 +215,27 @@ struct _LIBCPP_TEMPLATE_VIS pair
190#endif215#endif
191 typename enable_if<_CheckArgs::template __enable_implicit<_U1, _U2>()>::type* = nullptr216 typename enable_if<_CheckArgs::template __enable_implicit<_U1, _U2>()>::type* = nullptr
192 >217 >
193 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11218 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
194 pair(_U1&& __u1, _U2&& __u2)219 pair(_U1&& __u1, _U2&& __u2)
195 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value &&220 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value &&
196 is_nothrow_constructible<second_type, _U2>::value))221 is_nothrow_constructible<second_type, _U2>::value))
197 : first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {}222 : 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
199 template<class _U1, class _U2, typename enable_if<235 template<class _U1, class _U2, typename enable_if<
200 _CheckArgs::template __enable_explicit<_U1 const&, _U2 const&>()236 _CheckArgs::template __enable_explicit<_U1 const&, _U2 const&>()
201 >::type* = nullptr>237 >::type* = nullptr>
202 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11238 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
203 explicit pair(pair<_U1, _U2> const& __p)239 explicit pair(pair<_U1, _U2> const& __p)
204 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value &&240 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value &&
205 is_nothrow_constructible<second_type, _U2 const&>::value))241 is_nothrow_constructible<second_type, _U2 const&>::value))
...@@ -208,7 +244,7 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -208,7 +244,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
208 template<class _U1, class _U2, typename enable_if<244 template<class _U1, class _U2, typename enable_if<
209 _CheckArgs::template __enable_implicit<_U1 const&, _U2 const&>()245 _CheckArgs::template __enable_implicit<_U1 const&, _U2 const&>()
210 >::type* = nullptr>246 >::type* = nullptr>
211 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11247 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
212 pair(pair<_U1, _U2> const& __p)248 pair(pair<_U1, _U2> const& __p)
213 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value &&249 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value &&
214 is_nothrow_constructible<second_type, _U2 const&>::value))250 is_nothrow_constructible<second_type, _U2 const&>::value))
...@@ -217,7 +253,7 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -217,7 +253,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
217 template<class _U1, class _U2, typename enable_if<253 template<class _U1, class _U2, typename enable_if<
218 _CheckArgs::template __enable_explicit<_U1, _U2>()254 _CheckArgs::template __enable_explicit<_U1, _U2>()
219 >::type* = nullptr>255 >::type* = nullptr>
220 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11256 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
221 explicit pair(pair<_U1, _U2>&&__p)257 explicit pair(pair<_U1, _U2>&&__p)
222 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value &&258 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value &&
223 is_nothrow_constructible<second_type, _U2&&>::value))259 is_nothrow_constructible<second_type, _U2&&>::value))
...@@ -226,16 +262,28 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -226,16 +262,28 @@ struct _LIBCPP_TEMPLATE_VIS pair
226 template<class _U1, class _U2, typename enable_if<262 template<class _U1, class _U2, typename enable_if<
227 _CheckArgs::template __enable_implicit<_U1, _U2>()263 _CheckArgs::template __enable_implicit<_U1, _U2>()
228 >::type* = nullptr>264 >::type* = nullptr>
229 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11265 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
230 pair(pair<_U1, _U2>&& __p)266 pair(pair<_U1, _U2>&& __p)
231 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value &&267 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value &&
232 is_nothrow_constructible<second_type, _U2&&>::value))268 is_nothrow_constructible<second_type, _U2&&>::value))
233 : first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {}269 : 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
235 template<class _Tuple, typename enable_if<283 template<class _Tuple, typename enable_if<
236 _CheckTLC<_Tuple>::template __enable_explicit<_Tuple>()284 _CheckTLC<_Tuple>::template __enable_explicit<_Tuple>()
237 >::type* = nullptr>285 >::type* = nullptr>
238 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11286 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
239 explicit pair(_Tuple&& __p)287 explicit pair(_Tuple&& __p)
240 : first(_VSTD::get<0>(_VSTD::forward<_Tuple>(__p))),288 : first(_VSTD::get<0>(_VSTD::forward<_Tuple>(__p))),
241 second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {}289 second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {}
...@@ -243,13 +291,13 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -243,13 +291,13 @@ struct _LIBCPP_TEMPLATE_VIS pair
243 template<class _Tuple, typename enable_if<291 template<class _Tuple, typename enable_if<
244 _CheckTLC<_Tuple>::template __enable_implicit<_Tuple>()292 _CheckTLC<_Tuple>::template __enable_implicit<_Tuple>()
245 >::type* = nullptr>293 >::type* = nullptr>
246 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11294 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
247 pair(_Tuple&& __p)295 pair(_Tuple&& __p)
248 : first(_VSTD::get<0>(_VSTD::forward<_Tuple>(__p))),296 : first(_VSTD::get<0>(_VSTD::forward<_Tuple>(__p))),
249 second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {}297 second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {}
250298
251 template <class... _Args1, class... _Args2>299 template <class... _Args1, class... _Args2>
252 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17300 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
253 pair(piecewise_construct_t __pc,301 pair(piecewise_construct_t __pc,
254 tuple<_Args1...> __first_args, tuple<_Args2...> __second_args)302 tuple<_Args1...> __first_args, tuple<_Args2...> __second_args)
255 _NOEXCEPT_((is_nothrow_constructible<first_type, _Args1...>::value &&303 _NOEXCEPT_((is_nothrow_constructible<first_type, _Args1...>::value &&
...@@ -258,11 +306,11 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -258,11 +306,11 @@ struct _LIBCPP_TEMPLATE_VIS pair
258 typename __make_tuple_indices<sizeof...(_Args1)>::type(),306 typename __make_tuple_indices<sizeof...(_Args1)>::type(),
259 typename __make_tuple_indices<sizeof...(_Args2) >::type()) {}307 typename __make_tuple_indices<sizeof...(_Args2) >::type()) {}
260308
261 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17309 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
262 pair& operator=(typename conditional<310 pair& operator=(__conditional_t<
263 is_copy_assignable<first_type>::value &&311 is_copy_assignable<first_type>::value &&
264 is_copy_assignable<second_type>::value,312 is_copy_assignable<second_type>::value,
265 pair, __nat>::type const& __p)313 pair, __nat> const& __p)
266 _NOEXCEPT_(is_nothrow_copy_assignable<first_type>::value &&314 _NOEXCEPT_(is_nothrow_copy_assignable<first_type>::value &&
267 is_nothrow_copy_assignable<second_type>::value)315 is_nothrow_copy_assignable<second_type>::value)
268 {316 {
...@@ -271,11 +319,11 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -271,11 +319,11 @@ struct _LIBCPP_TEMPLATE_VIS pair
271 return *this;319 return *this;
272 }320 }
273321
274 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17322 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
275 pair& operator=(typename conditional<323 pair& operator=(__conditional_t<
276 is_move_assignable<first_type>::value &&324 is_move_assignable<first_type>::value &&
277 is_move_assignable<second_type>::value,325 is_move_assignable<second_type>::value,
278 pair, __nat>::type&& __p)326 pair, __nat>&& __p)
279 _NOEXCEPT_(is_nothrow_move_assignable<first_type>::value &&327 _NOEXCEPT_(is_nothrow_move_assignable<first_type>::value &&
280 is_nothrow_move_assignable<second_type>::value)328 is_nothrow_move_assignable<second_type>::value)
281 {329 {
...@@ -284,10 +332,54 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -284,10 +332,54 @@ struct _LIBCPP_TEMPLATE_VIS pair
284 return *this;332 return *this;
285 }333 }
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
287 template <class _Tuple, typename enable_if<379 template <class _Tuple, typename enable_if<
288 _CheckTLC<_Tuple>::template __enable_assign<_Tuple>()380 _CheckTLC<_Tuple>::template __enable_assign<_Tuple>()
289 >::type* = nullptr>381 >::type* = nullptr>
290 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17382 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
291 pair& operator=(_Tuple&& __p) {383 pair& operator=(_Tuple&& __p) {
292 first = _VSTD::get<0>(_VSTD::forward<_Tuple>(__p));384 first = _VSTD::get<0>(_VSTD::forward<_Tuple>(__p));
293 second = _VSTD::get<1>(_VSTD::forward<_Tuple>(__p));385 second = _VSTD::get<1>(_VSTD::forward<_Tuple>(__p));
...@@ -295,7 +387,7 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -295,7 +387,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
295 }387 }
296#endif388#endif
297389
298 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17390 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
299 void391 void
300 swap(pair& __p) _NOEXCEPT_(__is_nothrow_swappable<first_type>::value &&392 swap(pair& __p) _NOEXCEPT_(__is_nothrow_swappable<first_type>::value &&
301 __is_nothrow_swappable<second_type>::value)393 __is_nothrow_swappable<second_type>::value)
...@@ -304,11 +396,23 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -304,11 +396,23 @@ struct _LIBCPP_TEMPLATE_VIS pair
304 swap(first, __p.first);396 swap(first, __p.first);
305 swap(second, __p.second);397 swap(second, __p.second);
306 }398 }
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
307private:411private:
308412
309#ifndef _LIBCPP_CXX03_LANG413#ifndef _LIBCPP_CXX03_LANG
310 template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>414 template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
311 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17415 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
312 pair(piecewise_construct_t,416 pair(piecewise_construct_t,
313 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,417 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
314 __tuple_indices<_I1...>, __tuple_indices<_I2...>);418 __tuple_indices<_I1...>, __tuple_indices<_I2...>);
...@@ -323,7 +427,7 @@ pair(_T1, _T2) -> pair<_T1, _T2>;...@@ -323,7 +427,7 @@ pair(_T1, _T2) -> pair<_T1, _T2>;
323// [pairs.spec], specialized algorithms427// [pairs.spec], specialized algorithms
324428
325template <class _T1, class _T2>429template <class _T1, class _T2>
326inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11430inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
327bool431bool
328operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)432operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
329{433{
...@@ -348,7 +452,7 @@ operator<=>(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)...@@ -348,7 +452,7 @@ operator<=>(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
348#else // _LIBCPP_STD_VER > 17452#else // _LIBCPP_STD_VER > 17
349453
350template <class _T1, class _T2>454template <class _T1, class _T2>
351inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11455inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
352bool456bool
353operator!=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)457operator!=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
354{458{
...@@ -356,7 +460,7 @@ operator!=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)...@@ -356,7 +460,7 @@ operator!=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
356}460}
357461
358template <class _T1, class _T2>462template <class _T1, class _T2>
359inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11463inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
360bool464bool
361operator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)465operator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
362{466{
...@@ -364,7 +468,7 @@ operator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)...@@ -364,7 +468,7 @@ operator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
364}468}
365469
366template <class _T1, class _T2>470template <class _T1, class _T2>
367inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11471inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
368bool472bool
369operator> (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)473operator> (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
370{474{
...@@ -372,7 +476,7 @@ operator> (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)...@@ -372,7 +476,7 @@ operator> (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
372}476}
373477
374template <class _T1, class _T2>478template <class _T1, class _T2>
375inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11479inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
376bool480bool
377operator>=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)481operator>=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
378{482{
...@@ -380,7 +484,7 @@ operator>=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)...@@ -380,7 +484,7 @@ operator>=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
380}484}
381485
382template <class _T1, class _T2>486template <class _T1, class _T2>
383inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11487inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
384bool488bool
385operator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)489operator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
386{490{
...@@ -406,7 +510,7 @@ struct common_type<pair<_T1, _T2>, pair<_U1, _U2>> {...@@ -406,7 +510,7 @@ struct common_type<pair<_T1, _T2>, pair<_U1, _U2>> {
406#endif // _LIBCPP_STD_VER > 20510#endif // _LIBCPP_STD_VER > 20
407511
408template <class _T1, class _T2>512template <class _T1, class _T2>
409inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17513inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
410typename enable_if514typename enable_if
411<515<
412 __is_swappable<_T1>::value &&516 __is_swappable<_T1>::value &&
...@@ -420,10 +524,20 @@ swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)...@@ -420,10 +524,20 @@ swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
420 __x.swap(__y);524 __x.swap(__y);
421}525}
422526
423#ifndef _LIBCPP_CXX03_LANG527#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
425template <class _T1, class _T2>539template <class _T1, class _T2>
426inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11540inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
427pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type>541pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type>
428make_pair(_T1&& __t1, _T2&& __t2)542make_pair(_T1&& __t1, _T2&& __t2)
429{543{
...@@ -431,18 +545,6 @@ make_pair(_T1&& __t1, _T2&& __t2)...@@ -431,18 +545,6 @@ make_pair(_T1&& __t1, _T2&& __t2)
431 (_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2));545 (_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2));
432}546}
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
446template <class _T1, class _T2>548template <class _T1, class _T2>
447 struct _LIBCPP_TEMPLATE_VIS tuple_size<pair<_T1, _T2> >549 struct _LIBCPP_TEMPLATE_VIS tuple_size<pair<_T1, _T2> >
448 : public integral_constant<size_t, 2> {};550 : public integral_constant<size_t, 2> {};
...@@ -472,29 +574,27 @@ struct __get_pair<0>...@@ -472,29 +574,27 @@ struct __get_pair<0>
472{574{
473 template <class _T1, class _T2>575 template <class _T1, class _T2>
474 static576 static
475 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11577 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
476 _T1&578 _T1&
477 get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;}579 get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;}
478580
479 template <class _T1, class _T2>581 template <class _T1, class _T2>
480 static582 static
481 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11583 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
482 const _T1&584 const _T1&
483 get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;}585 get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;}
484586
485#ifndef _LIBCPP_CXX03_LANG
486 template <class _T1, class _T2>587 template <class _T1, class _T2>
487 static588 static
488 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11589 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
489 _T1&&590 _T1&&
490 get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T1>(__p.first);}591 get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T1>(__p.first);}
491592
492 template <class _T1, class _T2>593 template <class _T1, class _T2>
493 static594 static
494 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11595 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
495 const _T1&&596 const _T1&&
496 get(const pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<const _T1>(__p.first);}597 get(const pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<const _T1>(__p.first);}
497#endif // _LIBCPP_CXX03_LANG
498};598};
499599
500template <>600template <>
...@@ -502,33 +602,31 @@ struct __get_pair<1>...@@ -502,33 +602,31 @@ struct __get_pair<1>
502{602{
503 template <class _T1, class _T2>603 template <class _T1, class _T2>
504 static604 static
505 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11605 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
506 _T2&606 _T2&
507 get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;}607 get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;}
508608
509 template <class _T1, class _T2>609 template <class _T1, class _T2>
510 static610 static
511 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11611 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
512 const _T2&612 const _T2&
513 get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;}613 get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;}
514614
515#ifndef _LIBCPP_CXX03_LANG
516 template <class _T1, class _T2>615 template <class _T1, class _T2>
517 static616 static
518 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11617 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
519 _T2&&618 _T2&&
520 get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T2>(__p.second);}619 get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T2>(__p.second);}
521620
522 template <class _T1, class _T2>621 template <class _T1, class _T2>
523 static622 static
524 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11623 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
525 const _T2&&624 const _T2&&
526 get(const pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<const _T2>(__p.second);}625 get(const pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<const _T2>(__p.second);}
527#endif // _LIBCPP_CXX03_LANG
528};626};
529627
530template <size_t _Ip, class _T1, class _T2>628template <size_t _Ip, class _T1, class _T2>
531inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11629inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
532typename tuple_element<_Ip, pair<_T1, _T2> >::type&630typename tuple_element<_Ip, pair<_T1, _T2> >::type&
533get(pair<_T1, _T2>& __p) _NOEXCEPT631get(pair<_T1, _T2>& __p) _NOEXCEPT
534{632{
...@@ -536,16 +634,15 @@ get(pair<_T1, _T2>& __p) _NOEXCEPT...@@ -536,16 +634,15 @@ get(pair<_T1, _T2>& __p) _NOEXCEPT
536}634}
537635
538template <size_t _Ip, class _T1, class _T2>636template <size_t _Ip, class _T1, class _T2>
539inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11637inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
540const typename tuple_element<_Ip, pair<_T1, _T2> >::type&638const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
541get(const pair<_T1, _T2>& __p) _NOEXCEPT639get(const pair<_T1, _T2>& __p) _NOEXCEPT
542{640{
543 return __get_pair<_Ip>::get(__p);641 return __get_pair<_Ip>::get(__p);
544}642}
545643
546#ifndef _LIBCPP_CXX03_LANG
547template <size_t _Ip, class _T1, class _T2>644template <size_t _Ip, class _T1, class _T2>
548inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11645inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
549typename tuple_element<_Ip, pair<_T1, _T2> >::type&&646typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
550get(pair<_T1, _T2>&& __p) _NOEXCEPT647get(pair<_T1, _T2>&& __p) _NOEXCEPT
551{648{
...@@ -553,13 +650,12 @@ get(pair<_T1, _T2>&& __p) _NOEXCEPT...@@ -553,13 +650,12 @@ get(pair<_T1, _T2>&& __p) _NOEXCEPT
553}650}
554651
555template <size_t _Ip, class _T1, class _T2>652template <size_t _Ip, class _T1, class _T2>
556inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11653inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
557const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&654const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
558get(const pair<_T1, _T2>&& __p) _NOEXCEPT655get(const pair<_T1, _T2>&& __p) _NOEXCEPT
559{656{
560 return __get_pair<_Ip>::get(_VSTD::move(__p));657 return __get_pair<_Ip>::get(_VSTD::move(__p));
561}658}
562#endif // _LIBCPP_CXX03_LANG
563659
564#if _LIBCPP_STD_VER > 11660#if _LIBCPP_STD_VER > 11
565template <class _T1, class _T2>661template <class _T1, class _T2>
...@@ -618,7 +714,7 @@ constexpr _T1 const && get(pair<_T2, _T1> const&& __p) _NOEXCEPT...@@ -618,7 +714,7 @@ constexpr _T1 const && get(pair<_T2, _T1> const&& __p) _NOEXCEPT
618 return __get_pair<1>::get(_VSTD::move(__p));714 return __get_pair<1>::get(_VSTD::move(__p));
619}715}
620716
621#endif717#endif // _LIBCPP_STD_VER > 11
622718
623_LIBCPP_END_NAMESPACE_STD719_LIBCPP_END_NAMESPACE_STD
624720
lib/libcxx/include/__utility/rel_ops.h-3
...@@ -10,9 +10,6 @@...@@ -10,9 +10,6 @@
10#define _LIBCPP___UTILITY_REL_OPS_H10#define _LIBCPP___UTILITY_REL_OPS_H
1111
12#include <__config>12#include <__config>
13#include <__utility/forward.h>
14#include <__utility/move.h>
15#include <type_traits>
1613
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header15# pragma GCC system_header
lib/libcxx/include/__utility/swap.h+7-3
...@@ -10,10 +10,14 @@...@@ -10,10 +10,14 @@
10#define _LIBCPP___UTILITY_SWAP_H10#define _LIBCPP___UTILITY_SWAP_H
1111
12#include <__config>12#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>
13#include <__utility/declval.h>18#include <__utility/declval.h>
14#include <__utility/move.h>19#include <__utility/move.h>
15#include <cstddef>20#include <cstddef>
16#include <type_traits>
1721
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header23# pragma GCC system_header
...@@ -30,7 +34,7 @@ using __swap_result_t = void;...@@ -30,7 +34,7 @@ using __swap_result_t = void;
30#endif34#endif
3135
32template <class _Tp>36template <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)
34 _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value&& is_nothrow_move_assignable<_Tp>::value) {38 _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value&& is_nothrow_move_assignable<_Tp>::value) {
35 _Tp __t(_VSTD::move(__x));39 _Tp __t(_VSTD::move(__x));
36 __x = _VSTD::move(__y);40 __x = _VSTD::move(__y);
...@@ -38,7 +42,7 @@ inline _LIBCPP_INLINE_VISIBILITY __swap_result_t<_Tp> _LIBCPP_CONSTEXPR_AFTER_CX...@@ -38,7 +42,7 @@ inline _LIBCPP_INLINE_VISIBILITY __swap_result_t<_Tp> _LIBCPP_CONSTEXPR_AFTER_CX
38}42}
3943
40template <class _Tp, size_t _Np>44template <class _Tp, size_t _Np>
41inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if<__is_swappable<_Tp>::value>::type45inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 typename enable_if<__is_swappable<_Tp>::value>::type
42swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {46swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
43 for (size_t __i = 0; __i != _Np; ++__i) {47 for (size_t __i = 0; __i != _Np; ++__i) {
44 swap(__a[__i], __b[__i]);48 swap(__a[__i], __b[__i]);
lib/libcxx/include/__utility/to_underlying.h+1-1
...@@ -11,7 +11,7 @@...@@ -11,7 +11,7 @@
11#define _LIBCPP___UTILITY_TO_UNDERLYING_H11#define _LIBCPP___UTILITY_TO_UNDERLYING_H
1212
13#include <__config>13#include <__config>
14#include <type_traits>14#include <__type_traits/underlying_type.h>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header17# 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 @@...@@ -9,8 +9,8 @@
9#ifndef _LIBCPP___UTILITY_UNREACHABLE_H9#ifndef _LIBCPP___UTILITY_UNREACHABLE_H
10#define _LIBCPP___UTILITY_UNREACHABLE_H10#define _LIBCPP___UTILITY_UNREACHABLE_H
1111
12#include <__assert>
12#include <__config>13#include <__config>
13#include <cstdlib>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header16# pragma GCC system_header
...@@ -18,21 +18,17 @@...@@ -18,21 +18,17 @@
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void __libcpp_unreachable()21_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void __libcpp_unreachable() {
22{22 _LIBCPP_ASSERT(false, "std::unreachable() was reached");
23#if __has_builtin(__builtin_unreachable)23 __builtin_unreachable();
24 __builtin_unreachable();
25#else
26 std::abort();
27#endif
28}24}
2925
30#if _LIBCPP_STD_VER > 2026#if _LIBCPP_STD_VER > 20
3127
32[[noreturn]] _LIBCPP_HIDE_FROM_ABI inline void unreachable() { __libcpp_unreachable(); }28[[noreturn]] _LIBCPP_HIDE_FROM_ABI inline void unreachable() { __libcpp_unreachable(); }
3329
34#endif // _LIBCPP_STD_VER > 2030#endif
3531
36_LIBCPP_END_NAMESPACE_STD32_LIBCPP_END_NAMESPACE_STD
3733
38#endif34#endif // _LIBCPP___UTILITY_UNREACHABLE_H
lib/libcxx/include/__variant/monostate.h+18-14
...@@ -10,6 +10,7 @@...@@ -10,6 +10,7 @@
10#ifndef _LIBCPP___VARIANT_MONOSTATE_H10#ifndef _LIBCPP___VARIANT_MONOSTATE_H
11#define _LIBCPP___VARIANT_MONOSTATE_H11#define _LIBCPP___VARIANT_MONOSTATE_H
1212
13#include <__compare/ordering.h>
13#include <__config>14#include <__config>
14#include <__functional/hash.h>15#include <__functional/hash.h>
15#include <cstddef>16#include <cstddef>
...@@ -24,31 +25,34 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -24,31 +25,34 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2425
25struct _LIBCPP_TEMPLATE_VIS monostate {};26struct _LIBCPP_TEMPLATE_VIS monostate {};
2627
27inline _LIBCPP_INLINE_VISIBILITY28_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(monostate, monostate) noexcept { return true; }
28constexpr bool operator<(monostate, monostate) noexcept { return false; }
2929
30inline _LIBCPP_INLINE_VISIBILITY30# if _LIBCPP_STD_VER > 17
31constexpr bool operator>(monostate, monostate) noexcept { return false; }
3231
33inline _LIBCPP_INLINE_VISIBILITY32_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(monostate, monostate) noexcept {
34constexpr bool operator<=(monostate, monostate) noexcept { return true; }33 return strong_ordering::equal;
34}
3535
36inline _LIBCPP_INLINE_VISIBILITY36# else // _LIBCPP_STD_VER > 17
37constexpr bool operator>=(monostate, monostate) noexcept { return true; }
3837
39inline _LIBCPP_INLINE_VISIBILITY38_LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(monostate, monostate) noexcept { return false; }
40constexpr bool operator==(monostate, monostate) noexcept { return true; }
4139
42inline _LIBCPP_INLINE_VISIBILITY40_LIBCPP_HIDE_FROM_ABI constexpr bool operator<(monostate, monostate) noexcept { return false; }
43constexpr 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
45template <>50template <>
46struct _LIBCPP_TEMPLATE_VIS hash<monostate> {51struct _LIBCPP_TEMPLATE_VIS hash<monostate> {
47 using argument_type = monostate;52 using argument_type = monostate;
48 using result_type = size_t;53 using result_type = size_t;
4954
50 inline _LIBCPP_INLINE_VISIBILITY55 inline _LIBCPP_HIDE_FROM_ABI result_type operator()(const argument_type&) const _NOEXCEPT {
51 result_type operator()(const argument_type&) const _NOEXCEPT {
52 return 66740831; // return a fundamentally attractive random value.56 return 66740831; // return a fundamentally attractive random value.
53 }57 }
54};58};
lib/libcxx/include/__verbose_abort+30-24
...@@ -17,35 +17,41 @@...@@ -17,35 +17,41 @@
17# pragma GCC system_header17# pragma GCC system_header
18#endif18#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
42_LIBCPP_BEGIN_NAMESPACE_STD20_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.
44_LIBCPP_NORETURN _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2)24_LIBCPP_NORETURN _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2)
45void __libcpp_verbose_abort(const char *__format, ...);25void __libcpp_verbose_abort(const char *__format, ...);
4626
47_LIBCPP_END_NAMESPACE_STD27// _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#endif55_LIBCPP_END_NAMESPACE_STD
5056
51#endif // _LIBCPP___VERBOSE_ABORT57#endif // _LIBCPP___VERBOSE_ABORT
lib/libcxx/include/algorithm+17-10
...@@ -1704,12 +1704,9 @@ template <class BidirectionalIterator, class Compare>...@@ -1704,12 +1704,9 @@ template <class BidirectionalIterator, class Compare>
1704*/1704*/
17051705
1706#include <__assert> // all public C++ headers provide the assertion handler1706#include <__assert> // all public C++ headers provide the assertion handler
1707#include <__bits>
1708#include <__config>1707#include <__config>
1709#include <__debug>1708#include <__debug>
1710#include <cstddef>1709#include <cstddef>
1711#include <cstring>
1712#include <memory>
1713#include <type_traits>1710#include <type_traits>
1714#include <version>1711#include <version>
17151712
...@@ -1899,13 +1896,9 @@ template <class BidirectionalIterator, class Compare>...@@ -1899,13 +1896,9 @@ template <class BidirectionalIterator, class Compare>
1899#include <__algorithm/unwrap_iter.h>1896#include <__algorithm/unwrap_iter.h>
1900#include <__algorithm/upper_bound.h>1897#include <__algorithm/upper_bound.h>
19011898
1902#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
1903# include <chrono>
1904# include <iterator>
1905# include <utility>
1906#endif
1907
1908// standard-mandated includes1899// standard-mandated includes
1900
1901// [algorithm.syn]
1909#include <initializer_list>1902#include <initializer_list>
19101903
1911#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)1904#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -1913,7 +1906,21 @@ template <class BidirectionalIterator, class Compare>...@@ -1913,7 +1906,21 @@ template <class BidirectionalIterator, class Compare>
1913#endif1906#endif
19141907
1915#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 171908#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>
1917#endif1924#endif
19181925
1919#endif // _LIBCPP_ALGORITHM1926#endif // _LIBCPP_ALGORITHM
lib/libcxx/include/any+57-43
...@@ -83,21 +83,20 @@ namespace std {...@@ -83,21 +83,20 @@ namespace std {
83#include <__assert> // all public C++ headers provide the assertion handler83#include <__assert> // all public C++ headers provide the assertion handler
84#include <__availability>84#include <__availability>
85#include <__config>85#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>
86#include <__utility/forward.h>90#include <__utility/forward.h>
87#include <__utility/in_place.h>91#include <__utility/in_place.h>
88#include <__utility/move.h>92#include <__utility/move.h>
89#include <__utility/unreachable.h>93#include <__utility/unreachable.h>
90#include <cstdlib>94#include <cstdlib>
91#include <initializer_list>95#include <initializer_list>
92#include <memory>
93#include <type_traits>96#include <type_traits>
94#include <typeinfo>97#include <typeinfo>
95#include <version>98#include <version>
9699
97#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
98# include <chrono>
99#endif
100
101#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)100#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
102# pragma GCC system_header101# pragma GCC system_header
103#endif102#endif
...@@ -106,7 +105,7 @@ namespace std {...@@ -106,7 +105,7 @@ namespace std {
106class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast105class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast
107{106{
108public:107public:
109 virtual const char* what() const _NOEXCEPT;108 const char* what() const _NOEXCEPT override;
110};109};
111} // namespace std110} // namespace std
112111
...@@ -139,7 +138,9 @@ add_pointer_t<_ValueType> any_cast(any *) _NOEXCEPT;...@@ -139,7 +138,9 @@ add_pointer_t<_ValueType> any_cast(any *) _NOEXCEPT;
139138
140namespace __any_imp139namespace __any_imp
141{140{
141 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
142 using _Buffer = aligned_storage_t<3*sizeof(void*), alignment_of<void*>::value>;142 using _Buffer = aligned_storage_t<3*sizeof(void*), alignment_of<void*>::value>;
143 _LIBCPP_SUPPRESS_DEPRECATED_POP
143144
144 template <class _Tp>145 template <class _Tp>
145 using _IsSmallObject = integral_constant<bool146 using _IsSmallObject = integral_constant<bool
...@@ -194,18 +195,18 @@ class _LIBCPP_TEMPLATE_VIS any...@@ -194,18 +195,18 @@ class _LIBCPP_TEMPLATE_VIS any
194public:195public:
195 // construct/destruct196 // construct/destruct
196 _LIBCPP_INLINE_VISIBILITY197 _LIBCPP_INLINE_VISIBILITY
197 constexpr any() _NOEXCEPT : __h(nullptr) {}198 constexpr any() _NOEXCEPT : __h_(nullptr) {}
198199
199 _LIBCPP_INLINE_VISIBILITY200 _LIBCPP_INLINE_VISIBILITY
200 any(any const & __other) : __h(nullptr)201 any(any const & __other) : __h_(nullptr)
201 {202 {
202 if (__other.__h) __other.__call(_Action::_Copy, this);203 if (__other.__h_) __other.__call(_Action::_Copy, this);
203 }204 }
204205
205 _LIBCPP_INLINE_VISIBILITY206 _LIBCPP_INLINE_VISIBILITY
206 any(any && __other) _NOEXCEPT : __h(nullptr)207 any(any && __other) _NOEXCEPT : __h_(nullptr)
207 {208 {
208 if (__other.__h) __other.__call(_Action::_Move, this);209 if (__other.__h_) __other.__call(_Action::_Move, this);
209 }210 }
210211
211 template <212 template <
...@@ -284,19 +285,19 @@ public:...@@ -284,19 +285,19 @@ public:
284285
285 // 6.3.3 any modifiers286 // 6.3.3 any modifiers
286 _LIBCPP_INLINE_VISIBILITY287 _LIBCPP_INLINE_VISIBILITY
287 void reset() _NOEXCEPT { if (__h) this->__call(_Action::_Destroy); }288 void reset() _NOEXCEPT { if (__h_) this->__call(_Action::_Destroy); }
288289
289 _LIBCPP_INLINE_VISIBILITY290 _LIBCPP_INLINE_VISIBILITY
290 void swap(any & __rhs) _NOEXCEPT;291 void swap(any & __rhs) _NOEXCEPT;
291292
292 // 6.3.4 any observers293 // 6.3.4 any observers
293 _LIBCPP_INLINE_VISIBILITY294 _LIBCPP_INLINE_VISIBILITY
294 bool has_value() const _NOEXCEPT { return __h != nullptr; }295 bool has_value() const _NOEXCEPT { return __h_ != nullptr; }
295296
296#if !defined(_LIBCPP_NO_RTTI)297#if !defined(_LIBCPP_NO_RTTI)
297 _LIBCPP_INLINE_VISIBILITY298 _LIBCPP_INLINE_VISIBILITY
298 const type_info & type() const _NOEXCEPT {299 const type_info & type() const _NOEXCEPT {
299 if (__h) {300 if (__h_) {
300 return *static_cast<type_info const *>(this->__call(_Action::_TypeInfo));301 return *static_cast<type_info const *>(this->__call(_Action::_TypeInfo));
301 } else {302 } else {
302 return typeid(void);303 return typeid(void);
...@@ -320,7 +321,7 @@ private:...@@ -320,7 +321,7 @@ private:
320 type_info const * __info = nullptr,321 type_info const * __info = nullptr,
321 const void* __fallback_info = nullptr) const322 const void* __fallback_info = nullptr) const
322 {323 {
323 return __h(__a, this, __other, __info, __fallback_info);324 return __h_(__a, this, __other, __info, __fallback_info);
324 }325 }
325326
326 _LIBCPP_INLINE_VISIBILITY327 _LIBCPP_INLINE_VISIBILITY
...@@ -328,7 +329,7 @@ private:...@@ -328,7 +329,7 @@ private:
328 type_info const * __info = nullptr,329 type_info const * __info = nullptr,
329 const void* __fallback_info = nullptr)330 const void* __fallback_info = nullptr)
330 {331 {
331 return __h(__a, this, __other, __info, __fallback_info);332 return __h_(__a, this, __other, __info, __fallback_info);
332 }333 }
333334
334 template <class>335 template <class>
...@@ -344,8 +345,8 @@ private:...@@ -344,8 +345,8 @@ private:
344 friend add_pointer_t<_ValueType>345 friend add_pointer_t<_ValueType>
345 any_cast(any *) _NOEXCEPT;346 any_cast(any *) _NOEXCEPT;
346347
347 _HandleFuncPtr __h = nullptr;348 _HandleFuncPtr __h_ = nullptr;
348 _Storage __s;349 _Storage __s_;
349};350};
350351
351namespace __any_imp352namespace __any_imp
...@@ -382,9 +383,9 @@ namespace __any_imp...@@ -382,9 +383,9 @@ namespace __any_imp
382 typedef allocator<_Tp> _Alloc;383 typedef allocator<_Tp> _Alloc;
383 typedef allocator_traits<_Alloc> _ATraits;384 typedef allocator_traits<_Alloc> _ATraits;
384 _Alloc __a;385 _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));
386 _ATraits::construct(__a, __ret, _VSTD::forward<_Args>(__args)...);387 _ATraits::construct(__a, __ret, _VSTD::forward<_Args>(__args)...);
387 __dest.__h = &_SmallHandler::__handle;388 __dest.__h_ = &_SmallHandler::__handle;
388 return *__ret;389 return *__ret;
389 }390 }
390391
...@@ -394,21 +395,21 @@ namespace __any_imp...@@ -394,21 +395,21 @@ namespace __any_imp
394 typedef allocator<_Tp> _Alloc;395 typedef allocator<_Tp> _Alloc;
395 typedef allocator_traits<_Alloc> _ATraits;396 typedef allocator_traits<_Alloc> _ATraits;
396 _Alloc __a;397 _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));
398 _ATraits::destroy(__a, __p);399 _ATraits::destroy(__a, __p);
399 __this.__h = nullptr;400 __this.__h_ = nullptr;
400 }401 }
401402
402 _LIBCPP_INLINE_VISIBILITY403 _LIBCPP_INLINE_VISIBILITY
403 static void __copy(any const & __this, any & __dest) {404 static void __copy(any const & __this, any & __dest) {
404 _SmallHandler::__create(__dest, *static_cast<_Tp const *>(405 _SmallHandler::__create(__dest, *static_cast<_Tp const *>(
405 static_cast<void const *>(&__this.__s.__buf)));406 static_cast<void const *>(&__this.__s_.__buf)));
406 }407 }
407408
408 _LIBCPP_INLINE_VISIBILITY409 _LIBCPP_INLINE_VISIBILITY
409 static void __move(any & __this, any & __dest) {410 static void __move(any & __this, any & __dest) {
410 _SmallHandler::__create(__dest, _VSTD::move(411 _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))));
412 __destroy(__this);413 __destroy(__this);
413 }414 }
414415
...@@ -418,7 +419,7 @@ namespace __any_imp...@@ -418,7 +419,7 @@ namespace __any_imp
418 const void* __fallback_id)419 const void* __fallback_id)
419 {420 {
420 if (__any_imp::__compare_typeid<_Tp>(__info, __fallback_id))421 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);
422 return nullptr;423 return nullptr;
423 }424 }
424425
...@@ -470,8 +471,8 @@ namespace __any_imp...@@ -470,8 +471,8 @@ namespace __any_imp
470 unique_ptr<_Tp, _Dp> __hold(_ATraits::allocate(__a, 1), _Dp(__a, 1));471 unique_ptr<_Tp, _Dp> __hold(_ATraits::allocate(__a, 1), _Dp(__a, 1));
471 _Tp * __ret = __hold.get();472 _Tp * __ret = __hold.get();
472 _ATraits::construct(__a, __ret, _VSTD::forward<_Args>(__args)...);473 _ATraits::construct(__a, __ret, _VSTD::forward<_Args>(__args)...);
473 __dest.__s.__ptr = __hold.release();474 __dest.__s_.__ptr = __hold.release();
474 __dest.__h = &_LargeHandler::__handle;475 __dest.__h_ = &_LargeHandler::__handle;
475 return *__ret;476 return *__ret;
476 }477 }
477478
...@@ -482,22 +483,22 @@ namespace __any_imp...@@ -482,22 +483,22 @@ namespace __any_imp
482 typedef allocator<_Tp> _Alloc;483 typedef allocator<_Tp> _Alloc;
483 typedef allocator_traits<_Alloc> _ATraits;484 typedef allocator_traits<_Alloc> _ATraits;
484 _Alloc __a;485 _Alloc __a;
485 _Tp * __p = static_cast<_Tp *>(__this.__s.__ptr);486 _Tp * __p = static_cast<_Tp *>(__this.__s_.__ptr);
486 _ATraits::destroy(__a, __p);487 _ATraits::destroy(__a, __p);
487 _ATraits::deallocate(__a, __p, 1);488 _ATraits::deallocate(__a, __p, 1);
488 __this.__h = nullptr;489 __this.__h_ = nullptr;
489 }490 }
490491
491 _LIBCPP_INLINE_VISIBILITY492 _LIBCPP_INLINE_VISIBILITY
492 static void __copy(any const & __this, any & __dest) {493 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));
494 }495 }
495496
496 _LIBCPP_INLINE_VISIBILITY497 _LIBCPP_INLINE_VISIBILITY
497 static void __move(any & __this, any & __dest) {498 static void __move(any & __this, any & __dest) {
498 __dest.__s.__ptr = __this.__s.__ptr;499 __dest.__s_.__ptr = __this.__s_.__ptr;
499 __dest.__h = &_LargeHandler::__handle;500 __dest.__h_ = &_LargeHandler::__handle;
500 __this.__h = nullptr;501 __this.__h_ = nullptr;
501 }502 }
502503
503 _LIBCPP_INLINE_VISIBILITY504 _LIBCPP_INLINE_VISIBILITY
...@@ -505,7 +506,7 @@ namespace __any_imp...@@ -505,7 +506,7 @@ namespace __any_imp
505 void const* __fallback_info)506 void const* __fallback_info)
506 {507 {
507 if (__any_imp::__compare_typeid<_Tp>(__info, __fallback_info))508 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);
509 return nullptr;510 return nullptr;
510511
511 }512 }
...@@ -525,7 +526,7 @@ namespace __any_imp...@@ -525,7 +526,7 @@ namespace __any_imp
525526
526527
527template <class _ValueType, class _Tp, class>528template <class _ValueType, class _Tp, class>
528any::any(_ValueType && __v) : __h(nullptr)529any::any(_ValueType && __v) : __h_(nullptr)
529{530{
530 __any_imp::_Handler<_Tp>::__create(*this, _VSTD::forward<_ValueType>(__v));531 __any_imp::_Handler<_Tp>::__create(*this, _VSTD::forward<_ValueType>(__v));
531}532}
...@@ -567,16 +568,16 @@ void any::swap(any & __rhs) _NOEXCEPT...@@ -567,16 +568,16 @@ void any::swap(any & __rhs) _NOEXCEPT
567{568{
568 if (this == &__rhs)569 if (this == &__rhs)
569 return;570 return;
570 if (__h && __rhs.__h) {571 if (__h_ && __rhs.__h_) {
571 any __tmp;572 any __tmp;
572 __rhs.__call(_Action::_Move, &__tmp);573 __rhs.__call(_Action::_Move, &__tmp);
573 this->__call(_Action::_Move, &__rhs);574 this->__call(_Action::_Move, &__rhs);
574 __tmp.__call(_Action::_Move, this);575 __tmp.__call(_Action::_Move, this);
575 }576 }
576 else if (__h) {577 else if (__h_) {
577 this->__call(_Action::_Move, &__rhs);578 this->__call(_Action::_Move, &__rhs);
578 }579 }
579 else if (__rhs.__h) {580 else if (__rhs.__h_) {
580 __rhs.__call(_Action::_Move, this);581 __rhs.__call(_Action::_Move, this);
581 }582 }
582}583}
...@@ -606,7 +607,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -606,7 +607,7 @@ inline _LIBCPP_INLINE_VISIBILITY
606_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST607_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
607_ValueType any_cast(any const & __v)608_ValueType any_cast(any const & __v)
608{609{
609 using _RawValueType = __uncvref_t<_ValueType>;610 using _RawValueType = __remove_cvref_t<_ValueType>;
610 static_assert(is_constructible<_ValueType, _RawValueType const &>::value,611 static_assert(is_constructible<_ValueType, _RawValueType const &>::value,
611 "ValueType is required to be a const lvalue reference "612 "ValueType is required to be a const lvalue reference "
612 "or a CopyConstructible type");613 "or a CopyConstructible type");
...@@ -621,7 +622,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -621,7 +622,7 @@ inline _LIBCPP_INLINE_VISIBILITY
621_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST622_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
622_ValueType any_cast(any & __v)623_ValueType any_cast(any & __v)
623{624{
624 using _RawValueType = __uncvref_t<_ValueType>;625 using _RawValueType = __remove_cvref_t<_ValueType>;
625 static_assert(is_constructible<_ValueType, _RawValueType &>::value,626 static_assert(is_constructible<_ValueType, _RawValueType &>::value,
626 "ValueType is required to be an lvalue reference "627 "ValueType is required to be an lvalue reference "
627 "or a CopyConstructible type");628 "or a CopyConstructible type");
...@@ -636,7 +637,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -636,7 +637,7 @@ inline _LIBCPP_INLINE_VISIBILITY
636_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST637_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
637_ValueType any_cast(any && __v)638_ValueType any_cast(any && __v)
638{639{
639 using _RawValueType = __uncvref_t<_ValueType>;640 using _RawValueType = __remove_cvref_t<_ValueType>;
640 static_assert(is_constructible<_ValueType, _RawValueType>::value,641 static_assert(is_constructible<_ValueType, _RawValueType>::value,
641 "ValueType is required to be an rvalue reference "642 "ValueType is required to be an rvalue reference "
642 "or a CopyConstructible type");643 "or a CopyConstructible type");
...@@ -676,8 +677,8 @@ any_cast(any * __any) _NOEXCEPT...@@ -676,8 +677,8 @@ any_cast(any * __any) _NOEXCEPT
676 using __any_imp::_Action;677 using __any_imp::_Action;
677 static_assert(!is_reference<_ValueType>::value,678 static_assert(!is_reference<_ValueType>::value,
678 "_ValueType may not be a reference.");679 "_ValueType may not be a reference.");
679 typedef typename add_pointer<_ValueType>::type _ReturnType;680 typedef add_pointer_t<_ValueType> _ReturnType;
680 if (__any && __any->__h) {681 if (__any && __any->__h_) {
681 void *__p = __any->__call(_Action::_Get, nullptr,682 void *__p = __any->__call(_Action::_Get, nullptr,
682#if !defined(_LIBCPP_NO_RTTI)683#if !defined(_LIBCPP_NO_RTTI)
683 &typeid(_ValueType),684 &typeid(_ValueType),
...@@ -695,4 +696,17 @@ any_cast(any * __any) _NOEXCEPT...@@ -695,4 +696,17 @@ any_cast(any * __any) _NOEXCEPT
695696
696_LIBCPP_END_NAMESPACE_STD697_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
698#endif // _LIBCPP_ANY712#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...@@ -115,7 +115,7 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
115#include <__assert> // all public C++ headers provide the assertion handler115#include <__assert> // all public C++ headers provide the assertion handler
116#include <__config>116#include <__config>
117#include <__iterator/reverse_iterator.h>117#include <__iterator/reverse_iterator.h>
118#include <__tuple>118#include <__tuple_dir/sfinae_helpers.h>
119#include <__utility/integer_sequence.h>119#include <__utility/integer_sequence.h>
120#include <__utility/move.h>120#include <__utility/move.h>
121#include <__utility/unreachable.h>121#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...@@ -123,12 +123,6 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
123#include <type_traits>123#include <type_traits>
124#include <version>124#include <version>
125125
126#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
127# include <algorithm>
128# include <iterator>
129# include <utility>
130#endif
131
132// standard-mandated includes126// standard-mandated includes
133127
134// [iterator.range]128// [iterator.range]
...@@ -142,6 +136,10 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce...@@ -142,6 +136,10 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
142#include <compare>136#include <compare>
143#include <initializer_list>137#include <initializer_list>
144138
139// [tuple.helper]
140#include <__tuple_dir/tuple_element.h>
141#include <__tuple_dir/tuple_size.h>
142
145#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)143#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
146# pragma GCC system_header144# pragma GCC system_header
147#endif145#endif
...@@ -168,42 +166,42 @@ struct _LIBCPP_TEMPLATE_VIS array...@@ -168,42 +166,42 @@ struct _LIBCPP_TEMPLATE_VIS array
168 _Tp __elems_[_Size];166 _Tp __elems_[_Size];
169167
170 // No explicit construct/copy/destroy for aggregate type168 // No explicit construct/copy/destroy for aggregate type
171 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17169 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
172 void fill(const value_type& __u) {170 void fill(const value_type& __u) {
173 _VSTD::fill_n(data(), _Size, __u);171 _VSTD::fill_n(data(), _Size, __u);
174 }172 }
175173
176 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17174 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
177 void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {175 void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
178 _VSTD::swap_ranges(data(), data() + _Size, __a.data());176 _VSTD::swap_ranges(data(), data() + _Size, __a.data());
179 }177 }
180178
181 // iterators:179 // iterators:
182 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14180 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
183 iterator begin() _NOEXCEPT {return iterator(data());}181 iterator begin() _NOEXCEPT {return iterator(data());}
184 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14182 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
185 const_iterator begin() const _NOEXCEPT {return const_iterator(data());}183 const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
186 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14184 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
187 iterator end() _NOEXCEPT {return iterator(data() + _Size);}185 iterator end() _NOEXCEPT {return iterator(data() + _Size);}
188 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14186 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
189 const_iterator end() const _NOEXCEPT {return const_iterator(data() + _Size);}187 const_iterator end() const _NOEXCEPT {return const_iterator(data() + _Size);}
190188
191 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14189 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
192 reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}190 reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
193 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14191 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
194 const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}192 const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
195 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14193 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
196 reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}194 reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
197 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14195 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
198 const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}196 const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
199197
200 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14198 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
201 const_iterator cbegin() const _NOEXCEPT {return begin();}199 const_iterator cbegin() const _NOEXCEPT {return begin();}
202 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14200 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
203 const_iterator cend() const _NOEXCEPT {return end();}201 const_iterator cend() const _NOEXCEPT {return end();}
204 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14202 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
205 const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}203 const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
206 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14204 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
207 const_reverse_iterator crend() const _NOEXCEPT {return rend();}205 const_reverse_iterator crend() const _NOEXCEPT {return rend();}
208206
209 // capacity:207 // capacity:
...@@ -215,39 +213,39 @@ struct _LIBCPP_TEMPLATE_VIS array...@@ -215,39 +213,39 @@ struct _LIBCPP_TEMPLATE_VIS array
215 _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return _Size == 0;}213 _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return _Size == 0;}
216214
217 // element access:215 // element access:
218 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14216 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
219 reference operator[](size_type __n) _NOEXCEPT {217 reference operator[](size_type __n) _NOEXCEPT {
220 _LIBCPP_ASSERT(__n < _Size, "out-of-bounds access in std::array<T, N>");218 _LIBCPP_ASSERT(__n < _Size, "out-of-bounds access in std::array<T, N>");
221 return __elems_[__n];219 return __elems_[__n];
222 }220 }
223 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11221 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
224 const_reference operator[](size_type __n) const _NOEXCEPT {222 const_reference operator[](size_type __n) const _NOEXCEPT {
225 _LIBCPP_ASSERT(__n < _Size, "out-of-bounds access in std::array<T, N>");223 _LIBCPP_ASSERT(__n < _Size, "out-of-bounds access in std::array<T, N>");
226 return __elems_[__n];224 return __elems_[__n];
227 }225 }
228226
229 _LIBCPP_CONSTEXPR_AFTER_CXX14 reference at(size_type __n)227 _LIBCPP_CONSTEXPR_SINCE_CXX17 reference at(size_type __n)
230 {228 {
231 if (__n >= _Size)229 if (__n >= _Size)
232 __throw_out_of_range("array::at");230 __throw_out_of_range("array::at");
233 return __elems_[__n];231 return __elems_[__n];
234 }232 }
235233
236 _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference at(size_type __n) const234 _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference at(size_type __n) const
237 {235 {
238 if (__n >= _Size)236 if (__n >= _Size)
239 __throw_out_of_range("array::at");237 __throw_out_of_range("array::at");
240 return __elems_[__n];238 return __elems_[__n];
241 }239 }
242240
243 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference front() _NOEXCEPT {return (*this)[0];}241 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 reference front() _NOEXCEPT {return (*this)[0];}
244 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const _NOEXCEPT {return (*this)[0];}242 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference front() const _NOEXCEPT {return (*this)[0];}
245 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back() _NOEXCEPT {return (*this)[_Size - 1];}243 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 reference back() _NOEXCEPT {return (*this)[_Size - 1];}
246 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const _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_CXX14246 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
249 value_type* data() _NOEXCEPT {return __elems_;}247 value_type* data() _NOEXCEPT {return __elems_;}
250 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14248 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
251 const value_type* data() const _NOEXCEPT {return __elems_;}249 const value_type* data() const _NOEXCEPT {return __elems_;}
252};250};
253251
...@@ -268,56 +266,55 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>...@@ -268,56 +266,55 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>
268 typedef _VSTD::reverse_iterator<iterator> reverse_iterator;266 typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
269 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;267 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
270268
271 typedef typename conditional<is_const<_Tp>::value, const char,269 typedef __conditional_t<is_const<_Tp>::value, const char, char> _CharType;
272 char>::type _CharType;
273270
274 struct _ArrayInStructT { _Tp __data_[1]; };271 struct _ArrayInStructT { _Tp __data_[1]; };
275 _ALIGNAS_TYPE(_ArrayInStructT) _CharType __elems_[sizeof(_ArrayInStructT)];272 _ALIGNAS_TYPE(_ArrayInStructT) _CharType __elems_[sizeof(_ArrayInStructT)];
276273
277 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14274 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
278 value_type* data() _NOEXCEPT {return nullptr;}275 value_type* data() _NOEXCEPT {return nullptr;}
279 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14276 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
280 const value_type* data() const _NOEXCEPT {return nullptr;}277 const value_type* data() const _NOEXCEPT {return nullptr;}
281278
282 // No explicit construct/copy/destroy for aggregate type279 // No explicit construct/copy/destroy for aggregate type
283 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17280 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
284 void fill(const value_type&) {281 void fill(const value_type&) {
285 static_assert(!is_const<_Tp>::value,282 static_assert(!is_const<_Tp>::value,
286 "cannot fill zero-sized array of type 'const T'");283 "cannot fill zero-sized array of type 'const T'");
287 }284 }
288285
289 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17286 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
290 void swap(array&) _NOEXCEPT {287 void swap(array&) _NOEXCEPT {
291 static_assert(!is_const<_Tp>::value,288 static_assert(!is_const<_Tp>::value,
292 "cannot swap zero-sized array of type 'const T'");289 "cannot swap zero-sized array of type 'const T'");
293 }290 }
294291
295 // iterators:292 // iterators:
296 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14293 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
297 iterator begin() _NOEXCEPT {return iterator(data());}294 iterator begin() _NOEXCEPT {return iterator(data());}
298 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14295 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
299 const_iterator begin() const _NOEXCEPT {return const_iterator(data());}296 const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
300 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14297 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
301 iterator end() _NOEXCEPT {return iterator(data());}298 iterator end() _NOEXCEPT {return iterator(data());}
302 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14299 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
303 const_iterator end() const _NOEXCEPT {return const_iterator(data());}300 const_iterator end() const _NOEXCEPT {return const_iterator(data());}
304301
305 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14302 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
306 reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}303 reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
307 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14304 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
308 const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}305 const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
309 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14306 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
310 reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}307 reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
311 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14308 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
312 const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}309 const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
313310
314 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14311 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
315 const_iterator cbegin() const _NOEXCEPT {return begin();}312 const_iterator cbegin() const _NOEXCEPT {return begin();}
316 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14313 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
317 const_iterator cend() const _NOEXCEPT {return end();}314 const_iterator cend() const _NOEXCEPT {return end();}
318 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14315 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
319 const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}316 const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
320 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14317 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
321 const_reverse_iterator crend() const _NOEXCEPT {return rend();}318 const_reverse_iterator crend() const _NOEXCEPT {return rend();}
322319
323 // capacity:320 // capacity:
...@@ -329,49 +326,49 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>...@@ -329,49 +326,49 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>
329 _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return true;}326 _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return true;}
330327
331 // element access:328 // element access:
332 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14329 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
333 reference operator[](size_type) _NOEXCEPT {330 reference operator[](size_type) _NOEXCEPT {
334 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");331 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
335 __libcpp_unreachable();332 __libcpp_unreachable();
336 }333 }
337334
338 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11335 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
339 const_reference operator[](size_type) const _NOEXCEPT {336 const_reference operator[](size_type) const _NOEXCEPT {
340 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");337 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
341 __libcpp_unreachable();338 __libcpp_unreachable();
342 }339 }
343340
344 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14341 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
345 reference at(size_type) {342 reference at(size_type) {
346 __throw_out_of_range("array<T, 0>::at");343 __throw_out_of_range("array<T, 0>::at");
347 __libcpp_unreachable();344 __libcpp_unreachable();
348 }345 }
349346
350 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11347 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
351 const_reference at(size_type) const {348 const_reference at(size_type) const {
352 __throw_out_of_range("array<T, 0>::at");349 __throw_out_of_range("array<T, 0>::at");
353 __libcpp_unreachable();350 __libcpp_unreachable();
354 }351 }
355352
356 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14353 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
357 reference front() _NOEXCEPT {354 reference front() _NOEXCEPT {
358 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");355 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
359 __libcpp_unreachable();356 __libcpp_unreachable();
360 }357 }
361358
362 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11359 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
363 const_reference front() const _NOEXCEPT {360 const_reference front() const _NOEXCEPT {
364 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");361 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
365 __libcpp_unreachable();362 __libcpp_unreachable();
366 }363 }
367364
368 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14365 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17
369 reference back() _NOEXCEPT {366 reference back() _NOEXCEPT {
370 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");367 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
371 __libcpp_unreachable();368 __libcpp_unreachable();
372 }369 }
373370
374 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11371 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
375 const_reference back() const _NOEXCEPT {372 const_reference back() const _NOEXCEPT {
376 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");373 _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
377 __libcpp_unreachable();374 __libcpp_unreachable();
...@@ -389,7 +386,7 @@ array(_Tp, _Args...)...@@ -389,7 +386,7 @@ array(_Tp, _Args...)
389386
390template <class _Tp, size_t _Size>387template <class _Tp, size_t _Size>
391inline _LIBCPP_INLINE_VISIBILITY388inline _LIBCPP_INLINE_VISIBILITY
392_LIBCPP_CONSTEXPR_AFTER_CXX17 bool389_LIBCPP_CONSTEXPR_SINCE_CXX20 bool
393operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)390operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
394{391{
395 return _VSTD::equal(__x.begin(), __x.end(), __y.begin());392 return _VSTD::equal(__x.begin(), __x.end(), __y.begin());
...@@ -397,7 +394,7 @@ operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)...@@ -397,7 +394,7 @@ operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
397394
398template <class _Tp, size_t _Size>395template <class _Tp, size_t _Size>
399inline _LIBCPP_INLINE_VISIBILITY396inline _LIBCPP_INLINE_VISIBILITY
400_LIBCPP_CONSTEXPR_AFTER_CXX17 bool397_LIBCPP_CONSTEXPR_SINCE_CXX20 bool
401operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)398operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
402{399{
403 return !(__x == __y);400 return !(__x == __y);
...@@ -405,7 +402,7 @@ operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)...@@ -405,7 +402,7 @@ operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
405402
406template <class _Tp, size_t _Size>403template <class _Tp, size_t _Size>
407inline _LIBCPP_INLINE_VISIBILITY404inline _LIBCPP_INLINE_VISIBILITY
408_LIBCPP_CONSTEXPR_AFTER_CXX17 bool405_LIBCPP_CONSTEXPR_SINCE_CXX20 bool
409operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)406operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
410{407{
411 return _VSTD::lexicographical_compare(__x.begin(), __x.end(),408 return _VSTD::lexicographical_compare(__x.begin(), __x.end(),
...@@ -414,7 +411,7 @@ operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)...@@ -414,7 +411,7 @@ operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
414411
415template <class _Tp, size_t _Size>412template <class _Tp, size_t _Size>
416inline _LIBCPP_INLINE_VISIBILITY413inline _LIBCPP_INLINE_VISIBILITY
417_LIBCPP_CONSTEXPR_AFTER_CXX17 bool414_LIBCPP_CONSTEXPR_SINCE_CXX20 bool
418operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)415operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
419{416{
420 return __y < __x;417 return __y < __x;
...@@ -422,7 +419,7 @@ operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)...@@ -422,7 +419,7 @@ operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
422419
423template <class _Tp, size_t _Size>420template <class _Tp, size_t _Size>
424inline _LIBCPP_INLINE_VISIBILITY421inline _LIBCPP_INLINE_VISIBILITY
425_LIBCPP_CONSTEXPR_AFTER_CXX17 bool422_LIBCPP_CONSTEXPR_SINCE_CXX20 bool
426operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)423operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
427{424{
428 return !(__y < __x);425 return !(__y < __x);
...@@ -430,14 +427,14 @@ operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)...@@ -430,14 +427,14 @@ operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
430427
431template <class _Tp, size_t _Size>428template <class _Tp, size_t _Size>
432inline _LIBCPP_INLINE_VISIBILITY429inline _LIBCPP_INLINE_VISIBILITY
433_LIBCPP_CONSTEXPR_AFTER_CXX17 bool430_LIBCPP_CONSTEXPR_SINCE_CXX20 bool
434operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)431operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
435{432{
436 return !(__x < __y);433 return !(__x < __y);
437}434}
438435
439template <class _Tp, size_t _Size>436template <class _Tp, size_t _Size>
440inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17437inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
441__enable_if_t<_Size == 0 || __is_swappable<_Tp>::value, void>438__enable_if_t<_Size == 0 || __is_swappable<_Tp>::value, void>
442swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)439swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
443 _NOEXCEPT_(noexcept(__x.swap(__y)))440 _NOEXCEPT_(noexcept(__x.swap(__y)))
...@@ -457,7 +454,7 @@ struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> >...@@ -457,7 +454,7 @@ struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> >
457};454};
458455
459template <size_t _Ip, class _Tp, size_t _Size>456template <size_t _Ip, class _Tp, size_t _Size>
460inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11457inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
461_Tp&458_Tp&
462get(array<_Tp, _Size>& __a) _NOEXCEPT459get(array<_Tp, _Size>& __a) _NOEXCEPT
463{460{
...@@ -466,7 +463,7 @@ get(array<_Tp, _Size>& __a) _NOEXCEPT...@@ -466,7 +463,7 @@ get(array<_Tp, _Size>& __a) _NOEXCEPT
466}463}
467464
468template <size_t _Ip, class _Tp, size_t _Size>465template <size_t _Ip, class _Tp, size_t _Size>
469inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11466inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
470const _Tp&467const _Tp&
471get(const array<_Tp, _Size>& __a) _NOEXCEPT468get(const array<_Tp, _Size>& __a) _NOEXCEPT
472{469{
...@@ -475,7 +472,7 @@ get(const array<_Tp, _Size>& __a) _NOEXCEPT...@@ -475,7 +472,7 @@ get(const array<_Tp, _Size>& __a) _NOEXCEPT
475}472}
476473
477template <size_t _Ip, class _Tp, size_t _Size>474template <size_t _Ip, class _Tp, size_t _Size>
478inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11475inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
479_Tp&&476_Tp&&
480get(array<_Tp, _Size>&& __a) _NOEXCEPT477get(array<_Tp, _Size>&& __a) _NOEXCEPT
481{478{
...@@ -484,7 +481,7 @@ get(array<_Tp, _Size>&& __a) _NOEXCEPT...@@ -484,7 +481,7 @@ get(array<_Tp, _Size>&& __a) _NOEXCEPT
484}481}
485482
486template <size_t _Ip, class _Tp, size_t _Size>483template <size_t _Ip, class _Tp, size_t _Size>
487inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11484inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
488const _Tp&&485const _Tp&&
489get(const array<_Tp, _Size>&& __a) _NOEXCEPT486get(const array<_Tp, _Size>&& __a) _NOEXCEPT
490{487{
...@@ -535,4 +532,11 @@ to_array(_Tp(&&__arr)[_Size]) noexcept(is_nothrow_move_constructible_v<_Tp>) {...@@ -535,4 +532,11 @@ to_array(_Tp(&&__arr)[_Size]) noexcept(is_nothrow_move_constructible_v<_Tp>) {
535532
536_LIBCPP_END_NAMESPACE_STD533_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
538#endif // _LIBCPP_ARRAY542#endif // _LIBCPP_ARRAY
lib/libcxx/include/atomic+85-89
...@@ -377,23 +377,23 @@ template<class T>...@@ -377,23 +377,23 @@ template<class T>
377 memory_order) noexcept;377 memory_order) noexcept;
378378
379template<class T>379template<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;
381template<class T>381template<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;
383template<class T>383template<class T>
384 void atomic_wait_explicit(const volatile atomic<T>*, atomic<T>::value_type,384 void atomic_wait_explicit(const volatile atomic<T>*, atomic<T>::value_type,
385 memory_order);385 memory_order) noexcept;
386template<class T>386template<class T>
387 void atomic_wait_explicit(const atomic<T>*, atomic<T>::value_type,387 void atomic_wait_explicit(const atomic<T>*, atomic<T>::value_type,
388 memory_order);388 memory_order) noexcept;
389template<class T>389template<class T>
390 void atomic_notify_one(volatile atomic<T>*);390 void atomic_notify_one(volatile atomic<T>*) noexcept;
391template<class T>391template<class T>
392 void atomic_notify_one(atomic<T>*);392 void atomic_notify_one(atomic<T>*) noexcept;
393template<class T>393template<class T>
394 void atomic_notify_all(volatile atomic<T>*);394 void atomic_notify_all(volatile atomic<T>*) noexcept;
395template<class T>395template<class T>
396 void atomic_notify_all(atomic<T>*);396 void atomic_notify_all(atomic<T>*) noexcept;
397397
398// Atomics for standard typedef types398// Atomics for standard typedef types
399399
...@@ -524,20 +524,25 @@ template <class T>...@@ -524,20 +524,25 @@ template <class T>
524#include <__config>524#include <__config>
525#include <__thread/poll_with_backoff.h>525#include <__thread/poll_with_backoff.h>
526#include <__thread/timed_backoff_policy.h>526#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>
527#include <cstddef>537#include <cstddef>
528#include <cstdint>538#include <cstdint>
529#include <cstring>539#include <cstring>
530#include <type_traits>
531#include <version>540#include <version>
532541
533#ifndef _LIBCPP_HAS_NO_THREADS542#ifndef _LIBCPP_HAS_NO_THREADS
534# include <__threading_support>543# include <__threading_support>
535#endif544#endif
536545
537#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
538# include <chrono>
539#endif
540
541#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)546#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
542# pragma GCC system_header547# pragma GCC system_header
543#endif548#endif
...@@ -948,13 +953,13 @@ void __cxx_atomic_store(__cxx_atomic_base_impl<_Tp> * __a, _Tp __val, memory_ord...@@ -948,13 +953,13 @@ void __cxx_atomic_store(__cxx_atomic_base_impl<_Tp> * __a, _Tp __val, memory_ord
948template<class _Tp>953template<class _Tp>
949_LIBCPP_INLINE_VISIBILITY954_LIBCPP_INLINE_VISIBILITY
950_Tp __cxx_atomic_load(__cxx_atomic_base_impl<_Tp> const volatile* __a, memory_order __order) _NOEXCEPT {955_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)>*;
952 return __c11_atomic_load(const_cast<__ptr_type>(&__a->__a_value), static_cast<__memory_order_underlying_t>(__order));957 return __c11_atomic_load(const_cast<__ptr_type>(&__a->__a_value), static_cast<__memory_order_underlying_t>(__order));
953}958}
954template<class _Tp>959template<class _Tp>
955_LIBCPP_INLINE_VISIBILITY960_LIBCPP_INLINE_VISIBILITY
956_Tp __cxx_atomic_load(__cxx_atomic_base_impl<_Tp> const* __a, memory_order __order) _NOEXCEPT {961_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)>*;
958 return __c11_atomic_load(const_cast<__ptr_type>(&__a->__a_value), static_cast<__memory_order_underlying_t>(__order));963 return __c11_atomic_load(const_cast<__ptr_type>(&__a->__a_value), static_cast<__memory_order_underlying_t>(__order));
959}964}
960965
...@@ -1435,17 +1440,7 @@ struct __cxx_atomic_impl : public _Base {...@@ -1435,17 +1440,7 @@ struct __cxx_atomic_impl : public _Base {
14351440
1436using __cxx_atomic_contention_t = __cxx_atomic_impl<__cxx_contention_t>;1441using __cxx_atomic_contention_t = __cxx_atomic_impl<__cxx_contention_t>;
14371442
1438#if defined(_LIBCPP_HAS_NO_THREADS)1443#ifndef _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
14491444
1450_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile*);1445_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile*);
1451_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile*);1446_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 {...@@ -1466,10 +1461,10 @@ struct __libcpp_atomic_wait_backoff_impl {
1466 {1461 {
1467 if(__elapsed > chrono::microseconds(64))1462 if(__elapsed > chrono::microseconds(64))
1468 {1463 {
1469 auto const __monitor = __libcpp_atomic_monitor(__a);1464 auto const __monitor = std::__libcpp_atomic_monitor(__a);
1470 if(__test_fn())1465 if(__test_fn())
1471 return true;1466 return true;
1472 __libcpp_atomic_wait(__a, __monitor);1467 std::__libcpp_atomic_wait(__a, __monitor);
1473 }1468 }
1474 else if(__elapsed > chrono::microseconds(4))1469 else if(__elapsed > chrono::microseconds(4))
1475 __libcpp_thread_yield();1470 __libcpp_thread_yield();
...@@ -1484,10 +1479,10 @@ _LIBCPP_AVAILABILITY_SYNC...@@ -1484,10 +1479,10 @@ _LIBCPP_AVAILABILITY_SYNC
1484_LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp* __a, _Fn && __test_fn)1479_LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp* __a, _Fn && __test_fn)
1485{1480{
1486 __libcpp_atomic_wait_backoff_impl<_Atp, typename decay<_Fn>::type> __backoff_fn = {__a, __test_fn};1481 __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);
1488}1483}
14891484
1490#else // _LIBCPP_HAS_NO_PLATFORM_WAIT1485#else // _LIBCPP_HAS_NO_THREADS
14911486
1492template <class _Tp>1487template <class _Tp>
1493_LIBCPP_INLINE_VISIBILITY void __cxx_atomic_notify_all(__cxx_atomic_impl<_Tp> const volatile*) { }1488_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...@@ -1496,15 +1491,10 @@ _LIBCPP_INLINE_VISIBILITY void __cxx_atomic_notify_one(__cxx_atomic_impl<_Tp> co
1496template <class _Atp, class _Fn>1491template <class _Atp, class _Fn>
1497_LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp*, _Fn && __test_fn)1492_LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp*, _Fn && __test_fn)
1498{1493{
1499#if defined(_LIBCPP_HAS_NO_THREADS)1494 return __libcpp_thread_poll_with_backoff(__test_fn, __spinning_backoff_policy());
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());
1505}1495}
15061496
1507#endif // _LIBCPP_HAS_NO_PLATFORM_WAIT1497#endif // _LIBCPP_HAS_NO_THREADS
15081498
1509template <class _Atp, class _Tp>1499template <class _Atp, class _Tp>
1510struct __cxx_atomic_wait_test_fn_impl {1500struct __cxx_atomic_wait_test_fn_impl {
...@@ -1513,7 +1503,7 @@ struct __cxx_atomic_wait_test_fn_impl {...@@ -1513,7 +1503,7 @@ struct __cxx_atomic_wait_test_fn_impl {
1513 memory_order __order;1503 memory_order __order;
1514 _LIBCPP_INLINE_VISIBILITY bool operator()() const1504 _LIBCPP_INLINE_VISIBILITY bool operator()() const
1515 {1505 {
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);
1517 }1507 }
1518};1508};
15191509
...@@ -1522,7 +1512,7 @@ _LIBCPP_AVAILABILITY_SYNC...@@ -1522,7 +1512,7 @@ _LIBCPP_AVAILABILITY_SYNC
1522_LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp* __a, _Tp const __val, memory_order __order)1512_LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp* __a, _Tp const __val, memory_order __order)
1523{1513{
1524 __cxx_atomic_wait_test_fn_impl<_Atp, _Tp> __test_fn = {__a, __val, __order};1514 __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);
1526}1516}
15271517
1528// general atomic<T>1518// general atomic<T>
...@@ -1545,78 +1535,78 @@ struct __atomic_base // false...@@ -1545,78 +1535,78 @@ struct __atomic_base // false
1545 _LIBCPP_INLINE_VISIBILITY1535 _LIBCPP_INLINE_VISIBILITY
1546 void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT1536 void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
1547 _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)1537 _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)
1548 {__cxx_atomic_store(&__a_, __d, __m);}1538 {std::__cxx_atomic_store(&__a_, __d, __m);}
1549 _LIBCPP_INLINE_VISIBILITY1539 _LIBCPP_INLINE_VISIBILITY
1550 void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT1540 void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT
1551 _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)1541 _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)
1552 {__cxx_atomic_store(&__a_, __d, __m);}1542 {std::__cxx_atomic_store(&__a_, __d, __m);}
1553 _LIBCPP_INLINE_VISIBILITY1543 _LIBCPP_INLINE_VISIBILITY
1554 _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT1544 _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT
1555 _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m)1545 _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m)
1556 {return __cxx_atomic_load(&__a_, __m);}1546 {return std::__cxx_atomic_load(&__a_, __m);}
1557 _LIBCPP_INLINE_VISIBILITY1547 _LIBCPP_INLINE_VISIBILITY
1558 _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT1548 _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT
1559 _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m)1549 _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m)
1560 {return __cxx_atomic_load(&__a_, __m);}1550 {return std::__cxx_atomic_load(&__a_, __m);}
1561 _LIBCPP_INLINE_VISIBILITY1551 _LIBCPP_INLINE_VISIBILITY
1562 operator _Tp() const volatile _NOEXCEPT {return load();}1552 operator _Tp() const volatile _NOEXCEPT {return load();}
1563 _LIBCPP_INLINE_VISIBILITY1553 _LIBCPP_INLINE_VISIBILITY
1564 operator _Tp() const _NOEXCEPT {return load();}1554 operator _Tp() const _NOEXCEPT {return load();}
1565 _LIBCPP_INLINE_VISIBILITY1555 _LIBCPP_INLINE_VISIBILITY
1566 _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT1556 _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);}
1568 _LIBCPP_INLINE_VISIBILITY1558 _LIBCPP_INLINE_VISIBILITY
1569 _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT1559 _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);}
1571 _LIBCPP_INLINE_VISIBILITY1561 _LIBCPP_INLINE_VISIBILITY
1572 bool compare_exchange_weak(_Tp& __e, _Tp __d,1562 bool compare_exchange_weak(_Tp& __e, _Tp __d,
1573 memory_order __s, memory_order __f) volatile _NOEXCEPT1563 memory_order __s, memory_order __f) volatile _NOEXCEPT
1574 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)1564 _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);}
1576 _LIBCPP_INLINE_VISIBILITY1566 _LIBCPP_INLINE_VISIBILITY
1577 bool compare_exchange_weak(_Tp& __e, _Tp __d,1567 bool compare_exchange_weak(_Tp& __e, _Tp __d,
1578 memory_order __s, memory_order __f) _NOEXCEPT1568 memory_order __s, memory_order __f) _NOEXCEPT
1579 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)1569 _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);}
1581 _LIBCPP_INLINE_VISIBILITY1571 _LIBCPP_INLINE_VISIBILITY
1582 bool compare_exchange_strong(_Tp& __e, _Tp __d,1572 bool compare_exchange_strong(_Tp& __e, _Tp __d,
1583 memory_order __s, memory_order __f) volatile _NOEXCEPT1573 memory_order __s, memory_order __f) volatile _NOEXCEPT
1584 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)1574 _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);}
1586 _LIBCPP_INLINE_VISIBILITY1576 _LIBCPP_INLINE_VISIBILITY
1587 bool compare_exchange_strong(_Tp& __e, _Tp __d,1577 bool compare_exchange_strong(_Tp& __e, _Tp __d,
1588 memory_order __s, memory_order __f) _NOEXCEPT1578 memory_order __s, memory_order __f) _NOEXCEPT
1589 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)1579 _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);}
1591 _LIBCPP_INLINE_VISIBILITY1581 _LIBCPP_INLINE_VISIBILITY
1592 bool compare_exchange_weak(_Tp& __e, _Tp __d,1582 bool compare_exchange_weak(_Tp& __e, _Tp __d,
1593 memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT1583 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);}
1595 _LIBCPP_INLINE_VISIBILITY1585 _LIBCPP_INLINE_VISIBILITY
1596 bool compare_exchange_weak(_Tp& __e, _Tp __d,1586 bool compare_exchange_weak(_Tp& __e, _Tp __d,
1597 memory_order __m = memory_order_seq_cst) _NOEXCEPT1587 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);}
1599 _LIBCPP_INLINE_VISIBILITY1589 _LIBCPP_INLINE_VISIBILITY
1600 bool compare_exchange_strong(_Tp& __e, _Tp __d,1590 bool compare_exchange_strong(_Tp& __e, _Tp __d,
1601 memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT1591 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);}
1603 _LIBCPP_INLINE_VISIBILITY1593 _LIBCPP_INLINE_VISIBILITY
1604 bool compare_exchange_strong(_Tp& __e, _Tp __d,1594 bool compare_exchange_strong(_Tp& __e, _Tp __d,
1605 memory_order __m = memory_order_seq_cst) _NOEXCEPT1595 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
1608 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT1598 _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);}
1610 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT1600 _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);}
1612 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_one() volatile _NOEXCEPT1602 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_one() volatile _NOEXCEPT
1613 {__cxx_atomic_notify_one(&__a_);}1603 {std::__cxx_atomic_notify_one(&__a_);}
1614 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_one() _NOEXCEPT1604 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_one() _NOEXCEPT
1615 {__cxx_atomic_notify_one(&__a_);}1605 {std::__cxx_atomic_notify_one(&__a_);}
1616 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_all() volatile _NOEXCEPT1606 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_all() volatile _NOEXCEPT
1617 {__cxx_atomic_notify_all(&__a_);}1607 {std::__cxx_atomic_notify_all(&__a_);}
1618 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_all() _NOEXCEPT1608 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void notify_all() _NOEXCEPT
1619 {__cxx_atomic_notify_all(&__a_);}1609 {std::__cxx_atomic_notify_all(&__a_);}
16201610
1621#if _LIBCPP_STD_VER > 171611#if _LIBCPP_STD_VER > 17
1622 _LIBCPP_INLINE_VISIBILITY constexpr1612 _LIBCPP_INLINE_VISIBILITY constexpr
...@@ -1645,7 +1635,7 @@ struct __atomic_base<_Tp, true>...@@ -1645,7 +1635,7 @@ struct __atomic_base<_Tp, true>
1645{1635{
1646 typedef __atomic_base<_Tp, false> __base;1636 typedef __atomic_base<_Tp, false> __base;
16471637
1648 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171638 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1649 __atomic_base() _NOEXCEPT = default;1639 __atomic_base() _NOEXCEPT = default;
16501640
1651 _LIBCPP_INLINE_VISIBILITY1641 _LIBCPP_INLINE_VISIBILITY
...@@ -1653,34 +1643,34 @@ struct __atomic_base<_Tp, true>...@@ -1653,34 +1643,34 @@ struct __atomic_base<_Tp, true>
16531643
1654 _LIBCPP_INLINE_VISIBILITY1644 _LIBCPP_INLINE_VISIBILITY
1655 _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT1645 _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);}
1657 _LIBCPP_INLINE_VISIBILITY1647 _LIBCPP_INLINE_VISIBILITY
1658 _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT1648 _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);}
1660 _LIBCPP_INLINE_VISIBILITY1650 _LIBCPP_INLINE_VISIBILITY
1661 _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT1651 _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);}
1663 _LIBCPP_INLINE_VISIBILITY1653 _LIBCPP_INLINE_VISIBILITY
1664 _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT1654 _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);}
1666 _LIBCPP_INLINE_VISIBILITY1656 _LIBCPP_INLINE_VISIBILITY
1667 _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT1657 _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);}
1669 _LIBCPP_INLINE_VISIBILITY1659 _LIBCPP_INLINE_VISIBILITY
1670 _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT1660 _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);}
1672 _LIBCPP_INLINE_VISIBILITY1662 _LIBCPP_INLINE_VISIBILITY
1673 _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT1663 _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);}
1675 _LIBCPP_INLINE_VISIBILITY1665 _LIBCPP_INLINE_VISIBILITY
1676 _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT1666 _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);}
1678 _LIBCPP_INLINE_VISIBILITY1668 _LIBCPP_INLINE_VISIBILITY
1679 _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT1669 _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);}
1681 _LIBCPP_INLINE_VISIBILITY1671 _LIBCPP_INLINE_VISIBILITY
1682 _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT1672 _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
1685 _LIBCPP_INLINE_VISIBILITY1675 _LIBCPP_INLINE_VISIBILITY
1686 _Tp operator++(int) volatile _NOEXCEPT {return fetch_add(_Tp(1));}1676 _Tp operator++(int) volatile _NOEXCEPT {return fetch_add(_Tp(1));}
...@@ -1778,29 +1768,29 @@ struct atomic<_Tp*>...@@ -1778,29 +1768,29 @@ struct atomic<_Tp*>
1778 _LIBCPP_INLINE_VISIBILITY1768 _LIBCPP_INLINE_VISIBILITY
1779 _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {1769 _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
1780 // __atomic_fetch_add accepts function pointers, guard against them.1770 // __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");1771 static_assert(!is_function<__remove_pointer_t<_Tp> >::value, "Pointer to function isn't allowed");
1782 return __cxx_atomic_fetch_add(&this->__a_, __op, __m);1772 return std::__cxx_atomic_fetch_add(&this->__a_, __op, __m);
1783 }1773 }
17841774
1785 _LIBCPP_INLINE_VISIBILITY1775 _LIBCPP_INLINE_VISIBILITY
1786 _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT {1776 _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT {
1787 // __atomic_fetch_add accepts function pointers, guard against them.1777 // __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");1778 static_assert(!is_function<__remove_pointer_t<_Tp> >::value, "Pointer to function isn't allowed");
1789 return __cxx_atomic_fetch_add(&this->__a_, __op, __m);1779 return std::__cxx_atomic_fetch_add(&this->__a_, __op, __m);
1790 }1780 }
17911781
1792 _LIBCPP_INLINE_VISIBILITY1782 _LIBCPP_INLINE_VISIBILITY
1793 _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {1783 _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
1794 // __atomic_fetch_add accepts function pointers, guard against them.1784 // __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");1785 static_assert(!is_function<__remove_pointer_t<_Tp> >::value, "Pointer to function isn't allowed");
1796 return __cxx_atomic_fetch_sub(&this->__a_, __op, __m);1786 return std::__cxx_atomic_fetch_sub(&this->__a_, __op, __m);
1797 }1787 }
17981788
1799 _LIBCPP_INLINE_VISIBILITY1789 _LIBCPP_INLINE_VISIBILITY
1800 _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT {1790 _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT {
1801 // __atomic_fetch_add accepts function pointers, guard against them.1791 // __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");1792 static_assert(!is_function<__remove_pointer_t<_Tp> >::value, "Pointer to function isn't allowed");
1803 return __cxx_atomic_fetch_sub(&this->__a_, __op, __m);1793 return std::__cxx_atomic_fetch_sub(&this->__a_, __op, __m);
1804 }1794 }
18051795
1806 _LIBCPP_INLINE_VISIBILITY1796 _LIBCPP_INLINE_VISIBILITY
...@@ -1857,7 +1847,7 @@ _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_INLINE_VISIBILITY...@@ -1857,7 +1847,7 @@ _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_INLINE_VISIBILITY
1857void1847void
1858atomic_init(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT1848atomic_init(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
1859{1849{
1860 __cxx_atomic_init(&__o->__a_, __d);1850 std::__cxx_atomic_init(&__o->__a_, __d);
1861}1851}
18621852
1863template <class _Tp>1853template <class _Tp>
...@@ -1865,7 +1855,7 @@ _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_INLINE_VISIBILITY...@@ -1865,7 +1855,7 @@ _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_INLINE_VISIBILITY
1865void1855void
1866atomic_init(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT1856atomic_init(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __d) _NOEXCEPT
1867{1857{
1868 __cxx_atomic_init(&__o->__a_, __d);1858 std::__cxx_atomic_init(&__o->__a_, __d);
1869}1859}
18701860
1871// atomic_store1861// atomic_store
...@@ -2118,7 +2108,7 @@ void atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT...@@ -2118,7 +2108,7 @@ void atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT
2118 __o->notify_one();2108 __o->notify_one();
2119}2109}
21202110
2121// atomic_notify_one2111// atomic_notify_all
21222112
2123template <class _Tp>2113template <class _Tp>
2124_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY2114_LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
...@@ -2642,17 +2632,17 @@ typedef atomic<uintmax_t> atomic_uintmax_t;...@@ -2642,17 +2632,17 @@ typedef atomic<uintmax_t> atomic_uintmax_t;
2642#endif2632#endif
26432633
2644#if ATOMIC_LLONG_LOCK_FREE == 22634#if ATOMIC_LLONG_LOCK_FREE == 2
2645typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, long long>::type __libcpp_signed_lock_free;2635typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, long long> __libcpp_signed_lock_free;
2646typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned long long>::type __libcpp_unsigned_lock_free;2636typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned long long> __libcpp_unsigned_lock_free;
2647#elif ATOMIC_INT_LOCK_FREE == 22637#elif ATOMIC_INT_LOCK_FREE == 2
2648typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, int>::type __libcpp_signed_lock_free;2638typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, int> __libcpp_signed_lock_free;
2649typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned int>::type __libcpp_unsigned_lock_free;2639typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned int> __libcpp_unsigned_lock_free;
2650#elif ATOMIC_SHORT_LOCK_FREE == 22640#elif ATOMIC_SHORT_LOCK_FREE == 2
2651typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, short>::type __libcpp_signed_lock_free;2641typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, short> __libcpp_signed_lock_free;
2652typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned short>::type __libcpp_unsigned_lock_free;2642typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned short> __libcpp_unsigned_lock_free;
2653#elif ATOMIC_CHAR_LOCK_FREE == 22643#elif ATOMIC_CHAR_LOCK_FREE == 2
2654typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, char>::type __libcpp_signed_lock_free;2644typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, char> __libcpp_signed_lock_free;
2655typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned char>::type __libcpp_unsigned_lock_free;2645typedef __conditional_t<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned char> __libcpp_unsigned_lock_free;
2656#else2646#else
2657 // No signed/unsigned lock-free types2647 // No signed/unsigned lock-free types
2658#define _LIBCPP_NO_LOCK_FREE_TYPES2648#define _LIBCPP_NO_LOCK_FREE_TYPES
...@@ -2674,4 +2664,10 @@ typedef atomic<__libcpp_unsigned_lock_free> atomic_unsigned_lock_free;...@@ -2674,4 +2664,10 @@ typedef atomic<__libcpp_unsigned_lock_free> atomic_unsigned_lock_free;
26742664
2675_LIBCPP_END_NAMESPACE_STD2665_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
2677#endif // _LIBCPP_ATOMIC2673#endif // _LIBCPP_ATOMIC
lib/libcxx/include/barrier+17-8
...@@ -48,10 +48,11 @@ namespace std...@@ -48,10 +48,11 @@ namespace std
48#include <__assert> // all public C++ headers provide the assertion handler48#include <__assert> // all public C++ headers provide the assertion handler
49#include <__availability>49#include <__availability>
50#include <__config>50#include <__config>
51#include <__memory/unique_ptr.h>
51#include <__thread/timed_backoff_policy.h>52#include <__thread/timed_backoff_policy.h>
53#include <__utility/move.h>
52#include <atomic>54#include <atomic>
53#include <limits>55#include <limits>
54#include <memory>
5556
56#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)57#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
57# pragma GCC system_header58# pragma GCC system_header
...@@ -124,7 +125,7 @@ public:...@@ -124,7 +125,7 @@ public:
124125
125 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY126 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
126 __barrier_base(ptrdiff_t __expected, _CompletionF __completion = _CompletionF())127 __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_),
128 &__destroy_barrier_algorithm_base),129 &__destroy_barrier_algorithm_base),
129 __expected_adjustment_(0), __completion_(std::move(__completion)), __phase_(0)130 __expected_adjustment_(0), __completion_(std::move(__completion)), __phase_(0)
130 {131 {
...@@ -149,7 +150,7 @@ public:...@@ -149,7 +150,7 @@ public:
149 auto const __test_fn = [this, __old_phase]() -> bool {150 auto const __test_fn = [this, __old_phase]() -> bool {
150 return __phase_.load(memory_order_acquire) != __old_phase;151 return __phase_.load(memory_order_acquire) != __old_phase;
151 };152 };
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());
153 }154 }
154 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY155 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
155 void arrive_and_drop()156 void arrive_and_drop()
...@@ -283,7 +284,7 @@ public:...@@ -283,7 +284,7 @@ public:
283template<class _CompletionF = __empty_completion>284template<class _CompletionF = __empty_completion>
284class barrier {285class barrier {
285286
286 __barrier_base<_CompletionF> __b;287 __barrier_base<_CompletionF> __b_;
287public:288public:
288 using arrival_token = typename __barrier_base<_CompletionF>::arrival_token;289 using arrival_token = typename __barrier_base<_CompletionF>::arrival_token;
289290
...@@ -293,7 +294,7 @@ public:...@@ -293,7 +294,7 @@ public:
293294
294 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY295 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
295 barrier(ptrdiff_t __count, _CompletionF __completion = _CompletionF())296 barrier(ptrdiff_t __count, _CompletionF __completion = _CompletionF())
296 : __b(__count, _VSTD::move(__completion)) {297 : __b_(__count, _VSTD::move(__completion)) {
297 }298 }
298299
299 barrier(barrier const&) = delete;300 barrier(barrier const&) = delete;
...@@ -302,12 +303,12 @@ public:...@@ -302,12 +303,12 @@ public:
302 [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY303 [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
303 arrival_token arrive(ptrdiff_t __update = 1)304 arrival_token arrive(ptrdiff_t __update = 1)
304 {305 {
305 return __b.arrive(__update);306 return __b_.arrive(__update);
306 }307 }
307 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY308 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
308 void wait(arrival_token&& __phase) const309 void wait(arrival_token&& __phase) const
309 {310 {
310 __b.wait(_VSTD::move(__phase));311 __b_.wait(_VSTD::move(__phase));
311 }312 }
312 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY313 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
313 void arrive_and_wait()314 void arrive_and_wait()
...@@ -317,7 +318,7 @@ public:...@@ -317,7 +318,7 @@ public:
317 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY318 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
318 void arrive_and_drop()319 void arrive_and_drop()
319 {320 {
320 __b.arrive_and_drop();321 __b_.arrive_and_drop();
321 }322 }
322};323};
323324
...@@ -327,4 +328,12 @@ _LIBCPP_END_NAMESPACE_STD...@@ -327,4 +328,12 @@ _LIBCPP_END_NAMESPACE_STD
327328
328_LIBCPP_POP_MACROS329_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
330#endif //_LIBCPP_BARRIER339#endif //_LIBCPP_BARRIER
lib/libcxx/include/bit+16-184
...@@ -63,197 +63,29 @@ namespace std {...@@ -63,197 +63,29 @@ namespace std {
6363
64#include <__assert> // all public C++ headers provide the assertion handler64#include <__assert> // all public C++ headers provide the assertion handler
65#include <__bit/bit_cast.h>65#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>
66#include <__bit/byteswap.h>71#include <__bit/byteswap.h>
67#include <__bits> // __libcpp_clz72#include <__bit/countl.h>
68#include <__concepts/arithmetic.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>
69#include <__config>78#include <__config>
70#include <limits>
71#include <type_traits>
72#include <version>79#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
82#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)81#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
83# pragma GCC system_header82# pragma GCC system_header
84#endif83#endif
8584
86_LIBCPP_PUSH_MACROS85#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
87#include <__undef_macros>86# include <iosfwd>
8887# include <limits>
89_LIBCPP_BEGIN_NAMESPACE_STD88# include <type_traits>
9089#endif
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
25890
259#endif // _LIBCPP_BIT91#endif // _LIBCPP_BIT
lib/libcxx/include/bitset+164-117
...@@ -42,61 +42,61 @@ public:...@@ -42,61 +42,61 @@ public:
42 template <class charT>42 template <class charT>
43 explicit bitset(const charT* str,43 explicit bitset(const charT* str,
44 typename basic_string<charT>::size_type n = basic_string<charT>::npos,44 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
46 template<class charT, class traits, class Allocator>46 template<class charT, class traits, class Allocator>
47 explicit bitset(const basic_string<charT,traits,Allocator>& str,47 explicit bitset(const basic_string<charT,traits,Allocator>& str,
48 typename basic_string<charT,traits,Allocator>::size_type pos = 0,48 typename basic_string<charT,traits,Allocator>::size_type pos = 0,
49 typename basic_string<charT,traits,Allocator>::size_type n =49 typename basic_string<charT,traits,Allocator>::size_type n =
50 basic_string<charT,traits,Allocator>::npos,50 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
53 // 23.3.5.2 bitset operations:53 // 23.3.5.2 bitset operations:
54 bitset& operator&=(const bitset& rhs) noexcept;54 bitset& operator&=(const bitset& rhs) noexcept; // constexpr since C++23
55 bitset& operator|=(const bitset& rhs) noexcept;55 bitset& operator|=(const bitset& rhs) noexcept; // constexpr since C++23
56 bitset& operator^=(const bitset& rhs) noexcept;56 bitset& operator^=(const bitset& rhs) noexcept; // constexpr since C++23
57 bitset& operator<<=(size_t pos) noexcept;57 bitset& operator<<=(size_t pos) noexcept; // constexpr since C++23
58 bitset& operator>>=(size_t pos) noexcept;58 bitset& operator>>=(size_t pos) noexcept; // constexpr since C++23
59 bitset& set() noexcept;59 bitset& set() noexcept; // constexpr since C++23
60 bitset& set(size_t pos, bool val = true);60 bitset& set(size_t pos, bool val = true); // constexpr since C++23
61 bitset& reset() noexcept;61 bitset& reset() noexcept; // constexpr since C++23
62 bitset& reset(size_t pos);62 bitset& reset(size_t pos); // constexpr since C++23
63 bitset operator~() const noexcept;63 bitset operator~() const noexcept; // constexpr since C++23
64 bitset& flip() noexcept;64 bitset& flip() noexcept; // constexpr since C++23
65 bitset& flip(size_t pos);65 bitset& flip(size_t pos); // constexpr since C++23
6666
67 // element access:67 // element access:
68 constexpr bool operator[](size_t pos) const; // for b[i];68 constexpr bool operator[](size_t pos) const;
69 reference operator[](size_t pos); // for b[i];69 reference operator[](size_t pos); // constexpr since C++23
70 unsigned long to_ulong() const;70 unsigned long to_ulong() const; // constexpr since C++23
71 unsigned long long to_ullong() const;71 unsigned long long to_ullong() const; // constexpr since C++23
72 template <class charT, class traits, class Allocator>72 template <class charT, class traits, class Allocator> // constexpr since C++23
73 basic_string<charT, traits, Allocator> to_string(charT zero = charT('0'), charT one = charT('1')) const;73 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
75 basic_string<charT, traits, allocator<charT> > to_string(charT zero = charT('0'), charT one = charT('1')) const;75 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
77 basic_string<charT, char_traits<charT>, allocator<charT> > to_string(charT zero = charT('0'), charT one = charT('1')) const;77 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;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;79 size_t count() const noexcept; // constexpr since C++23
80 constexpr size_t size() const noexcept;80 constexpr size_t size() const noexcept; // constexpr since C++23
81 bool operator==(const bitset& rhs) const noexcept;81 bool operator==(const bitset& rhs) const noexcept; // constexpr since C++23
82 bool operator!=(const bitset& rhs) const noexcept;82 bool operator!=(const bitset& rhs) const noexcept; // constexpr since C++23
83 bool test(size_t pos) const;83 bool test(size_t pos) const; // constexpr since C++23
84 bool all() const noexcept;84 bool all() const noexcept; // constexpr since C++23
85 bool any() const noexcept;85 bool any() const noexcept; // constexpr since C++23
86 bool none() const noexcept;86 bool none() const noexcept; // constexpr since C++23
87 bitset operator<<(size_t pos) const noexcept;87 bitset<N> operator<<(size_t pos) const noexcept; // constexpr since C++23
88 bitset operator>>(size_t pos) const noexcept;88 bitset<N> operator>>(size_t pos) const noexcept; // constexpr since C++23
89};89};
9090
91// 23.3.5.3 bitset operators:91// 23.3.5.3 bitset operators:
92template <size_t N>92template <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
95template <size_t N>95template <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
98template <size_t N>98template <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
101template <class charT, class traits, size_t N>101template <class charT, class traits, size_t N>
102basic_istream<charT, traits>&102basic_istream<charT, traits>&
...@@ -118,12 +118,15 @@ template <size_t N> struct hash<std::bitset<N>>;...@@ -118,12 +118,15 @@ template <size_t N> struct hash<std::bitset<N>>;
118#include <__config>118#include <__config>
119#include <__functional/hash.h>119#include <__functional/hash.h>
120#include <__functional/unary_function.h>120#include <__functional/unary_function.h>
121#include <__type_traits/is_char_like_type.h>
121#include <climits>122#include <climits>
122#include <cstddef>123#include <cstddef>
123#include <stdexcept>124#include <stdexcept>
124#include <version>125#include <version>
125126
126// standard-mandated includes127// standard-mandated includes
128
129// [bitset.syn]
127#include <iosfwd>130#include <iosfwd>
128#include <string>131#include <string>
129132
...@@ -177,30 +180,30 @@ protected:...@@ -177,30 +180,30 @@ protected:
177 _LIBCPP_INLINE_VISIBILITY180 _LIBCPP_INLINE_VISIBILITY
178 explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;181 explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;
179182
180 _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT183 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t __pos) _NOEXCEPT
181 {return reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}184 {return reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}
182 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT185 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT
183 {return const_reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}186 {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) _NOEXCEPT187 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 iterator __make_iter(size_t __pos) _NOEXCEPT
185 {return iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}188 {return iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
186 _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t __pos) const _NOEXCEPT189 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 const_iterator __make_iter(size_t __pos) const _NOEXCEPT
187 {return const_iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}190 {return const_iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
188191
189 _LIBCPP_INLINE_VISIBILITY192 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
190 void operator&=(const __bitset& __v) _NOEXCEPT;193 void operator&=(const __bitset& __v) _NOEXCEPT;
191 _LIBCPP_INLINE_VISIBILITY194 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
192 void operator|=(const __bitset& __v) _NOEXCEPT;195 void operator|=(const __bitset& __v) _NOEXCEPT;
193 _LIBCPP_INLINE_VISIBILITY196 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
194 void operator^=(const __bitset& __v) _NOEXCEPT;197 void operator^=(const __bitset& __v) _NOEXCEPT;
195198
196 void flip() _NOEXCEPT;199 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip() _NOEXCEPT;
197 _LIBCPP_INLINE_VISIBILITY unsigned long to_ulong() const200 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const
198 {return to_ulong(integral_constant<bool, _Size < sizeof(unsigned long) * CHAR_BIT>());}201 {return to_ulong(integral_constant<bool, _Size < sizeof(unsigned long) * CHAR_BIT>());}
199 _LIBCPP_INLINE_VISIBILITY unsigned long long to_ullong() const202 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const
200 {return to_ullong(integral_constant<bool, _Size < sizeof(unsigned long long) * CHAR_BIT>());}203 {return to_ullong(integral_constant<bool, _Size < sizeof(unsigned long long) * CHAR_BIT>());}
201204
202 bool all() const _NOEXCEPT;205 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT;
203 bool any() const _NOEXCEPT;206 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT;
204 _LIBCPP_INLINE_VISIBILITY207 _LIBCPP_INLINE_VISIBILITY
205 size_t __hash_code() const _NOEXCEPT;208 size_t __hash_code() const _NOEXCEPT;
206private:209private:
...@@ -209,14 +212,17 @@ private:...@@ -209,14 +212,17 @@ private:
209 _LIBCPP_INLINE_VISIBILITY212 _LIBCPP_INLINE_VISIBILITY
210 void __init(unsigned long long __v, true_type) _NOEXCEPT;213 void __init(unsigned long long __v, true_type) _NOEXCEPT;
211#endif // _LIBCPP_CXX03_LANG214#endif // _LIBCPP_CXX03_LANG
215 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
212 unsigned long to_ulong(false_type) const;216 unsigned long to_ulong(false_type) const;
213 _LIBCPP_INLINE_VISIBILITY217 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
214 unsigned long to_ulong(true_type) const;218 unsigned long to_ulong(true_type) const;
219 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
215 unsigned long long to_ullong(false_type) const;220 unsigned long long to_ullong(false_type) const;
216 _LIBCPP_INLINE_VISIBILITY221 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
217 unsigned long long to_ullong(true_type) const;222 unsigned long long to_ullong(true_type) const;
218 _LIBCPP_INLINE_VISIBILITY223 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
219 unsigned long long to_ullong(true_type, false_type) const;224 unsigned long long to_ullong(true_type, false_type) const;
225 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
220 unsigned long long to_ullong(true_type, true_type) const;226 unsigned long long to_ullong(true_type, true_type) const;
221};227};
222228
...@@ -289,7 +295,7 @@ __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT...@@ -289,7 +295,7 @@ __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
289295
290template <size_t _N_words, size_t _Size>296template <size_t _N_words, size_t _Size>
291inline297inline
292void298_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
293__bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT299__bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT
294{300{
295 for (size_type __i = 0; __i < _N_words; ++__i)301 for (size_type __i = 0; __i < _N_words; ++__i)
...@@ -298,7 +304,7 @@ __bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT...@@ -298,7 +304,7 @@ __bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT
298304
299template <size_t _N_words, size_t _Size>305template <size_t _N_words, size_t _Size>
300inline306inline
301void307_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
302__bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT308__bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT
303{309{
304 for (size_type __i = 0; __i < _N_words; ++__i)310 for (size_type __i = 0; __i < _N_words; ++__i)
...@@ -307,7 +313,7 @@ __bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT...@@ -307,7 +313,7 @@ __bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT
307313
308template <size_t _N_words, size_t _Size>314template <size_t _N_words, size_t _Size>
309inline315inline
310void316_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
311__bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT317__bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT
312{318{
313 for (size_type __i = 0; __i < _N_words; ++__i)319 for (size_type __i = 0; __i < _N_words; ++__i)
...@@ -315,7 +321,7 @@ __bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT...@@ -315,7 +321,7 @@ __bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT
315}321}
316322
317template <size_t _N_words, size_t _Size>323template <size_t _N_words, size_t _Size>
318void324_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
319__bitset<_N_words, _Size>::flip() _NOEXCEPT325__bitset<_N_words, _Size>::flip() _NOEXCEPT
320{326{
321 // do middle whole words327 // do middle whole words
...@@ -334,7 +340,7 @@ __bitset<_N_words, _Size>::flip() _NOEXCEPT...@@ -334,7 +340,7 @@ __bitset<_N_words, _Size>::flip() _NOEXCEPT
334}340}
335341
336template <size_t _N_words, size_t _Size>342template <size_t _N_words, size_t _Size>
337unsigned long343_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
338__bitset<_N_words, _Size>::to_ulong(false_type) const344__bitset<_N_words, _Size>::to_ulong(false_type) const
339{345{
340 const_iterator __e = __make_iter(_Size);346 const_iterator __e = __make_iter(_Size);
...@@ -347,14 +353,14 @@ __bitset<_N_words, _Size>::to_ulong(false_type) const...@@ -347,14 +353,14 @@ __bitset<_N_words, _Size>::to_ulong(false_type) const
347353
348template <size_t _N_words, size_t _Size>354template <size_t _N_words, size_t _Size>
349inline355inline
350unsigned long356_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
351__bitset<_N_words, _Size>::to_ulong(true_type) const357__bitset<_N_words, _Size>::to_ulong(true_type) const
352{358{
353 return __first_[0];359 return __first_[0];
354}360}
355361
356template <size_t _N_words, size_t _Size>362template <size_t _N_words, size_t _Size>
357unsigned long long363_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
358__bitset<_N_words, _Size>::to_ullong(false_type) const364__bitset<_N_words, _Size>::to_ullong(false_type) const
359{365{
360 const_iterator __e = __make_iter(_Size);366 const_iterator __e = __make_iter(_Size);
...@@ -367,7 +373,7 @@ __bitset<_N_words, _Size>::to_ullong(false_type) const...@@ -367,7 +373,7 @@ __bitset<_N_words, _Size>::to_ullong(false_type) const
367373
368template <size_t _N_words, size_t _Size>374template <size_t _N_words, size_t _Size>
369inline375inline
370unsigned long long376_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
371__bitset<_N_words, _Size>::to_ullong(true_type) const377__bitset<_N_words, _Size>::to_ullong(true_type) const
372{378{
373 return to_ullong(true_type(), integral_constant<bool, sizeof(__storage_type) < sizeof(unsigned long long)>());379 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...@@ -375,14 +381,14 @@ __bitset<_N_words, _Size>::to_ullong(true_type) const
375381
376template <size_t _N_words, size_t _Size>382template <size_t _N_words, size_t _Size>
377inline383inline
378unsigned long long384_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
379__bitset<_N_words, _Size>::to_ullong(true_type, false_type) const385__bitset<_N_words, _Size>::to_ullong(true_type, false_type) const
380{386{
381 return __first_[0];387 return __first_[0];
382}388}
383389
384template <size_t _N_words, size_t _Size>390template <size_t _N_words, size_t _Size>
385unsigned long long391_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
386__bitset<_N_words, _Size>::to_ullong(true_type, true_type) const392__bitset<_N_words, _Size>::to_ullong(true_type, true_type) const
387{393{
388 unsigned long long __r = __first_[0];394 unsigned long long __r = __first_[0];
...@@ -392,7 +398,7 @@ __bitset<_N_words, _Size>::to_ullong(true_type, true_type) const...@@ -392,7 +398,7 @@ __bitset<_N_words, _Size>::to_ullong(true_type, true_type) const
392}398}
393399
394template <size_t _N_words, size_t _Size>400template <size_t _N_words, size_t _Size>
395bool401_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
396__bitset<_N_words, _Size>::all() const _NOEXCEPT402__bitset<_N_words, _Size>::all() const _NOEXCEPT
397{403{
398 // do middle whole words404 // do middle whole words
...@@ -412,7 +418,7 @@ __bitset<_N_words, _Size>::all() const _NOEXCEPT...@@ -412,7 +418,7 @@ __bitset<_N_words, _Size>::all() const _NOEXCEPT
412}418}
413419
414template <size_t _N_words, size_t _Size>420template <size_t _N_words, size_t _Size>
415bool421_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
416__bitset<_N_words, _Size>::any() const _NOEXCEPT422__bitset<_N_words, _Size>::any() const _NOEXCEPT
417{423{
418 // do middle whole words424 // do middle whole words
...@@ -473,33 +479,33 @@ protected:...@@ -473,33 +479,33 @@ protected:
473 _LIBCPP_INLINE_VISIBILITY479 _LIBCPP_INLINE_VISIBILITY
474 explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;480 explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;
475481
476 _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT482 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t __pos) _NOEXCEPT
477 {return reference(&__first_, __storage_type(1) << __pos);}483 {return reference(&__first_, __storage_type(1) << __pos);}
478 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT484 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT
479 {return const_reference(&__first_, __storage_type(1) << __pos);}485 {return const_reference(&__first_, __storage_type(1) << __pos);}
480 _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t __pos) _NOEXCEPT486 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 iterator __make_iter(size_t __pos) _NOEXCEPT
481 {return iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}487 {return iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
482 _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t __pos) const _NOEXCEPT488 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 const_iterator __make_iter(size_t __pos) const _NOEXCEPT
483 {return const_iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}489 {return const_iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
484490
485 _LIBCPP_INLINE_VISIBILITY491 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
486 void operator&=(const __bitset& __v) _NOEXCEPT;492 void operator&=(const __bitset& __v) _NOEXCEPT;
487 _LIBCPP_INLINE_VISIBILITY493 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
488 void operator|=(const __bitset& __v) _NOEXCEPT;494 void operator|=(const __bitset& __v) _NOEXCEPT;
489 _LIBCPP_INLINE_VISIBILITY495 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
490 void operator^=(const __bitset& __v) _NOEXCEPT;496 void operator^=(const __bitset& __v) _NOEXCEPT;
491497
492 _LIBCPP_INLINE_VISIBILITY498 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
493 void flip() _NOEXCEPT;499 void flip() _NOEXCEPT;
494500
495 _LIBCPP_INLINE_VISIBILITY501 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
496 unsigned long to_ulong() const;502 unsigned long to_ulong() const;
497 _LIBCPP_INLINE_VISIBILITY503 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
498 unsigned long long to_ullong() const;504 unsigned long long to_ullong() const;
499505
500 _LIBCPP_INLINE_VISIBILITY506 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
501 bool all() const _NOEXCEPT;507 bool all() const _NOEXCEPT;
502 _LIBCPP_INLINE_VISIBILITY508 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
503 bool any() const _NOEXCEPT;509 bool any() const _NOEXCEPT;
504510
505 _LIBCPP_INLINE_VISIBILITY511 _LIBCPP_INLINE_VISIBILITY
...@@ -527,7 +533,7 @@ __bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT...@@ -527,7 +533,7 @@ __bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
527533
528template <size_t _Size>534template <size_t _Size>
529inline535inline
530void536_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
531__bitset<1, _Size>::operator&=(const __bitset& __v) _NOEXCEPT537__bitset<1, _Size>::operator&=(const __bitset& __v) _NOEXCEPT
532{538{
533 __first_ &= __v.__first_;539 __first_ &= __v.__first_;
...@@ -535,7 +541,7 @@ __bitset<1, _Size>::operator&=(const __bitset& __v) _NOEXCEPT...@@ -535,7 +541,7 @@ __bitset<1, _Size>::operator&=(const __bitset& __v) _NOEXCEPT
535541
536template <size_t _Size>542template <size_t _Size>
537inline543inline
538void544_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
539__bitset<1, _Size>::operator|=(const __bitset& __v) _NOEXCEPT545__bitset<1, _Size>::operator|=(const __bitset& __v) _NOEXCEPT
540{546{
541 __first_ |= __v.__first_;547 __first_ |= __v.__first_;
...@@ -543,7 +549,7 @@ __bitset<1, _Size>::operator|=(const __bitset& __v) _NOEXCEPT...@@ -543,7 +549,7 @@ __bitset<1, _Size>::operator|=(const __bitset& __v) _NOEXCEPT
543549
544template <size_t _Size>550template <size_t _Size>
545inline551inline
546void552_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
547__bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT553__bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT
548{554{
549 __first_ ^= __v.__first_;555 __first_ ^= __v.__first_;
...@@ -551,7 +557,7 @@ __bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT...@@ -551,7 +557,7 @@ __bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT
551557
552template <size_t _Size>558template <size_t _Size>
553inline559inline
554void560_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
555__bitset<1, _Size>::flip() _NOEXCEPT561__bitset<1, _Size>::flip() _NOEXCEPT
556{562{
557 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);563 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
...@@ -561,7 +567,7 @@ __bitset<1, _Size>::flip() _NOEXCEPT...@@ -561,7 +567,7 @@ __bitset<1, _Size>::flip() _NOEXCEPT
561567
562template <size_t _Size>568template <size_t _Size>
563inline569inline
564unsigned long570_LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
565__bitset<1, _Size>::to_ulong() const571__bitset<1, _Size>::to_ulong() const
566{572{
567 return __first_;573 return __first_;
...@@ -569,7 +575,7 @@ __bitset<1, _Size>::to_ulong() const...@@ -569,7 +575,7 @@ __bitset<1, _Size>::to_ulong() const
569575
570template <size_t _Size>576template <size_t _Size>
571inline577inline
572unsigned long long578_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
573__bitset<1, _Size>::to_ullong() const579__bitset<1, _Size>::to_ullong() const
574{580{
575 return __first_;581 return __first_;
...@@ -577,7 +583,7 @@ __bitset<1, _Size>::to_ullong() const...@@ -577,7 +583,7 @@ __bitset<1, _Size>::to_ullong() const
577583
578template <size_t _Size>584template <size_t _Size>
579inline585inline
580bool586_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
581__bitset<1, _Size>::all() const _NOEXCEPT587__bitset<1, _Size>::all() const _NOEXCEPT
582{588{
583 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);589 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
...@@ -586,7 +592,7 @@ __bitset<1, _Size>::all() const _NOEXCEPT...@@ -586,7 +592,7 @@ __bitset<1, _Size>::all() const _NOEXCEPT
586592
587template <size_t _Size>593template <size_t _Size>
588inline594inline
589bool595_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
590__bitset<1, _Size>::any() const _NOEXCEPT596__bitset<1, _Size>::any() const _NOEXCEPT
591{597{
592 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);598 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
...@@ -630,26 +636,26 @@ protected:...@@ -630,26 +636,26 @@ protected:
630 _LIBCPP_INLINE_VISIBILITY636 _LIBCPP_INLINE_VISIBILITY
631 explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT;637 explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT;
632638
633 _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t) _NOEXCEPT639 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t) _NOEXCEPT
634 {return reference(nullptr, 1);}640 {return reference(nullptr, 1);}
635 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t) const _NOEXCEPT641 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t) const _NOEXCEPT
636 {return const_reference(nullptr, 1);}642 {return const_reference(nullptr, 1);}
637 _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t) _NOEXCEPT643 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 iterator __make_iter(size_t) _NOEXCEPT
638 {return iterator(nullptr, 0);}644 {return iterator(nullptr, 0);}
639 _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t) const _NOEXCEPT645 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 const_iterator __make_iter(size_t) const _NOEXCEPT
640 {return const_iterator(nullptr, 0);}646 {return const_iterator(nullptr, 0);}
641647
642 _LIBCPP_INLINE_VISIBILITY void operator&=(const __bitset&) _NOEXCEPT {}648 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset&) _NOEXCEPT {}
643 _LIBCPP_INLINE_VISIBILITY void operator|=(const __bitset&) _NOEXCEPT {}649 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator|=(const __bitset&) _NOEXCEPT {}
644 _LIBCPP_INLINE_VISIBILITY 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;}654 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const {return 0;}
649 _LIBCPP_INLINE_VISIBILITY unsigned long long to_ullong() 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;}657 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT {return true;}
652 _LIBCPP_INLINE_VISIBILITY bool any() const _NOEXCEPT {return false;}658 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT {return false;}
653659
654 _LIBCPP_INLINE_VISIBILITY size_t __hash_code() const _NOEXCEPT {return 0;}660 _LIBCPP_INLINE_VISIBILITY size_t __hash_code() const _NOEXCEPT {return 0;}
655};661};
...@@ -686,10 +692,12 @@ public:...@@ -686,10 +692,12 @@ public:
686 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR692 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
687 bitset(unsigned long long __v) _NOEXCEPT : base(__v) {}693 bitset(unsigned long long __v) _NOEXCEPT : base(__v) {}
688 template<class _CharT, class = __enable_if_t<_IsCharLikeType<_CharT>::value> >694 template<class _CharT, class = __enable_if_t<_IsCharLikeType<_CharT>::value> >
695 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
689 explicit bitset(const _CharT* __str,696 explicit bitset(const _CharT* __str,
690 typename basic_string<_CharT>::size_type __n = basic_string<_CharT>::npos,697 typename basic_string<_CharT>::size_type __n = basic_string<_CharT>::npos,
691 _CharT __zero = _CharT('0'), _CharT __one = _CharT('1'));698 _CharT __zero = _CharT('0'), _CharT __one = _CharT('1'));
692 template<class _CharT, class _Traits, class _Allocator>699 template<class _CharT, class _Traits, class _Allocator>
700 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
693 explicit bitset(const basic_string<_CharT,_Traits,_Allocator>& __str,701 explicit bitset(const basic_string<_CharT,_Traits,_Allocator>& __str,
694 typename basic_string<_CharT,_Traits,_Allocator>::size_type __pos = 0,702 typename basic_string<_CharT,_Traits,_Allocator>::size_type __pos = 0,
695 typename basic_string<_CharT,_Traits,_Allocator>::size_type __n =703 typename basic_string<_CharT,_Traits,_Allocator>::size_type __n =
...@@ -697,24 +705,29 @@ public:...@@ -697,24 +705,29 @@ public:
697 _CharT __zero = _CharT('0'), _CharT __one = _CharT('1'));705 _CharT __zero = _CharT('0'), _CharT __one = _CharT('1'));
698706
699 // 23.3.5.2 bitset operations:707 // 23.3.5.2 bitset operations:
700 _LIBCPP_INLINE_VISIBILITY708 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
701 bitset& operator&=(const bitset& __rhs) _NOEXCEPT;709 bitset& operator&=(const bitset& __rhs) _NOEXCEPT;
702 _LIBCPP_INLINE_VISIBILITY710 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
703 bitset& operator|=(const bitset& __rhs) _NOEXCEPT;711 bitset& operator|=(const bitset& __rhs) _NOEXCEPT;
704 _LIBCPP_INLINE_VISIBILITY712 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
705 bitset& operator^=(const bitset& __rhs) _NOEXCEPT;713 bitset& operator^=(const bitset& __rhs) _NOEXCEPT;
714 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
706 bitset& operator<<=(size_t __pos) _NOEXCEPT;715 bitset& operator<<=(size_t __pos) _NOEXCEPT;
716 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
707 bitset& operator>>=(size_t __pos) _NOEXCEPT;717 bitset& operator>>=(size_t __pos) _NOEXCEPT;
708 _LIBCPP_INLINE_VISIBILITY718 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
709 bitset& set() _NOEXCEPT;719 bitset& set() _NOEXCEPT;
720 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
710 bitset& set(size_t __pos, bool __val = true);721 bitset& set(size_t __pos, bool __val = true);
711 _LIBCPP_INLINE_VISIBILITY722 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
712 bitset& reset() _NOEXCEPT;723 bitset& reset() _NOEXCEPT;
724 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
713 bitset& reset(size_t __pos);725 bitset& reset(size_t __pos);
714 _LIBCPP_INLINE_VISIBILITY726 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
715 bitset operator~() const _NOEXCEPT;727 bitset operator~() const _NOEXCEPT;
716 _LIBCPP_INLINE_VISIBILITY728 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
717 bitset& flip() _NOEXCEPT;729 bitset& flip() _NOEXCEPT;
730 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
718 bitset& flip(size_t __pos);731 bitset& flip(size_t __pos);
719732
720 // element access:733 // element access:
...@@ -723,41 +736,43 @@ public:...@@ -723,41 +736,43 @@ public:
723#else736#else
724 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference operator[](size_t __p) const {return base::__make_ref(__p);}737 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference operator[](size_t __p) const {return base::__make_ref(__p);}
725#endif738#endif
726 _LIBCPP_HIDE_FROM_ABI reference operator[](size_t __p) {return base::__make_ref(__p);}739 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference operator[](size_t __p) {return base::__make_ref(__p);}
727 _LIBCPP_INLINE_VISIBILITY740 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
728 unsigned long to_ulong() const;741 unsigned long to_ulong() const;
729 _LIBCPP_INLINE_VISIBILITY742 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
730 unsigned long long to_ullong() const;743 unsigned long long to_ullong() const;
731 template <class _CharT, class _Traits, class _Allocator>744 template <class _CharT, class _Traits, class _Allocator>
745 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
732 basic_string<_CharT, _Traits, _Allocator> to_string(_CharT __zero = _CharT('0'),746 basic_string<_CharT, _Traits, _Allocator> to_string(_CharT __zero = _CharT('0'),
733 _CharT __one = _CharT('1')) const;747 _CharT __one = _CharT('1')) const;
734 template <class _CharT, class _Traits>748 template <class _CharT, class _Traits>
735 _LIBCPP_INLINE_VISIBILITY749 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
736 basic_string<_CharT, _Traits, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'),750 basic_string<_CharT, _Traits, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'),
737 _CharT __one = _CharT('1')) const;751 _CharT __one = _CharT('1')) const;
738 template <class _CharT>752 template <class _CharT>
739 _LIBCPP_INLINE_VISIBILITY753 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
740 basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'),754 basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'),
741 _CharT __one = _CharT('1')) const;755 _CharT __one = _CharT('1')) const;
742 _LIBCPP_INLINE_VISIBILITY756 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
743 basic_string<char, char_traits<char>, allocator<char> > to_string(char __zero = '0',757 basic_string<char, char_traits<char>, allocator<char> > to_string(char __zero = '0',
744 char __one = '1') const;758 char __one = '1') const;
745 _LIBCPP_INLINE_VISIBILITY759 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
746 size_t count() const _NOEXCEPT;760 size_t count() const _NOEXCEPT;
747 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR size_t size() const _NOEXCEPT {return _Size;}761 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR size_t size() const _NOEXCEPT {return _Size;}
748 _LIBCPP_INLINE_VISIBILITY762 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
749 bool operator==(const bitset& __rhs) const _NOEXCEPT;763 bool operator==(const bitset& __rhs) const _NOEXCEPT;
750 _LIBCPP_INLINE_VISIBILITY764 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
751 bool operator!=(const bitset& __rhs) const _NOEXCEPT;765 bool operator!=(const bitset& __rhs) const _NOEXCEPT;
766 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
752 bool test(size_t __pos) const;767 bool test(size_t __pos) const;
753 _LIBCPP_INLINE_VISIBILITY768 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
754 bool all() const _NOEXCEPT;769 bool all() const _NOEXCEPT;
755 _LIBCPP_INLINE_VISIBILITY770 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
756 bool any() const _NOEXCEPT;771 bool any() const _NOEXCEPT;
757 _LIBCPP_INLINE_VISIBILITY bool none() const _NOEXCEPT {return !any();}772 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 bool none() const _NOEXCEPT {return !any();}
758 _LIBCPP_INLINE_VISIBILITY773 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
759 bitset operator<<(size_t __pos) const _NOEXCEPT;774 bitset operator<<(size_t __pos) const _NOEXCEPT;
760 _LIBCPP_INLINE_VISIBILITY775 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
761 bitset operator>>(size_t __pos) const _NOEXCEPT;776 bitset operator>>(size_t __pos) const _NOEXCEPT;
762777
763private:778private:
...@@ -770,6 +785,7 @@ private:...@@ -770,6 +785,7 @@ private:
770785
771template <size_t _Size>786template <size_t _Size>
772template<class _CharT, class>787template<class _CharT, class>
788_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
773bitset<_Size>::bitset(const _CharT* __str,789bitset<_Size>::bitset(const _CharT* __str,
774 typename basic_string<_CharT>::size_type __n,790 typename basic_string<_CharT>::size_type __n,
775 _CharT __zero, _CharT __one)791 _CharT __zero, _CharT __one)
...@@ -791,6 +807,7 @@ bitset<_Size>::bitset(const _CharT* __str,...@@ -791,6 +807,7 @@ bitset<_Size>::bitset(const _CharT* __str,
791807
792template <size_t _Size>808template <size_t _Size>
793template<class _CharT, class _Traits, class _Allocator>809template<class _CharT, class _Traits, class _Allocator>
810_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
794bitset<_Size>::bitset(const basic_string<_CharT,_Traits,_Allocator>& __str,811bitset<_Size>::bitset(const basic_string<_CharT,_Traits,_Allocator>& __str,
795 typename basic_string<_CharT,_Traits,_Allocator>::size_type __pos,812 typename basic_string<_CharT,_Traits,_Allocator>::size_type __pos,
796 typename basic_string<_CharT,_Traits,_Allocator>::size_type __n,813 typename basic_string<_CharT,_Traits,_Allocator>::size_type __n,
...@@ -816,6 +833,7 @@ bitset<_Size>::bitset(const basic_string<_CharT,_Traits,_Allocator>& __str,...@@ -816,6 +833,7 @@ bitset<_Size>::bitset(const basic_string<_CharT,_Traits,_Allocator>& __str,
816833
817template <size_t _Size>834template <size_t _Size>
818inline835inline
836_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
819bitset<_Size>&837bitset<_Size>&
820bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT838bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT
821{839{
...@@ -825,6 +843,7 @@ bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT...@@ -825,6 +843,7 @@ bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT
825843
826template <size_t _Size>844template <size_t _Size>
827inline845inline
846_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
828bitset<_Size>&847bitset<_Size>&
829bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT848bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT
830{849{
...@@ -834,6 +853,7 @@ bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT...@@ -834,6 +853,7 @@ bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT
834853
835template <size_t _Size>854template <size_t _Size>
836inline855inline
856_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
837bitset<_Size>&857bitset<_Size>&
838bitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT858bitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT
839{859{
...@@ -842,6 +862,7 @@ bitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT...@@ -842,6 +862,7 @@ bitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT
842}862}
843863
844template <size_t _Size>864template <size_t _Size>
865_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
845bitset<_Size>&866bitset<_Size>&
846bitset<_Size>::operator<<=(size_t __pos) _NOEXCEPT867bitset<_Size>::operator<<=(size_t __pos) _NOEXCEPT
847{868{
...@@ -852,6 +873,7 @@ bitset<_Size>::operator<<=(size_t __pos) _NOEXCEPT...@@ -852,6 +873,7 @@ bitset<_Size>::operator<<=(size_t __pos) _NOEXCEPT
852}873}
853874
854template <size_t _Size>875template <size_t _Size>
876_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
855bitset<_Size>&877bitset<_Size>&
856bitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT878bitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT
857{879{
...@@ -863,6 +885,7 @@ bitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT...@@ -863,6 +885,7 @@ bitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT
863885
864template <size_t _Size>886template <size_t _Size>
865inline887inline
888_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
866bitset<_Size>&889bitset<_Size>&
867bitset<_Size>::set() _NOEXCEPT890bitset<_Size>::set() _NOEXCEPT
868{891{
...@@ -871,6 +894,7 @@ bitset<_Size>::set() _NOEXCEPT...@@ -871,6 +894,7 @@ bitset<_Size>::set() _NOEXCEPT
871}894}
872895
873template <size_t _Size>896template <size_t _Size>
897_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
874bitset<_Size>&898bitset<_Size>&
875bitset<_Size>::set(size_t __pos, bool __val)899bitset<_Size>::set(size_t __pos, bool __val)
876{900{
...@@ -883,6 +907,7 @@ bitset<_Size>::set(size_t __pos, bool __val)...@@ -883,6 +907,7 @@ bitset<_Size>::set(size_t __pos, bool __val)
883907
884template <size_t _Size>908template <size_t _Size>
885inline909inline
910_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
886bitset<_Size>&911bitset<_Size>&
887bitset<_Size>::reset() _NOEXCEPT912bitset<_Size>::reset() _NOEXCEPT
888{913{
...@@ -891,6 +916,7 @@ bitset<_Size>::reset() _NOEXCEPT...@@ -891,6 +916,7 @@ bitset<_Size>::reset() _NOEXCEPT
891}916}
892917
893template <size_t _Size>918template <size_t _Size>
919_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
894bitset<_Size>&920bitset<_Size>&
895bitset<_Size>::reset(size_t __pos)921bitset<_Size>::reset(size_t __pos)
896{922{
...@@ -903,6 +929,7 @@ bitset<_Size>::reset(size_t __pos)...@@ -903,6 +929,7 @@ bitset<_Size>::reset(size_t __pos)
903929
904template <size_t _Size>930template <size_t _Size>
905inline931inline
932_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
906bitset<_Size>933bitset<_Size>
907bitset<_Size>::operator~() const _NOEXCEPT934bitset<_Size>::operator~() const _NOEXCEPT
908{935{
...@@ -913,6 +940,7 @@ bitset<_Size>::operator~() const _NOEXCEPT...@@ -913,6 +940,7 @@ bitset<_Size>::operator~() const _NOEXCEPT
913940
914template <size_t _Size>941template <size_t _Size>
915inline942inline
943_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
916bitset<_Size>&944bitset<_Size>&
917bitset<_Size>::flip() _NOEXCEPT945bitset<_Size>::flip() _NOEXCEPT
918{946{
...@@ -921,6 +949,7 @@ bitset<_Size>::flip() _NOEXCEPT...@@ -921,6 +949,7 @@ bitset<_Size>::flip() _NOEXCEPT
921}949}
922950
923template <size_t _Size>951template <size_t _Size>
952_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
924bitset<_Size>&953bitset<_Size>&
925bitset<_Size>::flip(size_t __pos)954bitset<_Size>::flip(size_t __pos)
926{955{
...@@ -934,6 +963,7 @@ bitset<_Size>::flip(size_t __pos)...@@ -934,6 +963,7 @@ bitset<_Size>::flip(size_t __pos)
934963
935template <size_t _Size>964template <size_t _Size>
936inline965inline
966_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
937unsigned long967unsigned long
938bitset<_Size>::to_ulong() const968bitset<_Size>::to_ulong() const
939{969{
...@@ -942,6 +972,7 @@ bitset<_Size>::to_ulong() const...@@ -942,6 +972,7 @@ bitset<_Size>::to_ulong() const
942972
943template <size_t _Size>973template <size_t _Size>
944inline974inline
975_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
945unsigned long long976unsigned long long
946bitset<_Size>::to_ullong() const977bitset<_Size>::to_ullong() const
947{978{
...@@ -950,6 +981,7 @@ bitset<_Size>::to_ullong() const...@@ -950,6 +981,7 @@ bitset<_Size>::to_ullong() const
950981
951template <size_t _Size>982template <size_t _Size>
952template <class _CharT, class _Traits, class _Allocator>983template <class _CharT, class _Traits, class _Allocator>
984_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
953basic_string<_CharT, _Traits, _Allocator>985basic_string<_CharT, _Traits, _Allocator>
954bitset<_Size>::to_string(_CharT __zero, _CharT __one) const986bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
955{987{
...@@ -965,6 +997,7 @@ bitset<_Size>::to_string(_CharT __zero, _CharT __one) const...@@ -965,6 +997,7 @@ bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
965template <size_t _Size>997template <size_t _Size>
966template <class _CharT, class _Traits>998template <class _CharT, class _Traits>
967inline999inline
1000_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
968basic_string<_CharT, _Traits, allocator<_CharT> >1001basic_string<_CharT, _Traits, allocator<_CharT> >
969bitset<_Size>::to_string(_CharT __zero, _CharT __one) const1002bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
970{1003{
...@@ -974,6 +1007,7 @@ bitset<_Size>::to_string(_CharT __zero, _CharT __one) const...@@ -974,6 +1007,7 @@ bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
974template <size_t _Size>1007template <size_t _Size>
975template <class _CharT>1008template <class _CharT>
976inline1009inline
1010_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
977basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> >1011basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> >
978bitset<_Size>::to_string(_CharT __zero, _CharT __one) const1012bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
979{1013{
...@@ -982,6 +1016,7 @@ bitset<_Size>::to_string(_CharT __zero, _CharT __one) const...@@ -982,6 +1016,7 @@ bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
9821016
983template <size_t _Size>1017template <size_t _Size>
984inline1018inline
1019_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
985basic_string<char, char_traits<char>, allocator<char> >1020basic_string<char, char_traits<char>, allocator<char> >
986bitset<_Size>::to_string(char __zero, char __one) const1021bitset<_Size>::to_string(char __zero, char __one) const
987{1022{
...@@ -990,6 +1025,7 @@ bitset<_Size>::to_string(char __zero, char __one) const...@@ -990,6 +1025,7 @@ bitset<_Size>::to_string(char __zero, char __one) const
9901025
991template <size_t _Size>1026template <size_t _Size>
992inline1027inline
1028_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
993size_t1029size_t
994bitset<_Size>::count() const _NOEXCEPT1030bitset<_Size>::count() const _NOEXCEPT
995{1031{
...@@ -998,6 +1034,7 @@ bitset<_Size>::count() const _NOEXCEPT...@@ -998,6 +1034,7 @@ bitset<_Size>::count() const _NOEXCEPT
9981034
999template <size_t _Size>1035template <size_t _Size>
1000inline1036inline
1037_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
1001bool1038bool
1002bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT1039bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT
1003{1040{
...@@ -1006,6 +1043,7 @@ bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT...@@ -1006,6 +1043,7 @@ bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT
10061043
1007template <size_t _Size>1044template <size_t _Size>
1008inline1045inline
1046_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
1009bool1047bool
1010bitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT1048bitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT
1011{1049{
...@@ -1013,6 +1051,7 @@ bitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT...@@ -1013,6 +1051,7 @@ bitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT
1013}1051}
10141052
1015template <size_t _Size>1053template <size_t _Size>
1054_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
1016bool1055bool
1017bitset<_Size>::test(size_t __pos) const1056bitset<_Size>::test(size_t __pos) const
1018{1057{
...@@ -1024,6 +1063,7 @@ bitset<_Size>::test(size_t __pos) const...@@ -1024,6 +1063,7 @@ bitset<_Size>::test(size_t __pos) const
10241063
1025template <size_t _Size>1064template <size_t _Size>
1026inline1065inline
1066_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
1027bool1067bool
1028bitset<_Size>::all() const _NOEXCEPT1068bitset<_Size>::all() const _NOEXCEPT
1029{1069{
...@@ -1032,6 +1072,7 @@ bitset<_Size>::all() const _NOEXCEPT...@@ -1032,6 +1072,7 @@ bitset<_Size>::all() const _NOEXCEPT
10321072
1033template <size_t _Size>1073template <size_t _Size>
1034inline1074inline
1075_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
1035bool1076bool
1036bitset<_Size>::any() const _NOEXCEPT1077bitset<_Size>::any() const _NOEXCEPT
1037{1078{
...@@ -1040,6 +1081,7 @@ bitset<_Size>::any() const _NOEXCEPT...@@ -1040,6 +1081,7 @@ bitset<_Size>::any() const _NOEXCEPT
10401081
1041template <size_t _Size>1082template <size_t _Size>
1042inline1083inline
1084_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
1043bitset<_Size>1085bitset<_Size>
1044bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT1086bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT
1045{1087{
...@@ -1050,6 +1092,7 @@ bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT...@@ -1050,6 +1092,7 @@ bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT
10501092
1051template <size_t _Size>1093template <size_t _Size>
1052inline1094inline
1095_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
1053bitset<_Size>1096bitset<_Size>
1054bitset<_Size>::operator>>(size_t __pos) const _NOEXCEPT1097bitset<_Size>::operator>>(size_t __pos) const _NOEXCEPT
1055{1098{
...@@ -1059,7 +1102,7 @@ bitset<_Size>::operator>>(size_t __pos) const _NOEXCEPT...@@ -1059,7 +1102,7 @@ bitset<_Size>::operator>>(size_t __pos) const _NOEXCEPT
1059}1102}
10601103
1061template <size_t _Size>1104template <size_t _Size>
1062inline _LIBCPP_INLINE_VISIBILITY1105inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
1063bitset<_Size>1106bitset<_Size>
1064operator&(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT1107operator&(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
1065{1108{
...@@ -1069,7 +1112,7 @@ operator&(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT...@@ -1069,7 +1112,7 @@ operator&(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
1069}1112}
10701113
1071template <size_t _Size>1114template <size_t _Size>
1072inline _LIBCPP_INLINE_VISIBILITY1115inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
1073bitset<_Size>1116bitset<_Size>
1074operator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT1117operator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
1075{1118{
...@@ -1079,7 +1122,7 @@ operator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT...@@ -1079,7 +1122,7 @@ operator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
1079}1122}
10801123
1081template <size_t _Size>1124template <size_t _Size>
1082inline _LIBCPP_INLINE_VISIBILITY1125inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23
1083bitset<_Size>1126bitset<_Size>
1084operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT1127operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
1085{1128{
...@@ -1098,15 +1141,19 @@ struct _LIBCPP_TEMPLATE_VIS hash<bitset<_Size> >...@@ -1098,15 +1141,19 @@ struct _LIBCPP_TEMPLATE_VIS hash<bitset<_Size> >
1098};1141};
10991142
1100template <class _CharT, class _Traits, size_t _Size>1143template <class _CharT, class _Traits, size_t _Size>
1101basic_istream<_CharT, _Traits>&1144_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
1102operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x);1145operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x);
11031146
1104template <class _CharT, class _Traits, size_t _Size>1147template <class _CharT, class _Traits, size_t _Size>
1105basic_ostream<_CharT, _Traits>&1148_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
1106operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x);1149operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x);
11071150
1108_LIBCPP_END_NAMESPACE_STD1151_LIBCPP_END_NAMESPACE_STD
11091152
1110_LIBCPP_POP_MACROS1153_LIBCPP_POP_MACROS
11111154
1155#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1156# include <concepts>
1157#endif
1158
1112#endif // _LIBCPP_BITSET1159#endif // _LIBCPP_BITSET
lib/libcxx/include/cassert+8-1
...@@ -18,7 +18,14 @@ Macros:...@@ -18,7 +18,14 @@ Macros:
1818
19#include <__assert> // all public C++ headers provide the assertion handler19#include <__assert> // all public C++ headers provide the assertion handler
20#include <__config>20#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
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header31# pragma GCC system_header
lib/libcxx/include/cctype+8
...@@ -36,8 +36,16 @@ int toupper(int c);...@@ -36,8 +36,16 @@ int toupper(int c);
3636
37#include <__assert> // all public C++ headers provide the assertion handler37#include <__assert> // all public C++ headers provide the assertion handler
38#include <__config>38#include <__config>
39
39#include <ctype.h>40#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
41#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)49#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
42# pragma GCC system_header50# pragma GCC system_header
43#endif51#endif
lib/libcxx/include/cerrno+9
...@@ -24,8 +24,17 @@ Macros:...@@ -24,8 +24,17 @@ Macros:
2424
25#include <__assert> // all public C++ headers provide the assertion handler25#include <__assert> // all public C++ headers provide the assertion handler
26#include <__config>26#include <__config>
27
27#include <errno.h>28#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
29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)38#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
30# pragma GCC system_header39# pragma GCC system_header
31#endif40#endif
lib/libcxx/include/cfenv+9
...@@ -54,8 +54,17 @@ int feupdateenv(const fenv_t* envp);...@@ -54,8 +54,17 @@ int feupdateenv(const fenv_t* envp);
5454
55#include <__assert> // all public C++ headers provide the assertion handler55#include <__assert> // all public C++ headers provide the assertion handler
56#include <__config>56#include <__config>
57
57#include <fenv.h>58#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
59#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)68#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
60# pragma GCC system_header69# pragma GCC system_header
61#endif70#endif
lib/libcxx/include/cfloat+9
...@@ -71,8 +71,17 @@ Macros:...@@ -71,8 +71,17 @@ Macros:
7171
72#include <__assert> // all public C++ headers provide the assertion handler72#include <__assert> // all public C++ headers provide the assertion handler
73#include <__config>73#include <__config>
74
74#include <float.h>75#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
76#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)85#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
77# pragma GCC system_header86# pragma GCC system_header
78#endif87#endif
lib/libcxx/include/charconv+125-105
...@@ -30,8 +30,8 @@ namespace std {...@@ -30,8 +30,8 @@ namespace std {
30 friend bool operator==(const to_chars_result&, const to_chars_result&) = default; // since C++2030 friend bool operator==(const to_chars_result&, const to_chars_result&) = default; // since C++20
31 };31 };
3232
33 to_chars_result to_chars(char* first, char* last, see below value,33 constexpr to_chars_result to_chars(char* first, char* last, see below value,
34 int base = 10);34 int base = 10); // constexpr since C++23
35 to_chars_result to_chars(char* first, char* last, bool value,35 to_chars_result to_chars(char* first, char* last, bool value,
36 int base = 10) = delete;36 int base = 10) = delete;
3737
...@@ -60,8 +60,8 @@ namespace std {...@@ -60,8 +60,8 @@ namespace std {
60 friend bool operator==(const from_chars_result&, const from_chars_result&) = default; // since C++2060 friend bool operator==(const from_chars_result&, const from_chars_result&) = default; // since C++20
61 };61 };
6262
63 from_chars_result from_chars(const char* first, const char* last,63 constexpr from_chars_result from_chars(const char* first, const char* last,
64 see below& value, int base = 10);64 see below& value, int base = 10); // constexpr since C++23
6565
66 from_chars_result from_chars(const char* first, const char* last,66 from_chars_result from_chars(const char* first, const char* last,
67 float& value,67 float& value,
...@@ -77,9 +77,10 @@ namespace std {...@@ -77,9 +77,10 @@ namespace std {
7777
78*/78*/
7979
80#include <__algorithm/copy_n.h>
80#include <__assert> // all public C++ headers provide the assertion handler81#include <__assert> // all public C++ headers provide the assertion handler
81#include <__availability>82#include <__availability>
82#include <__bits>83#include <__bit/countl.h>
83#include <__charconv/chars_format.h>84#include <__charconv/chars_format.h>
84#include <__charconv/from_chars_result.h>85#include <__charconv/from_chars_result.h>
85#include <__charconv/tables.h>86#include <__charconv/tables.h>
...@@ -88,6 +89,7 @@ namespace std {...@@ -88,6 +89,7 @@ namespace std {
88#include <__config>89#include <__config>
89#include <__debug>90#include <__debug>
90#include <__errc>91#include <__errc>
92#include <__memory/addressof.h>
91#include <__type_traits/make_32_64_or_128_bit.h>93#include <__type_traits/make_32_64_or_128_bit.h>
92#include <__utility/unreachable.h>94#include <__utility/unreachable.h>
93#include <cmath> // for log2f95#include <cmath> // for log2f
...@@ -97,10 +99,6 @@ namespace std {...@@ -97,10 +99,6 @@ namespace std {
97#include <limits>99#include <limits>
98#include <type_traits>100#include <type_traits>
99101
100#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
101# include <iosfwd>
102#endif
103
104#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)102#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
105# pragma GCC system_header103# pragma GCC system_header
106#endif104#endif
...@@ -110,7 +108,7 @@ _LIBCPP_PUSH_MACROS...@@ -110,7 +108,7 @@ _LIBCPP_PUSH_MACROS
110108
111_LIBCPP_BEGIN_NAMESPACE_STD109_LIBCPP_BEGIN_NAMESPACE_STD
112110
113#ifndef _LIBCPP_CXX03_LANG111#if _LIBCPP_STD_VER > 14
114112
115to_chars_result to_chars(char*, char*, bool, int = 10) = delete;113to_chars_result to_chars(char*, char*, bool, int = 10) = delete;
116from_chars_result from_chars(const char*, const char*, bool, int = 10) = delete;114from_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...@@ -134,18 +132,18 @@ struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) <= sizeof(uin
134 /// function requires its input to have at least one bit set the value of132 /// function requires its input to have at least one bit set the value of
135 /// zero is set to one. This means the first element of the lookup table is133 /// zero is set to one. This means the first element of the lookup table is
136 /// zero.134 /// 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)
138 {136 {
139 auto __t = (32 - std::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12;137 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;
141 }139 }
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)
144 {142 {
145 return __itoa::__base_10_u32(__p, __v);143 return __itoa::__base_10_u32(__p, __v);
146 }144 }
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; }
149};147};
150148
151template <typename _Tp>149template <typename _Tp>
...@@ -161,14 +159,14 @@ struct _LIBCPP_HIDDEN...@@ -161,14 +159,14 @@ struct _LIBCPP_HIDDEN
161 /// function requires its input to have at least one bit set the value of159 /// function requires its input to have at least one bit set the value of
162 /// zero is set to one. This means the first element of the lookup table is160 /// zero is set to one. This means the first element of the lookup table is
163 /// zero.161 /// 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) {
165 auto __t = (64 - std::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12;163 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;
167 }165 }
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; }
172};170};
173171
174172
...@@ -186,25 +184,25 @@ struct _LIBCPP_HIDDEN...@@ -186,25 +184,25 @@ struct _LIBCPP_HIDDEN
186 /// function requires its input to have at least one bit set the value of184 /// function requires its input to have at least one bit set the value of
187 /// zero is set to one. This means the first element of the lookup table is185 /// zero is set to one. This means the first element of the lookup table is
188 /// zero.186 /// 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) {
190 _LIBCPP_ASSERT(__v > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fail when this isn't true.");188 _LIBCPP_ASSERT(__v > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fail when this isn't true.");
191 // There's always a bit set in the upper 64-bits.189 // There's always a bit set in the upper 64-bits.
192 auto __t = (128 - std::__libcpp_clz(static_cast<uint64_t>(__v >> 64))) * 1233 >> 12;190 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");
194 // __t is adjusted since the lookup table misses the lower entries.192 // __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;
196 }194 }
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
200 // TODO FMT This pow function should get an index.198 // TODO FMT This pow function should get an index.
201 // By moving this to its own header it can be reused by the pow function in to_chars_base_10.199 // 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; }
203};201};
204#endif202#endif
205203
206template <typename _Tp>204template <typename _Tp>
207inline _LIBCPP_HIDE_FROM_ABI bool205inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool
208__mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r)206__mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r)
209{207{
210 auto __c = __a * __b;208 auto __c = __a * __b;
...@@ -213,7 +211,7 @@ __mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r)...@@ -213,7 +211,7 @@ __mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r)
213}211}
214212
215template <typename _Tp>213template <typename _Tp>
216inline _LIBCPP_HIDE_FROM_ABI bool214inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool
217__mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r)215__mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r)
218{216{
219 auto __c = __a * __b;217 auto __c = __a * __b;
...@@ -222,24 +220,18 @@ __mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r)...@@ -222,24 +220,18 @@ __mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r)
222}220}
223221
224template <typename _Tp>222template <typename _Tp>
225inline _LIBCPP_HIDE_FROM_ABI bool223inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool
226__mul_overflowed(_Tp __a, _Tp __b, _Tp& __r)224__mul_overflowed(_Tp __a, _Tp __b, _Tp& __r)
227{225{
228 static_assert(is_unsigned<_Tp>::value, "");226 static_assert(is_unsigned<_Tp>::value, "");
229#if !defined(_LIBCPP_COMPILER_MSVC)
230 return __builtin_mul_overflow(__a, __b, &__r);227 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
236}228}
237229
238template <typename _Tp, typename _Up>230template <typename _Tp, typename _Up>
239inline _LIBCPP_HIDE_FROM_ABI bool231inline _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)
241{233{
242 return __mul_overflowed(__a, static_cast<_Tp>(__b), __r);234 return __itoa::__mul_overflowed(__a, static_cast<_Tp>(__b), __r);
243}235}
244236
245template <typename _Tp>237template <typename _Tp>
...@@ -250,7 +242,7 @@ struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>...@@ -250,7 +242,7 @@ struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>
250 using typename __traits_base<_Tp>::type;242 using typename __traits_base<_Tp>::type;
251243
252 // precondition: at least one non-zero character available244 // 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*
254 __read(char const* __p, char const* __ep, type& __a, type& __b)246 __read(char const* __p, char const* __ep, type& __a, type& __b)
255 {247 {
256 type __cprod[digits];248 type __cprod[digits];
...@@ -258,20 +250,20 @@ struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>...@@ -258,20 +250,20 @@ struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>
258 int __i = digits;250 int __i = digits;
259 do251 do
260 {252 {
261 if (!('0' <= *__p && *__p <= '9'))253 if (*__p < '0' || *__p > '9')
262 break;254 break;
263 __cprod[--__i] = *__p++ - '0';255 __cprod[--__i] = *__p++ - '0';
264 } while (__p != __ep && __i != 0);256 } while (__p != __ep && __i != 0);
265257
266 __a = __inner_product(__cprod + __i + 1, __cprod + __j, __pow() + 1,258 __a = __inner_product(__cprod + __i + 1, __cprod + __j, __pow() + 1,
267 __cprod[__i]);259 __cprod[__i]);
268 if (__mul_overflowed(__cprod[__j], __pow()[__j - __i], __b))260 if (__itoa::__mul_overflowed(__cprod[__j], __pow()[__j - __i], __b))
269 --__p;261 --__p;
270 return __p;262 return __p;
271 }263 }
272264
273 template <typename _It1, typename _It2, class _Up>265 template <typename _It1, typename _It2, class _Up>
274 static _LIBCPP_HIDE_FROM_ABI _Up266 static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _Up
275 __inner_product(_It1 __first1, _It1 __last1, _It2 __first2, _Up __init)267 __inner_product(_It1 __first1, _It1 __last1, _It2 __first2, _Up __init)
276 {268 {
277 for (; __first1 < __last1; ++__first1, ++__first2)269 for (; __first1 < __last1; ++__first1, ++__first2)
...@@ -283,7 +275,7 @@ struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>...@@ -283,7 +275,7 @@ struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>
283} // namespace __itoa275} // namespace __itoa
284276
285template <typename _Tp>277template <typename _Tp>
286inline _LIBCPP_HIDE_FROM_ABI _Tp278inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _Tp
287__complement(_Tp __x)279__complement(_Tp __x)
288{280{
289 static_assert(is_unsigned<_Tp>::value, "cast to unsigned first");281 static_assert(is_unsigned<_Tp>::value, "cast to unsigned first");
...@@ -291,21 +283,25 @@ __complement(_Tp __x)...@@ -291,21 +283,25 @@ __complement(_Tp __x)
291}283}
292284
293template <typename _Tp>285template <typename _Tp>
294inline _LIBCPP_HIDE_FROM_ABI to_chars_result286inline _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
295__to_chars_itoa(char* __first, char* __last, _Tp __value, true_type)291__to_chars_itoa(char* __first, char* __last, _Tp __value, true_type)
296{292{
297 auto __x = __to_unsigned_like(__value);293 auto __x = std::__to_unsigned_like(__value);
298 if (__value < 0 && __first != __last)294 if (__value < 0 && __first != __last)
299 {295 {
300 *__first++ = '-';296 *__first++ = '-';
301 __x = __complement(__x);297 __x = std::__complement(__x);
302 }298 }
303299
304 return __to_chars_itoa(__first, __last, __x, false_type());300 return std::__to_chars_itoa(__first, __last, __x, false_type());
305}301}
306302
307template <typename _Tp>303template <typename _Tp>
308inline _LIBCPP_HIDE_FROM_ABI to_chars_result304inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
309__to_chars_itoa(char* __first, char* __last, _Tp __value, false_type)305__to_chars_itoa(char* __first, char* __last, _Tp __value, false_type)
310{306{
311 using __tx = __itoa::__traits<_Tp>;307 using __tx = __itoa::__traits<_Tp>;
...@@ -319,7 +315,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type)...@@ -319,7 +315,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type)
319315
320# ifndef _LIBCPP_HAS_NO_INT128316# ifndef _LIBCPP_HAS_NO_INT128
321template <>317template <>
322inline _LIBCPP_HIDE_FROM_ABI to_chars_result318inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
323__to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type)319__to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type)
324{320{
325 // When the value fits in 64-bits use the 64-bit code path. This reduces321 // 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)...@@ -339,19 +335,23 @@ __to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type)
339}335}
340#endif336#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
342template <typename _Tp>342template <typename _Tp>
343inline _LIBCPP_HIDE_FROM_ABI to_chars_result343inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
344__to_chars_integral(char* __first, char* __last, _Tp __value, int __base,344__to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
345 true_type)345 true_type)
346{346{
347 auto __x = __to_unsigned_like(__value);347 auto __x = std::__to_unsigned_like(__value);
348 if (__value < 0 && __first != __last)348 if (__value < 0 && __first != __last)
349 {349 {
350 *__first++ = '-';350 *__first++ = '-';
351 __x = __complement(__x);351 __x = std::__complement(__x);
352 }352 }
353353
354 return __to_chars_integral(__first, __last, __x, __base, false_type());354 return std::__to_chars_integral(__first, __last, __x, __base, false_type());
355}355}
356356
357namespace __itoa {357namespace __itoa {
...@@ -370,7 +370,7 @@ struct _LIBCPP_HIDDEN __integral<2> {...@@ -370,7 +370,7 @@ struct _LIBCPP_HIDDEN __integral<2> {
370 }370 }
371371
372 template <typename _Tp>372 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) {
374 ptrdiff_t __cap = __last - __first;374 ptrdiff_t __cap = __last - __first;
375 int __n = __width(__value);375 int __n = __width(__value);
376 if (__n > __cap)376 if (__n > __cap)
...@@ -383,7 +383,7 @@ struct _LIBCPP_HIDDEN __integral<2> {...@@ -383,7 +383,7 @@ struct _LIBCPP_HIDDEN __integral<2> {
383 unsigned __c = __value % __divisor;383 unsigned __c = __value % __divisor;
384 __value /= __divisor;384 __value /= __divisor;
385 __p -= 4;385 __p -= 4;
386 std::memcpy(__p, &__table<>::__base_2_lut[4 * __c], 4);386 std::copy_n(&__base_2_lut[4 * __c], 4, __p);
387 }387 }
388 do {388 do {
389 unsigned __c = __value % 2;389 unsigned __c = __value % 2;
...@@ -405,7 +405,7 @@ struct _LIBCPP_HIDDEN __integral<8> {...@@ -405,7 +405,7 @@ struct _LIBCPP_HIDDEN __integral<8> {
405 }405 }
406406
407 template <typename _Tp>407 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) {
409 ptrdiff_t __cap = __last - __first;409 ptrdiff_t __cap = __last - __first;
410 int __n = __width(__value);410 int __n = __width(__value);
411 if (__n > __cap)411 if (__n > __cap)
...@@ -418,7 +418,7 @@ struct _LIBCPP_HIDDEN __integral<8> {...@@ -418,7 +418,7 @@ struct _LIBCPP_HIDDEN __integral<8> {
418 unsigned __c = __value % __divisor;418 unsigned __c = __value % __divisor;
419 __value /= __divisor;419 __value /= __divisor;
420 __p -= 2;420 __p -= 2;
421 std::memcpy(__p, &__table<>::__base_8_lut[2 * __c], 2);421 std::copy_n(&__base_8_lut[2 * __c], 2, __p);
422 }422 }
423 do {423 do {
424 unsigned __c = __value % 8;424 unsigned __c = __value % 8;
...@@ -441,7 +441,7 @@ struct _LIBCPP_HIDDEN __integral<16> {...@@ -441,7 +441,7 @@ struct _LIBCPP_HIDDEN __integral<16> {
441 }441 }
442442
443 template <typename _Tp>443 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) {
445 ptrdiff_t __cap = __last - __first;445 ptrdiff_t __cap = __last - __first;
446 int __n = __width(__value);446 int __n = __width(__value);
447 if (__n > __cap)447 if (__n > __cap)
...@@ -454,7 +454,7 @@ struct _LIBCPP_HIDDEN __integral<16> {...@@ -454,7 +454,7 @@ struct _LIBCPP_HIDDEN __integral<16> {
454 unsigned __c = __value % __divisor;454 unsigned __c = __value % __divisor;
455 __value /= __divisor;455 __value /= __divisor;
456 __p -= 2;456 __p -= 2;
457 std::memcpy(__p, &__table<>::__base_16_lut[2 * __c], 2);457 std::copy_n(&__base_16_lut[2 * __c], 2, __p);
458 }458 }
459 if (__first != __last)459 if (__first != __last)
460 do {460 do {
...@@ -470,34 +470,34 @@ struct _LIBCPP_HIDDEN __integral<16> {...@@ -470,34 +470,34 @@ struct _LIBCPP_HIDDEN __integral<16> {
470470
471template <unsigned _Base, typename _Tp,471template <unsigned _Base, typename _Tp,
472 typename enable_if<(sizeof(_Tp) >= sizeof(unsigned)), int>::type = 0>472 typename enable_if<(sizeof(_Tp) >= sizeof(unsigned)), int>::type = 0>
473_LIBCPP_HIDE_FROM_ABI int473_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int
474__to_chars_integral_width(_Tp __value) {474__to_chars_integral_width(_Tp __value) {
475 return __itoa::__integral<_Base>::__width(__value);475 return __itoa::__integral<_Base>::__width(__value);
476}476}
477477
478template <unsigned _Base, typename _Tp,478template <unsigned _Base, typename _Tp,
479 typename enable_if<(sizeof(_Tp) < sizeof(unsigned)), int>::type = 0>479 typename enable_if<(sizeof(_Tp) < sizeof(unsigned)), int>::type = 0>
480_LIBCPP_HIDE_FROM_ABI int480_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int
481__to_chars_integral_width(_Tp __value) {481__to_chars_integral_width(_Tp __value) {
482 return std::__to_chars_integral_width<_Base>(static_cast<unsigned>(__value));482 return std::__to_chars_integral_width<_Base>(static_cast<unsigned>(__value));
483}483}
484484
485template <unsigned _Base, typename _Tp,485template <unsigned _Base, typename _Tp,
486 typename enable_if<(sizeof(_Tp) >= sizeof(unsigned)), int>::type = 0>486 typename enable_if<(sizeof(_Tp) >= sizeof(unsigned)), int>::type = 0>
487_LIBCPP_HIDE_FROM_ABI to_chars_result487_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
488__to_chars_integral(char* __first, char* __last, _Tp __value) {488__to_chars_integral(char* __first, char* __last, _Tp __value) {
489 return __itoa::__integral<_Base>::__to_chars(__first, __last, __value);489 return __itoa::__integral<_Base>::__to_chars(__first, __last, __value);
490}490}
491491
492template <unsigned _Base, typename _Tp,492template <unsigned _Base, typename _Tp,
493 typename enable_if<(sizeof(_Tp) < sizeof(unsigned)), int>::type = 0>493 typename enable_if<(sizeof(_Tp) < sizeof(unsigned)), int>::type = 0>
494_LIBCPP_HIDE_FROM_ABI to_chars_result494_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
495__to_chars_integral(char* __first, char* __last, _Tp __value) {495__to_chars_integral(char* __first, char* __last, _Tp __value) {
496 return std::__to_chars_integral<_Base>(__first, __last, static_cast<unsigned>(__value));496 return std::__to_chars_integral<_Base>(__first, __last, static_cast<unsigned>(__value));
497}497}
498498
499template <typename _Tp>499template <typename _Tp>
500_LIBCPP_HIDE_FROM_ABI int500_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int
501__to_chars_integral_width(_Tp __value, unsigned __base) {501__to_chars_integral_width(_Tp __value, unsigned __base) {
502 _LIBCPP_ASSERT(__value >= 0, "The function requires a non-negative value.");502 _LIBCPP_ASSERT(__value >= 0, "The function requires a non-negative value.");
503503
...@@ -524,24 +524,24 @@ __to_chars_integral_width(_Tp __value, unsigned __base) {...@@ -524,24 +524,24 @@ __to_chars_integral_width(_Tp __value, unsigned __base) {
524}524}
525525
526template <typename _Tp>526template <typename _Tp>
527inline _LIBCPP_HIDE_FROM_ABI to_chars_result527inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
528__to_chars_integral(char* __first, char* __last, _Tp __value, int __base,528__to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
529 false_type)529 false_type)
530{530{
531 if (__base == 10) [[likely]]531 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
534 switch (__base) {534 switch (__base) {
535 case 2:535 case 2:
536 return __to_chars_integral<2>(__first, __last, __value);536 return std::__to_chars_integral<2>(__first, __last, __value);
537 case 8:537 case 8:
538 return __to_chars_integral<8>(__first, __last, __value);538 return std::__to_chars_integral<8>(__first, __last, __value);
539 case 16:539 case 16:
540 return __to_chars_integral<16>(__first, __last, __value);540 return std::__to_chars_integral<16>(__first, __last, __value);
541 }541 }
542542
543 ptrdiff_t __cap = __last - __first;543 ptrdiff_t __cap = __last - __first;
544 int __n = __to_chars_integral_width(__value, __base);544 int __n = std::__to_chars_integral_width(__value, __base);
545 if (__n > __cap)545 if (__n > __cap)
546 return {__last, errc::value_too_large};546 return {__last, errc::value_too_large};
547547
...@@ -556,7 +556,7 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base,...@@ -556,7 +556,7 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
556}556}
557557
558template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>558template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
559inline _LIBCPP_HIDE_FROM_ABI to_chars_result559inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
560to_chars(char* __first, char* __last, _Tp __value)560to_chars(char* __first, char* __last, _Tp __value)
561{561{
562 using _Type = __make_32_64_or_128_bit_t<_Tp>;562 using _Type = __make_32_64_or_128_bit_t<_Tp>;
...@@ -565,7 +565,7 @@ to_chars(char* __first, char* __last, _Tp __value)...@@ -565,7 +565,7 @@ to_chars(char* __first, char* __last, _Tp __value)
565}565}
566566
567template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>567template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
568inline _LIBCPP_HIDE_FROM_ABI to_chars_result568inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
569to_chars(char* __first, char* __last, _Tp __value, int __base)569to_chars(char* __first, char* __last, _Tp __value, int __base)
570{570{
571 _LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]");571 _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)...@@ -575,11 +575,11 @@ to_chars(char* __first, char* __last, _Tp __value, int __base)
575}575}
576576
577template <typename _It, typename _Tp, typename _Fn, typename... _Ts>577template <typename _It, typename _Tp, typename _Fn, typename... _Ts>
578inline _LIBCPP_HIDE_FROM_ABI from_chars_result578inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
579__sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)579__sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)
580{580{
581 using __tl = numeric_limits<_Tp>;581 using __tl = numeric_limits<_Tp>;
582 decltype(__to_unsigned_like(__value)) __x;582 decltype(std::__to_unsigned_like(__value)) __x;
583583
584 bool __neg = (__first != __last && *__first == '-');584 bool __neg = (__first != __last && *__first == '-');
585 auto __r = __f(__neg ? __first + 1 : __first, __last, __x, __args...);585 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)...@@ -595,16 +595,16 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)
595595
596 if (__neg)596 if (__neg)
597 {597 {
598 if (__x <= __complement(__to_unsigned_like(__tl::min())))598 if (__x <= std::__complement(std::__to_unsigned_like(__tl::min())))
599 {599 {
600 __x = __complement(__x);600 __x = std::__complement(__x);
601 std::memcpy(&__value, &__x, sizeof(__x));601 std::copy_n(std::addressof(__x), 1, std::addressof(__value));
602 return __r;602 return __r;
603 }603 }
604 }604 }
605 else605 else
606 {606 {
607 if (__x <= __to_unsigned_like(__tl::max()))607 if (__x <= std::__to_unsigned_like(__tl::max()))
608 {608 {
609 __value = __x;609 __value = __x;
610 return __r;610 return __r;
...@@ -615,7 +615,7 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)...@@ -615,7 +615,7 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)
615}615}
616616
617template <typename _Tp>617template <typename _Tp>
618inline _LIBCPP_HIDE_FROM_ABI bool618inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool
619__in_pattern(_Tp __c)619__in_pattern(_Tp __c)
620{620{
621 return '0' <= __c && __c <= '9';621 return '0' <= __c && __c <= '9';
...@@ -626,16 +626,16 @@ struct _LIBCPP_HIDDEN __in_pattern_result...@@ -626,16 +626,16 @@ struct _LIBCPP_HIDDEN __in_pattern_result
626 bool __ok;626 bool __ok;
627 int __val;627 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; }
630};630};
631631
632template <typename _Tp>632template <typename _Tp>
633inline _LIBCPP_HIDE_FROM_ABI __in_pattern_result633inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __in_pattern_result
634__in_pattern(_Tp __c, int __base)634__in_pattern(_Tp __c, int __base)
635{635{
636 if (__base <= 10)636 if (__base <= 10)
637 return {'0' <= __c && __c < '0' + __base, __c - '0'};637 return {'0' <= __c && __c < '0' + __base, __c - '0'};
638 else if (__in_pattern(__c))638 else if (std::__in_pattern(__c))
639 return {true, __c - '0'};639 return {true, __c - '0'};
640 else if ('a' <= __c && __c < 'a' + __base - 10)640 else if ('a' <= __c && __c < 'a' + __base - 10)
641 return {true, __c - 'a' + 10};641 return {true, __c - 'a' + 10};
...@@ -644,7 +644,7 @@ __in_pattern(_Tp __c, int __base)...@@ -644,7 +644,7 @@ __in_pattern(_Tp __c, int __base)
644}644}
645645
646template <typename _It, typename _Tp, typename _Fn, typename... _Ts>646template <typename _It, typename _Tp, typename _Fn, typename... _Ts>
647inline _LIBCPP_HIDE_FROM_ABI from_chars_result647inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
648__subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,648__subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,
649 _Ts... __args)649 _Ts... __args)
650{650{
...@@ -656,7 +656,7 @@ __subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,...@@ -656,7 +656,7 @@ __subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,
656 };656 };
657657
658 auto __p = __find_non_zero(__first, __last);658 auto __p = __find_non_zero(__first, __last);
659 if (__p == __last || !__in_pattern(*__p, __args...))659 if (__p == __last || !std::__in_pattern(*__p, __args...))
660 {660 {
661 if (__p == __first)661 if (__p == __first)
662 return {__first, errc::invalid_argument};662 return {__first, errc::invalid_argument};
...@@ -672,7 +672,7 @@ __subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,...@@ -672,7 +672,7 @@ __subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,
672 {672 {
673 for (; __r.ptr != __last; ++__r.ptr)673 for (; __r.ptr != __last; ++__r.ptr)
674 {674 {
675 if (!__in_pattern(*__r.ptr, __args...))675 if (!std::__in_pattern(*__r.ptr, __args...))
676 break;676 break;
677 }677 }
678 }678 }
...@@ -681,19 +681,19 @@ __subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,...@@ -681,19 +681,19 @@ __subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,
681}681}
682682
683template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0>683template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0>
684inline _LIBCPP_HIDE_FROM_ABI from_chars_result684inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
685__from_chars_atoi(const char* __first, const char* __last, _Tp& __value)685__from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
686{686{
687 using __tx = __itoa::__traits<_Tp>;687 using __tx = __itoa::__traits<_Tp>;
688 using __output_type = typename __tx::type;688 using __output_type = typename __tx::type;
689689
690 return __subject_seq_combinator(690 return std::__subject_seq_combinator(
691 __first, __last, __value,691 __first, __last, __value,
692 [](const char* __f, const char* __l,692 [](const char* __f, const char* __l,
693 _Tp& __val) -> from_chars_result {693 _Tp& __val) -> from_chars_result {
694 __output_type __a, __b;694 __output_type __a, __b;
695 auto __p = __tx::__read(__f, __l, __a, __b);695 auto __p = __tx::__read(__f, __l, __a, __b);
696 if (__p == __l || !__in_pattern(*__p))696 if (__p == __l || !std::__in_pattern(*__p))
697 {697 {
698 __output_type __m = numeric_limits<_Tp>::max();698 __output_type __m = numeric_limits<_Tp>::max();
699 if (__m >= __a && __m - __a >= __b)699 if (__m >= __a && __m - __a >= __b)
...@@ -707,27 +707,47 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value)...@@ -707,27 +707,47 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
707}707}
708708
709template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0>709template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0>
710inline _LIBCPP_HIDE_FROM_ABI from_chars_result710inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
711__from_chars_atoi(const char* __first, const char* __last, _Tp& __value)711__from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
712{712{
713 using __t = decltype(__to_unsigned_like(__value));713 using __t = decltype(std::__to_unsigned_like(__value));
714 return __sign_combinator(__first, __last, __value, __from_chars_atoi<__t>);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));
715}727}
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
717template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0>736template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0>
718inline _LIBCPP_HIDE_FROM_ABI from_chars_result737inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
719__from_chars_integral(const char* __first, const char* __last, _Tp& __value,738__from_chars_integral(const char* __first, const char* __last, _Tp& __value,
720 int __base)739 int __base)
721{740{
722 if (__base == 10)741 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(
726 __first, __last, __value,745 __first, __last, __value,
727 [](const char* __p, const char* __lastp, _Tp& __val,746 [](const char* __p, const char* __lastp, _Tp& __val,
728 int __b) -> from_chars_result {747 int __b) -> from_chars_result {
729 using __tl = numeric_limits<_Tp>;748 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];
731 _Tp __x = __in_pattern(*__p++, __b).__val, __y = 0;751 _Tp __x = __in_pattern(*__p++, __b).__val, __y = 0;
732752
733 for (int __i = 1; __p != __lastp; ++__i, ++__p)753 for (int __i = 1; __p != __lastp; ++__i, ++__p)
...@@ -762,34 +782,30 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,...@@ -762,34 +782,30 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,
762}782}
763783
764template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0>784template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0>
765inline _LIBCPP_HIDE_FROM_ABI from_chars_result785inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
766__from_chars_integral(const char* __first, const char* __last, _Tp& __value,786__from_chars_integral(const char* __first, const char* __last, _Tp& __value,
767 int __base)787 int __base)
768{788{
769 using __t = decltype(__to_unsigned_like(__value));789 using __t = decltype(std::__to_unsigned_like(__value));
770 return __sign_combinator(__first, __last, __value,790 return std::__sign_combinator(__first, __last, __value,
771 __from_chars_integral<__t>, __base);791 __from_chars_integral<__t>, __base);
772}792}
773793
774template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>794template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
775inline _LIBCPP_HIDE_FROM_ABI from_chars_result795inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
776from_chars(const char* __first, const char* __last, _Tp& __value)796from_chars(const char* __first, const char* __last, _Tp& __value)
777{797{
778 return __from_chars_atoi(__first, __last, __value);798 return std::__from_chars_atoi(__first, __last, __value);
779}799}
780800
781template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>801template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
782inline _LIBCPP_HIDE_FROM_ABI from_chars_result802inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
783from_chars(const char* __first, const char* __last, _Tp& __value, int __base)803from_chars(const char* __first, const char* __last, _Tp& __value, int __base)
784{804{
785 _LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]");805 _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);
787}807}
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
793_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS809_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
794to_chars_result to_chars(char* __first, char* __last, float __value);810to_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...@@ -817,11 +833,15 @@ to_chars_result to_chars(char* __first, char* __last, double __value, chars_form
817_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS833_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS
818to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt, int __precision);834to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt, int __precision);
819835
820# endif // _LIBCPP_STD_VER > 14836#endif // _LIBCPP_STD_VER > 14
821#endif // _LIBCPP_CXX03_LANG
822837
823_LIBCPP_END_NAMESPACE_STD838_LIBCPP_END_NAMESPACE_STD
824839
825_LIBCPP_POP_MACROS840_LIBCPP_POP_MACROS
826841
842#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
843# include <concepts>
844# include <iosfwd>
845#endif
846
827#endif // _LIBCPP_CHARCONV847#endif // _LIBCPP_CHARCONV
lib/libcxx/include/chrono+106-43
...@@ -207,7 +207,11 @@ template <class ToDuration, class Rep, class Period>...@@ -207,7 +207,11 @@ template <class ToDuration, class Rep, class Period>
207template <class ToDuration, class Rep, class Period>207template <class ToDuration, class Rep, class Period>
208 constexpr ToDuration round(const duration<Rep, Period>& d); // C++17208 constexpr ToDuration round(const duration<Rep, Period>& d); // C++17
209209
210// duration I/O is elsewhere210// 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
212// time_point arithmetic (all constexpr in C++14)216// time_point arithmetic (all constexpr in C++14)
213template <class Clock, class Duration1, class Rep2, class Period2>217template <class Clock, class Duration1, class Rep2, class Period2>
...@@ -332,32 +336,35 @@ constexpr day operator+(const day& x, const days& y) noexcept;...@@ -332,32 +336,35 @@ constexpr day operator+(const day& x, const days& y) noexcept;
332constexpr day operator+(const days& x, const day& y) noexcept;336constexpr day operator+(const days& x, const day& y) noexcept;
333constexpr day operator-(const day& x, const days& y) noexcept;337constexpr day operator-(const day& x, const days& y) noexcept;
334constexpr days operator-(const day& x, const day& y) noexcept;338constexpr 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
336// 25.8.4, class month // C++20343// 25.8.4, class month // C++20
337class month;344class month;
338constexpr bool operator==(const month& x, const month& y) noexcept;345constexpr bool operator==(const month& x, const month& y) noexcept;
339constexpr bool operator!=(const month& x, const month& y) noexcept;346constexpr strong_ordering operator<=>(const month& x, const month& y) noexcept;
340constexpr bool operator< (const month& x, const month& y) noexcept;347
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;
344constexpr month operator+(const month& x, const months& y) noexcept;348constexpr month operator+(const month& x, const months& y) noexcept;
345constexpr month operator+(const months& x, const month& y) noexcept;349constexpr month operator+(const months& x, const month& y) noexcept;
346constexpr month operator-(const month& x, const months& y) noexcept;350constexpr month operator-(const month& x, const months& y) noexcept;
347constexpr months operator-(const month& x, const month& y) noexcept;351constexpr 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
349// 25.8.5, class year // C++20356// 25.8.5, class year // C++20
350class year;357class year;
351constexpr bool operator==(const year& x, const year& y) noexcept;358constexpr bool operator==(const year& x, const year& y) noexcept;
352constexpr bool operator!=(const year& x, const year& y) noexcept;359constexpr strong_ordering operator<=>(const year& x, const year& y) noexcept;
353constexpr bool operator< (const year& x, const year& y) noexcept;360
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;
357constexpr year operator+(const year& x, const years& y) noexcept;361constexpr year operator+(const year& x, const years& y) noexcept;
358constexpr year operator+(const years& x, const year& y) noexcept;362constexpr year operator+(const years& x, const year& y) noexcept;
359constexpr year operator-(const year& x, const years& y) noexcept;363constexpr year operator-(const year& x, const years& y) noexcept;
360constexpr years operator-(const year& x, const year& y) noexcept;364constexpr 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
362// 25.8.6, class weekday // C++20369// 25.8.6, class weekday // C++20
363class weekday;370class weekday;
...@@ -368,6 +375,9 @@ constexpr weekday operator+(const weekday& x, const days& y) noexcept;...@@ -368,6 +375,9 @@ constexpr weekday operator+(const weekday& x, const days& y) noexcept;
368constexpr weekday operator+(const days& x, const weekday& y) noexcept;375constexpr weekday operator+(const days& x, const weekday& y) noexcept;
369constexpr weekday operator-(const weekday& x, const days& y) noexcept;376constexpr weekday operator-(const weekday& x, const days& y) noexcept;
370constexpr days operator-(const weekday& x, const weekday& y) noexcept;377constexpr 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
372// 25.8.7, class weekday_indexed // C++20382// 25.8.7, class weekday_indexed // C++20
373383
...@@ -375,32 +385,39 @@ class weekday_indexed;...@@ -375,32 +385,39 @@ class weekday_indexed;
375constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept;385constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept;
376constexpr bool operator!=(const weekday_indexed& x, const weekday_indexed& y) noexcept;386constexpr 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
378// 25.8.8, class weekday_last // C++20392// 25.8.8, class weekday_last // C++20
379class weekday_last;393class weekday_last;
380394
381constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept;395constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept;
382constexpr bool operator!=(const weekday_last& x, const weekday_last& y) noexcept;396constexpr 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
384// 25.8.9, class month_day // C++20402// 25.8.9, class month_day // C++20
385class month_day;403class month_day;
386404
387constexpr bool operator==(const month_day& x, const month_day& y) noexcept;405constexpr bool operator==(const month_day& x, const month_day& y) noexcept;
388constexpr bool operator!=(const month_day& x, const month_day& y) noexcept;406constexpr strong_ordering 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;
393407
408template<class charT, class traits>
409 basic_ostream<charT, traits>&
410 operator<<(basic_ostream<charT, traits>& os, const month_day& md);
394411
395// 25.8.10, class month_day_last // C++20412// 25.8.10, class month_day_last // C++20
396class month_day_last;413class month_day_last;
397414
398constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept;415constexpr 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;416constexpr strong_ordering 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;417
401constexpr bool operator> (const month_day_last& x, const month_day_last& y) noexcept;418template<class charT, class traits>
402constexpr bool operator<=(const month_day_last& x, const month_day_last& y) noexcept;419 basic_ostream<charT, traits>&
403constexpr bool operator>=(const month_day_last& x, const month_day_last& y) noexcept;420 operator<<(basic_ostream<charT, traits>& os, const month_day_last& mdl);
404421
405// 25.8.11, class month_weekday // C++20422// 25.8.11, class month_weekday // C++20
406class month_weekday;423class month_weekday;
...@@ -408,22 +425,26 @@ class month_weekday;...@@ -408,22 +425,26 @@ class month_weekday;
408constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept;425constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept;
409constexpr bool operator!=(const month_weekday& x, const month_weekday& y) noexcept;426constexpr 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
411// 25.8.12, class month_weekday_last // C++20432// 25.8.12, class month_weekday_last // C++20
412class month_weekday_last;433class month_weekday_last;
413434
414constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept;435constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept;
415constexpr bool operator!=(const month_weekday_last& x, const month_weekday_last& y) noexcept;436constexpr 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
418// 25.8.13, class year_month // C++20443// 25.8.13, class year_month // C++20
419class year_month;444class year_month;
420445
421constexpr bool operator==(const year_month& x, const year_month& y) noexcept;446constexpr bool operator==(const year_month& x, const year_month& y) noexcept;
422constexpr bool operator!=(const year_month& x, const year_month& y) noexcept;447constexpr strong_ordering 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;
427448
428constexpr year_month operator+(const year_month& ym, const months& dm) noexcept;449constexpr year_month operator+(const year_month& ym, const months& dm) noexcept;
429constexpr year_month operator+(const months& dm, const year_month& ym) noexcept;450constexpr 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;...@@ -433,15 +454,15 @@ constexpr year_month operator+(const year_month& ym, const years& dy) noexcept;
433constexpr year_month operator+(const years& dy, const year_month& ym) noexcept;454constexpr year_month operator+(const years& dy, const year_month& ym) noexcept;
434constexpr year_month operator-(const year_month& ym, const years& dy) noexcept;455constexpr 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
436// 25.8.14, class year_month_day class // C++20461// 25.8.14, class year_month_day class // C++20
437year_month_day;462year_month_day;
438463
439constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept;464constexpr 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;465constexpr strong_ordering 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;
445466
446constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept;467constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept;
447constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept;468constexpr 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...@@ -450,22 +471,15 @@ constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) n
450constexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept;471constexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept;
451constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept;472constexpr 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
454// 25.8.15, class year_month_day_last // C++20478// 25.8.15, class year_month_day_last // C++20
455class year_month_day_last;479class year_month_day_last;
456480
457constexpr bool operator==(const year_month_day_last& x,481constexpr bool operator==(const year_month_day_last& x, const year_month_day_last& y) noexcept;
458 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;
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;
469483
470constexpr year_month_day_last484constexpr year_month_day_last
471 operator+(const year_month_day_last& ymdl, const months& dm) noexcept;485 operator+(const year_month_day_last& ymdl, const months& dm) noexcept;
...@@ -480,6 +494,10 @@ constexpr year_month_day_last...@@ -480,6 +494,10 @@ constexpr year_month_day_last
480constexpr year_month_day_last494constexpr year_month_day_last
481 operator-(const year_month_day_last& ymdl, const years& dy) noexcept;495 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
483// 25.8.16, class year_month_weekday // C++20501// 25.8.16, class year_month_weekday // C++20
484class year_month_weekday;502class year_month_weekday;
485503
...@@ -501,6 +519,10 @@ constexpr year_month_weekday...@@ -501,6 +519,10 @@ constexpr year_month_weekday
501constexpr year_month_weekday519constexpr year_month_weekday
502 operator-(const year_month_weekday& ymwd, const years& dy) noexcept;520 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
504// 25.8.17, class year_month_weekday_last // C++20526// 25.8.17, class year_month_weekday_last // C++20
505class year_month_weekday_last;527class year_month_weekday_last;
506528
...@@ -521,6 +543,10 @@ constexpr year_month_weekday_last...@@ -521,6 +543,10 @@ constexpr year_month_weekday_last
521constexpr year_month_weekday_last543constexpr year_month_weekday_last
522 operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept;544 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
524// 25.8.18, civil calendar conventional syntax operators // C++20550// 25.8.18, civil calendar conventional syntax operators // C++20
525constexpr year_month551constexpr year_month
526 operator/(const year& y, const month& m) noexcept;552 operator/(const year& y, const month& m) noexcept;
...@@ -645,7 +671,29 @@ bool operator<(const time_zone& x, const time_zone& y) noexcept;...@@ -645,7 +671,29 @@ bool operator<(const time_zone& x, const time_zone& y) noexcept;
645bool operator>(const time_zone& x, const time_zone& y) noexcept;671bool operator>(const time_zone& x, const time_zone& y) noexcept;
646bool operator<=(const time_zone& x, const time_zone& y) noexcept;672bool operator<=(const time_zone& x, const time_zone& y) noexcept;
647bool operator>=(const time_zone& x, const time_zone& y) noexcept;673bool 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 {
649// calendrical constants697// calendrical constants
650inline constexpr last_spec last{}; // C++20698inline constexpr last_spec last{}; // C++20
651inline constexpr chrono::weekday Sunday{0}; // C++20699inline constexpr chrono::weekday Sunday{0}; // C++20
...@@ -695,6 +743,7 @@ constexpr chrono::year operator ""y(unsigned lo...@@ -695,6 +743,7 @@ constexpr chrono::year operator ""y(unsigned lo
695#include <__assert> // all public C++ headers provide the assertion handler743#include <__assert> // all public C++ headers provide the assertion handler
696#include <__chrono/calendar.h>744#include <__chrono/calendar.h>
697#include <__chrono/convert_to_timespec.h>745#include <__chrono/convert_to_timespec.h>
746#include <__chrono/convert_to_tm.h>
698#include <__chrono/day.h>747#include <__chrono/day.h>
699#include <__chrono/duration.h>748#include <__chrono/duration.h>
700#include <__chrono/file_clock.h>749#include <__chrono/file_clock.h>
...@@ -716,10 +765,24 @@ constexpr chrono::year operator ""y(unsigned lo...@@ -716,10 +765,24 @@ constexpr chrono::year operator ""y(unsigned lo
716#include <version>765#include <version>
717766
718// standard-mandated includes767// standard-mandated includes
768
769// [time.syn]
719#include <compare>770#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
721#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)780#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
722# pragma GCC system_header781# pragma GCC system_header
723#endif782#endif
724783
784#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
785# include <concepts>
786#endif
787
725#endif // _LIBCPP_CHRONO788#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...@@ -236,9 +236,22 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int
236236
237#include <__assert> // all public C++ headers provide the assertion handler237#include <__assert> // all public C++ headers provide the assertion handler
238#include <__config>238#include <__config>
239
240// standard-mandated includes
241
242// [cinttypes.syn]
239#include <cstdint>243#include <cstdint>
244
240#include <inttypes.h>245#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
242#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)255#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
243# pragma GCC system_header256# pragma GCC system_header
244#endif257#endif
lib/libcxx/include/climits+9
...@@ -39,8 +39,17 @@ Macros:...@@ -39,8 +39,17 @@ Macros:
3939
40#include <__assert> // all public C++ headers provide the assertion handler40#include <__assert> // all public C++ headers provide the assertion handler
41#include <__config>41#include <__config>
42
42#include <limits.h>43#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
44#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)53#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
45# pragma GCC system_header54# pragma GCC system_header
46#endif55#endif
lib/libcxx/include/clocale+9
...@@ -36,8 +36,17 @@ lconv* localeconv();...@@ -36,8 +36,17 @@ lconv* localeconv();
3636
37#include <__assert> // all public C++ headers provide the assertion handler37#include <__assert> // all public C++ headers provide the assertion handler
38#include <__config>38#include <__config>
39
39#include <locale.h>40#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
41#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)50#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
42# pragma GCC system_header51# pragma GCC system_header
43#endif52#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...@@ -306,10 +306,24 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept
306306
307#include <__assert> // all public C++ headers provide the assertion handler307#include <__assert> // all public C++ headers provide the assertion handler
308#include <__config>308#include <__config>
309#include <math.h>309#include <__type_traits/enable_if.h>
310#include <type_traits>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>
311#include <version>315#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
313#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)327#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
314# pragma GCC system_header328# pragma GCC system_header
315#endif329#endif
...@@ -549,14 +563,14 @@ hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT...@@ -549,14 +563,14 @@ hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
549 static_assert((!(is_same<_A1, __result_type>::value &&563 static_assert((!(is_same<_A1, __result_type>::value &&
550 is_same<_A2, __result_type>::value &&564 is_same<_A2, __result_type>::value &&
551 is_same<_A3, __result_type>::value)), "");565 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);
553}567}
554#endif568#endif
555569
556template <class _A1>570template <class _A1>
557_LIBCPP_INLINE_VISIBILITY571_LIBCPP_INLINE_VISIBILITY
558_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type572_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
559__libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT573__constexpr_isnan(_A1 __lcpp_x) _NOEXCEPT
560{574{
561#if __has_builtin(__builtin_isnan)575#if __has_builtin(__builtin_isnan)
562 return __builtin_isnan(__lcpp_x);576 return __builtin_isnan(__lcpp_x);
...@@ -568,15 +582,15 @@ __libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT...@@ -568,15 +582,15 @@ __libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
568template <class _A1>582template <class _A1>
569_LIBCPP_INLINE_VISIBILITY583_LIBCPP_INLINE_VISIBILITY
570_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type584_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
571__libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT585__constexpr_isnan(_A1 __lcpp_x) _NOEXCEPT
572{586{
573 return isnan(__lcpp_x);587 return std::isnan(__lcpp_x);
574}588}
575589
576template <class _A1>590template <class _A1>
577_LIBCPP_INLINE_VISIBILITY591_LIBCPP_INLINE_VISIBILITY
578_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type592_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
579__libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT593__constexpr_isinf(_A1 __lcpp_x) _NOEXCEPT
580{594{
581#if __has_builtin(__builtin_isinf)595#if __has_builtin(__builtin_isinf)
582 return __builtin_isinf(__lcpp_x);596 return __builtin_isinf(__lcpp_x);
...@@ -588,15 +602,15 @@ __libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT...@@ -588,15 +602,15 @@ __libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
588template <class _A1>602template <class _A1>
589_LIBCPP_INLINE_VISIBILITY603_LIBCPP_INLINE_VISIBILITY
590_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type604_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
591__libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT605__constexpr_isinf(_A1 __lcpp_x) _NOEXCEPT
592{606{
593 return isinf(__lcpp_x);607 return std::isinf(__lcpp_x);
594}608}
595609
596template <class _A1>610template <class _A1>
597_LIBCPP_INLINE_VISIBILITY611_LIBCPP_INLINE_VISIBILITY
598_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type612_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
599__libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT613__constexpr_isfinite(_A1 __lcpp_x) _NOEXCEPT
600{614{
601#if __has_builtin(__builtin_isfinite)615#if __has_builtin(__builtin_isfinite)
602 return __builtin_isfinite(__lcpp_x);616 return __builtin_isfinite(__lcpp_x);
...@@ -608,14 +622,169 @@ __libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT...@@ -608,14 +622,169 @@ __libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
608template <class _A1>622template <class _A1>
609_LIBCPP_INLINE_VISIBILITY623_LIBCPP_INLINE_VISIBILITY
610_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type624_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
611__libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT625__constexpr_isfinite(_A1 __lcpp_x) _NOEXCEPT
612{626{
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);
614}783}
615784
616#if _LIBCPP_STD_VER > 17785#if _LIBCPP_STD_VER > 17
617template <typename _Fp>786template <typename _Fp>
618constexpr787_LIBCPP_HIDE_FROM_ABI constexpr
619_Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept {788_Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept {
620 if ((__a <= 0 && __b >= 0) || (__a >= 0 && __b <= 0))789 if ((__a <= 0 && __b >= 0) || (__a >= 0 && __b <= 0))
621 return __t * __b + (1 - __t) * __a;790 return __t * __b + (1 - __t) * __a;
...@@ -628,13 +797,13 @@ _Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept {...@@ -628,13 +797,13 @@ _Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept {
628 return __x < __b ? __x : __b;797 return __x < __b ? __x : __b;
629}798}
630799
631constexpr float800_LIBCPP_HIDE_FROM_ABI constexpr float
632lerp(float __a, float __b, float __t) _NOEXCEPT { return __lerp(__a, __b, __t); }801lerp(float __a, float __b, float __t) _NOEXCEPT { return __lerp(__a, __b, __t); }
633802
634constexpr double803_LIBCPP_HIDE_FROM_ABI constexpr double
635lerp(double __a, double __b, double __t) _NOEXCEPT { return __lerp(__a, __b, __t); }804lerp(double __a, double __b, double __t) _NOEXCEPT { return __lerp(__a, __b, __t); }
636805
637constexpr long double806_LIBCPP_HIDE_FROM_ABI constexpr long double
638lerp(long double __a, long double __b, long double __t) _NOEXCEPT { return __lerp(__a, __b, __t); }807lerp(long double __a, long double __b, long double __t) _NOEXCEPT { return __lerp(__a, __b, __t); }
639808
640template <class _A1, class _A2, class _A3>809template <class _A1, class _A2, class _A3>
...@@ -652,7 +821,7 @@ lerp(_A1 __a, _A2 __b, _A3 __t) noexcept...@@ -652,7 +821,7 @@ lerp(_A1 __a, _A2 __b, _A3 __t) noexcept
652 static_assert(!(_IsSame<_A1, __result_type>::value &&821 static_assert(!(_IsSame<_A1, __result_type>::value &&
653 _IsSame<_A2, __result_type>::value &&822 _IsSame<_A2, __result_type>::value &&
654 _IsSame<_A3, __result_type>::value));823 _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);
656}825}
657#endif // _LIBCPP_STD_VER > 17826#endif // _LIBCPP_STD_VER > 17
658827
...@@ -660,4 +829,8 @@ _LIBCPP_END_NAMESPACE_STD...@@ -660,4 +829,8 @@ _LIBCPP_END_NAMESPACE_STD
660829
661_LIBCPP_POP_MACROS830_LIBCPP_POP_MACROS
662831
832#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
833# include <type_traits>
834#endif
835
663#endif // _LIBCPP_CMATH836#endif // _LIBCPP_CMATH
lib/libcxx/include/codecvt+208-240
...@@ -81,9 +81,9 @@ template <>...@@ -81,9 +81,9 @@ template <>
81class _LIBCPP_TYPE_VIS __codecvt_utf8<wchar_t>81class _LIBCPP_TYPE_VIS __codecvt_utf8<wchar_t>
82 : public codecvt<wchar_t, char, mbstate_t>82 : public codecvt<wchar_t, char, mbstate_t>
83{83{
84 unsigned long _Maxcode_;84 unsigned long __maxcode_;
85_LIBCPP_SUPPRESS_DEPRECATED_PUSH85_LIBCPP_SUPPRESS_DEPRECATED_PUSH
86 codecvt_mode _Mode_;86 codecvt_mode __mode_;
87_LIBCPP_SUPPRESS_DEPRECATED_POP87_LIBCPP_SUPPRESS_DEPRECATED_POP
88public:88public:
89 typedef wchar_t intern_type;89 typedef wchar_t intern_type;
...@@ -94,26 +94,22 @@ _LIBCPP_SUPPRESS_DEPRECATED_PUSH...@@ -94,26 +94,22 @@ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
94 _LIBCPP_INLINE_VISIBILITY94 _LIBCPP_INLINE_VISIBILITY
95 explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode,95 explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode,
96 codecvt_mode __mode)96 codecvt_mode __mode)
97 : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),97 : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
98 _Mode_(__mode) {}98 __mode_(__mode) {}
99_LIBCPP_SUPPRESS_DEPRECATED_POP99_LIBCPP_SUPPRESS_DEPRECATED_POP
100protected:100protected:
101 virtual result101 result do_out(state_type& __st,
102 do_out(state_type& __st,102 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
103 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 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;104 result do_in(state_type& __st,
105 virtual result105 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
106 do_in(state_type& __st,106 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
107 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,107 result do_unshift(state_type& __st,
108 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;108 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
109 virtual result109 int do_encoding() const _NOEXCEPT override;
110 do_unshift(state_type& __st,110 bool do_always_noconv() const _NOEXCEPT override;
111 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;111 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
112 virtual int do_encoding() const _NOEXCEPT;112 int do_max_length() const _NOEXCEPT override;
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;
117};113};
118#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS114#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
119115
...@@ -122,8 +118,8 @@ template <>...@@ -122,8 +118,8 @@ template <>
122class _LIBCPP_TYPE_VIS __codecvt_utf8<char16_t>118class _LIBCPP_TYPE_VIS __codecvt_utf8<char16_t>
123 : public codecvt<char16_t, char, mbstate_t>119 : public codecvt<char16_t, char, mbstate_t>
124{120{
125 unsigned long _Maxcode_;121 unsigned long __maxcode_;
126 codecvt_mode _Mode_;122 codecvt_mode __mode_;
127public:123public:
128 typedef char16_t intern_type;124 typedef char16_t intern_type;
129 typedef char extern_type;125 typedef char extern_type;
...@@ -132,27 +128,23 @@ public:...@@ -132,27 +128,23 @@ public:
132 _LIBCPP_INLINE_VISIBILITY128 _LIBCPP_INLINE_VISIBILITY
133 explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode,129 explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode,
134 codecvt_mode __mode)130 codecvt_mode __mode)
135 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),131 : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
136 _Mode_(__mode) {}132 __mode_(__mode) {}
137_LIBCPP_SUPPRESS_DEPRECATED_POP133_LIBCPP_SUPPRESS_DEPRECATED_POP
138134
139protected:135protected:
140 virtual result136 result do_out(state_type& __st,
141 do_out(state_type& __st,137 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
142 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;
143 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;139 result do_in(state_type& __st,
144 virtual result140 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
145 do_in(state_type& __st,141 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
146 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,142 result do_unshift(state_type& __st,
147 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;143 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
148 virtual result144 int do_encoding() const _NOEXCEPT override;
149 do_unshift(state_type& __st,145 bool do_always_noconv() const _NOEXCEPT override;
150 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;146 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
151 virtual int do_encoding() const _NOEXCEPT;147 int do_max_length() const _NOEXCEPT override;
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;
156};148};
157149
158_LIBCPP_SUPPRESS_DEPRECATED_PUSH150_LIBCPP_SUPPRESS_DEPRECATED_PUSH
...@@ -160,8 +152,8 @@ template <>...@@ -160,8 +152,8 @@ template <>
160class _LIBCPP_TYPE_VIS __codecvt_utf8<char32_t>152class _LIBCPP_TYPE_VIS __codecvt_utf8<char32_t>
161 : public codecvt<char32_t, char, mbstate_t>153 : public codecvt<char32_t, char, mbstate_t>
162{154{
163 unsigned long _Maxcode_;155 unsigned long __maxcode_;
164 codecvt_mode _Mode_;156 codecvt_mode __mode_;
165public:157public:
166 typedef char32_t intern_type;158 typedef char32_t intern_type;
167 typedef char extern_type;159 typedef char extern_type;
...@@ -170,27 +162,23 @@ public:...@@ -170,27 +162,23 @@ public:
170 _LIBCPP_INLINE_VISIBILITY162 _LIBCPP_INLINE_VISIBILITY
171 explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode,163 explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode,
172 codecvt_mode __mode)164 codecvt_mode __mode)
173 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),165 : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
174 _Mode_(__mode) {}166 __mode_(__mode) {}
175_LIBCPP_SUPPRESS_DEPRECATED_POP167_LIBCPP_SUPPRESS_DEPRECATED_POP
176168
177protected:169protected:
178 virtual result170 result do_out(state_type& __st,
179 do_out(state_type& __st,171 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
180 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;
181 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;173 result do_in(state_type& __st,
182 virtual result174 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
183 do_in(state_type& __st,175 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
184 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,176 result do_unshift(state_type& __st,
185 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;177 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
186 virtual result178 int do_encoding() const _NOEXCEPT override;
187 do_unshift(state_type& __st,179 bool do_always_noconv() const _NOEXCEPT override;
188 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;180 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
189 virtual int do_encoding() const _NOEXCEPT;181 int do_max_length() const _NOEXCEPT override;
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;
194};182};
195183
196_LIBCPP_SUPPRESS_DEPRECATED_PUSH184_LIBCPP_SUPPRESS_DEPRECATED_PUSH
...@@ -218,9 +206,9 @@ template <>...@@ -218,9 +206,9 @@ template <>
218class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, false>206class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, false>
219 : public codecvt<wchar_t, char, mbstate_t>207 : public codecvt<wchar_t, char, mbstate_t>
220{208{
221 unsigned long _Maxcode_;209 unsigned long __maxcode_;
222_LIBCPP_SUPPRESS_DEPRECATED_PUSH210_LIBCPP_SUPPRESS_DEPRECATED_PUSH
223 codecvt_mode _Mode_;211 codecvt_mode __mode_;
224_LIBCPP_SUPPRESS_DEPRECATED_POP212_LIBCPP_SUPPRESS_DEPRECATED_POP
225public:213public:
226 typedef wchar_t intern_type;214 typedef wchar_t intern_type;
...@@ -231,35 +219,32 @@ _LIBCPP_SUPPRESS_DEPRECATED_PUSH...@@ -231,35 +219,32 @@ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
231 _LIBCPP_INLINE_VISIBILITY219 _LIBCPP_INLINE_VISIBILITY
232 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,220 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
233 codecvt_mode __mode)221 codecvt_mode __mode)
234 : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),222 : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
235 _Mode_(__mode) {}223 __mode_(__mode) {}
236_LIBCPP_SUPPRESS_DEPRECATED_POP224_LIBCPP_SUPPRESS_DEPRECATED_POP
237protected:225protected:
238 virtual result226 result do_out(state_type& __st,
239 do_out(state_type& __st,227 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
240 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;
241 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;229 result do_in(state_type& __st,
242 virtual result230 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
243 do_in(state_type& __st,231 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
244 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,232 result do_unshift(state_type& __st,
245 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;233 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
246 virtual result234 int do_encoding() const _NOEXCEPT override;
247 do_unshift(state_type& __st,235 bool do_always_noconv() const _NOEXCEPT override;
248 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;236 int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
249 virtual int do_encoding() const _NOEXCEPT;237 size_t __mx) const override;
250 virtual bool do_always_noconv() const _NOEXCEPT;238 int do_max_length() const _NOEXCEPT override;
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;
254};239};
255240
256template <>241template <>
257class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, true>242class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, true>
258 : public codecvt<wchar_t, char, mbstate_t>243 : public codecvt<wchar_t, char, mbstate_t>
259{244{
260 unsigned long _Maxcode_;245 unsigned long __maxcode_;
261_LIBCPP_SUPPRESS_DEPRECATED_PUSH246_LIBCPP_SUPPRESS_DEPRECATED_PUSH
262 codecvt_mode _Mode_;247 codecvt_mode __mode_;
263_LIBCPP_SUPPRESS_DEPRECATED_POP248_LIBCPP_SUPPRESS_DEPRECATED_POP
264public:249public:
265 typedef wchar_t intern_type;250 typedef wchar_t intern_type;
...@@ -270,26 +255,22 @@ _LIBCPP_SUPPRESS_DEPRECATED_PUSH...@@ -270,26 +255,22 @@ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
270 _LIBCPP_INLINE_VISIBILITY255 _LIBCPP_INLINE_VISIBILITY
271 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,256 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
272 codecvt_mode __mode)257 codecvt_mode __mode)
273 : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),258 : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
274 _Mode_(__mode) {}259 __mode_(__mode) {}
275_LIBCPP_SUPPRESS_DEPRECATED_POP260_LIBCPP_SUPPRESS_DEPRECATED_POP
276protected:261protected:
277 virtual result262 result do_out(state_type& __st,
278 do_out(state_type& __st,263 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
279 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;
280 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;265 result do_in(state_type& __st,
281 virtual result266 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
282 do_in(state_type& __st,267 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
283 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,268 result do_unshift(state_type& __st,
284 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;269 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
285 virtual result270 int do_encoding() const _NOEXCEPT override;
286 do_unshift(state_type& __st,271 bool do_always_noconv() const _NOEXCEPT override;
287 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;272 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
288 virtual int do_encoding() const _NOEXCEPT;273 int do_max_length() const _NOEXCEPT override;
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;
293};274};
294#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS275#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
295276
...@@ -298,8 +279,8 @@ template <>...@@ -298,8 +279,8 @@ template <>
298class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, false>279class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, false>
299 : public codecvt<char16_t, char, mbstate_t>280 : public codecvt<char16_t, char, mbstate_t>
300{281{
301 unsigned long _Maxcode_;282 unsigned long __maxcode_;
302 codecvt_mode _Mode_;283 codecvt_mode __mode_;
303public:284public:
304 typedef char16_t intern_type;285 typedef char16_t intern_type;
305 typedef char extern_type;286 typedef char extern_type;
...@@ -308,27 +289,23 @@ public:...@@ -308,27 +289,23 @@ public:
308 _LIBCPP_INLINE_VISIBILITY289 _LIBCPP_INLINE_VISIBILITY
309 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,290 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
310 codecvt_mode __mode)291 codecvt_mode __mode)
311 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),292 : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
312 _Mode_(__mode) {}293 __mode_(__mode) {}
313_LIBCPP_SUPPRESS_DEPRECATED_POP294_LIBCPP_SUPPRESS_DEPRECATED_POP
314295
315protected:296protected:
316 virtual result297 result do_out(state_type& __st,
317 do_out(state_type& __st,298 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
318 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;
319 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;300 result do_in(state_type& __st,
320 virtual result301 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
321 do_in(state_type& __st,302 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
322 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,303 result do_unshift(state_type& __st,
323 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;304 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
324 virtual result305 int do_encoding() const _NOEXCEPT override;
325 do_unshift(state_type& __st,306 bool do_always_noconv() const _NOEXCEPT override;
326 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;307 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
327 virtual int do_encoding() const _NOEXCEPT;308 int do_max_length() const _NOEXCEPT override;
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;
332};309};
333310
334_LIBCPP_SUPPRESS_DEPRECATED_PUSH311_LIBCPP_SUPPRESS_DEPRECATED_PUSH
...@@ -336,8 +313,8 @@ template <>...@@ -336,8 +313,8 @@ template <>
336class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, true>313class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, true>
337 : public codecvt<char16_t, char, mbstate_t>314 : public codecvt<char16_t, char, mbstate_t>
338{315{
339 unsigned long _Maxcode_;316 unsigned long __maxcode_;
340 codecvt_mode _Mode_;317 codecvt_mode __mode_;
341public:318public:
342 typedef char16_t intern_type;319 typedef char16_t intern_type;
343 typedef char extern_type;320 typedef char extern_type;
...@@ -346,27 +323,23 @@ public:...@@ -346,27 +323,23 @@ public:
346 _LIBCPP_INLINE_VISIBILITY323 _LIBCPP_INLINE_VISIBILITY
347 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,324 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
348 codecvt_mode __mode)325 codecvt_mode __mode)
349 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),326 : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
350 _Mode_(__mode) {}327 __mode_(__mode) {}
351_LIBCPP_SUPPRESS_DEPRECATED_POP328_LIBCPP_SUPPRESS_DEPRECATED_POP
352329
353protected:330protected:
354 virtual result331 result do_out(state_type& __st,
355 do_out(state_type& __st,332 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
356 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;
357 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;334 result do_in(state_type& __st,
358 virtual result335 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
359 do_in(state_type& __st,336 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
360 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,337 result do_unshift(state_type& __st,
361 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;338 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
362 virtual result339 int do_encoding() const _NOEXCEPT override;
363 do_unshift(state_type& __st,340 bool do_always_noconv() const _NOEXCEPT override;
364 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;341 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
365 virtual int do_encoding() const _NOEXCEPT;342 int do_max_length() const _NOEXCEPT override;
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;
370};343};
371344
372_LIBCPP_SUPPRESS_DEPRECATED_PUSH345_LIBCPP_SUPPRESS_DEPRECATED_PUSH
...@@ -374,8 +347,8 @@ template <>...@@ -374,8 +347,8 @@ template <>
374class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, false>347class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, false>
375 : public codecvt<char32_t, char, mbstate_t>348 : public codecvt<char32_t, char, mbstate_t>
376{349{
377 unsigned long _Maxcode_;350 unsigned long __maxcode_;
378 codecvt_mode _Mode_;351 codecvt_mode __mode_;
379public:352public:
380 typedef char32_t intern_type;353 typedef char32_t intern_type;
381 typedef char extern_type;354 typedef char extern_type;
...@@ -384,27 +357,23 @@ public:...@@ -384,27 +357,23 @@ public:
384 _LIBCPP_INLINE_VISIBILITY357 _LIBCPP_INLINE_VISIBILITY
385 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,358 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
386 codecvt_mode __mode)359 codecvt_mode __mode)
387 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),360 : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
388 _Mode_(__mode) {}361 __mode_(__mode) {}
389_LIBCPP_SUPPRESS_DEPRECATED_POP362_LIBCPP_SUPPRESS_DEPRECATED_POP
390363
391protected:364protected:
392 virtual result365 result do_out(state_type& __st,
393 do_out(state_type& __st,366 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
394 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;
395 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;368 result do_in(state_type& __st,
396 virtual result369 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
397 do_in(state_type& __st,370 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
398 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,371 result do_unshift(state_type& __st,
399 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;372 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
400 virtual result373 int do_encoding() const _NOEXCEPT override;
401 do_unshift(state_type& __st,374 bool do_always_noconv() const _NOEXCEPT override;
402 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;375 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
403 virtual int do_encoding() const _NOEXCEPT;376 int do_max_length() const _NOEXCEPT override;
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;
408};377};
409378
410_LIBCPP_SUPPRESS_DEPRECATED_PUSH379_LIBCPP_SUPPRESS_DEPRECATED_PUSH
...@@ -412,8 +381,8 @@ template <>...@@ -412,8 +381,8 @@ template <>
412class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, true>381class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, true>
413 : public codecvt<char32_t, char, mbstate_t>382 : public codecvt<char32_t, char, mbstate_t>
414{383{
415 unsigned long _Maxcode_;384 unsigned long __maxcode_;
416 codecvt_mode _Mode_;385 codecvt_mode __mode_;
417public:386public:
418 typedef char32_t intern_type;387 typedef char32_t intern_type;
419 typedef char extern_type;388 typedef char extern_type;
...@@ -422,27 +391,23 @@ public:...@@ -422,27 +391,23 @@ public:
422 _LIBCPP_INLINE_VISIBILITY391 _LIBCPP_INLINE_VISIBILITY
423 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,392 explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode,
424 codecvt_mode __mode)393 codecvt_mode __mode)
425 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),394 : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
426 _Mode_(__mode) {}395 __mode_(__mode) {}
427_LIBCPP_SUPPRESS_DEPRECATED_POP396_LIBCPP_SUPPRESS_DEPRECATED_POP
428397
429protected:398protected:
430 virtual result399 result do_out(state_type& __st,
431 do_out(state_type& __st,400 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
432 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;
433 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;402 result do_in(state_type& __st,
434 virtual result403 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
435 do_in(state_type& __st,404 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
436 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,405 result do_unshift(state_type& __st,
437 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;406 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
438 virtual result407 int do_encoding() const _NOEXCEPT override;
439 do_unshift(state_type& __st,408 bool do_always_noconv() const _NOEXCEPT override;
440 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;409 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
441 virtual int do_encoding() const _NOEXCEPT;410 int do_max_length() const _NOEXCEPT override;
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;
446};411};
447412
448_LIBCPP_SUPPRESS_DEPRECATED_PUSH413_LIBCPP_SUPPRESS_DEPRECATED_PUSH
...@@ -470,9 +435,9 @@ template <>...@@ -470,9 +435,9 @@ template <>
470class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<wchar_t>435class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<wchar_t>
471 : public codecvt<wchar_t, char, mbstate_t>436 : public codecvt<wchar_t, char, mbstate_t>
472{437{
473 unsigned long _Maxcode_;438 unsigned long __maxcode_;
474_LIBCPP_SUPPRESS_DEPRECATED_PUSH439_LIBCPP_SUPPRESS_DEPRECATED_PUSH
475 codecvt_mode _Mode_;440 codecvt_mode __mode_;
476_LIBCPP_SUPPRESS_DEPRECATED_POP441_LIBCPP_SUPPRESS_DEPRECATED_POP
477public:442public:
478 typedef wchar_t intern_type;443 typedef wchar_t intern_type;
...@@ -483,26 +448,22 @@ _LIBCPP_SUPPRESS_DEPRECATED_PUSH...@@ -483,26 +448,22 @@ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
483 _LIBCPP_INLINE_VISIBILITY448 _LIBCPP_INLINE_VISIBILITY
484 explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode,449 explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode,
485 codecvt_mode __mode)450 codecvt_mode __mode)
486 : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),451 : codecvt<wchar_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
487 _Mode_(__mode) {}452 __mode_(__mode) {}
488_LIBCPP_SUPPRESS_DEPRECATED_POP453_LIBCPP_SUPPRESS_DEPRECATED_POP
489protected:454protected:
490 virtual result455 result do_out(state_type& __st,
491 do_out(state_type& __st,456 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
492 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;
493 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;458 result do_in(state_type& __st,
494 virtual result459 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
495 do_in(state_type& __st,460 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
496 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,461 result do_unshift(state_type& __st,
497 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;462 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
498 virtual result463 int do_encoding() const _NOEXCEPT override;
499 do_unshift(state_type& __st,464 bool do_always_noconv() const _NOEXCEPT override;
500 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;465 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
501 virtual int do_encoding() const _NOEXCEPT;466 int do_max_length() const _NOEXCEPT override;
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;
506};467};
507#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS468#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
508469
...@@ -511,8 +472,8 @@ template <>...@@ -511,8 +472,8 @@ template <>
511class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char32_t>472class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char32_t>
512 : public codecvt<char32_t, char, mbstate_t>473 : public codecvt<char32_t, char, mbstate_t>
513{474{
514 unsigned long _Maxcode_;475 unsigned long __maxcode_;
515 codecvt_mode _Mode_;476 codecvt_mode __mode_;
516public:477public:
517 typedef char32_t intern_type;478 typedef char32_t intern_type;
518 typedef char extern_type;479 typedef char extern_type;
...@@ -521,27 +482,23 @@ public:...@@ -521,27 +482,23 @@ public:
521 _LIBCPP_INLINE_VISIBILITY482 _LIBCPP_INLINE_VISIBILITY
522 explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode,483 explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode,
523 codecvt_mode __mode)484 codecvt_mode __mode)
524 : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),485 : codecvt<char32_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
525 _Mode_(__mode) {}486 __mode_(__mode) {}
526_LIBCPP_SUPPRESS_DEPRECATED_POP487_LIBCPP_SUPPRESS_DEPRECATED_POP
527488
528protected:489protected:
529 virtual result490 result do_out(state_type& __st,
530 do_out(state_type& __st,491 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
531 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;
532 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;493 result do_in(state_type& __st,
533 virtual result494 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
534 do_in(state_type& __st,495 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
535 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,496 result do_unshift(state_type& __st,
536 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;497 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
537 virtual result498 int do_encoding() const _NOEXCEPT override;
538 do_unshift(state_type& __st,499 bool do_always_noconv() const _NOEXCEPT override;
539 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;500 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
540 virtual int do_encoding() const _NOEXCEPT;501 int do_max_length() const _NOEXCEPT override;
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;
545};502};
546503
547_LIBCPP_SUPPRESS_DEPRECATED_PUSH504_LIBCPP_SUPPRESS_DEPRECATED_PUSH
...@@ -549,8 +506,8 @@ template <>...@@ -549,8 +506,8 @@ template <>
549class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char16_t>506class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char16_t>
550 : public codecvt<char16_t, char, mbstate_t>507 : public codecvt<char16_t, char, mbstate_t>
551{508{
552 unsigned long _Maxcode_;509 unsigned long __maxcode_;
553 codecvt_mode _Mode_;510 codecvt_mode __mode_;
554public:511public:
555 typedef char16_t intern_type;512 typedef char16_t intern_type;
556 typedef char extern_type;513 typedef char extern_type;
...@@ -559,27 +516,23 @@ public:...@@ -559,27 +516,23 @@ public:
559 _LIBCPP_INLINE_VISIBILITY516 _LIBCPP_INLINE_VISIBILITY
560 explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode,517 explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode,
561 codecvt_mode __mode)518 codecvt_mode __mode)
562 : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode),519 : codecvt<char16_t, char, mbstate_t>(__refs), __maxcode_(__maxcode),
563 _Mode_(__mode) {}520 __mode_(__mode) {}
564_LIBCPP_SUPPRESS_DEPRECATED_POP521_LIBCPP_SUPPRESS_DEPRECATED_POP
565522
566protected:523protected:
567 virtual result524 result do_out(state_type& __st,
568 do_out(state_type& __st,525 const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
569 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;
570 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;527 result do_in(state_type& __st,
571 virtual result528 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
572 do_in(state_type& __st,529 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const override;
573 const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,530 result do_unshift(state_type& __st,
574 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;531 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const override;
575 virtual result532 int do_encoding() const _NOEXCEPT override;
576 do_unshift(state_type& __st,533 bool do_always_noconv() const _NOEXCEPT override;
577 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;534 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
578 virtual int do_encoding() const _NOEXCEPT;535 int do_max_length() const _NOEXCEPT override;
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;
583};536};
584537
585_LIBCPP_SUPPRESS_DEPRECATED_PUSH538_LIBCPP_SUPPRESS_DEPRECATED_PUSH
...@@ -600,4 +553,19 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP...@@ -600,4 +553,19 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
600553
601_LIBCPP_END_NAMESPACE_STD554_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
603#endif // _LIBCPP_CODECVT571#endif // _LIBCPP_CODECVT
lib/libcxx/include/compare+4
...@@ -160,4 +160,8 @@ namespace std {...@@ -160,4 +160,8 @@ namespace std {
160# pragma GCC system_header160# pragma GCC system_header
161#endif161#endif
162162
163#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
164# include <type_traits>
165#endif
166
163#endif // _LIBCPP_COMPARE167#endif // _LIBCPP_COMPARE
lib/libcxx/include/complex+422-349
...@@ -29,21 +29,21 @@ public:...@@ -29,21 +29,21 @@ public:
29 T real() const; // constexpr in C++1429 T real() const; // constexpr in C++14
30 T imag() const; // constexpr in C++1430 T imag() const; // constexpr in C++14
3131
32 void real(T);32 void real(T); // constexpr in C++20
33 void imag(T);33 void imag(T); // constexpr in C++20
3434
35 complex<T>& operator= (const T&);35 complex<T>& operator= (const T&); // constexpr in C++20
36 complex<T>& operator+=(const T&);36 complex<T>& operator+=(const T&); // constexpr in C++20
37 complex<T>& operator-=(const T&);37 complex<T>& operator-=(const T&); // constexpr in C++20
38 complex<T>& operator*=(const T&);38 complex<T>& operator*=(const T&); // constexpr in C++20
39 complex<T>& operator/=(const T&);39 complex<T>& operator/=(const T&); // constexpr in C++20
4040
41 complex& operator=(const complex&);41 complex& operator=(const complex&); // constexpr in C++20
42 template<class X> complex<T>& operator= (const complex<X>&);42 template<class X> complex<T>& operator= (const complex<X>&); // constexpr in C++20
43 template<class X> complex<T>& operator+=(const complex<X>&);43 template<class X> complex<T>& operator+=(const complex<X>&); // constexpr in C++20
44 template<class X> complex<T>& operator-=(const complex<X>&);44 template<class X> complex<T>& operator-=(const complex<X>&); // constexpr in C++20
45 template<class X> complex<T>& operator*=(const complex<X>&);45 template<class X> complex<T>& operator*=(const complex<X>&); // constexpr in C++20
46 template<class X> complex<T>& operator/=(const complex<X>&);46 template<class X> complex<T>& operator/=(const complex<X>&); // constexpr in C++20
47};47};
4848
49template<>49template<>
...@@ -57,22 +57,22 @@ public:...@@ -57,22 +57,22 @@ public:
57 explicit constexpr complex(const complex<long double>&);57 explicit constexpr complex(const complex<long double>&);
5858
59 constexpr float real() const;59 constexpr float real() const;
60 void real(float);60 void real(float); // constexpr in C++20
61 constexpr float imag() const;61 constexpr float imag() const;
62 void imag(float);62 void imag(float); // constexpr in C++20
6363
64 complex<float>& operator= (float);64 complex<float>& operator= (float); // constexpr in C++20
65 complex<float>& operator+=(float);65 complex<float>& operator+=(float); // constexpr in C++20
66 complex<float>& operator-=(float);66 complex<float>& operator-=(float); // constexpr in C++20
67 complex<float>& operator*=(float);67 complex<float>& operator*=(float); // constexpr in C++20
68 complex<float>& operator/=(float);68 complex<float>& operator/=(float); // constexpr in C++20
6969
70 complex<float>& operator=(const complex<float>&);70 complex<float>& operator=(const complex<float>&); // constexpr in C++20
71 template<class X> complex<float>& operator= (const complex<X>&);71 template<class X> complex<float>& operator= (const complex<X>&); // constexpr in C++20
72 template<class X> complex<float>& operator+=(const complex<X>&);72 template<class X> complex<float>& operator+=(const complex<X>&); // constexpr in C++20
73 template<class X> complex<float>& operator-=(const complex<X>&);73 template<class X> complex<float>& operator-=(const complex<X>&); // constexpr in C++20
74 template<class X> complex<float>& operator*=(const complex<X>&);74 template<class X> complex<float>& operator*=(const complex<X>&); // constexpr in C++20
75 template<class X> complex<float>& operator/=(const complex<X>&);75 template<class X> complex<float>& operator/=(const complex<X>&); // constexpr in C++20
76};76};
7777
78template<>78template<>
...@@ -86,22 +86,22 @@ public:...@@ -86,22 +86,22 @@ public:
86 explicit constexpr complex(const complex<long double>&);86 explicit constexpr complex(const complex<long double>&);
8787
88 constexpr double real() const;88 constexpr double real() const;
89 void real(double);89 void real(double); // constexpr in C++20
90 constexpr double imag() const;90 constexpr double imag() const;
91 void imag(double);91 void imag(double); // constexpr in C++20
9292
93 complex<double>& operator= (double);93 complex<double>& operator= (double); // constexpr in C++20
94 complex<double>& operator+=(double);94 complex<double>& operator+=(double); // constexpr in C++20
95 complex<double>& operator-=(double);95 complex<double>& operator-=(double); // constexpr in C++20
96 complex<double>& operator*=(double);96 complex<double>& operator*=(double); // constexpr in C++20
97 complex<double>& operator/=(double);97 complex<double>& operator/=(double); // constexpr in C++20
98 complex<double>& operator=(const complex<double>&);98 complex<double>& operator=(const complex<double>&); // constexpr in C++20
9999
100 template<class X> complex<double>& operator= (const complex<X>&);100 template<class X> complex<double>& operator= (const complex<X>&); // constexpr in C++20
101 template<class X> complex<double>& operator+=(const complex<X>&);101 template<class X> complex<double>& operator+=(const complex<X>&); // constexpr in C++20
102 template<class X> complex<double>& operator-=(const complex<X>&);102 template<class X> complex<double>& operator-=(const complex<X>&); // constexpr in C++20
103 template<class X> complex<double>& operator*=(const complex<X>&);103 template<class X> complex<double>& operator*=(const complex<X>&); // constexpr in C++20
104 template<class X> complex<double>& operator/=(const complex<X>&);104 template<class X> complex<double>& operator/=(const complex<X>&); // constexpr in C++20
105};105};
106106
107template<>107template<>
...@@ -115,39 +115,39 @@ public:...@@ -115,39 +115,39 @@ public:
115 constexpr complex(const complex<double>&);115 constexpr complex(const complex<double>&);
116116
117 constexpr long double real() const;117 constexpr long double real() const;
118 void real(long double);118 void real(long double); // constexpr in C++20
119 constexpr long double imag() const;119 constexpr long double imag() const;
120 void imag(long double);120 void imag(long double); // constexpr in C++20
121121
122 complex<long double>& operator=(const complex<long double>&);122 complex<long double>& operator=(const complex<long double>&); // constexpr in C++20
123 complex<long double>& operator= (long double);123 complex<long double>& operator= (long double); // constexpr in C++20
124 complex<long double>& operator+=(long double);124 complex<long double>& operator+=(long double); // constexpr in C++20
125 complex<long double>& operator-=(long double);125 complex<long double>& operator-=(long double); // constexpr in C++20
126 complex<long double>& operator*=(long double);126 complex<long double>& operator*=(long double); // constexpr in C++20
127 complex<long double>& operator/=(long double);127 complex<long double>& operator/=(long double); // constexpr in C++20
128128
129 template<class X> complex<long double>& operator= (const complex<X>&);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>&);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>&);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>&);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>&);133 template<class X> complex<long double>& operator/=(const complex<X>&); // constexpr in C++20
134};134};
135135
136// 26.3.6 operators:136// 26.3.6 operators:
137template<class T> complex<T> operator+(const complex<T>&, 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&);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>&);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>&);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&);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>&);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>&);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&);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>&);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>&);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&);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>&);148template<class T> complex<T> operator/(const T&, const complex<T>&); // constexpr in C++20
149template<class T> complex<T> operator+(const complex<T>&);149template<class T> complex<T> operator+(const complex<T>&); // constexpr in C++20
150template<class T> complex<T> operator-(const complex<T>&);150template<class T> complex<T> operator-(const complex<T>&); // constexpr in C++20
151template<class T> bool operator==(const complex<T>&, const complex<T>&); // constexpr in C++14151template<class T> bool operator==(const complex<T>&, const complex<T>&); // constexpr in C++14
152template<class T> bool operator==(const complex<T>&, const T&); // constexpr in C++14152template<class T> bool operator==(const complex<T>&, const T&); // constexpr in C++14
153template<class T> bool operator==(const T&, const complex<T>&); // constexpr in C++14153template<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>&);...@@ -184,17 +184,17 @@ template<class T> T arg(const complex<T>&);
184template<Integral T> double arg(T);184template<Integral T> double arg(T);
185 float arg(float);185 float arg(float);
186186
187template<class T> T norm(const complex<T>&);187template<class T> T norm(const complex<T>&); // constexpr in C++20
188 long double norm(long double);188 long double norm(long double); // constexpr in C++20
189 double norm(double);189 double norm(double); // constexpr in C++20
190template<Integral T> double norm(T);190template<Integral T> double norm(T); // constexpr in C++20
191 float norm(float);191 float norm(float); // constexpr in C++20
192192
193template<class T> complex<T> conj(const complex<T>&);193template<class T> complex<T> conj(const complex<T>&); // constexpr in C++20
194 complex<long double> conj(long double);194 complex<long double> conj(long double); // constexpr in C++20
195 complex<double> conj(double);195 complex<double> conj(double); // constexpr in C++20
196template<Integral T> complex<double> conj(T);196template<Integral T> complex<double> conj(T); // constexpr in C++20
197 complex<float> conj(float);197 complex<float> conj(float); // constexpr in C++20
198198
199template<class T> complex<T> proj(const complex<T>&);199template<class T> complex<T> proj(const complex<T>&);
200 complex<long double> proj(long double);200 complex<long double> proj(long double);
...@@ -251,8 +251,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -251,8 +251,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
251251
252template<class _Tp> class _LIBCPP_TEMPLATE_VIS complex;252template<class _Tp> class _LIBCPP_TEMPLATE_VIS complex;
253253
254template<class _Tp> complex<_Tp> operator*(const complex<_Tp>& __z, const complex<_Tp>& __w);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> complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y);255template<class _Tp> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y);
256256
257template<class _Tp>257template<class _Tp>
258class _LIBCPP_TEMPLATE_VIS complex258class _LIBCPP_TEMPLATE_VIS complex
...@@ -263,50 +263,50 @@ private:...@@ -263,50 +263,50 @@ private:
263 value_type __re_;263 value_type __re_;
264 value_type __im_;264 value_type __im_;
265public:265public:
266 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11266 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
267 complex(const value_type& __re = value_type(), const value_type& __im = value_type())267 complex(const value_type& __re = value_type(), const value_type& __im = value_type())
268 : __re_(__re), __im_(__im) {}268 : __re_(__re), __im_(__im) {}
269 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11269 template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
270 complex(const complex<_Xp>& __c)270 complex(const complex<_Xp>& __c)
271 : __re_(__c.real()), __im_(__c.imag()) {}271 : __re_(__c.real()), __im_(__c.imag()) {}
272272
273 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 value_type real() const {return __re_;}273 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 value_type real() const {return __re_;}
274 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 value_type imag() const {return __im_;}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;}276 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) {__re_ = __re;}
277 _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}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)
280 {__re_ = __re; __im_ = value_type(); return *this;}280 {__re_ = __re; __im_ = value_type(); return *this;}
281 _LIBCPP_INLINE_VISIBILITY complex& operator+=(const value_type& __re) {__re_ += __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 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 complex& operator*=(const value_type& __re) {__re_ *= __re; __im_ *= __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 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)
287 {287 {
288 __re_ = __c.real();288 __re_ = __c.real();
289 __im_ = __c.imag();289 __im_ = __c.imag();
290 return *this;290 return *this;
291 }291 }
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)
293 {293 {
294 __re_ += __c.real();294 __re_ += __c.real();
295 __im_ += __c.imag();295 __im_ += __c.imag();
296 return *this;296 return *this;
297 }297 }
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)
299 {299 {
300 __re_ -= __c.real();300 __re_ -= __c.real();
301 __im_ -= __c.imag();301 __im_ -= __c.imag();
302 return *this;302 return *this;
303 }303 }
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)
305 {305 {
306 *this = *this * complex(__c.real(), __c.imag());306 *this = *this * complex(__c.real(), __c.imag());
307 return *this;307 return *this;
308 }308 }
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)
310 {310 {
311 *this = *this / complex(__c.real(), __c.imag());311 *this = *this / complex(__c.real(), __c.imag());
312 return *this;312 return *this;
...@@ -334,40 +334,40 @@ public:...@@ -334,40 +334,40 @@ public:
334 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR float real() const {return __re_;}334 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR float real() const {return __re_;}
335 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR float imag() const {return __im_;}335 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR float imag() const {return __im_;}
336336
337 _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;}337 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) {__re_ = __re;}
338 _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}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)
341 {__re_ = __re; __im_ = value_type(); return *this;}341 {__re_ = __re; __im_ = value_type(); return *this;}
342 _LIBCPP_INLINE_VISIBILITY complex& operator+=(float __re) {__re_ += __re; return *this;}342 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(float __re) {__re_ += __re; return *this;}
343 _LIBCPP_INLINE_VISIBILITY 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 complex& operator*=(float __re) {__re_ *= __re; __im_ *= __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 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)
348 {348 {
349 __re_ = __c.real();349 __re_ = __c.real();
350 __im_ = __c.imag();350 __im_ = __c.imag();
351 return *this;351 return *this;
352 }352 }
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)
354 {354 {
355 __re_ += __c.real();355 __re_ += __c.real();
356 __im_ += __c.imag();356 __im_ += __c.imag();
357 return *this;357 return *this;
358 }358 }
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)
360 {360 {
361 __re_ -= __c.real();361 __re_ -= __c.real();
362 __im_ -= __c.imag();362 __im_ -= __c.imag();
363 return *this;363 return *this;
364 }364 }
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)
366 {366 {
367 *this = *this * complex(__c.real(), __c.imag());367 *this = *this * complex(__c.real(), __c.imag());
368 return *this;368 return *this;
369 }369 }
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)
371 {371 {
372 *this = *this / complex(__c.real(), __c.imag());372 *this = *this / complex(__c.real(), __c.imag());
373 return *this;373 return *this;
...@@ -392,40 +392,40 @@ public:...@@ -392,40 +392,40 @@ public:
392 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR double real() const {return __re_;}392 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR double real() const {return __re_;}
393 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR double imag() const {return __im_;}393 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR double imag() const {return __im_;}
394394
395 _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;}395 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) {__re_ = __re;}
396 _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}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)
399 {__re_ = __re; __im_ = value_type(); return *this;}399 {__re_ = __re; __im_ = value_type(); return *this;}
400 _LIBCPP_INLINE_VISIBILITY complex& operator+=(double __re) {__re_ += __re; return *this;}400 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(double __re) {__re_ += __re; return *this;}
401 _LIBCPP_INLINE_VISIBILITY 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 complex& operator*=(double __re) {__re_ *= __re; __im_ *= __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 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)
406 {406 {
407 __re_ = __c.real();407 __re_ = __c.real();
408 __im_ = __c.imag();408 __im_ = __c.imag();
409 return *this;409 return *this;
410 }410 }
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)
412 {412 {
413 __re_ += __c.real();413 __re_ += __c.real();
414 __im_ += __c.imag();414 __im_ += __c.imag();
415 return *this;415 return *this;
416 }416 }
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)
418 {418 {
419 __re_ -= __c.real();419 __re_ -= __c.real();
420 __im_ -= __c.imag();420 __im_ -= __c.imag();
421 return *this;421 return *this;
422 }422 }
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)
424 {424 {
425 *this = *this * complex(__c.real(), __c.imag());425 *this = *this * complex(__c.real(), __c.imag());
426 return *this;426 return *this;
427 }427 }
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)
429 {429 {
430 *this = *this / complex(__c.real(), __c.imag());430 *this = *this / complex(__c.real(), __c.imag());
431 return *this;431 return *this;
...@@ -450,40 +450,40 @@ public:...@@ -450,40 +450,40 @@ public:
450 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR long double real() const {return __re_;}450 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR long double real() const {return __re_;}
451 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR long double imag() const {return __im_;}451 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR long double imag() const {return __im_;}
452452
453 _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;}453 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) {__re_ = __re;}
454 _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}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)
457 {__re_ = __re; __im_ = value_type(); return *this;}457 {__re_ = __re; __im_ = value_type(); return *this;}
458 _LIBCPP_INLINE_VISIBILITY complex& operator+=(long double __re) {__re_ += __re; return *this;}458 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator+=(long double __re) {__re_ += __re; return *this;}
459 _LIBCPP_INLINE_VISIBILITY 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 complex& operator*=(long double __re) {__re_ *= __re; __im_ *= __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 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)
464 {464 {
465 __re_ = __c.real();465 __re_ = __c.real();
466 __im_ = __c.imag();466 __im_ = __c.imag();
467 return *this;467 return *this;
468 }468 }
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)
470 {470 {
471 __re_ += __c.real();471 __re_ += __c.real();
472 __im_ += __c.imag();472 __im_ += __c.imag();
473 return *this;473 return *this;
474 }474 }
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)
476 {476 {
477 __re_ -= __c.real();477 __re_ -= __c.real();
478 __im_ -= __c.imag();478 __im_ -= __c.imag();
479 return *this;479 return *this;
480 }480 }
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)
482 {482 {
483 *this = *this * complex(__c.real(), __c.imag());483 *this = *this * complex(__c.real(), __c.imag());
484 return *this;484 return *this;
485 }485 }
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)
487 {487 {
488 *this = *this / complex(__c.real(), __c.imag());488 *this = *this / complex(__c.real(), __c.imag());
489 return *this;489 return *this;
...@@ -523,7 +523,7 @@ complex<long double>::complex(const complex<double>& __c)...@@ -523,7 +523,7 @@ complex<long double>::complex(const complex<double>& __c)
523// 26.3.6 operators:523// 26.3.6 operators:
524524
525template<class _Tp>525template<class _Tp>
526inline _LIBCPP_INLINE_VISIBILITY526inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
527complex<_Tp>527complex<_Tp>
528operator+(const complex<_Tp>& __x, const complex<_Tp>& __y)528operator+(const complex<_Tp>& __x, const complex<_Tp>& __y)
529{529{
...@@ -533,7 +533,7 @@ operator+(const complex<_Tp>& __x, const complex<_Tp>& __y)...@@ -533,7 +533,7 @@ operator+(const complex<_Tp>& __x, const complex<_Tp>& __y)
533}533}
534534
535template<class _Tp>535template<class _Tp>
536inline _LIBCPP_INLINE_VISIBILITY536inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
537complex<_Tp>537complex<_Tp>
538operator+(const complex<_Tp>& __x, const _Tp& __y)538operator+(const complex<_Tp>& __x, const _Tp& __y)
539{539{
...@@ -543,7 +543,7 @@ operator+(const complex<_Tp>& __x, const _Tp& __y)...@@ -543,7 +543,7 @@ operator+(const complex<_Tp>& __x, const _Tp& __y)
543}543}
544544
545template<class _Tp>545template<class _Tp>
546inline _LIBCPP_INLINE_VISIBILITY546inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
547complex<_Tp>547complex<_Tp>
548operator+(const _Tp& __x, const complex<_Tp>& __y)548operator+(const _Tp& __x, const complex<_Tp>& __y)
549{549{
...@@ -553,7 +553,7 @@ operator+(const _Tp& __x, const complex<_Tp>& __y)...@@ -553,7 +553,7 @@ operator+(const _Tp& __x, const complex<_Tp>& __y)
553}553}
554554
555template<class _Tp>555template<class _Tp>
556inline _LIBCPP_INLINE_VISIBILITY556inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
557complex<_Tp>557complex<_Tp>
558operator-(const complex<_Tp>& __x, const complex<_Tp>& __y)558operator-(const complex<_Tp>& __x, const complex<_Tp>& __y)
559{559{
...@@ -563,7 +563,7 @@ operator-(const complex<_Tp>& __x, const complex<_Tp>& __y)...@@ -563,7 +563,7 @@ operator-(const complex<_Tp>& __x, const complex<_Tp>& __y)
563}563}
564564
565template<class _Tp>565template<class _Tp>
566inline _LIBCPP_INLINE_VISIBILITY566inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
567complex<_Tp>567complex<_Tp>
568operator-(const complex<_Tp>& __x, const _Tp& __y)568operator-(const complex<_Tp>& __x, const _Tp& __y)
569{569{
...@@ -573,7 +573,7 @@ operator-(const complex<_Tp>& __x, const _Tp& __y)...@@ -573,7 +573,7 @@ operator-(const complex<_Tp>& __x, const _Tp& __y)
573}573}
574574
575template<class _Tp>575template<class _Tp>
576inline _LIBCPP_INLINE_VISIBILITY576inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
577complex<_Tp>577complex<_Tp>
578operator-(const _Tp& __x, const complex<_Tp>& __y)578operator-(const _Tp& __x, const complex<_Tp>& __y)
579{579{
...@@ -583,53 +583,86 @@ operator-(const _Tp& __x, const complex<_Tp>& __y)...@@ -583,53 +583,86 @@ operator-(const _Tp& __x, const complex<_Tp>& __y)
583}583}
584584
585template<class _Tp>585template<class _Tp>
586complex<_Tp>586_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
587operator*(const complex<_Tp>& __z, const complex<_Tp>& __w)587operator*(const complex<_Tp>& __z, const complex<_Tp>& __w)
588{588{
589 _Tp __a = __z.real();589 _Tp __a = __z.real();
590 _Tp __b = __z.imag();590 _Tp __b = __z.imag();
591 _Tp __c = __w.real();591 _Tp __c = __w.real();
592 _Tp __d = __w.imag();592 _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
593 _Tp __ac = __a * __c;626 _Tp __ac = __a * __c;
594 _Tp __bd = __b * __d;627 _Tp __bd = __b * __d;
595 _Tp __ad = __a * __d;628 _Tp __ad = __a * __d;
596 _Tp __bc = __b * __c;629 _Tp __bc = __b * __c;
597 _Tp __x = __ac - __bd;630 _Tp __x = __ac - __bd;
598 _Tp __y = __ad + __bc;631 _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))
600 {633 {
601 bool __recalc = false;634 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))
603 {636 {
604 __a = copysign(__libcpp_isinf_or_builtin(__a) ? _Tp(1) : _Tp(0), __a);637 __a = std::__constexpr_copysign(std::__constexpr_isinf(__a) ? _Tp(1) : _Tp(0), __a);
605 __b = copysign(__libcpp_isinf_or_builtin(__b) ? _Tp(1) : _Tp(0), __b);638 __b = std::__constexpr_copysign(std::__constexpr_isinf(__b) ? _Tp(1) : _Tp(0), __b);
606 if (__libcpp_isnan_or_builtin(__c))639 if (std::__constexpr_isnan(__c))
607 __c = copysign(_Tp(0), __c);640 __c = std::__constexpr_copysign(_Tp(0), __c);
608 if (__libcpp_isnan_or_builtin(__d))641 if (std::__constexpr_isnan(__d))
609 __d = copysign(_Tp(0), __d);642 __d = std::__constexpr_copysign(_Tp(0), __d);
610 __recalc = true;643 __recalc = true;
611 }644 }
612 if (__libcpp_isinf_or_builtin(__c) || __libcpp_isinf_or_builtin(__d))645 if (std::__constexpr_isinf(__c) || std::__constexpr_isinf(__d))
613 {646 {
614 __c = copysign(__libcpp_isinf_or_builtin(__c) ? _Tp(1) : _Tp(0), __c);647 __c = std::__constexpr_copysign(std::__constexpr_isinf(__c) ? _Tp(1) : _Tp(0), __c);
615 __d = copysign(__libcpp_isinf_or_builtin(__d) ? _Tp(1) : _Tp(0), __d);648 __d = std::__constexpr_copysign(std::__constexpr_isinf(__d) ? _Tp(1) : _Tp(0), __d);
616 if (__libcpp_isnan_or_builtin(__a))649 if (std::__constexpr_isnan(__a))
617 __a = copysign(_Tp(0), __a);650 __a = std::__constexpr_copysign(_Tp(0), __a);
618 if (__libcpp_isnan_or_builtin(__b))651 if (std::__constexpr_isnan(__b))
619 __b = copysign(_Tp(0), __b);652 __b = std::__constexpr_copysign(_Tp(0), __b);
620 __recalc = true;653 __recalc = true;
621 }654 }
622 if (!__recalc && (__libcpp_isinf_or_builtin(__ac) || __libcpp_isinf_or_builtin(__bd) ||655 if (!__recalc && (std::__constexpr_isinf(__ac) || std::__constexpr_isinf(__bd) ||
623 __libcpp_isinf_or_builtin(__ad) || __libcpp_isinf_or_builtin(__bc)))656 std::__constexpr_isinf(__ad) || std::__constexpr_isinf(__bc)))
624 {657 {
625 if (__libcpp_isnan_or_builtin(__a))658 if (std::__constexpr_isnan(__a))
626 __a = copysign(_Tp(0), __a);659 __a = std::__constexpr_copysign(_Tp(0), __a);
627 if (__libcpp_isnan_or_builtin(__b))660 if (std::__constexpr_isnan(__b))
628 __b = copysign(_Tp(0), __b);661 __b = std::__constexpr_copysign(_Tp(0), __b);
629 if (__libcpp_isnan_or_builtin(__c))662 if (std::__constexpr_isnan(__c))
630 __c = copysign(_Tp(0), __c);663 __c = std::__constexpr_copysign(_Tp(0), __c);
631 if (__libcpp_isnan_or_builtin(__d))664 if (std::__constexpr_isnan(__d))
632 __d = copysign(_Tp(0), __d);665 __d = std::__constexpr_copysign(_Tp(0), __d);
633 __recalc = true;666 __recalc = true;
634 }667 }
635 if (__recalc)668 if (__recalc)
...@@ -642,7 +675,7 @@ operator*(const complex<_Tp>& __z, const complex<_Tp>& __w)...@@ -642,7 +675,7 @@ operator*(const complex<_Tp>& __z, const complex<_Tp>& __w)
642}675}
643676
644template<class _Tp>677template<class _Tp>
645inline _LIBCPP_INLINE_VISIBILITY678inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
646complex<_Tp>679complex<_Tp>
647operator*(const complex<_Tp>& __x, const _Tp& __y)680operator*(const complex<_Tp>& __x, const _Tp& __y)
648{681{
...@@ -652,7 +685,7 @@ operator*(const complex<_Tp>& __x, const _Tp& __y)...@@ -652,7 +685,7 @@ operator*(const complex<_Tp>& __x, const _Tp& __y)
652}685}
653686
654template<class _Tp>687template<class _Tp>
655inline _LIBCPP_INLINE_VISIBILITY688inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
656complex<_Tp>689complex<_Tp>
657operator*(const _Tp& __x, const complex<_Tp>& __y)690operator*(const _Tp& __x, const complex<_Tp>& __y)
658{691{
...@@ -662,7 +695,7 @@ operator*(const _Tp& __x, const complex<_Tp>& __y)...@@ -662,7 +695,7 @@ operator*(const _Tp& __x, const complex<_Tp>& __y)
662}695}
663696
664template<class _Tp>697template<class _Tp>
665complex<_Tp>698_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
666operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)699operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
667{700{
668 int __ilogbw = 0;701 int __ilogbw = 0;
...@@ -670,34 +703,74 @@ operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)...@@ -670,34 +703,74 @@ operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
670 _Tp __b = __z.imag();703 _Tp __b = __z.imag();
671 _Tp __c = __w.real();704 _Tp __c = __w.real();
672 _Tp __d = __w.imag();705 _Tp __d = __w.imag();
673 _Tp __logbw = logb(fmax(fabs(__c), fabs(__d)));706 _Tp __logbw = std::__constexpr_logb(std::__constexpr_fmax(std::__constexpr_fabs(__c), std::__constexpr_fabs(__d)));
674 if (__libcpp_isfinite_or_builtin(__logbw))707 if (std::__constexpr_isfinite(__logbw))
675 {708 {
676 __ilogbw = static_cast<int>(__logbw);709 __ilogbw = static_cast<int>(__logbw);
677 __c = scalbn(__c, -__ilogbw);710 __c = std::__constexpr_scalbn(__c, -__ilogbw);
678 __d = scalbn(__d, -__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 }
679 }753 }
754
680 _Tp __denom = __c * __c + __d * __d;755 _Tp __denom = __c * __c + __d * __d;
681 _Tp __x = scalbn((__a * __c + __b * __d) / __denom, -__ilogbw);756 _Tp __x = std::__constexpr_scalbn((__a * __c + __b * __d) / __denom, -__ilogbw);
682 _Tp __y = scalbn((__b * __c - __a * __d) / __denom, -__ilogbw);757 _Tp __y = std::__constexpr_scalbn((__b * __c - __a * __d) / __denom, -__ilogbw);
683 if (__libcpp_isnan_or_builtin(__x) && __libcpp_isnan_or_builtin(__y))758 if (std::__constexpr_isnan(__x) && std::__constexpr_isnan(__y))
684 {759 {
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)))
686 {761 {
687 __x = copysign(_Tp(INFINITY), __c) * __a;762 __x = std::__constexpr_copysign(_Tp(INFINITY), __c) * __a;
688 __y = copysign(_Tp(INFINITY), __c) * __b;763 __y = std::__constexpr_copysign(_Tp(INFINITY), __c) * __b;
689 }764 } else if ((std::__constexpr_isinf(__a) || std::__constexpr_isinf(__b)) && std::__constexpr_isfinite(__c) &&
690 else if ((__libcpp_isinf_or_builtin(__a) || __libcpp_isinf_or_builtin(__b)) && __libcpp_isfinite_or_builtin(__c) && __libcpp_isfinite_or_builtin(__d))765 std::__constexpr_isfinite(__d)) {
691 {766 __a = std::__constexpr_copysign(std::__constexpr_isinf(__a) ? _Tp(1) : _Tp(0), __a);
692 __a = copysign(__libcpp_isinf_or_builtin(__a) ? _Tp(1) : _Tp(0), __a);767 __b = std::__constexpr_copysign(std::__constexpr_isinf(__b) ? _Tp(1) : _Tp(0), __b);
693 __b = copysign(__libcpp_isinf_or_builtin(__b) ? _Tp(1) : _Tp(0), __b);
694 __x = _Tp(INFINITY) * (__a * __c + __b * __d);768 __x = _Tp(INFINITY) * (__a * __c + __b * __d);
695 __y = _Tp(INFINITY) * (__b * __c - __a * __d);769 __y = _Tp(INFINITY) * (__b * __c - __a * __d);
696 }770 } else if (std::__constexpr_isinf(__logbw) && __logbw > _Tp(0) && std::__constexpr_isfinite(__a) &&
697 else if (__libcpp_isinf_or_builtin(__logbw) && __logbw > _Tp(0) && __libcpp_isfinite_or_builtin(__a) && __libcpp_isfinite_or_builtin(__b))771 std::__constexpr_isfinite(__b)) {
698 {772 __c = std::__constexpr_copysign(std::__constexpr_isinf(__c) ? _Tp(1) : _Tp(0), __c);
699 __c = copysign(__libcpp_isinf_or_builtin(__c) ? _Tp(1) : _Tp(0), __c);773 __d = std::__constexpr_copysign(std::__constexpr_isinf(__d) ? _Tp(1) : _Tp(0), __d);
700 __d = copysign(__libcpp_isinf_or_builtin(__d) ? _Tp(1) : _Tp(0), __d);
701 __x = _Tp(0) * (__a * __c + __b * __d);774 __x = _Tp(0) * (__a * __c + __b * __d);
702 __y = _Tp(0) * (__b * __c - __a * __d);775 __y = _Tp(0) * (__b * __c - __a * __d);
703 }776 }
...@@ -706,7 +779,7 @@ operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)...@@ -706,7 +779,7 @@ operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
706}779}
707780
708template<class _Tp>781template<class _Tp>
709inline _LIBCPP_INLINE_VISIBILITY782inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
710complex<_Tp>783complex<_Tp>
711operator/(const complex<_Tp>& __x, const _Tp& __y)784operator/(const complex<_Tp>& __x, const _Tp& __y)
712{785{
...@@ -714,7 +787,7 @@ operator/(const complex<_Tp>& __x, const _Tp& __y)...@@ -714,7 +787,7 @@ operator/(const complex<_Tp>& __x, const _Tp& __y)
714}787}
715788
716template<class _Tp>789template<class _Tp>
717inline _LIBCPP_INLINE_VISIBILITY790inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
718complex<_Tp>791complex<_Tp>
719operator/(const _Tp& __x, const complex<_Tp>& __y)792operator/(const _Tp& __x, const complex<_Tp>& __y)
720{793{
...@@ -724,7 +797,7 @@ operator/(const _Tp& __x, const complex<_Tp>& __y)...@@ -724,7 +797,7 @@ operator/(const _Tp& __x, const complex<_Tp>& __y)
724}797}
725798
726template<class _Tp>799template<class _Tp>
727inline _LIBCPP_INLINE_VISIBILITY800inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
728complex<_Tp>801complex<_Tp>
729operator+(const complex<_Tp>& __x)802operator+(const complex<_Tp>& __x)
730{803{
...@@ -732,7 +805,7 @@ operator+(const complex<_Tp>& __x)...@@ -732,7 +805,7 @@ operator+(const complex<_Tp>& __x)
732}805}
733806
734template<class _Tp>807template<class _Tp>
735inline _LIBCPP_INLINE_VISIBILITY808inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
736complex<_Tp>809complex<_Tp>
737operator-(const complex<_Tp>& __x)810operator-(const complex<_Tp>& __x)
738{811{
...@@ -740,7 +813,7 @@ operator-(const complex<_Tp>& __x)...@@ -740,7 +813,7 @@ operator-(const complex<_Tp>& __x)
740}813}
741814
742template<class _Tp>815template<class _Tp>
743inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11816inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
744bool817bool
745operator==(const complex<_Tp>& __x, const complex<_Tp>& __y)818operator==(const complex<_Tp>& __x, const complex<_Tp>& __y)
746{819{
...@@ -748,7 +821,7 @@ operator==(const complex<_Tp>& __x, const complex<_Tp>& __y)...@@ -748,7 +821,7 @@ operator==(const complex<_Tp>& __x, const complex<_Tp>& __y)
748}821}
749822
750template<class _Tp>823template<class _Tp>
751inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11824inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
752bool825bool
753operator==(const complex<_Tp>& __x, const _Tp& __y)826operator==(const complex<_Tp>& __x, const _Tp& __y)
754{827{
...@@ -756,7 +829,7 @@ operator==(const complex<_Tp>& __x, const _Tp& __y)...@@ -756,7 +829,7 @@ operator==(const complex<_Tp>& __x, const _Tp& __y)
756}829}
757830
758template<class _Tp>831template<class _Tp>
759inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11832inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
760bool833bool
761operator==(const _Tp& __x, const complex<_Tp>& __y)834operator==(const _Tp& __x, const complex<_Tp>& __y)
762{835{
...@@ -764,7 +837,7 @@ operator==(const _Tp& __x, const complex<_Tp>& __y)...@@ -764,7 +837,7 @@ operator==(const _Tp& __x, const complex<_Tp>& __y)
764}837}
765838
766template<class _Tp>839template<class _Tp>
767inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11840inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
768bool841bool
769operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y)842operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y)
770{843{
...@@ -772,7 +845,7 @@ operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y)...@@ -772,7 +845,7 @@ operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y)
772}845}
773846
774template<class _Tp>847template<class _Tp>
775inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11848inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
776bool849bool
777operator!=(const complex<_Tp>& __x, const _Tp& __y)850operator!=(const complex<_Tp>& __x, const _Tp& __y)
778{851{
...@@ -780,7 +853,7 @@ operator!=(const complex<_Tp>& __x, const _Tp& __y)...@@ -780,7 +853,7 @@ operator!=(const complex<_Tp>& __x, const _Tp& __y)
780}853}
781854
782template<class _Tp>855template<class _Tp>
783inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11856inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
784bool857bool
785operator!=(const _Tp& __x, const complex<_Tp>& __y)858operator!=(const _Tp& __x, const complex<_Tp>& __y)
786{859{
...@@ -813,7 +886,7 @@ struct __libcpp_complex_overload_traits<_Tp, false, true>...@@ -813,7 +886,7 @@ struct __libcpp_complex_overload_traits<_Tp, false, true>
813// real886// real
814887
815template<class _Tp>888template<class _Tp>
816inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11889inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
817_Tp890_Tp
818real(const complex<_Tp>& __c)891real(const complex<_Tp>& __c)
819{892{
...@@ -821,7 +894,7 @@ real(const complex<_Tp>& __c)...@@ -821,7 +894,7 @@ real(const complex<_Tp>& __c)
821}894}
822895
823template <class _Tp>896template <class _Tp>
824inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11897inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
825typename __libcpp_complex_overload_traits<_Tp>::_ValueType898typename __libcpp_complex_overload_traits<_Tp>::_ValueType
826real(_Tp __re)899real(_Tp __re)
827{900{
...@@ -831,7 +904,7 @@ real(_Tp __re)...@@ -831,7 +904,7 @@ real(_Tp __re)
831// imag904// imag
832905
833template<class _Tp>906template<class _Tp>
834inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11907inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
835_Tp908_Tp
836imag(const complex<_Tp>& __c)909imag(const complex<_Tp>& __c)
837{910{
...@@ -839,7 +912,7 @@ imag(const complex<_Tp>& __c)...@@ -839,7 +912,7 @@ imag(const complex<_Tp>& __c)
839}912}
840913
841template <class _Tp>914template <class _Tp>
842inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11915inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
843typename __libcpp_complex_overload_traits<_Tp>::_ValueType916typename __libcpp_complex_overload_traits<_Tp>::_ValueType
844imag(_Tp)917imag(_Tp)
845{918{
...@@ -853,7 +926,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -853,7 +926,7 @@ inline _LIBCPP_INLINE_VISIBILITY
853_Tp926_Tp
854abs(const complex<_Tp>& __c)927abs(const complex<_Tp>& __c)
855{928{
856 return hypot(__c.real(), __c.imag());929 return std::hypot(__c.real(), __c.imag());
857}930}
858931
859// arg932// arg
...@@ -863,7 +936,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -863,7 +936,7 @@ inline _LIBCPP_INLINE_VISIBILITY
863_Tp936_Tp
864arg(const complex<_Tp>& __c)937arg(const complex<_Tp>& __c)
865{938{
866 return atan2(__c.imag(), __c.real());939 return std::atan2(__c.imag(), __c.real());
867}940}
868941
869template <class _Tp>942template <class _Tp>
...@@ -874,7 +947,7 @@ typename enable_if<...@@ -874,7 +947,7 @@ typename enable_if<
874>::type947>::type
875arg(_Tp __re)948arg(_Tp __re)
876{949{
877 return atan2l(0.L, __re);950 return std::atan2l(0.L, __re);
878}951}
879952
880template<class _Tp>953template<class _Tp>
...@@ -886,7 +959,7 @@ typename enable_if...@@ -886,7 +959,7 @@ typename enable_if
886>::type959>::type
887arg(_Tp __re)960arg(_Tp __re)
888{961{
889 return atan2(0., __re);962 return std::atan2(0., __re);
890}963}
891964
892template <class _Tp>965template <class _Tp>
...@@ -897,25 +970,25 @@ typename enable_if<...@@ -897,25 +970,25 @@ typename enable_if<
897>::type970>::type
898arg(_Tp __re)971arg(_Tp __re)
899{972{
900 return atan2f(0.F, __re);973 return std::atan2f(0.F, __re);
901}974}
902975
903// norm976// norm
904977
905template<class _Tp>978template<class _Tp>
906inline _LIBCPP_INLINE_VISIBILITY979inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
907_Tp980_Tp
908norm(const complex<_Tp>& __c)981norm(const complex<_Tp>& __c)
909{982{
910 if (__libcpp_isinf_or_builtin(__c.real()))983 if (std::__constexpr_isinf(__c.real()))
911 return abs(__c.real());984 return std::abs(__c.real());
912 if (__libcpp_isinf_or_builtin(__c.imag()))985 if (std::__constexpr_isinf(__c.imag()))
913 return abs(__c.imag());986 return std::abs(__c.imag());
914 return __c.real() * __c.real() + __c.imag() * __c.imag();987 return __c.real() * __c.real() + __c.imag() * __c.imag();
915}988}
916989
917template <class _Tp>990template <class _Tp>
918inline _LIBCPP_INLINE_VISIBILITY991inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
919typename __libcpp_complex_overload_traits<_Tp>::_ValueType992typename __libcpp_complex_overload_traits<_Tp>::_ValueType
920norm(_Tp __re)993norm(_Tp __re)
921{994{
...@@ -926,7 +999,7 @@ norm(_Tp __re)...@@ -926,7 +999,7 @@ norm(_Tp __re)
926// conj999// conj
9271000
928template<class _Tp>1001template<class _Tp>
929inline _LIBCPP_INLINE_VISIBILITY1002inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
930complex<_Tp>1003complex<_Tp>
931conj(const complex<_Tp>& __c)1004conj(const complex<_Tp>& __c)
932{1005{
...@@ -934,7 +1007,7 @@ conj(const complex<_Tp>& __c)...@@ -934,7 +1007,7 @@ conj(const complex<_Tp>& __c)
934}1007}
9351008
936template <class _Tp>1009template <class _Tp>
937inline _LIBCPP_INLINE_VISIBILITY1010inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
938typename __libcpp_complex_overload_traits<_Tp>::_ComplexType1011typename __libcpp_complex_overload_traits<_Tp>::_ComplexType
939conj(_Tp __re)1012conj(_Tp __re)
940{1013{
...@@ -952,8 +1025,8 @@ complex<_Tp>...@@ -952,8 +1025,8 @@ complex<_Tp>
952proj(const complex<_Tp>& __c)1025proj(const complex<_Tp>& __c)
953{1026{
954 complex<_Tp> __r = __c;1027 complex<_Tp> __r = __c;
955 if (__libcpp_isinf_or_builtin(__c.real()) || __libcpp_isinf_or_builtin(__c.imag()))1028 if (std::__constexpr_isinf(__c.real()) || std::__constexpr_isinf(__c.imag()))
956 __r = complex<_Tp>(INFINITY, copysign(_Tp(0), __c.imag()));1029 __r = complex<_Tp>(INFINITY, std::copysign(_Tp(0), __c.imag()));
957 return __r;1030 return __r;
958}1031}
9591032
...@@ -966,8 +1039,8 @@ typename enable_if...@@ -966,8 +1039,8 @@ typename enable_if
966>::type1039>::type
967proj(_Tp __re)1040proj(_Tp __re)
968{1041{
969 if (__libcpp_isinf_or_builtin(__re))1042 if (std::__constexpr_isinf(__re))
970 __re = abs(__re);1043 __re = std::abs(__re);
971 return complex<_Tp>(__re);1044 return complex<_Tp>(__re);
972}1045}
9731046
...@@ -987,28 +1060,28 @@ proj(_Tp __re)...@@ -987,28 +1060,28 @@ proj(_Tp __re)
987// polar1060// polar
9881061
989template<class _Tp>1062template<class _Tp>
990complex<_Tp>1063_LIBCPP_HIDE_FROM_ABI complex<_Tp>
991polar(const _Tp& __rho, const _Tp& __theta = _Tp())1064polar(const _Tp& __rho, const _Tp& __theta = _Tp())
992{1065{
993 if (__libcpp_isnan_or_builtin(__rho) || signbit(__rho))1066 if (std::__constexpr_isnan(__rho) || std::signbit(__rho))
994 return complex<_Tp>(_Tp(NAN), _Tp(NAN));1067 return complex<_Tp>(_Tp(NAN), _Tp(NAN));
995 if (__libcpp_isnan_or_builtin(__theta))1068 if (std::__constexpr_isnan(__theta))
996 {1069 {
997 if (__libcpp_isinf_or_builtin(__rho))1070 if (std::__constexpr_isinf(__rho))
998 return complex<_Tp>(__rho, __theta);1071 return complex<_Tp>(__rho, __theta);
999 return complex<_Tp>(__theta, __theta);1072 return complex<_Tp>(__theta, __theta);
1000 }1073 }
1001 if (__libcpp_isinf_or_builtin(__theta))1074 if (std::__constexpr_isinf(__theta))
1002 {1075 {
1003 if (__libcpp_isinf_or_builtin(__rho))1076 if (std::__constexpr_isinf(__rho))
1004 return complex<_Tp>(__rho, _Tp(NAN));1077 return complex<_Tp>(__rho, _Tp(NAN));
1005 return complex<_Tp>(_Tp(NAN), _Tp(NAN));1078 return complex<_Tp>(_Tp(NAN), _Tp(NAN));
1006 }1079 }
1007 _Tp __x = __rho * cos(__theta);1080 _Tp __x = __rho * std::cos(__theta);
1008 if (__libcpp_isnan_or_builtin(__x))1081 if (std::__constexpr_isnan(__x))
1009 __x = 0;1082 __x = 0;
1010 _Tp __y = __rho * sin(__theta);1083 _Tp __y = __rho * std::sin(__theta);
1011 if (__libcpp_isnan_or_builtin(__y))1084 if (std::__constexpr_isnan(__y))
1012 __y = 0;1085 __y = 0;
1013 return complex<_Tp>(__x, __y);1086 return complex<_Tp>(__x, __y);
1014}1087}
...@@ -1020,7 +1093,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -1020,7 +1093,7 @@ inline _LIBCPP_INLINE_VISIBILITY
1020complex<_Tp>1093complex<_Tp>
1021log(const complex<_Tp>& __x)1094log(const complex<_Tp>& __x)
1022{1095{
1023 return complex<_Tp>(log(abs(__x)), arg(__x));1096 return complex<_Tp>(std::log(std::abs(__x)), std::arg(__x));
1024}1097}
10251098
1026// log101099// log10
...@@ -1030,52 +1103,52 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -1030,52 +1103,52 @@ inline _LIBCPP_INLINE_VISIBILITY
1030complex<_Tp>1103complex<_Tp>
1031log10(const complex<_Tp>& __x)1104log10(const complex<_Tp>& __x)
1032{1105{
1033 return log(__x) / log(_Tp(10));1106 return std::log(__x) / std::log(_Tp(10));
1034}1107}
10351108
1036// sqrt1109// sqrt
10371110
1038template<class _Tp>1111template<class _Tp>
1039complex<_Tp>1112_LIBCPP_HIDE_FROM_ABI complex<_Tp>
1040sqrt(const complex<_Tp>& __x)1113sqrt(const complex<_Tp>& __x)
1041{1114{
1042 if (__libcpp_isinf_or_builtin(__x.imag()))1115 if (std::__constexpr_isinf(__x.imag()))
1043 return complex<_Tp>(_Tp(INFINITY), __x.imag());1116 return complex<_Tp>(_Tp(INFINITY), __x.imag());
1044 if (__libcpp_isinf_or_builtin(__x.real()))1117 if (std::__constexpr_isinf(__x.real()))
1045 {1118 {
1046 if (__x.real() > _Tp(0))1119 if (__x.real() > _Tp(0))
1047 return complex<_Tp>(__x.real(), __libcpp_isnan_or_builtin(__x.imag()) ? __x.imag() : copysign(_Tp(0), __x.imag()));1120 return complex<_Tp>(__x.real(), std::__constexpr_isnan(__x.imag()) ? __x.imag() : std::copysign(_Tp(0), __x.imag()));
1048 return complex<_Tp>(__libcpp_isnan_or_builtin(__x.imag()) ? __x.imag() : _Tp(0), copysign(__x.real(), __x.imag()));1121 return complex<_Tp>(std::__constexpr_isnan(__x.imag()) ? __x.imag() : _Tp(0), std::copysign(__x.real(), __x.imag()));
1049 }1122 }
1050 return polar(sqrt(abs(__x)), arg(__x) / _Tp(2));1123 return std::polar(std::sqrt(std::abs(__x)), std::arg(__x) / _Tp(2));
1051}1124}
10521125
1053// exp1126// exp
10541127
1055template<class _Tp>1128template<class _Tp>
1056complex<_Tp>1129_LIBCPP_HIDE_FROM_ABI complex<_Tp>
1057exp(const complex<_Tp>& __x)1130exp(const complex<_Tp>& __x)
1058{1131{
1059 _Tp __i = __x.imag();1132 _Tp __i = __x.imag();
1060 if (__i == 0) {1133 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()));
1062 }1135 }
1063 if (__libcpp_isinf_or_builtin(__x.real()))1136 if (std::__constexpr_isinf(__x.real()))
1064 {1137 {
1065 if (__x.real() < _Tp(0))1138 if (__x.real() < _Tp(0))
1066 {1139 {
1067 if (!__libcpp_isfinite_or_builtin(__i))1140 if (!std::__constexpr_isfinite(__i))
1068 __i = _Tp(1);1141 __i = _Tp(1);
1069 }1142 }
1070 else if (__i == 0 || !__libcpp_isfinite_or_builtin(__i))1143 else if (__i == 0 || !std::__constexpr_isfinite(__i))
1071 {1144 {
1072 if (__libcpp_isinf_or_builtin(__i))1145 if (std::__constexpr_isinf(__i))
1073 __i = _Tp(NAN);1146 __i = _Tp(NAN);
1074 return complex<_Tp>(__x.real(), __i);1147 return complex<_Tp>(__x.real(), __i);
1075 }1148 }
1076 }1149 }
1077 _Tp __e = exp(__x.real());1150 _Tp __e = std::exp(__x.real());
1078 return complex<_Tp>(__e * cos(__i), __e * sin(__i));1151 return complex<_Tp>(__e * std::cos(__i), __e * std::sin(__i));
1079}1152}
10801153
1081// pow1154// pow
...@@ -1085,7 +1158,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -1085,7 +1158,7 @@ inline _LIBCPP_INLINE_VISIBILITY
1085complex<_Tp>1158complex<_Tp>
1086pow(const complex<_Tp>& __x, const complex<_Tp>& __y)1159pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
1087{1160{
1088 return exp(__y * log(__x));1161 return std::exp(__y * std::log(__x));
1089}1162}
10901163
1091template<class _Tp, class _Up>1164template<class _Tp, class _Up>
...@@ -1137,219 +1210,219 @@ __sqr(const complex<_Tp>& __x)...@@ -1137,219 +1210,219 @@ __sqr(const complex<_Tp>& __x)
1137// asinh1210// asinh
11381211
1139template<class _Tp>1212template<class _Tp>
1140complex<_Tp>1213_LIBCPP_HIDE_FROM_ABI complex<_Tp>
1141asinh(const complex<_Tp>& __x)1214asinh(const complex<_Tp>& __x)
1142{1215{
1143 const _Tp __pi(atan2(+0., -0.));1216 const _Tp __pi(atan2(+0., -0.));
1144 if (__libcpp_isinf_or_builtin(__x.real()))1217 if (std::__constexpr_isinf(__x.real()))
1145 {1218 {
1146 if (__libcpp_isnan_or_builtin(__x.imag()))1219 if (std::__constexpr_isnan(__x.imag()))
1147 return __x;1220 return __x;
1148 if (__libcpp_isinf_or_builtin(__x.imag()))1221 if (std::__constexpr_isinf(__x.imag()))
1149 return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag()));1222 return complex<_Tp>(__x.real(), std::copysign(__pi * _Tp(0.25), __x.imag()));
1150 return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag()));1223 return complex<_Tp>(__x.real(), std::copysign(_Tp(0), __x.imag()));
1151 }1224 }
1152 if (__libcpp_isnan_or_builtin(__x.real()))1225 if (std::__constexpr_isnan(__x.real()))
1153 {1226 {
1154 if (__libcpp_isinf_or_builtin(__x.imag()))1227 if (std::__constexpr_isinf(__x.imag()))
1155 return complex<_Tp>(__x.imag(), __x.real());1228 return complex<_Tp>(__x.imag(), __x.real());
1156 if (__x.imag() == 0)1229 if (__x.imag() == 0)
1157 return __x;1230 return __x;
1158 return complex<_Tp>(__x.real(), __x.real());1231 return complex<_Tp>(__x.real(), __x.real());
1159 }1232 }
1160 if (__libcpp_isinf_or_builtin(__x.imag()))1233 if (std::__constexpr_isinf(__x.imag()))
1161 return complex<_Tp>(copysign(__x.imag(), __x.real()), copysign(__pi/_Tp(2), __x.imag()));1234 return complex<_Tp>(std::copysign(__x.imag(), __x.real()), std::copysign(__pi/_Tp(2), __x.imag()));
1162 complex<_Tp> __z = log(__x + sqrt(__sqr(__x) + _Tp(1)));1235 complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) + _Tp(1)));
1163 return complex<_Tp>(copysign(__z.real(), __x.real()), copysign(__z.imag(), __x.imag()));1236 return complex<_Tp>(std::copysign(__z.real(), __x.real()), std::copysign(__z.imag(), __x.imag()));
1164}1237}
11651238
1166// acosh1239// acosh
11671240
1168template<class _Tp>1241template<class _Tp>
1169complex<_Tp>1242_LIBCPP_HIDE_FROM_ABI complex<_Tp>
1170acosh(const complex<_Tp>& __x)1243acosh(const complex<_Tp>& __x)
1171{1244{
1172 const _Tp __pi(atan2(+0., -0.));1245 const _Tp __pi(atan2(+0., -0.));
1173 if (__libcpp_isinf_or_builtin(__x.real()))1246 if (std::__constexpr_isinf(__x.real()))
1174 {1247 {
1175 if (__libcpp_isnan_or_builtin(__x.imag()))1248 if (std::__constexpr_isnan(__x.imag()))
1176 return complex<_Tp>(abs(__x.real()), __x.imag());1249 return complex<_Tp>(std::abs(__x.real()), __x.imag());
1177 if (__libcpp_isinf_or_builtin(__x.imag()))1250 if (std::__constexpr_isinf(__x.imag()))
1178 {1251 {
1179 if (__x.real() > 0)1252 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()));
1181 else1254 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()));
1183 }1256 }
1184 if (__x.real() < 0)1257 if (__x.real() < 0)
1185 return complex<_Tp>(-__x.real(), copysign(__pi, __x.imag()));1258 return complex<_Tp>(-__x.real(), std::copysign(__pi, __x.imag()));
1186 return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag()));1259 return complex<_Tp>(__x.real(), std::copysign(_Tp(0), __x.imag()));
1187 }1260 }
1188 if (__libcpp_isnan_or_builtin(__x.real()))1261 if (std::__constexpr_isnan(__x.real()))
1189 {1262 {
1190 if (__libcpp_isinf_or_builtin(__x.imag()))1263 if (std::__constexpr_isinf(__x.imag()))
1191 return complex<_Tp>(abs(__x.imag()), __x.real());1264 return complex<_Tp>(std::abs(__x.imag()), __x.real());
1192 return complex<_Tp>(__x.real(), __x.real());1265 return complex<_Tp>(__x.real(), __x.real());
1193 }1266 }
1194 if (__libcpp_isinf_or_builtin(__x.imag()))1267 if (std::__constexpr_isinf(__x.imag()))
1195 return complex<_Tp>(abs(__x.imag()), copysign(__pi/_Tp(2), __x.imag()));1268 return complex<_Tp>(std::abs(__x.imag()), std::copysign(__pi/_Tp(2), __x.imag()));
1196 complex<_Tp> __z = log(__x + sqrt(__sqr(__x) - _Tp(1)));1269 complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) - _Tp(1)));
1197 return complex<_Tp>(copysign(__z.real(), _Tp(0)), copysign(__z.imag(), __x.imag()));1270 return complex<_Tp>(std::copysign(__z.real(), _Tp(0)), std::copysign(__z.imag(), __x.imag()));
1198}1271}
11991272
1200// atanh1273// atanh
12011274
1202template<class _Tp>1275template<class _Tp>
1203complex<_Tp>1276_LIBCPP_HIDE_FROM_ABI complex<_Tp>
1204atanh(const complex<_Tp>& __x)1277atanh(const complex<_Tp>& __x)
1205{1278{
1206 const _Tp __pi(atan2(+0., -0.));1279 const _Tp __pi(atan2(+0., -0.));
1207 if (__libcpp_isinf_or_builtin(__x.imag()))1280 if (std::__constexpr_isinf(__x.imag()))
1208 {1281 {
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()));
1210 }1283 }
1211 if (__libcpp_isnan_or_builtin(__x.imag()))1284 if (std::__constexpr_isnan(__x.imag()))
1212 {1285 {
1213 if (__libcpp_isinf_or_builtin(__x.real()) || __x.real() == 0)1286 if (std::__constexpr_isinf(__x.real()) || __x.real() == 0)
1214 return complex<_Tp>(copysign(_Tp(0), __x.real()), __x.imag());1287 return complex<_Tp>(std::copysign(_Tp(0), __x.real()), __x.imag());
1215 return complex<_Tp>(__x.imag(), __x.imag());1288 return complex<_Tp>(__x.imag(), __x.imag());
1216 }1289 }
1217 if (__libcpp_isnan_or_builtin(__x.real()))1290 if (std::__constexpr_isnan(__x.real()))
1218 {1291 {
1219 return complex<_Tp>(__x.real(), __x.real());1292 return complex<_Tp>(__x.real(), __x.real());
1220 }1293 }
1221 if (__libcpp_isinf_or_builtin(__x.real()))1294 if (std::__constexpr_isinf(__x.real()))
1222 {1295 {
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()));
1224 }1297 }
1225 if (abs(__x.real()) == _Tp(1) && __x.imag() == _Tp(0))1298 if (std::abs(__x.real()) == _Tp(1) && __x.imag() == _Tp(0))
1226 {1299 {
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()));
1228 }1301 }
1229 complex<_Tp> __z = log((_Tp(1) + __x) / (_Tp(1) - __x)) / _Tp(2);1302 complex<_Tp> __z = std::log((_Tp(1) + __x) / (_Tp(1) - __x)) / _Tp(2);
1230 return complex<_Tp>(copysign(__z.real(), __x.real()), copysign(__z.imag(), __x.imag()));1303 return complex<_Tp>(std::copysign(__z.real(), __x.real()), std::copysign(__z.imag(), __x.imag()));
1231}1304}
12321305
1233// sinh1306// sinh
12341307
1235template<class _Tp>1308template<class _Tp>
1236complex<_Tp>1309_LIBCPP_HIDE_FROM_ABI complex<_Tp>
1237sinh(const complex<_Tp>& __x)1310sinh(const complex<_Tp>& __x)
1238{1311{
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()))
1240 return complex<_Tp>(__x.real(), _Tp(NAN));1313 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()))
1242 return complex<_Tp>(__x.real(), _Tp(NAN));1315 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()))
1244 return __x;1317 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()));
1246}1319}
12471320
1248// cosh1321// cosh
12491322
1250template<class _Tp>1323template<class _Tp>
1251complex<_Tp>1324_LIBCPP_HIDE_FROM_ABI complex<_Tp>
1252cosh(const complex<_Tp>& __x)1325cosh(const complex<_Tp>& __x)
1253{1326{
1254 if (__libcpp_isinf_or_builtin(__x.real()) && !__libcpp_isfinite_or_builtin(__x.imag()))1327 if (std::__constexpr_isinf(__x.real()) && !std::__constexpr_isfinite(__x.imag()))
1255 return complex<_Tp>(abs(__x.real()), _Tp(NAN));1328 return complex<_Tp>(std::abs(__x.real()), _Tp(NAN));
1256 if (__x.real() == 0 && !__libcpp_isfinite_or_builtin(__x.imag()))1329 if (__x.real() == 0 && !std::__constexpr_isfinite(__x.imag()))
1257 return complex<_Tp>(_Tp(NAN), __x.real());1330 return complex<_Tp>(_Tp(NAN), __x.real());
1258 if (__x.real() == 0 && __x.imag() == 0)1331 if (__x.real() == 0 && __x.imag() == 0)
1259 return complex<_Tp>(_Tp(1), __x.imag());1332 return complex<_Tp>(_Tp(1), __x.imag());
1260 if (__x.imag() == 0 && !__libcpp_isfinite_or_builtin(__x.real()))1333 if (__x.imag() == 0 && !std::__constexpr_isfinite(__x.real()))
1261 return complex<_Tp>(abs(__x.real()), __x.imag());1334 return complex<_Tp>(std::abs(__x.real()), __x.imag());
1262 return complex<_Tp>(cosh(__x.real()) * cos(__x.imag()), sinh(__x.real()) * sin(__x.imag()));1335 return complex<_Tp>(std::cosh(__x.real()) * std::cos(__x.imag()), std::sinh(__x.real()) * std::sin(__x.imag()));
1263}1336}
12641337
1265// tanh1338// tanh
12661339
1267template<class _Tp>1340template<class _Tp>
1268complex<_Tp>1341_LIBCPP_HIDE_FROM_ABI complex<_Tp>
1269tanh(const complex<_Tp>& __x)1342tanh(const complex<_Tp>& __x)
1270{1343{
1271 if (__libcpp_isinf_or_builtin(__x.real()))1344 if (std::__constexpr_isinf(__x.real()))
1272 {1345 {
1273 if (!__libcpp_isfinite_or_builtin(__x.imag()))1346 if (!std::__constexpr_isfinite(__x.imag()))
1274 return complex<_Tp>(copysign(_Tp(1), __x.real()), _Tp(0));1347 return complex<_Tp>(std::copysign(_Tp(1), __x.real()), _Tp(0));
1275 return complex<_Tp>(copysign(_Tp(1), __x.real()), copysign(_Tp(0), sin(_Tp(2) * __x.imag())));1348 return complex<_Tp>(std::copysign(_Tp(1), __x.real()), std::copysign(_Tp(0), std::sin(_Tp(2) * __x.imag())));
1276 }1349 }
1277 if (__libcpp_isnan_or_builtin(__x.real()) && __x.imag() == 0)1350 if (std::__constexpr_isnan(__x.real()) && __x.imag() == 0)
1278 return __x;1351 return __x;
1279 _Tp __2r(_Tp(2) * __x.real());1352 _Tp __2r(_Tp(2) * __x.real());
1280 _Tp __2i(_Tp(2) * __x.imag());1353 _Tp __2i(_Tp(2) * __x.imag());
1281 _Tp __d(cosh(__2r) + cos(__2i));1354 _Tp __d(std::cosh(__2r) + std::cos(__2i));
1282 _Tp __2rsh(sinh(__2r));1355 _Tp __2rsh(std::sinh(__2r));
1283 if (__libcpp_isinf_or_builtin(__2rsh) && __libcpp_isinf_or_builtin(__d))1356 if (std::__constexpr_isinf(__2rsh) && std::__constexpr_isinf(__d))
1284 return complex<_Tp>(__2rsh > _Tp(0) ? _Tp(1) : _Tp(-1),1357 return complex<_Tp>(__2rsh > _Tp(0) ? _Tp(1) : _Tp(-1),
1285 __2i > _Tp(0) ? _Tp(0) : _Tp(-0.));1358 __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);
1287}1360}
12881361
1289// asin1362// asin
12901363
1291template<class _Tp>1364template<class _Tp>
1292complex<_Tp>1365_LIBCPP_HIDE_FROM_ABI complex<_Tp>
1293asin(const complex<_Tp>& __x)1366asin(const complex<_Tp>& __x)
1294{1367{
1295 complex<_Tp> __z = asinh(complex<_Tp>(-__x.imag(), __x.real()));1368 complex<_Tp> __z = std::asinh(complex<_Tp>(-__x.imag(), __x.real()));
1296 return complex<_Tp>(__z.imag(), -__z.real());1369 return complex<_Tp>(__z.imag(), -__z.real());
1297}1370}
12981371
1299// acos1372// acos
13001373
1301template<class _Tp>1374template<class _Tp>
1302complex<_Tp>1375_LIBCPP_HIDE_FROM_ABI complex<_Tp>
1303acos(const complex<_Tp>& __x)1376acos(const complex<_Tp>& __x)
1304{1377{
1305 const _Tp __pi(atan2(+0., -0.));1378 const _Tp __pi(atan2(+0., -0.));
1306 if (__libcpp_isinf_or_builtin(__x.real()))1379 if (std::__constexpr_isinf(__x.real()))
1307 {1380 {
1308 if (__libcpp_isnan_or_builtin(__x.imag()))1381 if (std::__constexpr_isnan(__x.imag()))
1309 return complex<_Tp>(__x.imag(), __x.real());1382 return complex<_Tp>(__x.imag(), __x.real());
1310 if (__libcpp_isinf_or_builtin(__x.imag()))1383 if (std::__constexpr_isinf(__x.imag()))
1311 {1384 {
1312 if (__x.real() < _Tp(0))1385 if (__x.real() < _Tp(0))
1313 return complex<_Tp>(_Tp(0.75) * __pi, -__x.imag());1386 return complex<_Tp>(_Tp(0.75) * __pi, -__x.imag());
1314 return complex<_Tp>(_Tp(0.25) * __pi, -__x.imag());1387 return complex<_Tp>(_Tp(0.25) * __pi, -__x.imag());
1315 }1388 }
1316 if (__x.real() < _Tp(0))1389 if (__x.real() < _Tp(0))
1317 return complex<_Tp>(__pi, signbit(__x.imag()) ? -__x.real() : __x.real());1390 return complex<_Tp>(__pi, std::signbit(__x.imag()) ? -__x.real() : __x.real());
1318 return complex<_Tp>(_Tp(0), signbit(__x.imag()) ? __x.real() : -__x.real());1391 return complex<_Tp>(_Tp(0), std::signbit(__x.imag()) ? __x.real() : -__x.real());
1319 }1392 }
1320 if (__libcpp_isnan_or_builtin(__x.real()))1393 if (std::__constexpr_isnan(__x.real()))
1321 {1394 {
1322 if (__libcpp_isinf_or_builtin(__x.imag()))1395 if (std::__constexpr_isinf(__x.imag()))
1323 return complex<_Tp>(__x.real(), -__x.imag());1396 return complex<_Tp>(__x.real(), -__x.imag());
1324 return complex<_Tp>(__x.real(), __x.real());1397 return complex<_Tp>(__x.real(), __x.real());
1325 }1398 }
1326 if (__libcpp_isinf_or_builtin(__x.imag()))1399 if (std::__constexpr_isinf(__x.imag()))
1327 return complex<_Tp>(__pi/_Tp(2), -__x.imag());1400 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())))
1329 return complex<_Tp>(__pi/_Tp(2), -__x.imag());1402 return complex<_Tp>(__pi/_Tp(2), -__x.imag());
1330 complex<_Tp> __z = log(__x + sqrt(__sqr(__x) - _Tp(1)));1403 complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) - _Tp(1)));
1331 if (signbit(__x.imag()))1404 if (std::signbit(__x.imag()))
1332 return complex<_Tp>(abs(__z.imag()), abs(__z.real()));1405 return complex<_Tp>(std::abs(__z.imag()), std::abs(__z.real()));
1333 return complex<_Tp>(abs(__z.imag()), -abs(__z.real()));1406 return complex<_Tp>(std::abs(__z.imag()), -std::abs(__z.real()));
1334}1407}
13351408
1336// atan1409// atan
13371410
1338template<class _Tp>1411template<class _Tp>
1339complex<_Tp>1412_LIBCPP_HIDE_FROM_ABI complex<_Tp>
1340atan(const complex<_Tp>& __x)1413atan(const complex<_Tp>& __x)
1341{1414{
1342 complex<_Tp> __z = atanh(complex<_Tp>(-__x.imag(), __x.real()));1415 complex<_Tp> __z = std::atanh(complex<_Tp>(-__x.imag(), __x.real()));
1343 return complex<_Tp>(__z.imag(), -__z.real());1416 return complex<_Tp>(__z.imag(), -__z.real());
1344}1417}
13451418
1346// sin1419// sin
13471420
1348template<class _Tp>1421template<class _Tp>
1349complex<_Tp>1422_LIBCPP_HIDE_FROM_ABI complex<_Tp>
1350sin(const complex<_Tp>& __x)1423sin(const complex<_Tp>& __x)
1351{1424{
1352 complex<_Tp> __z = sinh(complex<_Tp>(-__x.imag(), __x.real()));1425 complex<_Tp> __z = std::sinh(complex<_Tp>(-__x.imag(), __x.real()));
1353 return complex<_Tp>(__z.imag(), -__z.real());1426 return complex<_Tp>(__z.imag(), -__z.real());
1354}1427}
13551428
...@@ -1360,26 +1433,27 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -1360,26 +1433,27 @@ inline _LIBCPP_INLINE_VISIBILITY
1360complex<_Tp>1433complex<_Tp>
1361cos(const complex<_Tp>& __x)1434cos(const complex<_Tp>& __x)
1362{1435{
1363 return cosh(complex<_Tp>(-__x.imag(), __x.real()));1436 return std::cosh(complex<_Tp>(-__x.imag(), __x.real()));
1364}1437}
13651438
1366// tan1439// tan
13671440
1368template<class _Tp>1441template<class _Tp>
1369complex<_Tp>1442_LIBCPP_HIDE_FROM_ABI complex<_Tp>
1370tan(const complex<_Tp>& __x)1443tan(const complex<_Tp>& __x)
1371{1444{
1372 complex<_Tp> __z = tanh(complex<_Tp>(-__x.imag(), __x.real()));1445 complex<_Tp> __z = std::tanh(complex<_Tp>(-__x.imag(), __x.real()));
1373 return complex<_Tp>(__z.imag(), -__z.real());1446 return complex<_Tp>(__z.imag(), -__z.real());
1374}1447}
13751448
1449#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
1376template<class _Tp, class _CharT, class _Traits>1450template<class _Tp, class _CharT, class _Traits>
1377basic_istream<_CharT, _Traits>&1451_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
1378operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)1452operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
1379{1453{
1380 if (__is.good())1454 if (__is.good())
1381 {1455 {
1382 ws(__is);1456 std::ws(__is);
1383 if (__is.peek() == _CharT('('))1457 if (__is.peek() == _CharT('('))
1384 {1458 {
1385 __is.get();1459 __is.get();
...@@ -1387,7 +1461,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)...@@ -1387,7 +1461,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
1387 __is >> __r;1461 __is >> __r;
1388 if (!__is.fail())1462 if (!__is.fail())
1389 {1463 {
1390 ws(__is);1464 std::ws(__is);
1391 _CharT __c = __is.peek();1465 _CharT __c = __is.peek();
1392 if (__c == _CharT(','))1466 if (__c == _CharT(','))
1393 {1467 {
...@@ -1396,7 +1470,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)...@@ -1396,7 +1470,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
1396 __is >> __i;1470 __is >> __i;
1397 if (!__is.fail())1471 if (!__is.fail())
1398 {1472 {
1399 ws(__is);1473 std::ws(__is);
1400 __c = __is.peek();1474 __c = __is.peek();
1401 if (__c == _CharT(')'))1475 if (__c == _CharT(')'))
1402 {1476 {
...@@ -1435,9 +1509,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)...@@ -1435,9 +1509,8 @@ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
1435 return __is;1509 return __is;
1436}1510}
14371511
1438#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
1439template<class _Tp, class _CharT, class _Traits>1512template<class _Tp, class _CharT, class _Traits>
1440basic_ostream<_CharT, _Traits>&1513_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
1441operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x)1514operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x)
1442{1515{
1443 basic_ostringstream<_CharT, _Traits> __s;1516 basic_ostringstream<_CharT, _Traits> __s;
...@@ -1455,34 +1528,34 @@ inline namespace literals...@@ -1455,34 +1528,34 @@ inline namespace literals
1455{1528{
1456 inline namespace complex_literals1529 inline namespace complex_literals
1457 {1530 {
1458 constexpr complex<long double> operator""il(long double __im)1531 _LIBCPP_HIDE_FROM_ABI constexpr complex<long double> operator""il(long double __im)
1459 {1532 {
1460 return { 0.0l, __im };1533 return { 0.0l, __im };
1461 }1534 }
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)
1464 {1537 {
1465 return { 0.0l, static_cast<long double>(__im) };1538 return { 0.0l, static_cast<long double>(__im) };
1466 }1539 }
14671540
14681541
1469 constexpr complex<double> operator""i(long double __im)1542 _LIBCPP_HIDE_FROM_ABI constexpr complex<double> operator""i(long double __im)
1470 {1543 {
1471 return { 0.0, static_cast<double>(__im) };1544 return { 0.0, static_cast<double>(__im) };
1472 }1545 }
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)
1475 {1548 {
1476 return { 0.0, static_cast<double>(__im) };1549 return { 0.0, static_cast<double>(__im) };
1477 }1550 }
14781551
14791552
1480 constexpr complex<float> operator""if(long double __im)1553 _LIBCPP_HIDE_FROM_ABI constexpr complex<float> operator""if(long double __im)
1481 {1554 {
1482 return { 0.0f, static_cast<float>(__im) };1555 return { 0.0f, static_cast<float>(__im) };
1483 }1556 }
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)
1486 {1559 {
1487 return { 0.0f, static_cast<float>(__im) };1560 return { 0.0f, static_cast<float>(__im) };
1488 }1561 }
lib/libcxx/include/complex.h+4-8
...@@ -24,13 +24,9 @@...@@ -24,13 +24,9 @@
24#endif24#endif
2525
26#ifdef __cplusplus26#ifdef __cplusplus
2727# include <ccomplex>
28#include <ccomplex>28#elif __has_include_next(<complex.h>)
2929# include_next <complex.h>
30#else // __cplusplus30#endif
31
32#include_next <complex.h>
33
34#endif // __cplusplus
3531
36#endif // _LIBCPP_COMPLEX_H32#endif // _LIBCPP_COMPLEX_H
lib/libcxx/include/concepts+4
...@@ -155,6 +155,10 @@ namespace std {...@@ -155,6 +155,10 @@ namespace std {
155#include <__config>155#include <__config>
156#include <version>156#include <version>
157157
158#if _LIBCPP_STD_VER <= 20 && !defined(_LIPCPP_REMOVE_TRANSITIVE_INCLUDES)
159# include <type_traits>
160#endif
161
158#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)162#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
159# pragma GCC system_header163# pragma GCC system_header
160#endif164#endif
lib/libcxx/include/condition_variable+7-1
...@@ -108,8 +108,9 @@ public:...@@ -108,8 +108,9 @@ public:
108108
109#include <__assert> // all public C++ headers provide the assertion handler109#include <__assert> // all public C++ headers provide the assertion handler
110#include <__config>110#include <__config>
111#include <__memory/shared_ptr.h>
112#include <__memory/unique_ptr.h>
111#include <__mutex_base>113#include <__mutex_base>
112#include <memory>
113#include <version>114#include <version>
114115
115#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)116#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -267,4 +268,9 @@ _LIBCPP_END_NAMESPACE_STD...@@ -267,4 +268,9 @@ _LIBCPP_END_NAMESPACE_STD
267268
268#endif // !_LIBCPP_HAS_NO_THREADS269#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
270#endif // _LIBCPP_CONDITION_VARIABLE276#endif // _LIBCPP_CONDITION_VARIABLE
lib/libcxx/include/coroutine+7-4
...@@ -46,15 +46,18 @@ struct suspend_always;...@@ -46,15 +46,18 @@ struct suspend_always;
46#include <__coroutine/trivial_awaitables.h>46#include <__coroutine/trivial_awaitables.h>
47#include <version>47#include <version>
4848
49#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
50# include <iosfwd>
51#endif
52
53// standard-mandated includes49// standard-mandated includes
50
51// [coroutine.syn]
54#include <compare>52#include <compare>
5553
56#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER54#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
57# pragma GCC system_header55# pragma GCC system_header
58#endif56#endif
5957
58#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
59# include <iosfwd>
60# include <type_traits>
61#endif
62
60#endif // _LIBCPP_COROUTINE63#endif // _LIBCPP_COROUTINE
lib/libcxx/include/csetjmp+9
...@@ -32,8 +32,17 @@ void longjmp(jmp_buf env, int val);...@@ -32,8 +32,17 @@ void longjmp(jmp_buf env, int val);
3232
33#include <__assert> // all public C++ headers provide the assertion handler33#include <__assert> // all public C++ headers provide the assertion handler
34#include <__config>34#include <__config>
35
35#include <setjmp.h>36#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
37#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)46#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
38# pragma GCC system_header47# pragma GCC system_header
39#endif48#endif
lib/libcxx/include/csignal+5-1
...@@ -42,8 +42,12 @@ int raise(int sig);...@@ -42,8 +42,12 @@ int raise(int sig);
42#include <__assert> // all public C++ headers provide the assertion handler42#include <__assert> // all public C++ headers provide the assertion handler
43#include <__config>43#include <__config>
4444
45// <signal.h> is not provided by libc++
45#if __has_include(<signal.h>)46#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
47#endif51#endif
4852
49#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)53#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/cstdarg+8-1
...@@ -33,7 +33,14 @@ Types:...@@ -33,7 +33,14 @@ Types:
3333
34#include <__assert> // all public C++ headers provide the assertion handler34#include <__assert> // all public C++ headers provide the assertion handler
35#include <__config>35#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
38#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)45#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
39# pragma GCC system_header46# pragma GCC system_header
lib/libcxx/include/cstddef+22-13
...@@ -38,9 +38,18 @@ Types:...@@ -38,9 +38,18 @@ Types:
38#include <__type_traits/enable_if.h>38#include <__type_traits/enable_if.h>
39#include <__type_traits/integral_constant.h>39#include <__type_traits/integral_constant.h>
40#include <__type_traits/is_integral.h>40#include <__type_traits/is_integral.h>
41#include <stddef.h>
42#include <version>41#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
44#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)53#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
45# pragma GCC system_header54# pragma GCC system_header
46#endif55#endif
...@@ -62,7 +71,7 @@ namespace std // purposefully not versioned...@@ -62,7 +71,7 @@ namespace std // purposefully not versioned
62{71{
63enum class byte : unsigned char {};72enum class byte : unsigned char {};
6473
65constexpr byte operator| (byte __lhs, byte __rhs) noexcept74_LIBCPP_HIDE_FROM_ABI constexpr byte operator| (byte __lhs, byte __rhs) noexcept
66{75{
67 return static_cast<byte>(76 return static_cast<byte>(
68 static_cast<unsigned char>(77 static_cast<unsigned char>(
...@@ -70,10 +79,10 @@ constexpr byte operator| (byte __lhs, byte __rhs) noexcept...@@ -70,10 +79,10 @@ constexpr byte operator| (byte __lhs, byte __rhs) noexcept
70 ));79 ));
71}80}
7281
73constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept82_LIBCPP_HIDE_FROM_ABI constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept
74{ return __lhs = __lhs | __rhs; }83{ return __lhs = __lhs | __rhs; }
7584
76constexpr byte operator& (byte __lhs, byte __rhs) noexcept85_LIBCPP_HIDE_FROM_ABI constexpr byte operator& (byte __lhs, byte __rhs) noexcept
77{86{
78 return static_cast<byte>(87 return static_cast<byte>(
79 static_cast<unsigned char>(88 static_cast<unsigned char>(
...@@ -81,10 +90,10 @@ constexpr byte operator& (byte __lhs, byte __rhs) noexcept...@@ -81,10 +90,10 @@ constexpr byte operator& (byte __lhs, byte __rhs) noexcept
81 ));90 ));
82}91}
8392
84constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept93_LIBCPP_HIDE_FROM_ABI constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept
85{ return __lhs = __lhs & __rhs; }94{ return __lhs = __lhs & __rhs; }
8695
87constexpr byte operator^ (byte __lhs, byte __rhs) noexcept96_LIBCPP_HIDE_FROM_ABI constexpr byte operator^ (byte __lhs, byte __rhs) noexcept
88{97{
89 return static_cast<byte>(98 return static_cast<byte>(
90 static_cast<unsigned char>(99 static_cast<unsigned char>(
...@@ -92,10 +101,10 @@ constexpr byte operator^ (byte __lhs, byte __rhs) noexcept...@@ -92,10 +101,10 @@ constexpr byte operator^ (byte __lhs, byte __rhs) noexcept
92 ));101 ));
93}102}
94103
95constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept104_LIBCPP_HIDE_FROM_ABI constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept
96{ return __lhs = __lhs ^ __rhs; }105{ return __lhs = __lhs ^ __rhs; }
97106
98constexpr byte operator~ (byte __b) noexcept107_LIBCPP_HIDE_FROM_ABI constexpr byte operator~ (byte __b) noexcept
99{108{
100 return static_cast<byte>(109 return static_cast<byte>(
101 static_cast<unsigned char>(110 static_cast<unsigned char>(
...@@ -107,27 +116,27 @@ template <class _Tp>...@@ -107,27 +116,27 @@ template <class _Tp>
107using _EnableByteOverload = __enable_if_t<is_integral<_Tp>::value, byte>;116using _EnableByteOverload = __enable_if_t<is_integral<_Tp>::value, byte>;
108117
109template <class _Integer>118template <class _Integer>
110 constexpr _EnableByteOverload<_Integer> &119_LIBCPP_HIDE_FROM_ABI constexpr _EnableByteOverload<_Integer> &
111 operator<<=(byte& __lhs, _Integer __shift) noexcept120 operator<<=(byte& __lhs, _Integer __shift) noexcept
112 { return __lhs = __lhs << __shift; }121 { return __lhs = __lhs << __shift; }
113122
114template <class _Integer>123template <class _Integer>
115 constexpr _EnableByteOverload<_Integer>124_LIBCPP_HIDE_FROM_ABI constexpr _EnableByteOverload<_Integer>
116 operator<< (byte __lhs, _Integer __shift) noexcept125 operator<< (byte __lhs, _Integer __shift) noexcept
117 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); }126 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); }
118127
119template <class _Integer>128template <class _Integer>
120 constexpr _EnableByteOverload<_Integer> &129_LIBCPP_HIDE_FROM_ABI constexpr _EnableByteOverload<_Integer> &
121 operator>>=(byte& __lhs, _Integer __shift) noexcept130 operator>>=(byte& __lhs, _Integer __shift) noexcept
122 { return __lhs = __lhs >> __shift; }131 { return __lhs = __lhs >> __shift; }
123132
124template <class _Integer>133template <class _Integer>
125 constexpr _EnableByteOverload<_Integer>134_LIBCPP_HIDE_FROM_ABI constexpr _EnableByteOverload<_Integer>
126 operator>> (byte __lhs, _Integer __shift) noexcept135 operator>> (byte __lhs, _Integer __shift) noexcept
127 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); }136 { return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); }
128137
129template <class _Integer, class = _EnableByteOverload<_Integer> >138template <class _Integer, class = _EnableByteOverload<_Integer> >
130 _LIBCPP_NODISCARD_EXT constexpr _Integer139_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Integer
131 to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); }140 to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); }
132141
133} // namespace std142} // namespace std
lib/libcxx/include/cstdint+9
...@@ -142,8 +142,17 @@ Types:...@@ -142,8 +142,17 @@ Types:
142142
143#include <__assert> // all public C++ headers provide the assertion handler143#include <__assert> // all public C++ headers provide the assertion handler
144#include <__config>144#include <__config>
145
145#include <stdint.h>146#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
147#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)156#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
148# pragma GCC system_header157# pragma GCC system_header
149#endif158#endif
lib/libcxx/include/cstdio+9
...@@ -97,8 +97,17 @@ void perror(const char* s);...@@ -97,8 +97,17 @@ void perror(const char* s);
9797
98#include <__assert> // all public C++ headers provide the assertion handler98#include <__assert> // all public C++ headers provide the assertion handler
99#include <__config>99#include <__config>
100
100#include <stdio.h>101#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
102#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)111#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
103# pragma GCC system_header112# pragma GCC system_header
104#endif113#endif
lib/libcxx/include/cstdlib+9
...@@ -83,8 +83,17 @@ void *aligned_alloc(size_t alignment, size_t size); // C11...@@ -83,8 +83,17 @@ void *aligned_alloc(size_t alignment, size_t size); // C11
8383
84#include <__assert> // all public C++ headers provide the assertion handler84#include <__assert> // all public C++ headers provide the assertion handler
85#include <__config>85#include <__config>
86
86#include <stdlib.h>87#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
88#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)97#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
89# pragma GCC system_header98# pragma GCC system_header
90#endif99#endif
lib/libcxx/include/cstring+57
...@@ -58,8 +58,18 @@ size_t strlen(const char* s);...@@ -58,8 +58,18 @@ size_t strlen(const char* s);
5858
59#include <__assert> // all public C++ headers provide the assertion handler59#include <__assert> // all public C++ headers provide the assertion handler
60#include <__config>60#include <__config>
61#include <__type_traits/is_constant_evaluated.h>
62
61#include <string.h>63#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
63#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)73#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
64# pragma GCC system_header74# pragma GCC system_header
65#endif75#endif
...@@ -90,6 +100,53 @@ using ::memset _LIBCPP_USING_IF_EXISTS;...@@ -90,6 +100,53 @@ using ::memset _LIBCPP_USING_IF_EXISTS;
90using ::strerror _LIBCPP_USING_IF_EXISTS;100using ::strerror _LIBCPP_USING_IF_EXISTS;
91using ::strlen _LIBCPP_USING_IF_EXISTS;101using ::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
93_LIBCPP_END_NAMESPACE_STD150_LIBCPP_END_NAMESPACE_STD
94151
95#endif // _LIBCPP_CSTRING152#endif // _LIBCPP_CSTRING
lib/libcxx/include/ctime+8-1
...@@ -47,7 +47,14 @@ int timespec_get( struct timespec *ts, int base); // C++17...@@ -47,7 +47,14 @@ int timespec_get( struct timespec *ts, int base); // C++17
4747
48#include <__assert> // all public C++ headers provide the assertion handler48#include <__assert> // all public C++ headers provide the assertion handler
49#include <__config>49#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
52#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)59#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
53# pragma GCC system_header60# pragma GCC system_header
lib/libcxx/include/ctype.h+3-1
...@@ -35,7 +35,9 @@ int toupper(int c);...@@ -35,7 +35,9 @@ int toupper(int c);
35# pragma GCC system_header35# pragma GCC system_header
36#endif36#endif
3737
38#include_next <ctype.h>38#if __has_include_next(<ctype.h>)
39# include_next <ctype.h>
40#endif
3941
40#ifdef __cplusplus42#ifdef __cplusplus
4143
lib/libcxx/include/cuchar+15
...@@ -25,6 +25,8 @@ Types:...@@ -25,6 +25,8 @@ Types:
25 mbstate_t25 mbstate_t
26 size_t26 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
28size_t mbrtoc16(char16_t* pc16, const char* s, size_t n, mbstate_t* ps);30size_t mbrtoc16(char16_t* pc16, const char* s, size_t n, mbstate_t* ps);
29size_t c16rtomb(char* s, char16_t c16, mbstate_t* ps);31size_t c16rtomb(char* s, char16_t c16, mbstate_t* ps);
30size_t mbrtoc32(char32_t* pc32, const char* s, size_t n, mbstate_t* ps);32size_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);...@@ -36,8 +38,17 @@ size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps);
3638
37#include <__assert> // all public C++ headers provide the assertion handler39#include <__assert> // all public C++ headers provide the assertion handler
38#include <__config>40#include <__config>
41
39#include <uchar.h>42#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
41#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)52#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
42# pragma GCC system_header53# pragma GCC system_header
43#endif54#endif
...@@ -49,6 +60,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -49,6 +60,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
49using ::mbstate_t _LIBCPP_USING_IF_EXISTS;60using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
50using ::size_t _LIBCPP_USING_IF_EXISTS;61using ::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
52using ::mbrtoc16 _LIBCPP_USING_IF_EXISTS;67using ::mbrtoc16 _LIBCPP_USING_IF_EXISTS;
53using ::c16rtomb _LIBCPP_USING_IF_EXISTS;68using ::c16rtomb _LIBCPP_USING_IF_EXISTS;
54using ::mbrtoc32 _LIBCPP_USING_IF_EXISTS;69using ::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,...@@ -104,9 +104,19 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
104104
105#include <__assert> // all public C++ headers provide the assertion handler105#include <__assert> // all public C++ headers provide the assertion handler
106#include <__config>106#include <__config>
107#include <__type_traits/is_constant_evaluated.h>
107#include <cwctype>108#include <cwctype>
109
108#include <wchar.h>110#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
110#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)120#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
111# pragma GCC system_header121# pragma GCC system_header
112#endif122#endif
...@@ -180,6 +190,55 @@ using ::putwchar _LIBCPP_USING_IF_EXISTS;...@@ -180,6 +190,55 @@ using ::putwchar _LIBCPP_USING_IF_EXISTS;
180using ::vwprintf _LIBCPP_USING_IF_EXISTS;190using ::vwprintf _LIBCPP_USING_IF_EXISTS;
181using ::wprintf _LIBCPP_USING_IF_EXISTS;191using ::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
183_LIBCPP_END_NAMESPACE_STD242_LIBCPP_END_NAMESPACE_STD
184243
185#endif // _LIBCPP_CWCHAR244#endif // _LIBCPP_CWCHAR
lib/libcxx/include/cwctype+9
...@@ -52,8 +52,17 @@ wctrans_t wctrans(const char* property);...@@ -52,8 +52,17 @@ wctrans_t wctrans(const char* property);
52#include <__assert> // all public C++ headers provide the assertion handler52#include <__assert> // all public C++ headers provide the assertion handler
53#include <__config>53#include <__config>
54#include <cctype>54#include <cctype>
55
55#include <wctype.h>56#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
57#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)66#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
58# pragma GCC system_header67# pragma GCC system_header
59#endif68#endif
lib/libcxx/include/deque+757-1374
...@@ -176,7 +176,14 @@ template <class T, class Allocator, class Predicate>...@@ -176,7 +176,14 @@ template <class T, class Allocator, class Predicate>
176#include <__iterator/next.h>176#include <__iterator/next.h>
177#include <__iterator/prev.h>177#include <__iterator/prev.h>
178#include <__iterator/reverse_iterator.h>178#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>
179#include <__split_buffer>185#include <__split_buffer>
186#include <__type_traits/is_allocator.h>
180#include <__utility/forward.h>187#include <__utility/forward.h>
181#include <__utility/move.h>188#include <__utility/move.h>
182#include <__utility/swap.h>189#include <__utility/swap.h>
...@@ -185,12 +192,6 @@ template <class T, class Allocator, class Predicate>...@@ -185,12 +192,6 @@ template <class T, class Allocator, class Predicate>
185#include <type_traits>192#include <type_traits>
186#include <version>193#include <version>
187194
188#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
189# include <algorithm>
190# include <functional>
191# include <iterator>
192#endif
193
194// standard-mandated includes195// standard-mandated includes
195196
196// [iterator.range]197// [iterator.range]
...@@ -214,101 +215,8 @@ _LIBCPP_PUSH_MACROS...@@ -214,101 +215,8 @@ _LIBCPP_PUSH_MACROS
214215
215_LIBCPP_BEGIN_NAMESPACE_STD216_LIBCPP_BEGIN_NAMESPACE_STD
216217
217template <class _Tp, class _Allocator> class __deque_base;
218template <class _Tp, class _Allocator = allocator<_Tp> > class _LIBCPP_TEMPLATE_VIS deque;218template <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
312template <class _ValueType, class _DiffType>220template <class _ValueType, class _DiffType>
313struct __deque_block_size {221struct __deque_block_size {
314 static const _DiffType value = sizeof(_ValueType) < 256 ? 4096 / sizeof(_ValueType) : 16;222 static const _DiffType value = sizeof(_ValueType) < 256 ? 4096 / sizeof(_ValueType) : 16;
...@@ -340,22 +248,22 @@ public:...@@ -340,22 +248,22 @@ public:
340 typedef random_access_iterator_tag iterator_category;248 typedef random_access_iterator_tag iterator_category;
341 typedef _Reference reference;249 typedef _Reference reference;
342250
343 _LIBCPP_INLINE_VISIBILITY __deque_iterator() _NOEXCEPT251 _LIBCPP_HIDE_FROM_ABI __deque_iterator() _NOEXCEPT
344#if _LIBCPP_STD_VER > 11252#if _LIBCPP_STD_VER > 11
345 : __m_iter_(nullptr), __ptr_(nullptr)253 : __m_iter_(nullptr), __ptr_(nullptr)
346#endif254#endif
347 {}255 {}
348256
349 template <class _Pp, class _Rp, class _MP>257 template <class _Pp, class _Rp, class _MP>
350 _LIBCPP_INLINE_VISIBILITY258 _LIBCPP_HIDE_FROM_ABI
351 __deque_iterator(const __deque_iterator<value_type, _Pp, _Rp, _MP, difference_type, _BS>& __it,259 __deque_iterator(const __deque_iterator<value_type, _Pp, _Rp, _MP, difference_type, _BS>& __it,
352 typename enable_if<is_convertible<_Pp, pointer>::value>::type* = 0) _NOEXCEPT260 typename enable_if<is_convertible<_Pp, pointer>::value>::type* = 0) _NOEXCEPT
353 : __m_iter_(__it.__m_iter_), __ptr_(__it.__ptr_) {}261 : __m_iter_(__it.__m_iter_), __ptr_(__it.__ptr_) {}
354262
355 _LIBCPP_INLINE_VISIBILITY reference operator*() const {return *__ptr_;}263 _LIBCPP_HIDE_FROM_ABI reference operator*() const {return *__ptr_;}
356 _LIBCPP_INLINE_VISIBILITY pointer 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++()
359 {267 {
360 if (++__ptr_ - *__m_iter_ == __block_size)268 if (++__ptr_ - *__m_iter_ == __block_size)
361 {269 {
...@@ -365,14 +273,14 @@ public:...@@ -365,14 +273,14 @@ public:
365 return *this;273 return *this;
366 }274 }
367275
368 _LIBCPP_INLINE_VISIBILITY __deque_iterator operator++(int)276 _LIBCPP_HIDE_FROM_ABI __deque_iterator operator++(int)
369 {277 {
370 __deque_iterator __tmp = *this;278 __deque_iterator __tmp = *this;
371 ++(*this);279 ++(*this);
372 return __tmp;280 return __tmp;
373 }281 }
374282
375 _LIBCPP_INLINE_VISIBILITY __deque_iterator& operator--()283 _LIBCPP_HIDE_FROM_ABI __deque_iterator& operator--()
376 {284 {
377 if (__ptr_ == *__m_iter_)285 if (__ptr_ == *__m_iter_)
378 {286 {
...@@ -383,14 +291,14 @@ public:...@@ -383,14 +291,14 @@ public:
383 return *this;291 return *this;
384 }292 }
385293
386 _LIBCPP_INLINE_VISIBILITY __deque_iterator operator--(int)294 _LIBCPP_HIDE_FROM_ABI __deque_iterator operator--(int)
387 {295 {
388 __deque_iterator __tmp = *this;296 __deque_iterator __tmp = *this;
389 --(*this);297 --(*this);
390 return __tmp;298 return __tmp;
391 }299 }
392300
393 _LIBCPP_INLINE_VISIBILITY __deque_iterator& operator+=(difference_type __n)301 _LIBCPP_HIDE_FROM_ABI __deque_iterator& operator+=(difference_type __n)
394 {302 {
395 if (__n != 0)303 if (__n != 0)
396 {304 {
...@@ -410,30 +318,30 @@ public:...@@ -410,30 +318,30 @@ public:
410 return *this;318 return *this;
411 }319 }
412320
413 _LIBCPP_INLINE_VISIBILITY __deque_iterator& operator-=(difference_type __n)321 _LIBCPP_HIDE_FROM_ABI __deque_iterator& operator-=(difference_type __n)
414 {322 {
415 return *this += -__n;323 return *this += -__n;
416 }324 }
417325
418 _LIBCPP_INLINE_VISIBILITY __deque_iterator operator+(difference_type __n) const326 _LIBCPP_HIDE_FROM_ABI __deque_iterator operator+(difference_type __n) const
419 {327 {
420 __deque_iterator __t(*this);328 __deque_iterator __t(*this);
421 __t += __n;329 __t += __n;
422 return __t;330 return __t;
423 }331 }
424332
425 _LIBCPP_INLINE_VISIBILITY __deque_iterator operator-(difference_type __n) const333 _LIBCPP_HIDE_FROM_ABI __deque_iterator operator-(difference_type __n) const
426 {334 {
427 __deque_iterator __t(*this);335 __deque_iterator __t(*this);
428 __t -= __n;336 __t -= __n;
429 return __t;337 return __t;
430 }338 }
431339
432 _LIBCPP_INLINE_VISIBILITY340 _LIBCPP_HIDE_FROM_ABI
433 friend __deque_iterator operator+(difference_type __n, const __deque_iterator& __it)341 friend __deque_iterator operator+(difference_type __n, const __deque_iterator& __it)
434 {return __it + __n;}342 {return __it + __n;}
435343
436 _LIBCPP_INLINE_VISIBILITY344 _LIBCPP_HIDE_FROM_ABI
437 friend difference_type operator-(const __deque_iterator& __x, const __deque_iterator& __y)345 friend difference_type operator-(const __deque_iterator& __x, const __deque_iterator& __y)
438 {346 {
439 if (__x != __y)347 if (__x != __y)
...@@ -443,142 +351,72 @@ public:...@@ -443,142 +351,72 @@ public:
443 return 0;351 return 0;
444 }352 }
445353
446 _LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const354 _LIBCPP_HIDE_FROM_ABI reference operator[](difference_type __n) const
447 {return *(*this + __n);}355 {return *(*this + __n);}
448356
449 _LIBCPP_INLINE_VISIBILITY friend357 _LIBCPP_HIDE_FROM_ABI friend
450 bool operator==(const __deque_iterator& __x, const __deque_iterator& __y)358 bool operator==(const __deque_iterator& __x, const __deque_iterator& __y)
451 {return __x.__ptr_ == __y.__ptr_;}359 {return __x.__ptr_ == __y.__ptr_;}
452360
453 _LIBCPP_INLINE_VISIBILITY friend361 _LIBCPP_HIDE_FROM_ABI friend
454 bool operator!=(const __deque_iterator& __x, const __deque_iterator& __y)362 bool operator!=(const __deque_iterator& __x, const __deque_iterator& __y)
455 {return !(__x == __y);}363 {return !(__x == __y);}
456364
457 _LIBCPP_INLINE_VISIBILITY friend365 _LIBCPP_HIDE_FROM_ABI friend
458 bool operator<(const __deque_iterator& __x, const __deque_iterator& __y)366 bool operator<(const __deque_iterator& __x, const __deque_iterator& __y)
459 {return __x.__m_iter_ < __y.__m_iter_ ||367 {return __x.__m_iter_ < __y.__m_iter_ ||
460 (__x.__m_iter_ == __y.__m_iter_ && __x.__ptr_ < __y.__ptr_);}368 (__x.__m_iter_ == __y.__m_iter_ && __x.__ptr_ < __y.__ptr_);}
461369
462 _LIBCPP_INLINE_VISIBILITY friend370 _LIBCPP_HIDE_FROM_ABI friend
463 bool operator>(const __deque_iterator& __x, const __deque_iterator& __y)371 bool operator>(const __deque_iterator& __x, const __deque_iterator& __y)
464 {return __y < __x;}372 {return __y < __x;}
465373
466 _LIBCPP_INLINE_VISIBILITY friend374 _LIBCPP_HIDE_FROM_ABI friend
467 bool operator<=(const __deque_iterator& __x, const __deque_iterator& __y)375 bool operator<=(const __deque_iterator& __x, const __deque_iterator& __y)
468 {return !(__y < __x);}376 {return !(__y < __x);}
469377
470 _LIBCPP_INLINE_VISIBILITY friend378 _LIBCPP_HIDE_FROM_ABI friend
471 bool operator>=(const __deque_iterator& __x, const __deque_iterator& __y)379 bool operator>=(const __deque_iterator& __x, const __deque_iterator& __y)
472 {return !(__x < __y);}380 {return !(__x < __y);}
473381
474private:382private:
475 _LIBCPP_INLINE_VISIBILITY explicit __deque_iterator(__map_iterator __m, pointer __p) _NOEXCEPT383 _LIBCPP_HIDE_FROM_ABI explicit __deque_iterator(__map_iterator __m, pointer __p) _NOEXCEPT
476 : __m_iter_(__m), __ptr_(__p) {}384 : __m_iter_(__m), __ptr_(__p) {}
477385
478 template <class _Tp, class _Ap> friend class __deque_base;
479 template <class _Tp, class _Ap> friend class _LIBCPP_TEMPLATE_VIS deque;386 template <class _Tp, class _Ap> friend class _LIBCPP_TEMPLATE_VIS deque;
480 template <class _Vp, class _Pp, class _Rp, class _MP, class _Dp, _Dp>387 template <class _Vp, class _Pp, class _Rp, class _MP, class _Dp, _Dp>
481 friend class _LIBCPP_TEMPLATE_VIS __deque_iterator;388 friend class _LIBCPP_TEMPLATE_VIS __deque_iterator;
482389
483 template <class _RAIter,390 template <class>
484 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>391 friend struct __segmented_iterator_traits;
485 friend392};
486 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>393
487 copy(_RAIter __f,394template <class _ValueType, class _Pointer, class _Reference, class _MapPointer, class _DiffType, _DiffType _BlockSize>
488 _RAIter __l,395struct __segmented_iterator_traits<
489 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,396 __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, _DiffType, _BlockSize> > {
490 typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*);397private:
491398 using _Iterator = __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, _DiffType, _BlockSize>;
492 template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,399
493 class _OutputIterator>400public:
494 friend401 using __is_segmented_iterator = true_type;
495 _OutputIterator402 using __segment_iterator = _MapPointer;
496 copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,403 using __local_iterator = _Pointer;
497 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,404
498 _OutputIterator __r);405 static _LIBCPP_HIDE_FROM_ABI __segment_iterator __segment(_Iterator __iter) { return __iter.__m_iter_; }
499406 static _LIBCPP_HIDE_FROM_ABI __local_iterator __local(_Iterator __iter) { return __iter.__ptr_; }
500 template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,407 static _LIBCPP_HIDE_FROM_ABI __local_iterator __begin(__segment_iterator __iter) { return *__iter; }
501 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>408
502 friend409 static _LIBCPP_HIDE_FROM_ABI __local_iterator __end(__segment_iterator __iter) {
503 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>410 return *__iter + _Iterator::__block_size;
504 copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,411 }
505 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,412
506 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r);413 static _LIBCPP_HIDE_FROM_ABI _Iterator __compose(__segment_iterator __segment, __local_iterator __local) {
507414 if (__local == __end(__segment)) {
508 template <class _RAIter,415 ++__segment;
509 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>416 return _Iterator(__segment, *__segment);
510 friend417 }
511 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>418 return _Iterator(__segment, __local);
512 copy_backward(_RAIter __f,419 }
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);
582};420};
583421
584template <class _ValueType, class _Pointer, class _Reference, class _MapPointer,422template <class _ValueType, class _Pointer, class _Reference, class _MapPointer,
...@@ -587,897 +425,329 @@ const _DiffType __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer,...@@ -587,897 +425,329 @@ const _DiffType __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer,
587 _DiffType, _BlockSize>::__block_size =425 _DiffType, _BlockSize>::__block_size =
588 __deque_block_size<_ValueType, _DiffType>::value;426 __deque_block_size<_ValueType, _DiffType>::value;
589427
590// copy428template <class _Tp, class _Allocator /*= allocator<_Tp>*/>
591429class _LIBCPP_TEMPLATE_VIS deque
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*)
599{430{
600 typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::difference_type difference_type;431public:
601 typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer;432 // types:
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}
621433
622template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,434 using value_type = _Tp;
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}
649435
650template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,436 static_assert((is_same<typename _Allocator::value_type, value_type>::value),
651 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>437 "Allocator::value_type must be same type as value_type");
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}
677438
678// copy_backward439 using allocator_type = _Allocator;
440 using __alloc_traits = allocator_traits<allocator_type>;
679441
680template <class _RAIter,442 using size_type = typename __alloc_traits::size_type;
681 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>443 using difference_type = typename __alloc_traits::difference_type;
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}
709444
710template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,445 using pointer = typename __alloc_traits::pointer;
711 class _OutputIterator>446 using const_pointer = typename __alloc_traits::const_pointer;
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}
737447
738template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,448 using __pointer_allocator = __rebind_alloc<__alloc_traits, pointer>;
739 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>449 using __const_pointer_allocator = __rebind_alloc<__alloc_traits, const_pointer>;
740__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>450 using __map = __split_buffer<pointer, __pointer_allocator>;
741copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,451 using __map_alloc_traits = allocator_traits<__pointer_allocator>;
742 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,452 using __map_pointer = typename __map_alloc_traits::pointer;
743 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r)453 using __map_const_pointer = typename allocator_traits<__const_pointer_allocator>::const_pointer;
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}
765454
766// move455 using reference = value_type&;
456 using const_reference = const value_type&;
767457
768template <class _RAIter,458 using iterator = __deque_iterator<value_type, pointer, reference, __map_pointer, difference_type>;
769 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>459 using const_iterator =
770__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>460 __deque_iterator<value_type, const_pointer, const_reference, __map_const_pointer, difference_type>;
771move(_RAIter __f,461 using reverse_iterator = std::reverse_iterator<iterator>;
772 _RAIter __l,462 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
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}
797463
798template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,464 static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
799 class _OutputIterator>465 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
800_OutputIterator466 "original allocator");
801move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,467 static_assert(is_nothrow_default_constructible<allocator_type>::value ==
802 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,468 is_nothrow_default_constructible<__pointer_allocator>::value,
803 _OutputIterator __r)469 "rebinding an allocator should not change excpetion guarantees");
804{470 static_assert(is_nothrow_move_constructible<allocator_type>::value ==
805 typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type;471 is_nothrow_move_constructible<typename __map::allocator_type>::value,
806 typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer;472 "rebinding an allocator should not change excpetion guarantees");
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}
825473
826template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,474private:
827 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>475 struct __deque_block_range {
828__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>476 explicit _LIBCPP_HIDE_FROM_ABI
829move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,477 __deque_block_range(pointer __b, pointer __e) _NOEXCEPT : __begin_(__b), __end_(__e) {}
830 __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,478 const pointer __begin_;
831 __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r)479 const pointer __end_;
832{480 };
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}
853481
854// move_backward482 struct __deque_range {
483 iterator __pos_;
484 const iterator __end_;
855485
856template <class _RAIter,486 _LIBCPP_HIDE_FROM_ABI __deque_range(iterator __pos, iterator __e) _NOEXCEPT
857 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>487 : __pos_(__pos), __end_(__e) {}
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}
885488
886template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,489 explicit _LIBCPP_HIDE_FROM_ABI operator bool() const _NOEXCEPT {
887 class _OutputIterator>490 return __pos_ != __end_;
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;
910 }491 }
911 return __r;
912}
913492
914template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,493 _LIBCPP_HIDE_FROM_ABI __deque_range begin() const {
915 class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>494 return *this;
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;
938 }495 }
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;497 _LIBCPP_HIDE_FROM_ABI __deque_range end() const {
953 typedef value_type& reference;498 return __deque_range(__end_, __end_);
954 typedef const value_type& const_reference;499 }
955 typedef typename __alloc_traits::difference_type difference_type;500 _LIBCPP_HIDE_FROM_ABI __deque_block_range operator*() const _NOEXCEPT {
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 {
1005 if (__pos_.__m_iter_ == __end_.__m_iter_) {501 if (__pos_.__m_iter_ == __end_.__m_iter_) {
1006 __pos_ = __end_;502 return __deque_block_range(__pos_.__ptr_, __end_.__ptr_);
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_;
1017 }503 }
1018 friend bool operator!=(__deque_range const& __lhs, __deque_range const& __rhs) {504 return __deque_block_range(__pos_.__ptr_, *__pos_.__m_iter_ + __block_size);
1019 return !(__lhs == __rhs);505 }
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
1029506
1030 ~_ConstructTransaction() {507 _LIBCPP_HIDE_FROM_ABI __deque_range& operator++() _NOEXCEPT {
1031 __base_->size() += (__pos_ - __begin_);508 if (__pos_.__m_iter_ == __end_.__m_iter_) {
509 __pos_ = __end_;
510 } else {
511 ++__pos_.__m_iter_;
512 __pos_.__ptr_ = *__pos_.__m_iter_;
1032 }513 }
1033514 return *this;
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;
1094 }515 }
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:518 _LIBCPP_HIDE_FROM_ABI friend bool operator==(__deque_range const& __lhs, __deque_range const& __rhs) {
1104 _LIBCPP_INLINE_VISIBILITY519 return __lhs.__pos_ == __rhs.__pos_;
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;
1139 }520 }
1140 else521 _LIBCPP_HIDE_FROM_ABI friend bool operator!=(__deque_range const& __lhs, __deque_range const& __rhs) {
1141 {522 return !(__lhs == __rhs);
1142 if (size() != 0)
1143 return false;
1144 if (__start_ != 0)
1145 return false;
1146 }523 }
1147 return true;524 };
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) {}
1194525
1195template <class _Tp, class _Allocator>526 struct _ConstructTransaction {
1196__deque_base<_Tp, _Allocator>::~__deque_base()527 _LIBCPP_HIDE_FROM_ABI _ConstructTransaction(deque* __db, __deque_block_range& __r)
1197{528 : __pos_(__r.__begin_), __end_(__r.__end_), __begin_(__r.__begin_), __base_(__db) {}
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}
1204529
1205#ifndef _LIBCPP_CXX03_LANG
1206530
1207template <class _Tp, class _Allocator>531 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() {
1208__deque_base<_Tp, _Allocator>::__deque_base(__deque_base&& __c)532 __base_->__size() += (__pos_ - __begin_);
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;
1228 }533 }
1229 else
1230 {
1231 __map_.clear();
1232 __start_ = 0;
1233 size() = 0;
1234 }
1235}
1236534
1237#endif // _LIBCPP_CXX03_LANG535 pointer __pos_;
536 const pointer __end_;
537 private:
538 const pointer __begin_;
539 deque* const __base_;
540 };
1238541
1239template <class _Tp, class _Allocator>542 static const difference_type __block_size;
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}
1254543
1255template <class _Tp, class _Allocator>544 __map __map_;
1256void545 size_type __start_;
1257__deque_base<_Tp, _Allocator>::clear() _NOEXCEPT546 __compressed_pair<size_type, allocator_type> __size_;
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}
1278547
1279template <class _Tp, class _Allocator /*= allocator<_Tp>*/>
1280class _LIBCPP_TEMPLATE_VIS deque
1281 : private __deque_base<_Tp, _Allocator>
1282{
1283public:548public:
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),550 // construct/copy/destroy:
1290 "Allocator::value_type must be same type as value_type");551 _LIBCPP_HIDE_FROM_ABI
1291552 deque() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
1292 typedef __deque_base<value_type, allocator_type> __base;553 : __start_(0), __size_(0, __default_init_tag()) {}
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;
1301554
1302 typedef typename __base::pointer pointer;555 _LIBCPP_HIDE_FROM_ABI ~deque() {
1303 typedef typename __base::const_pointer const_pointer;556 clear();
1304 typedef _VSTD::reverse_iterator<iterator> reverse_iterator;557 typename __map::iterator __i = __map_.begin();
1305 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;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;563 _LIBCPP_HIDE_FROM_ABI explicit deque(const allocator_type& __a)
1308 using typename __base::__deque_block_range;564 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) {}
1309 using typename __base::_ConstructTransaction;
1310565
1311 // construct/copy/destroy:566 explicit _LIBCPP_HIDE_FROM_ABI deque(size_type __n);
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);
1318#if _LIBCPP_STD_VER > 11567#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);
1320#endif569#endif
1321 deque(size_type __n, const value_type& __v);570 _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v);
1322571
1323 template <class = __enable_if_t<__is_allocator<_Allocator>::value> >572 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)
1325 {575 {
1326 if (__n > 0)576 if (__n > 0)
1327 __append(__n, __v);577 __append(__n, __v);
1328 }578 }
1329579
1330 template <class _InputIter>580 template <class _InputIter>
1331 deque(_InputIter __f, _InputIter __l,581 _LIBCPP_HIDE_FROM_ABI deque(_InputIter __f, _InputIter __l,
1332 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type* = 0);582 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type* = 0);
1333 template <class _InputIter>583 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,
1335 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type* = 0);585 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type* = 0);
1336 deque(const deque& __c);586 _LIBCPP_HIDE_FROM_ABI deque(const deque& __c);
1337 deque(const deque& __c, const __type_identity_t<allocator_type>& __a);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
1341#ifndef _LIBCPP_CXX03_LANG591#ifndef _LIBCPP_CXX03_LANG
1342 deque(initializer_list<value_type> __il);592 _LIBCPP_HIDE_FROM_ABI deque(initializer_list<value_type> __il);
1343 deque(initializer_list<value_type> __il, const allocator_type& __a);593 _LIBCPP_HIDE_FROM_ABI deque(initializer_list<value_type> __il, const allocator_type& __a);
1344594
1345 _LIBCPP_INLINE_VISIBILITY595 _LIBCPP_HIDE_FROM_ABI
1346 deque& operator=(initializer_list<value_type> __il) {assign(__il); return *this;}596 deque& operator=(initializer_list<value_type> __il) {assign(__il); return *this;}
1347597
1348 _LIBCPP_INLINE_VISIBILITY598 _LIBCPP_HIDE_FROM_ABI
1349 deque(deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value);599 deque(deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
1350 _LIBCPP_INLINE_VISIBILITY600 _LIBCPP_HIDE_FROM_ABI
1351 deque(deque&& __c, const __type_identity_t<allocator_type>& __a);601 deque(deque&& __c, const __type_identity_t<allocator_type>& __a);
1352 _LIBCPP_INLINE_VISIBILITY602 _LIBCPP_HIDE_FROM_ABI
1353 deque& operator=(deque&& __c)603 deque& operator=(deque&& __c)
1354 _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value &&604 _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value &&
1355 is_nothrow_move_assignable<allocator_type>::value);605 is_nothrow_move_assignable<allocator_type>::value);
1356606
1357 _LIBCPP_INLINE_VISIBILITY607 _LIBCPP_HIDE_FROM_ABI
1358 void assign(initializer_list<value_type> __il) {assign(__il.begin(), __il.end());}608 void assign(initializer_list<value_type> __il) {assign(__il.begin(), __il.end());}
1359#endif // _LIBCPP_CXX03_LANG609#endif // _LIBCPP_CXX03_LANG
1360610
1361 template <class _InputIter>611 template <class _InputIter>
1362 void assign(_InputIter __f, _InputIter __l,612 _LIBCPP_HIDE_FROM_ABI void assign(_InputIter __f, _InputIter __l,
1363 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value &&613 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value &&
1364 !__is_cpp17_random_access_iterator<_InputIter>::value>::type* = 0);614 !__is_cpp17_random_access_iterator<_InputIter>::value>::type* = 0);
1365 template <class _RAIter>615 template <class _RAIter>
1366 void assign(_RAIter __f, _RAIter __l,616 _LIBCPP_HIDE_FROM_ABI void assign(_RAIter __f, _RAIter __l,
1367 typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type* = 0);617 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_VISIBILITY620 _LIBCPP_HIDE_FROM_ABI
1371 allocator_type get_allocator() const _NOEXCEPT;621 allocator_type get_allocator() const _NOEXCEPT;
1372622 _LIBCPP_HIDE_FROM_ABI allocator_type& __alloc() _NOEXCEPT { return __size_.second(); }
1373 // iterators:623 _LIBCPP_HIDE_FROM_ABI const allocator_type& __alloc() const _NOEXCEPT { return __size_.second(); }
1374624
1375 _LIBCPP_INLINE_VISIBILITY625 // iterators:
1376 iterator begin() _NOEXCEPT {return __base::begin();}626
1377 _LIBCPP_INLINE_VISIBILITY627 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT {
1378 const_iterator begin() const _NOEXCEPT {return __base::begin();}628 __map_pointer __mp = __map_.begin() + __start_ / __block_size;
1379 _LIBCPP_INLINE_VISIBILITY629 return iterator(__mp, __map_.empty() ? 0 : *__mp + __start_ % __block_size);
1380 iterator end() _NOEXCEPT {return __base::end();}630 }
1381 _LIBCPP_INLINE_VISIBILITY631
1382 const_iterator end() const _NOEXCEPT {return __base::end();}632 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT {
1383633 __map_const_pointer __mp =
1384 _LIBCPP_INLINE_VISIBILITY634 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
1385 reverse_iterator rbegin() _NOEXCEPT651 reverse_iterator rbegin() _NOEXCEPT
1386 {return reverse_iterator(__base::end());}652 {return reverse_iterator(end());}
1387 _LIBCPP_INLINE_VISIBILITY653 _LIBCPP_HIDE_FROM_ABI
1388 const_reverse_iterator rbegin() const _NOEXCEPT654 const_reverse_iterator rbegin() const _NOEXCEPT
1389 {return const_reverse_iterator(__base::end());}655 {return const_reverse_iterator(end());}
1390 _LIBCPP_INLINE_VISIBILITY656 _LIBCPP_HIDE_FROM_ABI
1391 reverse_iterator rend() _NOEXCEPT657 reverse_iterator rend() _NOEXCEPT
1392 {return reverse_iterator(__base::begin());}658 {return reverse_iterator(begin());}
1393 _LIBCPP_INLINE_VISIBILITY659 _LIBCPP_HIDE_FROM_ABI
1394 const_reverse_iterator rend() const _NOEXCEPT660 const_reverse_iterator rend() const _NOEXCEPT
1395 {return const_reverse_iterator(__base::begin());}661 {return const_reverse_iterator(begin());}
1396662
1397 _LIBCPP_INLINE_VISIBILITY663 _LIBCPP_HIDE_FROM_ABI
1398 const_iterator cbegin() const _NOEXCEPT664 const_iterator cbegin() const _NOEXCEPT
1399 {return __base::begin();}665 {return begin();}
1400 _LIBCPP_INLINE_VISIBILITY666 _LIBCPP_HIDE_FROM_ABI
1401 const_iterator cend() const _NOEXCEPT667 const_iterator cend() const _NOEXCEPT
1402 {return __base::end();}668 {return end();}
1403 _LIBCPP_INLINE_VISIBILITY669 _LIBCPP_HIDE_FROM_ABI
1404 const_reverse_iterator crbegin() const _NOEXCEPT670 const_reverse_iterator crbegin() const _NOEXCEPT
1405 {return const_reverse_iterator(__base::end());}671 {return const_reverse_iterator(end());}
1406 _LIBCPP_INLINE_VISIBILITY672 _LIBCPP_HIDE_FROM_ABI
1407 const_reverse_iterator crend() const _NOEXCEPT673 const_reverse_iterator crend() const _NOEXCEPT
1408 {return const_reverse_iterator(__base::begin());}674 {return const_reverse_iterator(begin());}
1409675
1410 // capacity:676 // capacity:
1411 _LIBCPP_INLINE_VISIBILITY677 _LIBCPP_HIDE_FROM_ABI
1412 size_type size() const _NOEXCEPT {return __base::size();}678 size_type size() const _NOEXCEPT {return __size();}
1413 _LIBCPP_INLINE_VISIBILITY679
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
1414 size_type max_size() const _NOEXCEPT684 size_type max_size() const _NOEXCEPT
1415 {return _VSTD::min<size_type>(685 {return _VSTD::min<size_type>(
1416 __alloc_traits::max_size(__base::__alloc()),686 __alloc_traits::max_size(__alloc()),
1417 numeric_limits<difference_type>::max());}687 numeric_limits<difference_type>::max());}
1418 void resize(size_type __n);688 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n);
1419 void resize(size_type __n, const value_type& __v);689 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __v);
1420 void shrink_to_fit() _NOEXCEPT;690 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT;
1421 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY691 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
1422 bool empty() const _NOEXCEPT {return __base::size() == 0;}692 bool empty() const _NOEXCEPT {return size() == 0;}
1423693
1424 // element access:694 // element access:
1425 _LIBCPP_INLINE_VISIBILITY695 _LIBCPP_HIDE_FROM_ABI
1426 reference operator[](size_type __i) _NOEXCEPT;696 reference operator[](size_type __i) _NOEXCEPT;
1427 _LIBCPP_INLINE_VISIBILITY697 _LIBCPP_HIDE_FROM_ABI
1428 const_reference operator[](size_type __i) const _NOEXCEPT;698 const_reference operator[](size_type __i) const _NOEXCEPT;
1429 _LIBCPP_INLINE_VISIBILITY699 _LIBCPP_HIDE_FROM_ABI
1430 reference at(size_type __i);700 reference at(size_type __i);
1431 _LIBCPP_INLINE_VISIBILITY701 _LIBCPP_HIDE_FROM_ABI
1432 const_reference at(size_type __i) const;702 const_reference at(size_type __i) const;
1433 _LIBCPP_INLINE_VISIBILITY703 _LIBCPP_HIDE_FROM_ABI
1434 reference front() _NOEXCEPT;704 reference front() _NOEXCEPT;
1435 _LIBCPP_INLINE_VISIBILITY705 _LIBCPP_HIDE_FROM_ABI
1436 const_reference front() const _NOEXCEPT;706 const_reference front() const _NOEXCEPT;
1437 _LIBCPP_INLINE_VISIBILITY707 _LIBCPP_HIDE_FROM_ABI
1438 reference back() _NOEXCEPT;708 reference back() _NOEXCEPT;
1439 _LIBCPP_INLINE_VISIBILITY709 _LIBCPP_HIDE_FROM_ABI
1440 const_reference back() const _NOEXCEPT;710 const_reference back() const _NOEXCEPT;
1441711
1442 // 23.2.2.3 modifiers:712 // 23.2.2.3 modifiers:
1443 void push_front(const value_type& __v);713 _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __v);
1444 void push_back(const value_type& __v);714 _LIBCPP_HIDE_FROM_ABI void push_back(const value_type& __v);
1445#ifndef _LIBCPP_CXX03_LANG715#ifndef _LIBCPP_CXX03_LANG
1446#if _LIBCPP_STD_VER > 14716#if _LIBCPP_STD_VER > 14
1447 template <class... _Args> reference emplace_front(_Args&&... __args);717 template <class... _Args> _LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args);
1448 template <class... _Args> reference emplace_back (_Args&&... __args);718 template <class... _Args> _LIBCPP_HIDE_FROM_ABI reference emplace_back (_Args&&... __args);
1449#else719#else
1450 template <class... _Args> void emplace_front(_Args&&... __args);720 template <class... _Args> _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args);
1451 template <class... _Args> void emplace_back (_Args&&... __args);721 template <class... _Args> _LIBCPP_HIDE_FROM_ABI void emplace_back (_Args&&... __args);
1452#endif722#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);725 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __v);
1456 void push_back(value_type&& __v);726 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __v);
1457 iterator insert(const_iterator __p, value_type&& __v);727 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v);
1458728
1459 _LIBCPP_INLINE_VISIBILITY729 _LIBCPP_HIDE_FROM_ABI
1460 iterator insert(const_iterator __p, initializer_list<value_type> __il)730 iterator insert(const_iterator __p, initializer_list<value_type> __il)
1461 {return insert(__p, __il.begin(), __il.end());}731 {return insert(__p, __il.begin(), __il.end());}
1462#endif // _LIBCPP_CXX03_LANG732#endif // _LIBCPP_CXX03_LANG
1463 iterator insert(const_iterator __p, const value_type& __v);733 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v);
1464 iterator insert(const_iterator __p, size_type __n, const value_type& __v);734 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, size_type __n, const value_type& __v);
1465 template <class _InputIter>735 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,
1467 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIter>::value>::type* = 0);737 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIter>::value>::type* = 0);
1468 template <class _ForwardIterator>738 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,
1470 typename enable_if<__is_exactly_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);740 typename enable_if<__is_exactly_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);
1471 template <class _BiIter>741 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,
1473 typename enable_if<__is_cpp17_bidirectional_iterator<_BiIter>::value>::type* = 0);743 typename enable_if<__is_cpp17_bidirectional_iterator<_BiIter>::value>::type* = 0);
1474744
1475 void pop_front();745 _LIBCPP_HIDE_FROM_ABI void pop_front();
1476 void pop_back();746 _LIBCPP_HIDE_FROM_ABI void pop_back();
1477 iterator erase(const_iterator __p);747 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p);
1478 iterator erase(const_iterator __f, const_iterator __l);748 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l);
1479749
1480 _LIBCPP_INLINE_VISIBILITY750 _LIBCPP_HIDE_FROM_ABI
1481 void swap(deque& __c)751 void swap(deque& __c)
1482#if _LIBCPP_STD_VER >= 14752#if _LIBCPP_STD_VER >= 14
1483 _NOEXCEPT;753 _NOEXCEPT;
...@@ -1485,121 +755,177 @@ public:...@@ -1485,121 +755,177 @@ public:
1485 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||755 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
1486 __is_nothrow_swappable<allocator_type>::value);756 __is_nothrow_swappable<allocator_type>::value);
1487#endif757#endif
1488 _LIBCPP_INLINE_VISIBILITY758 _LIBCPP_HIDE_FROM_ABI
1489 void clear() _NOEXCEPT;759 void clear() _NOEXCEPT;
1490760
1491 _LIBCPP_INLINE_VISIBILITY761 _LIBCPP_HIDE_FROM_ABI
1492 bool __invariants() const {return __base::__invariants();}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_VISIBILITY818 _LIBCPP_HIDE_FROM_ABI
1497 static size_type __recommend_blocks(size_type __n)819 static size_type __recommend_blocks(size_type __n)
1498 {820 {
1499 return __n / __base::__block_size + (__n % __base::__block_size != 0);821 return __n / __block_size + (__n % __block_size != 0);
1500 }822 }
1501 _LIBCPP_INLINE_VISIBILITY823 _LIBCPP_HIDE_FROM_ABI
1502 size_type __capacity() const824 size_type __capacity() const
1503 {825 {
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;
1505 }827 }
1506 _LIBCPP_INLINE_VISIBILITY828 _LIBCPP_HIDE_FROM_ABI
1507 size_type __block_count() const829 size_type __block_count() const
1508 {830 {
1509 return __base::__map_.size();831 return __map_.size();
1510 }832 }
1511833
1512 _LIBCPP_INLINE_VISIBILITY834 _LIBCPP_HIDE_FROM_ABI
1513 size_type __front_spare() const835 size_type __front_spare() const
1514 {836 {
1515 return __base::__start_;837 return __start_;
1516 }838 }
1517 _LIBCPP_INLINE_VISIBILITY839 _LIBCPP_HIDE_FROM_ABI
1518 size_type __front_spare_blocks() const {840 size_type __front_spare_blocks() const {
1519 return __front_spare() / __base::__block_size;841 return __front_spare() / __block_size;
1520 }842 }
1521 _LIBCPP_INLINE_VISIBILITY843 _LIBCPP_HIDE_FROM_ABI
1522 size_type __back_spare() const844 size_type __back_spare() const
1523 {845 {
1524 return __capacity() - (__base::__start_ + __base::size());846 return __capacity() - (__start_ + size());
1525 }847 }
1526 _LIBCPP_INLINE_VISIBILITY848 _LIBCPP_HIDE_FROM_ABI
1527 size_type __back_spare_blocks() const {849 size_type __back_spare_blocks() const {
1528 return __back_spare() / __base::__block_size;850 return __back_spare() / __block_size;
1529 }851 }
1530852
1531 private:853 private:
1532 _LIBCPP_INLINE_VISIBILITY854 _LIBCPP_HIDE_FROM_ABI
1533 bool __maybe_remove_front_spare(bool __keep_one = true) {855 bool __maybe_remove_front_spare(bool __keep_one = true) {
1534 if (__front_spare_blocks() >= 2 || (!__keep_one && __front_spare_blocks())) {856 if (__front_spare_blocks() >= 2 || (!__keep_one && __front_spare_blocks())) {
1535 __alloc_traits::deallocate(__base::__alloc(), __base::__map_.front(),857 __alloc_traits::deallocate(__alloc(), __map_.front(),
1536 __base::__block_size);858 __block_size);
1537 __base::__map_.pop_front();859 __map_.pop_front();
1538 __base::__start_ -= __base::__block_size;860 __start_ -= __block_size;
1539 return true;861 return true;
1540 }862 }
1541 return false;863 return false;
1542 }864 }
1543865
1544 _LIBCPP_INLINE_VISIBILITY866 _LIBCPP_HIDE_FROM_ABI
1545 bool __maybe_remove_back_spare(bool __keep_one = true) {867 bool __maybe_remove_back_spare(bool __keep_one = true) {
1546 if (__back_spare_blocks() >= 2 || (!__keep_one && __back_spare_blocks())) {868 if (__back_spare_blocks() >= 2 || (!__keep_one && __back_spare_blocks())) {
1547 __alloc_traits::deallocate(__base::__alloc(), __base::__map_.back(),869 __alloc_traits::deallocate(__alloc(), __map_.back(),
1548 __base::__block_size);870 __block_size);
1549 __base::__map_.pop_back();871 __map_.pop_back();
1550 return true;872 return true;
1551 }873 }
1552 return false;874 return false;
1553 }875 }
1554876
1555 template <class _InpIter>877 template <class _InpIter>
1556 void __append(_InpIter __f, _InpIter __l,878 _LIBCPP_HIDE_FROM_ABI void __append(_InpIter __f, _InpIter __l,
1557 typename enable_if<__is_exactly_cpp17_input_iterator<_InpIter>::value>::type* = 0);879 typename enable_if<__is_exactly_cpp17_input_iterator<_InpIter>::value>::type* = 0);
1558 template <class _ForIter>880 template <class _ForIter>
1559 void __append(_ForIter __f, _ForIter __l,881 _LIBCPP_HIDE_FROM_ABI void __append(_ForIter __f, _ForIter __l,
1560 typename enable_if<__is_cpp17_forward_iterator<_ForIter>::value>::type* = 0);882 typename enable_if<__is_cpp17_forward_iterator<_ForIter>::value>::type* = 0);
1561 void __append(size_type __n);883 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n);
1562 void __append(size_type __n, const value_type& __v);884 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n, const value_type& __v);
1563 void __erase_to_end(const_iterator __f);885 _LIBCPP_HIDE_FROM_ABI void __erase_to_end(const_iterator __f);
1564 void __add_front_capacity();886 _LIBCPP_HIDE_FROM_ABI void __add_front_capacity();
1565 void __add_front_capacity(size_type __n);887 _LIBCPP_HIDE_FROM_ABI void __add_front_capacity(size_type __n);
1566 void __add_back_capacity();888 _LIBCPP_HIDE_FROM_ABI void __add_back_capacity();
1567 void __add_back_capacity(size_type __n);889 _LIBCPP_HIDE_FROM_ABI void __add_back_capacity(size_type __n);
1568 iterator __move_and_check(iterator __f, iterator __l, iterator __r,890 _LIBCPP_HIDE_FROM_ABI iterator __move_and_check(iterator __f, iterator __l, iterator __r,
1569 const_pointer& __vt);891 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,
1571 const_pointer& __vt);893 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,
1573 iterator __r, const_pointer& __vt);895 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,
1575 iterator __r, const_pointer& __vt);897 iterator __r, const_pointer& __vt);
1576898
1577 _LIBCPP_INLINE_VISIBILITY899 _LIBCPP_HIDE_FROM_ABI
1578 void __copy_assign_alloc(const deque& __c)900 void __copy_assign_alloc(const deque& __c)
1579 {__copy_assign_alloc(__c, integral_constant<bool,901 {__copy_assign_alloc(__c, integral_constant<bool,
1580 __alloc_traits::propagate_on_container_copy_assignment::value>());}902 __alloc_traits::propagate_on_container_copy_assignment::value>());}
1581903
1582 _LIBCPP_INLINE_VISIBILITY904 _LIBCPP_HIDE_FROM_ABI
1583 void __copy_assign_alloc(const deque& __c, true_type)905 void __copy_assign_alloc(const deque& __c, true_type)
1584 {906 {
1585 if (__base::__alloc() != __c.__alloc())907 if (__alloc() != __c.__alloc())
1586 {908 {
1587 clear();909 clear();
1588 shrink_to_fit();910 shrink_to_fit();
1589 }911 }
1590 __base::__alloc() = __c.__alloc();912 __alloc() = __c.__alloc();
1591 __base::__map_.__alloc() = __c.__map_.__alloc();913 __map_.__alloc() = __c.__map_.__alloc();
1592 }914 }
1593915
1594 _LIBCPP_INLINE_VISIBILITY916 _LIBCPP_HIDE_FROM_ABI
1595 void __copy_assign_alloc(const deque&, false_type)917 void __copy_assign_alloc(const deque&, false_type)
1596 {}918 {}
1597919
1598 void __move_assign(deque& __c, true_type)920 _LIBCPP_HIDE_FROM_ABI void __move_assign(deque& __c, true_type)
1599 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);921 _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);
1601};923};
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
1603#if _LIBCPP_STD_VER >= 17929#if _LIBCPP_STD_VER >= 17
1604template<class _InputIterator,930template<class _InputIterator,
1605 class _Alloc = allocator<__iter_value_type<_InputIterator>>,931 class _Alloc = allocator<__iter_value_type<_InputIterator>>,
...@@ -1620,6 +946,7 @@ deque(_InputIterator, _InputIterator, _Alloc)...@@ -1620,6 +946,7 @@ deque(_InputIterator, _InputIterator, _Alloc)
1620946
1621template <class _Tp, class _Allocator>947template <class _Tp, class _Allocator>
1622deque<_Tp, _Allocator>::deque(size_type __n)948deque<_Tp, _Allocator>::deque(size_type __n)
949 : __start_(0), __size_(0, __default_init_tag())
1623{950{
1624 if (__n > 0)951 if (__n > 0)
1625 __append(__n);952 __append(__n);
...@@ -1628,7 +955,7 @@ deque<_Tp, _Allocator>::deque(size_type __n)...@@ -1628,7 +955,7 @@ deque<_Tp, _Allocator>::deque(size_type __n)
1628#if _LIBCPP_STD_VER > 11955#if _LIBCPP_STD_VER > 11
1629template <class _Tp, class _Allocator>956template <class _Tp, class _Allocator>
1630deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a)957deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a)
1631 : __base(__a)958 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a)
1632{959{
1633 if (__n > 0)960 if (__n > 0)
1634 __append(__n);961 __append(__n);
...@@ -1637,6 +964,7 @@ deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a)...@@ -1637,6 +964,7 @@ deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a)
1637964
1638template <class _Tp, class _Allocator>965template <class _Tp, class _Allocator>
1639deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v)966deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v)
967 : __start_(0), __size_(0, __default_init_tag())
1640{968{
1641 if (__n > 0)969 if (__n > 0)
1642 __append(__n, __v);970 __append(__n, __v);
...@@ -1646,6 +974,7 @@ template <class _Tp, class _Allocator>...@@ -1646,6 +974,7 @@ template <class _Tp, class _Allocator>
1646template <class _InputIter>974template <class _InputIter>
1647deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l,975deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l,
1648 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type*)976 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type*)
977 : __start_(0), __size_(0, __default_init_tag())
1649{978{
1650 __append(__f, __l);979 __append(__f, __l);
1651}980}
...@@ -1654,21 +983,23 @@ template <class _Tp, class _Allocator>...@@ -1654,21 +983,23 @@ template <class _Tp, class _Allocator>
1654template <class _InputIter>983template <class _InputIter>
1655deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l, const allocator_type& __a,984deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l, const allocator_type& __a,
1656 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type*)985 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type*)
1657 : __base(__a)986 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a)
1658{987{
1659 __append(__f, __l);988 __append(__f, __l);
1660}989}
1661990
1662template <class _Tp, class _Allocator>991template <class _Tp, class _Allocator>
1663deque<_Tp, _Allocator>::deque(const deque& __c)992deque<_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())
1665{996{
1666 __append(__c.begin(), __c.end());997 __append(__c.begin(), __c.end());
1667}998}
1668999
1669template <class _Tp, class _Allocator>1000template <class _Tp, class _Allocator>
1670deque<_Tp, _Allocator>::deque(const deque& __c, const __type_identity_t<allocator_type>& __a)1001deque<_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)
1672{1003{
1673 __append(__c.begin(), __c.end());1004 __append(__c.begin(), __c.end());
1674}1005}
...@@ -1689,13 +1020,14 @@ deque<_Tp, _Allocator>::operator=(const deque& __c)...@@ -1689,13 +1020,14 @@ deque<_Tp, _Allocator>::operator=(const deque& __c)
16891020
1690template <class _Tp, class _Allocator>1021template <class _Tp, class _Allocator>
1691deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il)1022deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il)
1023 : __start_(0), __size_(0, __default_init_tag())
1692{1024{
1693 __append(__il.begin(), __il.end());1025 __append(__il.begin(), __il.end());
1694}1026}
16951027
1696template <class _Tp, class _Allocator>1028template <class _Tp, class _Allocator>
1697deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il, const allocator_type& __a)1029deque<_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)
1699{1031{
1700 __append(__il.begin(), __il.end());1032 __append(__il.begin(), __il.end());
1701}1033}
...@@ -1703,18 +1035,30 @@ deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il, const allocator...@@ -1703,18 +1035,30 @@ deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il, const allocator
1703template <class _Tp, class _Allocator>1035template <class _Tp, class _Allocator>
1704inline1036inline
1705deque<_Tp, _Allocator>::deque(deque&& __c)1037deque<_Tp, _Allocator>::deque(deque&& __c)
1706 _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)1038 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
1707 : __base(_VSTD::move(__c))1039 : __map_(std::move(__c.__map_)), __start_(std::move(__c.__start_)), __size_(std::move(__c.__size_))
1708{1040{
1041 __c.__start_ = 0;
1042 __c.__size() = 0;
1709}1043}
17101044
1711template <class _Tp, class _Allocator>1045template <class _Tp, class _Allocator>
1712inline1046inline
1713deque<_Tp, _Allocator>::deque(deque&& __c, const __type_identity_t<allocator_type>& __a)1047deque<_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)
1715{1051{
1716 if (__a != __c.__alloc())1052 if (__a == __c.__alloc())
1717 {1053 {
1054 __c.__start_ = 0;
1055 __c.__size() = 0;
1056 }
1057 else
1058 {
1059 __map_.clear();
1060 __start_ = 0;
1061 __size() = 0;
1718 typedef move_iterator<iterator> _Ip;1062 typedef move_iterator<iterator> _Ip;
1719 assign(_Ip(__c.begin()), _Ip(__c.end()));1063 assign(_Ip(__c.begin()), _Ip(__c.end()));
1720 }1064 }
...@@ -1736,7 +1080,7 @@ template <class _Tp, class _Allocator>...@@ -1736,7 +1080,7 @@ template <class _Tp, class _Allocator>
1736void1080void
1737deque<_Tp, _Allocator>::__move_assign(deque& __c, false_type)1081deque<_Tp, _Allocator>::__move_assign(deque& __c, false_type)
1738{1082{
1739 if (__base::__alloc() != __c.__alloc())1083 if (__alloc() != __c.__alloc())
1740 {1084 {
1741 typedef move_iterator<iterator> _Ip;1085 typedef move_iterator<iterator> _Ip;
1742 assign(_Ip(__c.begin()), _Ip(__c.end()));1086 assign(_Ip(__c.begin()), _Ip(__c.end()));
...@@ -1752,7 +1096,7 @@ deque<_Tp, _Allocator>::__move_assign(deque& __c, true_type)...@@ -1752,7 +1096,7 @@ deque<_Tp, _Allocator>::__move_assign(deque& __c, true_type)
1752{1096{
1753 clear();1097 clear();
1754 shrink_to_fit();1098 shrink_to_fit();
1755 __base::__move_assign(__c);1099 __move_assign(__c);
1756}1100}
17571101
1758#endif // _LIBCPP_CXX03_LANG1102#endif // _LIBCPP_CXX03_LANG
...@@ -1764,8 +1108,8 @@ deque<_Tp, _Allocator>::assign(_InputIter __f, _InputIter __l,...@@ -1764,8 +1108,8 @@ deque<_Tp, _Allocator>::assign(_InputIter __f, _InputIter __l,
1764 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value &&1108 typename enable_if<__is_cpp17_input_iterator<_InputIter>::value &&
1765 !__is_cpp17_random_access_iterator<_InputIter>::value>::type*)1109 !__is_cpp17_random_access_iterator<_InputIter>::value>::type*)
1766{1110{
1767 iterator __i = __base::begin();1111 iterator __i = begin();
1768 iterator __e = __base::end();1112 iterator __e = end();
1769 for (; __f != __l && __i != __e; ++__f, (void) ++__i)1113 for (; __f != __l && __i != __e; ++__f, (void) ++__i)
1770 *__i = *__f;1114 *__i = *__f;
1771 if (__f != __l)1115 if (__f != __l)
...@@ -1780,28 +1124,28 @@ void...@@ -1780,28 +1124,28 @@ void
1780deque<_Tp, _Allocator>::assign(_RAIter __f, _RAIter __l,1124deque<_Tp, _Allocator>::assign(_RAIter __f, _RAIter __l,
1781 typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*)1125 typename enable_if<__is_cpp17_random_access_iterator<_RAIter>::value>::type*)
1782{1126{
1783 if (static_cast<size_type>(__l - __f) > __base::size())1127 if (static_cast<size_type>(__l - __f) > size())
1784 {1128 {
1785 _RAIter __m = __f + __base::size();1129 _RAIter __m = __f + size();
1786 _VSTD::copy(__f, __m, __base::begin());1130 _VSTD::copy(__f, __m, begin());
1787 __append(__m, __l);1131 __append(__m, __l);
1788 }1132 }
1789 else1133 else
1790 __erase_to_end(_VSTD::copy(__f, __l, __base::begin()));1134 __erase_to_end(_VSTD::copy(__f, __l, begin()));
1791}1135}
17921136
1793template <class _Tp, class _Allocator>1137template <class _Tp, class _Allocator>
1794void1138void
1795deque<_Tp, _Allocator>::assign(size_type __n, const value_type& __v)1139deque<_Tp, _Allocator>::assign(size_type __n, const value_type& __v)
1796{1140{
1797 if (__n > __base::size())1141 if (__n > size())
1798 {1142 {
1799 _VSTD::fill_n(__base::begin(), __base::size(), __v);1143 _VSTD::fill_n(begin(), size(), __v);
1800 __n -= __base::size();1144 __n -= size();
1801 __append(__n, __v);1145 __append(__n, __v);
1802 }1146 }
1803 else1147 else
1804 __erase_to_end(_VSTD::fill_n(__base::begin(), __n, __v));1148 __erase_to_end(_VSTD::fill_n(begin(), __n, __v));
1805}1149}
18061150
1807template <class _Tp, class _Allocator>1151template <class _Tp, class _Allocator>
...@@ -1809,49 +1153,49 @@ inline...@@ -1809,49 +1153,49 @@ inline
1809_Allocator1153_Allocator
1810deque<_Tp, _Allocator>::get_allocator() const _NOEXCEPT1154deque<_Tp, _Allocator>::get_allocator() const _NOEXCEPT
1811{1155{
1812 return __base::__alloc();1156 return __alloc();
1813}1157}
18141158
1815template <class _Tp, class _Allocator>1159template <class _Tp, class _Allocator>
1816void1160void
1817deque<_Tp, _Allocator>::resize(size_type __n)1161deque<_Tp, _Allocator>::resize(size_type __n)
1818{1162{
1819 if (__n > __base::size())1163 if (__n > size())
1820 __append(__n - __base::size());1164 __append(__n - size());
1821 else if (__n < __base::size())1165 else if (__n < size())
1822 __erase_to_end(__base::begin() + __n);1166 __erase_to_end(begin() + __n);
1823}1167}
18241168
1825template <class _Tp, class _Allocator>1169template <class _Tp, class _Allocator>
1826void1170void
1827deque<_Tp, _Allocator>::resize(size_type __n, const value_type& __v)1171deque<_Tp, _Allocator>::resize(size_type __n, const value_type& __v)
1828{1172{
1829 if (__n > __base::size())1173 if (__n > size())
1830 __append(__n - __base::size(), __v);1174 __append(__n - size(), __v);
1831 else if (__n < __base::size())1175 else if (__n < size())
1832 __erase_to_end(__base::begin() + __n);1176 __erase_to_end(begin() + __n);
1833}1177}
18341178
1835template <class _Tp, class _Allocator>1179template <class _Tp, class _Allocator>
1836void1180void
1837deque<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT1181deque<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
1838{1182{
1839 allocator_type& __a = __base::__alloc();1183 allocator_type& __a = __alloc();
1840 if (empty())1184 if (empty())
1841 {1185 {
1842 while (__base::__map_.size() > 0)1186 while (__map_.size() > 0)
1843 {1187 {
1844 __alloc_traits::deallocate(__a, __base::__map_.back(), __base::__block_size);1188 __alloc_traits::deallocate(__a, __map_.back(), __block_size);
1845 __base::__map_.pop_back();1189 __map_.pop_back();
1846 }1190 }
1847 __base::__start_ = 0;1191 __start_ = 0;
1848 }1192 }
1849 else1193 else
1850 {1194 {
1851 __maybe_remove_front_spare(/*__keep_one=*/false);1195 __maybe_remove_front_spare(/*__keep_one=*/false);
1852 __maybe_remove_back_spare(/*__keep_one=*/false);1196 __maybe_remove_back_spare(/*__keep_one=*/false);
1853 }1197 }
1854 __base::__map_.shrink_to_fit();1198 __map_.shrink_to_fit();
1855}1199}
18561200
1857template <class _Tp, class _Allocator>1201template <class _Tp, class _Allocator>
...@@ -1859,8 +1203,8 @@ inline...@@ -1859,8 +1203,8 @@ inline
1859typename deque<_Tp, _Allocator>::reference1203typename deque<_Tp, _Allocator>::reference
1860deque<_Tp, _Allocator>::operator[](size_type __i) _NOEXCEPT1204deque<_Tp, _Allocator>::operator[](size_type __i) _NOEXCEPT
1861{1205{
1862 size_type __p = __base::__start_ + __i;1206 size_type __p = __start_ + __i;
1863 return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);1207 return *(*(__map_.begin() + __p / __block_size) + __p % __block_size);
1864}1208}
18651209
1866template <class _Tp, class _Allocator>1210template <class _Tp, class _Allocator>
...@@ -1868,8 +1212,8 @@ inline...@@ -1868,8 +1212,8 @@ inline
1868typename deque<_Tp, _Allocator>::const_reference1212typename deque<_Tp, _Allocator>::const_reference
1869deque<_Tp, _Allocator>::operator[](size_type __i) const _NOEXCEPT1213deque<_Tp, _Allocator>::operator[](size_type __i) const _NOEXCEPT
1870{1214{
1871 size_type __p = __base::__start_ + __i;1215 size_type __p = __start_ + __i;
1872 return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);1216 return *(*(__map_.begin() + __p / __block_size) + __p % __block_size);
1873}1217}
18741218
1875template <class _Tp, class _Allocator>1219template <class _Tp, class _Allocator>
...@@ -1877,10 +1221,10 @@ inline...@@ -1877,10 +1221,10 @@ inline
1877typename deque<_Tp, _Allocator>::reference1221typename deque<_Tp, _Allocator>::reference
1878deque<_Tp, _Allocator>::at(size_type __i)1222deque<_Tp, _Allocator>::at(size_type __i)
1879{1223{
1880 if (__i >= __base::size())1224 if (__i >= size())
1881 _VSTD::__throw_out_of_range("deque");1225 _VSTD::__throw_out_of_range("deque");
1882 size_type __p = __base::__start_ + __i;1226 size_type __p = __start_ + __i;
1883 return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);1227 return *(*(__map_.begin() + __p / __block_size) + __p % __block_size);
1884}1228}
18851229
1886template <class _Tp, class _Allocator>1230template <class _Tp, class _Allocator>
...@@ -1888,10 +1232,10 @@ inline...@@ -1888,10 +1232,10 @@ inline
1888typename deque<_Tp, _Allocator>::const_reference1232typename deque<_Tp, _Allocator>::const_reference
1889deque<_Tp, _Allocator>::at(size_type __i) const1233deque<_Tp, _Allocator>::at(size_type __i) const
1890{1234{
1891 if (__i >= __base::size())1235 if (__i >= size())
1892 _VSTD::__throw_out_of_range("deque");1236 _VSTD::__throw_out_of_range("deque");
1893 size_type __p = __base::__start_ + __i;1237 size_type __p = __start_ + __i;
1894 return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);1238 return *(*(__map_.begin() + __p / __block_size) + __p % __block_size);
1895}1239}
18961240
1897template <class _Tp, class _Allocator>1241template <class _Tp, class _Allocator>
...@@ -1899,8 +1243,8 @@ inline...@@ -1899,8 +1243,8 @@ inline
1899typename deque<_Tp, _Allocator>::reference1243typename deque<_Tp, _Allocator>::reference
1900deque<_Tp, _Allocator>::front() _NOEXCEPT1244deque<_Tp, _Allocator>::front() _NOEXCEPT
1901{1245{
1902 return *(*(__base::__map_.begin() + __base::__start_ / __base::__block_size)1246 return *(*(__map_.begin() + __start_ / __block_size)
1903 + __base::__start_ % __base::__block_size);1247 + __start_ % __block_size);
1904}1248}
19051249
1906template <class _Tp, class _Allocator>1250template <class _Tp, class _Allocator>
...@@ -1908,8 +1252,8 @@ inline...@@ -1908,8 +1252,8 @@ inline
1908typename deque<_Tp, _Allocator>::const_reference1252typename deque<_Tp, _Allocator>::const_reference
1909deque<_Tp, _Allocator>::front() const _NOEXCEPT1253deque<_Tp, _Allocator>::front() const _NOEXCEPT
1910{1254{
1911 return *(*(__base::__map_.begin() + __base::__start_ / __base::__block_size)1255 return *(*(__map_.begin() + __start_ / __block_size)
1912 + __base::__start_ % __base::__block_size);1256 + __start_ % __block_size);
1913}1257}
19141258
1915template <class _Tp, class _Allocator>1259template <class _Tp, class _Allocator>
...@@ -1917,8 +1261,8 @@ inline...@@ -1917,8 +1261,8 @@ inline
1917typename deque<_Tp, _Allocator>::reference1261typename deque<_Tp, _Allocator>::reference
1918deque<_Tp, _Allocator>::back() _NOEXCEPT1262deque<_Tp, _Allocator>::back() _NOEXCEPT
1919{1263{
1920 size_type __p = __base::size() + __base::__start_ - 1;1264 size_type __p = size() + __start_ - 1;
1921 return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);1265 return *(*(__map_.begin() + __p / __block_size) + __p % __block_size);
1922}1266}
19231267
1924template <class _Tp, class _Allocator>1268template <class _Tp, class _Allocator>
...@@ -1926,33 +1270,33 @@ inline...@@ -1926,33 +1270,33 @@ inline
1926typename deque<_Tp, _Allocator>::const_reference1270typename deque<_Tp, _Allocator>::const_reference
1927deque<_Tp, _Allocator>::back() const _NOEXCEPT1271deque<_Tp, _Allocator>::back() const _NOEXCEPT
1928{1272{
1929 size_type __p = __base::size() + __base::__start_ - 1;1273 size_type __p = size() + __start_ - 1;
1930 return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);1274 return *(*(__map_.begin() + __p / __block_size) + __p % __block_size);
1931}1275}
19321276
1933template <class _Tp, class _Allocator>1277template <class _Tp, class _Allocator>
1934void1278void
1935deque<_Tp, _Allocator>::push_back(const value_type& __v)1279deque<_Tp, _Allocator>::push_back(const value_type& __v)
1936{1280{
1937 allocator_type& __a = __base::__alloc();1281 allocator_type& __a = __alloc();
1938 if (__back_spare() == 0)1282 if (__back_spare() == 0)
1939 __add_back_capacity();1283 __add_back_capacity();
1940 // __back_spare() >= 11284 // __back_spare() >= 1
1941 __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), __v);1285 __alloc_traits::construct(__a, _VSTD::addressof(*end()), __v);
1942 ++__base::size();1286 ++__size();
1943}1287}
19441288
1945template <class _Tp, class _Allocator>1289template <class _Tp, class _Allocator>
1946void1290void
1947deque<_Tp, _Allocator>::push_front(const value_type& __v)1291deque<_Tp, _Allocator>::push_front(const value_type& __v)
1948{1292{
1949 allocator_type& __a = __base::__alloc();1293 allocator_type& __a = __alloc();
1950 if (__front_spare() == 0)1294 if (__front_spare() == 0)
1951 __add_front_capacity();1295 __add_front_capacity();
1952 // __front_spare() >= 11296 // __front_spare() >= 1
1953 __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), __v);1297 __alloc_traits::construct(__a, _VSTD::addressof(*--begin()), __v);
1954 --__base::__start_;1298 --__start_;
1955 ++__base::size();1299 ++__size();
1956}1300}
19571301
1958#ifndef _LIBCPP_CXX03_LANG1302#ifndef _LIBCPP_CXX03_LANG
...@@ -1960,12 +1304,12 @@ template <class _Tp, class _Allocator>...@@ -1960,12 +1304,12 @@ template <class _Tp, class _Allocator>
1960void1304void
1961deque<_Tp, _Allocator>::push_back(value_type&& __v)1305deque<_Tp, _Allocator>::push_back(value_type&& __v)
1962{1306{
1963 allocator_type& __a = __base::__alloc();1307 allocator_type& __a = __alloc();
1964 if (__back_spare() == 0)1308 if (__back_spare() == 0)
1965 __add_back_capacity();1309 __add_back_capacity();
1966 // __back_spare() >= 11310 // __back_spare() >= 1
1967 __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), _VSTD::move(__v));1311 __alloc_traits::construct(__a, _VSTD::addressof(*end()), _VSTD::move(__v));
1968 ++__base::size();1312 ++__size();
1969}1313}
19701314
1971template <class _Tp, class _Allocator>1315template <class _Tp, class _Allocator>
...@@ -1977,15 +1321,15 @@ void...@@ -1977,15 +1321,15 @@ void
1977#endif1321#endif
1978deque<_Tp, _Allocator>::emplace_back(_Args&&... __args)1322deque<_Tp, _Allocator>::emplace_back(_Args&&... __args)
1979{1323{
1980 allocator_type& __a = __base::__alloc();1324 allocator_type& __a = __alloc();
1981 if (__back_spare() == 0)1325 if (__back_spare() == 0)
1982 __add_back_capacity();1326 __add_back_capacity();
1983 // __back_spare() >= 11327 // __back_spare() >= 1
1984 __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()),1328 __alloc_traits::construct(__a, _VSTD::addressof(*end()),
1985 _VSTD::forward<_Args>(__args)...);1329 _VSTD::forward<_Args>(__args)...);
1986 ++__base::size();1330 ++__size();
1987#if _LIBCPP_STD_VER > 141331#if _LIBCPP_STD_VER > 14
1988 return *--__base::end();1332 return *--end();
1989#endif1333#endif
1990}1334}
19911335
...@@ -1993,13 +1337,13 @@ template <class _Tp, class _Allocator>...@@ -1993,13 +1337,13 @@ template <class _Tp, class _Allocator>
1993void1337void
1994deque<_Tp, _Allocator>::push_front(value_type&& __v)1338deque<_Tp, _Allocator>::push_front(value_type&& __v)
1995{1339{
1996 allocator_type& __a = __base::__alloc();1340 allocator_type& __a = __alloc();
1997 if (__front_spare() == 0)1341 if (__front_spare() == 0)
1998 __add_front_capacity();1342 __add_front_capacity();
1999 // __front_spare() >= 11343 // __front_spare() >= 1
2000 __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), _VSTD::move(__v));1344 __alloc_traits::construct(__a, _VSTD::addressof(*--begin()), _VSTD::move(__v));
2001 --__base::__start_;1345 --__start_;
2002 ++__base::size();1346 ++__size();
2003}1347}
20041348
20051349
...@@ -2012,15 +1356,15 @@ void...@@ -2012,15 +1356,15 @@ void
2012#endif1356#endif
2013deque<_Tp, _Allocator>::emplace_front(_Args&&... __args)1357deque<_Tp, _Allocator>::emplace_front(_Args&&... __args)
2014{1358{
2015 allocator_type& __a = __base::__alloc();1359 allocator_type& __a = __alloc();
2016 if (__front_spare() == 0)1360 if (__front_spare() == 0)
2017 __add_front_capacity();1361 __add_front_capacity();
2018 // __front_spare() >= 11362 // __front_spare() >= 1
2019 __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), _VSTD::forward<_Args>(__args)...);1363 __alloc_traits::construct(__a, _VSTD::addressof(*--begin()), _VSTD::forward<_Args>(__args)...);
2020 --__base::__start_;1364 --__start_;
2021 ++__base::size();1365 ++__size();
2022#if _LIBCPP_STD_VER > 141366#if _LIBCPP_STD_VER > 14
2023 return *__base::begin();1367 return *begin();
2024#endif1368#endif
2025}1369}
20261370
...@@ -2028,9 +1372,9 @@ template <class _Tp, class _Allocator>...@@ -2028,9 +1372,9 @@ template <class _Tp, class _Allocator>
2028typename deque<_Tp, _Allocator>::iterator1372typename deque<_Tp, _Allocator>::iterator
2029deque<_Tp, _Allocator>::insert(const_iterator __p, value_type&& __v)1373deque<_Tp, _Allocator>::insert(const_iterator __p, value_type&& __v)
2030{1374{
2031 size_type __pos = __p - __base::begin();1375 size_type __pos = __p - begin();
2032 size_type __to_end = __base::size() - __pos;1376 size_type __to_end = size() - __pos;
2033 allocator_type& __a = __base::__alloc();1377 allocator_type& __a = __alloc();
2034 if (__pos < __to_end)1378 if (__pos < __to_end)
2035 { // insert by shifting things backward1379 { // insert by shifting things backward
2036 if (__front_spare() == 0)1380 if (__front_spare() == 0)
...@@ -2038,17 +1382,17 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, value_type&& __v)...@@ -2038,17 +1382,17 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, value_type&& __v)
2038 // __front_spare() >= 11382 // __front_spare() >= 1
2039 if (__pos == 0)1383 if (__pos == 0)
2040 {1384 {
2041 __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), _VSTD::move(__v));1385 __alloc_traits::construct(__a, _VSTD::addressof(*--begin()), _VSTD::move(__v));
2042 --__base::__start_;1386 --__start_;
2043 ++__base::size();1387 ++__size();
2044 }1388 }
2045 else1389 else
2046 {1390 {
2047 iterator __b = __base::begin();1391 iterator __b = begin();
2048 iterator __bm1 = _VSTD::prev(__b);1392 iterator __bm1 = _VSTD::prev(__b);
2049 __alloc_traits::construct(__a, _VSTD::addressof(*__bm1), _VSTD::move(*__b));1393 __alloc_traits::construct(__a, _VSTD::addressof(*__bm1), _VSTD::move(*__b));
2050 --__base::__start_;1394 --__start_;
2051 ++__base::size();1395 ++__size();
2052 if (__pos > 1)1396 if (__pos > 1)
2053 __b = _VSTD::move(_VSTD::next(__b), __b + __pos, __b);1397 __b = _VSTD::move(_VSTD::next(__b), __b + __pos, __b);
2054 *__b = _VSTD::move(__v);1398 *__b = _VSTD::move(__v);
...@@ -2059,24 +1403,24 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, value_type&& __v)...@@ -2059,24 +1403,24 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, value_type&& __v)
2059 if (__back_spare() == 0)1403 if (__back_spare() == 0)
2060 __add_back_capacity();1404 __add_back_capacity();
2061 // __back_capacity >= 11405 // __back_capacity >= 1
2062 size_type __de = __base::size() - __pos;1406 size_type __de = size() - __pos;
2063 if (__de == 0)1407 if (__de == 0)
2064 {1408 {
2065 __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), _VSTD::move(__v));1409 __alloc_traits::construct(__a, _VSTD::addressof(*end()), _VSTD::move(__v));
2066 ++__base::size();1410 ++__size();
2067 }1411 }
2068 else1412 else
2069 {1413 {
2070 iterator __e = __base::end();1414 iterator __e = end();
2071 iterator __em1 = _VSTD::prev(__e);1415 iterator __em1 = _VSTD::prev(__e);
2072 __alloc_traits::construct(__a, _VSTD::addressof(*__e), _VSTD::move(*__em1));1416 __alloc_traits::construct(__a, _VSTD::addressof(*__e), _VSTD::move(*__em1));
2073 ++__base::size();1417 ++__size();
2074 if (__de > 1)1418 if (__de > 1)
2075 __e = _VSTD::move_backward(__e - __de, __em1, __e);1419 __e = _VSTD::move_backward(__e - __de, __em1, __e);
2076 *--__e = _VSTD::move(__v);1420 *--__e = _VSTD::move(__v);
2077 }1421 }
2078 }1422 }
2079 return __base::begin() + __pos;1423 return begin() + __pos;
2080}1424}
20811425
2082template <class _Tp, class _Allocator>1426template <class _Tp, class _Allocator>
...@@ -2084,9 +1428,9 @@ template <class... _Args>...@@ -2084,9 +1428,9 @@ template <class... _Args>
2084typename deque<_Tp, _Allocator>::iterator1428typename deque<_Tp, _Allocator>::iterator
2085deque<_Tp, _Allocator>::emplace(const_iterator __p, _Args&&... __args)1429deque<_Tp, _Allocator>::emplace(const_iterator __p, _Args&&... __args)
2086{1430{
2087 size_type __pos = __p - __base::begin();1431 size_type __pos = __p - begin();
2088 size_type __to_end = __base::size() - __pos;1432 size_type __to_end = size() - __pos;
2089 allocator_type& __a = __base::__alloc();1433 allocator_type& __a = __alloc();
2090 if (__pos < __to_end)1434 if (__pos < __to_end)
2091 { // insert by shifting things backward1435 { // insert by shifting things backward
2092 if (__front_spare() == 0)1436 if (__front_spare() == 0)
...@@ -2094,18 +1438,18 @@ deque<_Tp, _Allocator>::emplace(const_iterator __p, _Args&&... __args)...@@ -2094,18 +1438,18 @@ deque<_Tp, _Allocator>::emplace(const_iterator __p, _Args&&... __args)
2094 // __front_spare() >= 11438 // __front_spare() >= 1
2095 if (__pos == 0)1439 if (__pos == 0)
2096 {1440 {
2097 __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), _VSTD::forward<_Args>(__args)...);1441 __alloc_traits::construct(__a, _VSTD::addressof(*--begin()), _VSTD::forward<_Args>(__args)...);
2098 --__base::__start_;1442 --__start_;
2099 ++__base::size();1443 ++__size();
2100 }1444 }
2101 else1445 else
2102 {1446 {
2103 __temp_value<value_type, _Allocator> __tmp(this->__alloc(), _VSTD::forward<_Args>(__args)...);1447 __temp_value<value_type, _Allocator> __tmp(__alloc(), _VSTD::forward<_Args>(__args)...);
2104 iterator __b = __base::begin();1448 iterator __b = begin();
2105 iterator __bm1 = _VSTD::prev(__b);1449 iterator __bm1 = _VSTD::prev(__b);
2106 __alloc_traits::construct(__a, _VSTD::addressof(*__bm1), _VSTD::move(*__b));1450 __alloc_traits::construct(__a, _VSTD::addressof(*__bm1), _VSTD::move(*__b));
2107 --__base::__start_;1451 --__start_;
2108 ++__base::size();1452 ++__size();
2109 if (__pos > 1)1453 if (__pos > 1)
2110 __b = _VSTD::move(_VSTD::next(__b), __b + __pos, __b);1454 __b = _VSTD::move(_VSTD::next(__b), __b + __pos, __b);
2111 *__b = _VSTD::move(__tmp.get());1455 *__b = _VSTD::move(__tmp.get());
...@@ -2116,25 +1460,25 @@ deque<_Tp, _Allocator>::emplace(const_iterator __p, _Args&&... __args)...@@ -2116,25 +1460,25 @@ deque<_Tp, _Allocator>::emplace(const_iterator __p, _Args&&... __args)
2116 if (__back_spare() == 0)1460 if (__back_spare() == 0)
2117 __add_back_capacity();1461 __add_back_capacity();
2118 // __back_capacity >= 11462 // __back_capacity >= 1
2119 size_type __de = __base::size() - __pos;1463 size_type __de = size() - __pos;
2120 if (__de == 0)1464 if (__de == 0)
2121 {1465 {
2122 __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), _VSTD::forward<_Args>(__args)...);1466 __alloc_traits::construct(__a, _VSTD::addressof(*end()), _VSTD::forward<_Args>(__args)...);
2123 ++__base::size();1467 ++__size();
2124 }1468 }
2125 else1469 else
2126 {1470 {
2127 __temp_value<value_type, _Allocator> __tmp(this->__alloc(), _VSTD::forward<_Args>(__args)...);1471 __temp_value<value_type, _Allocator> __tmp(__alloc(), _VSTD::forward<_Args>(__args)...);
2128 iterator __e = __base::end();1472 iterator __e = end();
2129 iterator __em1 = _VSTD::prev(__e);1473 iterator __em1 = _VSTD::prev(__e);
2130 __alloc_traits::construct(__a, _VSTD::addressof(*__e), _VSTD::move(*__em1));1474 __alloc_traits::construct(__a, _VSTD::addressof(*__e), _VSTD::move(*__em1));
2131 ++__base::size();1475 ++__size();
2132 if (__de > 1)1476 if (__de > 1)
2133 __e = _VSTD::move_backward(__e - __de, __em1, __e);1477 __e = _VSTD::move_backward(__e - __de, __em1, __e);
2134 *--__e = _VSTD::move(__tmp.get());1478 *--__e = _VSTD::move(__tmp.get());
2135 }1479 }
2136 }1480 }
2137 return __base::begin() + __pos;1481 return begin() + __pos;
2138}1482}
21391483
2140#endif // _LIBCPP_CXX03_LANG1484#endif // _LIBCPP_CXX03_LANG
...@@ -2144,9 +1488,9 @@ template <class _Tp, class _Allocator>...@@ -2144,9 +1488,9 @@ template <class _Tp, class _Allocator>
2144typename deque<_Tp, _Allocator>::iterator1488typename deque<_Tp, _Allocator>::iterator
2145deque<_Tp, _Allocator>::insert(const_iterator __p, const value_type& __v)1489deque<_Tp, _Allocator>::insert(const_iterator __p, const value_type& __v)
2146{1490{
2147 size_type __pos = __p - __base::begin();1491 size_type __pos = __p - begin();
2148 size_type __to_end = __base::size() - __pos;1492 size_type __to_end = size() - __pos;
2149 allocator_type& __a = __base::__alloc();1493 allocator_type& __a = __alloc();
2150 if (__pos < __to_end)1494 if (__pos < __to_end)
2151 { // insert by shifting things backward1495 { // insert by shifting things backward
2152 if (__front_spare() == 0)1496 if (__front_spare() == 0)
...@@ -2154,20 +1498,20 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, const value_type& __v)...@@ -2154,20 +1498,20 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, const value_type& __v)
2154 // __front_spare() >= 11498 // __front_spare() >= 1
2155 if (__pos == 0)1499 if (__pos == 0)
2156 {1500 {
2157 __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), __v);1501 __alloc_traits::construct(__a, _VSTD::addressof(*--begin()), __v);
2158 --__base::__start_;1502 --__start_;
2159 ++__base::size();1503 ++__size();
2160 }1504 }
2161 else1505 else
2162 {1506 {
2163 const_pointer __vt = pointer_traits<const_pointer>::pointer_to(__v);1507 const_pointer __vt = pointer_traits<const_pointer>::pointer_to(__v);
2164 iterator __b = __base::begin();1508 iterator __b = begin();
2165 iterator __bm1 = _VSTD::prev(__b);1509 iterator __bm1 = _VSTD::prev(__b);
2166 if (__vt == pointer_traits<const_pointer>::pointer_to(*__b))1510 if (__vt == pointer_traits<const_pointer>::pointer_to(*__b))
2167 __vt = pointer_traits<const_pointer>::pointer_to(*__bm1);1511 __vt = pointer_traits<const_pointer>::pointer_to(*__bm1);
2168 __alloc_traits::construct(__a, _VSTD::addressof(*__bm1), _VSTD::move(*__b));1512 __alloc_traits::construct(__a, _VSTD::addressof(*__bm1), _VSTD::move(*__b));
2169 --__base::__start_;1513 --__start_;
2170 ++__base::size();1514 ++__size();
2171 if (__pos > 1)1515 if (__pos > 1)
2172 __b = __move_and_check(_VSTD::next(__b), __b + __pos, __b, __vt);1516 __b = __move_and_check(_VSTD::next(__b), __b + __pos, __b, __vt);
2173 *__b = *__vt;1517 *__b = *__vt;
...@@ -2178,46 +1522,46 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, const value_type& __v)...@@ -2178,46 +1522,46 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, const value_type& __v)
2178 if (__back_spare() == 0)1522 if (__back_spare() == 0)
2179 __add_back_capacity();1523 __add_back_capacity();
2180 // __back_capacity >= 11524 // __back_capacity >= 1
2181 size_type __de = __base::size() - __pos;1525 size_type __de = size() - __pos;
2182 if (__de == 0)1526 if (__de == 0)
2183 {1527 {
2184 __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), __v);1528 __alloc_traits::construct(__a, _VSTD::addressof(*end()), __v);
2185 ++__base::size();1529 ++__size();
2186 }1530 }
2187 else1531 else
2188 {1532 {
2189 const_pointer __vt = pointer_traits<const_pointer>::pointer_to(__v);1533 const_pointer __vt = pointer_traits<const_pointer>::pointer_to(__v);
2190 iterator __e = __base::end();1534 iterator __e = end();
2191 iterator __em1 = _VSTD::prev(__e);1535 iterator __em1 = _VSTD::prev(__e);
2192 if (__vt == pointer_traits<const_pointer>::pointer_to(*__em1))1536 if (__vt == pointer_traits<const_pointer>::pointer_to(*__em1))
2193 __vt = pointer_traits<const_pointer>::pointer_to(*__e);1537 __vt = pointer_traits<const_pointer>::pointer_to(*__e);
2194 __alloc_traits::construct(__a, _VSTD::addressof(*__e), _VSTD::move(*__em1));1538 __alloc_traits::construct(__a, _VSTD::addressof(*__e), _VSTD::move(*__em1));
2195 ++__base::size();1539 ++__size();
2196 if (__de > 1)1540 if (__de > 1)
2197 __e = __move_backward_and_check(__e - __de, __em1, __e, __vt);1541 __e = __move_backward_and_check(__e - __de, __em1, __e, __vt);
2198 *--__e = *__vt;1542 *--__e = *__vt;
2199 }1543 }
2200 }1544 }
2201 return __base::begin() + __pos;1545 return begin() + __pos;
2202}1546}
22031547
2204template <class _Tp, class _Allocator>1548template <class _Tp, class _Allocator>
2205typename deque<_Tp, _Allocator>::iterator1549typename deque<_Tp, _Allocator>::iterator
2206deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_type& __v)1550deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_type& __v)
2207{1551{
2208 size_type __pos = __p - __base::begin();1552 size_type __pos = __p - begin();
2209 size_type __to_end = __base::size() - __pos;1553 size_type __to_end = __size() - __pos;
2210 allocator_type& __a = __base::__alloc();1554 allocator_type& __a = __alloc();
2211 if (__pos < __to_end)1555 if (__pos < __to_end)
2212 { // insert by shifting things backward1556 { // insert by shifting things backward
2213 if (__n > __front_spare())1557 if (__n > __front_spare())
2214 __add_front_capacity(__n - __front_spare());1558 __add_front_capacity(__n - __front_spare());
2215 // __n <= __front_spare()1559 // __n <= __front_spare()
2216 iterator __old_begin = __base::begin();1560 iterator __old_begin = begin();
2217 iterator __i = __old_begin;1561 iterator __i = __old_begin;
2218 if (__n > __pos)1562 if (__n > __pos)
2219 {1563 {
2220 for (size_type __m = __n - __pos; __m; --__m, --__base::__start_, ++__base::size())1564 for (size_type __m = __n - __pos; __m; --__m, --__start_, ++__size())
2221 __alloc_traits::construct(__a, _VSTD::addressof(*--__i), __v);1565 __alloc_traits::construct(__a, _VSTD::addressof(*--__i), __v);
2222 __n = __pos;1566 __n = __pos;
2223 }1567 }
...@@ -2237,12 +1581,12 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_ty...@@ -2237,12 +1581,12 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_ty
2237 if (__n > __back_capacity)1581 if (__n > __back_capacity)
2238 __add_back_capacity(__n - __back_capacity);1582 __add_back_capacity(__n - __back_capacity);
2239 // __n <= __back_capacity1583 // __n <= __back_capacity
2240 iterator __old_end = __base::end();1584 iterator __old_end = end();
2241 iterator __i = __old_end;1585 iterator __i = __old_end;
2242 size_type __de = __base::size() - __pos;1586 size_type __de = size() - __pos;
2243 if (__n > __de)1587 if (__n > __de)
2244 {1588 {
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())
2246 __alloc_traits::construct(__a, _VSTD::addressof(*__i), __v);1590 __alloc_traits::construct(__a, _VSTD::addressof(*__i), __v);
2247 __n = __de;1591 __n = __de;
2248 }1592 }
...@@ -2256,7 +1600,7 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_ty...@@ -2256,7 +1600,7 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_ty
2256 _VSTD::fill_n(__old_end - __n, __n, *__vt);1600 _VSTD::fill_n(__old_end - __n, __n, *__vt);
2257 }1601 }
2258 }1602 }
2259 return __base::begin() + __pos;1603 return begin() + __pos;
2260}1604}
22611605
2262template <class _Tp, class _Allocator>1606template <class _Tp, class _Allocator>
...@@ -2265,7 +1609,7 @@ typename deque<_Tp, _Allocator>::iterator...@@ -2265,7 +1609,7 @@ typename deque<_Tp, _Allocator>::iterator
2265deque<_Tp, _Allocator>::insert(const_iterator __p, _InputIter __f, _InputIter __l,1609deque<_Tp, _Allocator>::insert(const_iterator __p, _InputIter __f, _InputIter __l,
2266 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIter>::value>::type*)1610 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIter>::value>::type*)
2267{1611{
2268 __split_buffer<value_type, allocator_type&> __buf(__base::__alloc());1612 __split_buffer<value_type, allocator_type&> __buf(__alloc());
2269 __buf.__construct_at_end(__f, __l);1613 __buf.__construct_at_end(__f, __l);
2270 typedef typename __split_buffer<value_type, allocator_type&>::iterator __bi;1614 typedef typename __split_buffer<value_type, allocator_type&>::iterator __bi;
2271 return insert(__p, move_iterator<__bi>(__buf.begin()), move_iterator<__bi>(__buf.end()));1615 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...@@ -2278,7 +1622,7 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _ForwardIterator __f, _Forwar
2278 typename enable_if<__is_exactly_cpp17_forward_iterator<_ForwardIterator>::value>::type*)1622 typename enable_if<__is_exactly_cpp17_forward_iterator<_ForwardIterator>::value>::type*)
2279{1623{
2280 size_type __n = _VSTD::distance(__f, __l);1624 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());
2282 __buf.__construct_at_end(__f, __l);1626 __buf.__construct_at_end(__f, __l);
2283 typedef typename __split_buffer<value_type, allocator_type&>::iterator __fwd;1627 typedef typename __split_buffer<value_type, allocator_type&>::iterator __fwd;
2284 return insert(__p, move_iterator<__fwd>(__buf.begin()), move_iterator<__fwd>(__buf.end()));1628 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,...@@ -2291,21 +1635,21 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l,
2291 typename enable_if<__is_cpp17_bidirectional_iterator<_BiIter>::value>::type*)1635 typename enable_if<__is_cpp17_bidirectional_iterator<_BiIter>::value>::type*)
2292{1636{
2293 size_type __n = _VSTD::distance(__f, __l);1637 size_type __n = _VSTD::distance(__f, __l);
2294 size_type __pos = __p - __base::begin();1638 size_type __pos = __p - begin();
2295 size_type __to_end = __base::size() - __pos;1639 size_type __to_end = size() - __pos;
2296 allocator_type& __a = __base::__alloc();1640 allocator_type& __a = __alloc();
2297 if (__pos < __to_end)1641 if (__pos < __to_end)
2298 { // insert by shifting things backward1642 { // insert by shifting things backward
2299 if (__n > __front_spare())1643 if (__n > __front_spare())
2300 __add_front_capacity(__n - __front_spare());1644 __add_front_capacity(__n - __front_spare());
2301 // __n <= __front_spare()1645 // __n <= __front_spare()
2302 iterator __old_begin = __base::begin();1646 iterator __old_begin = begin();
2303 iterator __i = __old_begin;1647 iterator __i = __old_begin;
2304 _BiIter __m = __f;1648 _BiIter __m = __f;
2305 if (__n > __pos)1649 if (__n > __pos)
2306 {1650 {
2307 __m = __pos < __n / 2 ? _VSTD::prev(__l, __pos) : _VSTD::next(__f, __n - __pos);1651 __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())
2309 __alloc_traits::construct(__a, _VSTD::addressof(*--__i), *--__j);1653 __alloc_traits::construct(__a, _VSTD::addressof(*--__i), *--__j);
2310 __n = __pos;1654 __n = __pos;
2311 }1655 }
...@@ -2315,8 +1659,8 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l,...@@ -2315,8 +1659,8 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l,
2315 for (iterator __j = __obn; __j != __old_begin;)1659 for (iterator __j = __obn; __j != __old_begin;)
2316 {1660 {
2317 __alloc_traits::construct(__a, _VSTD::addressof(*--__i), _VSTD::move(*--__j));1661 __alloc_traits::construct(__a, _VSTD::addressof(*--__i), _VSTD::move(*--__j));
2318 --__base::__start_;1662 --__start_;
2319 ++__base::size();1663 ++__size();
2320 }1664 }
2321 if (__n < __pos)1665 if (__n < __pos)
2322 __old_begin = _VSTD::move(__obn, __old_begin + __pos, __old_begin);1666 __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,...@@ -2329,28 +1673,28 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l,
2329 if (__n > __back_capacity)1673 if (__n > __back_capacity)
2330 __add_back_capacity(__n - __back_capacity);1674 __add_back_capacity(__n - __back_capacity);
2331 // __n <= __back_capacity1675 // __n <= __back_capacity
2332 iterator __old_end = __base::end();1676 iterator __old_end = end();
2333 iterator __i = __old_end;1677 iterator __i = __old_end;
2334 _BiIter __m = __l;1678 _BiIter __m = __l;
2335 size_type __de = __base::size() - __pos;1679 size_type __de = size() - __pos;
2336 if (__n > __de)1680 if (__n > __de)
2337 {1681 {
2338 __m = __de < __n / 2 ? _VSTD::next(__f, __de) : _VSTD::prev(__l, __n - __de);1682 __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())
2340 __alloc_traits::construct(__a, _VSTD::addressof(*__i), *__j);1684 __alloc_traits::construct(__a, _VSTD::addressof(*__i), *__j);
2341 __n = __de;1685 __n = __de;
2342 }1686 }
2343 if (__n > 0)1687 if (__n > 0)
2344 {1688 {
2345 iterator __oen = __old_end - __n;1689 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())
2347 __alloc_traits::construct(__a, _VSTD::addressof(*__i), _VSTD::move(*__j));1691 __alloc_traits::construct(__a, _VSTD::addressof(*__i), _VSTD::move(*__j));
2348 if (__n < __de)1692 if (__n < __de)
2349 __old_end = _VSTD::move_backward(__old_end - __de, __oen, __old_end);1693 __old_end = _VSTD::move_backward(__old_end - __de, __oen, __old_end);
2350 _VSTD::copy_backward(__f, __m, __old_end);1694 _VSTD::copy_backward(__f, __m, __old_end);
2351 }1695 }
2352 }1696 }
2353 return __base::begin() + __pos;1697 return begin() + __pos;
2354}1698}
23551699
2356template <class _Tp, class _Allocator>1700template <class _Tp, class _Allocator>
...@@ -2374,12 +1718,12 @@ deque<_Tp, _Allocator>::__append(_ForIter __f, _ForIter __l,...@@ -2374,12 +1718,12 @@ deque<_Tp, _Allocator>::__append(_ForIter __f, _ForIter __l,
2374 typename enable_if<__is_cpp17_forward_iterator<_ForIter>::value>::type*)1718 typename enable_if<__is_cpp17_forward_iterator<_ForIter>::value>::type*)
2375{1719{
2376 size_type __n = _VSTD::distance(__f, __l);1720 size_type __n = _VSTD::distance(__f, __l);
2377 allocator_type& __a = __base::__alloc();1721 allocator_type& __a = __alloc();
2378 size_type __back_capacity = __back_spare();1722 size_type __back_capacity = __back_spare();
2379 if (__n > __back_capacity)1723 if (__n > __back_capacity)
2380 __add_back_capacity(__n - __back_capacity);1724 __add_back_capacity(__n - __back_capacity);
2381 // __n <= __back_capacity1725 // __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)) {
2383 _ConstructTransaction __tx(this, __br);1727 _ConstructTransaction __tx(this, __br);
2384 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void)++__f) {1728 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void)++__f) {
2385 __alloc_traits::construct(__a, _VSTD::__to_address(__tx.__pos_), *__f);1729 __alloc_traits::construct(__a, _VSTD::__to_address(__tx.__pos_), *__f);
...@@ -2391,12 +1735,12 @@ template <class _Tp, class _Allocator>...@@ -2391,12 +1735,12 @@ template <class _Tp, class _Allocator>
2391void1735void
2392deque<_Tp, _Allocator>::__append(size_type __n)1736deque<_Tp, _Allocator>::__append(size_type __n)
2393{1737{
2394 allocator_type& __a = __base::__alloc();1738 allocator_type& __a = __alloc();
2395 size_type __back_capacity = __back_spare();1739 size_type __back_capacity = __back_spare();
2396 if (__n > __back_capacity)1740 if (__n > __back_capacity)
2397 __add_back_capacity(__n - __back_capacity);1741 __add_back_capacity(__n - __back_capacity);
2398 // __n <= __back_capacity1742 // __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)) {
2400 _ConstructTransaction __tx(this, __br);1744 _ConstructTransaction __tx(this, __br);
2401 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {1745 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
2402 __alloc_traits::construct(__a, _VSTD::__to_address(__tx.__pos_));1746 __alloc_traits::construct(__a, _VSTD::__to_address(__tx.__pos_));
...@@ -2408,12 +1752,12 @@ template <class _Tp, class _Allocator>...@@ -2408,12 +1752,12 @@ template <class _Tp, class _Allocator>
2408void1752void
2409deque<_Tp, _Allocator>::__append(size_type __n, const value_type& __v)1753deque<_Tp, _Allocator>::__append(size_type __n, const value_type& __v)
2410{1754{
2411 allocator_type& __a = __base::__alloc();1755 allocator_type& __a = __alloc();
2412 size_type __back_capacity = __back_spare();1756 size_type __back_capacity = __back_spare();
2413 if (__n > __back_capacity)1757 if (__n > __back_capacity)
2414 __add_back_capacity(__n - __back_capacity);1758 __add_back_capacity(__n - __back_capacity);
2415 // __n <= __back_capacity1759 // __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)) {
2417 _ConstructTransaction __tx(this, __br);1761 _ConstructTransaction __tx(this, __br);
2418 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {1762 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
2419 __alloc_traits::construct(__a, _VSTD::__to_address(__tx.__pos_), __v);1763 __alloc_traits::construct(__a, _VSTD::__to_address(__tx.__pos_), __v);
...@@ -2428,57 +1772,57 @@ template <class _Tp, class _Allocator>...@@ -2428,57 +1772,57 @@ template <class _Tp, class _Allocator>
2428void1772void
2429deque<_Tp, _Allocator>::__add_front_capacity()1773deque<_Tp, _Allocator>::__add_front_capacity()
2430{1774{
2431 allocator_type& __a = __base::__alloc();1775 allocator_type& __a = __alloc();
2432 if (__back_spare() >= __base::__block_size)1776 if (__back_spare() >= __block_size)
2433 {1777 {
2434 __base::__start_ += __base::__block_size;1778 __start_ += __block_size;
2435 pointer __pt = __base::__map_.back();1779 pointer __pt = __map_.back();
2436 __base::__map_.pop_back();1780 __map_.pop_back();
2437 __base::__map_.push_front(__pt);1781 __map_.push_front(__pt);
2438 }1782 }
2439 // Else if __base::__map_.size() < __base::__map_.capacity() then we need to allocate 1 buffer1783 // Else if __map_.size() < __map_.capacity() then we need to allocate 1 buffer
2440 else if (__base::__map_.size() < __base::__map_.capacity())1784 else if (__map_.size() < __map_.capacity())
2441 { // we can put the new buffer into the map, but don't shift things around1785 { // we can put the new buffer into the map, but don't shift things around
2442 // until all buffers are allocated. If we throw, we don't need to fix1786 // until all buffers are allocated. If we throw, we don't need to fix
2443 // anything up (any added buffers are undetectible)1787 // anything up (any added buffers are undetectible)
2444 if (__base::__map_.__front_spare() > 0)1788 if (__map_.__front_spare() > 0)
2445 __base::__map_.push_front(__alloc_traits::allocate(__a, __base::__block_size));1789 __map_.push_front(__alloc_traits::allocate(__a, __block_size));
2446 else1790 else
2447 {1791 {
2448 __base::__map_.push_back(__alloc_traits::allocate(__a, __base::__block_size));1792 __map_.push_back(__alloc_traits::allocate(__a, __block_size));
2449 // Done allocating, reorder capacity1793 // Done allocating, reorder capacity
2450 pointer __pt = __base::__map_.back();1794 pointer __pt = __map_.back();
2451 __base::__map_.pop_back();1795 __map_.pop_back();
2452 __base::__map_.push_front(__pt);1796 __map_.push_front(__pt);
2453 }1797 }
2454 __base::__start_ = __base::__map_.size() == 1 ?1798 __start_ = __map_.size() == 1 ?
2455 __base::__block_size / 2 :1799 __block_size / 2 :
2456 __base::__start_ + __base::__block_size;1800 __start_ + __block_size;
2457 }1801 }
2458 // Else need to allocate 1 buffer, *and* we need to reallocate __map_.1802 // Else need to allocate 1 buffer, *and* we need to reallocate __map_.
2459 else1803 else
2460 {1804 {
2461 __split_buffer<pointer, typename __base::__pointer_allocator&>1805 __split_buffer<pointer, __pointer_allocator&>
2462 __buf(max<size_type>(2 * __base::__map_.capacity(), 1),1806 __buf(std::max<size_type>(2 * __map_.capacity(), 1),
2463 0, __base::__map_.__alloc());1807 0, __map_.__alloc());
24641808
2465 typedef __allocator_destructor<_Allocator> _Dp;1809 typedef __allocator_destructor<_Allocator> _Dp;
2466 unique_ptr<pointer, _Dp> __hold(1810 unique_ptr<pointer, _Dp> __hold(
2467 __alloc_traits::allocate(__a, __base::__block_size),1811 __alloc_traits::allocate(__a, __block_size),
2468 _Dp(__a, __base::__block_size));1812 _Dp(__a, __block_size));
2469 __buf.push_back(__hold.get());1813 __buf.push_back(__hold.get());
2470 __hold.release();1814 __hold.release();
24711815
2472 for (typename __base::__map_pointer __i = __base::__map_.begin();1816 for (__map_pointer __i = __map_.begin();
2473 __i != __base::__map_.end(); ++__i)1817 __i != __map_.end(); ++__i)
2474 __buf.push_back(*__i);1818 __buf.push_back(*__i);
2475 _VSTD::swap(__base::__map_.__first_, __buf.__first_);1819 _VSTD::swap(__map_.__first_, __buf.__first_);
2476 _VSTD::swap(__base::__map_.__begin_, __buf.__begin_);1820 _VSTD::swap(__map_.__begin_, __buf.__begin_);
2477 _VSTD::swap(__base::__map_.__end_, __buf.__end_);1821 _VSTD::swap(__map_.__end_, __buf.__end_);
2478 _VSTD::swap(__base::__map_.__end_cap(), __buf.__end_cap());1822 _VSTD::swap(__map_.__end_cap(), __buf.__end_cap());
2479 __base::__start_ = __base::__map_.size() == 1 ?1823 __start_ = __map_.size() == 1 ?
2480 __base::__block_size / 2 :1824 __block_size / 2 :
2481 __base::__start_ + __base::__block_size;1825 __start_ + __block_size;
2482 }1826 }
2483}1827}
24841828
...@@ -2488,82 +1832,82 @@ template <class _Tp, class _Allocator>...@@ -2488,82 +1832,82 @@ template <class _Tp, class _Allocator>
2488void1832void
2489deque<_Tp, _Allocator>::__add_front_capacity(size_type __n)1833deque<_Tp, _Allocator>::__add_front_capacity(size_type __n)
2490{1834{
2491 allocator_type& __a = __base::__alloc();1835 allocator_type& __a = __alloc();
2492 size_type __nb = __recommend_blocks(__n + __base::__map_.empty());1836 size_type __nb = __recommend_blocks(__n + __map_.empty());
2493 // Number of unused blocks at back:1837 // 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;
2495 __back_capacity = _VSTD::min(__back_capacity, __nb); // don't take more than you need1839 __back_capacity = _VSTD::min(__back_capacity, __nb); // don't take more than you need
2496 __nb -= __back_capacity; // number of blocks need to allocate1840 __nb -= __back_capacity; // number of blocks need to allocate
2497 // If __nb == 0, then we have sufficient capacity.1841 // If __nb == 0, then we have sufficient capacity.
2498 if (__nb == 0)1842 if (__nb == 0)
2499 {1843 {
2500 __base::__start_ += __base::__block_size * __back_capacity;1844 __start_ += __block_size * __back_capacity;
2501 for (; __back_capacity > 0; --__back_capacity)1845 for (; __back_capacity > 0; --__back_capacity)
2502 {1846 {
2503 pointer __pt = __base::__map_.back();1847 pointer __pt = __map_.back();
2504 __base::__map_.pop_back();1848 __map_.pop_back();
2505 __base::__map_.push_front(__pt);1849 __map_.push_front(__pt);
2506 }1850 }
2507 }1851 }
2508 // Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers1852 // 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())
2510 { // we can put the new buffers into the map, but don't shift things around1854 { // we can put the new buffers into the map, but don't shift things around
2511 // until all buffers are allocated. If we throw, we don't need to fix1855 // until all buffers are allocated. If we throw, we don't need to fix
2512 // anything up (any added buffers are undetectible)1856 // 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))
2514 {1858 {
2515 if (__base::__map_.__front_spare() == 0)1859 if (__map_.__front_spare() == 0)
2516 break;1860 break;
2517 __base::__map_.push_front(__alloc_traits::allocate(__a, __base::__block_size));1861 __map_.push_front(__alloc_traits::allocate(__a, __block_size));
2518 }1862 }
2519 for (; __nb > 0; --__nb, ++__back_capacity)1863 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));
2521 // Done allocating, reorder capacity1865 // Done allocating, reorder capacity
2522 __base::__start_ += __back_capacity * __base::__block_size;1866 __start_ += __back_capacity * __block_size;
2523 for (; __back_capacity > 0; --__back_capacity)1867 for (; __back_capacity > 0; --__back_capacity)
2524 {1868 {
2525 pointer __pt = __base::__map_.back();1869 pointer __pt = __map_.back();
2526 __base::__map_.pop_back();1870 __map_.pop_back();
2527 __base::__map_.push_front(__pt);1871 __map_.push_front(__pt);
2528 }1872 }
2529 }1873 }
2530 // Else need to allocate __nb buffers, *and* we need to reallocate __map_.1874 // Else need to allocate __nb buffers, *and* we need to reallocate __map_.
2531 else1875 else
2532 {1876 {
2533 size_type __ds = (__nb + __back_capacity) * __base::__block_size - __base::__map_.empty();1877 size_type __ds = (__nb + __back_capacity) * __block_size - __map_.empty();
2534 __split_buffer<pointer, typename __base::__pointer_allocator&>1878 __split_buffer<pointer, __pointer_allocator&>
2535 __buf(max<size_type>(2* __base::__map_.capacity(),1879 __buf(std::max<size_type>(2* __map_.capacity(),
2536 __nb + __base::__map_.size()),1880 __nb + __map_.size()),
2537 0, __base::__map_.__alloc());1881 0, __map_.__alloc());
2538#ifndef _LIBCPP_NO_EXCEPTIONS1882#ifndef _LIBCPP_NO_EXCEPTIONS
2539 try1883 try
2540 {1884 {
2541#endif // _LIBCPP_NO_EXCEPTIONS1885#endif // _LIBCPP_NO_EXCEPTIONS
2542 for (; __nb > 0; --__nb)1886 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));
2544#ifndef _LIBCPP_NO_EXCEPTIONS1888#ifndef _LIBCPP_NO_EXCEPTIONS
2545 }1889 }
2546 catch (...)1890 catch (...)
2547 {1891 {
2548 for (typename __base::__map_pointer __i = __buf.begin();1892 for (__map_pointer __i = __buf.begin();
2549 __i != __buf.end(); ++__i)1893 __i != __buf.end(); ++__i)
2550 __alloc_traits::deallocate(__a, *__i, __base::__block_size);1894 __alloc_traits::deallocate(__a, *__i, __block_size);
2551 throw;1895 throw;
2552 }1896 }
2553#endif // _LIBCPP_NO_EXCEPTIONS1897#endif // _LIBCPP_NO_EXCEPTIONS
2554 for (; __back_capacity > 0; --__back_capacity)1898 for (; __back_capacity > 0; --__back_capacity)
2555 {1899 {
2556 __buf.push_back(__base::__map_.back());1900 __buf.push_back(__map_.back());
2557 __base::__map_.pop_back();1901 __map_.pop_back();
2558 }1902 }
2559 for (typename __base::__map_pointer __i = __base::__map_.begin();1903 for (__map_pointer __i = __map_.begin();
2560 __i != __base::__map_.end(); ++__i)1904 __i != __map_.end(); ++__i)
2561 __buf.push_back(*__i);1905 __buf.push_back(*__i);
2562 _VSTD::swap(__base::__map_.__first_, __buf.__first_);1906 _VSTD::swap(__map_.__first_, __buf.__first_);
2563 _VSTD::swap(__base::__map_.__begin_, __buf.__begin_);1907 _VSTD::swap(__map_.__begin_, __buf.__begin_);
2564 _VSTD::swap(__base::__map_.__end_, __buf.__end_);1908 _VSTD::swap(__map_.__end_, __buf.__end_);
2565 _VSTD::swap(__base::__map_.__end_cap(), __buf.__end_cap());1909 _VSTD::swap(__map_.__end_cap(), __buf.__end_cap());
2566 __base::__start_ += __ds;1910 __start_ += __ds;
2567 }1911 }
2568}1912}
25691913
...@@ -2573,52 +1917,52 @@ template <class _Tp, class _Allocator>...@@ -2573,52 +1917,52 @@ template <class _Tp, class _Allocator>
2573void1917void
2574deque<_Tp, _Allocator>::__add_back_capacity()1918deque<_Tp, _Allocator>::__add_back_capacity()
2575{1919{
2576 allocator_type& __a = __base::__alloc();1920 allocator_type& __a = __alloc();
2577 if (__front_spare() >= __base::__block_size)1921 if (__front_spare() >= __block_size)
2578 {1922 {
2579 __base::__start_ -= __base::__block_size;1923 __start_ -= __block_size;
2580 pointer __pt = __base::__map_.front();1924 pointer __pt = __map_.front();
2581 __base::__map_.pop_front();1925 __map_.pop_front();
2582 __base::__map_.push_back(__pt);1926 __map_.push_back(__pt);
2583 }1927 }
2584 // Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers1928 // 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())
2586 { // we can put the new buffer into the map, but don't shift things around1930 { // we can put the new buffer into the map, but don't shift things around
2587 // until it is allocated. If we throw, we don't need to fix1931 // until it is allocated. If we throw, we don't need to fix
2588 // anything up (any added buffers are undetectible)1932 // anything up (any added buffers are undetectible)
2589 if (__base::__map_.__back_spare() != 0)1933 if (__map_.__back_spare() != 0)
2590 __base::__map_.push_back(__alloc_traits::allocate(__a, __base::__block_size));1934 __map_.push_back(__alloc_traits::allocate(__a, __block_size));
2591 else1935 else
2592 {1936 {
2593 __base::__map_.push_front(__alloc_traits::allocate(__a, __base::__block_size));1937 __map_.push_front(__alloc_traits::allocate(__a, __block_size));
2594 // Done allocating, reorder capacity1938 // Done allocating, reorder capacity
2595 pointer __pt = __base::__map_.front();1939 pointer __pt = __map_.front();
2596 __base::__map_.pop_front();1940 __map_.pop_front();
2597 __base::__map_.push_back(__pt);1941 __map_.push_back(__pt);
2598 }1942 }
2599 }1943 }
2600 // Else need to allocate 1 buffer, *and* we need to reallocate __map_.1944 // Else need to allocate 1 buffer, *and* we need to reallocate __map_.
2601 else1945 else
2602 {1946 {
2603 __split_buffer<pointer, typename __base::__pointer_allocator&>1947 __split_buffer<pointer, __pointer_allocator&>
2604 __buf(max<size_type>(2* __base::__map_.capacity(), 1),1948 __buf(std::max<size_type>(2* __map_.capacity(), 1),
2605 __base::__map_.size(),1949 __map_.size(),
2606 __base::__map_.__alloc());1950 __map_.__alloc());
26071951
2608 typedef __allocator_destructor<_Allocator> _Dp;1952 typedef __allocator_destructor<_Allocator> _Dp;
2609 unique_ptr<pointer, _Dp> __hold(1953 unique_ptr<pointer, _Dp> __hold(
2610 __alloc_traits::allocate(__a, __base::__block_size),1954 __alloc_traits::allocate(__a, __block_size),
2611 _Dp(__a, __base::__block_size));1955 _Dp(__a, __block_size));
2612 __buf.push_back(__hold.get());1956 __buf.push_back(__hold.get());
2613 __hold.release();1957 __hold.release();
26141958
2615 for (typename __base::__map_pointer __i = __base::__map_.end();1959 for (__map_pointer __i = __map_.end();
2616 __i != __base::__map_.begin();)1960 __i != __map_.begin();)
2617 __buf.push_front(*--__i);1961 __buf.push_front(*--__i);
2618 _VSTD::swap(__base::__map_.__first_, __buf.__first_);1962 _VSTD::swap(__map_.__first_, __buf.__first_);
2619 _VSTD::swap(__base::__map_.__begin_, __buf.__begin_);1963 _VSTD::swap(__map_.__begin_, __buf.__begin_);
2620 _VSTD::swap(__base::__map_.__end_, __buf.__end_);1964 _VSTD::swap(__map_.__end_, __buf.__end_);
2621 _VSTD::swap(__base::__map_.__end_cap(), __buf.__end_cap());1965 _VSTD::swap(__map_.__end_cap(), __buf.__end_cap());
2622 }1966 }
2623}1967}
26241968
...@@ -2628,84 +1972,84 @@ template <class _Tp, class _Allocator>...@@ -2628,84 +1972,84 @@ template <class _Tp, class _Allocator>
2628void1972void
2629deque<_Tp, _Allocator>::__add_back_capacity(size_type __n)1973deque<_Tp, _Allocator>::__add_back_capacity(size_type __n)
2630{1974{
2631 allocator_type& __a = __base::__alloc();1975 allocator_type& __a = __alloc();
2632 size_type __nb = __recommend_blocks(__n + __base::__map_.empty());1976 size_type __nb = __recommend_blocks(__n + __map_.empty());
2633 // Number of unused blocks at front:1977 // 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;
2635 __front_capacity = _VSTD::min(__front_capacity, __nb); // don't take more than you need1979 __front_capacity = _VSTD::min(__front_capacity, __nb); // don't take more than you need
2636 __nb -= __front_capacity; // number of blocks need to allocate1980 __nb -= __front_capacity; // number of blocks need to allocate
2637 // If __nb == 0, then we have sufficient capacity.1981 // If __nb == 0, then we have sufficient capacity.
2638 if (__nb == 0)1982 if (__nb == 0)
2639 {1983 {
2640 __base::__start_ -= __base::__block_size * __front_capacity;1984 __start_ -= __block_size * __front_capacity;
2641 for (; __front_capacity > 0; --__front_capacity)1985 for (; __front_capacity > 0; --__front_capacity)
2642 {1986 {
2643 pointer __pt = __base::__map_.front();1987 pointer __pt = __map_.front();
2644 __base::__map_.pop_front();1988 __map_.pop_front();
2645 __base::__map_.push_back(__pt);1989 __map_.push_back(__pt);
2646 }1990 }
2647 }1991 }
2648 // Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers1992 // 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())
2650 { // we can put the new buffers into the map, but don't shift things around1994 { // we can put the new buffers into the map, but don't shift things around
2651 // until all buffers are allocated. If we throw, we don't need to fix1995 // until all buffers are allocated. If we throw, we don't need to fix
2652 // anything up (any added buffers are undetectible)1996 // anything up (any added buffers are undetectible)
2653 for (; __nb > 0; --__nb)1997 for (; __nb > 0; --__nb)
2654 {1998 {
2655 if (__base::__map_.__back_spare() == 0)1999 if (__map_.__back_spare() == 0)
2656 break;2000 break;
2657 __base::__map_.push_back(__alloc_traits::allocate(__a, __base::__block_size));2001 __map_.push_back(__alloc_traits::allocate(__a, __block_size));
2658 }2002 }
2659 for (; __nb > 0; --__nb, ++__front_capacity, __base::__start_ +=2003 for (; __nb > 0; --__nb, ++__front_capacity, __start_ +=
2660 __base::__block_size - (__base::__map_.size() == 1))2004 __block_size - (__map_.size() == 1))
2661 __base::__map_.push_front(__alloc_traits::allocate(__a, __base::__block_size));2005 __map_.push_front(__alloc_traits::allocate(__a, __block_size));
2662 // Done allocating, reorder capacity2006 // Done allocating, reorder capacity
2663 __base::__start_ -= __base::__block_size * __front_capacity;2007 __start_ -= __block_size * __front_capacity;
2664 for (; __front_capacity > 0; --__front_capacity)2008 for (; __front_capacity > 0; --__front_capacity)
2665 {2009 {
2666 pointer __pt = __base::__map_.front();2010 pointer __pt = __map_.front();
2667 __base::__map_.pop_front();2011 __map_.pop_front();
2668 __base::__map_.push_back(__pt);2012 __map_.push_back(__pt);
2669 }2013 }
2670 }2014 }
2671 // Else need to allocate __nb buffers, *and* we need to reallocate __map_.2015 // Else need to allocate __nb buffers, *and* we need to reallocate __map_.
2672 else2016 else
2673 {2017 {
2674 size_type __ds = __front_capacity * __base::__block_size;2018 size_type __ds = __front_capacity * __block_size;
2675 __split_buffer<pointer, typename __base::__pointer_allocator&>2019 __split_buffer<pointer, __pointer_allocator&>
2676 __buf(max<size_type>(2* __base::__map_.capacity(),2020 __buf(std::max<size_type>(2* __map_.capacity(),
2677 __nb + __base::__map_.size()),2021 __nb + __map_.size()),
2678 __base::__map_.size() - __front_capacity,2022 __map_.size() - __front_capacity,
2679 __base::__map_.__alloc());2023 __map_.__alloc());
2680#ifndef _LIBCPP_NO_EXCEPTIONS2024#ifndef _LIBCPP_NO_EXCEPTIONS
2681 try2025 try
2682 {2026 {
2683#endif // _LIBCPP_NO_EXCEPTIONS2027#endif // _LIBCPP_NO_EXCEPTIONS
2684 for (; __nb > 0; --__nb)2028 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));
2686#ifndef _LIBCPP_NO_EXCEPTIONS2030#ifndef _LIBCPP_NO_EXCEPTIONS
2687 }2031 }
2688 catch (...)2032 catch (...)
2689 {2033 {
2690 for (typename __base::__map_pointer __i = __buf.begin();2034 for (__map_pointer __i = __buf.begin();
2691 __i != __buf.end(); ++__i)2035 __i != __buf.end(); ++__i)
2692 __alloc_traits::deallocate(__a, *__i, __base::__block_size);2036 __alloc_traits::deallocate(__a, *__i, __block_size);
2693 throw;2037 throw;
2694 }2038 }
2695#endif // _LIBCPP_NO_EXCEPTIONS2039#endif // _LIBCPP_NO_EXCEPTIONS
2696 for (; __front_capacity > 0; --__front_capacity)2040 for (; __front_capacity > 0; --__front_capacity)
2697 {2041 {
2698 __buf.push_back(__base::__map_.front());2042 __buf.push_back(__map_.front());
2699 __base::__map_.pop_front();2043 __map_.pop_front();
2700 }2044 }
2701 for (typename __base::__map_pointer __i = __base::__map_.end();2045 for (__map_pointer __i = __map_.end();
2702 __i != __base::__map_.begin();)2046 __i != __map_.begin();)
2703 __buf.push_front(*--__i);2047 __buf.push_front(*--__i);
2704 _VSTD::swap(__base::__map_.__first_, __buf.__first_);2048 _VSTD::swap(__map_.__first_, __buf.__first_);
2705 _VSTD::swap(__base::__map_.__begin_, __buf.__begin_);2049 _VSTD::swap(__map_.__begin_, __buf.__begin_);
2706 _VSTD::swap(__base::__map_.__end_, __buf.__end_);2050 _VSTD::swap(__map_.__end_, __buf.__end_);
2707 _VSTD::swap(__base::__map_.__end_cap(), __buf.__end_cap());2051 _VSTD::swap(__map_.__end_cap(), __buf.__end_cap());
2708 __base::__start_ -= __ds;2052 __start_ -= __ds;
2709 }2053 }
2710}2054}
27112055
...@@ -2713,12 +2057,12 @@ template <class _Tp, class _Allocator>...@@ -2713,12 +2057,12 @@ template <class _Tp, class _Allocator>
2713void2057void
2714deque<_Tp, _Allocator>::pop_front()2058deque<_Tp, _Allocator>::pop_front()
2715{2059{
2716 allocator_type& __a = __base::__alloc();2060 allocator_type& __a = __alloc();
2717 __alloc_traits::destroy(__a, _VSTD::__to_address(*(__base::__map_.begin() +2061 __alloc_traits::destroy(__a, _VSTD::__to_address(*(__map_.begin() +
2718 __base::__start_ / __base::__block_size) +2062 __start_ / __block_size) +
2719 __base::__start_ % __base::__block_size));2063 __start_ % __block_size));
2720 --__base::size();2064 --__size();
2721 ++__base::__start_;2065 ++__start_;
2722 __maybe_remove_front_spare();2066 __maybe_remove_front_spare();
2723}2067}
27242068
...@@ -2727,12 +2071,12 @@ void...@@ -2727,12 +2071,12 @@ void
2727deque<_Tp, _Allocator>::pop_back()2071deque<_Tp, _Allocator>::pop_back()
2728{2072{
2729 _LIBCPP_ASSERT(!empty(), "deque::pop_back called on an empty deque");2073 _LIBCPP_ASSERT(!empty(), "deque::pop_back called on an empty deque");
2730 allocator_type& __a = __base::__alloc();2074 allocator_type& __a = __alloc();
2731 size_type __p = __base::size() + __base::__start_ - 1;2075 size_type __p = size() + __start_ - 1;
2732 __alloc_traits::destroy(__a, _VSTD::__to_address(*(__base::__map_.begin() +2076 __alloc_traits::destroy(__a, _VSTD::__to_address(*(__map_.begin() +
2733 __p / __base::__block_size) +2077 __p / __block_size) +
2734 __p % __base::__block_size));2078 __p % __block_size));
2735 --__base::size();2079 --__size();
2736 __maybe_remove_back_spare();2080 __maybe_remove_back_spare();
2737}2081}
27382082
...@@ -2750,7 +2094,7 @@ deque<_Tp, _Allocator>::__move_and_check(iterator __f, iterator __l, iterator __...@@ -2750,7 +2094,7 @@ deque<_Tp, _Allocator>::__move_and_check(iterator __f, iterator __l, iterator __
2750 while (__n > 0)2094 while (__n > 0)
2751 {2095 {
2752 pointer __fb = __f.__ptr_;2096 pointer __fb = __f.__ptr_;
2753 pointer __fe = *__f.__m_iter_ + __base::__block_size;2097 pointer __fe = *__f.__m_iter_ + __block_size;
2754 difference_type __bs = __fe - __fb;2098 difference_type __bs = __fe - __fb;
2755 if (__bs > __n)2099 if (__bs > __n)
2756 {2100 {
...@@ -2804,15 +2148,15 @@ void...@@ -2804,15 +2148,15 @@ void
2804deque<_Tp, _Allocator>::__move_construct_and_check(iterator __f, iterator __l,2148deque<_Tp, _Allocator>::__move_construct_and_check(iterator __f, iterator __l,
2805 iterator __r, const_pointer& __vt)2149 iterator __r, const_pointer& __vt)
2806{2150{
2807 allocator_type& __a = __base::__alloc();2151 allocator_type& __a = __alloc();
2808 // as if2152 // as if
2809 // for (; __f != __l; ++__r, ++__f, ++__base::size())2153 // for (; __f != __l; ++__r, ++__f, ++__size())
2810 // __alloc_traits::construct(__a, _VSTD::addressof(*__r), _VSTD::move(*__f));2154 // __alloc_traits::construct(__a, _VSTD::addressof(*__r), _VSTD::move(*__f));
2811 difference_type __n = __l - __f;2155 difference_type __n = __l - __f;
2812 while (__n > 0)2156 while (__n > 0)
2813 {2157 {
2814 pointer __fb = __f.__ptr_;2158 pointer __fb = __f.__ptr_;
2815 pointer __fe = *__f.__m_iter_ + __base::__block_size;2159 pointer __fe = *__f.__m_iter_ + __block_size;
2816 difference_type __bs = __fe - __fb;2160 difference_type __bs = __fe - __fb;
2817 if (__bs > __n)2161 if (__bs > __n)
2818 {2162 {
...@@ -2821,7 +2165,7 @@ deque<_Tp, _Allocator>::__move_construct_and_check(iterator __f, iterator __l,...@@ -2821,7 +2165,7 @@ deque<_Tp, _Allocator>::__move_construct_and_check(iterator __f, iterator __l,
2821 }2165 }
2822 if (__fb <= __vt && __vt < __fe)2166 if (__fb <= __vt && __vt < __fe)
2823 __vt = (const_iterator(static_cast<__map_const_pointer>(__f.__m_iter_), __vt) += __r - __f).__ptr_;2167 __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())
2825 __alloc_traits::construct(__a, _VSTD::addressof(*__r), _VSTD::move(*__fb));2169 __alloc_traits::construct(__a, _VSTD::addressof(*__r), _VSTD::move(*__fb));
2826 __n -= __bs;2170 __n -= __bs;
2827 __f += __bs;2171 __f += __bs;
...@@ -2835,13 +2179,13 @@ void...@@ -2835,13 +2179,13 @@ void
2835deque<_Tp, _Allocator>::__move_construct_backward_and_check(iterator __f, iterator __l,2179deque<_Tp, _Allocator>::__move_construct_backward_and_check(iterator __f, iterator __l,
2836 iterator __r, const_pointer& __vt)2180 iterator __r, const_pointer& __vt)
2837{2181{
2838 allocator_type& __a = __base::__alloc();2182 allocator_type& __a = __alloc();
2839 // as if2183 // as if
2840 // for (iterator __j = __l; __j != __f;)2184 // for (iterator __j = __l; __j != __f;)
2841 // {2185 // {
2842 // __alloc_traitsconstruct(__a, _VSTD::addressof(*--__r), _VSTD::move(*--__j));2186 // __alloc_traitsconstruct(__a, _VSTD::addressof(*--__r), _VSTD::move(*--__j));
2843 // --__base::__start_;2187 // --__start_;
2844 // ++__base::size();2188 // ++__size();
2845 // }2189 // }
2846 difference_type __n = __l - __f;2190 difference_type __n = __l - __f;
2847 while (__n > 0)2191 while (__n > 0)
...@@ -2860,8 +2204,8 @@ deque<_Tp, _Allocator>::__move_construct_backward_and_check(iterator __f, iterat...@@ -2860,8 +2204,8 @@ deque<_Tp, _Allocator>::__move_construct_backward_and_check(iterator __f, iterat
2860 while (__le != __lb)2204 while (__le != __lb)
2861 {2205 {
2862 __alloc_traits::construct(__a, _VSTD::addressof(*--__r), _VSTD::move(*--__le));2206 __alloc_traits::construct(__a, _VSTD::addressof(*--__r), _VSTD::move(*--__le));
2863 --__base::__start_;2207 --__start_;
2864 ++__base::size();2208 ++__size();
2865 }2209 }
2866 __n -= __bs;2210 __n -= __bs;
2867 __l -= __bs - 1;2211 __l -= __bs - 1;
...@@ -2872,26 +2216,26 @@ template <class _Tp, class _Allocator>...@@ -2872,26 +2216,26 @@ template <class _Tp, class _Allocator>
2872typename deque<_Tp, _Allocator>::iterator2216typename deque<_Tp, _Allocator>::iterator
2873deque<_Tp, _Allocator>::erase(const_iterator __f)2217deque<_Tp, _Allocator>::erase(const_iterator __f)
2874{2218{
2875 iterator __b = __base::begin();2219 iterator __b = begin();
2876 difference_type __pos = __f - __b;2220 difference_type __pos = __f - __b;
2877 iterator __p = __b + __pos;2221 iterator __p = __b + __pos;
2878 allocator_type& __a = __base::__alloc();2222 allocator_type& __a = __alloc();
2879 if (static_cast<size_t>(__pos) <= (__base::size() - 1) / 2)2223 if (static_cast<size_t>(__pos) <= (size() - 1) / 2)
2880 { // erase from front2224 { // erase from front
2881 _VSTD::move_backward(__b, __p, _VSTD::next(__p));2225 _VSTD::move_backward(__b, __p, _VSTD::next(__p));
2882 __alloc_traits::destroy(__a, _VSTD::addressof(*__b));2226 __alloc_traits::destroy(__a, _VSTD::addressof(*__b));
2883 --__base::size();2227 --__size();
2884 ++__base::__start_;2228 ++__start_;
2885 __maybe_remove_front_spare();2229 __maybe_remove_front_spare();
2886 }2230 }
2887 else2231 else
2888 { // erase from back2232 { // erase from back
2889 iterator __i = _VSTD::move(_VSTD::next(__p), __base::end(), __p);2233 iterator __i = _VSTD::move(_VSTD::next(__p), end(), __p);
2890 __alloc_traits::destroy(__a, _VSTD::addressof(*__i));2234 __alloc_traits::destroy(__a, _VSTD::addressof(*__i));
2891 --__base::size();2235 --__size();
2892 __maybe_remove_back_spare();2236 __maybe_remove_back_spare();
2893 }2237 }
2894 return __base::begin() + __pos;2238 return begin() + __pos;
2895}2239}
28962240
2897template <class _Tp, class _Allocator>2241template <class _Tp, class _Allocator>
...@@ -2899,49 +2243,49 @@ typename deque<_Tp, _Allocator>::iterator...@@ -2899,49 +2243,49 @@ typename deque<_Tp, _Allocator>::iterator
2899deque<_Tp, _Allocator>::erase(const_iterator __f, const_iterator __l)2243deque<_Tp, _Allocator>::erase(const_iterator __f, const_iterator __l)
2900{2244{
2901 difference_type __n = __l - __f;2245 difference_type __n = __l - __f;
2902 iterator __b = __base::begin();2246 iterator __b = begin();
2903 difference_type __pos = __f - __b;2247 difference_type __pos = __f - __b;
2904 iterator __p = __b + __pos;2248 iterator __p = __b + __pos;
2905 if (__n > 0)2249 if (__n > 0)
2906 {2250 {
2907 allocator_type& __a = __base::__alloc();2251 allocator_type& __a = __alloc();
2908 if (static_cast<size_t>(__pos) <= (__base::size() - __n) / 2)2252 if (static_cast<size_t>(__pos) <= (size() - __n) / 2)
2909 { // erase from front2253 { // erase from front
2910 iterator __i = _VSTD::move_backward(__b, __p, __p + __n);2254 iterator __i = _VSTD::move_backward(__b, __p, __p + __n);
2911 for (; __b != __i; ++__b)2255 for (; __b != __i; ++__b)
2912 __alloc_traits::destroy(__a, _VSTD::addressof(*__b));2256 __alloc_traits::destroy(__a, _VSTD::addressof(*__b));
2913 __base::size() -= __n;2257 __size() -= __n;
2914 __base::__start_ += __n;2258 __start_ += __n;
2915 while (__maybe_remove_front_spare()) {2259 while (__maybe_remove_front_spare()) {
2916 }2260 }
2917 }2261 }
2918 else2262 else
2919 { // erase from back2263 { // erase from back
2920 iterator __i = _VSTD::move(__p + __n, __base::end(), __p);2264 iterator __i = _VSTD::move(__p + __n, end(), __p);
2921 for (iterator __e = __base::end(); __i != __e; ++__i)2265 for (iterator __e = end(); __i != __e; ++__i)
2922 __alloc_traits::destroy(__a, _VSTD::addressof(*__i));2266 __alloc_traits::destroy(__a, _VSTD::addressof(*__i));
2923 __base::size() -= __n;2267 __size() -= __n;
2924 while (__maybe_remove_back_spare()) {2268 while (__maybe_remove_back_spare()) {
2925 }2269 }
2926 }2270 }
2927 }2271 }
2928 return __base::begin() + __pos;2272 return begin() + __pos;
2929}2273}
29302274
2931template <class _Tp, class _Allocator>2275template <class _Tp, class _Allocator>
2932void2276void
2933deque<_Tp, _Allocator>::__erase_to_end(const_iterator __f)2277deque<_Tp, _Allocator>::__erase_to_end(const_iterator __f)
2934{2278{
2935 iterator __e = __base::end();2279 iterator __e = end();
2936 difference_type __n = __e - __f;2280 difference_type __n = __e - __f;
2937 if (__n > 0)2281 if (__n > 0)
2938 {2282 {
2939 allocator_type& __a = __base::__alloc();2283 allocator_type& __a = __alloc();
2940 iterator __b = __base::begin();2284 iterator __b = begin();
2941 difference_type __pos = __f - __b;2285 difference_type __pos = __f - __b;
2942 for (iterator __p = __b + __pos; __p != __e; ++__p)2286 for (iterator __p = __b + __pos; __p != __e; ++__p)
2943 __alloc_traits::destroy(__a, _VSTD::addressof(*__p));2287 __alloc_traits::destroy(__a, _VSTD::addressof(*__p));
2944 __base::size() -= __n;2288 __size() -= __n;
2945 while (__maybe_remove_back_spare()) {2289 while (__maybe_remove_back_spare()) {
2946 }2290 }
2947 }2291 }
...@@ -2958,7 +2302,10 @@ deque<_Tp, _Allocator>::swap(deque& __c)...@@ -2958,7 +2302,10 @@ deque<_Tp, _Allocator>::swap(deque& __c)
2958 __is_nothrow_swappable<allocator_type>::value)2302 __is_nothrow_swappable<allocator_type>::value)
2959#endif2303#endif
2960{2304{
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());
2962}2309}
29632310
2964template <class _Tp, class _Allocator>2311template <class _Tp, class _Allocator>
...@@ -2966,11 +2313,28 @@ inline...@@ -2966,11 +2313,28 @@ inline
2966void2313void
2967deque<_Tp, _Allocator>::clear() _NOEXCEPT2314deque<_Tp, _Allocator>::clear() _NOEXCEPT
2968{2315{
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 }
2970}2334}
29712335
2972template <class _Tp, class _Allocator>2336template <class _Tp, class _Allocator>
2973inline _LIBCPP_INLINE_VISIBILITY2337inline _LIBCPP_HIDE_FROM_ABI
2974bool2338bool
2975operator==(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)2339operator==(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
2976{2340{
...@@ -2979,7 +2343,7 @@ operator==(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)...@@ -2979,7 +2343,7 @@ operator==(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
2979}2343}
29802344
2981template <class _Tp, class _Allocator>2345template <class _Tp, class _Allocator>
2982inline _LIBCPP_INLINE_VISIBILITY2346inline _LIBCPP_HIDE_FROM_ABI
2983bool2347bool
2984operator!=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)2348operator!=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
2985{2349{
...@@ -2987,7 +2351,7 @@ operator!=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)...@@ -2987,7 +2351,7 @@ operator!=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
2987}2351}
29882352
2989template <class _Tp, class _Allocator>2353template <class _Tp, class _Allocator>
2990inline _LIBCPP_INLINE_VISIBILITY2354inline _LIBCPP_HIDE_FROM_ABI
2991bool2355bool
2992operator< (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)2356operator< (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
2993{2357{
...@@ -2995,7 +2359,7 @@ operator< (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)...@@ -2995,7 +2359,7 @@ operator< (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
2995}2359}
29962360
2997template <class _Tp, class _Allocator>2361template <class _Tp, class _Allocator>
2998inline _LIBCPP_INLINE_VISIBILITY2362inline _LIBCPP_HIDE_FROM_ABI
2999bool2363bool
3000operator> (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)2364operator> (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
3001{2365{
...@@ -3003,7 +2367,7 @@ operator> (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)...@@ -3003,7 +2367,7 @@ operator> (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
3003}2367}
30042368
3005template <class _Tp, class _Allocator>2369template <class _Tp, class _Allocator>
3006inline _LIBCPP_INLINE_VISIBILITY2370inline _LIBCPP_HIDE_FROM_ABI
3007bool2371bool
3008operator>=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)2372operator>=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
3009{2373{
...@@ -3011,7 +2375,7 @@ operator>=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)...@@ -3011,7 +2375,7 @@ operator>=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
3011}2375}
30122376
3013template <class _Tp, class _Allocator>2377template <class _Tp, class _Allocator>
3014inline _LIBCPP_INLINE_VISIBILITY2378inline _LIBCPP_HIDE_FROM_ABI
3015bool2379bool
3016operator<=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)2380operator<=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
3017{2381{
...@@ -3019,7 +2383,7 @@ operator<=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)...@@ -3019,7 +2383,7 @@ operator<=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
3019}2383}
30202384
3021template <class _Tp, class _Allocator>2385template <class _Tp, class _Allocator>
3022inline _LIBCPP_INLINE_VISIBILITY2386inline _LIBCPP_HIDE_FROM_ABI
3023void2387void
3024swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y)2388swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y)
3025 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))2389 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
...@@ -3029,7 +2393,7 @@ swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y)...@@ -3029,7 +2393,7 @@ swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y)
30292393
3030#if _LIBCPP_STD_VER > 172394#if _LIBCPP_STD_VER > 17
3031template <class _Tp, class _Allocator, class _Up>2395template <class _Tp, class _Allocator, class _Up>
3032inline _LIBCPP_INLINE_VISIBILITY typename deque<_Tp, _Allocator>::size_type2396inline _LIBCPP_HIDE_FROM_ABI typename deque<_Tp, _Allocator>::size_type
3033erase(deque<_Tp, _Allocator>& __c, const _Up& __v) {2397erase(deque<_Tp, _Allocator>& __c, const _Up& __v) {
3034 auto __old_size = __c.size();2398 auto __old_size = __c.size();
3035 __c.erase(_VSTD::remove(__c.begin(), __c.end(), __v), __c.end());2399 __c.erase(_VSTD::remove(__c.begin(), __c.end(), __v), __c.end());
...@@ -3037,7 +2401,7 @@ erase(deque<_Tp, _Allocator>& __c, const _Up& __v) {...@@ -3037,7 +2401,7 @@ erase(deque<_Tp, _Allocator>& __c, const _Up& __v) {
3037}2401}
30382402
3039template <class _Tp, class _Allocator, class _Predicate>2403template <class _Tp, class _Allocator, class _Predicate>
3040inline _LIBCPP_INLINE_VISIBILITY typename deque<_Tp, _Allocator>::size_type2404inline _LIBCPP_HIDE_FROM_ABI typename deque<_Tp, _Allocator>::size_type
3041erase_if(deque<_Tp, _Allocator>& __c, _Predicate __pred) {2405erase_if(deque<_Tp, _Allocator>& __c, _Predicate __pred) {
3042 auto __old_size = __c.size();2406 auto __old_size = __c.size();
3043 __c.erase(_VSTD::remove_if(__c.begin(), __c.end(), __pred), __c.end());2407 __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;...@@ -3055,6 +2419,25 @@ inline constexpr bool __format::__enable_insertable<std::deque<wchar_t>> = true;
30552419
3056_LIBCPP_END_NAMESPACE_STD2420_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
3058_LIBCPP_POP_MACROS2431_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
3060#endif // _LIBCPP_DEQUE2443#endif // _LIBCPP_DEQUE
lib/libcxx/include/errno.h+3-1
...@@ -28,7 +28,9 @@ Macros:...@@ -28,7 +28,9 @@ Macros:
28# pragma GCC system_header28# pragma GCC system_header
29#endif29#endif
3030
31#include_next <errno.h>31#if __has_include_next(<errno.h>)
32# include_next <errno.h>
33#endif
3234
33#ifdef __cplusplus35#ifdef __cplusplus
3436
lib/libcxx/include/exception+70-16
...@@ -80,13 +80,21 @@ template <class E> void rethrow_if_nested(const E& e);...@@ -80,13 +80,21 @@ template <class E> void rethrow_if_nested(const E& e);
80#include <__availability>80#include <__availability>
81#include <__config>81#include <__config>
82#include <__memory/addressof.h>82#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>
83#include <cstddef>90#include <cstddef>
84#include <cstdlib>91#include <cstdlib>
85#include <type_traits>
86#include <version>92#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.
88#if defined(_LIBCPP_ABI_VCRUNTIME)96#if defined(_LIBCPP_ABI_VCRUNTIME)
89#include <vcruntime_exception.h>97# include <vcruntime_exception.h>
90#endif98#endif
9199
92#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)100#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -96,24 +104,66 @@ template <class E> void rethrow_if_nested(const E& e);...@@ -96,24 +104,66 @@ template <class E> void rethrow_if_nested(const E& e);
96namespace std // purposefully not using versioning namespace104namespace std // purposefully not using versioning namespace
97{105{
98106
99#if !defined(_LIBCPP_ABI_VCRUNTIME)107#if defined(_LIBCPP_ABI_VCRUNTIME) && (!defined(_HAS_EXCEPTIONS) || _HAS_EXCEPTIONS != 0)
100class _LIBCPP_EXCEPTION_ABI exception108// The std::exception class was already included above, but we're explicit about this condition here for clarity.
101{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
102public:124public:
103 _LIBCPP_INLINE_VISIBILITY exception() _NOEXCEPT {}125 exception() _NOEXCEPT : __data_() {}
104 _LIBCPP_INLINE_VISIBILITY exception(const exception&) _NOEXCEPT = default;
105126
106 virtual ~exception() _NOEXCEPT;127 explicit exception(char const* __message) _NOEXCEPT : __data_() {
107 virtual const char* what() const _NOEXCEPT;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_;
108};142};
109143
110class _LIBCPP_EXCEPTION_ABI bad_exception144class bad_exception : public exception {
111 : public exception145public:
112{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 {
113public:154public:
114 _LIBCPP_INLINE_VISIBILITY bad_exception() _NOEXCEPT {}155 _LIBCPP_INLINE_VISIBILITY exception() _NOEXCEPT {}
115 virtual ~bad_exception() _NOEXCEPT;156 _LIBCPP_INLINE_VISIBILITY exception(const exception&) _NOEXCEPT = default;
116 virtual const char* what() const _NOEXCEPT;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;
117};167};
118#endif // !_LIBCPP_ABI_VCRUNTIME168#endif // !_LIBCPP_ABI_VCRUNTIME
119169
...@@ -282,7 +332,7 @@ struct __throw_with_nested<_Tp, _Up, false> {...@@ -282,7 +332,7 @@ struct __throw_with_nested<_Tp, _Up, false> {
282#endif332#endif
283333
284template <class _Tp>334template <class _Tp>
285_LIBCPP_NORETURN335_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
286void336void
287throw_with_nested(_Tp&& __t)337throw_with_nested(_Tp&& __t)
288{338{
...@@ -327,4 +377,8 @@ rethrow_if_nested(const _Ep&,...@@ -327,4 +377,8 @@ rethrow_if_nested(const _Ep&,
327377
328} // namespace std378} // namespace std
329379
380#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
381# include <type_traits>
382#endif
383
330#endif // _LIBCPP_EXCEPTION384#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...>...@@ -56,11 +56,11 @@ struct __lfts_uses_alloc_ctor_imp<true, _Tp, _Alloc, _Args...>
56 = is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;56 = is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
5757
58 static const bool __ic_second =58 static const bool __ic_second =
59 conditional<59 __conditional_t<
60 __ic_first,60 __ic_first,
61 false_type,61 false_type,
62 is_constructible<_Tp, _Args..., _Alloc>62 is_constructible<_Tp, _Args..., _Alloc>
63 >::type::value;63 >::value;
6464
65 static_assert(__ic_first || __ic_second,65 static_assert(__ic_first || __ic_second,
66 "Request for uses allocator construction is ill-formed");66 "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>>;...@@ -50,10 +50,28 @@ template <class P> struct hash<coroutine_handle<P>>;
50#include <__functional/operations.h>50#include <__functional/operations.h>
51#include <cstddef>51#include <cstddef>
52#include <experimental/__config>52#include <experimental/__config>
53#include <memory> // for hash<T*>
54#include <new>53#include <new>
55#include <type_traits>54#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
57#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)75#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
58# pragma GCC system_header76# pragma GCC system_header
59#endif77#endif
...@@ -66,8 +84,7 @@ template <class _Tp, class = void>...@@ -66,8 +84,7 @@ template <class _Tp, class = void>
66struct __coroutine_traits_sfinae {};84struct __coroutine_traits_sfinae {};
6785
68template <class _Tp>86template <class _Tp>
69struct __coroutine_traits_sfinae<87struct __coroutine_traits_sfinae<_Tp, __void_t<typename _Tp::promise_type> >
70 _Tp, typename __void_t<typename _Tp::promise_type>::type>
71{88{
72 using promise_type = typename _Tp::promise_type;89 using promise_type = typename _Tp::promise_type;
73};90};
...@@ -241,7 +258,7 @@ public:...@@ -241,7 +258,7 @@ public:
241258
242 _LIBCPP_INLINE_VISIBILITY259 _LIBCPP_INLINE_VISIBILITY
243 static coroutine_handle from_promise(_Promise& __promise) _NOEXCEPT {260 static coroutine_handle from_promise(_Promise& __promise) _NOEXCEPT {
244 typedef typename remove_cv<_Promise>::type _RawPromise;261 typedef __remove_cv_t<_Promise> _RawPromise;
245 coroutine_handle __tmp;262 coroutine_handle __tmp;
246 __tmp.__handle_ = __builtin_coro_promise(263 __tmp.__handle_ = __builtin_coro_promise(
247 _VSTD::addressof(const_cast<_RawPromise&>(__promise)),264 _VSTD::addressof(const_cast<_RawPromise&>(__promise)),
...@@ -269,9 +286,9 @@ public:...@@ -269,9 +286,9 @@ public:
269 _LIBCPP_CONSTEXPR explicit operator bool() const _NOEXCEPT { return true; }286 _LIBCPP_CONSTEXPR explicit operator bool() const _NOEXCEPT { return true; }
270 _LIBCPP_CONSTEXPR bool done() const _NOEXCEPT { return false; }287 _LIBCPP_CONSTEXPR bool done() const _NOEXCEPT { return false; }
271288
272 _LIBCPP_CONSTEXPR_AFTER_CXX17 void operator()() const _NOEXCEPT {}289 _LIBCPP_CONSTEXPR_SINCE_CXX20 void operator()() const _NOEXCEPT {}
273 _LIBCPP_CONSTEXPR_AFTER_CXX17 void resume() const _NOEXCEPT {}290 _LIBCPP_CONSTEXPR_SINCE_CXX20 void resume() const _NOEXCEPT {}
274 _LIBCPP_CONSTEXPR_AFTER_CXX17 void destroy() const _NOEXCEPT {}291 _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy() const _NOEXCEPT {}
275292
276private:293private:
277 _LIBCPP_INLINE_VISIBILITY294 _LIBCPP_INLINE_VISIBILITY
lib/libcxx/include/experimental/deque+4
...@@ -40,9 +40,13 @@ namespace pmr {...@@ -40,9 +40,13 @@ namespace pmr {
4040
41_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR41_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
4242
43#ifndef _LIBCPP_CXX03_LANG
44
43template <class _ValueT>45template <class _ValueT>
44using deque = _VSTD::deque<_ValueT, polymorphic_allocator<_ValueT>>;46using deque = _VSTD::deque<_ValueT, polymorphic_allocator<_ValueT>>;
4547
48#endif // _LIBCPP_CXX03_LANG
49
46_LIBCPP_END_NAMESPACE_LFTS_PMR50_LIBCPP_END_NAMESPACE_LFTS_PMR
4751
48#endif /* _LIBCPP_EXPERIMENTAL_DEQUE */52#endif /* _LIBCPP_EXPERIMENTAL_DEQUE */
lib/libcxx/include/experimental/forward_list+4
...@@ -40,9 +40,13 @@ namespace pmr {...@@ -40,9 +40,13 @@ namespace pmr {
4040
41_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR41_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
4242
43#ifndef _LIBCPP_CXX03_LANG
44
43template <class _ValueT>45template <class _ValueT>
44using forward_list = _VSTD::forward_list<_ValueT, polymorphic_allocator<_ValueT>>;46using forward_list = _VSTD::forward_list<_ValueT, polymorphic_allocator<_ValueT>>;
4547
48#endif // _LIBCPP_CXX03_LANG
49
46_LIBCPP_END_NAMESPACE_LFTS_PMR50_LIBCPP_END_NAMESPACE_LFTS_PMR
4751
48#endif /* _LIBCPP_EXPERIMENTAL_FORWARD_LIST */52#endif /* _LIBCPP_EXPERIMENTAL_FORWARD_LIST */
lib/libcxx/include/experimental/functional+25-25
...@@ -85,9 +85,9 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS...@@ -85,9 +85,9 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
85# define _LIBCPP_DEPRECATED_BOYER_MOORE_SEARCHER85# define _LIBCPP_DEPRECATED_BOYER_MOORE_SEARCHER
86# define _LIBCPP_DEPRECATED_BOYER_MOORE_HORSPOOL_SEARCHER86# define _LIBCPP_DEPRECATED_BOYER_MOORE_HORSPOOL_SEARCHER
87#else87#else
88# define _LIBCPP_DEPRECATED_DEFAULT_SEARCHER _LIBCPP_DEPRECATED_("std::exprerimental::default_searcher will be removed in LLVM 17. Use std::default_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::exprerimental::boyer_moore_searcher will be removed in LLVM 17. Use std::boyer_moore_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::exprerimental::boyer_moore_horspool_searcher will be removed in LLVM 17. Use std::boyer_moore_horspool_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")
91#endif91#endif
9292
93#if _LIBCPP_STD_VER > 1193#if _LIBCPP_STD_VER > 11
...@@ -132,24 +132,24 @@ class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, false> {...@@ -132,24 +132,24 @@ class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, false> {
132 typedef _Key key_type;132 typedef _Key key_type;
133133
134 const _Value __default_value_;134 const _Value __default_value_;
135 std::unordered_map<_Key, _Value, _Hash, _BinaryPredicate> __table;135 std::unordered_map<_Key, _Value, _Hash, _BinaryPredicate> __table_;
136136
137public:137public:
138 _LIBCPP_INLINE_VISIBILITY138 _LIBCPP_INLINE_VISIBILITY
139 _BMSkipTable(size_t __sz, _Value __default, _Hash __hf, _BinaryPredicate __pred)139 _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
142 _LIBCPP_INLINE_VISIBILITY142 _LIBCPP_INLINE_VISIBILITY
143 void insert(const key_type &__key, value_type __val)143 void insert(const key_type &__key, value_type __val)
144 {144 {
145 __table [__key] = __val; // Would skip_.insert (val) be better here?145 __table_ [__key] = __val; // Would skip_.insert (val) be better here?
146 }146 }
147147
148 _LIBCPP_INLINE_VISIBILITY148 _LIBCPP_INLINE_VISIBILITY
149 value_type operator [](const key_type & __key) const149 value_type operator [](const key_type & __key) const
150 {150 {
151 auto __it = __table.find (__key);151 auto __it = __table_.find (__key);
152 return __it == __table.end() ? __default_value_ : __it->second;152 return __it == __table_.end() ? __default_value_ : __it->second;
153 }153 }
154};154};
155155
...@@ -161,27 +161,27 @@ private:...@@ -161,27 +161,27 @@ private:
161 typedef _Value value_type;161 typedef _Value value_type;
162 typedef _Key key_type;162 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;
165 typedef std::array<value_type, 256> skip_map;165 typedef std::array<value_type, 256> skip_map;
166 skip_map __table;166 skip_map __table_;
167167
168public:168public:
169 _LIBCPP_INLINE_VISIBILITY169 _LIBCPP_INLINE_VISIBILITY
170 _BMSkipTable(size_t /*__sz*/, _Value __default, _Hash /*__hf*/, _BinaryPredicate /*__pred*/)170 _BMSkipTable(size_t /*__sz*/, _Value __default, _Hash /*__hf*/, _BinaryPredicate /*__pred*/)
171 {171 {
172 std::fill_n(__table.begin(), __table.size(), __default);172 std::fill_n(__table_.begin(), __table_.size(), __default);
173 }173 }
174174
175 _LIBCPP_INLINE_VISIBILITY175 _LIBCPP_INLINE_VISIBILITY
176 void insert(key_type __key, value_type __val)176 void insert(key_type __key, value_type __val)
177 {177 {
178 __table[static_cast<unsigned_key_type>(__key)] = __val;178 __table_[static_cast<unsigned_key_type>(__key)] = __val;
179 }179 }
180180
181 _LIBCPP_INLINE_VISIBILITY181 _LIBCPP_INLINE_VISIBILITY
182 value_type operator [](key_type __key) const182 value_type operator [](key_type __key) const
183 {183 {
184 return __table[static_cast<unsigned_key_type>(__key)];184 return __table_[static_cast<unsigned_key_type>(__key)];
185 }185 }
186};186};
187187
...@@ -205,8 +205,8 @@ public:...@@ -205,8 +205,8 @@ public:
205 _Hash __hf = _Hash(), _BinaryPredicate __pred = _BinaryPredicate())205 _Hash __hf = _Hash(), _BinaryPredicate __pred = _BinaryPredicate())
206 : __first_(__f), __last_(__l), __pred_(__pred),206 : __first_(__f), __last_(__l), __pred_(__pred),
207 __pattern_length_(_VSTD::distance(__first_, __last_)),207 __pattern_length_(_VSTD::distance(__first_, __last_)),
208 __skip_{make_shared<skip_table_type>(__pattern_length_, -1, __hf, __pred_)},208 __skip_{std::make_shared<skip_table_type>(__pattern_length_, -1, __hf, __pred_)},
209 __suffix_{make_shared<vector<difference_type>>(__pattern_length_ + 1)}209 __suffix_{std::make_shared<vector<difference_type>>(__pattern_length_ + 1)}
210 {210 {
211 // build the skip table211 // build the skip table
212 for ( difference_type __i = 0; __f != __l; ++__f, (void) ++__i )212 for ( difference_type __i = 0; __f != __l; ++__f, (void) ++__i )
...@@ -223,12 +223,12 @@ public:...@@ -223,12 +223,12 @@ public:
223 typename iterator_traits<_RandomAccessIterator2>::value_type>::value,223 typename iterator_traits<_RandomAccessIterator2>::value_type>::value,
224 "Corpus and Pattern iterators must point to the same type");224 "Corpus and Pattern iterators must point to the same type");
225225
226 if (__f == __l ) return make_pair(__l, __l); // empty corpus226 if (__f == __l ) return std::make_pair(__l, __l); // empty corpus
227 if (__first_ == __last_) return make_pair(__f, __f); // empty pattern227 if (__first_ == __last_) return std::make_pair(__f, __f); // empty pattern
228228
229 // If the pattern is larger than the corpus, we can't find it!229 // If the pattern is larger than the corpus, we can't find it!
230 if ( __pattern_length_ > _VSTD::distance(__f, __l))230 if ( __pattern_length_ > _VSTD::distance(__f, __l))
231 return make_pair(__l, __l);231 return std::make_pair(__l, __l);
232232
233 // Do the search233 // Do the search
234 return this->__search(__f, __l);234 return this->__search(__f, __l);
...@@ -260,7 +260,7 @@ private:...@@ -260,7 +260,7 @@ private:
260 __j--;260 __j--;
261 // We matched - we're done!261 // We matched - we're done!
262 if ( __j == 0 )262 if ( __j == 0 )
263 return make_pair(__cur, __cur + __pattern_length_);263 return std::make_pair(__cur, __cur + __pattern_length_);
264 }264 }
265265
266 // Since we didn't match, figure out how far to skip forward266 // Since we didn't match, figure out how far to skip forward
...@@ -272,7 +272,7 @@ private:...@@ -272,7 +272,7 @@ private:
272 __cur += __suffix[ __j ];272 __cur += __suffix[ __j ];
273 }273 }
274274
275 return make_pair(__l, __l); // We didn't find anything275 return std::make_pair(__l, __l); // We didn't find anything
276 }276 }
277277
278278
...@@ -373,12 +373,12 @@ public:...@@ -373,12 +373,12 @@ public:
373 typename std::iterator_traits<_RandomAccessIterator2>::value_type>::value,373 typename std::iterator_traits<_RandomAccessIterator2>::value_type>::value,
374 "Corpus and Pattern iterators must point to the same type");374 "Corpus and Pattern iterators must point to the same type");
375375
376 if (__f == __l ) return make_pair(__l, __l); // empty corpus376 if (__f == __l ) return std::make_pair(__l, __l); // empty corpus
377 if (__first_ == __last_) return make_pair(__f, __f); // empty pattern377 if (__first_ == __last_) return std::make_pair(__f, __f); // empty pattern
378378
379 // If the pattern is larger than the corpus, we can't find it!379 // If the pattern is larger than the corpus, we can't find it!
380 if ( __pattern_length_ > _VSTD::distance(__f, __l))380 if ( __pattern_length_ > _VSTD::distance(__f, __l))
381 return make_pair(__l, __l);381 return std::make_pair(__l, __l);
382382
383 // Do the search383 // Do the search
384 return this->__search(__f, __l);384 return this->__search(__f, __l);
...@@ -407,12 +407,12 @@ private:...@@ -407,12 +407,12 @@ private:
407 __j--;407 __j--;
408 // We matched - we're done!408 // We matched - we're done!
409 if ( __j == 0 )409 if ( __j == 0 )
410 return make_pair(__cur, __cur + __pattern_length_);410 return std::make_pair(__cur, __cur + __pattern_length_);
411 }411 }
412 __cur += __skip[__cur[__pattern_length_-1]];412 __cur += __skip[__cur[__pattern_length_-1]];
413 }413 }
414414
415 return make_pair(__l, __l);415 return std::make_pair(__l, __l);
416 }416 }
417};417};
418418
lib/libcxx/include/experimental/iterator+15-10
...@@ -54,6 +54,7 @@ namespace std {...@@ -54,6 +54,7 @@ namespace std {
5454
55#include <__assert> // all public C++ headers provide the assertion handler55#include <__assert> // all public C++ headers provide the assertion handler
56#include <__memory/addressof.h>56#include <__memory/addressof.h>
57#include <__type_traits/decay.h>
57#include <__utility/forward.h>58#include <__utility/forward.h>
58#include <__utility/move.h>59#include <__utility/move.h>
59#include <experimental/__config>60#include <experimental/__config>
...@@ -82,19 +83,19 @@ public:...@@ -82,19 +83,19 @@ public:
82 typedef void reference;83 typedef void reference;
8384
84 ostream_joiner(ostream_type& __os, _Delim&& __d)85 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
87 ostream_joiner(ostream_type& __os, const _Delim& __d)88 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
91 template<typename _Tp>92 template<typename _Tp>
92 ostream_joiner& operator=(const _Tp& __v)93 ostream_joiner& operator=(const _Tp& __v)
93 {94 {
94 if (!__first)95 if (!__first_)
95 *__output_iter << __delim;96 *__output_iter_ << __delim_;
96 __first = false;97 __first_ = false;
97 *__output_iter << __v;98 *__output_iter_ << __v;
98 return *this;99 return *this;
99 }100 }
100101
...@@ -103,14 +104,14 @@ public:...@@ -103,14 +104,14 @@ public:
103 ostream_joiner& operator++(int) _NOEXCEPT { return *this; }104 ostream_joiner& operator++(int) _NOEXCEPT { return *this; }
104105
105private:106private:
106 ostream_type* __output_iter;107 ostream_type* __output_iter_;
107 _Delim __delim;108 _Delim __delim_;
108 bool __first;109 bool __first_;
109};110};
110111
111112
112template <class _CharT, class _Traits, class _Delim>113template <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>
114make_ostream_joiner(basic_ostream<_CharT, _Traits>& __os, _Delim && __d)115make_ostream_joiner(basic_ostream<_CharT, _Traits>& __os, _Delim && __d)
115{ return ostream_joiner<typename decay<_Delim>::type, _CharT, _Traits>(__os, _VSTD::forward<_Delim>(__d)); }116{ return ostream_joiner<typename decay<_Delim>::type, _CharT, _Traits>(__os, _VSTD::forward<_Delim>(__d)); }
116117
...@@ -118,4 +119,8 @@ _LIBCPP_END_NAMESPACE_LFTS...@@ -118,4 +119,8 @@ _LIBCPP_END_NAMESPACE_LFTS
118119
119#endif // _LIBCPP_STD_VER > 11120#endif // _LIBCPP_STD_VER > 11
120121
122#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
123# include <type_traits>
124#endif
125
121#endif // _LIBCPP_EXPERIMENTAL_ITERATOR126#endif // _LIBCPP_EXPERIMENTAL_ITERATOR
lib/libcxx/include/experimental/list+4
...@@ -40,9 +40,13 @@ namespace pmr {...@@ -40,9 +40,13 @@ namespace pmr {
4040
41_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR41_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
4242
43#ifndef _LIBCPP_CXX03_LANG
44
43template <class _ValueT>45template <class _ValueT>
44using list = _VSTD::list<_ValueT, polymorphic_allocator<_ValueT>>;46using list = _VSTD::list<_ValueT, polymorphic_allocator<_ValueT>>;
4547
48#endif // _LIBCPP_CXX03_LANG
49
46_LIBCPP_END_NAMESPACE_LFTS_PMR50_LIBCPP_END_NAMESPACE_LFTS_PMR
4751
48#endif /* _LIBCPP_EXPERIMENTAL_LIST */52#endif /* _LIBCPP_EXPERIMENTAL_LIST */
lib/libcxx/include/experimental/map+4
...@@ -45,6 +45,8 @@ namespace pmr {...@@ -45,6 +45,8 @@ namespace pmr {
4545
46_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR46_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
4747
48#ifndef _LIBCPP_CXX03_LANG
49
48template <class _Key, class _Value, class _Compare = less<_Key>>50template <class _Key, class _Value, class _Compare = less<_Key>>
49using map = _VSTD::map<_Key, _Value, _Compare,51using map = _VSTD::map<_Key, _Value, _Compare,
50 polymorphic_allocator<pair<const _Key, _Value>>>;52 polymorphic_allocator<pair<const _Key, _Value>>>;
...@@ -53,6 +55,8 @@ template <class _Key, class _Value, class _Compare = less<_Key>>...@@ -53,6 +55,8 @@ template <class _Key, class _Value, class _Compare = less<_Key>>
53using multimap = _VSTD::multimap<_Key, _Value, _Compare,55using multimap = _VSTD::multimap<_Key, _Value, _Compare,
54 polymorphic_allocator<pair<const _Key, _Value>>>;56 polymorphic_allocator<pair<const _Key, _Value>>>;
5557
58#endif // _LIBCPP_CXX03_LANG
59
56_LIBCPP_END_NAMESPACE_LFTS_PMR60_LIBCPP_END_NAMESPACE_LFTS_PMR
5761
58#endif /* _LIBCPP_EXPERIMENTAL_MAP */62#endif /* _LIBCPP_EXPERIMENTAL_MAP */
lib/libcxx/include/experimental/memory_resource+37-13
...@@ -65,16 +65,16 @@ namespace pmr {...@@ -65,16 +65,16 @@ namespace pmr {
65 */65 */
6666
67#include <__assert> // all public C++ headers provide the assertion handler67#include <__assert> // all public C++ headers provide the assertion handler
68#include <__tuple>68#include <__memory/allocator_traits.h>
69#include <__utility/move.h>69#include <__utility/move.h>
70#include <cstddef>70#include <cstddef>
71#include <cstdlib>71#include <cstdlib>
72#include <experimental/__config>72#include <experimental/__config>
73#include <experimental/__memory>73#include <experimental/__memory>
74#include <limits>74#include <limits>
75#include <memory>
76#include <new>75#include <new>
77#include <stdexcept>76#include <stdexcept>
77#include <tuple>
78#include <type_traits>78#include <type_traits>
7979
80#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)80#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -86,6 +86,12 @@ _LIBCPP_PUSH_MACROS...@@ -86,6 +86,12 @@ _LIBCPP_PUSH_MACROS
8686
87_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR87_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
89// Round __s up to next multiple of __a.95// Round __s up to next multiple of __a.
90inline _LIBCPP_INLINE_VISIBILITY96inline _LIBCPP_INLINE_VISIBILITY
91size_t __aligned_allocation_size(size_t __s, size_t __a) _NOEXCEPT97size_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...@@ -95,7 +101,7 @@ size_t __aligned_allocation_size(size_t __s, size_t __a) _NOEXCEPT
95}101}
96102
97// 8.5, memory.resource103// 8.5, memory.resource
98class _LIBCPP_TYPE_VIS memory_resource104class _LIBCPP_DEPCREATED_MEMORY_RESOURCE("memory_resource") _LIBCPP_TYPE_VIS memory_resource
99{105{
100 static const size_t __max_align = _LIBCPP_ALIGNOF(max_align_t);106 static const size_t __max_align = _LIBCPP_ALIGNOF(max_align_t);
101107
...@@ -123,37 +129,37 @@ private:...@@ -123,37 +129,37 @@ private:
123};129};
124130
125// 8.5.4, memory.resource.eq131// 8.5.4, memory.resource.eq
126inline _LIBCPP_INLINE_VISIBILITY132_LIBCPP_DEPCREATED_MEMORY_RESOURCE("operator==(memory_resource, memory_resource)") inline _LIBCPP_INLINE_VISIBILITY
127bool operator==(memory_resource const & __lhs,133bool operator==(memory_resource const & __lhs,
128 memory_resource const & __rhs) _NOEXCEPT134 memory_resource const & __rhs) _NOEXCEPT
129{135{
130 return &__lhs == &__rhs || __lhs.is_equal(__rhs);136 return &__lhs == &__rhs || __lhs.is_equal(__rhs);
131}137}
132138
133inline _LIBCPP_INLINE_VISIBILITY139_LIBCPP_DEPCREATED_MEMORY_RESOURCE("operator!=(memory_resource, memory_resource)") inline _LIBCPP_INLINE_VISIBILITY
134bool operator!=(memory_resource const & __lhs,140bool operator!=(memory_resource const & __lhs,
135 memory_resource const & __rhs) _NOEXCEPT141 memory_resource const & __rhs) _NOEXCEPT
136{142{
137 return !(__lhs == __rhs);143 return !(__lhs == __rhs);
138}144}
139145
140_LIBCPP_FUNC_VIS146_LIBCPP_DEPCREATED_MEMORY_RESOURCE("new_delete_resource()") _LIBCPP_FUNC_VIS
141memory_resource * new_delete_resource() _NOEXCEPT;147memory_resource * new_delete_resource() _NOEXCEPT;
142148
143_LIBCPP_FUNC_VIS149_LIBCPP_DEPCREATED_MEMORY_RESOURCE("null_memory_resource()") _LIBCPP_FUNC_VIS
144memory_resource * null_memory_resource() _NOEXCEPT;150memory_resource * null_memory_resource() _NOEXCEPT;
145151
146_LIBCPP_FUNC_VIS152_LIBCPP_DEPCREATED_MEMORY_RESOURCE("get_default_resource()") _LIBCPP_FUNC_VIS
147memory_resource * get_default_resource() _NOEXCEPT;153memory_resource * get_default_resource() _NOEXCEPT;
148154
149_LIBCPP_FUNC_VIS155_LIBCPP_DEPCREATED_MEMORY_RESOURCE("set_default_resource()") _LIBCPP_FUNC_VIS
150memory_resource * set_default_resource(memory_resource * __new_res) _NOEXCEPT;156memory_resource * set_default_resource(memory_resource * __new_res) _NOEXCEPT;
151157
152// 8.6, memory.polymorphic.allocator.class158// 8.6, memory.polymorphic.allocator.class
153159
154// 8.6.1, memory.polymorphic.allocator.overview160// 8.6.1, memory.polymorphic.allocator.overview
155template <class _ValueType>161template <class _ValueType>
156class _LIBCPP_TEMPLATE_VIS polymorphic_allocator162class _LIBCPP_DEPCREATED_MEMORY_RESOURCE("polymorphic_allocator") _LIBCPP_TEMPLATE_VIS polymorphic_allocator
157{163{
158public:164public:
159 typedef _ValueType value_type;165 typedef _ValueType value_type;
...@@ -314,6 +320,7 @@ private:...@@ -314,6 +320,7 @@ private:
314// 8.6.4, memory.polymorphic.allocator.eq320// 8.6.4, memory.polymorphic.allocator.eq
315321
316template <class _Tp, class _Up>322template <class _Tp, class _Up>
323_LIBCPP_DEPCREATED_MEMORY_RESOURCE("operator==(const polymorphic_allocator&, const polymorphic_allocator&)")
317inline _LIBCPP_INLINE_VISIBILITY324inline _LIBCPP_INLINE_VISIBILITY
318bool operator==(polymorphic_allocator<_Tp> const & __lhs,325bool operator==(polymorphic_allocator<_Tp> const & __lhs,
319 polymorphic_allocator<_Up> const & __rhs) _NOEXCEPT326 polymorphic_allocator<_Up> const & __rhs) _NOEXCEPT
...@@ -322,6 +329,7 @@ bool operator==(polymorphic_allocator<_Tp> const & __lhs,...@@ -322,6 +329,7 @@ bool operator==(polymorphic_allocator<_Tp> const & __lhs,
322}329}
323330
324template <class _Tp, class _Up>331template <class _Tp, class _Up>
332_LIBCPP_DEPCREATED_MEMORY_RESOURCE("operator!=(const polymorphic_allocator&, const polymorphic_allocator&)")
325inline _LIBCPP_INLINE_VISIBILITY333inline _LIBCPP_INLINE_VISIBILITY
326bool operator!=(polymorphic_allocator<_Tp> const & __lhs,334bool operator!=(polymorphic_allocator<_Tp> const & __lhs,
327 polymorphic_allocator<_Up> const & __rhs) _NOEXCEPT335 polymorphic_allocator<_Up> const & __rhs) _NOEXCEPT
...@@ -331,6 +339,7 @@ bool operator!=(polymorphic_allocator<_Tp> const & __lhs,...@@ -331,6 +339,7 @@ bool operator!=(polymorphic_allocator<_Tp> const & __lhs,
331339
332// 8.7, memory.resource.adaptor340// 8.7, memory.resource.adaptor
333341
342_LIBCPP_SUPPRESS_DEPRECATED_PUSH
334// 8.7.1, memory.resource.adaptor.overview343// 8.7.1, memory.resource.adaptor.overview
335template <class _CharAlloc>344template <class _CharAlloc>
336class _LIBCPP_TEMPLATE_VIS __resource_adaptor_imp345class _LIBCPP_TEMPLATE_VIS __resource_adaptor_imp
...@@ -379,7 +388,7 @@ public:...@@ -379,7 +388,7 @@ public:
379388
380// 8.7.3, memory.resource.adaptor.mem389// 8.7.3, memory.resource.adaptor.mem
381private:390private:
382 virtual void * do_allocate(size_t __bytes, size_t)391 void * do_allocate(size_t __bytes, size_t) override
383 {392 {
384 if (__bytes > __max_size())393 if (__bytes > __max_size())
385 __throw_bad_array_new_length();394 __throw_bad_array_new_length();
...@@ -387,7 +396,7 @@ private:...@@ -387,7 +396,7 @@ private:
387 return __alloc_.allocate(__s);396 return __alloc_.allocate(__s);
388 }397 }
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
391 {400 {
392 _LIBCPP_ASSERT(__bytes <= __max_size(),401 _LIBCPP_ASSERT(__bytes <= __max_size(),
393 "do_deallocate called for size which exceeds the maximum allocation size");402 "do_deallocate called for size which exceeds the maximum allocation size");
...@@ -395,7 +404,7 @@ private:...@@ -395,7 +404,7 @@ private:
395 __alloc_.deallocate((_ValueType*)__p, __s);404 __alloc_.deallocate((_ValueType*)__p, __s);
396 }405 }
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 {
399 __resource_adaptor_imp const * __p408 __resource_adaptor_imp const * __p
400 = dynamic_cast<__resource_adaptor_imp const *>(&__other);409 = dynamic_cast<__resource_adaptor_imp const *>(&__other);
401 return __p ? __alloc_ == __p->__alloc_ : false;410 return __p ? __alloc_ == __p->__alloc_ : false;
...@@ -411,9 +420,24 @@ template <class _Alloc>...@@ -411,9 +420,24 @@ template <class _Alloc>
411using resource_adaptor = __resource_adaptor_imp<420using resource_adaptor = __resource_adaptor_imp<
412 typename allocator_traits<_Alloc>::template rebind_alloc<char>421 typename allocator_traits<_Alloc>::template rebind_alloc<char>
413 >;422 >;
423_LIBCPP_SUPPRESS_DEPRECATED_POP
424
425#endif // _LIBCPP_CXX03_LANG
414426
415_LIBCPP_END_NAMESPACE_LFTS_PMR427_LIBCPP_END_NAMESPACE_LFTS_PMR
416428
417_LIBCPP_POP_MACROS429_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
419#endif /* _LIBCPP_EXPERIMENTAL_MEMORY_RESOURCE */443#endif /* _LIBCPP_EXPERIMENTAL_MEMORY_RESOURCE */
lib/libcxx/include/experimental/propagate_const+4-3
...@@ -109,6 +109,7 @@...@@ -109,6 +109,7 @@
109109
110#include <__assert> // all public C++ headers provide the assertion handler110#include <__assert> // all public C++ headers provide the assertion handler
111#include <__functional/operations.h>111#include <__functional/operations.h>
112#include <__fwd/hash.h>
112#include <__utility/forward.h>113#include <__utility/forward.h>
113#include <__utility/move.h>114#include <__utility/move.h>
114#include <__utility/swap.h>115#include <__utility/swap.h>
...@@ -138,15 +139,15 @@ template <class _Tp>...@@ -138,15 +139,15 @@ template <class _Tp>
138class propagate_const139class propagate_const
139{140{
140public:141public:
141 typedef remove_reference_t<decltype(*declval<_Tp&>())> element_type;142 typedef remove_reference_t<decltype(*std::declval<_Tp&>())> element_type;
142143
143 static_assert(!is_array<_Tp>::value,144 static_assert(!is_array<_Tp>::value,
144 "Instantiation of propagate_const with an array type is ill-formed.");145 "Instantiation of propagate_const with an array type is ill-formed.");
145 static_assert(!is_reference<_Tp>::value,146 static_assert(!is_reference<_Tp>::value,
146 "Instantiation of propagate_const with a reference type is ill-formed.");147 "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),
148 "Instantiation of propagate_const with a function-pointer type is ill-formed.");149 "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),
150 "Instantiation of propagate_const with a pointer to (possibly cv-qualified) void is ill-formed.");151 "Instantiation of propagate_const with a pointer to (possibly cv-qualified) void is ill-formed.");
151152
152private:153private:
lib/libcxx/include/experimental/regex+8-4
...@@ -48,18 +48,22 @@ namespace pmr {...@@ -48,18 +48,22 @@ namespace pmr {
4848
49_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR49_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
5050
51#ifndef _LIBCPP_CXX03_LANG
52
51template <class _BiDirIter>53template <class _BiDirIter>
52using match_results =54using match_results =
53 _VSTD::match_results<_BiDirIter,55 _VSTD::match_results<_BiDirIter,
54 polymorphic_allocator<_VSTD::sub_match<_BiDirIter>>>;56 polymorphic_allocator<_VSTD::sub_match<_BiDirIter>>>;
5557
56typedef match_results<const char*> cmatch;58_LIBCPP_DEPCREATED_MEMORY_RESOURCE("cmatch") typedef match_results<const char*> cmatch;
57typedef match_results<_VSTD_LFTS_PMR::string::const_iterator> smatch;59_LIBCPP_DEPCREATED_MEMORY_RESOURCE("smatch") typedef match_results<_VSTD_LFTS_PMR::string::const_iterator> smatch;
58#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS60#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
59typedef match_results<const wchar_t*> wcmatch;61_LIBCPP_DEPCREATED_MEMORY_RESOURCE("wcmatch") typedef match_results<const wchar_t*> wcmatch;
60typedef match_results<_VSTD_LFTS_PMR::wstring::const_iterator> wsmatch;62_LIBCPP_DEPCREATED_MEMORY_RESOURCE("wsmatch") typedef match_results<_VSTD_LFTS_PMR::wstring::const_iterator> wsmatch;
61#endif63#endif
6264
65#endif // _LIBCPP_CXX03_LANG
66
63_LIBCPP_END_NAMESPACE_LFTS_PMR67_LIBCPP_END_NAMESPACE_LFTS_PMR
6468
65#endif /* _LIBCPP_EXPERIMENTAL_REGEX */69#endif /* _LIBCPP_EXPERIMENTAL_REGEX */
lib/libcxx/include/experimental/set+4
...@@ -45,6 +45,8 @@ namespace pmr {...@@ -45,6 +45,8 @@ namespace pmr {
4545
46_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR46_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
4747
48#ifndef _LIBCPP_CXX03_LANG
49
48template <class _Value, class _Compare = less<_Value>>50template <class _Value, class _Compare = less<_Value>>
49using set = _VSTD::set<_Value, _Compare,51using set = _VSTD::set<_Value, _Compare,
50 polymorphic_allocator<_Value>>;52 polymorphic_allocator<_Value>>;
...@@ -53,6 +55,8 @@ template <class _Value, class _Compare = less<_Value>>...@@ -53,6 +55,8 @@ template <class _Value, class _Compare = less<_Value>>
53using multiset = _VSTD::multiset<_Value, _Compare,55using multiset = _VSTD::multiset<_Value, _Compare,
54 polymorphic_allocator<_Value>>;56 polymorphic_allocator<_Value>>;
5557
58#endif // _LIBCPP_CXX03_LANG
59
56_LIBCPP_END_NAMESPACE_LFTS_PMR60_LIBCPP_END_NAMESPACE_LFTS_PMR
5761
58#endif /* _LIBCPP_EXPERIMENTAL_SET */62#endif /* _LIBCPP_EXPERIMENTAL_SET */
lib/libcxx/include/experimental/simd+26-23
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP_EXPERIMENTAL_SIMD10#ifndef _LIBCPP_EXPERIMENTAL_SIMD
10#define _LIBCPP_EXPERIMENTAL_SIMD11#define _LIBCPP_EXPERIMENTAL_SIMD
1112
...@@ -656,11 +657,6 @@ public:...@@ -656,11 +657,6 @@ public:
656#include <experimental/__config>657#include <experimental/__config>
657#include <tuple>658#include <tuple>
658659
659#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
660# include <algorithm>
661# include <functional>
662#endif
663
664#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)660#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
665# pragma GCC system_header661# pragma GCC system_header
666#endif662#endif
...@@ -720,12 +716,12 @@ public:...@@ -720,12 +716,12 @@ public:
720716
721#ifndef _LIBCPP_HAS_NO_VECTOR_EXTENSION717#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) {
724 return ((__val - 1) & __val) == 0 ? __val720 return ((__val - 1) & __val) == 0 ? __val
725 : __floor_pow_of_2((__val - 1) & __val);721 : __floor_pow_of_2((__val - 1) & __val);
726}722}
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) {
729 return __val == 1 ? 1 : __floor_pow_of_2(__val - 1) << 1;725 return __val == 1 ? 1 : __floor_pow_of_2(__val - 1) << 1;
730}726}
731727
...@@ -913,25 +909,27 @@ public:...@@ -913,25 +909,27 @@ public:
913};909};
914910
915template <class _To, class _From>911template <class _To, class _From>
916constexpr decltype(_To{std::declval<_From>()}, true)912_LIBCPP_HIDE_FROM_ABI constexpr decltype(_To{std::declval<_From>()}, true)
917__is_non_narrowing_convertible_impl(_From) {913__is_non_narrowing_convertible_impl(_From) {
918 return true;914 return true;
919}915}
920916
921template <class _To>917template <class _To>
922constexpr bool __is_non_narrowing_convertible_impl(...) {918_LIBCPP_HIDE_FROM_ABI constexpr bool __is_non_narrowing_convertible_impl(...) {
923 return false;919 return false;
924}920}
925921
926template <class _From, class _To>922template <class _From, class _To>
923_LIBCPP_HIDE_FROM_ABI
927constexpr typename std::enable_if<std::is_arithmetic<_To>::value &&924constexpr typename std::enable_if<std::is_arithmetic<_To>::value &&
928 std::is_arithmetic<_From>::value,925 std::is_arithmetic<_From>::value,
929 bool>::type926 bool>::type
930__is_non_narrowing_arithmetic_convertible() {927__is_non_narrowing_arithmetic_convertible() {
931 return __is_non_narrowing_convertible_impl<_To>(_From{});928 return experimental::__is_non_narrowing_convertible_impl<_To>(_From{});
932}929}
933930
934template <class _From, class _To>931template <class _From, class _To>
932_LIBCPP_HIDE_FROM_ABI
935constexpr typename std::enable_if<!(std::is_arithmetic<_To>::value &&933constexpr typename std::enable_if<!(std::is_arithmetic<_To>::value &&
936 std::is_arithmetic<_From>::value),934 std::is_arithmetic<_From>::value),
937 bool>::type935 bool>::type
...@@ -940,13 +938,13 @@ __is_non_narrowing_arithmetic_convertible() {...@@ -940,13 +938,13 @@ __is_non_narrowing_arithmetic_convertible() {
940}938}
941939
942template <class _Tp>940template <class _Tp>
943constexpr _Tp __variadic_sum() {941_LIBCPP_HIDE_FROM_ABI constexpr _Tp __variadic_sum() {
944 return _Tp{};942 return _Tp{};
945}943}
946944
947template <class _Tp, class _Up, class... _Args>945template <class _Tp, class _Up, class... _Args>
948constexpr _Tp __variadic_sum(_Up __first, _Args... __rest) {946_LIBCPP_HIDE_FROM_ABI constexpr _Tp __variadic_sum(_Up __first, _Args... __rest) {
949 return static_cast<_Tp>(__first) + __variadic_sum<_Tp>(__rest...);947 return static_cast<_Tp>(__first) + experimental::__variadic_sum<_Tp>(__rest...);
950}948}
951949
952template <class _Tp>950template <class _Tp>
...@@ -955,7 +953,7 @@ struct __nodeduce {...@@ -955,7 +953,7 @@ struct __nodeduce {
955};953};
956954
957template <class _Tp>955template <class _Tp>
958constexpr bool __vectorizable() {956_LIBCPP_HIDE_FROM_ABI constexpr bool __vectorizable() {
959 return std::is_arithmetic<_Tp>::value && !std::is_const<_Tp>::value &&957 return std::is_arithmetic<_Tp>::value && !std::is_const<_Tp>::value &&
960 !std::is_volatile<_Tp>::value && !std::is_same<_Tp, bool>::value;958 !std::is_volatile<_Tp>::value && !std::is_same<_Tp, bool>::value;
961}959}
...@@ -1060,7 +1058,7 @@ struct simd_size<_Tp, __simd_abi<__kind, _Np>>...@@ -1060,7 +1058,7 @@ struct simd_size<_Tp, __simd_abi<__kind, _Np>>
1060 : std::integral_constant<size_t, _Np> {1058 : std::integral_constant<size_t, _Np> {
1061 static_assert(1059 static_assert(
1062 std::is_arithmetic<_Tp>::value &&1060 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,
1064 "Element type should be vectorizable");1062 "Element type should be vectorizable");
1065};1063};
10661064
...@@ -1123,13 +1121,13 @@ struct __simd_cast_traits<simd<_Tp, _NewAbi>> {...@@ -1123,13 +1121,13 @@ struct __simd_cast_traits<simd<_Tp, _NewAbi>> {
1123};1121};
11241122
1125template <class _Tp, class _Up, class _Abi>1123template <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)
1127 -> decltype(__simd_cast_traits<_Tp>::__apply(__v)) {1125 -> decltype(__simd_cast_traits<_Tp>::__apply(__v)) {
1128 return __simd_cast_traits<_Tp>::__apply(__v);1126 return __simd_cast_traits<_Tp>::__apply(__v);
1129}1127}
11301128
1131template <class _Tp, class _Up, class _Abi>1129template <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)
1133 -> decltype(__static_simd_cast_traits<_Tp>::__apply(__v)) {1131 -> decltype(__static_simd_cast_traits<_Tp>::__apply(__v)) {
1134 return __static_simd_cast_traits<_Tp>::__apply(__v);1132 return __static_simd_cast_traits<_Tp>::__apply(__v);
1135}1133}
...@@ -1172,12 +1170,12 @@ array<_SimdType, simd_size<typename _SimdType::value_type, _Abi>::value /...@@ -1172,12 +1170,12 @@ array<_SimdType, simd_size<typename _SimdType::value_type, _Abi>::value /
1172split(const simd_mask<typename _SimdType::value_type, _Abi>&);1170split(const simd_mask<typename _SimdType::value_type, _Abi>&);
11731171
1174template <class _Tp, class... _Abis>1172template <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...)>>
1176concat(const simd<_Tp, _Abis>&...);1174concat(const simd<_Tp, _Abis>&...);
11771175
1178template <class _Tp, class... _Abis>1176template <class _Tp, class... _Abis>
1179simd_mask<_Tp,1177simd_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...)>>
1181concat(const simd_mask<_Tp, _Abis>&...);1179concat(const simd_mask<_Tp, _Abis>&...);
11821180
1183// reductions [simd.mask.reductions]1181// reductions [simd.mask.reductions]
...@@ -1302,7 +1300,7 @@ class const_where_expression {...@@ -1302,7 +1300,7 @@ class const_where_expression {
1302public:1300public:
1303 const_where_expression(const const_where_expression&) = delete;1301 const_where_expression(const const_where_expression&) = delete;
1304 const_where_expression& operator=(const const_where_expression&) = delete;1302 const_where_expression& operator=(const const_where_expression&) = delete;
1305 typename remove_const<_Tp>::type operator-() const&&;1303 __remove_const_t<_Tp> operator-() const&&;
1306 template <class _Up, class _Flags>1304 template <class _Up, class _Flags>
1307 void copy_to(_Up*, _Flags) const&&;1305 void copy_to(_Up*, _Flags) const&&;
1308};1306};
...@@ -1369,8 +1367,8 @@ private:...@@ -1369,8 +1367,8 @@ private:
1369 __is_non_narrowing_arithmetic_convertible<_Up, _Tp>()) ||1367 __is_non_narrowing_arithmetic_convertible<_Up, _Tp>()) ||
1370 (!std::is_arithmetic<_Up>::value &&1368 (!std::is_arithmetic<_Up>::value &&
1371 std::is_convertible<_Up, _Tp>::value) ||1369 std::is_convertible<_Up, _Tp>::value) ||
1372 std::is_same<typename std::remove_const<_Up>::type, int>::value ||1370 std::is_same<__remove_const_t<_Up>, int>::value ||
1373 (std::is_same<typename std::remove_const<_Up>::type,1371 (std::is_same<__remove_const_t<_Up>,
1374 unsigned int>::value &&1372 unsigned int>::value &&
1375 std::is_unsigned<_Tp>::value);1373 std::is_unsigned<_Tp>::value);
1376 }1374 }
...@@ -1381,7 +1379,7 @@ private:...@@ -1381,7 +1379,7 @@ private:
1381 std::integral_constant<size_t, __indicies>())...),1379 std::integral_constant<size_t, __indicies>())...),
1382 bool())1380 bool())
1383 __can_generate(std::index_sequence<__indicies...>) {1381 __can_generate(std::index_sequence<__indicies...>) {
1384 return !__variadic_sum<bool>(1382 return !experimental::__variadic_sum<bool>(
1385 !__can_broadcast<decltype(std::declval<_Generator>()(1383 !__can_broadcast<decltype(std::declval<_Generator>()(
1386 std::integral_constant<size_t, __indicies>()))>()...);1384 std::integral_constant<size_t, __indicies>()))>()...);
1387 }1385 }
...@@ -1579,4 +1577,9 @@ _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD...@@ -1579,4 +1577,9 @@ _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
15791577
1580_LIBCPP_POP_MACROS1578_LIBCPP_POP_MACROS
15811579
1580#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1581# include <algorithm>
1582# include <functional>
1583#endif
1584
1582#endif /* _LIBCPP_EXPERIMENTAL_SIMD */1585#endif /* _LIBCPP_EXPERIMENTAL_SIMD */
lib/libcxx/include/experimental/string+12-4
...@@ -49,17 +49,25 @@ namespace pmr {...@@ -49,17 +49,25 @@ namespace pmr {
4949
50_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR50_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
5151
52#ifndef _LIBCPP_CXX03_LANG
53
54_LIBCPP_SUPPRESS_DEPRECATED_PUSH
55
52template <class _CharT, class _Traits = char_traits<_CharT>>56template <class _CharT, class _Traits = char_traits<_CharT>>
53using basic_string =57using basic_string =
54 _VSTD::basic_string<_CharT, _Traits, polymorphic_allocator<_CharT>>;58 _VSTD::basic_string<_CharT, _Traits, polymorphic_allocator<_CharT>>;
5559
56typedef basic_string<char> string;60_LIBCPP_DEPCREATED_MEMORY_RESOURCE("string") typedef basic_string<char> string;
57typedef basic_string<char16_t> u16string;61_LIBCPP_DEPCREATED_MEMORY_RESOURCE("u16string") typedef basic_string<char16_t> u16string;
58typedef basic_string<char32_t> u32string;62_LIBCPP_DEPCREATED_MEMORY_RESOURCE("u32string") typedef basic_string<char32_t> u32string;
59#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS63#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
60typedef basic_string<wchar_t> wstring;64_LIBCPP_DEPCREATED_MEMORY_RESOURCE("wstring") typedef basic_string<wchar_t> wstring;
61#endif65#endif
6266
67_LIBCPP_SUPPRESS_DEPRECATED_POP
68
69#endif // _LIBCPP_CXX03_LANG
70
63_LIBCPP_END_NAMESPACE_LFTS_PMR71_LIBCPP_END_NAMESPACE_LFTS_PMR
6472
65#endif /* _LIBCPP_EXPERIMENTAL_STRING */73#endif /* _LIBCPP_EXPERIMENTAL_STRING */
lib/libcxx/include/experimental/unordered_map+12-8
...@@ -45,20 +45,14 @@ namespace pmr {...@@ -45,20 +45,14 @@ namespace pmr {
45#include <experimental/memory_resource>45#include <experimental/memory_resource>
46#include <unordered_map>46#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
56#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)48#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
57# pragma GCC system_header49# pragma GCC system_header
58#endif50#endif
5951
60_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR52_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
6153
54#ifndef _LIBCPP_CXX03_LANG
55
62template <class _Key, class _Value,56template <class _Key, class _Value,
63 class _Hash = hash<_Key>, class _Pred = equal_to<_Key>>57 class _Hash = hash<_Key>, class _Pred = equal_to<_Key>>
64using unordered_map = _VSTD::unordered_map<_Key, _Value, _Hash, _Pred,58using unordered_map = _VSTD::unordered_map<_Key, _Value, _Hash, _Pred,
...@@ -69,6 +63,16 @@ template <class _Key, class _Value,...@@ -69,6 +63,16 @@ template <class _Key, class _Value,
69using unordered_multimap = _VSTD::unordered_multimap<_Key, _Value, _Hash, _Pred,63using unordered_multimap = _VSTD::unordered_multimap<_Key, _Value, _Hash, _Pred,
70 polymorphic_allocator<pair<const _Key, _Value>>>;64 polymorphic_allocator<pair<const _Key, _Value>>>;
7165
66#endif // _LIBCPP_CXX03_LANG
67
72_LIBCPP_END_NAMESPACE_LFTS_PMR68_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
74#endif /* _LIBCPP_EXPERIMENTAL_UNORDERED_MAP */78#endif /* _LIBCPP_EXPERIMENTAL_UNORDERED_MAP */
lib/libcxx/include/experimental/unordered_set+4
...@@ -45,6 +45,8 @@ namespace pmr {...@@ -45,6 +45,8 @@ namespace pmr {
4545
46_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR46_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
4747
48#ifndef _LIBCPP_CXX03_LANG
49
48template <class _Value,50template <class _Value,
49 class _Hash = hash<_Value>, class _Pred = equal_to<_Value>>51 class _Hash = hash<_Value>, class _Pred = equal_to<_Value>>
50using unordered_set = _VSTD::unordered_set<_Value, _Hash, _Pred,52using unordered_set = _VSTD::unordered_set<_Value, _Hash, _Pred,
...@@ -55,6 +57,8 @@ template <class _Value,...@@ -55,6 +57,8 @@ template <class _Value,
55using unordered_multiset = _VSTD::unordered_multiset<_Value, _Hash, _Pred,57using unordered_multiset = _VSTD::unordered_multiset<_Value, _Hash, _Pred,
56 polymorphic_allocator<_Value>>;58 polymorphic_allocator<_Value>>;
5759
60#endif // _LIBCPP_CXX03_LANG
61
58_LIBCPP_END_NAMESPACE_LFTS_PMR62_LIBCPP_END_NAMESPACE_LFTS_PMR
5963
60#endif /* _LIBCPP_EXPERIMENTAL_UNORDERED_SET */64#endif /* _LIBCPP_EXPERIMENTAL_UNORDERED_SET */
lib/libcxx/include/experimental/vector+4
...@@ -40,9 +40,13 @@ namespace pmr {...@@ -40,9 +40,13 @@ namespace pmr {
4040
41_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR41_LIBCPP_BEGIN_NAMESPACE_LFTS_PMR
4242
43#ifndef _LIBCPP_CXX03_LANG
44
43template <class _ValueT>45template <class _ValueT>
44using vector = _VSTD::vector<_ValueT, polymorphic_allocator<_ValueT>>;46using vector = _VSTD::vector<_ValueT, polymorphic_allocator<_ValueT>>;
4547
48#endif // _LIBCPP_CXX03_LANG
49
46_LIBCPP_END_NAMESPACE_LFTS_PMR50_LIBCPP_END_NAMESPACE_LFTS_PMR
4751
48#endif /* _LIBCPP_EXPERIMENTAL_VECTOR */52#endif /* _LIBCPP_EXPERIMENTAL_VECTOR */
lib/libcxx/include/ext/__hash+1
...@@ -14,6 +14,7 @@...@@ -14,6 +14,7 @@
1414
15#include <__config>15#include <__config>
16#include <cstring>16#include <cstring>
17#include <stddef.h>
17#include <string>18#include <string>
1819
19namespace __gnu_cxx {20namespace __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>...@@ -210,10 +210,6 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
210#include <stdexcept>210#include <stdexcept>
211#include <type_traits>211#include <type_traits>
212212
213#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
214# include <iterator>
215#endif
216
217#if defined(__DEPRECATED) && __DEPRECATED213#if defined(__DEPRECATED) && __DEPRECATED
218#if defined(_LIBCPP_WARNING)214#if defined(_LIBCPP_WARNING)
219 _LIBCPP_WARNING("Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>")215 _LIBCPP_WARNING("Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>")
...@@ -382,7 +378,7 @@ public:...@@ -382,7 +378,7 @@ public:
382 typedef std::pair<key_type, mapped_type> value_type;378 typedef std::pair<key_type, mapped_type> value_type;
383 typedef typename _HashIterator::difference_type difference_type;379 typedef typename _HashIterator::difference_type difference_type;
384 typedef value_type& reference;380 typedef value_type& reference;
385 typedef typename std::__rebind_pointer<typename _HashIterator::pointer, value_type>::type381 typedef std::__rebind_pointer_t<typename _HashIterator::pointer, value_type>
386 pointer;382 pointer;
387383
388 _LIBCPP_INLINE_VISIBILITY __hash_map_iterator() {}384 _LIBCPP_INLINE_VISIBILITY __hash_map_iterator() {}
...@@ -427,7 +423,7 @@ public:...@@ -427,7 +423,7 @@ public:
427 typedef std::pair<key_type, mapped_type> value_type;423 typedef std::pair<key_type, mapped_type> value_type;
428 typedef typename _HashIterator::difference_type difference_type;424 typedef typename _HashIterator::difference_type difference_type;
429 typedef const value_type& reference;425 typedef const value_type& reference;
430 typedef typename std::__rebind_pointer<typename _HashIterator::pointer, const value_type>::type426 typedef std::__rebind_pointer_t<typename _HashIterator::pointer, const value_type>
431 pointer;427 pointer;
432428
433 _LIBCPP_INLINE_VISIBILITY __hash_map_const_iterator() {}429 _LIBCPP_INLINE_VISIBILITY __hash_map_const_iterator() {}
...@@ -487,8 +483,7 @@ private:...@@ -487,8 +483,7 @@ private:
487 typedef std::pair<key_type, mapped_type> __value_type;483 typedef std::pair<key_type, mapped_type> __value_type;
488 typedef __hash_map_hasher<__value_type, hasher> __hasher;484 typedef __hash_map_hasher<__value_type, hasher> __hasher;
489 typedef __hash_map_equal<__value_type, key_equal> __key_equal;485 typedef __hash_map_equal<__value_type, key_equal> __key_equal;
490 typedef typename std::__rebind_alloc_helper<486 typedef std::__rebind_alloc<std::allocator_traits<allocator_type>, __value_type> __allocator_type;
491 std::allocator_traits<allocator_type>, __value_type>::type __allocator_type;
492487
493 typedef std::__hash_table<__value_type, __hasher,488 typedef std::__hash_table<__value_type, __hasher,
494 __key_equal, __allocator_type> __table;489 __key_equal, __allocator_type> __table;
...@@ -714,7 +709,7 @@ swap(hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,...@@ -714,7 +709,7 @@ swap(hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
714}709}
715710
716template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>711template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
717bool712_LIBCPP_HIDE_FROM_ABI bool
718operator==(const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,713operator==(const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
719 const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)714 const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
720{715{
...@@ -761,7 +756,7 @@ private:...@@ -761,7 +756,7 @@ private:
761 typedef std::pair<key_type, mapped_type> __value_type;756 typedef std::pair<key_type, mapped_type> __value_type;
762 typedef __hash_map_hasher<__value_type, hasher> __hasher;757 typedef __hash_map_hasher<__value_type, hasher> __hasher;
763 typedef __hash_map_equal<__value_type, key_equal> __key_equal;758 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
766 typedef std::__hash_table<__value_type, __hasher,761 typedef std::__hash_table<__value_type, __hasher,
767 __key_equal, __allocator_type> __table;762 __key_equal, __allocator_type> __table;
...@@ -954,7 +949,7 @@ swap(hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,...@@ -954,7 +949,7 @@ swap(hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
954}949}
955950
956template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>951template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
957bool952_LIBCPP_HIDE_FROM_ABI bool
958operator==(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,953operator==(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
959 const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)954 const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
960{955{
...@@ -987,4 +982,9 @@ operator!=(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,...@@ -987,4 +982,9 @@ operator!=(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
987982
988} // namespace __gnu_cxx983} // namespace __gnu_cxx
989984
985#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
986# include <concepts>
987# include <iterator>
988#endif
989
990#endif // _LIBCPP_HASH_MAP990#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>...@@ -199,10 +199,6 @@ template <class Value, class Hash, class Pred, class Alloc>
199#include <ext/__hash>199#include <ext/__hash>
200#include <functional>200#include <functional>
201201
202#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
203# include <iterator>
204#endif
205
206#if defined(__DEPRECATED) && __DEPRECATED202#if defined(__DEPRECATED) && __DEPRECATED
207#if defined(_LIBCPP_WARNING)203#if defined(_LIBCPP_WARNING)
208 _LIBCPP_WARNING("Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set>")204 _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,...@@ -412,7 +408,7 @@ swap(hash_set<_Value, _Hash, _Pred, _Alloc>& __x,
412}408}
413409
414template <class _Value, class _Hash, class _Pred, class _Alloc>410template <class _Value, class _Hash, class _Pred, class _Alloc>
415bool411_LIBCPP_HIDE_FROM_ABI bool
416operator==(const hash_set<_Value, _Hash, _Pred, _Alloc>& __x,412operator==(const hash_set<_Value, _Hash, _Pred, _Alloc>& __x,
417 const hash_set<_Value, _Hash, _Pred, _Alloc>& __y)413 const hash_set<_Value, _Hash, _Pred, _Alloc>& __y)
418{414{
...@@ -633,7 +629,7 @@ swap(hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x,...@@ -633,7 +629,7 @@ swap(hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
633}629}
634630
635template <class _Value, class _Hash, class _Pred, class _Alloc>631template <class _Value, class _Hash, class _Pred, class _Alloc>
636bool632_LIBCPP_HIDE_FROM_ABI bool
637operator==(const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x,633operator==(const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
638 const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __y)634 const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
639{635{
...@@ -666,4 +662,9 @@ operator!=(const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x,...@@ -666,4 +662,9 @@ operator!=(const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
666662
667} // namespace __gnu_cxx663} // namespace __gnu_cxx
668664
665#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
666# include <concepts>
667# include <iterator>
668#endif
669
669#endif // _LIBCPP_HASH_SET670#endif // _LIBCPP_HASH_SET
lib/libcxx/include/fenv.h+3-1
...@@ -56,7 +56,9 @@ int feupdateenv(const fenv_t* envp);...@@ -56,7 +56,9 @@ int feupdateenv(const fenv_t* envp);
56# pragma GCC system_header56# pragma GCC system_header
57#endif57#endif
5858
59#include_next <fenv.h>59#if __has_include_next(<fenv.h>)
60# include_next <fenv.h>
61#endif
6062
61#ifdef __cplusplus63#ifdef __cplusplus
6264
lib/libcxx/include/filesystem+216-20
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP_FILESYSTEM10#ifndef _LIBCPP_FILESYSTEM
10#define _LIBCPP_FILESYSTEM11#define _LIBCPP_FILESYSTEM
1112
...@@ -14,36 +15,223 @@...@@ -14,36 +15,223 @@
1415
15 namespace std::filesystem {16 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
19 void swap(path& lhs, path& rhs) noexcept;159 void swap(path& lhs, path& rhs) noexcept;
20 size_t hash_value(const path& p) noexcept;160 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
40 template <class Source>162 template <class Source>
41 path u8path(const Source& source);163 path u8path(const Source& source);
42 template <class InputIterator>164 template <class InputIterator>
43 path u8path(InputIterator first, InputIterator last);165 path u8path(InputIterator first, InputIterator last);
44166
45 class filesystem_error;167 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
48 class directory_iterator;236 class directory_iterator;
49237
...@@ -64,6 +252,8 @@...@@ -64,6 +252,8 @@
64 uintmax_t capacity;252 uintmax_t capacity;
65 uintmax_t free;253 uintmax_t free;
66 uintmax_t available;254 uintmax_t available;
255
256 friend bool operator==(const space_info&, const space_info&) = default; // C++20
67 };257 };
68258
69 enum class file_type;259 enum class file_type;
...@@ -260,6 +450,8 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct...@@ -260,6 +450,8 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct
260#include <version>450#include <version>
261451
262// standard-mandated includes452// standard-mandated includes
453
454// [fs.filesystem.syn]
263#include <compare>455#include <compare>
264456
265#if defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)457#if defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
...@@ -270,4 +462,8 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct...@@ -270,4 +462,8 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct
270# pragma GCC system_header462# pragma GCC system_header
271#endif463#endif
272464
465#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
466# include <concepts>
467#endif
468
273#endif // _LIBCPP_FILESYSTEM469#endif // _LIBCPP_FILESYSTEM
lib/libcxx/include/float.h+3-1
...@@ -76,7 +76,9 @@ Macros:...@@ -76,7 +76,9 @@ Macros:
76# pragma GCC system_header76# pragma GCC system_header
77#endif77#endif
7878
79#include_next <float.h>79#if __has_include_next(<float.h>)
80# include_next <float.h>
81#endif
8082
81#ifdef __cplusplus83#ifdef __cplusplus
8284
lib/libcxx/include/format+39-636
...@@ -112,6 +112,40 @@ namespace std {...@@ -112,6 +112,40 @@ namespace std {
112 using format_parse_context = basic_format_parse_context<char>;112 using format_parse_context = basic_format_parse_context<char>;
113 using wformat_parse_context = basic_format_parse_context<wchar_t>;113 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
115 // [format.arguments], arguments149 // [format.arguments], arguments
116 // [format.arg], class template basic_format_arg150 // [format.arg], class template basic_format_arg
117 template<class Context> class basic_format_arg;151 template<class Context> class basic_format_arg;
...@@ -141,17 +175,17 @@ namespace std {...@@ -141,17 +175,17 @@ namespace std {
141// Enable the contents of the header only when libc++ was built with experimental features enabled.175// Enable the contents of the header only when libc++ was built with experimental features enabled.
142#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)176#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
143177
144#include <__algorithm/clamp.h>
145#include <__config>178#include <__config>
146#include <__debug>
147#include <__format/buffer.h>179#include <__format/buffer.h>
148#include <__format/concepts.h>180#include <__format/concepts.h>
181#include <__format/container_adaptor.h>
149#include <__format/enable_insertable.h>182#include <__format/enable_insertable.h>
150#include <__format/format_arg.h>183#include <__format/format_arg.h>
151#include <__format/format_arg_store.h>184#include <__format/format_arg_store.h>
152#include <__format/format_args.h>185#include <__format/format_args.h>
153#include <__format/format_context.h>186#include <__format/format_context.h>
154#include <__format/format_error.h>187#include <__format/format_error.h>
188#include <__format/format_functions.h>
155#include <__format/format_fwd.h>189#include <__format/format_fwd.h>
156#include <__format/format_parse_context.h>190#include <__format/format_parse_context.h>
157#include <__format/format_string.h>191#include <__format/format_string.h>
...@@ -163,647 +197,16 @@ namespace std {...@@ -163,647 +197,16 @@ namespace std {
163#include <__format/formatter_integer.h>197#include <__format/formatter_integer.h>
164#include <__format/formatter_pointer.h>198#include <__format/formatter_pointer.h>
165#include <__format/formatter_string.h>199#include <__format/formatter_string.h>
200#include <__format/formatter_tuple.h>
166#include <__format/parser_std_format_spec.h>201#include <__format/parser_std_format_spec.h>
202#include <__format/range_default_formatter.h>
203#include <__format/range_formatter.h>
167#include <__format/unicode.h>204#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
181#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)206#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
182# pragma GCC system_header207# pragma GCC system_header
183#endif208#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
807#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)210#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
808211
809#endif // _LIBCPP_FORMAT212#endif // _LIBCPP_FORMAT
lib/libcxx/include/forward_list+51-38
...@@ -188,19 +188,22 @@ template <class T, class Allocator, class Predicate>...@@ -188,19 +188,22 @@ template <class T, class Allocator, class Predicate>
188#include <__iterator/iterator_traits.h>188#include <__iterator/iterator_traits.h>
189#include <__iterator/move_iterator.h>189#include <__iterator/move_iterator.h>
190#include <__iterator/next.h>190#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>
191#include <__memory/swap_allocator.h>197#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>
192#include <__utility/forward.h>201#include <__utility/forward.h>
202#include <__utility/move.h>
193#include <limits>203#include <limits>
194#include <memory>
195#include <type_traits>204#include <type_traits>
196#include <version>205#include <version>
197206
198#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
199# include <algorithm>
200# include <functional>
201# include <iterator>
202#endif
203
204// standard-mandated includes207// standard-mandated includes
205208
206// [iterator.range]209// [iterator.range]
...@@ -239,30 +242,23 @@ struct __forward_list_node_value_type<__forward_list_node<_Tp, _VoidPtr> > {...@@ -239,30 +242,23 @@ struct __forward_list_node_value_type<__forward_list_node<_Tp, _VoidPtr> > {
239template <class _NodePtr>242template <class _NodePtr>
240struct __forward_node_traits {243struct __forward_node_traits {
241244
242 typedef typename remove_cv<245 typedef __remove_cv_t<
243 typename pointer_traits<_NodePtr>::element_type>::type __node;246 typename pointer_traits<_NodePtr>::element_type> __node;
244 typedef typename __forward_list_node_value_type<__node>::type __node_value_type;247 typedef typename __forward_list_node_value_type<__node>::type __node_value_type;
245 typedef _NodePtr __node_pointer;248 typedef _NodePtr __node_pointer;
246 typedef __forward_begin_node<_NodePtr> __begin_node;249 typedef __forward_begin_node<_NodePtr> __begin_node;
247 typedef typename __rebind_pointer<_NodePtr, __begin_node>::type250 typedef __rebind_pointer_t<_NodePtr, __begin_node> __begin_node_pointer;
248 __begin_node_pointer;251 typedef __rebind_pointer_t<_NodePtr, void> __void_pointer;
249 typedef typename __rebind_pointer<_NodePtr, void>::type __void_pointer;
250252
251#if defined(_LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB)253#if defined(_LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB)
252 typedef __begin_node_pointer __iter_node_pointer;254 typedef __begin_node_pointer __iter_node_pointer;
253#else255#else
254 typedef typename conditional<256 typedef __conditional_t<is_pointer<__void_pointer>::value, __begin_node_pointer, __node_pointer>
255 is_pointer<__void_pointer>::value,257 __iter_node_pointer;
256 __begin_node_pointer,
257 __node_pointer
258 >::type __iter_node_pointer;
259#endif258#endif
260259
261 typedef typename conditional<260 typedef __conditional_t<is_same<__iter_node_pointer, __node_pointer>::value, __begin_node_pointer, __node_pointer>
262 is_same<__iter_node_pointer, __node_pointer>::value,261 __non_iter_node_pointer;
263 __begin_node_pointer,
264 __node_pointer
265 >::type __non_iter_node_pointer;
266262
267 _LIBCPP_INLINE_VISIBILITY263 _LIBCPP_INLINE_VISIBILITY
268 static __iter_node_pointer __as_iter_node(__iter_node_pointer __p) {264 static __iter_node_pointer __as_iter_node(__iter_node_pointer __p) {
...@@ -278,7 +274,7 @@ template <class _NodePtr>...@@ -278,7 +274,7 @@ template <class _NodePtr>
278struct __forward_begin_node274struct __forward_begin_node
279{275{
280 typedef _NodePtr pointer;276 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
283 pointer __next_;279 pointer __next_;
284280
...@@ -291,16 +287,11 @@ struct __forward_begin_node...@@ -291,16 +287,11 @@ struct __forward_begin_node
291};287};
292288
293template <class _Tp, class _VoidPtr>289template <class _Tp, class _VoidPtr>
294struct _LIBCPP_HIDDEN __begin_node_of290using __begin_node_of = __forward_begin_node<__rebind_pointer_t<_VoidPtr, __forward_list_node<_Tp, _VoidPtr> > >;
295{
296 typedef __forward_begin_node<
297 typename __rebind_pointer<_VoidPtr, __forward_list_node<_Tp, _VoidPtr> >::type
298 > type;
299};
300291
301template <class _Tp, class _VoidPtr>292template <class _Tp, class _VoidPtr>
302struct _LIBCPP_STANDALONE_DEBUG __forward_list_node293struct _LIBCPP_STANDALONE_DEBUG __forward_list_node
303 : public __begin_node_of<_Tp, _VoidPtr>::type294 : public __begin_node_of<_Tp, _VoidPtr>
304{295{
305 typedef _Tp value_type;296 typedef _Tp value_type;
306297
...@@ -353,7 +344,7 @@ public:...@@ -353,7 +344,7 @@ public:
353 typedef value_type& reference;344 typedef value_type& reference;
354 typedef typename pointer_traits<__node_pointer>::difference_type345 typedef typename pointer_traits<__node_pointer>::difference_type
355 difference_type;346 difference_type;
356 typedef typename __rebind_pointer<__node_pointer, value_type>::type pointer;347 typedef __rebind_pointer_t<__node_pointer, value_type> pointer;
357348
358 _LIBCPP_INLINE_VISIBILITY349 _LIBCPP_INLINE_VISIBILITY
359 __forward_list_iterator() _NOEXCEPT : __ptr_(nullptr) {}350 __forward_list_iterator() _NOEXCEPT : __ptr_(nullptr) {}
...@@ -434,7 +425,7 @@ public:...@@ -434,7 +425,7 @@ public:
434 typedef const value_type& reference;425 typedef const value_type& reference;
435 typedef typename pointer_traits<__node_pointer>::difference_type426 typedef typename pointer_traits<__node_pointer>::difference_type
436 difference_type;427 difference_type;
437 typedef typename __rebind_pointer<__node_pointer, const value_type>::type428 typedef __rebind_pointer_t<__node_pointer, const value_type>
438 pointer;429 pointer;
439430
440 _LIBCPP_INLINE_VISIBILITY431 _LIBCPP_INLINE_VISIBILITY
...@@ -482,14 +473,12 @@ protected:...@@ -482,14 +473,12 @@ protected:
482473
483 typedef typename allocator_traits<allocator_type>::void_pointer void_pointer;474 typedef typename allocator_traits<allocator_type>::void_pointer void_pointer;
484 typedef __forward_list_node<value_type, void_pointer> __node;475 typedef __forward_list_node<value_type, void_pointer> __node;
485 typedef typename __begin_node_of<value_type, void_pointer>::type __begin_node;476 typedef __begin_node_of<value_type, void_pointer> __begin_node;
486 typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __node>::type __node_allocator;477 typedef __rebind_alloc<allocator_traits<allocator_type>, __node> __node_allocator;
487 typedef allocator_traits<__node_allocator> __node_traits;478 typedef allocator_traits<__node_allocator> __node_traits;
488 typedef typename __node_traits::pointer __node_pointer;479 typedef typename __node_traits::pointer __node_pointer;
489480
490 typedef typename __rebind_alloc_helper<481 typedef __rebind_alloc<allocator_traits<allocator_type>, __begin_node> __begin_node_allocator;
491 allocator_traits<allocator_type>, __begin_node
492 >::type __begin_node_allocator;
493 typedef typename allocator_traits<__begin_node_allocator>::pointer482 typedef typename allocator_traits<__begin_node_allocator>::pointer
494 __begin_node_pointer;483 __begin_node_pointer;
495484
...@@ -497,6 +486,10 @@ protected:...@@ -497,6 +486,10 @@ protected:
497 "internal allocator type must differ from user-specified "486 "internal allocator type must differ from user-specified "
498 "type; otherwise overload resolution breaks");487 "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
500 __compressed_pair<__begin_node, __node_allocator> __before_begin_;493 __compressed_pair<__begin_node, __node_allocator> __before_begin_;
501494
502 _LIBCPP_INLINE_VISIBILITY495 _LIBCPP_INLINE_VISIBILITY
...@@ -852,7 +845,7 @@ public:...@@ -852,7 +845,7 @@ public:
852 __remove_return_type remove(const value_type& __v);845 __remove_return_type remove(const value_type& __v);
853 template <class _Predicate> __remove_return_type remove_if(_Predicate __pred);846 template <class _Predicate> __remove_return_type remove_if(_Predicate __pred);
854 _LIBCPP_INLINE_VISIBILITY847 _LIBCPP_INLINE_VISIBILITY
855 __remove_return_type unique() {return unique(__equal_to<value_type>());}848 __remove_return_type unique() { return unique(__equal_to()); }
856 template <class _BinaryPredicate> __remove_return_type unique(_BinaryPredicate __binary_pred);849 template <class _BinaryPredicate> __remove_return_type unique(_BinaryPredicate __binary_pred);
857#ifndef _LIBCPP_CXX03_LANG850#ifndef _LIBCPP_CXX03_LANG
858 _LIBCPP_INLINE_VISIBILITY851 _LIBCPP_INLINE_VISIBILITY
...@@ -1702,6 +1695,7 @@ forward_list<_Tp, _Alloc>::reverse() _NOEXCEPT...@@ -1702,6 +1695,7 @@ forward_list<_Tp, _Alloc>::reverse() _NOEXCEPT
1702}1695}
17031696
1704template <class _Tp, class _Alloc>1697template <class _Tp, class _Alloc>
1698_LIBCPP_HIDE_FROM_ABI
1705bool operator==(const forward_list<_Tp, _Alloc>& __x,1699bool operator==(const forward_list<_Tp, _Alloc>& __x,
1706 const forward_list<_Tp, _Alloc>& __y)1700 const forward_list<_Tp, _Alloc>& __y)
1707{1701{
...@@ -1785,6 +1779,25 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -1785,6 +1779,25 @@ inline _LIBCPP_INLINE_VISIBILITY
17851779
1786_LIBCPP_END_NAMESPACE_STD1780_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
1788_LIBCPP_POP_MACROS1791_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
1790#endif // _LIBCPP_FORWARD_LIST1803#endif // _LIBCPP_FORWARD_LIST
lib/libcxx/include/fstream+40-23
...@@ -192,6 +192,7 @@ typedef basic_fstream<wchar_t> wfstream;...@@ -192,6 +192,7 @@ typedef basic_fstream<wchar_t> wfstream;
192#include <cstring>192#include <cstring>
193#include <istream>193#include <istream>
194#include <ostream>194#include <ostream>
195#include <typeinfo>
195#include <version>196#include <version>
196197
197#if !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)198#if !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
...@@ -209,6 +210,8 @@ _LIBCPP_PUSH_MACROS...@@ -209,6 +210,8 @@ _LIBCPP_PUSH_MACROS
209# define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS210# define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
210#endif211#endif
211212
213#if !defined(_LIBCPP_HAS_NO_FSTREAM)
214
212_LIBCPP_BEGIN_NAMESPACE_STD215_LIBCPP_BEGIN_NAMESPACE_STD
213216
214template <class _CharT, class _Traits>217template <class _CharT, class _Traits>
...@@ -226,7 +229,7 @@ public:...@@ -226,7 +229,7 @@ public:
226 // 27.9.1.2 Constructors/destructor:229 // 27.9.1.2 Constructors/destructor:
227 basic_filebuf();230 basic_filebuf();
228 basic_filebuf(basic_filebuf&& __rhs);231 basic_filebuf(basic_filebuf&& __rhs);
229 virtual ~basic_filebuf();232 ~basic_filebuf() override;
230233
231 // 27.9.1.3 Assign/swap:234 // 27.9.1.3 Assign/swap:
232 _LIBCPP_INLINE_VISIBILITY235 _LIBCPP_INLINE_VISIBILITY
...@@ -259,16 +262,16 @@ public:...@@ -259,16 +262,16 @@ public:
259262
260 protected:263 protected:
261 // 27.9.1.5 Overridden virtual functions:264 // 27.9.1.5 Overridden virtual functions:
262 virtual int_type underflow();265 int_type underflow() override;
263 virtual int_type pbackfail(int_type __c = traits_type::eof());266 int_type pbackfail(int_type __c = traits_type::eof()) override;
264 virtual int_type overflow (int_type __c = traits_type::eof());267 int_type overflow (int_type __c = traits_type::eof()) override;
265 virtual basic_streambuf<char_type, traits_type>* setbuf(char_type* __s, streamsize __n);268 basic_streambuf<char_type, traits_type>* setbuf(char_type* __s, streamsize __n) override;
266 virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,269 pos_type seekoff(off_type __off, ios_base::seekdir __way,
267 ios_base::openmode __wch = ios_base::in | ios_base::out);270 ios_base::openmode __wch = ios_base::in | ios_base::out) override;
268 virtual pos_type seekpos(pos_type __sp,271 pos_type seekpos(pos_type __sp,
269 ios_base::openmode __wch = ios_base::in | ios_base::out);272 ios_base::openmode __wch = ios_base::in | ios_base::out) override;
270 virtual int sync();273 int sync() override;
271 virtual void imbue(const locale& __loc);274 void imbue(const locale& __loc) override;
272275
273private:276private:
274 char* __extbuf_;277 char* __extbuf_;
...@@ -310,9 +313,9 @@ basic_filebuf<_CharT, _Traits>::basic_filebuf()...@@ -310,9 +313,9 @@ basic_filebuf<_CharT, _Traits>::basic_filebuf()
310 __owns_ib_(false),313 __owns_ib_(false),
311 __always_noconv_(false)314 __always_noconv_(false)
312{315{
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()))
314 {317 {
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());
316 __always_noconv_ = __cv_->always_noconv();319 __always_noconv_ = __cv_->always_noconv();
317 }320 }
318 setbuf(nullptr, 4096);321 setbuf(nullptr, 4096);
...@@ -731,7 +734,7 @@ basic_filebuf<_CharT, _Traits>::underflow()...@@ -731,7 +734,7 @@ basic_filebuf<_CharT, _Traits>::underflow()
731 char_type __1buf;734 char_type __1buf;
732 if (this->gptr() == nullptr)735 if (this->gptr() == nullptr)
733 this->setg(&__1buf, &__1buf+1, &__1buf+1);736 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);
735 int_type __c = traits_type::eof();738 int_type __c = traits_type::eof();
736 if (this->gptr() == this->egptr())739 if (this->gptr() == this->egptr())
737 {740 {
...@@ -739,7 +742,7 @@ basic_filebuf<_CharT, _Traits>::underflow()...@@ -739,7 +742,7 @@ basic_filebuf<_CharT, _Traits>::underflow()
739 if (__always_noconv_)742 if (__always_noconv_)
740 {743 {
741 size_t __nmemb = static_cast<size_t>(this->egptr() - this->eback() - __unget_sz);744 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_);
743 if (__nmemb != 0)746 if (__nmemb != 0)
744 {747 {
745 this->setg(this->eback(),748 this->setg(this->eback(),
...@@ -750,9 +753,11 @@ basic_filebuf<_CharT, _Traits>::underflow()...@@ -750,9 +753,11 @@ basic_filebuf<_CharT, _Traits>::underflow()
750 }753 }
751 else754 else
752 {755 {
753 _LIBCPP_ASSERT ( !(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" );756 if (__extbufend_ != __extbufnext_) {
754 if (__extbufend_ != __extbufnext_)757 _LIBCPP_ASSERT(__extbufnext_ != nullptr, "underflow moving from nullptr");
758 _LIBCPP_ASSERT(__extbuf_ != nullptr, "underflow moving into nullptr");
755 _VSTD::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);759 _VSTD::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
760 }
756 __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);761 __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
757 __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);762 __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);
758 size_t __nmemb = _VSTD::min(static_cast<size_t>(__ibs_ - __unget_sz),763 size_t __nmemb = _VSTD::min(static_cast<size_t>(__ibs_ - __unget_sz),
...@@ -835,7 +840,7 @@ basic_filebuf<_CharT, _Traits>::overflow(int_type __c)...@@ -835,7 +840,7 @@ basic_filebuf<_CharT, _Traits>::overflow(int_type __c)
835 if (__always_noconv_)840 if (__always_noconv_)
836 {841 {
837 size_t __nmemb = static_cast<size_t>(this->pptr() - this->pbase());842 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)
839 return traits_type::eof();844 return traits_type::eof();
840 }845 }
841 else846 else
...@@ -855,7 +860,7 @@ basic_filebuf<_CharT, _Traits>::overflow(int_type __c)...@@ -855,7 +860,7 @@ basic_filebuf<_CharT, _Traits>::overflow(int_type __c)
855 if (__r == codecvt_base::noconv)860 if (__r == codecvt_base::noconv)
856 {861 {
857 size_t __nmemb = static_cast<size_t>(this->pptr() - this->pbase());862 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)
859 return traits_type::eof();864 return traits_type::eof();
860 }865 }
861 else if (__r == codecvt_base::ok || __r == codecvt_base::partial)866 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,...@@ -963,7 +968,7 @@ basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way,
963 return pos_type(off_type(-1));968 return pos_type(off_type(-1));
964 pos_type __r = ftell(__file_);969 pos_type __r = ftell(__file_);
965#else970#else
966 if (fseeko(__file_, __width > 0 ? __width * __off : 0, __whence))971 if (::fseeko(__file_, __width > 0 ? __width * __off : 0, __whence))
967 return pos_type(off_type(-1));972 return pos_type(off_type(-1));
968 pos_type __r = ftello(__file_);973 pos_type __r = ftello(__file_);
969#endif974#endif
...@@ -981,7 +986,7 @@ basic_filebuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode)...@@ -981,7 +986,7 @@ basic_filebuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode)
981 if (fseek(__file_, __sp, SEEK_SET))986 if (fseek(__file_, __sp, SEEK_SET))
982 return pos_type(off_type(-1));987 return pos_type(off_type(-1));
983#else988#else
984 if (fseeko(__file_, __sp, SEEK_SET))989 if (::fseeko(__file_, __sp, SEEK_SET))
985 return pos_type(off_type(-1));990 return pos_type(off_type(-1));
986#endif991#endif
987 __st_ = __sp.state();992 __st_ = __sp.state();
...@@ -1045,7 +1050,7 @@ basic_filebuf<_CharT, _Traits>::sync()...@@ -1045,7 +1050,7 @@ basic_filebuf<_CharT, _Traits>::sync()
1045 if (fseek(__file_, -__c, SEEK_CUR))1050 if (fseek(__file_, -__c, SEEK_CUR))
1046 return -1;1051 return -1;
1047#else1052#else
1048 if (fseeko(__file_, -__c, SEEK_CUR))1053 if (::fseeko(__file_, -__c, SEEK_CUR))
1049 return -1;1054 return -1;
1050#endif1055#endif
1051 if (__update_st)1056 if (__update_st)
...@@ -1062,7 +1067,7 @@ void...@@ -1062,7 +1067,7 @@ void
1062basic_filebuf<_CharT, _Traits>::imbue(const locale& __loc)1067basic_filebuf<_CharT, _Traits>::imbue(const locale& __loc)
1063{1068{
1064 sync();1069 sync();
1065 __cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);1070 __cv_ = &std::use_facet<codecvt<char_type, char, state_type> >(__loc);
1066 bool __old_anc = __always_noconv_;1071 bool __old_anc = __always_noconv_;
1067 __always_noconv_ = __cv_->always_noconv();1072 __always_noconv_ = __cv_->always_noconv();
1068 if (__old_anc != __always_noconv_)1073 if (__old_anc != __always_noconv_)
...@@ -1741,6 +1746,18 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>;...@@ -1741,6 +1746,18 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>;
17411746
1742_LIBCPP_END_NAMESPACE_STD1747_LIBCPP_END_NAMESPACE_STD
17431748
1749#endif // _LIBCPP_HAS_NO_FSTREAM
1750
1744_LIBCPP_POP_MACROS1751_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
1746#endif // _LIBCPP_FSTREAM1763#endif // _LIBCPP_FSTREAM
lib/libcxx/include/functional+7-7
...@@ -531,20 +531,20 @@ POLICY: For non-variadic implementations, the number of arguments is limited...@@ -531,20 +531,20 @@ POLICY: For non-variadic implementations, the number of arguments is limited
531#include <__functional/unary_negate.h>531#include <__functional/unary_negate.h>
532#include <__functional/unwrap_ref.h>532#include <__functional/unwrap_ref.h>
533#include <__utility/forward.h>533#include <__utility/forward.h>
534#include <concepts>
535#include <exception>534#include <exception>
536#include <memory>535#include <memory> // TODO: find out why removing this breaks the modules build
537#include <tuple>
538#include <type_traits>536#include <type_traits>
539#include <typeinfo>537#include <typeinfo>
540#include <version>538#include <version>
541539
542#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
543# include <utility>
544#endif
545
546#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)540#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
547# pragma GCC system_header541# pragma GCC system_header
548#endif542#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
550#endif // _LIBCPP_FUNCTIONAL550#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>;...@@ -367,21 +367,19 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
367#include <__chrono/time_point.h>367#include <__chrono/time_point.h>
368#include <__config>368#include <__config>
369#include <__memory/allocator_arg_t.h>369#include <__memory/allocator_arg_t.h>
370#include <__memory/allocator_destructor.h>
370#include <__memory/uses_allocator.h>371#include <__memory/uses_allocator.h>
372#include <__type_traits/strip_signature.h>
371#include <__utility/auto_cast.h>373#include <__utility/auto_cast.h>
372#include <__utility/forward.h>374#include <__utility/forward.h>
373#include <__utility/move.h>375#include <__utility/move.h>
374#include <exception>376#include <exception>
375#include <memory>
376#include <mutex>377#include <mutex>
378#include <new>
377#include <system_error>379#include <system_error>
378#include <thread>380#include <thread>
379#include <version>381#include <version>
380382
381#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
382# include <chrono>
383#endif
384
385#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)383#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
386# pragma GCC system_header384# pragma GCC system_header
387#endif385#endif
...@@ -518,7 +516,7 @@ public:...@@ -518,7 +516,7 @@ public:
518 const error_code& code() const _NOEXCEPT {return __ec_;}516 const error_code& code() const _NOEXCEPT {return __ec_;}
519517
520 future_error(const future_error&) _NOEXCEPT = default;518 future_error(const future_error&) _NOEXCEPT = default;
521 virtual ~future_error() _NOEXCEPT;519 ~future_error() _NOEXCEPT override;
522};520};
523521
524_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY522_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
...@@ -544,7 +542,7 @@ protected:...@@ -544,7 +542,7 @@ protected:
544 mutable condition_variable __cv_;542 mutable condition_variable __cv_;
545 unsigned __state_;543 unsigned __state_;
546544
547 virtual void __on_zero_shared() _NOEXCEPT;545 void __on_zero_shared() _NOEXCEPT override;
548 void __sub_wait(unique_lock<mutex>& __lk);546 void __sub_wait(unique_lock<mutex>& __lk);
549public:547public:
550 enum548 enum
...@@ -627,11 +625,13 @@ class _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_HIDDEN __assoc_state...@@ -627,11 +625,13 @@ class _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_HIDDEN __assoc_state
627 : public __assoc_sub_state625 : public __assoc_sub_state
628{626{
629 typedef __assoc_sub_state base;627 typedef __assoc_sub_state base;
628_LIBCPP_SUPPRESS_DEPRECATED_PUSH
630 typedef typename aligned_storage<sizeof(_Rp), alignment_of<_Rp>::value>::type _Up;629 typedef typename aligned_storage<sizeof(_Rp), alignment_of<_Rp>::value>::type _Up;
630_LIBCPP_SUPPRESS_DEPRECATED_POP
631protected:631protected:
632 _Up __value_;632 _Up __value_;
633633
634 virtual void __on_zero_shared() _NOEXCEPT;634 void __on_zero_shared() _NOEXCEPT override;
635public:635public:
636636
637 template <class _Arg>637 template <class _Arg>
...@@ -641,7 +641,7 @@ public:...@@ -641,7 +641,7 @@ public:
641 void set_value_at_thread_exit(_Arg&& __arg);641 void set_value_at_thread_exit(_Arg&& __arg);
642642
643 _Rp move();643 _Rp move();
644 typename add_lvalue_reference<_Rp>::type copy();644 __add_lvalue_reference_t<_Rp> copy();
645};645};
646646
647template <class _Rp>647template <class _Rp>
...@@ -687,18 +687,18 @@ __assoc_state<_Rp>::move()...@@ -687,18 +687,18 @@ __assoc_state<_Rp>::move()
687 unique_lock<mutex> __lk(this->__mut_);687 unique_lock<mutex> __lk(this->__mut_);
688 this->__sub_wait(__lk);688 this->__sub_wait(__lk);
689 if (this->__exception_ != nullptr)689 if (this->__exception_ != nullptr)
690 rethrow_exception(this->__exception_);690 std::rethrow_exception(this->__exception_);
691 return _VSTD::move(*reinterpret_cast<_Rp*>(&__value_));691 return _VSTD::move(*reinterpret_cast<_Rp*>(&__value_));
692}692}
693693
694template <class _Rp>694template <class _Rp>
695typename add_lvalue_reference<_Rp>::type695__add_lvalue_reference_t<_Rp>
696__assoc_state<_Rp>::copy()696__assoc_state<_Rp>::copy()
697{697{
698 unique_lock<mutex> __lk(this->__mut_);698 unique_lock<mutex> __lk(this->__mut_);
699 this->__sub_wait(__lk);699 this->__sub_wait(__lk);
700 if (this->__exception_ != nullptr)700 if (this->__exception_ != nullptr)
701 rethrow_exception(this->__exception_);701 std::rethrow_exception(this->__exception_);
702 return *reinterpret_cast<_Rp*>(&__value_);702 return *reinterpret_cast<_Rp*>(&__value_);
703}703}
704704
...@@ -711,7 +711,7 @@ class _LIBCPP_AVAILABILITY_FUTURE __assoc_state<_Rp&>...@@ -711,7 +711,7 @@ class _LIBCPP_AVAILABILITY_FUTURE __assoc_state<_Rp&>
711protected:711protected:
712 _Up __value_;712 _Up __value_;
713713
714 virtual void __on_zero_shared() _NOEXCEPT;714 void __on_zero_shared() _NOEXCEPT override;
715public:715public:
716716
717 void set_value(_Rp& __arg);717 void set_value(_Rp& __arg);
...@@ -758,7 +758,7 @@ __assoc_state<_Rp&>::copy()...@@ -758,7 +758,7 @@ __assoc_state<_Rp&>::copy()
758 unique_lock<mutex> __lk(this->__mut_);758 unique_lock<mutex> __lk(this->__mut_);
759 this->__sub_wait(__lk);759 this->__sub_wait(__lk);
760 if (this->__exception_ != nullptr)760 if (this->__exception_ != nullptr)
761 rethrow_exception(this->__exception_);761 std::rethrow_exception(this->__exception_);
762 return *__value_;762 return *__value_;
763}763}
764764
...@@ -823,7 +823,7 @@ class _LIBCPP_AVAILABILITY_FUTURE __assoc_sub_state_alloc...@@ -823,7 +823,7 @@ class _LIBCPP_AVAILABILITY_FUTURE __assoc_sub_state_alloc
823 typedef __assoc_sub_state base;823 typedef __assoc_sub_state base;
824 _Alloc __alloc_;824 _Alloc __alloc_;
825825
826 virtual void __on_zero_shared() _NOEXCEPT;826 void __on_zero_shared() _NOEXCEPT override;
827public:827public:
828 _LIBCPP_INLINE_VISIBILITY828 _LIBCPP_INLINE_VISIBILITY
829 explicit __assoc_sub_state_alloc(const _Alloc& __a)829 explicit __assoc_sub_state_alloc(const _Alloc& __a)
...@@ -895,7 +895,7 @@ public:...@@ -895,7 +895,7 @@ public:
895 _LIBCPP_INLINE_VISIBILITY895 _LIBCPP_INLINE_VISIBILITY
896 explicit __deferred_assoc_state(_Fp&& __f);896 explicit __deferred_assoc_state(_Fp&& __f);
897897
898 virtual void __execute();898 void __execute() override;
899};899};
900900
901template <class _Fp>901template <class _Fp>
...@@ -982,12 +982,12 @@ class _LIBCPP_AVAILABILITY_FUTURE __async_assoc_state<void, _Fp>...@@ -982,12 +982,12 @@ class _LIBCPP_AVAILABILITY_FUTURE __async_assoc_state<void, _Fp>
982982
983 _Fp __func_;983 _Fp __func_;
984984
985 virtual void __on_zero_shared() _NOEXCEPT;985 void __on_zero_shared() _NOEXCEPT override;
986public:986public:
987 _LIBCPP_INLINE_VISIBILITY987 _LIBCPP_INLINE_VISIBILITY
988 explicit __async_assoc_state(_Fp&& __f);988 explicit __async_assoc_state(_Fp&& __f);
989989
990 virtual void __execute();990 void __execute() override;
991};991};
992992
993template <class _Fp>993template <class _Fp>
...@@ -1628,7 +1628,7 @@ class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_base<_Rp(_ArgTypes...)>...@@ -1628,7 +1628,7 @@ class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_base<_Rp(_ArgTypes...)>
1628public:1628public:
1629 _LIBCPP_INLINE_VISIBILITY1629 _LIBCPP_INLINE_VISIBILITY
1630 __packaged_task_base() {}1630 __packaged_task_base() {}
1631 _LIBCPP_INLINE_VISIBILITY1631 _LIBCPP_HIDE_FROM_ABI_VIRTUAL
1632 virtual ~__packaged_task_base() {}1632 virtual ~__packaged_task_base() {}
1633 virtual void __move_to(__packaged_task_base*) _NOEXCEPT = 0;1633 virtual void __move_to(__packaged_task_base*) _NOEXCEPT = 0;
1634 virtual void destroy() = 0;1634 virtual void destroy() = 0;
...@@ -1704,7 +1704,9 @@ class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_function<_Rp(_ArgTypes...)>...@@ -1704,7 +1704,9 @@ class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_function<_Rp(_ArgTypes...)>
1704 _LIBCPP_INLINE_VISIBILITY _LIBCPP_NO_CFI1704 _LIBCPP_INLINE_VISIBILITY _LIBCPP_NO_CFI
1705 __base* __get_buf() { return (__base*)&__buf_; }1705 __base* __get_buf() { return (__base*)&__buf_; }
17061706
1707 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
1707 typename aligned_storage<3*sizeof(void*)>::type __buf_;1708 typename aligned_storage<3*sizeof(void*)>::type __buf_;
1709 _LIBCPP_SUPPRESS_DEPRECATED_POP
1708 __base* __f_;1710 __base* __f_;
17091711
1710public:1712public:
...@@ -1754,7 +1756,7 @@ template <class _Fp>...@@ -1754,7 +1756,7 @@ template <class _Fp>
1754__packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(_Fp&& __f)1756__packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(_Fp&& __f)
1755 : __f_(nullptr)1757 : __f_(nullptr)
1756{1758{
1757 typedef typename remove_reference<typename decay<_Fp>::type>::type _FR;1759 typedef __libcpp_remove_reference_t<typename decay<_Fp>::type> _FR;
1758 typedef __packaged_task_func<_FR, allocator<_FR>, _Rp(_ArgTypes...)> _FF;1760 typedef __packaged_task_func<_FR, allocator<_FR>, _Rp(_ArgTypes...)> _FF;
1759 if (sizeof(_FF) <= sizeof(__buf_))1761 if (sizeof(_FF) <= sizeof(__buf_))
1760 {1762 {
...@@ -1778,7 +1780,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(...@@ -1778,7 +1780,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(
1778 allocator_arg_t, const _Alloc& __a0, _Fp&& __f)1780 allocator_arg_t, const _Alloc& __a0, _Fp&& __f)
1779 : __f_(nullptr)1781 : __f_(nullptr)
1780{1782{
1781 typedef typename remove_reference<typename decay<_Fp>::type>::type _FR;1783 typedef __libcpp_remove_reference_t<typename decay<_Fp>::type> _FR;
1782 typedef __packaged_task_func<_FR, _Alloc, _Rp(_ArgTypes...)> _FF;1784 typedef __packaged_task_func<_FR, _Alloc, _Rp(_ArgTypes...)> _FF;
1783 if (sizeof(_FF) <= sizeof(__buf_))1785 if (sizeof(_FF) <= sizeof(__buf_))
1784 {1786 {
...@@ -1837,7 +1839,9 @@ __packaged_task_function<_Rp(_ArgTypes...)>::swap(__packaged_task_function& __f)...@@ -1837,7 +1839,9 @@ __packaged_task_function<_Rp(_ArgTypes...)>::swap(__packaged_task_function& __f)
1837{1839{
1838 if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)1840 if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
1839 {1841 {
1842 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
1840 typename aligned_storage<sizeof(__buf_)>::type __tempbuf;1843 typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
1844 _LIBCPP_SUPPRESS_DEPRECATED_POP
1841 __base* __t = (__base*)&__tempbuf;1845 __base* __t = (__base*)&__tempbuf;
1842 __f_->__move_to(__t);1846 __f_->__move_to(__t);
1843 __f_->destroy();1847 __f_->destroy();
...@@ -1891,11 +1895,11 @@ public:...@@ -1891,11 +1895,11 @@ public:
1891 _LIBCPP_INLINE_VISIBILITY1895 _LIBCPP_INLINE_VISIBILITY
1892 packaged_task() _NOEXCEPT : __p_(nullptr) {}1896 packaged_task() _NOEXCEPT : __p_(nullptr) {}
1893 template <class _Fp,1897 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> >
1895 _LIBCPP_INLINE_VISIBILITY1899 _LIBCPP_INLINE_VISIBILITY
1896 explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}1900 explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}
1897 template <class _Fp, class _Allocator,1901 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> >
1899 _LIBCPP_INLINE_VISIBILITY1903 _LIBCPP_INLINE_VISIBILITY
1900 packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)1904 packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
1901 : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),1905 : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
...@@ -2006,11 +2010,11 @@ public:...@@ -2006,11 +2010,11 @@ public:
2006 _LIBCPP_INLINE_VISIBILITY2010 _LIBCPP_INLINE_VISIBILITY
2007 packaged_task() _NOEXCEPT : __p_(nullptr) {}2011 packaged_task() _NOEXCEPT : __p_(nullptr) {}
2008 template <class _Fp,2012 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> >
2010 _LIBCPP_INLINE_VISIBILITY2014 _LIBCPP_INLINE_VISIBILITY
2011 explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}2015 explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}
2012 template <class _Fp, class _Allocator,2016 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> >
2014 _LIBCPP_INLINE_VISIBILITY2018 _LIBCPP_INLINE_VISIBILITY
2015 packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)2019 packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
2016 : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),2020 : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
...@@ -2053,6 +2057,16 @@ public:...@@ -2053,6 +2057,16 @@ public:
2053 void reset();2057 void reset();
2054};2058};
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
2056template<class ..._ArgTypes>2070template<class ..._ArgTypes>
2057void2071void
2058packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args)2072packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args)
...@@ -2174,7 +2188,7 @@ inline _LIBCPP_INLINE_VISIBILITY bool __does_policy_contain(launch __policy, lau...@@ -2174,7 +2188,7 @@ inline _LIBCPP_INLINE_VISIBILITY bool __does_policy_contain(launch __policy, lau
2174{ return (int(__policy) & int(__value)) != 0; }2188{ return (int(__policy) & int(__value)) != 0; }
21752189
2176template <class _Fp, class... _Args>2190template <class _Fp, class... _Args>
2177_LIBCPP_NODISCARD_AFTER_CXX172191_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
2178future<typename __invoke_of<typename decay<_Fp>::type, typename decay<_Args>::type...>::type>2192future<typename __invoke_of<typename decay<_Fp>::type, typename decay<_Args>::type...>::type>
2179async(launch __policy, _Fp&& __f, _Args&&... __args)2193async(launch __policy, _Fp&& __f, _Args&&... __args)
2180{2194{
...@@ -2436,4 +2450,8 @@ future<void>::share() _NOEXCEPT...@@ -2436,4 +2450,8 @@ future<void>::share() _NOEXCEPT
24362450
2437_LIBCPP_END_NAMESPACE_STD2451_LIBCPP_END_NAMESPACE_STD
24382452
2453#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
2454# include <chrono>
2455#endif
2456
2439#endif // _LIBCPP_FUTURE2457#endif // _LIBCPP_FUTURE
lib/libcxx/include/initializer_list+7-7
...@@ -62,7 +62,7 @@ class _LIBCPP_TEMPLATE_VIS initializer_list...@@ -62,7 +62,7 @@ class _LIBCPP_TEMPLATE_VIS initializer_list
62 size_t __size_;62 size_t __size_;
6363
64 _LIBCPP_INLINE_VISIBILITY64 _LIBCPP_INLINE_VISIBILITY
65 _LIBCPP_CONSTEXPR_AFTER_CXX1165 _LIBCPP_CONSTEXPR_SINCE_CXX14
66 initializer_list(const _Ep* __b, size_t __s) _NOEXCEPT66 initializer_list(const _Ep* __b, size_t __s) _NOEXCEPT
67 : __begin_(__b),67 : __begin_(__b),
68 __size_(__s)68 __size_(__s)
...@@ -77,25 +77,25 @@ public:...@@ -77,25 +77,25 @@ public:
77 typedef const _Ep* const_iterator;77 typedef const _Ep* const_iterator;
7878
79 _LIBCPP_INLINE_VISIBILITY79 _LIBCPP_INLINE_VISIBILITY
80 _LIBCPP_CONSTEXPR_AFTER_CXX1180 _LIBCPP_CONSTEXPR_SINCE_CXX14
81 initializer_list() _NOEXCEPT : __begin_(nullptr), __size_(0) {}81 initializer_list() _NOEXCEPT : __begin_(nullptr), __size_(0) {}
8282
83 _LIBCPP_INLINE_VISIBILITY83 _LIBCPP_INLINE_VISIBILITY
84 _LIBCPP_CONSTEXPR_AFTER_CXX1184 _LIBCPP_CONSTEXPR_SINCE_CXX14
85 size_t size() const _NOEXCEPT {return __size_;}85 size_t size() const _NOEXCEPT {return __size_;}
8686
87 _LIBCPP_INLINE_VISIBILITY87 _LIBCPP_INLINE_VISIBILITY
88 _LIBCPP_CONSTEXPR_AFTER_CXX1188 _LIBCPP_CONSTEXPR_SINCE_CXX14
89 const _Ep* begin() const _NOEXCEPT {return __begin_;}89 const _Ep* begin() const _NOEXCEPT {return __begin_;}
9090
91 _LIBCPP_INLINE_VISIBILITY91 _LIBCPP_INLINE_VISIBILITY
92 _LIBCPP_CONSTEXPR_AFTER_CXX1192 _LIBCPP_CONSTEXPR_SINCE_CXX14
93 const _Ep* end() const _NOEXCEPT {return __begin_ + __size_;}93 const _Ep* end() const _NOEXCEPT {return __begin_ + __size_;}
94};94};
9595
96template<class _Ep>96template<class _Ep>
97inline _LIBCPP_INLINE_VISIBILITY97inline _LIBCPP_INLINE_VISIBILITY
98_LIBCPP_CONSTEXPR_AFTER_CXX1198_LIBCPP_CONSTEXPR_SINCE_CXX14
99const _Ep*99const _Ep*
100begin(initializer_list<_Ep> __il) _NOEXCEPT100begin(initializer_list<_Ep> __il) _NOEXCEPT
101{101{
...@@ -104,7 +104,7 @@ begin(initializer_list<_Ep> __il) _NOEXCEPT...@@ -104,7 +104,7 @@ begin(initializer_list<_Ep> __il) _NOEXCEPT
104104
105template<class _Ep>105template<class _Ep>
106inline _LIBCPP_INLINE_VISIBILITY106inline _LIBCPP_INLINE_VISIBILITY
107_LIBCPP_CONSTEXPR_AFTER_CXX11107_LIBCPP_CONSTEXPR_SINCE_CXX14
108const _Ep*108const _Ep*
109end(initializer_list<_Ep> __il) _NOEXCEPT109end(initializer_list<_Ep> __il) _NOEXCEPT
110{110{
lib/libcxx/include/inttypes.h+3-1
...@@ -248,7 +248,9 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int...@@ -248,7 +248,9 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int
248# define __STDC_FORMAT_MACROS248# define __STDC_FORMAT_MACROS
249#endif249#endif
250250
251#include_next <inttypes.h>251#if __has_include_next(<inttypes.h>)
252# include_next <inttypes.h>
253#endif
252254
253#ifdef __cplusplus255#ifdef __cplusplus
254256
lib/libcxx/include/iomanip+12-12
...@@ -278,7 +278,7 @@ setw(int __n)...@@ -278,7 +278,7 @@ setw(int __n)
278template <class _MoneyT> class __iom_t7;278template <class _MoneyT> class __iom_t7;
279279
280template <class _CharT, class _Traits, class _MoneyT>280template <class _CharT, class _Traits, class _MoneyT>
281basic_istream<_CharT, _Traits>&281_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
282operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x);282operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x);
283283
284template <class _MoneyT>284template <class _MoneyT>
...@@ -298,7 +298,7 @@ public:...@@ -298,7 +298,7 @@ public:
298};298};
299299
300template <class _CharT, class _Traits, class _MoneyT>300template <class _CharT, class _Traits, class _MoneyT>
301basic_istream<_CharT, _Traits>&301_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
302operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x)302operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x)
303{303{
304#ifndef _LIBCPP_NO_EXCEPTIONS304#ifndef _LIBCPP_NO_EXCEPTIONS
...@@ -311,7 +311,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x)...@@ -311,7 +311,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x)
311 typedef istreambuf_iterator<_CharT, _Traits> _Ip;311 typedef istreambuf_iterator<_CharT, _Traits> _Ip;
312 typedef money_get<_CharT, _Ip> _Fp;312 typedef money_get<_CharT, _Ip> _Fp;
313 ios_base::iostate __err = ios_base::goodbit;313 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());
315 __mf.get(_Ip(__is), _Ip(), __x.__intl_, __is, __err, __x.__mon_);315 __mf.get(_Ip(__is), _Ip(), __x.__intl_, __is, __err, __x.__mon_);
316 __is.setstate(__err);316 __is.setstate(__err);
317 }317 }
...@@ -338,7 +338,7 @@ get_money(_MoneyT& __mon, bool __intl = false)...@@ -338,7 +338,7 @@ get_money(_MoneyT& __mon, bool __intl = false)
338template <class _MoneyT> class __iom_t8;338template <class _MoneyT> class __iom_t8;
339339
340template <class _CharT, class _Traits, class _MoneyT>340template <class _CharT, class _Traits, class _MoneyT>
341basic_ostream<_CharT, _Traits>&341_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
342operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x);342operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x);
343343
344template <class _MoneyT>344template <class _MoneyT>
...@@ -358,7 +358,7 @@ public:...@@ -358,7 +358,7 @@ public:
358};358};
359359
360template <class _CharT, class _Traits, class _MoneyT>360template <class _CharT, class _Traits, class _MoneyT>
361basic_ostream<_CharT, _Traits>&361_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
362operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x)362operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x)
363{363{
364#ifndef _LIBCPP_NO_EXCEPTIONS364#ifndef _LIBCPP_NO_EXCEPTIONS
...@@ -370,7 +370,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x)...@@ -370,7 +370,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x)
370 {370 {
371 typedef ostreambuf_iterator<_CharT, _Traits> _Op;371 typedef ostreambuf_iterator<_CharT, _Traits> _Op;
372 typedef money_put<_CharT, _Op> _Fp;372 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());
374 if (__mf.put(_Op(__os), __x.__intl_, __os, __os.fill(), __x.__mon_).failed())374 if (__mf.put(_Op(__os), __x.__intl_, __os, __os.fill(), __x.__mon_).failed())
375 __os.setstate(ios_base::badbit);375 __os.setstate(ios_base::badbit);
376 }376 }
...@@ -397,7 +397,7 @@ put_money(const _MoneyT& __mon, bool __intl = false)...@@ -397,7 +397,7 @@ put_money(const _MoneyT& __mon, bool __intl = false)
397template <class _CharT> class __iom_t9;397template <class _CharT> class __iom_t9;
398398
399template <class _CharT, class _Traits>399template <class _CharT, class _Traits>
400basic_istream<_CharT, _Traits>&400_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
401operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x);401operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x);
402402
403template <class _CharT>403template <class _CharT>
...@@ -417,7 +417,7 @@ public:...@@ -417,7 +417,7 @@ public:
417};417};
418418
419template <class _CharT, class _Traits>419template <class _CharT, class _Traits>
420basic_istream<_CharT, _Traits>&420_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
421operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x)421operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x)
422{422{
423#ifndef _LIBCPP_NO_EXCEPTIONS423#ifndef _LIBCPP_NO_EXCEPTIONS
...@@ -430,7 +430,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x)...@@ -430,7 +430,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x)
430 typedef istreambuf_iterator<_CharT, _Traits> _Ip;430 typedef istreambuf_iterator<_CharT, _Traits> _Ip;
431 typedef time_get<_CharT, _Ip> _Fp;431 typedef time_get<_CharT, _Ip> _Fp;
432 ios_base::iostate __err = ios_base::goodbit;432 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());
434 __tf.get(_Ip(__is), _Ip(), __is, __err, __x.__tm_,434 __tf.get(_Ip(__is), _Ip(), __is, __err, __x.__tm_,
435 __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_));435 __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_));
436 __is.setstate(__err);436 __is.setstate(__err);
...@@ -458,7 +458,7 @@ get_time(tm* __tm, const _CharT* __fmt)...@@ -458,7 +458,7 @@ get_time(tm* __tm, const _CharT* __fmt)
458template <class _CharT> class __iom_t10;458template <class _CharT> class __iom_t10;
459459
460template <class _CharT, class _Traits>460template <class _CharT, class _Traits>
461basic_ostream<_CharT, _Traits>&461_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
462operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x);462operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x);
463463
464template <class _CharT>464template <class _CharT>
...@@ -478,7 +478,7 @@ public:...@@ -478,7 +478,7 @@ public:
478};478};
479479
480template <class _CharT, class _Traits>480template <class _CharT, class _Traits>
481basic_ostream<_CharT, _Traits>&481_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
482operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x)482operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x)
483{483{
484#ifndef _LIBCPP_NO_EXCEPTIONS484#ifndef _LIBCPP_NO_EXCEPTIONS
...@@ -490,7 +490,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x)...@@ -490,7 +490,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x)
490 {490 {
491 typedef ostreambuf_iterator<_CharT, _Traits> _Op;491 typedef ostreambuf_iterator<_CharT, _Traits> _Op;
492 typedef time_put<_CharT, _Op> _Fp;492 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());
494 if (__tf.put(_Op(__os), __os, __os.fill(), __x.__tm_,494 if (__tf.put(_Op(__os), __os, __os.fill(), __x.__tm_,
495 __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_)).failed())495 __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_)).failed())
496 __os.setstate(ios_base::badbit);496 __os.setstate(ios_base::badbit);
lib/libcxx/include/ios+43-28
...@@ -224,6 +224,8 @@ storage-class-specifier const error_category& iostream_category() noexcept;...@@ -224,6 +224,8 @@ storage-class-specifier const error_category& iostream_category() noexcept;
224#include <version>224#include <version>
225225
226// standard-mandated includes226// standard-mandated includes
227
228// [ios.syn]
227#include <iosfwd>229#include <iosfwd>
228230
229#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)231#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
...@@ -441,7 +443,7 @@ public:...@@ -441,7 +443,7 @@ public:
441 explicit failure(const string& __msg, const error_code& __ec = io_errc::stream);443 explicit failure(const string& __msg, const error_code& __ec = io_errc::stream);
442 explicit failure(const char* __msg, const error_code& __ec = io_errc::stream);444 explicit failure(const char* __msg, const error_code& __ec = io_errc::stream);
443 failure(const failure&) _NOEXCEPT = default;445 failure(const failure&) _NOEXCEPT = default;
444 virtual ~failure() _NOEXCEPT;446 ~failure() _NOEXCEPT override;
445};447};
446448
447_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY449_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
...@@ -641,7 +643,7 @@ public:...@@ -641,7 +643,7 @@ public:
641 // 27.5.4.1 Constructor/destructor:643 // 27.5.4.1 Constructor/destructor:
642 _LIBCPP_INLINE_VISIBILITY644 _LIBCPP_INLINE_VISIBILITY
643 explicit basic_ios(basic_streambuf<char_type,traits_type>* __sb);645 explicit basic_ios(basic_streambuf<char_type,traits_type>* __sb);
644 virtual ~basic_ios();646 ~basic_ios() override;
645647
646 // 27.5.4.2 Members:648 // 27.5.4.2 Members:
647 _LIBCPP_INLINE_VISIBILITY649 _LIBCPP_INLINE_VISIBILITY
...@@ -764,7 +766,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -764,7 +766,7 @@ inline _LIBCPP_INLINE_VISIBILITY
764char766char
765basic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const767basic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const
766{768{
767 return use_facet<ctype<char_type> >(getloc()).narrow(__c, __dfault);769 return std::use_facet<ctype<char_type> >(getloc()).narrow(__c, __dfault);
768}770}
769771
770template <class _CharT, class _Traits>772template <class _CharT, class _Traits>
...@@ -772,7 +774,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -772,7 +774,7 @@ inline _LIBCPP_INLINE_VISIBILITY
772_CharT774_CharT
773basic_ios<_CharT, _Traits>::widen(char __c) const775basic_ios<_CharT, _Traits>::widen(char __c) const
774{776{
775 return use_facet<ctype<char_type> >(getloc()).widen(__c);777 return std::use_facet<ctype<char_type> >(getloc()).widen(__c);
776}778}
777779
778template <class _CharT, class _Traits>780template <class _CharT, class _Traits>
...@@ -842,7 +844,7 @@ basic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* _...@@ -842,7 +844,7 @@ basic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* _
842 ios_base::set_rdbuf(__sb);844 ios_base::set_rdbuf(__sb);
843}845}
844846
845inline847_LIBCPP_HIDE_FROM_ABI inline
846ios_base&848ios_base&
847boolalpha(ios_base& __str)849boolalpha(ios_base& __str)
848{850{
...@@ -850,7 +852,7 @@ boolalpha(ios_base& __str)...@@ -850,7 +852,7 @@ boolalpha(ios_base& __str)
850 return __str;852 return __str;
851}853}
852854
853inline855_LIBCPP_HIDE_FROM_ABI inline
854ios_base&856ios_base&
855noboolalpha(ios_base& __str)857noboolalpha(ios_base& __str)
856{858{
...@@ -858,7 +860,7 @@ noboolalpha(ios_base& __str)...@@ -858,7 +860,7 @@ noboolalpha(ios_base& __str)
858 return __str;860 return __str;
859}861}
860862
861inline863_LIBCPP_HIDE_FROM_ABI inline
862ios_base&864ios_base&
863showbase(ios_base& __str)865showbase(ios_base& __str)
864{866{
...@@ -866,7 +868,7 @@ showbase(ios_base& __str)...@@ -866,7 +868,7 @@ showbase(ios_base& __str)
866 return __str;868 return __str;
867}869}
868870
869inline871_LIBCPP_HIDE_FROM_ABI inline
870ios_base&872ios_base&
871noshowbase(ios_base& __str)873noshowbase(ios_base& __str)
872{874{
...@@ -874,7 +876,7 @@ noshowbase(ios_base& __str)...@@ -874,7 +876,7 @@ noshowbase(ios_base& __str)
874 return __str;876 return __str;
875}877}
876878
877inline879_LIBCPP_HIDE_FROM_ABI inline
878ios_base&880ios_base&
879showpoint(ios_base& __str)881showpoint(ios_base& __str)
880{882{
...@@ -882,7 +884,7 @@ showpoint(ios_base& __str)...@@ -882,7 +884,7 @@ showpoint(ios_base& __str)
882 return __str;884 return __str;
883}885}
884886
885inline887_LIBCPP_HIDE_FROM_ABI inline
886ios_base&888ios_base&
887noshowpoint(ios_base& __str)889noshowpoint(ios_base& __str)
888{890{
...@@ -890,7 +892,7 @@ noshowpoint(ios_base& __str)...@@ -890,7 +892,7 @@ noshowpoint(ios_base& __str)
890 return __str;892 return __str;
891}893}
892894
893inline895_LIBCPP_HIDE_FROM_ABI inline
894ios_base&896ios_base&
895showpos(ios_base& __str)897showpos(ios_base& __str)
896{898{
...@@ -898,7 +900,7 @@ showpos(ios_base& __str)...@@ -898,7 +900,7 @@ showpos(ios_base& __str)
898 return __str;900 return __str;
899}901}
900902
901inline903_LIBCPP_HIDE_FROM_ABI inline
902ios_base&904ios_base&
903noshowpos(ios_base& __str)905noshowpos(ios_base& __str)
904{906{
...@@ -906,7 +908,7 @@ noshowpos(ios_base& __str)...@@ -906,7 +908,7 @@ noshowpos(ios_base& __str)
906 return __str;908 return __str;
907}909}
908910
909inline911_LIBCPP_HIDE_FROM_ABI inline
910ios_base&912ios_base&
911skipws(ios_base& __str)913skipws(ios_base& __str)
912{914{
...@@ -914,7 +916,7 @@ skipws(ios_base& __str)...@@ -914,7 +916,7 @@ skipws(ios_base& __str)
914 return __str;916 return __str;
915}917}
916918
917inline919_LIBCPP_HIDE_FROM_ABI inline
918ios_base&920ios_base&
919noskipws(ios_base& __str)921noskipws(ios_base& __str)
920{922{
...@@ -922,7 +924,7 @@ noskipws(ios_base& __str)...@@ -922,7 +924,7 @@ noskipws(ios_base& __str)
922 return __str;924 return __str;
923}925}
924926
925inline927_LIBCPP_HIDE_FROM_ABI inline
926ios_base&928ios_base&
927uppercase(ios_base& __str)929uppercase(ios_base& __str)
928{930{
...@@ -930,7 +932,7 @@ uppercase(ios_base& __str)...@@ -930,7 +932,7 @@ uppercase(ios_base& __str)
930 return __str;932 return __str;
931}933}
932934
933inline935_LIBCPP_HIDE_FROM_ABI inline
934ios_base&936ios_base&
935nouppercase(ios_base& __str)937nouppercase(ios_base& __str)
936{938{
...@@ -938,7 +940,7 @@ nouppercase(ios_base& __str)...@@ -938,7 +940,7 @@ nouppercase(ios_base& __str)
938 return __str;940 return __str;
939}941}
940942
941inline943_LIBCPP_HIDE_FROM_ABI inline
942ios_base&944ios_base&
943unitbuf(ios_base& __str)945unitbuf(ios_base& __str)
944{946{
...@@ -946,7 +948,7 @@ unitbuf(ios_base& __str)...@@ -946,7 +948,7 @@ unitbuf(ios_base& __str)
946 return __str;948 return __str;
947}949}
948950
949inline951_LIBCPP_HIDE_FROM_ABI inline
950ios_base&952ios_base&
951nounitbuf(ios_base& __str)953nounitbuf(ios_base& __str)
952{954{
...@@ -954,7 +956,7 @@ nounitbuf(ios_base& __str)...@@ -954,7 +956,7 @@ nounitbuf(ios_base& __str)
954 return __str;956 return __str;
955}957}
956958
957inline959_LIBCPP_HIDE_FROM_ABI inline
958ios_base&960ios_base&
959internal(ios_base& __str)961internal(ios_base& __str)
960{962{
...@@ -962,7 +964,7 @@ internal(ios_base& __str)...@@ -962,7 +964,7 @@ internal(ios_base& __str)
962 return __str;964 return __str;
963}965}
964966
965inline967_LIBCPP_HIDE_FROM_ABI inline
966ios_base&968ios_base&
967left(ios_base& __str)969left(ios_base& __str)
968{970{
...@@ -970,7 +972,7 @@ left(ios_base& __str)...@@ -970,7 +972,7 @@ left(ios_base& __str)
970 return __str;972 return __str;
971}973}
972974
973inline975_LIBCPP_HIDE_FROM_ABI inline
974ios_base&976ios_base&
975right(ios_base& __str)977right(ios_base& __str)
976{978{
...@@ -978,7 +980,7 @@ right(ios_base& __str)...@@ -978,7 +980,7 @@ right(ios_base& __str)
978 return __str;980 return __str;
979}981}
980982
981inline983_LIBCPP_HIDE_FROM_ABI inline
982ios_base&984ios_base&
983dec(ios_base& __str)985dec(ios_base& __str)
984{986{
...@@ -986,7 +988,7 @@ dec(ios_base& __str)...@@ -986,7 +988,7 @@ dec(ios_base& __str)
986 return __str;988 return __str;
987}989}
988990
989inline991_LIBCPP_HIDE_FROM_ABI inline
990ios_base&992ios_base&
991hex(ios_base& __str)993hex(ios_base& __str)
992{994{
...@@ -994,7 +996,7 @@ hex(ios_base& __str)...@@ -994,7 +996,7 @@ hex(ios_base& __str)
994 return __str;996 return __str;
995}997}
996998
997inline999_LIBCPP_HIDE_FROM_ABI inline
998ios_base&1000ios_base&
999oct(ios_base& __str)1001oct(ios_base& __str)
1000{1002{
...@@ -1002,7 +1004,7 @@ oct(ios_base& __str)...@@ -1002,7 +1004,7 @@ oct(ios_base& __str)
1002 return __str;1004 return __str;
1003}1005}
10041006
1005inline1007_LIBCPP_HIDE_FROM_ABI inline
1006ios_base&1008ios_base&
1007fixed(ios_base& __str)1009fixed(ios_base& __str)
1008{1010{
...@@ -1010,7 +1012,7 @@ fixed(ios_base& __str)...@@ -1010,7 +1012,7 @@ fixed(ios_base& __str)
1010 return __str;1012 return __str;
1011}1013}
10121014
1013inline1015_LIBCPP_HIDE_FROM_ABI inline
1014ios_base&1016ios_base&
1015scientific(ios_base& __str)1017scientific(ios_base& __str)
1016{1018{
...@@ -1018,7 +1020,7 @@ scientific(ios_base& __str)...@@ -1018,7 +1020,7 @@ scientific(ios_base& __str)
1018 return __str;1020 return __str;
1019}1021}
10201022
1021inline1023_LIBCPP_HIDE_FROM_ABI inline
1022ios_base&1024ios_base&
1023hexfloat(ios_base& __str)1025hexfloat(ios_base& __str)
1024{1026{
...@@ -1026,7 +1028,7 @@ hexfloat(ios_base& __str)...@@ -1026,7 +1028,7 @@ hexfloat(ios_base& __str)
1026 return __str;1028 return __str;
1027}1029}
10281030
1029inline1031_LIBCPP_HIDE_FROM_ABI inline
1030ios_base&1032ios_base&
1031defaultfloat(ios_base& __str)1033defaultfloat(ios_base& __str)
1032{1034{
...@@ -1036,4 +1038,17 @@ defaultfloat(ios_base& __str)...@@ -1036,4 +1038,17 @@ defaultfloat(ios_base& __str)
10361038
1037_LIBCPP_END_NAMESPACE_STD1039_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
1039#endif // _LIBCPP_IOS1054#endif // _LIBCPP_IOS
lib/libcxx/include/iosfwd+1-25
...@@ -96,6 +96,7 @@ using u32streampos = fpos<char_traits<char32_t>::state_type>;...@@ -96,6 +96,7 @@ using u32streampos = fpos<char_traits<char32_t>::state_type>;
9696
97#include <__assert> // all public C++ headers provide the assertion handler97#include <__assert> // all public C++ headers provide the assertion handler
98#include <__config>98#include <__config>
99#include <__fwd/string.h>
99#include <__mbstate_t.h>100#include <__mbstate_t.h>
100#include <version>101#include <version>
101102
...@@ -107,19 +108,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -107,19 +108,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
107108
108class _LIBCPP_TYPE_VIS ios_base;109class _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
123template <class _CharT, class _Traits = char_traits<_CharT> >111template <class _CharT, class _Traits = char_traits<_CharT> >
124 class _LIBCPP_TEMPLATE_VIS basic_ios;112 class _LIBCPP_TEMPLATE_VIS basic_ios;
125113
...@@ -242,18 +230,6 @@ typedef long int streamoff; // for char_traits in <string>...@@ -242,18 +230,6 @@ typedef long int streamoff; // for char_traits in <string>
242typedef long long streamoff; // for char_traits in <string>230typedef long long streamoff; // for char_traits in <string>
243#endif231#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
257// Include other forward declarations here233// Include other forward declarations here
258template <class _Tp, class _Alloc = allocator<_Tp> >234template <class _Tp, class _Alloc = allocator<_Tp> >
259class _LIBCPP_TEMPLATE_VIS vector;235class _LIBCPP_TEMPLATE_VIS vector;
lib/libcxx/include/iostream+2
...@@ -38,6 +38,8 @@ extern wostream wclog;...@@ -38,6 +38,8 @@ extern wostream wclog;
38#include <version>38#include <version>
3939
40// standard-mandated includes40// standard-mandated includes
41
42// [iostream.syn]
41#include <ios>43#include <ios>
42#include <istream>44#include <istream>
43#include <ostream>45#include <ostream>
lib/libcxx/include/istream+23-18
...@@ -192,7 +192,7 @@ public:...@@ -192,7 +192,7 @@ public:
192 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1192 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
193 explicit basic_istream(basic_streambuf<char_type, traits_type>* __sb) : __gc_(0)193 explicit basic_istream(basic_streambuf<char_type, traits_type>* __sb) : __gc_(0)
194 { this->init(__sb); }194 { this->init(__sb); }
195 virtual ~basic_istream();195 ~basic_istream() override;
196protected:196protected:
197 inline _LIBCPP_INLINE_VISIBILITY197 inline _LIBCPP_INLINE_VISIBILITY
198 basic_istream(basic_istream&& __rhs);198 basic_istream(basic_istream&& __rhs);
...@@ -316,7 +316,7 @@ basic_istream<_CharT, _Traits>::sentry::sentry(basic_istream<_CharT, _Traits>& _...@@ -316,7 +316,7 @@ basic_istream<_CharT, _Traits>::sentry::sentry(basic_istream<_CharT, _Traits>& _
316 if (!__noskipws && (__is.flags() & ios_base::skipws))316 if (!__noskipws && (__is.flags() & ios_base::skipws))
317 {317 {
318 typedef istreambuf_iterator<_CharT, _Traits> _Ip;318 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());
320 _Ip __i(__is);320 _Ip __i(__is);
321 _Ip __eof;321 _Ip __eof;
322 for (; __i != __eof; ++__i)322 for (; __i != __eof; ++__i)
...@@ -366,7 +366,7 @@ __input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {...@@ -366,7 +366,7 @@ __input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {
366#endif // _LIBCPP_NO_EXCEPTIONS366#endif // _LIBCPP_NO_EXCEPTIONS
367 typedef istreambuf_iterator<_CharT, _Traits> _Ip;367 typedef istreambuf_iterator<_CharT, _Traits> _Ip;
368 typedef num_get<_CharT, _Ip> _Fp;368 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);
370#ifndef _LIBCPP_NO_EXCEPTIONS370#ifndef _LIBCPP_NO_EXCEPTIONS
371 }371 }
372 catch (...)372 catch (...)
...@@ -476,7 +476,7 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp...@@ -476,7 +476,7 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp
476 typedef istreambuf_iterator<_CharT, _Traits> _Ip;476 typedef istreambuf_iterator<_CharT, _Traits> _Ip;
477 typedef num_get<_CharT, _Ip> _Fp;477 typedef num_get<_CharT, _Ip> _Fp;
478 long __temp;478 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);
480 if (__temp < numeric_limits<_Tp>::min())480 if (__temp < numeric_limits<_Tp>::min())
481 {481 {
482 __state |= ios_base::failbit;482 __state |= ios_base::failbit;
...@@ -536,7 +536,7 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n)...@@ -536,7 +536,7 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n)
536 {536 {
537#endif537#endif
538 _CharT* __s = __p;538 _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());
540 while (__s != __p + (__n-1))540 while (__s != __p + (__n-1))
541 {541 {
542 typename _Traits::int_type __i = __is.rdbuf()->sgetc();542 typename _Traits::int_type __i = __is.rdbuf()->sgetc();
...@@ -633,7 +633,7 @@ operator>>(basic_istream<char, _Traits>& __is, signed char* __s)...@@ -633,7 +633,7 @@ operator>>(basic_istream<char, _Traits>& __is, signed char* __s)
633#endif // _LIBCPP_STD_VER > 17633#endif // _LIBCPP_STD_VER > 17
634634
635template<class _CharT, class _Traits>635template<class _CharT, class _Traits>
636basic_istream<_CharT, _Traits>&636_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
637operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c)637operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c)
638{638{
639 ios_base::iostate __state = ios_base::goodbit;639 ios_base::iostate __state = ios_base::goodbit;
...@@ -1329,7 +1329,7 @@ basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir)...@@ -1329,7 +1329,7 @@ basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir)
1329}1329}
13301330
1331template <class _CharT, class _Traits>1331template <class _CharT, class _Traits>
1332basic_istream<_CharT, _Traits>&1332_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
1333ws(basic_istream<_CharT, _Traits>& __is)1333ws(basic_istream<_CharT, _Traits>& __is)
1334{1334{
1335 ios_base::iostate __state = ios_base::goodbit;1335 ios_base::iostate __state = ios_base::goodbit;
...@@ -1340,7 +1340,7 @@ ws(basic_istream<_CharT, _Traits>& __is)...@@ -1340,7 +1340,7 @@ ws(basic_istream<_CharT, _Traits>& __is)
1340 try1340 try
1341 {1341 {
1342#endif // _LIBCPP_NO_EXCEPTIONS1342#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());
1344 while (true)1344 while (true)
1345 {1345 {
1346 typename _Traits::int_type __i = __is.rdbuf()->sgetc();1346 typename _Traits::int_type __i = __is.rdbuf()->sgetc();
...@@ -1375,7 +1375,7 @@ struct __is_istreamable : false_type { };...@@ -1375,7 +1375,7 @@ struct __is_istreamable : false_type { };
13751375
1376template <class _Stream, class _Tp>1376template <class _Stream, class _Tp>
1377struct __is_istreamable<_Stream, _Tp, decltype(1377struct __is_istreamable<_Stream, _Tp, decltype(
1378 declval<_Stream>() >> declval<_Tp>(), void()1378 std::declval<_Stream>() >> std::declval<_Tp>(), void()
1379)> : true_type { };1379)> : true_type { };
13801380
1381template <class _Stream, class _Tp, class = typename enable_if<1381template <class _Stream, class _Tp, class = typename enable_if<
...@@ -1408,7 +1408,7 @@ public:...@@ -1408,7 +1408,7 @@ public:
1408 : basic_istream<_CharT, _Traits>(__sb)1408 : basic_istream<_CharT, _Traits>(__sb)
1409 {}1409 {}
14101410
1411 virtual ~basic_iostream();1411 ~basic_iostream() override;
1412protected:1412protected:
1413 inline _LIBCPP_INLINE_VISIBILITY1413 inline _LIBCPP_INLINE_VISIBILITY
1414 basic_iostream(basic_iostream&& __rhs);1414 basic_iostream(basic_iostream&& __rhs);
...@@ -1442,7 +1442,7 @@ basic_iostream<_CharT, _Traits>::~basic_iostream()...@@ -1442,7 +1442,7 @@ basic_iostream<_CharT, _Traits>::~basic_iostream()
1442}1442}
14431443
1444template<class _CharT, class _Traits, class _Allocator>1444template<class _CharT, class _Traits, class _Allocator>
1445basic_istream<_CharT, _Traits>&1445_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
1446operator>>(basic_istream<_CharT, _Traits>& __is,1446operator>>(basic_istream<_CharT, _Traits>& __is,
1447 basic_string<_CharT, _Traits, _Allocator>& __str)1447 basic_string<_CharT, _Traits, _Allocator>& __str)
1448{1448{
...@@ -1461,7 +1461,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -1461,7 +1461,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
1461 if (__n <= 0)1461 if (__n <= 0)
1462 __n = numeric_limits<streamsize>::max();1462 __n = numeric_limits<streamsize>::max();
1463 streamsize __c = 0;1463 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());
1465 while (__c < __n)1465 while (__c < __n)
1466 {1466 {
1467 typename _Traits::int_type __i = __is.rdbuf()->sgetc();1467 typename _Traits::int_type __i = __is.rdbuf()->sgetc();
...@@ -1498,7 +1498,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is,...@@ -1498,7 +1498,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
1498}1498}
14991499
1500template<class _CharT, class _Traits, class _Allocator>1500template<class _CharT, class _Traits, class _Allocator>
1501basic_istream<_CharT, _Traits>&1501_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
1502getline(basic_istream<_CharT, _Traits>& __is,1502getline(basic_istream<_CharT, _Traits>& __is,
1503 basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm)1503 basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm)
1504{1504{
...@@ -1556,7 +1556,7 @@ basic_istream<_CharT, _Traits>&...@@ -1556,7 +1556,7 @@ basic_istream<_CharT, _Traits>&
1556getline(basic_istream<_CharT, _Traits>& __is,1556getline(basic_istream<_CharT, _Traits>& __is,
1557 basic_string<_CharT, _Traits, _Allocator>& __str)1557 basic_string<_CharT, _Traits, _Allocator>& __str)
1558{1558{
1559 return getline(__is, __str, __is.widen('\n'));1559 return std::getline(__is, __str, __is.widen('\n'));
1560}1560}
15611561
1562template<class _CharT, class _Traits, class _Allocator>1562template<class _CharT, class _Traits, class _Allocator>
...@@ -1565,7 +1565,7 @@ basic_istream<_CharT, _Traits>&...@@ -1565,7 +1565,7 @@ basic_istream<_CharT, _Traits>&
1565getline(basic_istream<_CharT, _Traits>&& __is,1565getline(basic_istream<_CharT, _Traits>&& __is,
1566 basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm)1566 basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm)
1567{1567{
1568 return getline(__is, __str, __dlm);1568 return std::getline(__is, __str, __dlm);
1569}1569}
15701570
1571template<class _CharT, class _Traits, class _Allocator>1571template<class _CharT, class _Traits, class _Allocator>
...@@ -1574,11 +1574,11 @@ basic_istream<_CharT, _Traits>&...@@ -1574,11 +1574,11 @@ basic_istream<_CharT, _Traits>&
1574getline(basic_istream<_CharT, _Traits>&& __is,1574getline(basic_istream<_CharT, _Traits>&& __is,
1575 basic_string<_CharT, _Traits, _Allocator>& __str)1575 basic_string<_CharT, _Traits, _Allocator>& __str)
1576{1576{
1577 return getline(__is, __str, __is.widen('\n'));1577 return std::getline(__is, __str, __is.widen('\n'));
1578}1578}
15791579
1580template <class _CharT, class _Traits, size_t _Size>1580template <class _CharT, class _Traits, size_t _Size>
1581basic_istream<_CharT, _Traits>&1581_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
1582operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)1582operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
1583{1583{
1584 ios_base::iostate __state = ios_base::goodbit;1584 ios_base::iostate __state = ios_base::goodbit;
...@@ -1590,7 +1590,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)...@@ -1590,7 +1590,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
1590 {1590 {
1591#endif1591#endif
1592 basic_string<_CharT, _Traits> __str;1592 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());
1594 size_t __c = 0;1594 size_t __c = 0;
1595 _CharT __zero = __ct.widen('0');1595 _CharT __zero = __ct.widen('0');
1596 _CharT __one = __ct.widen('1');1596 _CharT __one = __ct.widen('1');
...@@ -1637,6 +1637,11 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>;...@@ -1637,6 +1637,11 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>;
16371637
1638_LIBCPP_END_NAMESPACE_STD1638_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
1640_LIBCPP_POP_MACROS1645_LIBCPP_POP_MACROS
16411646
1642#endif // _LIBCPP_ISTREAM1647#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;...@@ -717,22 +717,26 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;
717#include <__iterator/wrap_iter.h>717#include <__iterator/wrap_iter.h>
718#include <__memory/addressof.h>718#include <__memory/addressof.h>
719#include <__memory/pointer_traits.h>719#include <__memory/pointer_traits.h>
720#include <compare>
721#include <concepts> // Mandated by the Standard.
722#include <cstddef>720#include <cstddef>
723#include <initializer_list>721#include <initializer_list>
724#include <type_traits>
725#include <version>722#include <version>
726723
727#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES724// 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
728# include <exception>735# include <exception>
729# include <new>736# include <new>
737# include <type_traits>
730# include <typeinfo>738# include <typeinfo>
731# include <utility>739# include <utility>
732#endif740#endif
733741
734#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
735# pragma GCC system_header
736#endif
737
738#endif // _LIBCPP_ITERATOR742#endif // _LIBCPP_ITERATOR
lib/libcxx/include/latch+6-6
...@@ -64,7 +64,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -64,7 +64,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
6464
65class latch65class latch
66{66{
67 __atomic_base<ptrdiff_t> __a;67 __atomic_base<ptrdiff_t> __a_;
6868
69public:69public:
70 static constexpr ptrdiff_t max() noexcept {70 static constexpr ptrdiff_t max() noexcept {
...@@ -72,7 +72,7 @@ public:...@@ -72,7 +72,7 @@ public:
72 }72 }
7373
74 inline _LIBCPP_INLINE_VISIBILITY74 inline _LIBCPP_INLINE_VISIBILITY
75 constexpr explicit latch(ptrdiff_t __expected) : __a(__expected) { }75 constexpr explicit latch(ptrdiff_t __expected) : __a_(__expected) { }
7676
77 ~latch() = default;77 ~latch() = default;
78 latch(const latch&) = delete;78 latch(const latch&) = delete;
...@@ -81,19 +81,19 @@ public:...@@ -81,19 +81,19 @@ public:
81 inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY81 inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
82 void count_down(ptrdiff_t __update = 1)82 void count_down(ptrdiff_t __update = 1)
83 {83 {
84 auto const __old = __a.fetch_sub(__update, memory_order_release);84 auto const __old = __a_.fetch_sub(__update, memory_order_release);
85 if(__old == __update)85 if(__old == __update)
86 __a.notify_all();86 __a_.notify_all();
87 }87 }
88 inline _LIBCPP_INLINE_VISIBILITY88 inline _LIBCPP_INLINE_VISIBILITY
89 bool try_wait() const noexcept89 bool try_wait() const noexcept
90 {90 {
91 return 0 == __a.load(memory_order_acquire);91 return 0 == __a_.load(memory_order_acquire);
92 }92 }
93 inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY93 inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
94 void wait() const94 void wait() const
95 {95 {
96 __cxx_atomic_wait(&__a.__a_, [&]() -> bool {96 __cxx_atomic_wait(&__a_.__a_, [&]() -> bool {
97 return try_wait();97 return try_wait();
98 });98 });
99 }99 }
lib/libcxx/include/limits+10-8
...@@ -104,11 +104,9 @@ template<> class numeric_limits<cv long double>;...@@ -104,11 +104,9 @@ template<> class numeric_limits<cv long double>;
104104
105#include <__assert> // all public C++ headers provide the assertion handler105#include <__assert> // all public C++ headers provide the assertion handler
106#include <__config>106#include <__config>
107#include <type_traits>107#include <__type_traits/is_arithmetic.h>
108108#include <__type_traits/is_signed.h>
109#if defined(_LIBCPP_COMPILER_MSVC)109#include <__type_traits/remove_cv.h>
110#include "__support/win32/limits_msvc_win32.h"
111#endif // _LIBCPP_MSVCRT
112110
113#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)111#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
114# pragma GCC system_header112# pragma GCC system_header
...@@ -432,7 +430,7 @@ protected:...@@ -432,7 +430,7 @@ protected:
432 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __builtin_nansl("");}430 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __builtin_nansl("");}
433 _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __LDBL_DENORM_MIN__;}431 _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__)
436 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;434 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
437#else435#else
438 static _LIBCPP_CONSTEXPR const bool is_iec559 = true;436 static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
...@@ -451,9 +449,9 @@ protected:...@@ -451,9 +449,9 @@ protected:
451449
452template <class _Tp>450template <class _Tp>
453class _LIBCPP_TEMPLATE_VIS numeric_limits451class _LIBCPP_TEMPLATE_VIS numeric_limits
454 : private __libcpp_numeric_limits<typename remove_cv<_Tp>::type>452 : private __libcpp_numeric_limits<__remove_cv_t<_Tp> >
455{453{
456 typedef __libcpp_numeric_limits<typename remove_cv<_Tp>::type> __base;454 typedef __libcpp_numeric_limits<__remove_cv_t<_Tp> > __base;
457 typedef typename __base::type type;455 typedef typename __base::type type;
458public:456public:
459 static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;457 static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
...@@ -825,4 +823,8 @@ _LIBCPP_END_NAMESPACE_STD...@@ -825,4 +823,8 @@ _LIBCPP_END_NAMESPACE_STD
825823
826_LIBCPP_POP_MACROS824_LIBCPP_POP_MACROS
827825
826#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
827# include <type_traits>
828#endif
829
828#endif // _LIBCPP_LIMITS830#endif // _LIBCPP_LIMITS
lib/libcxx/include/limits.h+13-6
...@@ -43,13 +43,13 @@ Macros:...@@ -43,13 +43,13 @@ Macros:
43# pragma GCC system_header43# pragma GCC system_header
44#endif44#endif
4545
46#ifndef __GNUC__46#ifdef _LIBCPP_COMPILER_GCC
47#include_next <limits.h>47
48#else
49// GCC header limits.h recursively includes itself through another header called48// GCC header limits.h recursively includes itself through another header called
50// syslimits.h for some reason. This setup breaks down if we directly49// 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,50// #include_next GCC's limits.h (reasons not entirely clear to me).
52// we manually re-create the necessary include sequence below: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
54// Get the system limits.h defines (force recurse into the next level)54// Get the system limits.h defines (force recurse into the next level)
55#define _GCC_LIMITS_H_55#define _GCC_LIMITS_H_
...@@ -59,6 +59,13 @@ Macros:...@@ -59,6 +59,13 @@ Macros:
59// Get the ISO C defines59// Get the ISO C defines
60#undef _GCC_LIMITS_H_60#undef _GCC_LIMITS_H_
61#include_next <limits.h>61#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
64#endif // _LIBCPP_LIMITS_H71#endif // _LIBCPP_LIMITS_H
lib/libcxx/include/list+43-24
...@@ -194,21 +194,24 @@ template <class T, class Allocator, class Predicate>...@@ -194,21 +194,24 @@ template <class T, class Allocator, class Predicate>
194#include <__iterator/next.h>194#include <__iterator/next.h>
195#include <__iterator/prev.h>195#include <__iterator/prev.h>
196#include <__iterator/reverse_iterator.h>196#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>
197#include <__memory/swap_allocator.h>203#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>
198#include <__utility/forward.h>207#include <__utility/forward.h>
199#include <__utility/move.h>208#include <__utility/move.h>
200#include <__utility/swap.h>209#include <__utility/swap.h>
210#include <cstring>
201#include <limits>211#include <limits>
202#include <memory>
203#include <type_traits>212#include <type_traits>
204#include <version>213#include <version>
205214
206#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
207# include <algorithm>
208# include <functional>
209# include <iterator>
210#endif
211
212// standard-mandated includes215// standard-mandated includes
213216
214// [iterator.range]217// [iterator.range]
...@@ -237,26 +240,19 @@ template <class _Tp, class _VoidPtr> struct __list_node_base;...@@ -237,26 +240,19 @@ template <class _Tp, class _VoidPtr> struct __list_node_base;
237240
238template <class _Tp, class _VoidPtr>241template <class _Tp, class _VoidPtr>
239struct __list_node_pointer_traits {242struct __list_node_pointer_traits {
240 typedef typename __rebind_pointer<_VoidPtr, __list_node<_Tp, _VoidPtr> >::type243 typedef __rebind_pointer_t<_VoidPtr, __list_node<_Tp, _VoidPtr> >
241 __node_pointer;244 __node_pointer;
242 typedef typename __rebind_pointer<_VoidPtr, __list_node_base<_Tp, _VoidPtr> >::type245 typedef __rebind_pointer_t<_VoidPtr, __list_node_base<_Tp, _VoidPtr> >
243 __base_pointer;246 __base_pointer;
244247
245#if defined(_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB)248#if defined(_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB)
246 typedef __base_pointer __link_pointer;249 typedef __base_pointer __link_pointer;
247#else250#else
248 typedef typename conditional<251 typedef __conditional_t<is_pointer<_VoidPtr>::value, __base_pointer, __node_pointer> __link_pointer;
249 is_pointer<_VoidPtr>::value,
250 __base_pointer,
251 __node_pointer
252 >::type __link_pointer;
253#endif252#endif
254253
255 typedef typename conditional<254 typedef __conditional_t<is_same<__link_pointer, __node_pointer>::value, __base_pointer, __node_pointer>
256 is_same<__link_pointer, __node_pointer>::value,255 __non_link_pointer;
257 __base_pointer,
258 __node_pointer
259 >::type __non_link_pointer;
260256
261 static _LIBCPP_INLINE_VISIBILITY257 static _LIBCPP_INLINE_VISIBILITY
262 __link_pointer __unsafe_link_pointer_cast(__link_pointer __p) {258 __link_pointer __unsafe_link_pointer_cast(__link_pointer __p) {
...@@ -340,7 +336,7 @@ public:...@@ -340,7 +336,7 @@ public:
340 typedef bidirectional_iterator_tag iterator_category;336 typedef bidirectional_iterator_tag iterator_category;
341 typedef _Tp value_type;337 typedef _Tp value_type;
342 typedef value_type& reference;338 typedef value_type& reference;
343 typedef typename __rebind_pointer<_VoidPtr, value_type>::type pointer;339 typedef __rebind_pointer_t<_VoidPtr, value_type> pointer;
344 typedef typename pointer_traits<pointer>::difference_type difference_type;340 typedef typename pointer_traits<pointer>::difference_type difference_type;
345341
346 _LIBCPP_INLINE_VISIBILITY342 _LIBCPP_INLINE_VISIBILITY
...@@ -448,7 +444,7 @@ public:...@@ -448,7 +444,7 @@ public:
448 typedef bidirectional_iterator_tag iterator_category;444 typedef bidirectional_iterator_tag iterator_category;
449 typedef _Tp value_type;445 typedef _Tp value_type;
450 typedef const value_type& reference;446 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;
452 typedef typename pointer_traits<pointer>::difference_type difference_type;448 typedef typename pointer_traits<pointer>::difference_type difference_type;
453449
454 _LIBCPP_INLINE_VISIBILITY450 _LIBCPP_INLINE_VISIBILITY
...@@ -555,7 +551,7 @@ protected:...@@ -555,7 +551,7 @@ protected:
555 typedef __list_const_iterator<value_type, __void_pointer> const_iterator;551 typedef __list_const_iterator<value_type, __void_pointer> const_iterator;
556 typedef __list_node_base<value_type, __void_pointer> __node_base;552 typedef __list_node_base<value_type, __void_pointer> __node_base;
557 typedef __list_node<value_type, __void_pointer> __node;553 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;
559 typedef allocator_traits<__node_allocator> __node_alloc_traits;555 typedef allocator_traits<__node_allocator> __node_alloc_traits;
560 typedef typename __node_alloc_traits::pointer __node_pointer;556 typedef typename __node_alloc_traits::pointer __node_pointer;
561 typedef typename __node_alloc_traits::pointer __node_const_pointer;557 typedef typename __node_alloc_traits::pointer __node_const_pointer;
...@@ -566,7 +562,7 @@ protected:...@@ -566,7 +562,7 @@ protected:
566 typedef typename __alloc_traits::const_pointer const_pointer;562 typedef typename __alloc_traits::const_pointer const_pointer;
567 typedef typename __alloc_traits::difference_type difference_type;563 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;
570 typedef typename allocator_traits<__node_base_allocator>::pointer __node_base_pointer;566 typedef typename allocator_traits<__node_base_allocator>::pointer __node_base_pointer;
571 static_assert((!is_same<allocator_type, __node_allocator>::value),567 static_assert((!is_same<allocator_type, __node_allocator>::value),
572 "internal allocator type must differ from user-specified "568 "internal allocator type must differ from user-specified "
...@@ -845,6 +841,10 @@ public:...@@ -845,6 +841,10 @@ public:
845 typedef void __remove_return_type;841 typedef void __remove_return_type;
846#endif842#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
848 _LIBCPP_INLINE_VISIBILITY848 _LIBCPP_INLINE_VISIBILITY
849 list()849 list()
850 _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)850 _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
...@@ -1063,7 +1063,7 @@ public:...@@ -1063,7 +1063,7 @@ public:
1063 __remove_return_type remove(const value_type& __x);1063 __remove_return_type remove(const value_type& __x);
1064 template <class _Pred> __remove_return_type remove_if(_Pred __pred);1064 template <class _Pred> __remove_return_type remove_if(_Pred __pred);
1065 _LIBCPP_INLINE_VISIBILITY1065 _LIBCPP_INLINE_VISIBILITY
1066 __remove_return_type unique() { return unique(__equal_to<value_type>()); }1066 __remove_return_type unique() { return unique(__equal_to()); }
1067 template <class _BinaryPred>1067 template <class _BinaryPred>
1068 __remove_return_type unique(_BinaryPred __binary_pred);1068 __remove_return_type unique(_BinaryPred __binary_pred);
1069 _LIBCPP_INLINE_VISIBILITY1069 _LIBCPP_INLINE_VISIBILITY
...@@ -2362,6 +2362,25 @@ inline constexpr bool __format::__enable_insertable<std::list<wchar_t>> = true;...@@ -2362,6 +2362,25 @@ inline constexpr bool __format::__enable_insertable<std::list<wchar_t>> = true;
23622362
2363_LIBCPP_END_NAMESPACE_STD2363_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
2365_LIBCPP_POP_MACROS2374_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
2367#endif // _LIBCPP_LIST2386#endif // _LIBCPP_LIST
lib/libcxx/include/locale+136-140
...@@ -201,19 +201,18 @@ template <class charT> class messages_byname;...@@ -201,19 +201,18 @@ template <class charT> class messages_byname;
201#include <__iterator/istreambuf_iterator.h>201#include <__iterator/istreambuf_iterator.h>
202#include <__iterator/ostreambuf_iterator.h>202#include <__iterator/ostreambuf_iterator.h>
203#include <__locale>203#include <__locale>
204#include <cstdarg> // TODO: Remove this include204#include <__memory/unique_ptr.h>
205#include <cstdio>205#include <cstdio>
206#include <cstdlib>206#include <cstdlib>
207#include <ctime>207#include <ctime>
208#include <ios>208#include <ios>
209#include <limits>209#include <limits>
210#include <memory>210#include <new>
211#include <streambuf>211#include <streambuf>
212#include <version>212#include <version>
213213
214#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES214// TODO: Fix __bsd_locale_defaults.h
215# include <iterator>215// NOLINTBEGIN(libcpp-robust-against-adl)
216#endif
217216
218#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))217#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
219// Most unix variants have catopen. These are the specific ones that don't.218// Most unix variants have catopen. These are the specific ones that don't.
...@@ -239,7 +238,7 @@ _LIBCPP_PUSH_MACROS...@@ -239,7 +238,7 @@ _LIBCPP_PUSH_MACROS
239238
240_LIBCPP_BEGIN_NAMESPACE_STD239_LIBCPP_BEGIN_NAMESPACE_STD
241240
242#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__)241#if defined(__APPLE__) || defined(__FreeBSD__)
243# define _LIBCPP_GET_C_LOCALE 0242# define _LIBCPP_GET_C_LOCALE 0
244#elif defined(__NetBSD__)243#elif defined(__NetBSD__)
245# define _LIBCPP_GET_C_LOCALE LC_C_LOCALE244# define _LIBCPP_GET_C_LOCALE LC_C_LOCALE
...@@ -269,7 +268,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -269,7 +268,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
269// If the input is "a", the first keyword matches and eofbit is set.268// If the input is "a", the first keyword matches and eofbit is set.
270// If the input is "abc", no match is found and "ab" are consumed.269// If the input is "abc", no match is found and "ab" are consumed.
271template <class _InputIterator, class _ForwardIterator, class _Ctype>270template <class _InputIterator, class _ForwardIterator, class _Ctype>
272_LIBCPP_HIDDEN271_LIBCPP_HIDE_FROM_ABI
273_ForwardIterator272_ForwardIterator
274__scan_keyword(_InputIterator& __b, _InputIterator __e,273__scan_keyword(_InputIterator& __b, _InputIterator __e,
275 _ForwardIterator __kb, _ForwardIterator __ke,274 _ForwardIterator __kb, _ForwardIterator __ke,
...@@ -450,8 +449,8 @@ string...@@ -450,8 +449,8 @@ string
450__num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep)449__num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep)
451{450{
452 locale __loc = __iob.getloc();451 locale __loc = __iob.getloc();
453 use_facet<ctype<_CharT> >(__loc).widen(__src, __src + 26, __atoms);452 std::use_facet<ctype<_CharT> >(__loc).widen(__src, __src + 26, __atoms);
454 const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);453 const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__loc);
455 __thousands_sep = __np.thousands_sep();454 __thousands_sep = __np.thousands_sep();
456 return __np.grouping();455 return __np.grouping();
457}456}
...@@ -463,8 +462,8 @@ __num_get<_CharT>::__stage2_float_prep(ios_base& __iob, _CharT* __atoms, _CharT&...@@ -463,8 +462,8 @@ __num_get<_CharT>::__stage2_float_prep(ios_base& __iob, _CharT* __atoms, _CharT&
463 _CharT& __thousands_sep)462 _CharT& __thousands_sep)
464{463{
465 locale __loc = __iob.getloc();464 locale __loc = __iob.getloc();
466 use_facet<ctype<_CharT> >(__loc).widen(__src, __src + 32, __atoms);465 std::use_facet<ctype<_CharT> >(__loc).widen(__src, __src + 32, __atoms);
467 const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);466 const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__loc);
468 __decimal_point = __np.decimal_point();467 __decimal_point = __np.decimal_point();
469 __thousands_sep = __np.thousands_sep();468 __thousands_sep = __np.thousands_sep();
470 return __np.grouping();469 return __np.grouping();
...@@ -498,7 +497,7 @@ __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*&...@@ -498,7 +497,7 @@ __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*&
498 }497 }
499 return 0;498 return 0;
500 }499 }
501 ptrdiff_t __f = find(__atoms, __atoms + 26, __ct) - __atoms;500 ptrdiff_t __f = std::find(__atoms, __atoms + 26, __ct) - __atoms;
502 if (__f >= 24)501 if (__f >= 24)
503 return -1;502 return -1;
504 switch (__base)503 switch (__base)
...@@ -551,13 +550,13 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex...@@ -551,13 +550,13 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex
551 }550 }
552 return 0;551 return 0;
553 }552 }
554 ptrdiff_t __f = find(__atoms, __atoms + 32, __ct) - __atoms;553 ptrdiff_t __f = std::find(__atoms, __atoms + 32, __ct) - __atoms;
555 if (__f >= 32)554 if (__f >= 32)
556 return -1;555 return -1;
557 char __x = __src[__f];556 char __x = __src[__f];
558 if (__x == '-' || __x == '+')557 if (__x == '-' || __x == '+')
559 {558 {
560 if (__a_end == __a || (__a_end[-1] & 0x5F) == (__exp & 0x7F))559 if (__a_end == __a || (std::toupper(__a_end[-1]) == std::toupper(__exp)))
561 {560 {
562 *__a_end++ = __x;561 *__a_end++ = __x;
563 return 0;562 return 0;
...@@ -566,9 +565,9 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex...@@ -566,9 +565,9 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex
566 }565 }
567 if (__x == 'x' || __x == 'X')566 if (__x == 'x' || __x == 'X')
568 __exp = 'P';567 __exp = 'P';
569 else if ((__x & 0x5F) == __exp)568 else if (std::toupper(__x) == __exp)
570 {569 {
571 __exp |= (char) 0x80;570 __exp = std::tolower(__exp);
572 if (__in_units)571 if (__in_units)
573 {572 {
574 __in_units = false;573 __in_units = false;
...@@ -681,8 +680,7 @@ public:...@@ -681,8 +680,7 @@ public:
681 static locale::id id;680 static locale::id id;
682681
683protected:682protected:
684 _LIBCPP_INLINE_VISIBILITY683 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~num_get() override {}
685 ~num_get() {}
686684
687 template <class _Fp>685 template <class _Fp>
688 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS686 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
...@@ -751,17 +749,17 @@ locale::id...@@ -751,17 +749,17 @@ locale::id
751num_get<_CharT, _InputIterator>::id;749num_get<_CharT, _InputIterator>::id;
752750
753template <class _Tp>751template <class _Tp>
754_LIBCPP_HIDDEN _Tp752_LIBCPP_HIDE_FROM_ABI _Tp
755__num_get_signed_integral(const char* __a, const char* __a_end,753__num_get_signed_integral(const char* __a, const char* __a_end,
756 ios_base::iostate& __err, int __base)754 ios_base::iostate& __err, int __base)
757{755{
758 if (__a != __a_end)756 if (__a != __a_end)
759 {757 {
760 typename remove_reference<decltype(errno)>::type __save_errno = errno;758 __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno;
761 errno = 0;759 errno = 0;
762 char *__p2;760 char *__p2;
763 long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);761 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;
765 if (__current_errno == 0)763 if (__current_errno == 0)
766 errno = __save_errno;764 errno = __save_errno;
767 if (__p2 != __a_end)765 if (__p2 != __a_end)
...@@ -786,7 +784,7 @@ __num_get_signed_integral(const char* __a, const char* __a_end,...@@ -786,7 +784,7 @@ __num_get_signed_integral(const char* __a, const char* __a_end,
786}784}
787785
788template <class _Tp>786template <class _Tp>
789_LIBCPP_HIDDEN _Tp787_LIBCPP_HIDE_FROM_ABI _Tp
790__num_get_unsigned_integral(const char* __a, const char* __a_end,788__num_get_unsigned_integral(const char* __a, const char* __a_end,
791 ios_base::iostate& __err, int __base)789 ios_base::iostate& __err, int __base)
792{790{
...@@ -797,11 +795,11 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end,...@@ -797,11 +795,11 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end,
797 __err = ios_base::failbit;795 __err = ios_base::failbit;
798 return 0;796 return 0;
799 }797 }
800 typename remove_reference<decltype(errno)>::type __save_errno = errno;798 __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno;
801 errno = 0;799 errno = 0;
802 char *__p2;800 char *__p2;
803 unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);801 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;
805 if (__current_errno == 0)803 if (__current_errno == 0)
806 errno = __save_errno;804 errno = __save_errno;
807 if (__p2 != __a_end)805 if (__p2 != __a_end)
...@@ -845,17 +843,17 @@ long double __do_strtod<long double>(const char* __a, char** __p2) {...@@ -845,17 +843,17 @@ long double __do_strtod<long double>(const char* __a, char** __p2) {
845}843}
846844
847template <class _Tp>845template <class _Tp>
848_LIBCPP_HIDDEN846_LIBCPP_HIDE_FROM_ABI
849_Tp847_Tp
850__num_get_float(const char* __a, const char* __a_end, ios_base::iostate& __err)848__num_get_float(const char* __a, const char* __a_end, ios_base::iostate& __err)
851{849{
852 if (__a != __a_end)850 if (__a != __a_end)
853 {851 {
854 typename remove_reference<decltype(errno)>::type __save_errno = errno;852 __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno;
855 errno = 0;853 errno = 0;
856 char *__p2;854 char *__p2;
857 _Tp __ld = __do_strtod<_Tp>(__a, &__p2);855 _Tp __ld = std::__do_strtod<_Tp>(__a, &__p2);
858 typename remove_reference<decltype(errno)>::type __current_errno = errno;856 __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno;
859 if (__current_errno == 0)857 if (__current_errno == 0)
860 errno = __save_errno;858 errno = __save_errno;
861 if (__p2 != __a_end)859 if (__p2 != __a_end)
...@@ -897,8 +895,8 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,...@@ -897,8 +895,8 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
897 }895 }
898 return __b;896 return __b;
899 }897 }
900 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__iob.getloc());898 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__iob.getloc());
901 const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__iob.getloc());899 const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__iob.getloc());
902 typedef typename numpunct<_CharT>::string_type string_type;900 typedef typename numpunct<_CharT>::string_type string_type;
903 const string_type __names[2] = {__np.truename(), __np.falsename()};901 const string_type __names[2] = {__np.truename(), __np.falsename()};
904 const string_type* __i = _VSTD::__scan_keyword(__b, __e, __names, __names+2,902 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,...@@ -955,7 +953,7 @@ num_get<_CharT, _InputIterator>::__do_get_signed(iter_type __b, iter_type __e,
955 if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz)953 if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz)
956 *__g_end++ = __dc;954 *__g_end++ = __dc;
957 // Stage 3955 // 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);
959 // Digit grouping checked957 // Digit grouping checked
960 __check_grouping(__grouping, __g, __g_end, __err);958 __check_grouping(__grouping, __g, __g_end, __err);
961 // EOF checked959 // EOF checked
...@@ -1012,7 +1010,7 @@ num_get<_CharT, _InputIterator>::__do_get_unsigned(iter_type __b, iter_type __e,...@@ -1012,7 +1010,7 @@ num_get<_CharT, _InputIterator>::__do_get_unsigned(iter_type __b, iter_type __e,
1012 if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz)1010 if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz)
1013 *__g_end++ = __dc;1011 *__g_end++ = __dc;
1014 // Stage 31012 // 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);
1016 // Digit grouping checked1014 // Digit grouping checked
1017 __check_grouping(__grouping, __g, __g_end, __err);1015 __check_grouping(__grouping, __g, __g_end, __err);
1018 // EOF checked1016 // EOF checked
...@@ -1067,7 +1065,7 @@ num_get<_CharT, _InputIterator>::__do_get_floating_point(iter_type __b, iter_typ...@@ -1067,7 +1065,7 @@ num_get<_CharT, _InputIterator>::__do_get_floating_point(iter_type __b, iter_typ
1067 if (__grouping.size() != 0 && __in_units && __g_end-__g < __num_get_base::__num_get_buf_sz)1065 if (__grouping.size() != 0 && __in_units && __g_end-__g < __num_get_base::__num_get_buf_sz)
1068 *__g_end++ = __dc;1066 *__g_end++ = __dc;
1069 // Stage 31067 // Stage 3
1070 __v = __num_get_float<_Fp>(__a, __a_end, __err);1068 __v = std::__num_get_float<_Fp>(__a, __a_end, __err);
1071 // Digit grouping checked1069 // Digit grouping checked
1072 __check_grouping(__grouping, __g, __g_end, __err);1070 __check_grouping(__grouping, __g, __g_end, __err);
1073 // EOF checked1071 // EOF checked
...@@ -1089,8 +1087,8 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,...@@ -1089,8 +1087,8 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
1089 char_type __atoms[26];1087 char_type __atoms[26];
1090 char_type __thousands_sep = 0;1088 char_type __thousands_sep = 0;
1091 string __grouping;1089 string __grouping;
1092 use_facet<ctype<_CharT> >(__iob.getloc()).widen(__num_get_base::__src,1090 std::use_facet<ctype<_CharT> >(__iob.getloc()).widen(__num_get_base::__src,
1093 __num_get_base::__src + 26, __atoms);1091 __num_get_base::__src + 26, __atoms);
1094 string __buf;1092 string __buf;
1095 __buf.resize(__buf.capacity());1093 __buf.resize(__buf.capacity());
1096 char* __a = &__buf[0];1094 char* __a = &__buf[0];
...@@ -1157,8 +1155,8 @@ __num_put<_CharT>::__widen_and_group_int(char* __nb, char* __np, char* __ne,...@@ -1157,8 +1155,8 @@ __num_put<_CharT>::__widen_and_group_int(char* __nb, char* __np, char* __ne,
1157 _CharT* __ob, _CharT*& __op, _CharT*& __oe,1155 _CharT* __ob, _CharT*& __op, _CharT*& __oe,
1158 const locale& __loc)1156 const locale& __loc)
1159{1157{
1160 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> > (__loc);1158 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> > (__loc);
1161 const numpunct<_CharT>& __npt = use_facet<numpunct<_CharT> >(__loc);1159 const numpunct<_CharT>& __npt = std::use_facet<numpunct<_CharT> >(__loc);
1162 string __grouping = __npt.grouping();1160 string __grouping = __npt.grouping();
1163 if (__grouping.empty())1161 if (__grouping.empty())
1164 {1162 {
...@@ -1177,7 +1175,7 @@ __num_put<_CharT>::__widen_and_group_int(char* __nb, char* __np, char* __ne,...@@ -1177,7 +1175,7 @@ __num_put<_CharT>::__widen_and_group_int(char* __nb, char* __np, char* __ne,
1177 *__oe++ = __ct.widen(*__nf++);1175 *__oe++ = __ct.widen(*__nf++);
1178 *__oe++ = __ct.widen(*__nf++);1176 *__oe++ = __ct.widen(*__nf++);
1179 }1177 }
1180 reverse(__nf, __ne);1178 std::reverse(__nf, __ne);
1181 _CharT __thousands_sep = __npt.thousands_sep();1179 _CharT __thousands_sep = __npt.thousands_sep();
1182 unsigned __dc = 0;1180 unsigned __dc = 0;
1183 unsigned __dg = 0;1181 unsigned __dg = 0;
...@@ -1194,7 +1192,7 @@ __num_put<_CharT>::__widen_and_group_int(char* __nb, char* __np, char* __ne,...@@ -1194,7 +1192,7 @@ __num_put<_CharT>::__widen_and_group_int(char* __nb, char* __np, char* __ne,
1194 *__oe++ = __ct.widen(*__p);1192 *__oe++ = __ct.widen(*__p);
1195 ++__dc;1193 ++__dc;
1196 }1194 }
1197 reverse(__ob + (__nf - __nb), __oe);1195 std::reverse(__ob + (__nf - __nb), __oe);
1198 }1196 }
1199 if (__np == __ne)1197 if (__np == __ne)
1200 __op = __oe;1198 __op = __oe;
...@@ -1208,8 +1206,8 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,...@@ -1208,8 +1206,8 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,
1208 _CharT* __ob, _CharT*& __op, _CharT*& __oe,1206 _CharT* __ob, _CharT*& __op, _CharT*& __oe,
1209 const locale& __loc)1207 const locale& __loc)
1210{1208{
1211 const ctype<_CharT>& __ct = use_facet<ctype<_CharT> > (__loc);1209 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> > (__loc);
1212 const numpunct<_CharT>& __npt = use_facet<numpunct<_CharT> >(__loc);1210 const numpunct<_CharT>& __npt = std::use_facet<numpunct<_CharT> >(__loc);
1213 string __grouping = __npt.grouping();1211 string __grouping = __npt.grouping();
1214 __oe = __ob;1212 __oe = __ob;
1215 char* __nf = __nb;1213 char* __nf = __nb;
...@@ -1238,7 +1236,7 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,...@@ -1238,7 +1236,7 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,
1238 }1236 }
1239 else1237 else
1240 {1238 {
1241 reverse(__nf, __ns);1239 std::reverse(__nf, __ns);
1242 _CharT __thousands_sep = __npt.thousands_sep();1240 _CharT __thousands_sep = __npt.thousands_sep();
1243 unsigned __dc = 0;1241 unsigned __dc = 0;
1244 unsigned __dg = 0;1242 unsigned __dg = 0;
...@@ -1254,7 +1252,7 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,...@@ -1254,7 +1252,7 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,
1254 *__oe++ = __ct.widen(*__p);1252 *__oe++ = __ct.widen(*__p);
1255 ++__dc;1253 ++__dc;
1256 }1254 }
1257 reverse(__ob + (__nf - __nb), __oe);1255 std::reverse(__ob + (__nf - __nb), __oe);
1258 }1256 }
1259 for (__nf = __ns; __nf < __ne; ++__nf)1257 for (__nf = __ns; __nf < __ne; ++__nf)
1260 {1258 {
...@@ -1352,8 +1350,7 @@ public:...@@ -1352,8 +1350,7 @@ public:
1352 static locale::id id;1350 static locale::id id;
13531351
1354protected:1352protected:
1355 _LIBCPP_INLINE_VISIBILITY1353 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~num_put() override {}
1356 ~num_put() {}
13571354
1358 virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl,1355 virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl,
1359 bool __v) const;1356 bool __v) const;
...@@ -1390,7 +1387,7 @@ locale::id...@@ -1390,7 +1387,7 @@ locale::id
1390num_put<_CharT, _OutputIterator>::id;1387num_put<_CharT, _OutputIterator>::id;
13911388
1392template <class _CharT, class _OutputIterator>1389template <class _CharT, class _OutputIterator>
1393_LIBCPP_HIDDEN1390_LIBCPP_HIDE_FROM_ABI
1394_OutputIterator1391_OutputIterator
1395__pad_and_output(_OutputIterator __s,1392__pad_and_output(_OutputIterator __s,
1396 const _CharT* __ob, const _CharT* __op, const _CharT* __oe,1393 const _CharT* __ob, const _CharT* __op, const _CharT* __oe,
...@@ -1413,7 +1410,7 @@ __pad_and_output(_OutputIterator __s,...@@ -1413,7 +1410,7 @@ __pad_and_output(_OutputIterator __s,
1413}1410}
14141411
1415template <class _CharT, class _Traits>1412template <class _CharT, class _Traits>
1416_LIBCPP_HIDDEN1413_LIBCPP_HIDE_FROM_ABI
1417ostreambuf_iterator<_CharT, _Traits>1414ostreambuf_iterator<_CharT, _Traits>
1418__pad_and_output(ostreambuf_iterator<_CharT, _Traits> __s,1415__pad_and_output(ostreambuf_iterator<_CharT, _Traits> __s,
1419 const _CharT* __ob, const _CharT* __op, const _CharT* __oe,1416 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,...@@ -1465,7 +1462,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
1465{1462{
1466 if ((__iob.flags() & ios_base::boolalpha) == 0)1463 if ((__iob.flags() & ios_base::boolalpha) == 0)
1467 return do_put(__s, __iob, __fl, (unsigned long)__v);1464 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());
1469 typedef typename numpunct<char_type>::string_type string_type;1466 typedef typename numpunct<char_type>::string_type string_type;
1470#ifdef _LIBCPP_ENABLE_DEBUG_MODE1467#ifdef _LIBCPP_ENABLE_DEBUG_MODE
1471 string_type __tmp(__v ? __np.truename() : __np.falsename());1468 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...@@ -1511,7 +1508,7 @@ num_put<_CharT, _OutputIterator>::__do_put_integral(iter_type __s, ios_base& __i
1511 this->__widen_and_group_int(__nar, __np, __ne, __o, __op, __oe, __iob.getloc());1508 this->__widen_and_group_int(__nar, __np, __ne, __o, __op, __oe, __iob.getloc());
1512 // [__o, __oe) contains thousands_sep'd wide number1509 // [__o, __oe) contains thousands_sep'd wide number
1513 // Stage 3 & 41510 // 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);
1515}1512}
15161513
1517template <class _CharT, class _OutputIterator>1514template <class _CharT, class _OutputIterator>
...@@ -1599,7 +1596,7 @@ num_put<_CharT, _OutputIterator>::__do_put_floating_point(iter_type __s, ios_bas...@@ -1599,7 +1596,7 @@ num_put<_CharT, _OutputIterator>::__do_put_floating_point(iter_type __s, ios_bas
1599 this->__widen_and_group_float(__nb, __np, __ne, __ob, __op, __oe, __iob.getloc());1596 this->__widen_and_group_float(__nb, __np, __ne, __ob, __op, __oe, __iob.getloc());
1600 // [__o, __oe) contains thousands_sep'd wide number1597 // [__o, __oe) contains thousands_sep'd wide number
1601 // Stage 3 & 41598 // 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);
1603 return __s;1600 return __s;
1604}1601}
16051602
...@@ -1634,7 +1631,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,...@@ -1634,7 +1631,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
1634 char_type __o[2*(__nbuf-1) - 1];1631 char_type __o[2*(__nbuf-1) - 1];
1635 char_type* __op; // pad here1632 char_type* __op; // pad here
1636 char_type* __oe; // end of output1633 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());
1638 __ct.widen(__nar, __ne, __o);1635 __ct.widen(__nar, __ne, __o);
1639 __oe = __o + (__ne - __nar);1636 __oe = __o + (__ne - __nar);
1640 if (__np == __ne)1637 if (__np == __ne)
...@@ -1643,7 +1640,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,...@@ -1643,7 +1640,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
1643 __op = __o + (__np - __nar);1640 __op = __o + (__np - __nar);
1644 // [__o, __oe) contains wide number1641 // [__o, __oe) contains wide number
1645 // Stage 3 & 41642 // 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);
1647}1644}
16481645
1649extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>;1646extern 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>;...@@ -1652,7 +1649,7 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>;
1652#endif1649#endif
16531650
1654template <class _CharT, class _InputIterator>1651template <class _CharT, class _InputIterator>
1655_LIBCPP_HIDDEN1652_LIBCPP_HIDE_FROM_ABI
1656int1653int
1657__get_up_to_n_digits(_InputIterator& __b, _InputIterator __e,1654__get_up_to_n_digits(_InputIterator& __b, _InputIterator __e,
1658 ios_base::iostate& __err, const ctype<_CharT>& __ct, int __n)1655 ios_base::iostate& __err, const ctype<_CharT>& __ct, int __n)
...@@ -1798,8 +1795,7 @@ public:...@@ -1798,8 +1795,7 @@ public:
1798 static locale::id id;1795 static locale::id id;
17991796
1800protected:1797protected:
1801 _LIBCPP_INLINE_VISIBILITY1798 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_get() override {}
1802 ~time_get() {}
18031799
1804 virtual dateorder do_date_order() const;1800 virtual dateorder do_date_order() const;
1805 virtual iter_type do_get_time(iter_type __b, iter_type __e, ios_base& __iob,1801 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,...@@ -1930,7 +1926,7 @@ time_get<_CharT, _InputIterator>::__get_month(int& __m,
1930 ios_base::iostate& __err,1926 ios_base::iostate& __err,
1931 const ctype<char_type>& __ct) const1927 const ctype<char_type>& __ct) const
1932{1928{
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;
1934 if (!(__err & ios_base::failbit) && 0 <= __t && __t <= 11)1930 if (!(__err & ios_base::failbit) && 0 <= __t && __t <= 11)
1935 __m = __t;1931 __m = __t;
1936 else1932 else
...@@ -1944,7 +1940,7 @@ time_get<_CharT, _InputIterator>::__get_year(int& __y,...@@ -1944,7 +1940,7 @@ time_get<_CharT, _InputIterator>::__get_year(int& __y,
1944 ios_base::iostate& __err,1940 ios_base::iostate& __err,
1945 const ctype<char_type>& __ct) const1941 const ctype<char_type>& __ct) const
1946{1942{
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);
1948 if (!(__err & ios_base::failbit))1944 if (!(__err & ios_base::failbit))
1949 {1945 {
1950 if (__t < 69)1946 if (__t < 69)
...@@ -1962,7 +1958,7 @@ time_get<_CharT, _InputIterator>::__get_year4(int& __y,...@@ -1962,7 +1958,7 @@ time_get<_CharT, _InputIterator>::__get_year4(int& __y,
1962 ios_base::iostate& __err,1958 ios_base::iostate& __err,
1963 const ctype<char_type>& __ct) const1959 const ctype<char_type>& __ct) const
1964{1960{
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);
1966 if (!(__err & ios_base::failbit))1962 if (!(__err & ios_base::failbit))
1967 __y = __t - 1900;1963 __y = __t - 1900;
1968}1964}
...@@ -1974,7 +1970,7 @@ time_get<_CharT, _InputIterator>::__get_hour(int& __h,...@@ -1974,7 +1970,7 @@ time_get<_CharT, _InputIterator>::__get_hour(int& __h,
1974 ios_base::iostate& __err,1970 ios_base::iostate& __err,
1975 const ctype<char_type>& __ct) const1971 const ctype<char_type>& __ct) const
1976{1972{
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);
1978 if (!(__err & ios_base::failbit) && __t <= 23)1974 if (!(__err & ios_base::failbit) && __t <= 23)
1979 __h = __t;1975 __h = __t;
1980 else1976 else
...@@ -1988,7 +1984,7 @@ time_get<_CharT, _InputIterator>::__get_12_hour(int& __h,...@@ -1988,7 +1984,7 @@ time_get<_CharT, _InputIterator>::__get_12_hour(int& __h,
1988 ios_base::iostate& __err,1984 ios_base::iostate& __err,
1989 const ctype<char_type>& __ct) const1985 const ctype<char_type>& __ct) const
1990{1986{
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);
1992 if (!(__err & ios_base::failbit) && 1 <= __t && __t <= 12)1988 if (!(__err & ios_base::failbit) && 1 <= __t && __t <= 12)
1993 __h = __t;1989 __h = __t;
1994 else1990 else
...@@ -2002,7 +1998,7 @@ time_get<_CharT, _InputIterator>::__get_minute(int& __m,...@@ -2002,7 +1998,7 @@ time_get<_CharT, _InputIterator>::__get_minute(int& __m,
2002 ios_base::iostate& __err,1998 ios_base::iostate& __err,
2003 const ctype<char_type>& __ct) const1999 const ctype<char_type>& __ct) const
2004{2000{
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);
2006 if (!(__err & ios_base::failbit) && __t <= 59)2002 if (!(__err & ios_base::failbit) && __t <= 59)
2007 __m = __t;2003 __m = __t;
2008 else2004 else
...@@ -2016,7 +2012,7 @@ time_get<_CharT, _InputIterator>::__get_second(int& __s,...@@ -2016,7 +2012,7 @@ time_get<_CharT, _InputIterator>::__get_second(int& __s,
2016 ios_base::iostate& __err,2012 ios_base::iostate& __err,
2017 const ctype<char_type>& __ct) const2013 const ctype<char_type>& __ct) const
2018{2014{
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);
2020 if (!(__err & ios_base::failbit) && __t <= 60)2016 if (!(__err & ios_base::failbit) && __t <= 60)
2021 __s = __t;2017 __s = __t;
2022 else2018 else
...@@ -2030,7 +2026,7 @@ time_get<_CharT, _InputIterator>::__get_weekday(int& __w,...@@ -2030,7 +2026,7 @@ time_get<_CharT, _InputIterator>::__get_weekday(int& __w,
2030 ios_base::iostate& __err,2026 ios_base::iostate& __err,
2031 const ctype<char_type>& __ct) const2027 const ctype<char_type>& __ct) const
2032{2028{
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);
2034 if (!(__err & ios_base::failbit) && __t <= 6)2030 if (!(__err & ios_base::failbit) && __t <= 6)
2035 __w = __t;2031 __w = __t;
2036 else2032 else
...@@ -2044,7 +2040,7 @@ time_get<_CharT, _InputIterator>::__get_day_year_num(int& __d,...@@ -2044,7 +2040,7 @@ time_get<_CharT, _InputIterator>::__get_day_year_num(int& __d,
2044 ios_base::iostate& __err,2040 ios_base::iostate& __err,
2045 const ctype<char_type>& __ct) const2041 const ctype<char_type>& __ct) const
2046{2042{
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);
2048 if (!(__err & ios_base::failbit) && __t <= 365)2044 if (!(__err & ios_base::failbit) && __t <= 365)
2049 __d = __t;2045 __d = __t;
2050 else2046 else
...@@ -2109,7 +2105,7 @@ time_get<_CharT, _InputIterator>::get(iter_type __b, iter_type __e,...@@ -2109,7 +2105,7 @@ time_get<_CharT, _InputIterator>::get(iter_type __b, iter_type __e,
2109 ios_base::iostate& __err, tm* __tm,2105 ios_base::iostate& __err, tm* __tm,
2110 const char_type* __fmtb, const char_type* __fmte) const2106 const char_type* __fmtb, const char_type* __fmte) const
2111{2107{
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());
2113 __err = ios_base::goodbit;2109 __err = ios_base::goodbit;
2114 while (__fmtb != __fmte && __err == ios_base::goodbit)2110 while (__fmtb != __fmte && __err == ios_base::goodbit)
2115 {2111 {
...@@ -2196,7 +2192,7 @@ time_get<_CharT, _InputIterator>::do_get_weekday(iter_type __b, iter_type __e,...@@ -2196,7 +2192,7 @@ time_get<_CharT, _InputIterator>::do_get_weekday(iter_type __b, iter_type __e,
2196 ios_base::iostate& __err,2192 ios_base::iostate& __err,
2197 tm* __tm) const2193 tm* __tm) const
2198{2194{
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());
2200 __get_weekdayname(__tm->tm_wday, __b, __e, __err, __ct);2196 __get_weekdayname(__tm->tm_wday, __b, __e, __err, __ct);
2201 return __b;2197 return __b;
2202}2198}
...@@ -2208,7 +2204,7 @@ time_get<_CharT, _InputIterator>::do_get_monthname(iter_type __b, iter_type __e,...@@ -2208,7 +2204,7 @@ time_get<_CharT, _InputIterator>::do_get_monthname(iter_type __b, iter_type __e,
2208 ios_base::iostate& __err,2204 ios_base::iostate& __err,
2209 tm* __tm) const2205 tm* __tm) const
2210{2206{
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());
2212 __get_monthname(__tm->tm_mon, __b, __e, __err, __ct);2208 __get_monthname(__tm->tm_mon, __b, __e, __err, __ct);
2213 return __b;2209 return __b;
2214}2210}
...@@ -2220,7 +2216,7 @@ time_get<_CharT, _InputIterator>::do_get_year(iter_type __b, iter_type __e,...@@ -2220,7 +2216,7 @@ time_get<_CharT, _InputIterator>::do_get_year(iter_type __b, iter_type __e,
2220 ios_base::iostate& __err,2216 ios_base::iostate& __err,
2221 tm* __tm) const2217 tm* __tm) const
2222{2218{
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());
2224 __get_year(__tm->tm_year, __b, __e, __err, __ct);2220 __get_year(__tm->tm_year, __b, __e, __err, __ct);
2225 return __b;2221 return __b;
2226}2222}
...@@ -2233,7 +2229,7 @@ time_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,...@@ -2233,7 +2229,7 @@ time_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
2233 char __fmt, char) const2229 char __fmt, char) const
2234{2230{
2235 __err = ios_base::goodbit;2231 __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());
2237 switch (__fmt)2233 switch (__fmt)
2238 {2234 {
2239 case 'a':2235 case 'a':
...@@ -2392,7 +2388,9 @@ extern template _LIBCPP_FUNC_VIS __time_get_storage<_CharT>::string_type __time_...@@ -2392,7 +2388,9 @@ extern template _LIBCPP_FUNC_VIS __time_get_storage<_CharT>::string_type __time_
2392/**/2388/**/
23932389
2394_LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(char)2390_LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(char)
2391#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2395_LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(wchar_t)2392_LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(wchar_t)
2393#endif
2396#undef _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION2394#undef _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION
23972395
2398template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >2396template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
...@@ -2416,26 +2414,17 @@ public:...@@ -2416,26 +2414,17 @@ public:
2416 __time_get_storage<_CharT>(__nm) {}2414 __time_get_storage<_CharT>(__nm) {}
24172415
2418protected:2416protected:
2419 _LIBCPP_INLINE_VISIBILITY2417 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_get_byname() override {}
2420 ~time_get_byname() {}
24212418
2422 _LIBCPP_INLINE_VISIBILITY2419 _LIBCPP_HIDE_FROM_ABI_VIRTUAL dateorder do_date_order() const override {return this->__do_date_order();}
2423 virtual dateorder do_date_order() const {return this->__do_date_order();}
2424private:2420private:
2425 _LIBCPP_INLINE_VISIBILITY2421 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type* __weeks() const override {return this->__weeks_;}
2426 virtual const string_type* __weeks() const {return this->__weeks_;}2422 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type* __months() const override {return this->__months_;}
2427 _LIBCPP_INLINE_VISIBILITY2423 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type* __am_pm() const override {return this->__am_pm_;}
2428 virtual const string_type* __months() const {return this->__months_;}2424 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __c() const override {return this->__c_;}
2429 _LIBCPP_INLINE_VISIBILITY2425 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __r() const override {return this->__r_;}
2430 virtual const string_type* __am_pm() const {return this->__am_pm_;}2426 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __x() const override {return this->__x_;}
2431 _LIBCPP_INLINE_VISIBILITY2427 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __X() const override {return this->__X_;}
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_;}
2439};2428};
24402429
2441extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>;2430extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>;
...@@ -2453,8 +2442,10 @@ protected:...@@ -2453,8 +2442,10 @@ protected:
2453 ~__time_put();2442 ~__time_put();
2454 void __do_put(char* __nb, char*& __ne, const tm* __tm,2443 void __do_put(char* __nb, char*& __ne, const tm* __tm,
2455 char __fmt, char __mod) const;2444 char __fmt, char __mod) const;
2445#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2456 void __do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm,2446 void __do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm,
2457 char __fmt, char __mod) const;2447 char __fmt, char __mod) const;
2448#endif
2458};2449};
24592450
2460template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >2451template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
...@@ -2483,8 +2474,7 @@ public:...@@ -2483,8 +2474,7 @@ public:
2483 static locale::id id;2474 static locale::id id;
24842475
2485protected:2476protected:
2486 _LIBCPP_INLINE_VISIBILITY2477 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_put() override {}
2487 ~time_put() {}
2488 virtual iter_type do_put(iter_type __s, ios_base&, char_type, const tm* __tm,2478 virtual iter_type do_put(iter_type __s, ios_base&, char_type, const tm* __tm,
2489 char __fmt, char __mod) const;2479 char __fmt, char __mod) const;
24902480
...@@ -2509,7 +2499,7 @@ time_put<_CharT, _OutputIterator>::put(iter_type __s, ios_base& __iob,...@@ -2509,7 +2499,7 @@ time_put<_CharT, _OutputIterator>::put(iter_type __s, ios_base& __iob,
2509 const char_type* __pb,2499 const char_type* __pb,
2510 const char_type* __pe) const2500 const char_type* __pe) const
2511{2501{
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());
2513 for (; __pb != __pe; ++__pb)2503 for (; __pb != __pe; ++__pb)
2514 {2504 {
2515 if (__ct.narrow(*__pb, 0) == '%')2505 if (__ct.narrow(*__pb, 0) == '%')
...@@ -2572,8 +2562,7 @@ public:...@@ -2572,8 +2562,7 @@ public:
2572 : time_put<_CharT, _OutputIterator>(__nm, __refs) {}2562 : time_put<_CharT, _OutputIterator>(__nm, __refs) {}
25732563
2574protected:2564protected:
2575 _LIBCPP_INLINE_VISIBILITY2565 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_put_byname() override {}
2576 ~time_put_byname() {}
2577};2566};
25782567
2579extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>;2568extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>;
...@@ -2621,8 +2610,7 @@ public:...@@ -2621,8 +2610,7 @@ public:
2621 static const bool intl = _International;2610 static const bool intl = _International;
26222611
2623protected:2612protected:
2624 _LIBCPP_INLINE_VISIBILITY2613 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~moneypunct() override {}
2625 ~moneypunct() {}
26262614
2627 virtual char_type do_decimal_point() const {return numeric_limits<char_type>::max();}2615 virtual char_type do_decimal_point() const {return numeric_limits<char_type>::max();}
2628 virtual char_type do_thousands_sep() const {return numeric_limits<char_type>::max();}2616 virtual char_type do_thousands_sep() const {return numeric_limits<char_type>::max();}
...@@ -2672,18 +2660,17 @@ public:...@@ -2672,18 +2660,17 @@ public:
2672 : moneypunct<_CharT, _International>(__refs) {init(__nm.c_str());}2660 : moneypunct<_CharT, _International>(__refs) {init(__nm.c_str());}
26732661
2674protected:2662protected:
2675 _LIBCPP_INLINE_VISIBILITY2663 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~moneypunct_byname() override {}
2676 ~moneypunct_byname() {}2664
26772665 char_type do_decimal_point() const override {return __decimal_point_;}
2678 virtual char_type do_decimal_point() const {return __decimal_point_;}2666 char_type do_thousands_sep() const override {return __thousands_sep_;}
2679 virtual char_type do_thousands_sep() const {return __thousands_sep_;}2667 string do_grouping() const override {return __grouping_;}
2680 virtual string do_grouping() const {return __grouping_;}2668 string_type do_curr_symbol() const override {return __curr_symbol_;}
2681 virtual string_type do_curr_symbol() const {return __curr_symbol_;}2669 string_type do_positive_sign() const override {return __positive_sign_;}
2682 virtual string_type do_positive_sign() const {return __positive_sign_;}2670 string_type do_negative_sign() const override {return __negative_sign_;}
2683 virtual string_type do_negative_sign() const {return __negative_sign_;}2671 int do_frac_digits() const override {return __frac_digits_;}
2684 virtual int do_frac_digits() const {return __frac_digits_;}2672 pattern do_pos_format() const override {return __pos_format_;}
2685 virtual pattern do_pos_format() const {return __pos_format_;}2673 pattern do_neg_format() const override {return __neg_format_;}
2686 virtual pattern do_neg_format() const {return __neg_format_;}
26872674
2688private:2675private:
2689 char_type __decimal_point_;2676 char_type __decimal_point_;
...@@ -2740,7 +2727,7 @@ __money_get<_CharT>::__gather_info(bool __intl, const locale& __loc,...@@ -2740,7 +2727,7 @@ __money_get<_CharT>::__gather_info(bool __intl, const locale& __loc,
2740 if (__intl)2727 if (__intl)
2741 {2728 {
2742 const moneypunct<char_type, true>& __mp =2729 const moneypunct<char_type, true>& __mp =
2743 use_facet<moneypunct<char_type, true> >(__loc);2730 std::use_facet<moneypunct<char_type, true> >(__loc);
2744 __pat = __mp.neg_format();2731 __pat = __mp.neg_format();
2745 __nsn = __mp.negative_sign();2732 __nsn = __mp.negative_sign();
2746 __psn = __mp.positive_sign();2733 __psn = __mp.positive_sign();
...@@ -2753,7 +2740,7 @@ __money_get<_CharT>::__gather_info(bool __intl, const locale& __loc,...@@ -2753,7 +2740,7 @@ __money_get<_CharT>::__gather_info(bool __intl, const locale& __loc,
2753 else2740 else
2754 {2741 {
2755 const moneypunct<char_type, false>& __mp =2742 const moneypunct<char_type, false>& __mp =
2756 use_facet<moneypunct<char_type, false> >(__loc);2743 std::use_facet<moneypunct<char_type, false> >(__loc);
2757 __pat = __mp.neg_format();2744 __pat = __mp.neg_format();
2758 __nsn = __mp.negative_sign();2745 __nsn = __mp.negative_sign();
2759 __psn = __mp.positive_sign();2746 __psn = __mp.positive_sign();
...@@ -2801,9 +2788,7 @@ public:...@@ -2801,9 +2788,7 @@ public:
2801 static locale::id id;2788 static locale::id id;
28022789
2803protected:2790protected:
28042791 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~money_get() override {}
2805 _LIBCPP_INLINE_VISIBILITY
2806 ~money_get() {}
28072792
2808 virtual iter_type do_get(iter_type __b, iter_type __e, bool __intl,2793 virtual iter_type do_get(iter_type __b, iter_type __e, bool __intl,
2809 ios_base& __iob, ios_base::iostate& __err,2794 ios_base& __iob, ios_base::iostate& __err,
...@@ -2828,7 +2813,7 @@ money_get<_CharT, _InputIterator>::id;...@@ -2828,7 +2813,7 @@ money_get<_CharT, _InputIterator>::id;
2828_LIBCPP_FUNC_VIS void __do_nothing(void*);2813_LIBCPP_FUNC_VIS void __do_nothing(void*);
28292814
2830template <class _Tp>2815template <class _Tp>
2831_LIBCPP_HIDDEN2816_LIBCPP_HIDE_FROM_ABI
2832void2817void
2833__double_or_nothing(unique_ptr<_Tp, void(*)(void*)>& __b, _Tp*& __n, _Tp*& __e)2818__double_or_nothing(unique_ptr<_Tp, void(*)(void*)>& __b, _Tp*& __n, _Tp*& __e)
2834{2819{
...@@ -2839,7 +2824,7 @@ __double_or_nothing(unique_ptr<_Tp, void(*)(void*)>& __b, _Tp*& __n, _Tp*& __e)...@@ -2839,7 +2824,7 @@ __double_or_nothing(unique_ptr<_Tp, void(*)(void*)>& __b, _Tp*& __n, _Tp*& __e)
2839 if (__new_cap == 0)2824 if (__new_cap == 0)
2840 __new_cap = sizeof(_Tp);2825 __new_cap = sizeof(_Tp);
2841 size_t __n_off = static_cast<size_t>(__n - __b.get());2826 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);
2843 if (__t == 0)2828 if (__t == 0)
2844 __throw_bad_alloc();2829 __throw_bad_alloc();
2845 if (__owns)2830 if (__owns)
...@@ -2954,7 +2939,7 @@ money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e,...@@ -2954,7 +2939,7 @@ money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e,
2954 ++__sym_space_end;2939 ++__sym_space_end;
2955 const size_t __num_spaces = __sym_space_end - __sym.begin();2940 const size_t __num_spaces = __sym_space_end - __sym.begin();
2956 if (__num_spaces > __spaces.size() ||2941 if (__num_spaces > __spaces.size() ||
2957 !equal(__spaces.end() - __num_spaces, __spaces.end(),2942 !std::equal(__spaces.end() - __num_spaces, __spaces.end(),
2958 __sym.begin())) {2943 __sym.begin())) {
2959 // No match. Put __sym_space_end back at the2944 // No match. Put __sym_space_end back at the
2960 // beginning of __sym, which will prevent a2945 // beginning of __sym, which will prevent a
...@@ -2985,14 +2970,14 @@ money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e,...@@ -2985,14 +2970,14 @@ money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e,
2985 if (__ct.is(ctype_base::digit, __c))2970 if (__ct.is(ctype_base::digit, __c))
2986 {2971 {
2987 if (__wn == __we)2972 if (__wn == __we)
2988 __double_or_nothing(__wb, __wn, __we);2973 std::__double_or_nothing(__wb, __wn, __we);
2989 *__wn++ = __c;2974 *__wn++ = __c;
2990 ++__ng;2975 ++__ng;
2991 }2976 }
2992 else if (__grp.size() > 0 && __ng > 0 && __c == __ts)2977 else if (__grp.size() > 0 && __ng > 0 && __c == __ts)
2993 {2978 {
2994 if (__gn == __ge)2979 if (__gn == __ge)
2995 __double_or_nothing(__gb, __gn, __ge);2980 std::__double_or_nothing(__gb, __gn, __ge);
2996 *__gn++ = __ng;2981 *__gn++ = __ng;
2997 __ng = 0;2982 __ng = 0;
2998 }2983 }
...@@ -3002,7 +2987,7 @@ money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e,...@@ -3002,7 +2987,7 @@ money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e,
3002 if (__gb.get() != __gn && __ng > 0)2987 if (__gb.get() != __gn && __ng > 0)
3003 {2988 {
3004 if (__gn == __ge)2989 if (__gn == __ge)
3005 __double_or_nothing(__gb, __gn, __ge);2990 std::__double_or_nothing(__gb, __gn, __ge);
3006 *__gn++ = __ng;2991 *__gn++ = __ng;
3007 }2992 }
3008 if (__fd > 0)2993 if (__fd > 0)
...@@ -3020,7 +3005,7 @@ money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e,...@@ -3020,7 +3005,7 @@ money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e,
3020 return false;3005 return false;
3021 }3006 }
3022 if (__wn == __we)3007 if (__wn == __we)
3023 __double_or_nothing(__wb, __wn, __we);3008 std::__double_or_nothing(__wb, __wn, __we);
3024 *__wn++ = *__b;3009 *__wn++ = *__b;
3025 }3010 }
3026 }3011 }
...@@ -3070,7 +3055,7 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,...@@ -3070,7 +3055,7 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
3070 char_type* __wn;3055 char_type* __wn;
3071 char_type* __we = __wbuf + __bz;3056 char_type* __we = __wbuf + __bz;
3072 locale __loc = __iob.getloc();3057 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);
3074 bool __neg = false;3059 bool __neg = false;
3075 if (__do_get(__b, __e, __intl, __loc, __iob.flags(), __err, __neg, __ct,3060 if (__do_get(__b, __e, __intl, __loc, __iob.flags(), __err, __neg, __ct,
3076 __wb, __wn, __we))3061 __wb, __wn, __we))
...@@ -3091,7 +3076,7 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,...@@ -3091,7 +3076,7 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
3091 if (__neg)3076 if (__neg)
3092 *__nc++ = '-';3077 *__nc++ = '-';
3093 for (const char_type* __w = __wb.get(); __w < __wn; ++__w, ++__nc)3078 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];
3095 *__nc = char();3080 *__nc = char();
3096 if (sscanf(__nbuf, "%Lf", &__v) != 1)3081 if (sscanf(__nbuf, "%Lf", &__v) != 1)
3097 __throw_runtime_error("money_get error");3082 __throw_runtime_error("money_get error");
...@@ -3114,7 +3099,7 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,...@@ -3114,7 +3099,7 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
3114 char_type* __wn;3099 char_type* __wn;
3115 char_type* __we = __wbuf + __bz;3100 char_type* __we = __wbuf + __bz;
3116 locale __loc = __iob.getloc();3101 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);
3118 bool __neg = false;3103 bool __neg = false;
3119 if (__do_get(__b, __e, __intl, __loc, __iob.flags(), __err, __neg, __ct,3104 if (__do_get(__b, __e, __intl, __loc, __iob.flags(), __err, __neg, __ct,
3120 __wb, __wn, __we))3105 __wb, __wn, __we))
...@@ -3176,7 +3161,7 @@ __money_put<_CharT>::__gather_info(bool __intl, bool __neg, const locale& __loc,...@@ -3176,7 +3161,7 @@ __money_put<_CharT>::__gather_info(bool __intl, bool __neg, const locale& __loc,
3176 if (__intl)3161 if (__intl)
3177 {3162 {
3178 const moneypunct<char_type, true>& __mp =3163 const moneypunct<char_type, true>& __mp =
3179 use_facet<moneypunct<char_type, true> >(__loc);3164 std::use_facet<moneypunct<char_type, true> >(__loc);
3180 if (__neg)3165 if (__neg)
3181 {3166 {
3182 __pat = __mp.neg_format();3167 __pat = __mp.neg_format();
...@@ -3196,7 +3181,7 @@ __money_put<_CharT>::__gather_info(bool __intl, bool __neg, const locale& __loc,...@@ -3196,7 +3181,7 @@ __money_put<_CharT>::__gather_info(bool __intl, bool __neg, const locale& __loc,
3196 else3181 else
3197 {3182 {
3198 const moneypunct<char_type, false>& __mp =3183 const moneypunct<char_type, false>& __mp =
3199 use_facet<moneypunct<char_type, false> >(__loc);3184 std::use_facet<moneypunct<char_type, false> >(__loc);
3200 if (__neg)3185 if (__neg)
3201 {3186 {
3202 __pat = __mp.neg_format();3187 __pat = __mp.neg_format();
...@@ -3296,7 +3281,7 @@ __money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __m...@@ -3296,7 +3281,7 @@ __money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __m
3296 }3281 }
3297 }3282 }
3298 // reverse it3283 // reverse it
3299 reverse(__t, __me);3284 std::reverse(__t, __me);
3300 }3285 }
3301 break;3286 break;
3302 }3287 }
...@@ -3347,8 +3332,7 @@ public:...@@ -3347,8 +3332,7 @@ public:
3347 static locale::id id;3332 static locale::id id;
33483333
3349protected:3334protected:
3350 _LIBCPP_INLINE_VISIBILITY3335 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~money_put() override {}
3351 ~money_put() {}
33523336
3353 virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __iob,3337 virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __iob,
3354 char_type __fl, long double __units) const;3338 char_type __fl, long double __units) const;
...@@ -3389,7 +3373,7 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,...@@ -3389,7 +3373,7 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
3389 }3373 }
3390 // gather info3374 // gather info
3391 locale __loc = __iob.getloc();3375 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);
3393 __ct.widen(__bb, __bb + __n, __db);3377 __ct.widen(__bb, __bb + __n, __db);
3394 bool __neg = __n > 0 && __bb[0] == '-';3378 bool __neg = __n > 0 && __bb[0] == '-';
3395 money_base::pattern __pat;3379 money_base::pattern __pat;
...@@ -3421,7 +3405,7 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,...@@ -3421,7 +3405,7 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
3421 this->__format(__mb, __mi, __me, __iob.flags(),3405 this->__format(__mb, __mi, __me, __iob.flags(),
3422 __db, __db + __n, __ct,3406 __db, __db + __n, __ct,
3423 __neg, __pat, __dp, __ts, __grp, __sym, __sn, __fd);3407 __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);
3425}3409}
34263410
3427template <class _CharT, class _OutputIterator>3411template <class _CharT, class _OutputIterator>
...@@ -3432,7 +3416,7 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,...@@ -3432,7 +3416,7 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
3432{3416{
3433 // gather info3417 // gather info
3434 locale __loc = __iob.getloc();3418 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);
3436 bool __neg = __digits.size() > 0 && __digits[0] == __ct.widen('-');3420 bool __neg = __digits.size() > 0 && __digits[0] == __ct.widen('-');
3437 money_base::pattern __pat;3421 money_base::pattern __pat;
3438 char_type __dp;3422 char_type __dp;
...@@ -3463,7 +3447,7 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,...@@ -3463,7 +3447,7 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
3463 this->__format(__mb, __mi, __me, __iob.flags(),3447 this->__format(__mb, __mi, __me, __iob.flags(),
3464 __digits.data(), __digits.data() + __digits.size(), __ct,3448 __digits.data(), __digits.data() + __digits.size(), __ct,
3465 __neg, __pat, __dp, __ts, __grp, __sym, __sn, __fd);3449 __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);
3467}3451}
34683452
3469extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>;3453extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>;
...@@ -3516,8 +3500,7 @@ public:...@@ -3516,8 +3500,7 @@ public:
3516 static locale::id id;3500 static locale::id id;
35173501
3518protected:3502protected:
3519 _LIBCPP_INLINE_VISIBILITY3503 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~messages() override {}
3520 ~messages() {}
35213504
3522 virtual catalog do_open(const basic_string<char>&, const locale&) const;3505 virtual catalog do_open(const basic_string<char>&, const locale&) const;
3523 virtual string_type do_get(catalog, int __set, int __msgid,3506 virtual string_type do_get(catalog, int __set, int __msgid,
...@@ -3551,7 +3534,7 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid,...@@ -3551,7 +3534,7 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid,
3551{3534{
3552#ifdef _LIBCPP_HAS_CATOPEN3535#ifdef _LIBCPP_HAS_CATOPEN
3553 string __ndflt;3536 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),
3555 __dflt.c_str(),3538 __dflt.c_str(),
3556 __dflt.c_str() + __dflt.size());3539 __dflt.c_str() + __dflt.size());
3557 if (__c != -1)3540 if (__c != -1)
...@@ -3559,7 +3542,7 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid,...@@ -3559,7 +3542,7 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid,
3559 nl_catd __cat = (nl_catd)__c;3542 nl_catd __cat = (nl_catd)__c;
3560 char* __n = catgets(__cat, __set, __msgid, __ndflt.c_str());3543 char* __n = catgets(__cat, __set, __msgid, __ndflt.c_str());
3561 string_type __w;3544 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),
3563 __n, __n + _VSTD::strlen(__n));3546 __n, __n + _VSTD::strlen(__n));
3564 return __w;3547 return __w;
3565#else // !_LIBCPP_HAS_CATOPEN3548#else // !_LIBCPP_HAS_CATOPEN
...@@ -3606,8 +3589,7 @@ public:...@@ -3606,8 +3589,7 @@ public:
3606 : messages<_CharT>(__refs) {}3589 : messages<_CharT>(__refs) {}
36073590
3608protected:3591protected:
3609 _LIBCPP_INLINE_VISIBILITY3592 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~messages_byname() override {}
3610 ~messages_byname() {}
3611};3593};
36123594
3613extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>;3595extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>;
...@@ -4007,7 +3989,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP...@@ -4007,7 +3989,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
4007 char_type __1buf;3989 char_type __1buf;
4008 if (this->gptr() == 0)3990 if (this->gptr() == 0)
4009 this->setg(&__1buf, &__1buf+1, &__1buf+1);3991 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);
4011 int_type __c = traits_type::eof();3993 int_type __c = traits_type::eof();
4012 if (this->gptr() == this->egptr())3994 if (this->gptr() == this->egptr())
4013 {3995 {
...@@ -4026,9 +4008,11 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP...@@ -4026,9 +4008,11 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
4026 }4008 }
4027 else4009 else
4028 {4010 {
4029 _LIBCPP_ASSERT(!(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" );4011 if (__extbufend_ != __extbufnext_) {
4030 if (__extbufend_ != __extbufnext_)4012 _LIBCPP_ASSERT(__extbufnext_ != nullptr, "underflow moving from nullptr");
4013 _LIBCPP_ASSERT(__extbuf_ != nullptr, "underflow moving into nullptr");
4031 _VSTD::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);4014 _VSTD::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
4015 }
4032 __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);4016 __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
4033 __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);4017 __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);
4034 streamsize __nmemb = _VSTD::min(static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz),4018 streamsize __nmemb = _VSTD::min(static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz),
...@@ -4276,7 +4260,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP...@@ -4276,7 +4260,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
4276 {4260 {
4277 if (this->gptr() != this->egptr())4261 if (this->gptr() != this->egptr())
4278 {4262 {
4279 reverse(this->gptr(), this->egptr());4263 std::reverse(this->gptr(), this->egptr());
4280 codecvt_base::result __r;4264 codecvt_base::result __r;
4281 const char_type* __e = this->gptr();4265 const char_type* __e = this->gptr();
4282 char* __extbe;4266 char* __extbe;
...@@ -4369,4 +4353,16 @@ _LIBCPP_END_NAMESPACE_STD...@@ -4369,4 +4353,16 @@ _LIBCPP_END_NAMESPACE_STD
43694353
4370_LIBCPP_POP_MACROS4354_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
4372#endif // _LIBCPP_LOCALE4368#endif // _LIBCPP_LOCALE
lib/libcxx/include/locale.h+3-1
...@@ -43,6 +43,8 @@ Functions:...@@ -43,6 +43,8 @@ Functions:
43# pragma GCC system_header43# pragma GCC system_header
44#endif44#endif
4545
46#include_next <locale.h>46#if __has_include_next(<locale.h>)
47# include_next <locale.h>
48#endif
4749
48#endif // _LIBCPP_LOCALE_H50#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...@@ -538,20 +538,18 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
538#include <__iterator/erase_if_container.h>538#include <__iterator/erase_if_container.h>
539#include <__iterator/iterator_traits.h>539#include <__iterator/iterator_traits.h>
540#include <__iterator/reverse_iterator.h>540#include <__iterator/reverse_iterator.h>
541#include <__memory/allocator.h>
542#include <__memory_resource/polymorphic_allocator.h>
541#include <__node_handle>543#include <__node_handle>
542#include <__tree>544#include <__tree>
545#include <__type_traits/is_allocator.h>
543#include <__utility/forward.h>546#include <__utility/forward.h>
547#include <__utility/piecewise_construct.h>
544#include <__utility/swap.h>548#include <__utility/swap.h>
545#include <memory>549#include <tuple>
546#include <type_traits>550#include <type_traits>
547#include <version>551#include <version>
548552
549#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
550# include <functional>
551# include <iterator>
552# include <utility>
553#endif
554
555// standard-mandated includes553// standard-mandated includes
556554
557// [iterator.range]555// [iterator.range]
...@@ -619,46 +617,46 @@ public:...@@ -619,46 +617,46 @@ public:
619template <class _Key, class _CP, class _Compare>617template <class _Key, class _CP, class _Compare>
620class __map_value_compare<_Key, _CP, _Compare, false>618class __map_value_compare<_Key, _CP, _Compare, false>
621{619{
622 _Compare comp;620 _Compare __comp_;
623621
624public:622public:
625 _LIBCPP_INLINE_VISIBILITY623 _LIBCPP_INLINE_VISIBILITY
626 __map_value_compare()624 __map_value_compare()
627 _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)625 _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)
628 : comp() {}626 : __comp_() {}
629 _LIBCPP_INLINE_VISIBILITY627 _LIBCPP_INLINE_VISIBILITY
630 __map_value_compare(_Compare __c)628 __map_value_compare(_Compare __c)
631 _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)629 _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)
632 : comp(__c) {}630 : __comp_(__c) {}
633 _LIBCPP_INLINE_VISIBILITY631 _LIBCPP_INLINE_VISIBILITY
634 const _Compare& key_comp() const _NOEXCEPT {return comp;}632 const _Compare& key_comp() const _NOEXCEPT {return __comp_;}
635633
636 _LIBCPP_INLINE_VISIBILITY634 _LIBCPP_INLINE_VISIBILITY
637 bool operator()(const _CP& __x, const _CP& __y) const635 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);}
639 _LIBCPP_INLINE_VISIBILITY637 _LIBCPP_INLINE_VISIBILITY
640 bool operator()(const _CP& __x, const _Key& __y) const638 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);}
642 _LIBCPP_INLINE_VISIBILITY640 _LIBCPP_INLINE_VISIBILITY
643 bool operator()(const _Key& __x, const _CP& __y) const641 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);}
645 void swap(__map_value_compare& __y)643 void swap(__map_value_compare& __y)
646 _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value)644 _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value)
647 {645 {
648 using _VSTD::swap;646 using _VSTD::swap;
649 swap(comp, __y.comp);647 swap(__comp_, __y.__comp_);
650 }648 }
651649
652#if _LIBCPP_STD_VER > 11650#if _LIBCPP_STD_VER > 11
653 template <typename _K2>651 template <typename _K2>
654 _LIBCPP_INLINE_VISIBILITY652 _LIBCPP_INLINE_VISIBILITY
655 bool operator()(const _K2& __x, const _CP& __y) const653 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
658 template <typename _K2>656 template <typename _K2>
659 _LIBCPP_INLINE_VISIBILITY657 _LIBCPP_INLINE_VISIBILITY
660 bool operator()(const _CP& __x, const _K2& __y) const658 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);}
662#endif660#endif
663};661};
664662
...@@ -738,16 +736,16 @@ struct _LIBCPP_STANDALONE_DEBUG __value_type...@@ -738,16 +736,16 @@ struct _LIBCPP_STANDALONE_DEBUG __value_type
738 typedef pair<key_type&&, mapped_type&&> __nc_rref_pair_type;736 typedef pair<key_type&&, mapped_type&&> __nc_rref_pair_type;
739737
740private:738private:
741 value_type __cc;739 value_type __cc_;
742740
743public:741public:
744 _LIBCPP_INLINE_VISIBILITY742 _LIBCPP_INLINE_VISIBILITY
745 value_type& __get_value()743 value_type& __get_value()
746 {744 {
747#if _LIBCPP_STD_VER > 14745#if _LIBCPP_STD_VER > 14
748 return *_VSTD::launder(_VSTD::addressof(__cc));746 return *_VSTD::launder(_VSTD::addressof(__cc_));
749#else747#else
750 return __cc;748 return __cc_;
751#endif749#endif
752 }750 }
753751
...@@ -755,9 +753,9 @@ public:...@@ -755,9 +753,9 @@ public:
755 const value_type& __get_value() const753 const value_type& __get_value() const
756 {754 {
757#if _LIBCPP_STD_VER > 14755#if _LIBCPP_STD_VER > 14
758 return *_VSTD::launder(_VSTD::addressof(__cc));756 return *_VSTD::launder(_VSTD::addressof(__cc_));
759#else757#else
760 return __cc;758 return __cc_;
761#endif759#endif
762 }760 }
763761
...@@ -818,13 +816,13 @@ struct __value_type...@@ -818,13 +816,13 @@ struct __value_type
818 typedef pair<const key_type, mapped_type> value_type;816 typedef pair<const key_type, mapped_type> value_type;
819817
820private:818private:
821 value_type __cc;819 value_type __cc_;
822820
823public:821public:
824 _LIBCPP_INLINE_VISIBILITY822 _LIBCPP_INLINE_VISIBILITY
825 value_type& __get_value() { return __cc; }823 value_type& __get_value() { return __cc_; }
826 _LIBCPP_INLINE_VISIBILITY824 _LIBCPP_INLINE_VISIBILITY
827 const value_type& __get_value() const { return __cc; }825 const value_type& __get_value() const { return __cc_; }
828826
829private:827private:
830 __value_type();828 __value_type();
...@@ -1001,12 +999,15 @@ private:...@@ -1001,12 +999,15 @@ private:
1001999
1002 typedef _VSTD::__value_type<key_type, mapped_type> __value_type;1000 typedef _VSTD::__value_type<key_type, mapped_type> __value_type;
1003 typedef __map_value_compare<key_type, __value_type, key_compare> __vc;1001 typedef __map_value_compare<key_type, __value_type, key_compare> __vc;
1004 typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,1002 typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type;
1005 __value_type>::type __allocator_type;
1006 typedef __tree<__value_type, __vc, __allocator_type> __base;1003 typedef __tree<__value_type, __vc, __allocator_type> __base;
1007 typedef typename __base::__node_traits __node_traits;1004 typedef typename __base::__node_traits __node_traits;
1008 typedef allocator_traits<allocator_type> __alloc_traits;1005 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
1010 __base __tree_;1011 __base __tree_;
10111012
1012public:1013public:
...@@ -1778,12 +1779,15 @@ private:...@@ -1778,12 +1779,15 @@ private:
17781779
1779 typedef _VSTD::__value_type<key_type, mapped_type> __value_type;1780 typedef _VSTD::__value_type<key_type, mapped_type> __value_type;
1780 typedef __map_value_compare<key_type, __value_type, key_compare> __vc;1781 typedef __map_value_compare<key_type, __value_type, key_compare> __vc;
1781 typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,1782 typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type;
1782 __value_type>::type __allocator_type;
1783 typedef __tree<__value_type, __vc, __allocator_type> __base;1783 typedef __tree<__value_type, __vc, __allocator_type> __base;
1784 typedef typename __base::__node_traits __node_traits;1784 typedef typename __base::__node_traits __node_traits;
1785 typedef allocator_traits<allocator_type> __alloc_traits;1785 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
1787 __base __tree_;1791 __base __tree_;
17881792
1789public:1793public:
...@@ -2335,4 +2339,23 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -2335,4 +2339,23 @@ inline _LIBCPP_INLINE_VISIBILITY
23352339
2336_LIBCPP_END_NAMESPACE_STD2340_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
2338#endif // _LIBCPP_MAP2361#endif // _LIBCPP_MAP
lib/libcxx/include/math.h+747-801
...@@ -297,7 +297,9 @@ long double truncl(long double x);...@@ -297,7 +297,9 @@ long double truncl(long double x);
297# pragma GCC system_header297# pragma GCC system_header
298#endif298#endif
299299
300#include_next <math.h>300# if __has_include_next(<math.h>)
301# include_next <math.h>
302# endif
301303
302#ifdef __cplusplus304#ifdef __cplusplus
303305
...@@ -305,479 +307,237 @@ long double truncl(long double x);...@@ -305,479 +307,237 @@ long double truncl(long double x);
305// back to C++ linkage before including these C++ headers.307// back to C++ linkage before including these C++ headers.
306extern "C++" {308extern "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>
308#include <__type_traits/promote.h>314#include <__type_traits/promote.h>
309#include <limits>315#include <limits>
310#include <stdlib.h>316#include <stdlib.h>
311#include <type_traits>
312317
313// signbit
314318
315#ifdef signbit319# ifdef fpclassify
320# undef fpclassify
321# endif
316322
317template <class _A1>323# ifdef signbit
318_LIBCPP_INLINE_VISIBILITY324# undef signbit
319bool325# endif
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}
328326
329#undef signbit327# ifdef isfinite
328# undef isfinite
329# endif
330330
331template <class _A1>331# ifdef isinf
332inline _LIBCPP_INLINE_VISIBILITY332# undef isinf
333typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type333# endif
334signbit(_A1 __lcpp_x) _NOEXCEPT
335{
336 return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x);
337}
338334
339template <class _A1>335# ifdef isnan
340inline _LIBCPP_INLINE_VISIBILITY336# undef isnan
341typename std::enable_if<337# endif
342 std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
343signbit(_A1 __lcpp_x) _NOEXCEPT
344{ return __lcpp_x < 0; }
345338
346template <class _A1>339# ifdef isnormal
347inline _LIBCPP_INLINE_VISIBILITY340# undef isnormal
348typename std::enable_if<341# endif
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}
362342
363template <class _A1>343# ifdef isgreater
364inline _LIBCPP_INLINE_VISIBILITY344# undef isgreater
365typename std::enable_if<345# endif
366 std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
367signbit(_A1 __lcpp_x) _NOEXCEPT
368{ return __lcpp_x < 0; }
369346
370template <class _A1>347# ifdef isgreaterequal
371inline _LIBCPP_INLINE_VISIBILITY348# undef isgreaterequal
372typename std::enable_if<349# endif
373 std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type350
374signbit(_A1) _NOEXCEPT351# ifdef isless
375{ return false; }352# undef isless
353# endif
376354
377#endif // signbit355# ifdef islessequal
356# undef islessequal
357# endif
378358
379// fpclassify359# ifdef islessgreater
360# undef islessgreater
361# endif
380362
381#ifdef fpclassify363# ifdef isunordered
364# undef isunordered
365# endif
382366
383template <class _A1>367// signbit
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}
395368
396#undef fpclassify369template <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>374template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value && std::is_signed<_A1>::value, int> = 0>
399inline _LIBCPP_INLINE_VISIBILITY375_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
400typename std::enable_if<std::is_floating_point<_A1>::value, int>::type376 return __x < 0;
401fpclassify(_A1 __lcpp_x) _NOEXCEPT
402{
403 return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x);
404}377}
405378
406template <class _A1>379template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value && !std::is_signed<_A1>::value, int> = 0>
407inline _LIBCPP_INLINE_VISIBILITY380_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT {
408typename std::enable_if<std::is_integral<_A1>::value, int>::type381 return false;
409fpclassify(_A1 __lcpp_x) _NOEXCEPT382}
410{ return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; }
411383
412#elif defined(_LIBCPP_MSVCRT)384// fpclassify
413385
414template <typename _A1>386template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
415inline _LIBCPP_INLINE_VISIBILITY387_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {
416typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type388 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
417fpclassify(_A1 __lcpp_x) _NOEXCEPT
418{
419 return ::fpclassify(static_cast<typename std::__promote<_A1>::type>(__lcpp_x));
420}389}
421390
422template <class _A1>391template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
423inline _LIBCPP_INLINE_VISIBILITY392_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {
424typename std::enable_if<std::is_integral<_A1>::value, int>::type393 return __x == 0 ? FP_ZERO : FP_NORMAL;
425fpclassify(_A1 __lcpp_x) _NOEXCEPT394}
426{ return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; }
427395
428#endif // fpclassify396// The MSVC runtime already provides these functions as templates
397#ifndef _LIBCPP_MSVCRT
429398
430// isfinite399// isfinite
431400
432#ifdef isfinite401template <class _A1,
433402 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0>
434template <class _A1>403_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1 __x) _NOEXCEPT {
435_LIBCPP_INLINE_VISIBILITY404 return __builtin_isfinite((typename std::__promote<_A1>::type)__x);
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
444}405}
445406
446#undef isfinite407template <class _A1,
447408 std::__enable_if_t<std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, int> = 0>
448template <class _A1>409_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT {
449inline _LIBCPP_INLINE_VISIBILITY410 return true;
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);
456}411}
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
468// isinf413// isinf
469414
470#ifdef isinf415template <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
472template <class _A1>421template <class _A1>
473_LIBCPP_INLINE_VISIBILITY422_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI
474bool423 typename std::enable_if< std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, bool>::type
475__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT424 isinf(_A1) _NOEXCEPT {
476{425 return false;
477#if __has_builtin(__builtin_isinf)
478 return __builtin_isinf(__lcpp_x);
479#else
480 return isinf(__lcpp_x);
481#endif
482}426}
483427
484#undef isinf428# ifdef _LIBCPP_PREFERRED_OVERLOAD
485429_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT {
486template <class _A1>430 return __builtin_isinf(__x);
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);
494}431}
495432
496template <class _A1>433_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isinf(double __x) _NOEXCEPT {
497inline _LIBCPP_INLINE_VISIBILITY434 return __builtin_isinf(__x);
498typename std::enable_if<435}
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
517436
518#endif // isinf437_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
520// isnan442// isnan
521443
522#ifdef isnan444template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
523445_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT {
524template <class _A1>446 return __builtin_isnan(__x);
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
534}447}
535448
536#undef isnan449template <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>454# ifdef _LIBCPP_PREFERRED_OVERLOAD
539inline _LIBCPP_INLINE_VISIBILITY455_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT {
540typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type456 return __builtin_isnan(__x);
541isnan(_A1 __lcpp_x) _NOEXCEPT
542{
543 return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x);
544}457}
545458
546template <class _A1>459_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isnan(double __x) _NOEXCEPT {
547inline _LIBCPP_INLINE_VISIBILITY460 return __builtin_isnan(__x);
548typename std::enable_if<std::is_integral<_A1>::value, bool>::type461}
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
565462
566#endif // isnan463_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
568// isnormal468// isnormal
569469
570#ifdef isnormal470template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0>
571471_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
572template <class _A1>472 return __builtin_isnormal(__x);
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
582}473}
583474
584#undef isnormal475template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
585476_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
586template <class _A1>477 return __x != 0;
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);
592}478}
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
602// isgreater480// isgreater
603481
604#ifdef isgreater482template <class _A1,
605483 class _A2,
606template <class _A1, class _A2>484 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
607_LIBCPP_INLINE_VISIBILITY485_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT {
608bool486 typedef typename std::__promote<_A1, _A2>::type type;
609__libcpp_isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT487 return __builtin_isgreater((type)__x, (type)__y);
610{
611 return isgreater(__lcpp_x, __lcpp_y);
612}488}
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
632// isgreaterequal490// isgreaterequal
633491
634#ifdef isgreaterequal492template <class _A1,
635493 class _A2,
636template <class _A1, class _A2>494 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
637_LIBCPP_INLINE_VISIBILITY495_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT {
638bool496 typedef typename std::__promote<_A1, _A2>::type type;
639__libcpp_isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT497 return __builtin_isgreaterequal((type)__x, (type)__y);
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);
658}498}
659499
660#endif // isgreaterequal
661
662// isless500// isless
663501
664#ifdef isless502template <class _A1,
665503 class _A2,
666template <class _A1, class _A2>504 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
667_LIBCPP_INLINE_VISIBILITY505_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT {
668bool506 typedef typename std::__promote<_A1, _A2>::type type;
669__libcpp_isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT507 return __builtin_isless((type)__x, (type)__y);
670{
671 return isless(__lcpp_x, __lcpp_y);
672}508}
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
692// islessequal510// islessequal
693511
694#ifdef islessequal512template <class _A1,
695513 class _A2,
696template <class _A1, class _A2>514 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
697_LIBCPP_INLINE_VISIBILITY515_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT {
698bool516 typedef typename std::__promote<_A1, _A2>::type type;
699__libcpp_islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT517 return __builtin_islessequal((type)__x, (type)__y);
700{
701 return islessequal(__lcpp_x, __lcpp_y);
702}518}
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
722// islessgreater520// islessgreater
723521
724#ifdef islessgreater522template <class _A1,
725523 class _A2,
726template <class _A1, class _A2>524 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
727_LIBCPP_INLINE_VISIBILITY525_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT {
728bool526 typedef typename std::__promote<_A1, _A2>::type type;
729__libcpp_islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT527 return __builtin_islessgreater((type)__x, (type)__y);
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);
748}528}
749529
750#endif // islessgreater
751
752// isunordered530// isunordered
753531
754#ifdef isunordered532template <class _A1,
755533 class _A2,
756template <class _A1, class _A2>534 std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
757_LIBCPP_INLINE_VISIBILITY535_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT {
758bool536 typedef typename std::__promote<_A1, _A2>::type type;
759__libcpp_isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT537 return __builtin_isunordered((type)__x, (type)__y);
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);
778}538}
779539
780#endif // isunordered540#endif // _LIBCPP_MSVCRT
781541
782// abs542// abs
783//543//
...@@ -787,497 +547,633 @@ isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT...@@ -787,497 +547,633 @@ isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
787//547//
788// handled in stdlib.h548// 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
790// acos555// acos
791556
792# if !defined(__sun__)557# if !defined(__sun__)
793inline _LIBCPP_INLINE_VISIBILITY float acos(float __lcpp_x) _NOEXCEPT {return ::acosf(__lcpp_x);}558inline _LIBCPP_HIDE_FROM_ABI float acos(float __x) _NOEXCEPT {return __builtin_acosf(__x);}
794inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return ::acosl(__lcpp_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);}
795# endif566# endif
796567
797template <class _A1>568template <class _A1>
798inline _LIBCPP_INLINE_VISIBILITY569inline _LIBCPP_HIDE_FROM_ABI
799typename std::enable_if<std::is_integral<_A1>::value, double>::type570typename 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
802// asin573// asin
803574
804# if !defined(__sun__)575# if !defined(__sun__)
805inline _LIBCPP_INLINE_VISIBILITY float asin(float __lcpp_x) _NOEXCEPT {return ::asinf(__lcpp_x);}576inline _LIBCPP_HIDE_FROM_ABI float asin(float __x) _NOEXCEPT {return __builtin_asinf(__x);}
806inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return ::asinl(__lcpp_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);}
807# endif584# endif
808585
809template <class _A1>586template <class _A1>
810inline _LIBCPP_INLINE_VISIBILITY587inline _LIBCPP_HIDE_FROM_ABI
811typename std::enable_if<std::is_integral<_A1>::value, double>::type588typename 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
814// atan591// atan
815592
816# if !defined(__sun__)593# if !defined(__sun__)
817inline _LIBCPP_INLINE_VISIBILITY float atan(float __lcpp_x) _NOEXCEPT {return ::atanf(__lcpp_x);}594inline _LIBCPP_HIDE_FROM_ABI float atan(float __x) _NOEXCEPT {return __builtin_atanf(__x);}
818inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return ::atanl(__lcpp_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);}
819# endif602# endif
820603
821template <class _A1>604template <class _A1>
822inline _LIBCPP_INLINE_VISIBILITY605inline _LIBCPP_HIDE_FROM_ABI
823typename std::enable_if<std::is_integral<_A1>::value, double>::type606typename 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
826// atan2609// atan2
827610
828# if !defined(__sun__)611# if !defined(__sun__)
829inline _LIBCPP_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return ::atan2f(__lcpp_y, __lcpp_x);}612inline _LIBCPP_HIDE_FROM_ABI float atan2(float __y, float __x) _NOEXCEPT {return __builtin_atan2f(__y, __x);}
830inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return ::atan2l(__lcpp_y, __lcpp_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);}
831# endif620# endif
832621
833template <class _A1, class _A2>622template <class _A1, class _A2>
834inline _LIBCPP_INLINE_VISIBILITY623inline _LIBCPP_HIDE_FROM_ABI
835typename std::__enable_if_t624typename std::__enable_if_t
836<625<
837 std::is_arithmetic<_A1>::value &&626 std::is_arithmetic<_A1>::value &&
838 std::is_arithmetic<_A2>::value,627 std::is_arithmetic<_A2>::value,
839 std::__promote<_A1, _A2>628 std::__promote<_A1, _A2>
840>::type629>::type
841atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT630atan2(_A1 __y, _A2 __x) _NOEXCEPT
842{631{
843 typedef typename std::__promote<_A1, _A2>::type __result_type;632 typedef typename std::__promote<_A1, _A2>::type __result_type;
844 static_assert((!(std::_IsSame<_A1, __result_type>::value &&633 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
845 std::_IsSame<_A2, __result_type>::value)), "");634 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);
847}636}
848637
849// ceil638// ceil
850639
851# if !defined(__sun__)640# if !defined(__sun__)
852inline _LIBCPP_INLINE_VISIBILITY float ceil(float __lcpp_x) _NOEXCEPT {return ::ceilf(__lcpp_x);}641_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT {return __builtin_ceilf(__x);}
853inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ::ceill(__lcpp_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);}
854# endif649# endif
855650
856template <class _A1>651template <class _A1>
857inline _LIBCPP_INLINE_VISIBILITY652_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
858typename std::enable_if<std::is_integral<_A1>::value, double>::type653typename 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
861// cos656// cos
862657
863# if !defined(__sun__)658# if !defined(__sun__)
864inline _LIBCPP_INLINE_VISIBILITY float cos(float __lcpp_x) _NOEXCEPT {return ::cosf(__lcpp_x);}659inline _LIBCPP_HIDE_FROM_ABI float cos(float __x) _NOEXCEPT {return __builtin_cosf(__x);}
865inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return ::cosl(__lcpp_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);}
866# endif667# endif
867668
868template <class _A1>669template <class _A1>
869inline _LIBCPP_INLINE_VISIBILITY670inline _LIBCPP_HIDE_FROM_ABI
870typename std::enable_if<std::is_integral<_A1>::value, double>::type671typename 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
873// cosh674// cosh
874675
875# if !defined(__sun__)676# if !defined(__sun__)
876inline _LIBCPP_INLINE_VISIBILITY float cosh(float __lcpp_x) _NOEXCEPT {return ::coshf(__lcpp_x);}677inline _LIBCPP_HIDE_FROM_ABI float cosh(float __x) _NOEXCEPT {return __builtin_coshf(__x);}
877inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return ::coshl(__lcpp_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);}
878# endif685# endif
879686
880template <class _A1>687template <class _A1>
881inline _LIBCPP_INLINE_VISIBILITY688inline _LIBCPP_HIDE_FROM_ABI
882typename std::enable_if<std::is_integral<_A1>::value, double>::type689typename 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
885// exp692// exp
886693
887# if !defined(__sun__)694# if !defined(__sun__)
888inline _LIBCPP_INLINE_VISIBILITY float exp(float __lcpp_x) _NOEXCEPT {return ::expf(__lcpp_x);}695inline _LIBCPP_HIDE_FROM_ABI float exp(float __x) _NOEXCEPT {return __builtin_expf(__x);}
889inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return ::expl(__lcpp_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);}
890# endif703# endif
891704
892template <class _A1>705template <class _A1>
893inline _LIBCPP_INLINE_VISIBILITY706inline _LIBCPP_HIDE_FROM_ABI
894typename std::enable_if<std::is_integral<_A1>::value, double>::type707typename 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
897// fabs710// fabs
898711
899# if !defined(__sun__)712# if !defined(__sun__)
900inline _LIBCPP_INLINE_VISIBILITY float fabs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);}713_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT {return __builtin_fabsf(__x);}
901inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_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);}
902# endif721# endif
903722
904template <class _A1>723template <class _A1>
905inline _LIBCPP_INLINE_VISIBILITY724_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
906typename std::enable_if<std::is_integral<_A1>::value, double>::type725typename 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
909// floor728// floor
910729
911# if !defined(__sun__)730# if !defined(__sun__)
912inline _LIBCPP_INLINE_VISIBILITY float floor(float __lcpp_x) _NOEXCEPT {return ::floorf(__lcpp_x);}731_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT {return __builtin_floorf(__x);}
913inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return ::floorl(__lcpp_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);}
914# endif739# endif
915740
916template <class _A1>741template <class _A1>
917inline _LIBCPP_INLINE_VISIBILITY742_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
918typename std::enable_if<std::is_integral<_A1>::value, double>::type743typename 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
921// fmod746// fmod
922747
923# if !defined(__sun__)748# if !defined(__sun__)
924inline _LIBCPP_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmodf(__lcpp_x, __lcpp_y);}749inline _LIBCPP_HIDE_FROM_ABI float fmod(float __x, float __y) _NOEXCEPT {return __builtin_fmodf(__x, __y);}
925inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fmodl(__lcpp_x, __lcpp_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);}
926# endif757# endif
927758
928template <class _A1, class _A2>759template <class _A1, class _A2>
929inline _LIBCPP_INLINE_VISIBILITY760inline _LIBCPP_HIDE_FROM_ABI
930typename std::__enable_if_t761typename std::__enable_if_t
931<762<
932 std::is_arithmetic<_A1>::value &&763 std::is_arithmetic<_A1>::value &&
933 std::is_arithmetic<_A2>::value,764 std::is_arithmetic<_A2>::value,
934 std::__promote<_A1, _A2>765 std::__promote<_A1, _A2>
935>::type766>::type
936fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT767fmod(_A1 __x, _A2 __y) _NOEXCEPT
937{768{
938 typedef typename std::__promote<_A1, _A2>::type __result_type;769 typedef typename std::__promote<_A1, _A2>::type __result_type;
939 static_assert((!(std::_IsSame<_A1, __result_type>::value &&770 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
940 std::_IsSame<_A2, __result_type>::value)), "");771 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);
942}773}
943774
944// frexp775// frexp
945776
946# if !defined(__sun__)777# if !defined(__sun__)
947inline _LIBCPP_INLINE_VISIBILITY float frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpf(__lcpp_x, __lcpp_e);}778inline _LIBCPP_HIDE_FROM_ABI float frexp(float __x, int* __e) _NOEXCEPT {return __builtin_frexpf(__x, __e);}
948inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpl(__lcpp_x, __lcpp_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);}
949# endif786# endif
950787
951template <class _A1>788template <class _A1>
952inline _LIBCPP_INLINE_VISIBILITY789inline _LIBCPP_HIDE_FROM_ABI
953typename std::enable_if<std::is_integral<_A1>::value, double>::type790typename 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
956// ldexp793// ldexp
957794
958# if !defined(__sun__)795# if !defined(__sun__)
959inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpf(__lcpp_x, __lcpp_e);}796inline _LIBCPP_HIDE_FROM_ABI float ldexp(float __x, int __e) _NOEXCEPT {return __builtin_ldexpf(__x, __e);}
960inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpl(__lcpp_x, __lcpp_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);}
961# endif804# endif
962805
963template <class _A1>806template <class _A1>
964inline _LIBCPP_INLINE_VISIBILITY807inline _LIBCPP_HIDE_FROM_ABI
965typename std::enable_if<std::is_integral<_A1>::value, double>::type808typename 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
968// log811// log
969812
970# if !defined(__sun__)813# if !defined(__sun__)
971inline _LIBCPP_INLINE_VISIBILITY float log(float __lcpp_x) _NOEXCEPT {return ::logf(__lcpp_x);}814inline _LIBCPP_HIDE_FROM_ABI float log(float __x) _NOEXCEPT {return __builtin_logf(__x);}
972inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return ::logl(__lcpp_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);}
973# endif822# endif
974823
975template <class _A1>824template <class _A1>
976inline _LIBCPP_INLINE_VISIBILITY825inline _LIBCPP_HIDE_FROM_ABI
977typename std::enable_if<std::is_integral<_A1>::value, double>::type826typename 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
980// log10829// log10
981830
982# if !defined(__sun__)831# if !defined(__sun__)
983inline _LIBCPP_INLINE_VISIBILITY float log10(float __lcpp_x) _NOEXCEPT {return ::log10f(__lcpp_x);}832inline _LIBCPP_HIDE_FROM_ABI float log10(float __x) _NOEXCEPT {return __builtin_log10f(__x);}
984inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return ::log10l(__lcpp_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);}
985# endif841# endif
986842
987template <class _A1>843template <class _A1>
988inline _LIBCPP_INLINE_VISIBILITY844inline _LIBCPP_HIDE_FROM_ABI
989typename std::enable_if<std::is_integral<_A1>::value, double>::type845typename 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
992// modf848// modf
993849
994# if !defined(__sun__)850# if !defined(__sun__)
995inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return ::modff(__lcpp_x, __lcpp_y);}851inline _LIBCPP_HIDE_FROM_ABI float modf(float __x, float* __y) _NOEXCEPT {return __builtin_modff(__x, __y);}
996inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return ::modfl(__lcpp_x, __lcpp_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);}
997# endif859# endif
998860
999// pow861// pow
1000862
1001# if !defined(__sun__)863# if !defined(__sun__)
1002inline _LIBCPP_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::powf(__lcpp_x, __lcpp_y);}864inline _LIBCPP_HIDE_FROM_ABI float pow(float __x, float __y) _NOEXCEPT {return __builtin_powf(__x, __y);}
1003inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::powl(__lcpp_x, __lcpp_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);}
1004# endif872# endif
1005873
1006template <class _A1, class _A2>874template <class _A1, class _A2>
1007inline _LIBCPP_INLINE_VISIBILITY875inline _LIBCPP_HIDE_FROM_ABI
1008typename std::__enable_if_t876typename std::__enable_if_t
1009<877<
1010 std::is_arithmetic<_A1>::value &&878 std::is_arithmetic<_A1>::value &&
1011 std::is_arithmetic<_A2>::value,879 std::is_arithmetic<_A2>::value,
1012 std::__promote<_A1, _A2>880 std::__promote<_A1, _A2>
1013>::type881>::type
1014pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT882pow(_A1 __x, _A2 __y) _NOEXCEPT
1015{883{
1016 typedef typename std::__promote<_A1, _A2>::type __result_type;884 typedef typename std::__promote<_A1, _A2>::type __result_type;
1017 static_assert((!(std::_IsSame<_A1, __result_type>::value &&885 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1018 std::_IsSame<_A2, __result_type>::value)), "");886 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);
1020}888}
1021889
1022// sin890// sin
1023891
1024# if !defined(__sun__)892# if !defined(__sun__)
1025inline _LIBCPP_INLINE_VISIBILITY float sin(float __lcpp_x) _NOEXCEPT {return ::sinf(__lcpp_x);}893inline _LIBCPP_HIDE_FROM_ABI float sin(float __x) _NOEXCEPT {return __builtin_sinf(__x);}
1026inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return ::sinl(__lcpp_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);}
1027#endif901#endif
1028902
1029template <class _A1>903template <class _A1>
1030inline _LIBCPP_INLINE_VISIBILITY904inline _LIBCPP_HIDE_FROM_ABI
1031typename std::enable_if<std::is_integral<_A1>::value, double>::type905typename 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
1034// sinh908// sinh
1035909
1036# if !defined(__sun__)910# if !defined(__sun__)
1037inline _LIBCPP_INLINE_VISIBILITY float sinh(float __lcpp_x) _NOEXCEPT {return ::sinhf(__lcpp_x);}911inline _LIBCPP_HIDE_FROM_ABI float sinh(float __x) _NOEXCEPT {return __builtin_sinhf(__x);}
1038inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return ::sinhl(__lcpp_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);}
1039# endif919# endif
1040920
1041template <class _A1>921template <class _A1>
1042inline _LIBCPP_INLINE_VISIBILITY922inline _LIBCPP_HIDE_FROM_ABI
1043typename std::enable_if<std::is_integral<_A1>::value, double>::type923typename 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
1046// sqrt926// sqrt
1047927
1048# if !defined(__sun__)928# if !defined(__sun__)
1049inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __lcpp_x) _NOEXCEPT {return ::sqrtf(__lcpp_x);}929inline _LIBCPP_HIDE_FROM_ABI float sqrt(float __x) _NOEXCEPT {return __builtin_sqrtf(__x);}
1050inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return ::sqrtl(__lcpp_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);}
1051# endif937# endif
1052938
1053template <class _A1>939template <class _A1>
1054inline _LIBCPP_INLINE_VISIBILITY940inline _LIBCPP_HIDE_FROM_ABI
1055typename std::enable_if<std::is_integral<_A1>::value, double>::type941typename 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
1058// tan944// tan
1059945
1060# if !defined(__sun__)946# if !defined(__sun__)
1061inline _LIBCPP_INLINE_VISIBILITY float tan(float __lcpp_x) _NOEXCEPT {return ::tanf(__lcpp_x);}947inline _LIBCPP_HIDE_FROM_ABI float tan(float __x) _NOEXCEPT {return __builtin_tanf(__x);}
1062inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return ::tanl(__lcpp_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);}
1063# endif955# endif
1064956
1065template <class _A1>957template <class _A1>
1066inline _LIBCPP_INLINE_VISIBILITY958inline _LIBCPP_HIDE_FROM_ABI
1067typename std::enable_if<std::is_integral<_A1>::value, double>::type959typename 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
1070// tanh962// tanh
1071963
1072# if !defined(__sun__)964# if !defined(__sun__)
1073inline _LIBCPP_INLINE_VISIBILITY float tanh(float __lcpp_x) _NOEXCEPT {return ::tanhf(__lcpp_x);}965inline _LIBCPP_HIDE_FROM_ABI float tanh(float __x) _NOEXCEPT {return __builtin_tanhf(__x);}
1074inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return ::tanhl(__lcpp_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);}
1075# endif973# endif
1076974
1077template <class _A1>975template <class _A1>
1078inline _LIBCPP_INLINE_VISIBILITY976inline _LIBCPP_HIDE_FROM_ABI
1079typename std::enable_if<std::is_integral<_A1>::value, double>::type977typename 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
1082// acosh980// acosh
1083981
1084inline _LIBCPP_INLINE_VISIBILITY float acosh(float __lcpp_x) _NOEXCEPT {return ::acoshf(__lcpp_x);}982inline _LIBCPP_HIDE_FROM_ABI float acosh(float __x) _NOEXCEPT {return __builtin_acoshf(__x);}
1085inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __lcpp_x) _NOEXCEPT {return ::acoshl(__lcpp_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
1087template <class _A1>991template <class _A1>
1088inline _LIBCPP_INLINE_VISIBILITY992inline _LIBCPP_HIDE_FROM_ABI
1089typename std::enable_if<std::is_integral<_A1>::value, double>::type993typename 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
1092// asinh996// asinh
1093997
1094inline _LIBCPP_INLINE_VISIBILITY float asinh(float __lcpp_x) _NOEXCEPT {return ::asinhf(__lcpp_x);}998inline _LIBCPP_HIDE_FROM_ABI float asinh(float __x) _NOEXCEPT {return __builtin_asinhf(__x);}
1095inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __lcpp_x) _NOEXCEPT {return ::asinhl(__lcpp_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
1097template <class _A1>1007template <class _A1>
1098inline _LIBCPP_INLINE_VISIBILITY1008inline _LIBCPP_HIDE_FROM_ABI
1099typename std::enable_if<std::is_integral<_A1>::value, double>::type1009typename 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
1102// atanh1012// atanh
11031013
1104inline _LIBCPP_INLINE_VISIBILITY float atanh(float __lcpp_x) _NOEXCEPT {return ::atanhf(__lcpp_x);}1014inline _LIBCPP_HIDE_FROM_ABI float atanh(float __x) _NOEXCEPT {return __builtin_atanhf(__x);}
1105inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __lcpp_x) _NOEXCEPT {return ::atanhl(__lcpp_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
1107template <class _A1>1023template <class _A1>
1108inline _LIBCPP_INLINE_VISIBILITY1024inline _LIBCPP_HIDE_FROM_ABI
1109typename std::enable_if<std::is_integral<_A1>::value, double>::type1025typename 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
1112// cbrt1028// cbrt
11131029
1114inline _LIBCPP_INLINE_VISIBILITY float cbrt(float __lcpp_x) _NOEXCEPT {return ::cbrtf(__lcpp_x);}1030_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT {return __builtin_cbrtf(__x);}
1115inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __lcpp_x) _NOEXCEPT {return ::cbrtl(__lcpp_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
1117template <class _A1>1039template <class _A1>
1118inline _LIBCPP_INLINE_VISIBILITY1040_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
1119typename std::enable_if<std::is_integral<_A1>::value, double>::type1041typename 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
1122// copysign1044// copysign
11231045
1124#if __has_builtin(__builtin_copysignf)1046_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT {
1125_LIBCPP_CONSTEXPR1047 return ::__builtin_copysignf(__x, __y);
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
1144}1048}
11451049
1146#if __has_builtin(__builtin_copysignl)1050_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT {
1147_LIBCPP_CONSTEXPR1051 return ::__builtin_copysignl(__x, __y);
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
1155}1052}
11561053
1157template <class _A1, class _A2>1054template <class _A1, class _A2>
1158#if __has_builtin(__builtin_copysign)1055_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
1159_LIBCPP_CONSTEXPR
1160#endif
1161inline _LIBCPP_INLINE_VISIBILITY
1162typename std::__enable_if_t1056typename std::__enable_if_t
1163<1057<
1164 std::is_arithmetic<_A1>::value &&1058 std::is_arithmetic<_A1>::value &&
1165 std::is_arithmetic<_A2>::value,1059 std::is_arithmetic<_A2>::value,
1166 std::__promote<_A1, _A2>1060 std::__promote<_A1, _A2>
1167>::type1061>::type
1168__libcpp_copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT {1062 copysign(_A1 __x, _A2 __y) _NOEXCEPT {
1169 typedef typename std::__promote<_A1, _A2>::type __result_type;1063 return ::__builtin_copysign(__x, __y);
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
1177}1064}
11781065
1179inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x, float __lcpp_y) _NOEXCEPT {1066// erf
1180 return ::__libcpp_copysign(__lcpp_x, __lcpp_y);
1181}
11821067
1183inline _LIBCPP_INLINE_VISIBILITY long double copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {1068inline _LIBCPP_HIDE_FROM_ABI float erf(float __x) _NOEXCEPT {return __builtin_erff(__x);}
1184 return ::__libcpp_copysign(__lcpp_x, __lcpp_y);
1185}
11861069
1187template <class _A1, class _A2>1070template <class = int>
1188inline _LIBCPP_INLINE_VISIBILITY1071_LIBCPP_HIDE_FROM_ABI double erf(double __x) _NOEXCEPT {
1189typename std::__enable_if_t1072 return __builtin_erf(__x);
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);
1197}1073}
11981074
1199// erf1075inline _LIBCPP_HIDE_FROM_ABI long double erf(long double __x) _NOEXCEPT {return __builtin_erfl(__x);}
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);}
12031076
1204template <class _A1>1077template <class _A1>
1205inline _LIBCPP_INLINE_VISIBILITY1078inline _LIBCPP_HIDE_FROM_ABI
1206typename std::enable_if<std::is_integral<_A1>::value, double>::type1079typename 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
1209// erfc1082// erfc
12101083
1211inline _LIBCPP_INLINE_VISIBILITY float erfc(float __lcpp_x) _NOEXCEPT {return ::erfcf(__lcpp_x);}1084inline _LIBCPP_HIDE_FROM_ABI float erfc(float __x) _NOEXCEPT {return __builtin_erfcf(__x);}
1212inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __lcpp_x) _NOEXCEPT {return ::erfcl(__lcpp_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
1214template <class _A1>1093template <class _A1>
1215inline _LIBCPP_INLINE_VISIBILITY1094inline _LIBCPP_HIDE_FROM_ABI
1216typename std::enable_if<std::is_integral<_A1>::value, double>::type1095typename 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
1219// exp21098// exp2
12201099
1221inline _LIBCPP_INLINE_VISIBILITY float exp2(float __lcpp_x) _NOEXCEPT {return ::exp2f(__lcpp_x);}1100inline _LIBCPP_HIDE_FROM_ABI float exp2(float __x) _NOEXCEPT {return __builtin_exp2f(__x);}
1222inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __lcpp_x) _NOEXCEPT {return ::exp2l(__lcpp_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
1224template <class _A1>1109template <class _A1>
1225inline _LIBCPP_INLINE_VISIBILITY1110inline _LIBCPP_HIDE_FROM_ABI
1226typename std::enable_if<std::is_integral<_A1>::value, double>::type1111typename 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
1229// expm11114// expm1
12301115
1231inline _LIBCPP_INLINE_VISIBILITY float expm1(float __lcpp_x) _NOEXCEPT {return ::expm1f(__lcpp_x);}1116inline _LIBCPP_HIDE_FROM_ABI float expm1(float __x) _NOEXCEPT {return __builtin_expm1f(__x);}
1232inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __lcpp_x) _NOEXCEPT {return ::expm1l(__lcpp_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
1234template <class _A1>1125template <class _A1>
1235inline _LIBCPP_INLINE_VISIBILITY1126inline _LIBCPP_HIDE_FROM_ABI
1236typename std::enable_if<std::is_integral<_A1>::value, double>::type1127typename 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
1239// fdim1130// fdim
12401131
1241inline _LIBCPP_INLINE_VISIBILITY float fdim(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fdimf(__lcpp_x, __lcpp_y);}1132inline _LIBCPP_HIDE_FROM_ABI float fdim(float __x, float __y) _NOEXCEPT {return __builtin_fdimf(__x, __y);}
1242inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fdiml(__lcpp_x, __lcpp_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
1244template <class _A1, class _A2>1141template <class _A1, class _A2>
1245inline _LIBCPP_INLINE_VISIBILITY1142inline _LIBCPP_HIDE_FROM_ABI
1246typename std::__enable_if_t1143typename std::__enable_if_t
1247<1144<
1248 std::is_arithmetic<_A1>::value &&1145 std::is_arithmetic<_A1>::value &&
1249 std::is_arithmetic<_A2>::value,1146 std::is_arithmetic<_A2>::value,
1250 std::__promote<_A1, _A2>1147 std::__promote<_A1, _A2>
1251>::type1148>::type
1252fdim(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT1149fdim(_A1 __x, _A2 __y) _NOEXCEPT
1253{1150{
1254 typedef typename std::__promote<_A1, _A2>::type __result_type;1151 typedef typename std::__promote<_A1, _A2>::type __result_type;
1255 static_assert((!(std::_IsSame<_A1, __result_type>::value &&1152 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1256 std::_IsSame<_A2, __result_type>::value)), "");1153 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);
1258}1155}
12591156
1260// fma1157// fma
12611158
1262inline _LIBCPP_INLINE_VISIBILITY float fma(float __lcpp_x, float __lcpp_y, float __lcpp_z) _NOEXCEPT1159inline _LIBCPP_HIDE_FROM_ABI float fma(float __x, float __y, float __z) _NOEXCEPT
1263{1160{
1264#if __has_builtin(__builtin_fmaf)1161 return __builtin_fmaf(__x, __y, __z);
1265 return __builtin_fmaf(__lcpp_x, __lcpp_y, __lcpp_z);1162}
1266#else1163
1267 return ::fmaf(__lcpp_x, __lcpp_y, __lcpp_z);1164
1268#endif1165template <class = int>
1166_LIBCPP_HIDE_FROM_ABI double fma(double __x, double __y, double __z) _NOEXCEPT {
1167 return __builtin_fma(__x, __y, __z);
1269}1168}
1270inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __lcpp_x, long double __lcpp_y, long double __lcpp_z) _NOEXCEPT1169
1170inline _LIBCPP_HIDE_FROM_ABI long double fma(long double __x, long double __y, long double __z) _NOEXCEPT
1271{1171{
1272#if __has_builtin(__builtin_fmal)1172 return __builtin_fmal(__x, __y, __z);
1273 return __builtin_fmal(__lcpp_x, __lcpp_y, __lcpp_z);
1274#else
1275 return ::fmal(__lcpp_x, __lcpp_y, __lcpp_z);
1276#endif
1277}1173}
12781174
1279template <class _A1, class _A2, class _A3>1175template <class _A1, class _A2, class _A3>
1280inline _LIBCPP_INLINE_VISIBILITY1176inline _LIBCPP_HIDE_FROM_ABI
1281typename std::__enable_if_t1177typename std::__enable_if_t
1282<1178<
1283 std::is_arithmetic<_A1>::value &&1179 std::is_arithmetic<_A1>::value &&
...@@ -1285,462 +1181,512 @@ typename std::__enable_if_t...@@ -1285,462 +1181,512 @@ typename std::__enable_if_t
1285 std::is_arithmetic<_A3>::value,1181 std::is_arithmetic<_A3>::value,
1286 std::__promote<_A1, _A2, _A3>1182 std::__promote<_A1, _A2, _A3>
1287>::type1183>::type
1288fma(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT1184fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT
1289{1185{
1290 typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;1186 typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;
1291 static_assert((!(std::_IsSame<_A1, __result_type>::value &&1187 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1292 std::_IsSame<_A2, __result_type>::value &&1188 std::_IsSame<_A2, __result_type>::value &&
1293 std::_IsSame<_A3, __result_type>::value)), "");1189 std::_IsSame<_A3, __result_type>::value)), "");
1294#if __has_builtin(__builtin_fma)1190 return __builtin_fma((__result_type)__x, (__result_type)__y, (__result_type)__z);
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
1299}1191}
13001192
1301// fmax1193// fmax
13021194
1303inline _LIBCPP_INLINE_VISIBILITY float fmax(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmaxf(__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);}
1304inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fmaxl(__lcpp_x, __lcpp_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
1306template <class _A1, class _A2>1204template <class _A1, class _A2>
1307inline _LIBCPP_INLINE_VISIBILITY1205_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
1308typename std::__enable_if_t1206typename std::__enable_if_t
1309<1207<
1310 std::is_arithmetic<_A1>::value &&1208 std::is_arithmetic<_A1>::value &&
1311 std::is_arithmetic<_A2>::value,1209 std::is_arithmetic<_A2>::value,
1312 std::__promote<_A1, _A2>1210 std::__promote<_A1, _A2>
1313>::type1211>::type
1314fmax(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT1212fmax(_A1 __x, _A2 __y) _NOEXCEPT
1315{1213{
1316 typedef typename std::__promote<_A1, _A2>::type __result_type;1214 typedef typename std::__promote<_A1, _A2>::type __result_type;
1317 static_assert((!(std::_IsSame<_A1, __result_type>::value &&1215 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1318 std::_IsSame<_A2, __result_type>::value)), "");1216 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);
1320}1218}
13211219
1322// fmin1220// fmin
13231221
1324inline _LIBCPP_INLINE_VISIBILITY float fmin(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fminf(__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);}
1325inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fminl(__lcpp_x, __lcpp_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
1327template <class _A1, class _A2>1231template <class _A1, class _A2>
1328inline _LIBCPP_INLINE_VISIBILITY1232_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
1329typename std::__enable_if_t1233typename std::__enable_if_t
1330<1234<
1331 std::is_arithmetic<_A1>::value &&1235 std::is_arithmetic<_A1>::value &&
1332 std::is_arithmetic<_A2>::value,1236 std::is_arithmetic<_A2>::value,
1333 std::__promote<_A1, _A2>1237 std::__promote<_A1, _A2>
1334>::type1238>::type
1335fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT1239fmin(_A1 __x, _A2 __y) _NOEXCEPT
1336{1240{
1337 typedef typename std::__promote<_A1, _A2>::type __result_type;1241 typedef typename std::__promote<_A1, _A2>::type __result_type;
1338 static_assert((!(std::_IsSame<_A1, __result_type>::value &&1242 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1339 std::_IsSame<_A2, __result_type>::value)), "");1243 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);
1341}1245}
13421246
1343// hypot1247// hypot
13441248
1345inline _LIBCPP_INLINE_VISIBILITY float hypot(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::hypotf(__lcpp_x, __lcpp_y);}1249inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y) _NOEXCEPT {return __builtin_hypotf(__x, __y);}
1346inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::hypotl(__lcpp_x, __lcpp_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
1348template <class _A1, class _A2>1258template <class _A1, class _A2>
1349inline _LIBCPP_INLINE_VISIBILITY1259inline _LIBCPP_HIDE_FROM_ABI
1350typename std::__enable_if_t1260typename std::__enable_if_t
1351<1261<
1352 std::is_arithmetic<_A1>::value &&1262 std::is_arithmetic<_A1>::value &&
1353 std::is_arithmetic<_A2>::value,1263 std::is_arithmetic<_A2>::value,
1354 std::__promote<_A1, _A2>1264 std::__promote<_A1, _A2>
1355>::type1265>::type
1356hypot(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT1266hypot(_A1 __x, _A2 __y) _NOEXCEPT
1357{1267{
1358 typedef typename std::__promote<_A1, _A2>::type __result_type;1268 typedef typename std::__promote<_A1, _A2>::type __result_type;
1359 static_assert((!(std::_IsSame<_A1, __result_type>::value &&1269 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1360 std::_IsSame<_A2, __result_type>::value)), "");1270 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);
1362}1272}
13631273
1364// ilogb1274// ilogb
13651275
1366inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __lcpp_x) _NOEXCEPT {return ::ilogbf(__lcpp_x);}1276inline _LIBCPP_HIDE_FROM_ABI int ilogb(float __x) _NOEXCEPT {return __builtin_ilogbf(__x);}
1367inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __lcpp_x) _NOEXCEPT {return ::ilogbl(__lcpp_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
1369template <class _A1>1285template <class _A1>
1370inline _LIBCPP_INLINE_VISIBILITY1286inline _LIBCPP_HIDE_FROM_ABI
1371typename std::enable_if<std::is_integral<_A1>::value, int>::type1287typename 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
1374// lgamma1290// lgamma
13751291
1376inline _LIBCPP_INLINE_VISIBILITY float lgamma(float __lcpp_x) _NOEXCEPT {return ::lgammaf(__lcpp_x);}1292inline _LIBCPP_HIDE_FROM_ABI float lgamma(float __x) _NOEXCEPT {return __builtin_lgammaf(__x);}
1377inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __lcpp_x) _NOEXCEPT {return ::lgammal(__lcpp_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
1379template <class _A1>1301template <class _A1>
1380inline _LIBCPP_INLINE_VISIBILITY1302inline _LIBCPP_HIDE_FROM_ABI
1381typename std::enable_if<std::is_integral<_A1>::value, double>::type1303typename 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
1384// llrint1306// llrint
13851307
1386inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __lcpp_x) _NOEXCEPT1308inline _LIBCPP_HIDE_FROM_ABI long long llrint(float __x) _NOEXCEPT
1387{1309{
1388#if __has_builtin(__builtin_llrintf)1310 return __builtin_llrintf(__x);
1389 return __builtin_llrintf(__lcpp_x);1311}
1390#else1312
1391 return ::llrintf(__lcpp_x);1313template <class = int>
1392#endif1314_LIBCPP_HIDE_FROM_ABI long long llrint(double __x) _NOEXCEPT {
1315 return __builtin_llrint(__x);
1393}1316}
1394inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __lcpp_x) _NOEXCEPT1317
1318inline _LIBCPP_HIDE_FROM_ABI long long llrint(long double __x) _NOEXCEPT
1395{1319{
1396#if __has_builtin(__builtin_llrintl)1320 return __builtin_llrintl(__x);
1397 return __builtin_llrintl(__lcpp_x);
1398#else
1399 return ::llrintl(__lcpp_x);
1400#endif
1401}1321}
14021322
1403template <class _A1>1323template <class _A1>
1404inline _LIBCPP_INLINE_VISIBILITY1324inline _LIBCPP_HIDE_FROM_ABI
1405typename std::enable_if<std::is_integral<_A1>::value, long long>::type1325typename std::enable_if<std::is_integral<_A1>::value, long long>::type
1406llrint(_A1 __lcpp_x) _NOEXCEPT1326llrint(_A1 __x) _NOEXCEPT
1407{1327{
1408#if __has_builtin(__builtin_llrint)1328 return __builtin_llrint((double)__x);
1409 return __builtin_llrint((double)__lcpp_x);
1410#else
1411 return ::llrint((double)__lcpp_x);
1412#endif
1413}1329}
14141330
1415// llround1331// llround
14161332
1417inline _LIBCPP_INLINE_VISIBILITY long long llround(float __lcpp_x) _NOEXCEPT1333inline _LIBCPP_HIDE_FROM_ABI long long llround(float __x) _NOEXCEPT
1418{1334{
1419#if __has_builtin(__builtin_llroundf)1335 return __builtin_llroundf(__x);
1420 return __builtin_llroundf(__lcpp_x);1336}
1421#else1337
1422 return ::llroundf(__lcpp_x);1338template <class = int>
1423#endif1339_LIBCPP_HIDE_FROM_ABI long long llround(double __x) _NOEXCEPT {
1340 return __builtin_llround(__x);
1424}1341}
1425inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __lcpp_x) _NOEXCEPT1342
1343inline _LIBCPP_HIDE_FROM_ABI long long llround(long double __x) _NOEXCEPT
1426{1344{
1427#if __has_builtin(__builtin_llroundl)1345 return __builtin_llroundl(__x);
1428 return __builtin_llroundl(__lcpp_x);
1429#else
1430 return ::llroundl(__lcpp_x);
1431#endif
1432}1346}
14331347
1434template <class _A1>1348template <class _A1>
1435inline _LIBCPP_INLINE_VISIBILITY1349inline _LIBCPP_HIDE_FROM_ABI
1436typename std::enable_if<std::is_integral<_A1>::value, long long>::type1350typename std::enable_if<std::is_integral<_A1>::value, long long>::type
1437llround(_A1 __lcpp_x) _NOEXCEPT1351llround(_A1 __x) _NOEXCEPT
1438{1352{
1439#if __has_builtin(__builtin_llround)1353 return __builtin_llround((double)__x);
1440 return __builtin_llround((double)__lcpp_x);
1441#else
1442 return ::llround((double)__lcpp_x);
1443#endif
1444}1354}
14451355
1446// log1p1356// log1p
14471357
1448inline _LIBCPP_INLINE_VISIBILITY float log1p(float __lcpp_x) _NOEXCEPT {return ::log1pf(__lcpp_x);}1358inline _LIBCPP_HIDE_FROM_ABI float log1p(float __x) _NOEXCEPT {return __builtin_log1pf(__x);}
1449inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __lcpp_x) _NOEXCEPT {return ::log1pl(__lcpp_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
1451template <class _A1>1367template <class _A1>
1452inline _LIBCPP_INLINE_VISIBILITY1368inline _LIBCPP_HIDE_FROM_ABI
1453typename std::enable_if<std::is_integral<_A1>::value, double>::type1369typename 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
1456// log21372// log2
14571373
1458inline _LIBCPP_INLINE_VISIBILITY float log2(float __lcpp_x) _NOEXCEPT {return ::log2f(__lcpp_x);}1374inline _LIBCPP_HIDE_FROM_ABI float log2(float __x) _NOEXCEPT {return __builtin_log2f(__x);}
1459inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __lcpp_x) _NOEXCEPT {return ::log2l(__lcpp_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
1461template <class _A1>1383template <class _A1>
1462inline _LIBCPP_INLINE_VISIBILITY1384inline _LIBCPP_HIDE_FROM_ABI
1463typename std::enable_if<std::is_integral<_A1>::value, double>::type1385typename 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
1466// logb1388// logb
14671389
1468inline _LIBCPP_INLINE_VISIBILITY float logb(float __lcpp_x) _NOEXCEPT {return ::logbf(__lcpp_x);}1390inline _LIBCPP_HIDE_FROM_ABI float logb(float __x) _NOEXCEPT {return __builtin_logbf(__x);}
1469inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __lcpp_x) _NOEXCEPT {return ::logbl(__lcpp_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
1471template <class _A1>1399template <class _A1>
1472inline _LIBCPP_INLINE_VISIBILITY1400inline _LIBCPP_HIDE_FROM_ABI
1473typename std::enable_if<std::is_integral<_A1>::value, double>::type1401typename 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
1476// lrint1404// lrint
14771405
1478inline _LIBCPP_INLINE_VISIBILITY long lrint(float __lcpp_x) _NOEXCEPT1406inline _LIBCPP_HIDE_FROM_ABI long lrint(float __x) _NOEXCEPT
1479{1407{
1480#if __has_builtin(__builtin_lrintf)1408 return __builtin_lrintf(__x);
1481 return __builtin_lrintf(__lcpp_x);
1482#else
1483 return ::lrintf(__lcpp_x);
1484#endif
1485}1409}
1486inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __lcpp_x) _NOEXCEPT1410
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
1487{1417{
1488#if __has_builtin(__builtin_lrintl)1418 return __builtin_lrintl(__x);
1489 return __builtin_lrintl(__lcpp_x);
1490#else
1491 return ::lrintl(__lcpp_x);
1492#endif
1493}1419}
14941420
1495template <class _A1>1421template <class _A1>
1496inline _LIBCPP_INLINE_VISIBILITY1422inline _LIBCPP_HIDE_FROM_ABI
1497typename std::enable_if<std::is_integral<_A1>::value, long>::type1423typename std::enable_if<std::is_integral<_A1>::value, long>::type
1498lrint(_A1 __lcpp_x) _NOEXCEPT1424lrint(_A1 __x) _NOEXCEPT
1499{1425{
1500#if __has_builtin(__builtin_lrint)1426 return __builtin_lrint((double)__x);
1501 return __builtin_lrint((double)__lcpp_x);
1502#else
1503 return ::lrint((double)__lcpp_x);
1504#endif
1505}1427}
15061428
1507// lround1429// lround
15081430
1509inline _LIBCPP_INLINE_VISIBILITY long lround(float __lcpp_x) _NOEXCEPT1431inline _LIBCPP_HIDE_FROM_ABI long lround(float __x) _NOEXCEPT
1510{1432{
1511#if __has_builtin(__builtin_lroundf)1433 return __builtin_lroundf(__x);
1512 return __builtin_lroundf(__lcpp_x);
1513#else
1514 return ::lroundf(__lcpp_x);
1515#endif
1516}1434}
1517inline _LIBCPP_INLINE_VISIBILITY long lround(long double __lcpp_x) _NOEXCEPT1435
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
1518{1442{
1519#if __has_builtin(__builtin_lroundl)1443 return __builtin_lroundl(__x);
1520 return __builtin_lroundl(__lcpp_x);
1521#else
1522 return ::lroundl(__lcpp_x);
1523#endif
1524}1444}
15251445
1526template <class _A1>1446template <class _A1>
1527inline _LIBCPP_INLINE_VISIBILITY1447inline _LIBCPP_HIDE_FROM_ABI
1528typename std::enable_if<std::is_integral<_A1>::value, long>::type1448typename std::enable_if<std::is_integral<_A1>::value, long>::type
1529lround(_A1 __lcpp_x) _NOEXCEPT1449lround(_A1 __x) _NOEXCEPT
1530{1450{
1531#if __has_builtin(__builtin_lround)1451 return __builtin_lround((double)__x);
1532 return __builtin_lround((double)__lcpp_x);
1533#else
1534 return ::lround((double)__lcpp_x);
1535#endif
1536}1452}
15371453
1538// nan1454// nan
15391455
1540// nearbyint1456// nearbyint
15411457
1542inline _LIBCPP_INLINE_VISIBILITY float nearbyint(float __lcpp_x) _NOEXCEPT {return ::nearbyintf(__lcpp_x);}1458_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT {return __builtin_nearbyintf(__x);}
1543inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __lcpp_x) _NOEXCEPT {return ::nearbyintl(__lcpp_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
1545template <class _A1>1467template <class _A1>
1546inline _LIBCPP_INLINE_VISIBILITY1468_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
1547typename std::enable_if<std::is_integral<_A1>::value, double>::type1469typename 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
1550// nextafter1472// nextafter
15511473
1552inline _LIBCPP_INLINE_VISIBILITY float nextafter(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::nextafterf(__lcpp_x, __lcpp_y);}1474inline _LIBCPP_HIDE_FROM_ABI float nextafter(float __x, float __y) _NOEXCEPT {return __builtin_nextafterf(__x, __y);}
1553inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nextafterl(__lcpp_x, __lcpp_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
1555template <class _A1, class _A2>1483template <class _A1, class _A2>
1556inline _LIBCPP_INLINE_VISIBILITY1484inline _LIBCPP_HIDE_FROM_ABI
1557typename std::__enable_if_t1485typename std::__enable_if_t
1558<1486<
1559 std::is_arithmetic<_A1>::value &&1487 std::is_arithmetic<_A1>::value &&
1560 std::is_arithmetic<_A2>::value,1488 std::is_arithmetic<_A2>::value,
1561 std::__promote<_A1, _A2>1489 std::__promote<_A1, _A2>
1562>::type1490>::type
1563nextafter(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT1491nextafter(_A1 __x, _A2 __y) _NOEXCEPT
1564{1492{
1565 typedef typename std::__promote<_A1, _A2>::type __result_type;1493 typedef typename std::__promote<_A1, _A2>::type __result_type;
1566 static_assert((!(std::_IsSame<_A1, __result_type>::value &&1494 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1567 std::_IsSame<_A2, __result_type>::value)), "");1495 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);
1569}1497}
15701498
1571// nexttoward1499// nexttoward
15721500
1573inline _LIBCPP_INLINE_VISIBILITY float nexttoward(float __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttowardf(__lcpp_x, __lcpp_y);}1501inline _LIBCPP_HIDE_FROM_ABI float nexttoward(float __x, long double __y) _NOEXCEPT {return __builtin_nexttowardf(__x, __y);}
1574inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttowardl(__lcpp_x, __lcpp_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
1576template <class _A1>1510template <class _A1>
1577inline _LIBCPP_INLINE_VISIBILITY1511inline _LIBCPP_HIDE_FROM_ABI
1578typename std::enable_if<std::is_integral<_A1>::value, double>::type1512typename 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
1581// remainder1515// remainder
15821516
1583inline _LIBCPP_INLINE_VISIBILITY float remainder(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::remainderf(__lcpp_x, __lcpp_y);}1517inline _LIBCPP_HIDE_FROM_ABI float remainder(float __x, float __y) _NOEXCEPT {return __builtin_remainderf(__x, __y);}
1584inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::remainderl(__lcpp_x, __lcpp_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
1586template <class _A1, class _A2>1526template <class _A1, class _A2>
1587inline _LIBCPP_INLINE_VISIBILITY1527inline _LIBCPP_HIDE_FROM_ABI
1588typename std::__enable_if_t1528typename std::__enable_if_t
1589<1529<
1590 std::is_arithmetic<_A1>::value &&1530 std::is_arithmetic<_A1>::value &&
1591 std::is_arithmetic<_A2>::value,1531 std::is_arithmetic<_A2>::value,
1592 std::__promote<_A1, _A2>1532 std::__promote<_A1, _A2>
1593>::type1533>::type
1594remainder(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT1534remainder(_A1 __x, _A2 __y) _NOEXCEPT
1595{1535{
1596 typedef typename std::__promote<_A1, _A2>::type __result_type;1536 typedef typename std::__promote<_A1, _A2>::type __result_type;
1597 static_assert((!(std::_IsSame<_A1, __result_type>::value &&1537 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1598 std::_IsSame<_A2, __result_type>::value)), "");1538 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);
1600}1540}
16011541
1602// remquo1542// 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);}1544inline _LIBCPP_HIDE_FROM_ABI float remquo(float __x, float __y, int* __z) _NOEXCEPT {return __builtin_remquof(__x, __y, __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);}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
1607template <class _A1, class _A2>1553template <class _A1, class _A2>
1608inline _LIBCPP_INLINE_VISIBILITY1554inline _LIBCPP_HIDE_FROM_ABI
1609typename std::__enable_if_t1555typename std::__enable_if_t
1610<1556<
1611 std::is_arithmetic<_A1>::value &&1557 std::is_arithmetic<_A1>::value &&
1612 std::is_arithmetic<_A2>::value,1558 std::is_arithmetic<_A2>::value,
1613 std::__promote<_A1, _A2>1559 std::__promote<_A1, _A2>
1614>::type1560>::type
1615remquo(_A1 __lcpp_x, _A2 __lcpp_y, int* __lcpp_z) _NOEXCEPT1561remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT
1616{1562{
1617 typedef typename std::__promote<_A1, _A2>::type __result_type;1563 typedef typename std::__promote<_A1, _A2>::type __result_type;
1618 static_assert((!(std::_IsSame<_A1, __result_type>::value &&1564 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1619 std::_IsSame<_A2, __result_type>::value)), "");1565 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);
1621}1567}
16221568
1623// rint1569// rint
16241570
1625inline _LIBCPP_INLINE_VISIBILITY float rint(float __lcpp_x) _NOEXCEPT1571_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT
1626{1572{
1627#if __has_builtin(__builtin_rintf)1573 return __builtin_rintf(__x);
1628 return __builtin_rintf(__lcpp_x);
1629#else
1630 return ::rintf(__lcpp_x);
1631#endif
1632}1574}
1633inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __lcpp_x) _NOEXCEPT1575
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
1634{1582{
1635#if __has_builtin(__builtin_rintl)1583 return __builtin_rintl(__x);
1636 return __builtin_rintl(__lcpp_x);
1637#else
1638 return ::rintl(__lcpp_x);
1639#endif
1640}1584}
16411585
1642template <class _A1>1586template <class _A1>
1643inline _LIBCPP_INLINE_VISIBILITY1587_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
1644typename std::enable_if<std::is_integral<_A1>::value, double>::type1588typename std::enable_if<std::is_integral<_A1>::value, double>::type
1645rint(_A1 __lcpp_x) _NOEXCEPT1589rint(_A1 __x) _NOEXCEPT
1646{1590{
1647#if __has_builtin(__builtin_rint)1591 return __builtin_rint((double)__x);
1648 return __builtin_rint((double)__lcpp_x);
1649#else
1650 return ::rint((double)__lcpp_x);
1651#endif
1652}1592}
16531593
1654// round1594// round
16551595
1656inline _LIBCPP_INLINE_VISIBILITY float round(float __lcpp_x) _NOEXCEPT1596_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT
1657{1597{
1658#if __has_builtin(__builtin_round)1598 return __builtin_round(__x);
1659 return __builtin_round(__lcpp_x);
1660#else
1661 return ::round(__lcpp_x);
1662#endif
1663}1599}
1664inline _LIBCPP_INLINE_VISIBILITY long double round(long double __lcpp_x) _NOEXCEPT1600
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
1665{1607{
1666#if __has_builtin(__builtin_roundl)1608 return __builtin_roundl(__x);
1667 return __builtin_roundl(__lcpp_x);
1668#else
1669 return ::roundl(__lcpp_x);
1670#endif
1671}1609}
16721610
1673template <class _A1>1611template <class _A1>
1674inline _LIBCPP_INLINE_VISIBILITY1612_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
1675typename std::enable_if<std::is_integral<_A1>::value, double>::type1613typename std::enable_if<std::is_integral<_A1>::value, double>::type
1676round(_A1 __lcpp_x) _NOEXCEPT1614round(_A1 __x) _NOEXCEPT
1677{1615{
1678#if __has_builtin(__builtin_round)1616 return __builtin_round((double)__x);
1679 return __builtin_round((double)__lcpp_x);
1680#else
1681 return ::round((double)__lcpp_x);
1682#endif
1683}1617}
16841618
1685// scalbln1619// scalbln
16861620
1687inline _LIBCPP_INLINE_VISIBILITY float scalbln(float __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalblnf(__lcpp_x, __lcpp_y);}1621inline _LIBCPP_HIDE_FROM_ABI float scalbln(float __x, long __y) _NOEXCEPT {return __builtin_scalblnf(__x, __y);}
1688inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalblnl(__lcpp_x, __lcpp_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
1690template <class _A1>1630template <class _A1>
1691inline _LIBCPP_INLINE_VISIBILITY1631inline _LIBCPP_HIDE_FROM_ABI
1692typename std::enable_if<std::is_integral<_A1>::value, double>::type1632typename 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
1695// scalbn1635// scalbn
16961636
1697inline _LIBCPP_INLINE_VISIBILITY float scalbn(float __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbnf(__lcpp_x, __lcpp_y);}1637inline _LIBCPP_HIDE_FROM_ABI float scalbn(float __x, int __y) _NOEXCEPT {return __builtin_scalbnf(__x, __y);}
1698inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbnl(__lcpp_x, __lcpp_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
1700template <class _A1>1646template <class _A1>
1701inline _LIBCPP_INLINE_VISIBILITY1647inline _LIBCPP_HIDE_FROM_ABI
1702typename std::enable_if<std::is_integral<_A1>::value, double>::type1648typename 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
1705// tgamma1651// tgamma
17061652
1707inline _LIBCPP_INLINE_VISIBILITY float tgamma(float __lcpp_x) _NOEXCEPT {return ::tgammaf(__lcpp_x);}1653inline _LIBCPP_HIDE_FROM_ABI float tgamma(float __x) _NOEXCEPT {return __builtin_tgammaf(__x);}
1708inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __lcpp_x) _NOEXCEPT {return ::tgammal(__lcpp_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
1710template <class _A1>1662template <class _A1>
1711inline _LIBCPP_INLINE_VISIBILITY1663inline _LIBCPP_HIDE_FROM_ABI
1712typename std::enable_if<std::is_integral<_A1>::value, double>::type1664typename 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
1715// trunc1667// trunc
17161668
1717inline _LIBCPP_INLINE_VISIBILITY float trunc(float __lcpp_x) _NOEXCEPT1669_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT
1718{1670{
1719#if __has_builtin(__builtin_trunc)1671 return __builtin_trunc(__x);
1720 return __builtin_trunc(__lcpp_x);
1721#else
1722 return ::trunc(__lcpp_x);
1723#endif
1724}1672}
1725inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __lcpp_x) _NOEXCEPT1673
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
1726{1680{
1727#if __has_builtin(__builtin_truncl)1681 return __builtin_truncl(__x);
1728 return __builtin_truncl(__lcpp_x);
1729#else
1730 return ::truncl(__lcpp_x);
1731#endif
1732}1682}
17331683
1734template <class _A1>1684template <class _A1>
1735inline _LIBCPP_INLINE_VISIBILITY1685_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
1736typename std::enable_if<std::is_integral<_A1>::value, double>::type1686typename std::enable_if<std::is_integral<_A1>::value, double>::type
1737trunc(_A1 __lcpp_x) _NOEXCEPT1687trunc(_A1 __x) _NOEXCEPT
1738{1688{
1739#if __has_builtin(__builtin_trunc)1689 return __builtin_trunc((double)__x);
1740 return __builtin_trunc((double)__lcpp_x);
1741#else
1742 return ::trunc((double)__lcpp_x);
1743#endif
1744}1690}
17451691
1746} // extern "C++"1692} // extern "C++"
lib/libcxx/include/memory+131-230
...@@ -406,16 +406,17 @@ template <class T>...@@ -406,16 +406,17 @@ template <class T>
406struct default_delete406struct default_delete
407{407{
408 constexpr default_delete() noexcept = default;408 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
412};412};
413413
414template <class T>414template <class T>
415struct default_delete<T[]>415struct default_delete<T[]>
416{416{
417 constexpr default_delete() noexcept = default;417 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
419 template <class U> void operator()(U*) const = delete;420 template <class U> void operator()(U*) const = delete;
420};421};
421422
...@@ -429,36 +430,37 @@ public:...@@ -429,36 +430,37 @@ public:
429430
430 // constructors431 // constructors
431 constexpr unique_ptr() noexcept;432 constexpr unique_ptr() noexcept;
432 explicit unique_ptr(pointer p) noexcept;433 constexpr explicit unique_ptr(pointer p) noexcept; // constexpr since C++23
433 unique_ptr(pointer p, see below d1) noexcept;434 constexpr unique_ptr(pointer p, see below d1) noexcept; // constexpr since C++23
434 unique_ptr(pointer p, see below d2) noexcept;435 constexpr unique_ptr(pointer p, see below d2) noexcept; // constexpr since C++23
435 unique_ptr(unique_ptr&& u) noexcept;436 constexpr unique_ptr(unique_ptr&& u) noexcept; // constexpr since C++23
436 unique_ptr(nullptr_t) noexcept : unique_ptr() { }437 constexpr unique_ptr(nullptr_t) noexcept : unique_ptr() { }
437 template <class U, class E>438 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
439 template <class U>440 template <class U>
440 unique_ptr(auto_ptr<U>&& u) noexcept; // removed in C++17441 unique_ptr(auto_ptr<U>&& u) noexcept; // removed in C++17
441442
442 // destructor443 // destructor
443 ~unique_ptr();444 constexpr ~unique_ptr(); // constexpr since C++23
444445
445 // assignment446 // assignment
446 unique_ptr& operator=(unique_ptr&& u) noexcept;447 constexpr unique_ptr& operator=(unique_ptr&& u) noexcept; // constexpr since C++23
447 template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;448 template <class U, class E>
448 unique_ptr& operator=(nullptr_t) noexcept;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
450 // observers452 // observers
451 typename add_lvalue_reference<T>::type operator*() const;453 typename constexpr add_lvalue_reference<T>::type operator*() const; // constexpr since C++23
452 pointer operator->() const noexcept;454 constexpr pointer operator->() const noexcept; // constexpr since C++23
453 pointer get() const noexcept;455 constexpr pointer get() const noexcept; // constexpr since C++23
454 deleter_type& get_deleter() noexcept;456 constexpr deleter_type& get_deleter() noexcept; // constexpr since C++23
455 const deleter_type& get_deleter() const noexcept;457 constexpr const deleter_type& get_deleter() const noexcept; // constexpr since C++23
456 explicit operator bool() const noexcept;458 constexpr explicit operator bool() const noexcept; // constexpr since C++23
457459
458 // modifiers460 // modifiers
459 pointer release() noexcept;461 constexpr pointer release() noexcept; // constexpr since C++23
460 void reset(pointer p = pointer()) noexcept;462 constexpr void reset(pointer p = pointer()) noexcept; // constexpr since C++23
461 void swap(unique_ptr& u) noexcept;463 constexpr void swap(unique_ptr& u) noexcept; // constexpr since C++23
462};464};
463465
464template <class T, class D>466template <class T, class D>
...@@ -471,41 +473,45 @@ public:...@@ -471,41 +473,45 @@ public:
471473
472 // constructors474 // constructors
473 constexpr unique_ptr() noexcept;475 constexpr unique_ptr() noexcept;
474 explicit unique_ptr(pointer p) noexcept;476 constexpr explicit unique_ptr(pointer p) noexcept; // constexpr since C++23
475 unique_ptr(pointer p, see below d) noexcept;477 constexpr unique_ptr(pointer p, see below d) noexcept; // constexpr since C++23
476 unique_ptr(pointer p, see below d) noexcept;478 constexpr unique_ptr(pointer p, see below d) noexcept; // constexpr since C++23
477 unique_ptr(unique_ptr&& u) noexcept;479 constexpr unique_ptr(unique_ptr&& u) noexcept; // constexpr since C++23
478 unique_ptr(nullptr_t) noexcept : unique_ptr() { }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
480 // destructor484 // destructor
481 ~unique_ptr();485 constexpr ~unique_ptr(); // constexpr since C++23
482486
483 // assignment487 // assignment
484 unique_ptr& operator=(unique_ptr&& u) noexcept;488 constexpr unique_ptr& operator=(unique_ptr&& u) noexcept; // constexpr since C++23
485 unique_ptr& operator=(nullptr_t) noexcept;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
487 // observers493 // observers
488 T& operator[](size_t i) const;494 constexpr T& operator[](size_t i) const; // constexpr since C++23
489 pointer get() const noexcept;495 constexpr pointer get() const noexcept; // constexpr since C++23
490 deleter_type& get_deleter() noexcept;496 constexpr deleter_type& get_deleter() noexcept; // constexpr since C++23
491 const deleter_type& get_deleter() const noexcept;497 constexpr const deleter_type& get_deleter() const noexcept; // constexpr since C++23
492 explicit operator bool() const noexcept;498 constexpr explicit operator bool() const noexcept; // constexpr since C++23
493499
494 // modifiers500 // modifiers
495 pointer release() noexcept;501 constexpr pointer release() noexcept; // constexpr since C++23
496 void reset(pointer p = pointer()) noexcept;502 constexpr void reset(pointer p = pointer()) noexcept; // constexpr since C++23
497 void reset(nullptr_t) noexcept;503 constexpr void reset(nullptr_t) noexcept; // constexpr since C++23
498 template <class U> void reset(U) = delete;504 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
500};506};
501507
502template <class T, class D>508template <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
505template <class T1, class D1, class T2, class D2>511template <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
507template <class T1, class D1, class T2, class D2>513template <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
509template <class T1, class D1, class T2, class D2>515template <class T1, class D1, class T2, class D2>
510 bool operator<(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);516 bool operator<(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
511template <class T1, class D1, class T2, class D2>517template <class T1, class D1, class T2, class D2>
...@@ -514,32 +520,42 @@ template <class T1, class D1, class T2, class D2>...@@ -514,32 +520,42 @@ template <class T1, class D1, class T2, class D2>
514 bool operator>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);520 bool operator>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
515template <class T1, class D1, class T2, class D2>521template <class T1, class D1, class T2, class D2>
516 bool operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);522 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
518template <class T, class D>530template <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
520template <class T, class D>532template <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
522template <class T, class D>534template <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
524template <class T, class D>536template <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
527template <class T, class D>539template <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
529template <class T, class D>541template <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
531template <class T, class D>543template <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
533template <class T, class D>545template <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
535template <class T, class D>547template <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
537template <class T, class D>549template <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
539template <class T, class D>551template <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
541template <class T, class D>553template <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
544class bad_weak_ptr560class bad_weak_ptr
545 : public std::exception561 : public std::exception
...@@ -547,10 +563,19 @@ class bad_weak_ptr...@@ -547,10 +563,19 @@ class bad_weak_ptr
547 bad_weak_ptr() noexcept;563 bad_weak_ptr() noexcept;
548};564};
549565
550template<class T, class... Args> unique_ptr<T> make_unique(Args&&... args); // C++14566template<class T, class... Args>
551template<class T> unique_ptr<T> make_unique(size_t n); // C++14567constexpr 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
552template<class T, class... Args> unspecified make_unique(Args&&...) = delete; // C++14, T == U[N]570template<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
554template<class E, class T, class Y, class D>579template<class E, class T, class Y, class D>
555 basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, unique_ptr<Y, D> const& p);580 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>;...@@ -617,40 +642,44 @@ shared_ptr(unique_ptr<T, D>) -> shared_ptr<T>;
617template<class T, class U>642template<class T, class U>
618 bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;643 bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
619template<class T, class U>644template<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
621template<class T, class U>648template<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
623template<class T, class U>650template<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
625template<class T, class U>652template<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
627template<class T, class U>654template<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
630template <class T>657template <class T>
631 bool operator==(const shared_ptr<T>& x, nullptr_t) noexcept;658 bool operator==(const shared_ptr<T>& x, nullptr_t) noexcept;
632template <class T>659template <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
634template <class T>661template <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
636template <class T>663template <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
638template <class T>665template <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
640template <class T>667template <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
642template <class T>669template <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
644template <class T>671template <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
646template <class T>673template <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
648template <class T>675template <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
650template <class T>677template <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
652template <class T>679template <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
655// shared_ptr specialized algorithms:684// shared_ptr specialized algorithms:
656template<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b) noexcept;685template<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b) noexcept;
...@@ -695,6 +724,16 @@ template<class T> shared_ptr<T>...@@ -695,6 +724,16 @@ template<class T> shared_ptr<T>
695template<class T, class A>724template<class T, class A>
696 shared_ptr<T> allocate_shared(const A& a, const remove_extent_t<T>& u); // T is U[N] (since C++20)725 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
698template<class T>737template<class T>
699class weak_ptr738class weak_ptr
700{739{
...@@ -838,11 +877,10 @@ template<size_t N, class T>...@@ -838,11 +877,10 @@ template<size_t N, class T>
838877
839*/878*/
840879
841#include <__algorithm/copy.h>
842#include <__algorithm/move.h>
843#include <__assert> // all public C++ headers provide the assertion handler880#include <__assert> // all public C++ headers provide the assertion handler
844#include <__config>881#include <__config>
845#include <__memory/addressof.h>882#include <__memory/addressof.h>
883#include <__memory/align.h>
846#include <__memory/allocate_at_least.h>884#include <__memory/allocate_at_least.h>
847#include <__memory/allocation_guard.h>885#include <__memory/allocation_guard.h>
848#include <__memory/allocator.h>886#include <__memory/allocator.h>
...@@ -862,172 +900,35 @@ template<size_t N, class T>...@@ -862,172 +900,35 @@ template<size_t N, class T>
862#include <__memory/uninitialized_algorithms.h>900#include <__memory/uninitialized_algorithms.h>
863#include <__memory/unique_ptr.h>901#include <__memory/unique_ptr.h>
864#include <__memory/uses_allocator.h>902#include <__memory/uses_allocator.h>
865#include <cstddef>903#include <__memory/uses_allocator_construction.h>
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>
874#include <version>904#include <version>
875905
876#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
877# include <iterator>
878# include <utility>
879#endif
880
881// standard-mandated includes906// standard-mandated includes
907
908// [memory.syn]
882#include <compare>909#include <compare>
883910
884#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)911#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
885# pragma GCC system_header912# pragma GCC system_header
886#endif913#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
1029#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17915#if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17
1030# include <__pstl_memory>916# include <__pstl_memory>
1031#endif917#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
1033#endif // _LIBCPP_MEMORY934#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>...@@ -188,20 +188,16 @@ template<class Callable, class ...Args>
188188
189#include <__assert> // all public C++ headers provide the assertion handler189#include <__assert> // all public C++ headers provide the assertion handler
190#include <__config>190#include <__config>
191#include <__memory/shared_ptr.h>
191#include <__mutex_base>192#include <__mutex_base>
192#include <__threading_support>193#include <__threading_support>
193#include <__utility/forward.h>194#include <__utility/forward.h>
194#include <cstdint>195#include <cstdint>
195#include <memory>
196#ifndef _LIBCPP_CXX03_LANG196#ifndef _LIBCPP_CXX03_LANG
197# include <tuple>197# include <tuple>
198#endif198#endif
199#include <version>199#include <version>
200200
201#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
202# include <functional>
203#endif
204
205#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)201#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
206# pragma GCC system_header202# pragma GCC system_header
207#endif203#endif
...@@ -329,7 +325,7 @@ recursive_timed_mutex::try_lock_until(const chrono::time_point<_Clock, _Duration...@@ -329,7 +325,7 @@ recursive_timed_mutex::try_lock_until(const chrono::time_point<_Clock, _Duration
329}325}
330326
331template <class _L0, class _L1>327template <class _L0, class _L1>
332int328_LIBCPP_HIDE_FROM_ABI int
333try_lock(_L0& __l0, _L1& __l1)329try_lock(_L0& __l0, _L1& __l1)
334{330{
335 unique_lock<_L0> __u0(__l0, try_to_lock);331 unique_lock<_L0> __u0(__l0, try_to_lock);
...@@ -349,14 +345,14 @@ try_lock(_L0& __l0, _L1& __l1)...@@ -349,14 +345,14 @@ try_lock(_L0& __l0, _L1& __l1)
349#ifndef _LIBCPP_CXX03_LANG345#ifndef _LIBCPP_CXX03_LANG
350346
351template <class _L0, class _L1, class _L2, class... _L3>347template <class _L0, class _L1, class _L2, class... _L3>
352int348_LIBCPP_HIDE_FROM_ABI int
353try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3)349try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3)
354{350{
355 int __r = 0;351 int __r = 0;
356 unique_lock<_L0> __u0(__l0, try_to_lock);352 unique_lock<_L0> __u0(__l0, try_to_lock);
357 if (__u0.owns_lock())353 if (__u0.owns_lock())
358 {354 {
359 __r = try_lock(__l1, __l2, __l3...);355 __r = std::try_lock(__l1, __l2, __l3...);
360 if (__r == -1)356 if (__r == -1)
361 __u0.release();357 __u0.release();
362 else358 else
...@@ -368,7 +364,7 @@ try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3)...@@ -368,7 +364,7 @@ try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3)
368#endif // _LIBCPP_CXX03_LANG364#endif // _LIBCPP_CXX03_LANG
369365
370template <class _L0, class _L1>366template <class _L0, class _L1>
371void367_LIBCPP_HIDE_FROM_ABI void
372lock(_L0& __l0, _L1& __l1)368lock(_L0& __l0, _L1& __l1)
373{369{
374 while (true)370 while (true)
...@@ -407,7 +403,7 @@ __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)...@@ -407,7 +403,7 @@ __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
407 case 0:403 case 0:
408 {404 {
409 unique_lock<_L0> __u0(__l0);405 unique_lock<_L0> __u0(__l0);
410 __i = try_lock(__l1, __l2, __l3...);406 __i = std::try_lock(__l1, __l2, __l3...);
411 if (__i == -1)407 if (__i == -1)
412 {408 {
413 __u0.release();409 __u0.release();
...@@ -420,7 +416,7 @@ __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)...@@ -420,7 +416,7 @@ __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
420 case 1:416 case 1:
421 {417 {
422 unique_lock<_L1> __u1(__l1);418 unique_lock<_L1> __u1(__l1);
423 __i = try_lock(__l2, __l3..., __l0);419 __i = std::try_lock(__l2, __l3..., __l0);
424 if (__i == -1)420 if (__i == -1)
425 {421 {
426 __u1.release();422 __u1.release();
...@@ -434,7 +430,7 @@ __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)...@@ -434,7 +430,7 @@ __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
434 __libcpp_thread_yield();430 __libcpp_thread_yield();
435 break;431 break;
436 default:432 default:
437 __lock_first(__i - 2, __l2, __l3..., __l0, __l1);433 std::__lock_first(__i - 2, __l2, __l3..., __l0, __l1);
438 return;434 return;
439 }435 }
440 }436 }
...@@ -445,7 +441,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -445,7 +441,7 @@ inline _LIBCPP_INLINE_VISIBILITY
445void441void
446lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)442lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
447{443{
448 __lock_first(0, __l0, __l1, __l2, __l3...);444 std::__lock_first(0, __l0, __l1, __l2, __l3...);
449}445}
450446
451template <class _L0>447template <class _L0>
...@@ -546,6 +542,7 @@ private:...@@ -546,6 +542,7 @@ private:
546542
547 _MutexTuple __t_;543 _MutexTuple __t_;
548};544};
545_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(scoped_lock);
549546
550#endif // _LIBCPP_STD_VER > 14547#endif // _LIBCPP_STD_VER > 14
551#endif // !_LIBCPP_HAS_NO_THREADS548#endif // !_LIBCPP_HAS_NO_THREADS
...@@ -670,7 +667,7 @@ call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args)...@@ -670,7 +667,7 @@ call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args)
670 typedef tuple<_Callable&&, _Args&&...> _Gp;667 typedef tuple<_Callable&&, _Args&&...> _Gp;
671 _Gp __f(_VSTD::forward<_Callable>(__func), _VSTD::forward<_Args>(__args)...);668 _Gp __f(_VSTD::forward<_Callable>(__func), _VSTD::forward<_Args>(__args)...);
672 __call_once_param<_Gp> __p(__f);669 __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>);
674 }671 }
675}672}
676673
...@@ -684,7 +681,7 @@ call_once(once_flag& __flag, _Callable& __func)...@@ -684,7 +681,7 @@ call_once(once_flag& __flag, _Callable& __func)
684 if (__libcpp_acquire_load(&__flag.__state_) != ~once_flag::_State_type(0))681 if (__libcpp_acquire_load(&__flag.__state_) != ~once_flag::_State_type(0))
685 {682 {
686 __call_once_param<_Callable> __p(__func);683 __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>);
688 }685 }
689}686}
690687
...@@ -696,7 +693,7 @@ call_once(once_flag& __flag, const _Callable& __func)...@@ -696,7 +693,7 @@ call_once(once_flag& __flag, const _Callable& __func)
696 if (__libcpp_acquire_load(&__flag.__state_) != ~once_flag::_State_type(0))693 if (__libcpp_acquire_load(&__flag.__state_) != ~once_flag::_State_type(0))
697 {694 {
698 __call_once_param<const _Callable> __p(__func);695 __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>);
700 }697 }
701}698}
702699
...@@ -706,4 +703,10 @@ _LIBCPP_END_NAMESPACE_STD...@@ -706,4 +703,10 @@ _LIBCPP_END_NAMESPACE_STD
706703
707_LIBCPP_POP_MACROS704_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
709#endif // _LIBCPP_MUTEX712#endif // _LIBCPP_MUTEX
lib/libcxx/include/new+53-19
...@@ -89,10 +89,12 @@ void operator delete[](void* ptr, void*) noexcept;...@@ -89,10 +89,12 @@ void operator delete[](void* ptr, void*) noexcept;
89#include <__assert> // all public C++ headers provide the assertion handler89#include <__assert> // all public C++ headers provide the assertion handler
90#include <__availability>90#include <__availability>
91#include <__config>91#include <__config>
92#include <__type_traits/is_function.h>
93#include <__type_traits/is_same.h>
94#include <__type_traits/remove_cv.h>
92#include <cstddef>95#include <cstddef>
93#include <cstdlib>96#include <cstdlib>
94#include <exception>97#include <exception>
95#include <type_traits>
96#include <version>98#include <version>
9799
98#if defined(_LIBCPP_ABI_VCRUNTIME)100#if defined(_LIBCPP_ABI_VCRUNTIME)
...@@ -129,8 +131,8 @@ class _LIBCPP_EXCEPTION_ABI bad_alloc...@@ -129,8 +131,8 @@ class _LIBCPP_EXCEPTION_ABI bad_alloc
129{131{
130public:132public:
131 bad_alloc() _NOEXCEPT;133 bad_alloc() _NOEXCEPT;
132 virtual ~bad_alloc() _NOEXCEPT;134 ~bad_alloc() _NOEXCEPT override;
133 virtual const char* what() const _NOEXCEPT;135 const char* what() const _NOEXCEPT override;
134};136};
135137
136class _LIBCPP_EXCEPTION_ABI bad_array_new_length138class _LIBCPP_EXCEPTION_ABI bad_array_new_length
...@@ -138,15 +140,33 @@ class _LIBCPP_EXCEPTION_ABI bad_array_new_length...@@ -138,15 +140,33 @@ class _LIBCPP_EXCEPTION_ABI bad_array_new_length
138{140{
139public:141public:
140 bad_array_new_length() _NOEXCEPT;142 bad_array_new_length() _NOEXCEPT;
141 virtual ~bad_array_new_length() _NOEXCEPT;143 ~bad_array_new_length() _NOEXCEPT override;
142 virtual const char* what() const _NOEXCEPT;144 const char* what() const _NOEXCEPT override;
143};145};
144146
145typedef void (*new_handler)();147typedef void (*new_handler)();
146_LIBCPP_FUNC_VIS new_handler set_new_handler(new_handler) _NOEXCEPT;148_LIBCPP_FUNC_VIS new_handler set_new_handler(new_handler) _NOEXCEPT;
147_LIBCPP_FUNC_VIS new_handler get_new_handler() _NOEXCEPT;149_LIBCPP_FUNC_VIS new_handler get_new_handler() _NOEXCEPT;
148150
149#endif // !_LIBCPP_ABI_VCRUNTIME151#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
151_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_bad_alloc(); // not in C++ spec171_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_bad_alloc(); // not in C++ spec
152172
...@@ -277,9 +297,9 @@ _LIBCPP_INLINE_VISIBILITY...@@ -277,9 +297,9 @@ _LIBCPP_INLINE_VISIBILITY
277void __do_deallocate_handle_size(void *__ptr, size_t __size, _Args ...__args) {297void __do_deallocate_handle_size(void *__ptr, size_t __size, _Args ...__args) {
278#ifdef _LIBCPP_HAS_NO_SIZED_DEALLOCATION298#ifdef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
279 (void)__size;299 (void)__size;
280 return __libcpp_operator_delete(__ptr, __args...);300 return std::__libcpp_operator_delete(__ptr, __args...);
281#else301#else
282 return __libcpp_operator_delete(__ptr, __size, __args...);302 return std::__libcpp_operator_delete(__ptr, __size, __args...);
283#endif303#endif
284}304}
285305
...@@ -319,16 +339,26 @@ inline _LIBCPP_INLINE_VISIBILITY void __libcpp_deallocate_unsized(void* __ptr, s...@@ -319,16 +339,26 @@ inline _LIBCPP_INLINE_VISIBILITY void __libcpp_deallocate_unsized(void* __ptr, s
319// chances are that you want to use `__libcpp_allocate` instead.339// chances are that you want to use `__libcpp_allocate` instead.
320//340//
321// Returns the allocated memory, or `nullptr` on failure.341// Returns the allocated memory, or `nullptr` on failure.
322inline _LIBCPP_INLINE_VISIBILITY342inline _LIBCPP_INLINE_VISIBILITY void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) {
323void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) {343# if defined(_LIBCPP_MSVCRT_LIKE)
324#if defined(_LIBCPP_MSVCRT_LIKE)344 return ::_aligned_malloc(__size, __alignment);
325 return ::_aligned_malloc(__size, __alignment);345# elif _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_C11_ALIGNED_ALLOC)
326#else346 // aligned_alloc() requires that __size is a multiple of __alignment,
327 void* __result = nullptr;347 // but for C++ [new.delete.general], only states "if the value of an
328 (void)::posix_memalign(&__result, __alignment, __size);348 // alignment argument passed to any of these functions is not a valid
329 // If posix_memalign fails, __result is unmodified so we still return `nullptr`.349 // alignment value, the behavior is undefined".
330 return __result;350 // To handle calls such as ::operator new(1, std::align_val_t(128)), we
331#endif351 // 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
332}362}
333363
334inline _LIBCPP_INLINE_VISIBILITY364inline _LIBCPP_INLINE_VISIBILITY
...@@ -347,7 +377,7 @@ _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_HIDE_FROM_ABI...@@ -347,7 +377,7 @@ _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_HIDE_FROM_ABI
347_LIBCPP_CONSTEXPR _Tp* __launder(_Tp* __p) _NOEXCEPT377_LIBCPP_CONSTEXPR _Tp* __launder(_Tp* __p) _NOEXCEPT
348{378{
349 static_assert (!(is_function<_Tp>::value), "can't launder functions" );379 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" );
351 return __builtin_launder(__p);381 return __builtin_launder(__p);
352}382}
353383
...@@ -373,4 +403,8 @@ inline constexpr size_t hardware_constructive_interference_size = __GCC_CONSTRUC...@@ -373,4 +403,8 @@ inline constexpr size_t hardware_constructive_interference_size = __GCC_CONSTRUC
373403
374_LIBCPP_END_NAMESPACE_STD404_LIBCPP_END_NAMESPACE_STD
375405
406#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
407# include <type_traits>
408#endif
409
376#endif // _LIBCPP_NEW410#endif // _LIBCPP_NEW
lib/libcxx/include/numbers+6-2
...@@ -59,9 +59,8 @@ namespace std::numbers {...@@ -59,9 +59,8 @@ namespace std::numbers {
59*/59*/
6060
61#include <__assert> // all public C++ headers provide the assertion handler61#include <__assert> // all public C++ headers provide the assertion handler
62#include <__concepts/arithmetic.h>
62#include <__config>63#include <__config>
63#include <concepts>
64#include <type_traits>
65#include <version>64#include <version>
6665
67#if _LIBCPP_STD_VER > 1766#if _LIBCPP_STD_VER > 17
...@@ -131,4 +130,9 @@ _LIBCPP_END_NAMESPACE_STD...@@ -131,4 +130,9 @@ _LIBCPP_END_NAMESPACE_STD
131130
132#endif // _LIBCPP_STD_VER > 17131#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
134#endif // _LIBCPP_NUMBERS138#endif // _LIBCPP_NUMBERS
lib/libcxx/include/numeric+7-5
...@@ -163,11 +163,6 @@ template<class T>...@@ -163,11 +163,6 @@ template<class T>
163#include <__numeric/transform_inclusive_scan.h>163#include <__numeric/transform_inclusive_scan.h>
164#include <__numeric/transform_reduce.h>164#include <__numeric/transform_reduce.h>
165165
166#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
167# include <functional>
168# include <iterator>
169#endif
170
171#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)166#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
172# pragma GCC system_header167# pragma GCC system_header
173#endif168#endif
...@@ -176,4 +171,11 @@ template<class T>...@@ -176,4 +171,11 @@ template<class T>
176# include <__pstl_numeric>171# include <__pstl_numeric>
177#endif172#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
179#endif // _LIBCPP_NUMERIC181#endif // _LIBCPP_NUMERIC
lib/libcxx/include/optional+96-95
...@@ -87,8 +87,8 @@ namespace std {...@@ -87,8 +87,8 @@ namespace std {
87 // 23.6.3.1, constructors87 // 23.6.3.1, constructors
88 constexpr optional() noexcept;88 constexpr optional() noexcept;
89 constexpr optional(nullopt_t) noexcept;89 constexpr optional(nullopt_t) noexcept;
90 optional(const optional &);90 constexpr optional(const optional &);
91 optional(optional &&) noexcept(see below);91 constexpr optional(optional &&) noexcept(see below);
92 template <class... Args> constexpr explicit optional(in_place_t, Args &&...);92 template <class... Args> constexpr explicit optional(in_place_t, Args &&...);
93 template <class U, class... Args>93 template <class U, class... Args>
94 constexpr explicit optional(in_place_t, initializer_list<U>, Args &&...);94 constexpr explicit optional(in_place_t, initializer_list<U>, Args &&...);
...@@ -104,8 +104,8 @@ namespace std {...@@ -104,8 +104,8 @@ namespace std {
104104
105 // 23.6.3.3, assignment105 // 23.6.3.3, assignment
106 optional &operator=(nullopt_t) noexcept; // constexpr in C++20106 optional &operator=(nullopt_t) noexcept; // constexpr in C++20
107 optional &operator=(const optional &); // constexpr in C++20107 constexpr optional &operator=(const optional &);
108 optional &operator=(optional &&) noexcept(see below); // constexpr in C++20108 constexpr optional &operator=(optional &&) noexcept(see below);
109 template <class U = T> optional &operator=(U &&); // constexpr in C++20109 template <class U = T> optional &operator=(U &&); // constexpr in C++20
110 template <class U> optional &operator=(const optional<U> &); // constexpr in C++20110 template <class U> optional &operator=(const optional<U> &); // constexpr in C++20
111 template <class U> optional &operator=(optional<U> &&); // constexpr in C++20111 template <class U> optional &operator=(optional<U> &&); // constexpr in C++20
...@@ -166,7 +166,7 @@ template<class T>...@@ -166,7 +166,7 @@ template<class T>
166#include <__functional/invoke.h>166#include <__functional/invoke.h>
167#include <__functional/unary_function.h>167#include <__functional/unary_function.h>
168#include <__memory/construct_at.h>168#include <__memory/construct_at.h>
169#include <__tuple>169#include <__tuple_dir/sfinae_helpers.h>
170#include <__utility/forward.h>170#include <__utility/forward.h>
171#include <__utility/in_place.h>171#include <__utility/in_place.h>
172#include <__utility/move.h>172#include <__utility/move.h>
...@@ -177,22 +177,9 @@ template<class T>...@@ -177,22 +177,9 @@ template<class T>
177#include <type_traits>177#include <type_traits>
178#include <version>178#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
195// standard-mandated includes180// standard-mandated includes
181
182// [optional.syn]
196#include <compare>183#include <compare>
197184
198#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)185#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -207,8 +194,8 @@ class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optiona...@@ -207,8 +194,8 @@ class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optiona
207{194{
208public:195public:
209 // Get the key function ~bad_optional_access() into the dylib196 // Get the key function ~bad_optional_access() into the dylib
210 virtual ~bad_optional_access() _NOEXCEPT;197 ~bad_optional_access() _NOEXCEPT override;
211 virtual const char* what() const _NOEXCEPT;198 const char* what() const _NOEXCEPT override;
212};199};
213200
214} // namespace std201} // namespace std
...@@ -255,7 +242,7 @@ struct __optional_destruct_base<_Tp, false>...@@ -255,7 +242,7 @@ struct __optional_destruct_base<_Tp, false>
255 bool __engaged_;242 bool __engaged_;
256243
257 _LIBCPP_INLINE_VISIBILITY244 _LIBCPP_INLINE_VISIBILITY
258 _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__optional_destruct_base()245 _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__optional_destruct_base()
259 {246 {
260 if (__engaged_)247 if (__engaged_)
261 __val_.~value_type();248 __val_.~value_type();
...@@ -280,7 +267,7 @@ struct __optional_destruct_base<_Tp, false>...@@ -280,7 +267,7 @@ struct __optional_destruct_base<_Tp, false>
280#endif267#endif
281268
282 _LIBCPP_INLINE_VISIBILITY269 _LIBCPP_INLINE_VISIBILITY
283 _LIBCPP_CONSTEXPR_AFTER_CXX17 void reset() noexcept270 _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept
284 {271 {
285 if (__engaged_)272 if (__engaged_)
286 {273 {
...@@ -322,7 +309,7 @@ struct __optional_destruct_base<_Tp, true>...@@ -322,7 +309,7 @@ struct __optional_destruct_base<_Tp, true>
322#endif309#endif
323310
324 _LIBCPP_INLINE_VISIBILITY311 _LIBCPP_INLINE_VISIBILITY
325 _LIBCPP_CONSTEXPR_AFTER_CXX17 void reset() noexcept312 _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept
326 {313 {
327 if (__engaged_)314 if (__engaged_)
328 {315 {
...@@ -367,7 +354,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp>...@@ -367,7 +354,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp>
367354
368 template <class... _Args>355 template <class... _Args>
369 _LIBCPP_INLINE_VISIBILITY356 _LIBCPP_INLINE_VISIBILITY
370 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct(_Args&&... __args)357 _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct(_Args&&... __args)
371 {358 {
372 _LIBCPP_ASSERT(!has_value(), "__construct called for engaged __optional_storage");359 _LIBCPP_ASSERT(!has_value(), "__construct called for engaged __optional_storage");
373#if _LIBCPP_STD_VER > 17360#if _LIBCPP_STD_VER > 17
...@@ -380,7 +367,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp>...@@ -380,7 +367,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp>
380367
381 template <class _That>368 template <class _That>
382 _LIBCPP_INLINE_VISIBILITY369 _LIBCPP_INLINE_VISIBILITY
383 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_from(_That&& __opt)370 _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct_from(_That&& __opt)
384 {371 {
385 if (__opt.has_value())372 if (__opt.has_value())
386 __construct(_VSTD::forward<_That>(__opt).__get());373 __construct(_VSTD::forward<_That>(__opt).__get());
...@@ -388,7 +375,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp>...@@ -388,7 +375,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp>
388375
389 template <class _That>376 template <class _That>
390 _LIBCPP_INLINE_VISIBILITY377 _LIBCPP_INLINE_VISIBILITY
391 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __assign_from(_That&& __opt)378 _LIBCPP_CONSTEXPR_SINCE_CXX20 void __assign_from(_That&& __opt)
392 {379 {
393 if (this->__engaged_ == __opt.has_value())380 if (this->__engaged_ == __opt.has_value())
394 {381 {
...@@ -417,14 +404,14 @@ struct __optional_storage_base<_Tp, true>...@@ -417,14 +404,14 @@ struct __optional_storage_base<_Tp, true>
417404
418 template <class _Up>405 template <class _Up>
419 static constexpr bool __can_bind_reference() {406 static constexpr bool __can_bind_reference() {
420 using _RawUp = typename remove_reference<_Up>::type;407 using _RawUp = __libcpp_remove_reference_t<_Up>;
421 using _UpPtr = _RawUp*;408 using _UpPtr = _RawUp*;
422 using _RawTp = typename remove_reference<_Tp>::type;409 using _RawTp = __libcpp_remove_reference_t<_Tp>;
423 using _TpPtr = _RawTp*;410 using _TpPtr = _RawTp*;
424 using _CheckLValueArg = integral_constant<bool,411 using _CheckLValueArg = integral_constant<bool,
425 (is_lvalue_reference<_Up>::value && is_convertible<_UpPtr, _TpPtr>::value)412 (is_lvalue_reference<_Up>::value && is_convertible<_UpPtr, _TpPtr>::value)
426 || is_same<_RawUp, reference_wrapper<_RawTp>>::value413 || is_same<_RawUp, reference_wrapper<_RawTp>>::value
427 || is_same<_RawUp, reference_wrapper<typename remove_const<_RawTp>::type>>::value414 || is_same<_RawUp, reference_wrapper<__remove_const_t<_RawTp>>>::value
428 >;415 >;
429 return (is_lvalue_reference<_Tp>::value && _CheckLValueArg::value)416 return (is_lvalue_reference<_Tp>::value && _CheckLValueArg::value)
430 || (is_rvalue_reference<_Tp>::value && !is_lvalue_reference<_Up>::value &&417 || (is_rvalue_reference<_Tp>::value && !is_lvalue_reference<_Up>::value &&
...@@ -446,7 +433,7 @@ struct __optional_storage_base<_Tp, true>...@@ -446,7 +433,7 @@ struct __optional_storage_base<_Tp, true>
446 }433 }
447434
448 _LIBCPP_INLINE_VISIBILITY435 _LIBCPP_INLINE_VISIBILITY
449 _LIBCPP_CONSTEXPR_AFTER_CXX17 void reset() noexcept { __value_ = nullptr; }436 _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept { __value_ = nullptr; }
450437
451 _LIBCPP_INLINE_VISIBILITY438 _LIBCPP_INLINE_VISIBILITY
452 constexpr bool has_value() const noexcept439 constexpr bool has_value() const noexcept
...@@ -462,7 +449,7 @@ struct __optional_storage_base<_Tp, true>...@@ -462,7 +449,7 @@ struct __optional_storage_base<_Tp, true>
462449
463 template <class _UArg>450 template <class _UArg>
464 _LIBCPP_INLINE_VISIBILITY451 _LIBCPP_INLINE_VISIBILITY
465 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct(_UArg&& __val)452 _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct(_UArg&& __val)
466 {453 {
467 _LIBCPP_ASSERT(!has_value(), "__construct called for engaged __optional_storage");454 _LIBCPP_ASSERT(!has_value(), "__construct called for engaged __optional_storage");
468 static_assert(__can_bind_reference<_UArg>(),455 static_assert(__can_bind_reference<_UArg>(),
...@@ -473,7 +460,7 @@ struct __optional_storage_base<_Tp, true>...@@ -473,7 +460,7 @@ struct __optional_storage_base<_Tp, true>
473460
474 template <class _That>461 template <class _That>
475 _LIBCPP_INLINE_VISIBILITY462 _LIBCPP_INLINE_VISIBILITY
476 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_from(_That&& __opt)463 _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct_from(_That&& __opt)
477 {464 {
478 if (__opt.has_value())465 if (__opt.has_value())
479 __construct(_VSTD::forward<_That>(__opt).__get());466 __construct(_VSTD::forward<_That>(__opt).__get());
...@@ -481,7 +468,7 @@ struct __optional_storage_base<_Tp, true>...@@ -481,7 +468,7 @@ struct __optional_storage_base<_Tp, true>
481468
482 template <class _That>469 template <class _That>
483 _LIBCPP_INLINE_VISIBILITY470 _LIBCPP_INLINE_VISIBILITY
484 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __assign_from(_That&& __opt)471 _LIBCPP_CONSTEXPR_SINCE_CXX20 void __assign_from(_That&& __opt)
485 {472 {
486 if (has_value() == __opt.has_value())473 if (has_value() == __opt.has_value())
487 {474 {
...@@ -513,7 +500,7 @@ struct __optional_copy_base<_Tp, false> : __optional_storage_base<_Tp>...@@ -513,7 +500,7 @@ struct __optional_copy_base<_Tp, false> : __optional_storage_base<_Tp>
513 __optional_copy_base() = default;500 __optional_copy_base() = default;
514501
515 _LIBCPP_INLINE_VISIBILITY502 _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)
517 {504 {
518 this->__construct_from(__opt);505 this->__construct_from(__opt);
519 }506 }
...@@ -544,7 +531,7 @@ struct __optional_move_base<_Tp, false> : __optional_copy_base<_Tp>...@@ -544,7 +531,7 @@ struct __optional_move_base<_Tp, false> : __optional_copy_base<_Tp>
544 __optional_move_base(const __optional_move_base&) = default;531 __optional_move_base(const __optional_move_base&) = default;
545532
546 _LIBCPP_INLINE_VISIBILITY533 _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)
548 noexcept(is_nothrow_move_constructible_v<value_type>)535 noexcept(is_nothrow_move_constructible_v<value_type>)
549 {536 {
550 this->__construct_from(_VSTD::move(__opt));537 this->__construct_from(_VSTD::move(__opt));
...@@ -578,7 +565,7 @@ struct __optional_copy_assign_base<_Tp, false> : __optional_move_base<_Tp>...@@ -578,7 +565,7 @@ struct __optional_copy_assign_base<_Tp, false> : __optional_move_base<_Tp>
578 __optional_copy_assign_base(__optional_copy_assign_base&&) = default;565 __optional_copy_assign_base(__optional_copy_assign_base&&) = default;
579566
580 _LIBCPP_INLINE_VISIBILITY567 _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)
582 {569 {
583 this->__assign_from(__opt);570 this->__assign_from(__opt);
584 return *this;571 return *this;
...@@ -613,7 +600,7 @@ struct __optional_move_assign_base<_Tp, false> : __optional_copy_assign_base<_Tp...@@ -613,7 +600,7 @@ struct __optional_move_assign_base<_Tp, false> : __optional_copy_assign_base<_Tp
613 __optional_move_assign_base& operator=(const __optional_move_assign_base&) = default;600 __optional_move_assign_base& operator=(const __optional_move_assign_base&) = default;
614601
615 _LIBCPP_INLINE_VISIBILITY602 _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)
617 noexcept(is_nothrow_move_assignable_v<value_type> &&604 noexcept(is_nothrow_move_assignable_v<value_type> &&
618 is_nothrow_move_constructible_v<value_type>)605 is_nothrow_move_constructible_v<value_type>)
619 {606 {
...@@ -652,9 +639,9 @@ public:...@@ -652,9 +639,9 @@ public:
652639
653private:640private:
654 // Disable the reference extension using this static assert.641 // 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>,
656 "instantiation of optional with in_place_t is ill-formed");643 "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>,
658 "instantiation of optional with nullopt_t is ill-formed");645 "instantiation of optional with nullopt_t is ill-formed");
659 static_assert(!is_reference_v<value_type>,646 static_assert(!is_reference_v<value_type>,
660 "instantiation of optional with a reference type is ill-formed");647 "instantiation of optional with a reference type is ill-formed");
...@@ -679,8 +666,8 @@ private:...@@ -679,8 +666,8 @@ private:
679 };666 };
680 template <class _Up>667 template <class _Up>
681 using _CheckOptionalArgsCtor = _If<668 using _CheckOptionalArgsCtor = _If<
682 _IsNotSame<__uncvref_t<_Up>, in_place_t>::value &&669 _IsNotSame<__remove_cvref_t<_Up>, in_place_t>::value &&
683 _IsNotSame<__uncvref_t<_Up>, optional>::value,670 _IsNotSame<__remove_cvref_t<_Up>, optional>::value,
684 _CheckOptionalArgsConstructor,671 _CheckOptionalArgsConstructor,
685 __check_tuple_constructor_fail672 __check_tuple_constructor_fail
686 >;673 >;
...@@ -787,7 +774,7 @@ public:...@@ -787,7 +774,7 @@ public:
787 _CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>()774 _CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>()
788 , int> = 0>775 , int> = 0>
789 _LIBCPP_INLINE_VISIBILITY776 _LIBCPP_INLINE_VISIBILITY
790 _LIBCPP_CONSTEXPR_AFTER_CXX17 optional(const optional<_Up>& __v)777 _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(const optional<_Up>& __v)
791 {778 {
792 this->__construct_from(__v);779 this->__construct_from(__v);
793 }780 }
...@@ -795,7 +782,7 @@ public:...@@ -795,7 +782,7 @@ public:
795 _CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>()782 _CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>()
796 , int> = 0>783 , int> = 0>
797 _LIBCPP_INLINE_VISIBILITY784 _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)
799 {786 {
800 this->__construct_from(__v);787 this->__construct_from(__v);
801 }788 }
...@@ -805,7 +792,7 @@ public:...@@ -805,7 +792,7 @@ public:
805 _CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_implicit<_Up>()792 _CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_implicit<_Up>()
806 , int> = 0>793 , int> = 0>
807 _LIBCPP_INLINE_VISIBILITY794 _LIBCPP_INLINE_VISIBILITY
808 _LIBCPP_CONSTEXPR_AFTER_CXX17 optional(optional<_Up>&& __v)795 _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(optional<_Up>&& __v)
809 {796 {
810 this->__construct_from(_VSTD::move(__v));797 this->__construct_from(_VSTD::move(__v));
811 }798 }
...@@ -813,7 +800,7 @@ public:...@@ -813,7 +800,7 @@ public:
813 _CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_explicit<_Up>()800 _CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_explicit<_Up>()
814 , int> = 0>801 , int> = 0>
815 _LIBCPP_INLINE_VISIBILITY802 _LIBCPP_INLINE_VISIBILITY
816 _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit optional(optional<_Up>&& __v)803 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(optional<_Up>&& __v)
817 {804 {
818 this->__construct_from(_VSTD::move(__v));805 this->__construct_from(_VSTD::move(__v));
819 }806 }
...@@ -827,22 +814,22 @@ public:...@@ -827,22 +814,22 @@ public:
827#endif814#endif
828815
829 _LIBCPP_INLINE_VISIBILITY816 _LIBCPP_INLINE_VISIBILITY
830 _LIBCPP_CONSTEXPR_AFTER_CXX17 optional& operator=(nullopt_t) noexcept817 _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(nullopt_t) noexcept
831 {818 {
832 reset();819 reset();
833 return *this;820 return *this;
834 }821 }
835822
836 _LIBCPP_INLINE_VISIBILITY optional& operator=(const optional&) = default;823 constexpr optional& operator=(const optional&) = default;
837 _LIBCPP_INLINE_VISIBILITY optional& operator=(optional&&) = default;824 constexpr optional& operator=(optional&&) = default;
838825
839 // LWG2756826 // LWG2756
840 template <class _Up = value_type,827 template <class _Up = value_type,
841 class = enable_if_t<828 class = enable_if_t<
842 _And<829 _And<
843 _IsNotSame<__uncvref_t<_Up>, optional>,830 _IsNotSame<__remove_cvref_t<_Up>, optional>,
844 _Or<831 _Or<
845 _IsNotSame<__uncvref_t<_Up>, value_type>,832 _IsNotSame<__remove_cvref_t<_Up>, value_type>,
846 _Not<is_scalar<value_type>>833 _Not<is_scalar<value_type>>
847 >,834 >,
848 is_constructible<value_type, _Up>,835 is_constructible<value_type, _Up>,
...@@ -850,7 +837,7 @@ public:...@@ -850,7 +837,7 @@ public:
850 >::value>837 >::value>
851 >838 >
852 _LIBCPP_INLINE_VISIBILITY839 _LIBCPP_INLINE_VISIBILITY
853 _LIBCPP_CONSTEXPR_AFTER_CXX17 optional&840 _LIBCPP_CONSTEXPR_SINCE_CXX20 optional&
854 operator=(_Up&& __v)841 operator=(_Up&& __v)
855 {842 {
856 if (this->has_value())843 if (this->has_value())
...@@ -865,7 +852,7 @@ public:...@@ -865,7 +852,7 @@ public:
865 _CheckOptionalLikeAssign<_Up, _Up const&>::template __enable_assign<_Up>()852 _CheckOptionalLikeAssign<_Up, _Up const&>::template __enable_assign<_Up>()
866 , int> = 0>853 , int> = 0>
867 _LIBCPP_INLINE_VISIBILITY854 _LIBCPP_INLINE_VISIBILITY
868 _LIBCPP_CONSTEXPR_AFTER_CXX17 optional&855 _LIBCPP_CONSTEXPR_SINCE_CXX20 optional&
869 operator=(const optional<_Up>& __v)856 operator=(const optional<_Up>& __v)
870 {857 {
871 this->__assign_from(__v);858 this->__assign_from(__v);
...@@ -877,7 +864,7 @@ public:...@@ -877,7 +864,7 @@ public:
877 _CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_assign<_Up>()864 _CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_assign<_Up>()
878 , int> = 0>865 , int> = 0>
879 _LIBCPP_INLINE_VISIBILITY866 _LIBCPP_INLINE_VISIBILITY
880 _LIBCPP_CONSTEXPR_AFTER_CXX17 optional&867 _LIBCPP_CONSTEXPR_SINCE_CXX20 optional&
881 operator=(optional<_Up>&& __v)868 operator=(optional<_Up>&& __v)
882 {869 {
883 this->__assign_from(_VSTD::move(__v));870 this->__assign_from(_VSTD::move(__v));
...@@ -891,7 +878,7 @@ public:...@@ -891,7 +878,7 @@ public:
891 >878 >
892 >879 >
893 _LIBCPP_INLINE_VISIBILITY880 _LIBCPP_INLINE_VISIBILITY
894 _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp &881 _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp &
895 emplace(_Args&&... __args)882 emplace(_Args&&... __args)
896 {883 {
897 reset();884 reset();
...@@ -906,7 +893,7 @@ public:...@@ -906,7 +893,7 @@ public:
906 >893 >
907 >894 >
908 _LIBCPP_INLINE_VISIBILITY895 _LIBCPP_INLINE_VISIBILITY
909 _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp &896 _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp &
910 emplace(initializer_list<_Up> __il, _Args&&... __args)897 emplace(initializer_list<_Up> __il, _Args&&... __args)
911 {898 {
912 reset();899 reset();
...@@ -915,7 +902,7 @@ public:...@@ -915,7 +902,7 @@ public:
915 }902 }
916903
917 _LIBCPP_INLINE_VISIBILITY904 _LIBCPP_INLINE_VISIBILITY
918 _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(optional& __opt)905 _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(optional& __opt)
919 noexcept(is_nothrow_move_constructible_v<value_type> &&906 noexcept(is_nothrow_move_constructible_v<value_type> &&
920 is_nothrow_swappable_v<value_type>)907 is_nothrow_swappable_v<value_type>)
921 {908 {
...@@ -1198,8 +1185,8 @@ template<class _Tp>...@@ -1198,8 +1185,8 @@ template<class _Tp>
1198template <class _Tp, class _Up>1185template <class _Tp, class _Up>
1199_LIBCPP_INLINE_VISIBILITY constexpr1186_LIBCPP_INLINE_VISIBILITY constexpr
1200enable_if_t<1187enable_if_t<
1201 is_convertible_v<decltype(declval<const _Tp&>() ==1188 is_convertible_v<decltype(std::declval<const _Tp&>() ==
1202 declval<const _Up&>()), bool>,1189 std::declval<const _Up&>()), bool>,
1203 bool1190 bool
1204>1191>
1205operator==(const optional<_Tp>& __x, const optional<_Up>& __y)1192operator==(const optional<_Tp>& __x, const optional<_Up>& __y)
...@@ -1214,8 +1201,8 @@ operator==(const optional<_Tp>& __x, const optional<_Up>& __y)...@@ -1214,8 +1201,8 @@ operator==(const optional<_Tp>& __x, const optional<_Up>& __y)
1214template <class _Tp, class _Up>1201template <class _Tp, class _Up>
1215_LIBCPP_INLINE_VISIBILITY constexpr1202_LIBCPP_INLINE_VISIBILITY constexpr
1216enable_if_t<1203enable_if_t<
1217 is_convertible_v<decltype(declval<const _Tp&>() !=1204 is_convertible_v<decltype(std::declval<const _Tp&>() !=
1218 declval<const _Up&>()), bool>,1205 std::declval<const _Up&>()), bool>,
1219 bool1206 bool
1220>1207>
1221operator!=(const optional<_Tp>& __x, const optional<_Up>& __y)1208operator!=(const optional<_Tp>& __x, const optional<_Up>& __y)
...@@ -1230,8 +1217,8 @@ operator!=(const optional<_Tp>& __x, const optional<_Up>& __y)...@@ -1230,8 +1217,8 @@ operator!=(const optional<_Tp>& __x, const optional<_Up>& __y)
1230template <class _Tp, class _Up>1217template <class _Tp, class _Up>
1231_LIBCPP_INLINE_VISIBILITY constexpr1218_LIBCPP_INLINE_VISIBILITY constexpr
1232enable_if_t<1219enable_if_t<
1233 is_convertible_v<decltype(declval<const _Tp&>() <1220 is_convertible_v<decltype(std::declval<const _Tp&>() <
1234 declval<const _Up&>()), bool>,1221 std::declval<const _Up&>()), bool>,
1235 bool1222 bool
1236>1223>
1237operator<(const optional<_Tp>& __x, const optional<_Up>& __y)1224operator<(const optional<_Tp>& __x, const optional<_Up>& __y)
...@@ -1246,8 +1233,8 @@ operator<(const optional<_Tp>& __x, const optional<_Up>& __y)...@@ -1246,8 +1233,8 @@ operator<(const optional<_Tp>& __x, const optional<_Up>& __y)
1246template <class _Tp, class _Up>1233template <class _Tp, class _Up>
1247_LIBCPP_INLINE_VISIBILITY constexpr1234_LIBCPP_INLINE_VISIBILITY constexpr
1248enable_if_t<1235enable_if_t<
1249 is_convertible_v<decltype(declval<const _Tp&>() >1236 is_convertible_v<decltype(std::declval<const _Tp&>() >
1250 declval<const _Up&>()), bool>,1237 std::declval<const _Up&>()), bool>,
1251 bool1238 bool
1252>1239>
1253operator>(const optional<_Tp>& __x, const optional<_Up>& __y)1240operator>(const optional<_Tp>& __x, const optional<_Up>& __y)
...@@ -1262,8 +1249,8 @@ operator>(const optional<_Tp>& __x, const optional<_Up>& __y)...@@ -1262,8 +1249,8 @@ operator>(const optional<_Tp>& __x, const optional<_Up>& __y)
1262template <class _Tp, class _Up>1249template <class _Tp, class _Up>
1263_LIBCPP_INLINE_VISIBILITY constexpr1250_LIBCPP_INLINE_VISIBILITY constexpr
1264enable_if_t<1251enable_if_t<
1265 is_convertible_v<decltype(declval<const _Tp&>() <=1252 is_convertible_v<decltype(std::declval<const _Tp&>() <=
1266 declval<const _Up&>()), bool>,1253 std::declval<const _Up&>()), bool>,
1267 bool1254 bool
1268>1255>
1269operator<=(const optional<_Tp>& __x, const optional<_Up>& __y)1256operator<=(const optional<_Tp>& __x, const optional<_Up>& __y)
...@@ -1278,8 +1265,8 @@ operator<=(const optional<_Tp>& __x, const optional<_Up>& __y)...@@ -1278,8 +1265,8 @@ operator<=(const optional<_Tp>& __x, const optional<_Up>& __y)
1278template <class _Tp, class _Up>1265template <class _Tp, class _Up>
1279_LIBCPP_INLINE_VISIBILITY constexpr1266_LIBCPP_INLINE_VISIBILITY constexpr
1280enable_if_t<1267enable_if_t<
1281 is_convertible_v<decltype(declval<const _Tp&>() >=1268 is_convertible_v<decltype(std::declval<const _Tp&>() >=
1282 declval<const _Up&>()), bool>,1269 std::declval<const _Up&>()), bool>,
1283 bool1270 bool
1284>1271>
1285operator>=(const optional<_Tp>& __x, const optional<_Up>& __y)1272operator>=(const optional<_Tp>& __x, const optional<_Up>& __y)
...@@ -1392,8 +1379,8 @@ operator>=(nullopt_t, const optional<_Tp>& __x) noexcept...@@ -1392,8 +1379,8 @@ operator>=(nullopt_t, const optional<_Tp>& __x) noexcept
1392template <class _Tp, class _Up>1379template <class _Tp, class _Up>
1393_LIBCPP_INLINE_VISIBILITY constexpr1380_LIBCPP_INLINE_VISIBILITY constexpr
1394enable_if_t<1381enable_if_t<
1395 is_convertible_v<decltype(declval<const _Tp&>() ==1382 is_convertible_v<decltype(std::declval<const _Tp&>() ==
1396 declval<const _Up&>()), bool>,1383 std::declval<const _Up&>()), bool>,
1397 bool1384 bool
1398>1385>
1399operator==(const optional<_Tp>& __x, const _Up& __v)1386operator==(const optional<_Tp>& __x, const _Up& __v)
...@@ -1404,8 +1391,8 @@ operator==(const optional<_Tp>& __x, const _Up& __v)...@@ -1404,8 +1391,8 @@ operator==(const optional<_Tp>& __x, const _Up& __v)
1404template <class _Tp, class _Up>1391template <class _Tp, class _Up>
1405_LIBCPP_INLINE_VISIBILITY constexpr1392_LIBCPP_INLINE_VISIBILITY constexpr
1406enable_if_t<1393enable_if_t<
1407 is_convertible_v<decltype(declval<const _Tp&>() ==1394 is_convertible_v<decltype(std::declval<const _Tp&>() ==
1408 declval<const _Up&>()), bool>,1395 std::declval<const _Up&>()), bool>,
1409 bool1396 bool
1410>1397>
1411operator==(const _Tp& __v, const optional<_Up>& __x)1398operator==(const _Tp& __v, const optional<_Up>& __x)
...@@ -1416,8 +1403,8 @@ operator==(const _Tp& __v, const optional<_Up>& __x)...@@ -1416,8 +1403,8 @@ operator==(const _Tp& __v, const optional<_Up>& __x)
1416template <class _Tp, class _Up>1403template <class _Tp, class _Up>
1417_LIBCPP_INLINE_VISIBILITY constexpr1404_LIBCPP_INLINE_VISIBILITY constexpr
1418enable_if_t<1405enable_if_t<
1419 is_convertible_v<decltype(declval<const _Tp&>() !=1406 is_convertible_v<decltype(std::declval<const _Tp&>() !=
1420 declval<const _Up&>()), bool>,1407 std::declval<const _Up&>()), bool>,
1421 bool1408 bool
1422>1409>
1423operator!=(const optional<_Tp>& __x, const _Up& __v)1410operator!=(const optional<_Tp>& __x, const _Up& __v)
...@@ -1428,8 +1415,8 @@ operator!=(const optional<_Tp>& __x, const _Up& __v)...@@ -1428,8 +1415,8 @@ operator!=(const optional<_Tp>& __x, const _Up& __v)
1428template <class _Tp, class _Up>1415template <class _Tp, class _Up>
1429_LIBCPP_INLINE_VISIBILITY constexpr1416_LIBCPP_INLINE_VISIBILITY constexpr
1430enable_if_t<1417enable_if_t<
1431 is_convertible_v<decltype(declval<const _Tp&>() !=1418 is_convertible_v<decltype(std::declval<const _Tp&>() !=
1432 declval<const _Up&>()), bool>,1419 std::declval<const _Up&>()), bool>,
1433 bool1420 bool
1434>1421>
1435operator!=(const _Tp& __v, const optional<_Up>& __x)1422operator!=(const _Tp& __v, const optional<_Up>& __x)
...@@ -1440,8 +1427,8 @@ operator!=(const _Tp& __v, const optional<_Up>& __x)...@@ -1440,8 +1427,8 @@ operator!=(const _Tp& __v, const optional<_Up>& __x)
1440template <class _Tp, class _Up>1427template <class _Tp, class _Up>
1441_LIBCPP_INLINE_VISIBILITY constexpr1428_LIBCPP_INLINE_VISIBILITY constexpr
1442enable_if_t<1429enable_if_t<
1443 is_convertible_v<decltype(declval<const _Tp&>() <1430 is_convertible_v<decltype(std::declval<const _Tp&>() <
1444 declval<const _Up&>()), bool>,1431 std::declval<const _Up&>()), bool>,
1445 bool1432 bool
1446>1433>
1447operator<(const optional<_Tp>& __x, const _Up& __v)1434operator<(const optional<_Tp>& __x, const _Up& __v)
...@@ -1452,8 +1439,8 @@ operator<(const optional<_Tp>& __x, const _Up& __v)...@@ -1452,8 +1439,8 @@ operator<(const optional<_Tp>& __x, const _Up& __v)
1452template <class _Tp, class _Up>1439template <class _Tp, class _Up>
1453_LIBCPP_INLINE_VISIBILITY constexpr1440_LIBCPP_INLINE_VISIBILITY constexpr
1454enable_if_t<1441enable_if_t<
1455 is_convertible_v<decltype(declval<const _Tp&>() <1442 is_convertible_v<decltype(std::declval<const _Tp&>() <
1456 declval<const _Up&>()), bool>,1443 std::declval<const _Up&>()), bool>,
1457 bool1444 bool
1458>1445>
1459operator<(const _Tp& __v, const optional<_Up>& __x)1446operator<(const _Tp& __v, const optional<_Up>& __x)
...@@ -1464,8 +1451,8 @@ operator<(const _Tp& __v, const optional<_Up>& __x)...@@ -1464,8 +1451,8 @@ operator<(const _Tp& __v, const optional<_Up>& __x)
1464template <class _Tp, class _Up>1451template <class _Tp, class _Up>
1465_LIBCPP_INLINE_VISIBILITY constexpr1452_LIBCPP_INLINE_VISIBILITY constexpr
1466enable_if_t<1453enable_if_t<
1467 is_convertible_v<decltype(declval<const _Tp&>() <=1454 is_convertible_v<decltype(std::declval<const _Tp&>() <=
1468 declval<const _Up&>()), bool>,1455 std::declval<const _Up&>()), bool>,
1469 bool1456 bool
1470>1457>
1471operator<=(const optional<_Tp>& __x, const _Up& __v)1458operator<=(const optional<_Tp>& __x, const _Up& __v)
...@@ -1476,8 +1463,8 @@ operator<=(const optional<_Tp>& __x, const _Up& __v)...@@ -1476,8 +1463,8 @@ operator<=(const optional<_Tp>& __x, const _Up& __v)
1476template <class _Tp, class _Up>1463template <class _Tp, class _Up>
1477_LIBCPP_INLINE_VISIBILITY constexpr1464_LIBCPP_INLINE_VISIBILITY constexpr
1478enable_if_t<1465enable_if_t<
1479 is_convertible_v<decltype(declval<const _Tp&>() <=1466 is_convertible_v<decltype(std::declval<const _Tp&>() <=
1480 declval<const _Up&>()), bool>,1467 std::declval<const _Up&>()), bool>,
1481 bool1468 bool
1482>1469>
1483operator<=(const _Tp& __v, const optional<_Up>& __x)1470operator<=(const _Tp& __v, const optional<_Up>& __x)
...@@ -1488,8 +1475,8 @@ operator<=(const _Tp& __v, const optional<_Up>& __x)...@@ -1488,8 +1475,8 @@ operator<=(const _Tp& __v, const optional<_Up>& __x)
1488template <class _Tp, class _Up>1475template <class _Tp, class _Up>
1489_LIBCPP_INLINE_VISIBILITY constexpr1476_LIBCPP_INLINE_VISIBILITY constexpr
1490enable_if_t<1477enable_if_t<
1491 is_convertible_v<decltype(declval<const _Tp&>() >1478 is_convertible_v<decltype(std::declval<const _Tp&>() >
1492 declval<const _Up&>()), bool>,1479 std::declval<const _Up&>()), bool>,
1493 bool1480 bool
1494>1481>
1495operator>(const optional<_Tp>& __x, const _Up& __v)1482operator>(const optional<_Tp>& __x, const _Up& __v)
...@@ -1500,8 +1487,8 @@ operator>(const optional<_Tp>& __x, const _Up& __v)...@@ -1500,8 +1487,8 @@ operator>(const optional<_Tp>& __x, const _Up& __v)
1500template <class _Tp, class _Up>1487template <class _Tp, class _Up>
1501_LIBCPP_INLINE_VISIBILITY constexpr1488_LIBCPP_INLINE_VISIBILITY constexpr
1502enable_if_t<1489enable_if_t<
1503 is_convertible_v<decltype(declval<const _Tp&>() >1490 is_convertible_v<decltype(std::declval<const _Tp&>() >
1504 declval<const _Up&>()), bool>,1491 std::declval<const _Up&>()), bool>,
1505 bool1492 bool
1506>1493>
1507operator>(const _Tp& __v, const optional<_Up>& __x)1494operator>(const _Tp& __v, const optional<_Up>& __x)
...@@ -1512,8 +1499,8 @@ operator>(const _Tp& __v, const optional<_Up>& __x)...@@ -1512,8 +1499,8 @@ operator>(const _Tp& __v, const optional<_Up>& __x)
1512template <class _Tp, class _Up>1499template <class _Tp, class _Up>
1513_LIBCPP_INLINE_VISIBILITY constexpr1500_LIBCPP_INLINE_VISIBILITY constexpr
1514enable_if_t<1501enable_if_t<
1515 is_convertible_v<decltype(declval<const _Tp&>() >=1502 is_convertible_v<decltype(std::declval<const _Tp&>() >=
1516 declval<const _Up&>()), bool>,1503 std::declval<const _Up&>()), bool>,
1517 bool1504 bool
1518>1505>
1519operator>=(const optional<_Tp>& __x, const _Up& __v)1506operator>=(const optional<_Tp>& __x, const _Up& __v)
...@@ -1524,8 +1511,8 @@ operator>=(const optional<_Tp>& __x, const _Up& __v)...@@ -1524,8 +1511,8 @@ operator>=(const optional<_Tp>& __x, const _Up& __v)
1524template <class _Tp, class _Up>1511template <class _Tp, class _Up>
1525_LIBCPP_INLINE_VISIBILITY constexpr1512_LIBCPP_INLINE_VISIBILITY constexpr
1526enable_if_t<1513enable_if_t<
1527 is_convertible_v<decltype(declval<const _Tp&>() >=1514 is_convertible_v<decltype(std::declval<const _Tp&>() >=
1528 declval<const _Up&>()), bool>,1515 std::declval<const _Up&>()), bool>,
1529 bool1516 bool
1530>1517>
1531operator>=(const _Tp& __v, const optional<_Up>& __x)1518operator>=(const _Tp& __v, const optional<_Up>& __x)
...@@ -1535,7 +1522,7 @@ operator>=(const _Tp& __v, const optional<_Up>& __x)...@@ -1535,7 +1522,7 @@ operator>=(const _Tp& __v, const optional<_Up>& __x)
15351522
15361523
1537template <class _Tp>1524template <class _Tp>
1538inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171525inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1539enable_if_t<1526enable_if_t<
1540 is_move_constructible_v<_Tp> && is_swappable_v<_Tp>,1527 is_move_constructible_v<_Tp> && is_swappable_v<_Tp>,
1541 void1528 void
...@@ -1587,4 +1574,18 @@ _LIBCPP_END_NAMESPACE_STD...@@ -1587,4 +1574,18 @@ _LIBCPP_END_NAMESPACE_STD
15871574
1588#endif // _LIBCPP_STD_VER > 141575#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
1590#endif // _LIBCPP_OPTIONAL1591#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...@@ -165,16 +165,15 @@ basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, cons
165165
166#include <__assert> // all public C++ headers provide the assertion handler166#include <__assert> // all public C++ headers provide the assertion handler
167#include <__config>167#include <__config>
168#include <__memory/shared_ptr.h>
169#include <__memory/unique_ptr.h>
168#include <bitset>170#include <bitset>
169#include <ios>171#include <ios>
170#include <locale>172#include <locale>
173#include <new>
171#include <streambuf>174#include <streambuf>
172#include <version>175#include <version>
173176
174#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
175# include <iterator>
176#endif
177
178#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)177#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
179# pragma GCC system_header178# pragma GCC system_header
180#endif179#endif
...@@ -197,7 +196,7 @@ public:...@@ -197,7 +196,7 @@ public:
197 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1196 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
198 explicit basic_ostream(basic_streambuf<char_type, traits_type>* __sb)197 explicit basic_ostream(basic_streambuf<char_type, traits_type>* __sb)
199 { this->init(__sb); }198 { this->init(__sb); }
200 virtual ~basic_ostream();199 ~basic_ostream() override;
201protected:200protected:
202 inline _LIBCPP_INLINE_VISIBILITY201 inline _LIBCPP_INLINE_VISIBILITY
203 basic_ostream(basic_ostream&& __rhs);202 basic_ostream(basic_ostream&& __rhs);
...@@ -413,7 +412,7 @@ basic_ostream<_CharT, _Traits>::operator<<(bool __n)...@@ -413,7 +412,7 @@ basic_ostream<_CharT, _Traits>::operator<<(bool __n)
413 if (__s)412 if (__s)
414 {413 {
415 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;414 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());
417 if (__f.put(*this, *this, this->fill(), __n).failed())416 if (__f.put(*this, *this, this->fill(), __n).failed())
418 this->setstate(ios_base::badbit | ios_base::failbit);417 this->setstate(ios_base::badbit | ios_base::failbit);
419 }418 }
...@@ -440,7 +439,7 @@ basic_ostream<_CharT, _Traits>::operator<<(short __n)...@@ -440,7 +439,7 @@ basic_ostream<_CharT, _Traits>::operator<<(short __n)
440 {439 {
441 ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;440 ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
442 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;441 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());
444 if (__f.put(*this, *this, this->fill(),443 if (__f.put(*this, *this, this->fill(),
445 __flags == ios_base::oct || __flags == ios_base::hex ?444 __flags == ios_base::oct || __flags == ios_base::hex ?
446 static_cast<long>(static_cast<unsigned short>(__n)) :445 static_cast<long>(static_cast<unsigned short>(__n)) :
...@@ -469,7 +468,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned short __n)...@@ -469,7 +468,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned short __n)
469 if (__s)468 if (__s)
470 {469 {
471 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;470 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());
473 if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())472 if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())
474 this->setstate(ios_base::badbit | ios_base::failbit);473 this->setstate(ios_base::badbit | ios_base::failbit);
475 }474 }
...@@ -496,7 +495,7 @@ basic_ostream<_CharT, _Traits>::operator<<(int __n)...@@ -496,7 +495,7 @@ basic_ostream<_CharT, _Traits>::operator<<(int __n)
496 {495 {
497 ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;496 ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
498 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;497 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());
500 if (__f.put(*this, *this, this->fill(),499 if (__f.put(*this, *this, this->fill(),
501 __flags == ios_base::oct || __flags == ios_base::hex ?500 __flags == ios_base::oct || __flags == ios_base::hex ?
502 static_cast<long>(static_cast<unsigned int>(__n)) :501 static_cast<long>(static_cast<unsigned int>(__n)) :
...@@ -525,7 +524,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned int __n)...@@ -525,7 +524,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned int __n)
525 if (__s)524 if (__s)
526 {525 {
527 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;526 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());
529 if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())528 if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())
530 this->setstate(ios_base::badbit | ios_base::failbit);529 this->setstate(ios_base::badbit | ios_base::failbit);
531 }530 }
...@@ -551,7 +550,7 @@ basic_ostream<_CharT, _Traits>::operator<<(long __n)...@@ -551,7 +550,7 @@ basic_ostream<_CharT, _Traits>::operator<<(long __n)
551 if (__s)550 if (__s)
552 {551 {
553 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;552 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());
555 if (__f.put(*this, *this, this->fill(), __n).failed())554 if (__f.put(*this, *this, this->fill(), __n).failed())
556 this->setstate(ios_base::badbit | ios_base::failbit);555 this->setstate(ios_base::badbit | ios_base::failbit);
557 }556 }
...@@ -577,7 +576,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n)...@@ -577,7 +576,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n)
577 if (__s)576 if (__s)
578 {577 {
579 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;578 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());
581 if (__f.put(*this, *this, this->fill(), __n).failed())580 if (__f.put(*this, *this, this->fill(), __n).failed())
582 this->setstate(ios_base::badbit | ios_base::failbit);581 this->setstate(ios_base::badbit | ios_base::failbit);
583 }582 }
...@@ -603,7 +602,7 @@ basic_ostream<_CharT, _Traits>::operator<<(long long __n)...@@ -603,7 +602,7 @@ basic_ostream<_CharT, _Traits>::operator<<(long long __n)
603 if (__s)602 if (__s)
604 {603 {
605 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;604 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());
607 if (__f.put(*this, *this, this->fill(), __n).failed())606 if (__f.put(*this, *this, this->fill(), __n).failed())
608 this->setstate(ios_base::badbit | ios_base::failbit);607 this->setstate(ios_base::badbit | ios_base::failbit);
609 }608 }
...@@ -629,7 +628,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n)...@@ -629,7 +628,7 @@ basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n)
629 if (__s)628 if (__s)
630 {629 {
631 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;630 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());
633 if (__f.put(*this, *this, this->fill(), __n).failed())632 if (__f.put(*this, *this, this->fill(), __n).failed())
634 this->setstate(ios_base::badbit | ios_base::failbit);633 this->setstate(ios_base::badbit | ios_base::failbit);
635 }634 }
...@@ -655,7 +654,7 @@ basic_ostream<_CharT, _Traits>::operator<<(float __n)...@@ -655,7 +654,7 @@ basic_ostream<_CharT, _Traits>::operator<<(float __n)
655 if (__s)654 if (__s)
656 {655 {
657 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;656 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());
659 if (__f.put(*this, *this, this->fill(), static_cast<double>(__n)).failed())658 if (__f.put(*this, *this, this->fill(), static_cast<double>(__n)).failed())
660 this->setstate(ios_base::badbit | ios_base::failbit);659 this->setstate(ios_base::badbit | ios_base::failbit);
661 }660 }
...@@ -681,7 +680,7 @@ basic_ostream<_CharT, _Traits>::operator<<(double __n)...@@ -681,7 +680,7 @@ basic_ostream<_CharT, _Traits>::operator<<(double __n)
681 if (__s)680 if (__s)
682 {681 {
683 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;682 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());
685 if (__f.put(*this, *this, this->fill(), __n).failed())684 if (__f.put(*this, *this, this->fill(), __n).failed())
686 this->setstate(ios_base::badbit | ios_base::failbit);685 this->setstate(ios_base::badbit | ios_base::failbit);
687 }686 }
...@@ -707,7 +706,7 @@ basic_ostream<_CharT, _Traits>::operator<<(long double __n)...@@ -707,7 +706,7 @@ basic_ostream<_CharT, _Traits>::operator<<(long double __n)
707 if (__s)706 if (__s)
708 {707 {
709 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;708 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());
711 if (__f.put(*this, *this, this->fill(), __n).failed())710 if (__f.put(*this, *this, this->fill(), __n).failed())
712 this->setstate(ios_base::badbit | ios_base::failbit);711 this->setstate(ios_base::badbit | ios_base::failbit);
713 }712 }
...@@ -733,7 +732,7 @@ basic_ostream<_CharT, _Traits>::operator<<(const void* __n)...@@ -733,7 +732,7 @@ basic_ostream<_CharT, _Traits>::operator<<(const void* __n)
733 if (__s)732 if (__s)
734 {733 {
735 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;734 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());
737 if (__f.put(*this, *this, this->fill(), __n).failed())736 if (__f.put(*this, *this, this->fill(), __n).failed())
738 this->setstate(ios_base::badbit | ios_base::failbit);737 this->setstate(ios_base::badbit | ios_base::failbit);
739 }738 }
...@@ -748,7 +747,7 @@ basic_ostream<_CharT, _Traits>::operator<<(const void* __n)...@@ -748,7 +747,7 @@ basic_ostream<_CharT, _Traits>::operator<<(const void* __n)
748}747}
749748
750template<class _CharT, class _Traits>749template<class _CharT, class _Traits>
751basic_ostream<_CharT, _Traits>&750_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
752__put_character_sequence(basic_ostream<_CharT, _Traits>& __os,751__put_character_sequence(basic_ostream<_CharT, _Traits>& __os,
753 const _CharT* __str, size_t __len)752 const _CharT* __str, size_t __len)
754{753{
...@@ -760,14 +759,14 @@ __put_character_sequence(basic_ostream<_CharT, _Traits>& __os,...@@ -760,14 +759,14 @@ __put_character_sequence(basic_ostream<_CharT, _Traits>& __os,
760 if (__s)759 if (__s)
761 {760 {
762 typedef ostreambuf_iterator<_CharT, _Traits> _Ip;761 typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
763 if (__pad_and_output(_Ip(__os),762 if (std::__pad_and_output(_Ip(__os),
764 __str,763 __str,
765 (__os.flags() & ios_base::adjustfield) == ios_base::left ?764 (__os.flags() & ios_base::adjustfield) == ios_base::left ?
766 __str + __len :765 __str + __len :
767 __str,766 __str,
768 __str + __len,767 __str + __len,
769 __os,768 __os,
770 __os.fill()).failed())769 __os.fill()).failed())
771 __os.setstate(ios_base::badbit | ios_base::failbit);770 __os.setstate(ios_base::badbit | ios_base::failbit);
772 }771 }
773#ifndef _LIBCPP_NO_EXCEPTIONS772#ifndef _LIBCPP_NO_EXCEPTIONS
...@@ -782,14 +781,14 @@ __put_character_sequence(basic_ostream<_CharT, _Traits>& __os,...@@ -782,14 +781,14 @@ __put_character_sequence(basic_ostream<_CharT, _Traits>& __os,
782781
783782
784template<class _CharT, class _Traits>783template<class _CharT, class _Traits>
785basic_ostream<_CharT, _Traits>&784_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
786operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c)785operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c)
787{786{
788 return _VSTD::__put_character_sequence(__os, &__c, 1);787 return _VSTD::__put_character_sequence(__os, &__c, 1);
789}788}
790789
791template<class _CharT, class _Traits>790template<class _CharT, class _Traits>
792basic_ostream<_CharT, _Traits>&791_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
793operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)792operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)
794{793{
795#ifndef _LIBCPP_NO_EXCEPTIONS794#ifndef _LIBCPP_NO_EXCEPTIONS
...@@ -801,14 +800,14 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)...@@ -801,14 +800,14 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)
801 {800 {
802 _CharT __c = __os.widen(__cn);801 _CharT __c = __os.widen(__cn);
803 typedef ostreambuf_iterator<_CharT, _Traits> _Ip;802 typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
804 if (__pad_and_output(_Ip(__os),803 if (std::__pad_and_output(_Ip(__os),
805 &__c,804 &__c,
806 (__os.flags() & ios_base::adjustfield) == ios_base::left ?805 (__os.flags() & ios_base::adjustfield) == ios_base::left ?
807 &__c + 1 :806 &__c + 1 :
808 &__c,807 &__c,
809 &__c + 1,808 &__c + 1,
810 __os,809 __os,
811 __os.fill()).failed())810 __os.fill()).failed())
812 __os.setstate(ios_base::badbit | ios_base::failbit);811 __os.setstate(ios_base::badbit | ios_base::failbit);
813 }812 }
814#ifndef _LIBCPP_NO_EXCEPTIONS813#ifndef _LIBCPP_NO_EXCEPTIONS
...@@ -822,35 +821,35 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)...@@ -822,35 +821,35 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)
822}821}
823822
824template<class _Traits>823template<class _Traits>
825basic_ostream<char, _Traits>&824_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
826operator<<(basic_ostream<char, _Traits>& __os, char __c)825operator<<(basic_ostream<char, _Traits>& __os, char __c)
827{826{
828 return _VSTD::__put_character_sequence(__os, &__c, 1);827 return _VSTD::__put_character_sequence(__os, &__c, 1);
829}828}
830829
831template<class _Traits>830template<class _Traits>
832basic_ostream<char, _Traits>&831_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
833operator<<(basic_ostream<char, _Traits>& __os, signed char __c)832operator<<(basic_ostream<char, _Traits>& __os, signed char __c)
834{833{
835 return _VSTD::__put_character_sequence(__os, (char *) &__c, 1);834 return _VSTD::__put_character_sequence(__os, (char *) &__c, 1);
836}835}
837836
838template<class _Traits>837template<class _Traits>
839basic_ostream<char, _Traits>&838_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
840operator<<(basic_ostream<char, _Traits>& __os, unsigned char __c)839operator<<(basic_ostream<char, _Traits>& __os, unsigned char __c)
841{840{
842 return _VSTD::__put_character_sequence(__os, (char *) &__c, 1);841 return _VSTD::__put_character_sequence(__os, (char *) &__c, 1);
843}842}
844843
845template<class _CharT, class _Traits>844template<class _CharT, class _Traits>
846basic_ostream<_CharT, _Traits>&845_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
847operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str)846operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str)
848{847{
849 return _VSTD::__put_character_sequence(__os, __str, _Traits::length(__str));848 return _VSTD::__put_character_sequence(__os, __str, _Traits::length(__str));
850}849}
851850
852template<class _CharT, class _Traits>851template<class _CharT, class _Traits>
853basic_ostream<_CharT, _Traits>&852_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
854operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn)853operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn)
855{854{
856#ifndef _LIBCPP_NO_EXCEPTIONS855#ifndef _LIBCPP_NO_EXCEPTIONS
...@@ -875,14 +874,14 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn)...@@ -875,14 +874,14 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn)
875 }874 }
876 for (_CharT* __p = __wb; *__strn != '\0'; ++__strn, ++__p)875 for (_CharT* __p = __wb; *__strn != '\0'; ++__strn, ++__p)
877 *__p = __os.widen(*__strn);876 *__p = __os.widen(*__strn);
878 if (__pad_and_output(_Ip(__os),877 if (std::__pad_and_output(_Ip(__os),
879 __wb,878 __wb,
880 (__os.flags() & ios_base::adjustfield) == ios_base::left ?879 (__os.flags() & ios_base::adjustfield) == ios_base::left ?
881 __wb + __len :880 __wb + __len :
882 __wb,881 __wb,
883 __wb + __len,882 __wb + __len,
884 __os,883 __os,
885 __os.fill()).failed())884 __os.fill()).failed())
886 __os.setstate(ios_base::badbit | ios_base::failbit);885 __os.setstate(ios_base::badbit | ios_base::failbit);
887 }886 }
888#ifndef _LIBCPP_NO_EXCEPTIONS887#ifndef _LIBCPP_NO_EXCEPTIONS
...@@ -896,14 +895,14 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn)...@@ -896,14 +895,14 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn)
896}895}
897896
898template<class _Traits>897template<class _Traits>
899basic_ostream<char, _Traits>&898_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
900operator<<(basic_ostream<char, _Traits>& __os, const char* __str)899operator<<(basic_ostream<char, _Traits>& __os, const char* __str)
901{900{
902 return _VSTD::__put_character_sequence(__os, __str, _Traits::length(__str));901 return _VSTD::__put_character_sequence(__os, __str, _Traits::length(__str));
903}902}
904903
905template<class _Traits>904template<class _Traits>
906basic_ostream<char, _Traits>&905_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
907operator<<(basic_ostream<char, _Traits>& __os, const signed char* __str)906operator<<(basic_ostream<char, _Traits>& __os, const signed char* __str)
908{907{
909 const char *__s = (const char *) __str;908 const char *__s = (const char *) __str;
...@@ -911,7 +910,7 @@ operator<<(basic_ostream<char, _Traits>& __os, const signed char* __str)...@@ -911,7 +910,7 @@ operator<<(basic_ostream<char, _Traits>& __os, const signed char* __str)
911}910}
912911
913template<class _Traits>912template<class _Traits>
914basic_ostream<char, _Traits>&913_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
915operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str)914operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str)
916{915{
917 const char *__s = (const char *) __str;916 const char *__s = (const char *) __str;
...@@ -1032,7 +1031,7 @@ basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir)...@@ -1032,7 +1031,7 @@ basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir)
1032}1031}
10331032
1034template <class _CharT, class _Traits>1033template <class _CharT, class _Traits>
1035inline1034_LIBCPP_HIDE_FROM_ABI inline
1036basic_ostream<_CharT, _Traits>&1035basic_ostream<_CharT, _Traits>&
1037endl(basic_ostream<_CharT, _Traits>& __os)1036endl(basic_ostream<_CharT, _Traits>& __os)
1038{1037{
...@@ -1042,7 +1041,7 @@ endl(basic_ostream<_CharT, _Traits>& __os)...@@ -1042,7 +1041,7 @@ endl(basic_ostream<_CharT, _Traits>& __os)
1042}1041}
10431042
1044template <class _CharT, class _Traits>1043template <class _CharT, class _Traits>
1045inline1044_LIBCPP_HIDE_FROM_ABI inline
1046basic_ostream<_CharT, _Traits>&1045basic_ostream<_CharT, _Traits>&
1047ends(basic_ostream<_CharT, _Traits>& __os)1046ends(basic_ostream<_CharT, _Traits>& __os)
1048{1047{
...@@ -1051,7 +1050,7 @@ ends(basic_ostream<_CharT, _Traits>& __os)...@@ -1051,7 +1050,7 @@ ends(basic_ostream<_CharT, _Traits>& __os)
1051}1050}
10521051
1053template <class _CharT, class _Traits>1052template <class _CharT, class _Traits>
1054inline1053_LIBCPP_HIDE_FROM_ABI inline
1055basic_ostream<_CharT, _Traits>&1054basic_ostream<_CharT, _Traits>&
1056flush(basic_ostream<_CharT, _Traits>& __os)1055flush(basic_ostream<_CharT, _Traits>& __os)
1057{1056{
...@@ -1064,7 +1063,7 @@ struct __is_ostreamable : false_type { };...@@ -1064,7 +1063,7 @@ struct __is_ostreamable : false_type { };
10641063
1065template <class _Stream, class _Tp>1064template <class _Stream, class _Tp>
1066struct __is_ostreamable<_Stream, _Tp, decltype(1065struct __is_ostreamable<_Stream, _Tp, decltype(
1067 declval<_Stream>() << declval<_Tp>(), void()1066 std::declval<_Stream>() << std::declval<_Tp>(), void()
1068)> : true_type { };1067)> : true_type { };
10691068
1070template <class _Stream, class _Tp, class = typename enable_if<1069template <class _Stream, class _Tp, class = typename enable_if<
...@@ -1087,7 +1086,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,...@@ -1087,7 +1086,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os,
1087}1086}
10881087
1089template<class _CharT, class _Traits>1088template<class _CharT, class _Traits>
1090basic_ostream<_CharT, _Traits>&1089_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
1091operator<<(basic_ostream<_CharT, _Traits>& __os,1090operator<<(basic_ostream<_CharT, _Traits>& __os,
1092 basic_string_view<_CharT, _Traits> __sv)1091 basic_string_view<_CharT, _Traits> __sv)
1093{1092{
...@@ -1114,7 +1113,7 @@ template<class _CharT, class _Traits, class _Yp, class _Dp>...@@ -1114,7 +1113,7 @@ template<class _CharT, class _Traits, class _Yp, class _Dp>
1114inline _LIBCPP_INLINE_VISIBILITY1113inline _LIBCPP_INLINE_VISIBILITY
1115typename enable_if1114typename enable_if
1116<1115<
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,
1118 basic_ostream<_CharT, _Traits>&1117 basic_ostream<_CharT, _Traits>&
1119>::type1118>::type
1120operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p)1119operator<<(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...@@ -1123,12 +1122,12 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p
1123}1122}
11241123
1125template <class _CharT, class _Traits, size_t _Size>1124template <class _CharT, class _Traits, size_t _Size>
1126basic_ostream<_CharT, _Traits>&1125_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
1127operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x)1126operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x)
1128{1127{
1129 return __os << __x.template to_string<_CharT, _Traits>1128 return __os << __x.template to_string<_CharT, _Traits>
1130 (use_facet<ctype<_CharT> >(__os.getloc()).widen('0'),1129 (std::use_facet<ctype<_CharT> >(__os.getloc()).widen('0'),
1131 use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));1130 std::use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));
1132}1131}
11331132
1134#if _LIBCPP_STD_VER > 171133#if _LIBCPP_STD_VER > 17
...@@ -1189,4 +1188,10 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>;...@@ -1189,4 +1188,10 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>;
11891188
1190_LIBCPP_END_NAMESPACE_STD1189_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
1192#endif // _LIBCPP_OSTREAM1197#endif // _LIBCPP_OSTREAM
lib/libcxx/include/queue+11-4
...@@ -231,11 +231,9 @@ template <class T, class Container, class Compare>...@@ -231,11 +231,9 @@ template <class T, class Container, class Compare>
231#include <vector>231#include <vector>
232#include <version>232#include <version>
233233
234#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
235# include <functional>
236#endif
237
238// standard-mandated includes234// standard-mandated includes
235
236// [queue.syn]
239#include <compare>237#include <compare>
240#include <initializer_list>238#include <initializer_list>
241239
...@@ -384,6 +382,8 @@ public:...@@ -384,6 +382,8 @@ public:
384 swap(c, __q.c);382 swap(c, __q.c);
385 }383 }
386384
385 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
386
387 template <class _T1, class _C1>387 template <class _T1, class _C1>
388 friend388 friend
389 _LIBCPP_INLINE_VISIBILITY389 _LIBCPP_INLINE_VISIBILITY
...@@ -635,6 +635,8 @@ public:...@@ -635,6 +635,8 @@ public:
635 void swap(priority_queue& __q)635 void swap(priority_queue& __q)
636 _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&636 _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
637 __is_nothrow_swappable<value_compare>::value);637 __is_nothrow_swappable<value_compare>::value);
638
639 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
638};640};
639641
640#if _LIBCPP_STD_VER >= 17642#if _LIBCPP_STD_VER >= 17
...@@ -960,4 +962,9 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Comp...@@ -960,4 +962,9 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Comp
960962
961_LIBCPP_END_NAMESPACE_STD963_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
963#endif // _LIBCPP_QUEUE970#endif // _LIBCPP_QUEUE
lib/libcxx/include/random+17-14
...@@ -1718,25 +1718,28 @@ class piecewise_linear_distribution...@@ -1718,25 +1718,28 @@ class piecewise_linear_distribution
1718#include <__random/weibull_distribution.h>1718#include <__random/weibull_distribution.h>
1719#include <version>1719#include <version>
17201720
1721#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
1722# include <algorithm>
1723#endif
1724
1725// standard-mandated includes1721// standard-mandated includes
1726#include <initializer_list>
17271722
1728#include <cmath> // for backward compatibility; TODO remove it1723// [rand.synopsis]
1729#include <cstddef> // for backward compatibility; TODO remove it1724#include <initializer_list>
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
17371725
1738#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)1726#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1739# pragma GCC system_header1727# pragma GCC system_header
1740#endif1728#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
1742#endif // _LIBCPP_RANDOM1745#endif // _LIBCPP_RANDOM
lib/libcxx/include/ranges+88-4
...@@ -115,6 +115,27 @@ namespace std::ranges {...@@ -115,6 +115,27 @@ namespace std::ranges {
115 template<range R>115 template<range R>
116 using borrowed_subrange_t = see below;116 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
118 // [range.empty], empty view139 // [range.empty], empty view
119 template<class T>140 template<class T>
120 requires is_object_v<T>141 requires is_object_v<T>
...@@ -166,6 +187,18 @@ namespace std::ranges {...@@ -166,6 +187,18 @@ namespace std::ranges {
166 template<class T>187 template<class T>
167 inline constexpr bool enable_borrowed_range<drop_view<T>> = enable_borrowed_range<T>;188 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
169 // [range.transform], transform view202 // [range.transform], transform view
170 template<input_range V, copy_constructible F>203 template<input_range V, copy_constructible F>
171 requires view<V> && is_object_v<F> &&204 requires view<V> && is_object_v<F> &&
...@@ -198,6 +231,14 @@ namespace std::ranges {...@@ -198,6 +231,14 @@ namespace std::ranges {
198 template<class T>231 template<class T>
199 inline constexpr bool enable_borrowed_range<take_view<T>> = enable_borrowed_range<T>;232 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
201 template<copy_constructible T>242 template<copy_constructible T>
202 requires is_object_v<T>243 requires is_object_v<T>
203 class single_view;244 class single_view;
...@@ -224,10 +265,30 @@ namespace std::ranges {...@@ -224,10 +265,30 @@ namespace std::ranges {
224 (forward_range<V> || tiny-range<Pattern>)265 (forward_range<V> || tiny-range<Pattern>)
225 class lazy_split_view;266 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
227 namespace views {274 namespace views {
228 inline constexpr unspecified lazy_split = unspecified;275 inline constexpr unspecified lazy_split = unspecified;
276 inline constexpr unspecified split = unspecified;
229 }277 }
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
231 // [range.zip], zip view292 // [range.zip], zip view
232 template<input_range... Views>293 template<input_range... Views>
233 requires (view<Views> && ...) && (sizeof...(Views) > 0)294 requires (view<Views> && ...) && (sizeof...(Views) > 0)
...@@ -238,6 +299,13 @@ namespace std::ranges {...@@ -238,6 +299,13 @@ namespace std::ranges {
238 (enable_borrowed_range<Views> && ...);299 (enable_borrowed_range<Views> && ...);
239300
240 namespace views { inline constexpr unspecified zip = unspecified; } // C++2b301 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
241}309}
242310
243namespace std {311namespace std {
...@@ -276,12 +344,15 @@ namespace std {...@@ -276,12 +344,15 @@ namespace std {
276#include <__config>344#include <__config>
277#include <__ranges/access.h>345#include <__ranges/access.h>
278#include <__ranges/all.h>346#include <__ranges/all.h>
347#include <__ranges/as_rvalue_view.h>
279#include <__ranges/common_view.h>348#include <__ranges/common_view.h>
280#include <__ranges/concepts.h>349#include <__ranges/concepts.h>
281#include <__ranges/counted.h>350#include <__ranges/counted.h>
282#include <__ranges/dangling.h>351#include <__ranges/dangling.h>
283#include <__ranges/data.h>352#include <__ranges/data.h>
284#include <__ranges/drop_view.h>353#include <__ranges/drop_view.h>
354#include <__ranges/drop_while_view.h>
355#include <__ranges/elements_view.h>
285#include <__ranges/empty.h>356#include <__ranges/empty.h>
286#include <__ranges/empty_view.h>357#include <__ranges/empty_view.h>
287#include <__ranges/enable_borrowed_range.h>358#include <__ranges/enable_borrowed_range.h>
...@@ -296,19 +367,32 @@ namespace std {...@@ -296,19 +367,32 @@ namespace std {
296#include <__ranges/reverse_view.h>367#include <__ranges/reverse_view.h>
297#include <__ranges/single_view.h>368#include <__ranges/single_view.h>
298#include <__ranges/size.h>369#include <__ranges/size.h>
370#include <__ranges/split_view.h>
299#include <__ranges/subrange.h>371#include <__ranges/subrange.h>
300#include <__ranges/take_view.h>372#include <__ranges/take_view.h>
373#include <__ranges/take_while_view.h>
301#include <__ranges/transform_view.h>374#include <__ranges/transform_view.h>
302#include <__ranges/view_interface.h>375#include <__ranges/view_interface.h>
303#include <__ranges/views.h>376#include <__ranges/views.h>
304#include <__ranges/zip_view.h>377#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.
309#include <type_traits>378#include <type_traits>
310#include <version>379#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
312#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)396#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
313# pragma GCC system_header397# pragma GCC system_header
314#endif398#endif
lib/libcxx/include/ratio+5-1
...@@ -79,9 +79,9 @@ typedef ratio<1000000000000000000000000, 1> yotta; // not supported...@@ -79,9 +79,9 @@ typedef ratio<1000000000000000000000000, 1> yotta; // not supported
7979
80#include <__assert> // all public C++ headers provide the assertion handler80#include <__assert> // all public C++ headers provide the assertion handler
81#include <__config>81#include <__config>
82#include <__type_traits/integral_constant.h>
82#include <climits>83#include <climits>
83#include <cstdint>84#include <cstdint>
84#include <type_traits>
85#include <version>85#include <version>
8686
87#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)87#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -525,4 +525,8 @@ _LIBCPP_END_NAMESPACE_STD...@@ -525,4 +525,8 @@ _LIBCPP_END_NAMESPACE_STD
525525
526_LIBCPP_POP_MACROS526_LIBCPP_POP_MACROS
527527
528#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
529# include <type_traits>
530#endif
531
528#endif // _LIBCPP_RATIO532#endif // _LIBCPP_RATIO
lib/libcxx/include/regex+66-37
...@@ -769,20 +769,17 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;...@@ -769,20 +769,17 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
769#include <__iterator/back_insert_iterator.h>769#include <__iterator/back_insert_iterator.h>
770#include <__iterator/wrap_iter.h>770#include <__iterator/wrap_iter.h>
771#include <__locale>771#include <__locale>
772#include <__memory_resource/polymorphic_allocator.h>
772#include <__utility/move.h>773#include <__utility/move.h>
774#include <__utility/pair.h>
773#include <__utility/swap.h>775#include <__utility/swap.h>
776#include <cstring>
774#include <deque>777#include <deque>
775#include <memory>
776#include <stdexcept>778#include <stdexcept>
777#include <string>779#include <string>
778#include <vector>780#include <vector>
779#include <version>781#include <version>
780782
781#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
782# include <iterator>
783# include <utility>
784#endif
785
786// standard-mandated includes783// standard-mandated includes
787784
788// [iterator.range]785// [iterator.range]
...@@ -833,7 +830,7 @@ enum syntax_option_type...@@ -833,7 +830,7 @@ enum syntax_option_type
833 multiline = 1 << 10830 multiline = 1 << 10
834};831};
835832
836inline _LIBCPP_CONSTEXPR833_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR
837syntax_option_type __get_grammar(syntax_option_type __g)834syntax_option_type __get_grammar(syntax_option_type __g)
838{835{
839#ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO836#ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
...@@ -1006,8 +1003,8 @@ class _LIBCPP_EXCEPTION_ABI regex_error...@@ -1006,8 +1003,8 @@ class _LIBCPP_EXCEPTION_ABI regex_error
1006public:1003public:
1007 explicit regex_error(regex_constants::error_type __ecode);1004 explicit regex_error(regex_constants::error_type __ecode);
1008 regex_error(const regex_error&) _NOEXCEPT = default;1005 regex_error(const regex_error&) _NOEXCEPT = default;
1009 virtual ~regex_error() _NOEXCEPT;1006 ~regex_error() _NOEXCEPT override;
1010 _LIBCPP_INLINE_VISIBILITY1007 _LIBCPP_INLINE_VISIBILITY
1011 regex_constants::error_type code() const {return __code_;}1008 regex_constants::error_type code() const {return __code_;}
1012};1009};
10131010
...@@ -1029,7 +1026,7 @@ public:...@@ -1029,7 +1026,7 @@ public:
1029 typedef _CharT char_type;1026 typedef _CharT char_type;
1030 typedef basic_string<char_type> string_type;1027 typedef basic_string<char_type> string_type;
1031 typedef locale locale_type;1028 typedef locale locale_type;
1032#ifdef __BIONIC__1029#if defined(__BIONIC__) || defined(_NEWLIB_VERSION)
1033 // Originally bionic's ctype_base used its own ctype masks because the1030 // Originally bionic's ctype_base used its own ctype masks because the
1034 // builtin ctype implementation wasn't in libc++ yet. Bionic's ctype mask1031 // builtin ctype implementation wasn't in libc++ yet. Bionic's ctype mask
1035 // was only 8 bits wide and already saturated, so it used a wider type here1032 // was only 8 bits wide and already saturated, so it used a wider type here
...@@ -1038,6 +1035,11 @@ public:...@@ -1038,6 +1035,11 @@ public:
1038 // implementation, but this was not updated to match. Since then Android has1035 // implementation, but this was not updated to match. Since then Android has
1039 // needed to maintain a stable libc++ ABI, and this can't be changed without1036 // needed to maintain a stable libc++ ABI, and this can't be changed without
1040 // an ABI break.1037 // 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.
1041 typedef uint16_t char_class_type;1043 typedef uint16_t char_class_type;
1042#else1044#else
1043 typedef ctype_base::mask char_class_type;1045 typedef ctype_base::mask char_class_type;
...@@ -1155,8 +1157,8 @@ template <class _CharT>...@@ -1155,8 +1157,8 @@ template <class _CharT>
1155void1157void
1156regex_traits<_CharT>::__init()1158regex_traits<_CharT>::__init()
1157{1159{
1158 __ct_ = &use_facet<ctype<char_type> >(__loc_);1160 __ct_ = &std::use_facet<ctype<char_type> >(__loc_);
1159 __col_ = &use_facet<collate<char_type> >(__loc_);1161 __col_ = &std::use_facet<collate<char_type> >(__loc_);
1160}1162}
11611163
1162template <class _CharT>1164template <class _CharT>
...@@ -1231,7 +1233,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f,...@@ -1231,7 +1233,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f,
1231 string_type __r;1233 string_type __r;
1232 if (!__s.empty())1234 if (!__s.empty())
1233 {1235 {
1234 __r = __get_collation_name(__s.c_str());1236 __r = std::__get_collation_name(__s.c_str());
1235 if (__r.empty() && __s.size() <= 2)1237 if (__r.empty() && __s.size() <= 2)
1236 {1238 {
1237 __r = __col_->transform(__s.data(), __s.data() + __s.size());1239 __r = __col_->transform(__s.data(), __s.data() + __s.size());
...@@ -1294,7 +1296,7 @@ regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f,...@@ -1294,7 +1296,7 @@ regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f,
1294{1296{
1295 string_type __s(__f, __l);1297 string_type __s(__f, __l);
1296 __ct_->tolower(&__s[0], &__s[0] + __s.size());1298 __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);
1298}1300}
12991301
1300#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1302#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
...@@ -1444,12 +1446,12 @@ public:...@@ -1444,12 +1446,12 @@ public:
14441446
1445 _LIBCPP_INLINE_VISIBILITY1447 _LIBCPP_INLINE_VISIBILITY
1446 __node() {}1448 __node() {}
1447 _LIBCPP_INLINE_VISIBILITY1449 _LIBCPP_HIDE_FROM_ABI_VIRTUAL
1448 virtual ~__node() {}1450 virtual ~__node() {}
14491451
1450 _LIBCPP_INLINE_VISIBILITY1452 _LIBCPP_HIDE_FROM_ABI_VIRTUAL
1451 virtual void __exec(__state&) const {}1453 virtual void __exec(__state&) const {}
1452 _LIBCPP_INLINE_VISIBILITY1454 _LIBCPP_HIDE_FROM_ABI_VIRTUAL
1453 virtual void __exec_split(bool, __state&) const {}1455 virtual void __exec_split(bool, __state&) const {}
1454};1456};
14551457
...@@ -1507,7 +1509,7 @@ public:...@@ -1507,7 +1509,7 @@ public:
1507 explicit __owns_one_state(__node<_CharT>* __s)1509 explicit __owns_one_state(__node<_CharT>* __s)
1508 : base(__s) {}1510 : base(__s) {}
15091511
1510 virtual ~__owns_one_state();1512 ~__owns_one_state() override;
1511};1513};
15121514
1513template <class _CharT>1515template <class _CharT>
...@@ -2092,7 +2094,7 @@ __l_anchor_multiline<_CharT>::__exec(__state& __s) const...@@ -2092,7 +2094,7 @@ __l_anchor_multiline<_CharT>::__exec(__state& __s) const
2092 }2094 }
2093 else if (__multiline_ &&2095 else if (__multiline_ &&
2094 !__s.__at_first_ &&2096 !__s.__at_first_ &&
2095 __is_eol(*_VSTD::prev(__s.__current_)))2097 std::__is_eol(*_VSTD::prev(__s.__current_)))
2096 {2098 {
2097 __s.__do_ = __state::__accept_but_not_consume;2099 __s.__do_ = __state::__accept_but_not_consume;
2098 __s.__node_ = this->first();2100 __s.__node_ = this->first();
...@@ -2134,7 +2136,7 @@ __r_anchor_multiline<_CharT>::__exec(__state& __s) const...@@ -2134,7 +2136,7 @@ __r_anchor_multiline<_CharT>::__exec(__state& __s) const
2134 __s.__do_ = __state::__accept_but_not_consume;2136 __s.__do_ = __state::__accept_but_not_consume;
2135 __s.__node_ = this->first();2137 __s.__node_ = this->first();
2136 }2138 }
2137 else if (__multiline_ && __is_eol(*__s.__current_))2139 else if (__multiline_ && std::__is_eol(*__s.__current_))
2138 {2140 {
2139 __s.__do_ = __state::__accept_but_not_consume;2141 __s.__do_ = __state::__accept_but_not_consume;
2140 __s.__node_ = this->first();2142 __s.__node_ = this->first();
...@@ -2196,7 +2198,7 @@ public:...@@ -2196,7 +2198,7 @@ public:
2196 __match_any_but_newline(__node<_CharT>* __s)2198 __match_any_but_newline(__node<_CharT>* __s)
2197 : base(__s) {}2199 : base(__s) {}
21982200
2199 virtual void __exec(__state&) const;2201 void __exec(__state&) const override;
2200};2202};
22012203
2202template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<char>::__exec(__state&) const;2204template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<char>::__exec(__state&) const;
...@@ -2403,7 +2405,7 @@ public:...@@ -2403,7 +2405,7 @@ public:
2403 for (size_t __i = 0; __i < __e.size(); ++__i)2405 for (size_t __i = 0; __i < __e.size(); ++__i)
2404 __e[__i] = __traits_.translate(__e[__i]);2406 __e[__i] = __traits_.translate(__e[__i]);
2405 }2407 }
2406 __ranges_.push_back(make_pair(2408 __ranges_.push_back(std::make_pair(
2407 __traits_.transform(__b.begin(), __b.end()),2409 __traits_.transform(__b.begin(), __b.end()),
2408 __traits_.transform(__e.begin(), __e.end())));2410 __traits_.transform(__e.begin(), __e.end())));
2409 }2411 }
...@@ -2416,20 +2418,20 @@ public:...@@ -2416,20 +2418,20 @@ public:
2416 __b[0] = __traits_.translate_nocase(__b[0]);2418 __b[0] = __traits_.translate_nocase(__b[0]);
2417 __e[0] = __traits_.translate_nocase(__e[0]);2419 __e[0] = __traits_.translate_nocase(__e[0]);
2418 }2420 }
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)));
2420 }2422 }
2421 }2423 }
2422 _LIBCPP_INLINE_VISIBILITY2424 _LIBCPP_INLINE_VISIBILITY
2423 void __add_digraph(_CharT __c1, _CharT __c2)2425 void __add_digraph(_CharT __c1, _CharT __c2)
2424 {2426 {
2425 if (__icase_)2427 if (__icase_)
2426 __digraphs_.push_back(make_pair(__traits_.translate_nocase(__c1),2428 __digraphs_.push_back(std::make_pair(__traits_.translate_nocase(__c1),
2427 __traits_.translate_nocase(__c2)));2429 __traits_.translate_nocase(__c2)));
2428 else if (__collate_)2430 else if (__collate_)
2429 __digraphs_.push_back(make_pair(__traits_.translate(__c1),2431 __digraphs_.push_back(std::make_pair(__traits_.translate(__c1),
2430 __traits_.translate(__c2)));2432 __traits_.translate(__c2)));
2431 else2433 else
2432 __digraphs_.push_back(make_pair(__c1, __c2));2434 __digraphs_.push_back(std::make_pair(__c1, __c2));
2433 }2435 }
2434 _LIBCPP_INLINE_VISIBILITY2436 _LIBCPP_INLINE_VISIBILITY
2435 void __add_equivalence(const string_type& __s)2437 void __add_equivalence(const string_type& __s)
...@@ -5521,7 +5523,7 @@ public:...@@ -5521,7 +5523,7 @@ public:
5521 regex_constants::match_flag_type __flags = regex_constants::format_default) const5523 regex_constants::match_flag_type __flags = regex_constants::format_default) const
5522 {5524 {
5523 basic_string<char_type, _ST, _SA> __r;5525 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(),
5525 __flags);5527 __flags);
5526 return __r;5528 return __r;
5527 }5529 }
...@@ -5531,7 +5533,7 @@ public:...@@ -5531,7 +5533,7 @@ public:
5531 regex_constants::match_flag_type __flags = regex_constants::format_default) const5533 regex_constants::match_flag_type __flags = regex_constants::format_default) const
5532 {5534 {
5533 string_type __r;5535 string_type __r;
5534 format(back_inserter(__r), __fmt,5536 format(std::back_inserter(__r), __fmt,
5535 __fmt + char_traits<char_type>::length(__fmt), __flags);5537 __fmt + char_traits<char_type>::length(__fmt), __flags);
5536 return __r;5538 return __r;
5537 }5539 }
...@@ -5732,7 +5734,7 @@ match_results<_BidirectionalIterator, _Allocator>::swap(match_results& __m)...@@ -5732,7 +5734,7 @@ match_results<_BidirectionalIterator, _Allocator>::swap(match_results& __m)
5732}5734}
57335735
5734template <class _BidirectionalIterator, class _Allocator>5736template <class _BidirectionalIterator, class _Allocator>
5735bool5737_LIBCPP_HIDE_FROM_ABI bool
5736operator==(const match_results<_BidirectionalIterator, _Allocator>& __x,5738operator==(const match_results<_BidirectionalIterator, _Allocator>& __x,
5737 const match_results<_BidirectionalIterator, _Allocator>& __y)5739 const match_results<_BidirectionalIterator, _Allocator>& __y)
5738{5740{
...@@ -6224,7 +6226,7 @@ regex_search(const basic_string<_Cp, _ST, _SA>&& __s,...@@ -6224,7 +6226,7 @@ regex_search(const basic_string<_Cp, _ST, _SA>&& __s,
6224// regex_match6226// regex_match
62256227
6226template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits>6228template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits>
6227bool6229_LIBCPP_HIDE_FROM_ABI bool
6228regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last,6230regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last,
6229 match_results<_BidirectionalIterator, _Allocator>& __m,6231 match_results<_BidirectionalIterator, _Allocator>& __m,
6230 const basic_regex<_CharT, _Traits>& __e,6232 const basic_regex<_CharT, _Traits>& __e,
...@@ -6737,7 +6739,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()...@@ -6737,7 +6739,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
67376739
6738template <class _OutputIterator, class _BidirectionalIterator,6740template <class _OutputIterator, class _BidirectionalIterator,
6739 class _Traits, class _CharT>6741 class _Traits, class _CharT>
6740_OutputIterator6742_LIBCPP_HIDE_FROM_ABI _OutputIterator
6741regex_replace(_OutputIterator __output_iter,6743regex_replace(_OutputIterator __output_iter,
6742 _BidirectionalIterator __first, _BidirectionalIterator __last,6744 _BidirectionalIterator __first, _BidirectionalIterator __last,
6743 const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt,6745 const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt,
...@@ -6792,7 +6794,7 @@ regex_replace(const basic_string<_CharT, _ST, _SA>& __s,...@@ -6792,7 +6794,7 @@ regex_replace(const basic_string<_CharT, _ST, _SA>& __s,
6792 regex_constants::match_flag_type __flags = regex_constants::match_default)6794 regex_constants::match_flag_type __flags = regex_constants::match_default)
6793{6795{
6794 basic_string<_CharT, _ST, _SA> __r;6796 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,
6796 __fmt.c_str(), __flags);6798 __fmt.c_str(), __flags);
6797 return __r;6799 return __r;
6798}6800}
...@@ -6805,7 +6807,7 @@ regex_replace(const basic_string<_CharT, _ST, _SA>& __s,...@@ -6805,7 +6807,7 @@ regex_replace(const basic_string<_CharT, _ST, _SA>& __s,
6805 regex_constants::match_flag_type __flags = regex_constants::match_default)6807 regex_constants::match_flag_type __flags = regex_constants::match_default)
6806{6808{
6807 basic_string<_CharT, _ST, _SA> __r;6809 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,
6809 __fmt, __flags);6811 __fmt, __flags);
6810 return __r;6812 return __r;
6811}6813}
...@@ -6819,7 +6821,7 @@ regex_replace(const _CharT* __s,...@@ -6819,7 +6821,7 @@ regex_replace(const _CharT* __s,
6819 regex_constants::match_flag_type __flags = regex_constants::match_default)6821 regex_constants::match_flag_type __flags = regex_constants::match_default)
6820{6822{
6821 basic_string<_CharT> __r;6823 basic_string<_CharT> __r;
6822 _VSTD::regex_replace(back_inserter(__r), __s,6824 _VSTD::regex_replace(std::back_inserter(__r), __s,
6823 __s + char_traits<_CharT>::length(__s), __e,6825 __s + char_traits<_CharT>::length(__s), __e,
6824 __fmt.c_str(), __flags);6826 __fmt.c_str(), __flags);
6825 return __r;6827 return __r;
...@@ -6834,7 +6836,7 @@ regex_replace(const _CharT* __s,...@@ -6834,7 +6836,7 @@ regex_replace(const _CharT* __s,
6834 regex_constants::match_flag_type __flags = regex_constants::match_default)6836 regex_constants::match_flag_type __flags = regex_constants::match_default)
6835{6837{
6836 basic_string<_CharT> __r;6838 basic_string<_CharT> __r;
6837 _VSTD::regex_replace(back_inserter(__r), __s,6839 _VSTD::regex_replace(std::back_inserter(__r), __s,
6838 __s + char_traits<_CharT>::length(__s), __e,6840 __s + char_traits<_CharT>::length(__s), __e,
6839 __fmt, __flags);6841 __fmt, __flags);
6840 return __r;6842 return __r;
...@@ -6842,6 +6844,33 @@ regex_replace(const _CharT* __s,...@@ -6842,6 +6844,33 @@ regex_replace(const _CharT* __s,
68426844
6843_LIBCPP_END_NAMESPACE_STD6845_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
6845_LIBCPP_POP_MACROS6864_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
6847#endif // _LIBCPP_REGEX6876#endif // _LIBCPP_REGEX
lib/libcxx/include/scoped_allocator+44-6
...@@ -111,8 +111,19 @@ template <class OuterA1, class OuterA2, class... InnerAllocs>...@@ -111,8 +111,19 @@ template <class OuterA1, class OuterA2, class... InnerAllocs>
111111
112#include <__assert> // all public C++ headers provide the assertion handler112#include <__assert> // all public C++ headers provide the assertion handler
113#include <__config>113#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>
114#include <__utility/forward.h>122#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>
116#include <version>127#include <version>
117128
118#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)129#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -352,7 +363,7 @@ protected:...@@ -352,7 +363,7 @@ protected:
352// __outermost363// __outermost
353364
354template <class _Alloc>365template <class _Alloc>
355decltype(declval<_Alloc>().outer_allocator(), true_type())366decltype(std::declval<_Alloc>().outer_allocator(), true_type())
356__has_outer_allocator_test(_Alloc&& __a);367__has_outer_allocator_test(_Alloc&& __a);
357368
358template <class _Alloc>369template <class _Alloc>
...@@ -363,7 +374,7 @@ template <class _Alloc>...@@ -363,7 +374,7 @@ template <class _Alloc>
363struct __has_outer_allocator374struct __has_outer_allocator
364 : public common_type375 : public common_type
365 <376 <
366 decltype(__has_outer_allocator_test(declval<_Alloc&>()))377 decltype(std::__has_outer_allocator_test(std::declval<_Alloc&>()))
367 >::type378 >::type
368{379{
369};380};
...@@ -379,10 +390,10 @@ struct __outermost...@@ -379,10 +390,10 @@ struct __outermost
379template <class _Alloc>390template <class _Alloc>
380struct __outermost<_Alloc, true>391struct __outermost<_Alloc, true>
381{392{
382 typedef typename remove_reference393 typedef __libcpp_remove_reference_t
383 <394 <
384 decltype(declval<_Alloc>().outer_allocator())395 decltype(std::declval<_Alloc>().outer_allocator())
385 >::type _OuterAlloc;396 > _OuterAlloc;
386 typedef typename __outermost<_OuterAlloc>::type type;397 typedef typename __outermost<_OuterAlloc>::type type;
387 _LIBCPP_INLINE_VISIBILITY398 _LIBCPP_INLINE_VISIBILITY
388 type& operator()(_Alloc& __a) const _NOEXCEPT399 type& operator()(_Alloc& __a) const _NOEXCEPT
...@@ -501,6 +512,18 @@ public:...@@ -501,6 +512,18 @@ public:
501 size_type max_size() const512 size_type max_size() const
502 {return allocator_traits<outer_allocator_type>::max_size(outer_allocator());}513 {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
504 template <class _Tp, class... _Args>527 template <class _Tp, class... _Args>
505 _LIBCPP_INLINE_VISIBILITY528 _LIBCPP_INLINE_VISIBILITY
506 void construct(_Tp* __p, _Args&& ...__args)529 void construct(_Tp* __p, _Args&& ...__args)
...@@ -555,6 +578,7 @@ public:...@@ -555,6 +578,7 @@ public:
555 _VSTD::forward_as_tuple(_VSTD::forward<_Up>(__x.first)),578 _VSTD::forward_as_tuple(_VSTD::forward<_Up>(__x.first)),
556 _VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__x.second)));579 _VSTD::forward_as_tuple(_VSTD::forward<_Vp>(__x.second)));
557 }580 }
581#endif
558582
559 template <class _Tp>583 template <class _Tp>
560 _LIBCPP_INLINE_VISIBILITY584 _LIBCPP_INLINE_VISIBILITY
...@@ -692,4 +716,18 @@ operator!=(const scoped_allocator_adaptor<_OuterA1, _InnerAllocs...>& __a,...@@ -692,4 +716,18 @@ operator!=(const scoped_allocator_adaptor<_OuterA1, _InnerAllocs...>& __a,
692716
693_LIBCPP_END_NAMESPACE_STD717_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
695#endif // _LIBCPP_SCOPED_ALLOCATOR733#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....@@ -80,31 +80,31 @@ functions. It avoids contention against users' own use of those facilities.
8080
81class __atomic_semaphore_base81class __atomic_semaphore_base
82{82{
83 __atomic_base<ptrdiff_t> __a;83 __atomic_base<ptrdiff_t> __a_;
8484
85public:85public:
86 _LIBCPP_INLINE_VISIBILITY86 _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)
88 {88 {
89 }89 }
90 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY90 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
91 void release(ptrdiff_t __update = 1)91 void release(ptrdiff_t __update = 1)
92 {92 {
93 if(0 < __a.fetch_add(__update, memory_order_release))93 if(0 < __a_.fetch_add(__update, memory_order_release))
94 ;94 ;
95 else if(__update > 1)95 else if(__update > 1)
96 __a.notify_all();96 __a_.notify_all();
97 else97 else
98 __a.notify_one();98 __a_.notify_one();
99 }99 }
100 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY100 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
101 void acquire()101 void acquire()
102 {102 {
103 auto const __test_fn = [this]() -> bool {103 auto const __test_fn = [this]() -> bool {
104 auto __old = __a.load(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);105 return (__old != 0) && __a_.compare_exchange_strong(__old, __old - 1, memory_order_acquire, memory_order_relaxed);
106 };106 };
107 __cxx_atomic_wait(&__a.__a_, __test_fn);107 __cxx_atomic_wait(&__a_.__a_, __test_fn);
108 }108 }
109 template <class Rep, class Period>109 template <class Rep, class Period>
110 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY110 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
...@@ -113,16 +113,16 @@ public:...@@ -113,16 +113,16 @@ public:
113 if (__rel_time == chrono::duration<Rep, Period>::zero())113 if (__rel_time == chrono::duration<Rep, Period>::zero())
114 return try_acquire();114 return try_acquire();
115 auto const __test_fn = [this]() { return try_acquire(); };115 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);
117 }117 }
118 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY118 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
119 bool try_acquire()119 bool try_acquire()
120 {120 {
121 auto __old = __a.load(memory_order_acquire);121 auto __old = __a_.load(memory_order_acquire);
122 while (true) {122 while (true) {
123 if (__old == 0)123 if (__old == 0)
124 return false;124 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))
126 return true;126 return true;
127 }127 }
128 }128 }
...@@ -133,7 +133,7 @@ public:...@@ -133,7 +133,7 @@ public:
133template<ptrdiff_t __least_max_value = _LIBCPP_SEMAPHORE_MAX>133template<ptrdiff_t __least_max_value = _LIBCPP_SEMAPHORE_MAX>
134class counting_semaphore134class counting_semaphore
135{135{
136 __atomic_semaphore_base __semaphore;136 __atomic_semaphore_base __semaphore_;
137137
138public:138public:
139 static constexpr ptrdiff_t max() noexcept {139 static constexpr ptrdiff_t max() noexcept {
...@@ -141,7 +141,7 @@ public:...@@ -141,7 +141,7 @@ public:
141 }141 }
142142
143 _LIBCPP_INLINE_VISIBILITY143 _LIBCPP_INLINE_VISIBILITY
144 constexpr explicit counting_semaphore(ptrdiff_t __count) : __semaphore(__count) { }144 constexpr explicit counting_semaphore(ptrdiff_t __count) : __semaphore_(__count) { }
145 ~counting_semaphore() = default;145 ~counting_semaphore() = default;
146146
147 counting_semaphore(const counting_semaphore&) = delete;147 counting_semaphore(const counting_semaphore&) = delete;
...@@ -150,23 +150,23 @@ public:...@@ -150,23 +150,23 @@ public:
150 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY150 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
151 void release(ptrdiff_t __update = 1)151 void release(ptrdiff_t __update = 1)
152 {152 {
153 __semaphore.release(__update);153 __semaphore_.release(__update);
154 }154 }
155 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY155 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
156 void acquire()156 void acquire()
157 {157 {
158 __semaphore.acquire();158 __semaphore_.acquire();
159 }159 }
160 template<class Rep, class Period>160 template<class Rep, class Period>
161 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY161 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
162 bool try_acquire_for(chrono::duration<Rep, Period> const& __rel_time)162 bool try_acquire_for(chrono::duration<Rep, Period> const& __rel_time)
163 {163 {
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));
165 }165 }
166 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY166 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
167 bool try_acquire()167 bool try_acquire()
168 {168 {
169 return __semaphore.try_acquire();169 return __semaphore_.try_acquire();
170 }170 }
171 template <class Clock, class Duration>171 template <class Clock, class Duration>
172 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY172 _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...@@ -480,16 +480,14 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20
480#include <__iterator/erase_if_container.h>480#include <__iterator/erase_if_container.h>
481#include <__iterator/iterator_traits.h>481#include <__iterator/iterator_traits.h>
482#include <__iterator/reverse_iterator.h>482#include <__iterator/reverse_iterator.h>
483#include <__memory/allocator.h>
484#include <__memory_resource/polymorphic_allocator.h>
483#include <__node_handle>485#include <__node_handle>
484#include <__tree>486#include <__tree>
487#include <__type_traits/is_allocator.h>
485#include <__utility/forward.h>488#include <__utility/forward.h>
486#include <version>489#include <version>
487490
488#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
489# include <functional>
490# include <iterator>
491#endif
492
493// standard-mandated includes491// standard-mandated includes
494492
495// [iterator.range]493// [iterator.range]
...@@ -533,6 +531,10 @@ private:...@@ -533,6 +531,10 @@ private:
533 typedef __tree<value_type, value_compare, allocator_type> __base;531 typedef __tree<value_type, value_compare, allocator_type> __base;
534 typedef allocator_traits<allocator_type> __alloc_traits;532 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
536 __base __tree_;538 __base __tree_;
537539
538public:540public:
...@@ -1066,6 +1068,10 @@ private:...@@ -1066,6 +1068,10 @@ private:
1066 typedef __tree<value_type, value_compare, allocator_type> __base;1068 typedef __tree<value_type, value_compare, allocator_type> __base;
1067 typedef allocator_traits<allocator_type> __alloc_traits;1069 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
1069 __base __tree_;1075 __base __tree_;
10701076
1071public:1077public:
...@@ -1578,4 +1584,22 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -1578,4 +1584,22 @@ inline _LIBCPP_INLINE_VISIBILITY
15781584
1579_LIBCPP_END_NAMESPACE_STD1585_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
1581#endif // _LIBCPP_SET1605#endif // _LIBCPP_SET
lib/libcxx/include/setjmp.h+3-1
...@@ -31,7 +31,9 @@ void longjmp(jmp_buf env, int val);...@@ -31,7 +31,9 @@ void longjmp(jmp_buf env, int val);
31# pragma GCC system_header31# pragma GCC system_header
32#endif32#endif
3333
34#include_next <setjmp.h>34#if __has_include_next(<setjmp.h>)
35# include_next <setjmp.h>
36#endif
3537
36#ifdef __cplusplus38#ifdef __cplusplus
3739
lib/libcxx/include/shared_mutex+28-27
...@@ -180,23 +180,23 @@ __shared_mutex_base...@@ -180,23 +180,23 @@ __shared_mutex_base
180#if _LIBCPP_STD_VER > 14180#if _LIBCPP_STD_VER > 14
181class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_SHARED_MUTEX shared_mutex181class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_SHARED_MUTEX shared_mutex
182{182{
183 __shared_mutex_base __base;183 __shared_mutex_base __base_;
184public:184public:
185 _LIBCPP_INLINE_VISIBILITY shared_mutex() : __base() {}185 _LIBCPP_INLINE_VISIBILITY shared_mutex() : __base_() {}
186 _LIBCPP_INLINE_VISIBILITY ~shared_mutex() = default;186 _LIBCPP_INLINE_VISIBILITY ~shared_mutex() = default;
187187
188 shared_mutex(const shared_mutex&) = delete;188 shared_mutex(const shared_mutex&) = delete;
189 shared_mutex& operator=(const shared_mutex&) = delete;189 shared_mutex& operator=(const shared_mutex&) = delete;
190190
191 // Exclusive ownership191 // Exclusive ownership
192 _LIBCPP_INLINE_VISIBILITY void lock() { return __base.lock(); }192 _LIBCPP_INLINE_VISIBILITY void lock() { return __base_.lock(); }
193 _LIBCPP_INLINE_VISIBILITY bool try_lock() { return __base.try_lock(); }193 _LIBCPP_INLINE_VISIBILITY bool try_lock() { return __base_.try_lock(); }
194 _LIBCPP_INLINE_VISIBILITY void unlock() { return __base.unlock(); }194 _LIBCPP_INLINE_VISIBILITY void unlock() { return __base_.unlock(); }
195195
196 // Shared ownership196 // Shared ownership
197 _LIBCPP_INLINE_VISIBILITY void lock_shared() { return __base.lock_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(); }198 _LIBCPP_INLINE_VISIBILITY bool try_lock_shared() { return __base_.try_lock_shared(); }
199 _LIBCPP_INLINE_VISIBILITY void unlock_shared() { return __base.unlock_shared(); }199 _LIBCPP_INLINE_VISIBILITY void unlock_shared() { return __base_.unlock_shared(); }
200200
201// typedef __shared_mutex_base::native_handle_type native_handle_type;201// typedef __shared_mutex_base::native_handle_type native_handle_type;
202// _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() { return __base::unlock_shared(); }202// _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() { return __base::unlock_shared(); }
...@@ -206,7 +206,7 @@ public:...@@ -206,7 +206,7 @@ public:
206206
207class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_SHARED_MUTEX shared_timed_mutex207class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_SHARED_MUTEX shared_timed_mutex
208{208{
209 __shared_mutex_base __base;209 __shared_mutex_base __base_;
210public:210public:
211 shared_timed_mutex();211 shared_timed_mutex();
212 _LIBCPP_INLINE_VISIBILITY ~shared_timed_mutex() = default;212 _LIBCPP_INLINE_VISIBILITY ~shared_timed_mutex() = default;
...@@ -252,30 +252,30 @@ bool...@@ -252,30 +252,30 @@ bool
252shared_timed_mutex::try_lock_until(252shared_timed_mutex::try_lock_until(
253 const chrono::time_point<_Clock, _Duration>& __abs_time)253 const chrono::time_point<_Clock, _Duration>& __abs_time)
254{254{
255 unique_lock<mutex> __lk(__base.__mut_);255 unique_lock<mutex> __lk(__base_.__mut_);
256 if (__base.__state_ & __base.__write_entered_)256 if (__base_.__state_ & __base_.__write_entered_)
257 {257 {
258 while (true)258 while (true)
259 {259 {
260 cv_status __status = __base.__gate1_.wait_until(__lk, __abs_time);260 cv_status __status = __base_.__gate1_.wait_until(__lk, __abs_time);
261 if ((__base.__state_ & __base.__write_entered_) == 0)261 if ((__base_.__state_ & __base_.__write_entered_) == 0)
262 break;262 break;
263 if (__status == cv_status::timeout)263 if (__status == cv_status::timeout)
264 return false;264 return false;
265 }265 }
266 }266 }
267 __base.__state_ |= __base.__write_entered_;267 __base_.__state_ |= __base_.__write_entered_;
268 if (__base.__state_ & __base.__n_readers_)268 if (__base_.__state_ & __base_.__n_readers_)
269 {269 {
270 while (true)270 while (true)
271 {271 {
272 cv_status __status = __base.__gate2_.wait_until(__lk, __abs_time);272 cv_status __status = __base_.__gate2_.wait_until(__lk, __abs_time);
273 if ((__base.__state_ & __base.__n_readers_) == 0)273 if ((__base_.__state_ & __base_.__n_readers_) == 0)
274 break;274 break;
275 if (__status == cv_status::timeout)275 if (__status == cv_status::timeout)
276 {276 {
277 __base.__state_ &= ~__base.__write_entered_;277 __base_.__state_ &= ~__base_.__write_entered_;
278 __base.__gate1_.notify_all();278 __base_.__gate1_.notify_all();
279 return false;279 return false;
280 }280 }
281 }281 }
...@@ -288,22 +288,22 @@ bool...@@ -288,22 +288,22 @@ bool
288shared_timed_mutex::try_lock_shared_until(288shared_timed_mutex::try_lock_shared_until(
289 const chrono::time_point<_Clock, _Duration>& __abs_time)289 const chrono::time_point<_Clock, _Duration>& __abs_time)
290{290{
291 unique_lock<mutex> __lk(__base.__mut_);291 unique_lock<mutex> __lk(__base_.__mut_);
292 if ((__base.__state_ & __base.__write_entered_) || (__base.__state_ & __base.__n_readers_) == __base.__n_readers_)292 if ((__base_.__state_ & __base_.__write_entered_) || (__base_.__state_ & __base_.__n_readers_) == __base_.__n_readers_)
293 {293 {
294 while (true)294 while (true)
295 {295 {
296 cv_status status = __base.__gate1_.wait_until(__lk, __abs_time);296 cv_status status = __base_.__gate1_.wait_until(__lk, __abs_time);
297 if ((__base.__state_ & __base.__write_entered_) == 0 &&297 if ((__base_.__state_ & __base_.__write_entered_) == 0 &&
298 (__base.__state_ & __base.__n_readers_) < __base.__n_readers_)298 (__base_.__state_ & __base_.__n_readers_) < __base_.__n_readers_)
299 break;299 break;
300 if (status == cv_status::timeout)300 if (status == cv_status::timeout)
301 return false;301 return false;
302 }302 }
303 }303 }
304 unsigned __num_readers = (__base.__state_ & __base.__n_readers_) + 1;304 unsigned __num_readers = (__base_.__state_ & __base_.__n_readers_) + 1;
305 __base.__state_ &= ~__base.__n_readers_;305 __base_.__state_ &= ~__base_.__n_readers_;
306 __base.__state_ |= __num_readers;306 __base_.__state_ |= __num_readers;
307 return true;307 return true;
308}308}
309309
...@@ -432,6 +432,7 @@ public:...@@ -432,6 +432,7 @@ public:
432 _LIBCPP_INLINE_VISIBILITY432 _LIBCPP_INLINE_VISIBILITY
433 mutex_type* mutex() const _NOEXCEPT {return __m_;}433 mutex_type* mutex() const _NOEXCEPT {return __m_;}
434};434};
435_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(shared_lock);
435436
436template <class _Mutex>437template <class _Mutex>
437void438void
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>...@@ -148,11 +148,6 @@ template<class R>
148#include <type_traits> // for remove_cv, etc148#include <type_traits> // for remove_cv, etc
149#include <version>149#include <version>
150150
151#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
152# include <functional>
153# include <iterator>
154#endif
155
156// standard-mandated includes151// standard-mandated includes
157152
158// [iterator.range]153// [iterator.range]
...@@ -185,23 +180,6 @@ struct __is_std_span : false_type {};...@@ -185,23 +180,6 @@ struct __is_std_span : false_type {};
185template <class _Tp, size_t _Sz>180template <class _Tp, size_t _Sz>
186struct __is_std_span<span<_Tp, _Sz>> : true_type {};181struct __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
205template <class _Range, class _ElementType>183template <class _Range, class _ElementType>
206concept __span_compatible_range =184concept __span_compatible_range =
207 ranges::contiguous_range<_Range> &&185 ranges::contiguous_range<_Range> &&
...@@ -211,7 +189,6 @@ concept __span_compatible_range =...@@ -211,7 +189,6 @@ concept __span_compatible_range =
211 !__is_std_array<remove_cvref_t<_Range>>::value &&189 !__is_std_array<remove_cvref_t<_Range>>::value &&
212 !is_array_v<remove_cvref_t<_Range>> &&190 !is_array_v<remove_cvref_t<_Range>> &&
213 is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>>(*)[], _ElementType(*)[]>;191 is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>>(*)[], _ElementType(*)[]>;
214#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
215192
216template <class _From, class _To>193template <class _From, class _To>
217concept __span_array_convertible = is_convertible_v<_From(*)[], _To(*)[]>;194concept __span_array_convertible = is_convertible_v<_From(*)[], _To(*)[]>;
...@@ -234,7 +211,7 @@ public:...@@ -234,7 +211,7 @@ public:
234 using const_pointer = const _Tp *;211 using const_pointer = const _Tp *;
235 using reference = _Tp &;212 using reference = _Tp &;
236 using const_reference = const _Tp &;213 using const_reference = const _Tp &;
237#ifdef _LIBCPP_ENABLE_DEBUG_MODE214#ifdef _LIBCPP_DEBUG_ITERATOR_BOUNDS_CHECKING
238 using iterator = __bounded_iter<pointer>;215 using iterator = __bounded_iter<pointer>;
239#else216#else
240 using iterator = __wrap_iter<pointer>;217 using iterator = __wrap_iter<pointer>;
...@@ -245,7 +222,7 @@ public:...@@ -245,7 +222,7 @@ public:
245222
246// [span.cons], span constructors, copy, assignment, and destructor223// [span.cons], span constructors, copy, assignment, and destructor
247 template <size_t _Sz = _Extent> requires(_Sz == 0)224 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
250 constexpr span (const span&) noexcept = default;227 constexpr span (const span&) noexcept = default;
251 constexpr span& operator=(const span&) noexcept = default;228 constexpr span& operator=(const span&) noexcept = default;
...@@ -253,61 +230,46 @@ public:...@@ -253,61 +230,46 @@ public:
253 template <__span_compatible_iterator<element_type> _It>230 template <__span_compatible_iterator<element_type> _It>
254 _LIBCPP_INLINE_VISIBILITY231 _LIBCPP_INLINE_VISIBILITY
255 constexpr explicit span(_It __first, size_type __count)232 constexpr explicit span(_It __first, size_type __count)
256 : __data{_VSTD::to_address(__first)} {233 : __data_{_VSTD::to_address(__first)} {
257 (void)__count;234 (void)__count;
258 _LIBCPP_ASSERT(_Extent == __count, "size mismatch in span's constructor (iterator, len)");235 _LIBCPP_ASSERT(_Extent == __count, "size mismatch in span's constructor (iterator, len)");
259 }236 }
260237
261 template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End>238 template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End>
262 _LIBCPP_INLINE_VISIBILITY239 _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)} {
264 (void)__last;241 (void)__last;
265 _LIBCPP_ASSERT((__last - __first >= 0), "invalid range in span's constructor (iterator, sentinel)");242 _LIBCPP_ASSERT((__last - __first >= 0), "invalid range in span's constructor (iterator, sentinel)");
266 _LIBCPP_ASSERT(__last - __first == _Extent,243 _LIBCPP_ASSERT(__last - __first == _Extent,
267 "invalid range in span's constructor (iterator, sentinel): last - first != extent");244 "invalid range in span's constructor (iterator, sentinel): last - first != extent");
268 }245 }
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
272 template <__span_array_convertible<element_type> _OtherElementType>249 template <__span_array_convertible<element_type> _OtherElementType>
273 _LIBCPP_INLINE_VISIBILITY250 _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
276 template <class _OtherElementType>253 template <class _OtherElementType>
277 requires __span_array_convertible<const _OtherElementType, element_type>254 requires __span_array_convertible<const _OtherElementType, element_type>
278 _LIBCPP_INLINE_VISIBILITY255 _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
295 template <__span_compatible_range<element_type> _Range>258 template <__span_compatible_range<element_type> _Range>
296 _LIBCPP_INLINE_VISIBILITY259 _LIBCPP_INLINE_VISIBILITY
297 constexpr explicit span(_Range&& __r) : __data{ranges::data(__r)} {260 constexpr explicit span(_Range&& __r) : __data_{ranges::data(__r)} {
298 _LIBCPP_ASSERT(ranges::size(__r) == _Extent, "size mismatch in span's constructor (range)");261 _LIBCPP_ASSERT(ranges::size(__r) == _Extent, "size mismatch in span's constructor (range)");
299 }262 }
300#endif
301263
302 template <__span_array_convertible<element_type> _OtherElementType>264 template <__span_array_convertible<element_type> _OtherElementType>
303 _LIBCPP_INLINE_VISIBILITY265 _LIBCPP_INLINE_VISIBILITY
304 constexpr span(const span<_OtherElementType, _Extent>& __other)266 constexpr span(const span<_OtherElementType, _Extent>& __other)
305 : __data{__other.data()} {}267 : __data_{__other.data()} {}
306268
307 template <__span_array_convertible<element_type> _OtherElementType>269 template <__span_array_convertible<element_type> _OtherElementType>
308 _LIBCPP_INLINE_VISIBILITY270 _LIBCPP_INLINE_VISIBILITY
309 constexpr explicit span(const span<_OtherElementType, dynamic_extent>& __other) noexcept271 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
313// ~span() noexcept = default;275// ~span() noexcept = default;
...@@ -374,33 +336,33 @@ public:...@@ -374,33 +336,33 @@ public:
374 _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept336 _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept
375 {337 {
376 _LIBCPP_ASSERT(__idx < size(), "span<T, N>::operator[](index): index out of range");338 _LIBCPP_ASSERT(__idx < size(), "span<T, N>::operator[](index): index out of range");
377 return __data[__idx];339 return __data_[__idx];
378 }340 }
379341
380 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept342 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
381 {343 {
382 _LIBCPP_ASSERT(!empty(), "span<T, N>::front() on empty span");344 _LIBCPP_ASSERT(!empty(), "span<T, N>::front() on empty span");
383 return __data[0];345 return __data_[0];
384 }346 }
385347
386 _LIBCPP_INLINE_VISIBILITY constexpr reference back() const noexcept348 _LIBCPP_INLINE_VISIBILITY constexpr reference back() const noexcept
387 {349 {
388 _LIBCPP_ASSERT(!empty(), "span<T, N>::back() on empty span");350 _LIBCPP_ASSERT(!empty(), "span<T, N>::back() on empty span");
389 return __data[size()-1];351 return __data_[size()-1];
390 }352 }
391353
392 _LIBCPP_INLINE_VISIBILITY constexpr pointer data() const noexcept { return __data; }354 _LIBCPP_INLINE_VISIBILITY constexpr pointer data() const noexcept { return __data_; }
393355
394// [span.iter], span iterator support356// [span.iter], span iterator support
395 _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept {357 _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept {
396#ifdef _LIBCPP_ENABLE_DEBUG_MODE358#ifdef _LIBCPP_DEBUG_ITERATOR_BOUNDS_CHECKING
397 return std::__make_bounded_iter(data(), data(), data() + size());359 return std::__make_bounded_iter(data(), data(), data() + size());
398#else360#else
399 return iterator(this, data());361 return iterator(this, data());
400#endif362#endif
401 }363 }
402 _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept {364 _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept {
403#ifdef _LIBCPP_ENABLE_DEBUG_MODE365#ifdef _LIBCPP_DEBUG_ITERATOR_BOUNDS_CHECKING
404 return std::__make_bounded_iter(data() + size(), data(), data() + size());366 return std::__make_bounded_iter(data() + size(), data(), data() + size());
405#else367#else
406 return iterator(this, data() + size());368 return iterator(this, data() + size());
...@@ -416,7 +378,7 @@ public:...@@ -416,7 +378,7 @@ public:
416 { return span<byte, _Extent * sizeof(element_type)>{reinterpret_cast<byte *>(data()), size_bytes()}; }378 { return span<byte, _Extent * sizeof(element_type)>{reinterpret_cast<byte *>(data()), size_bytes()}; }
417379
418private:380private:
419 pointer __data;381 pointer __data_;
420};382};
421383
422384
...@@ -432,7 +394,7 @@ public:...@@ -432,7 +394,7 @@ public:
432 using const_pointer = const _Tp *;394 using const_pointer = const _Tp *;
433 using reference = _Tp &;395 using reference = _Tp &;
434 using const_reference = const _Tp &;396 using const_reference = const _Tp &;
435#ifdef _LIBCPP_ENABLE_DEBUG_MODE397#ifdef _LIBCPP_DEBUG_ITERATOR_BOUNDS_CHECKING
436 using iterator = __bounded_iter<pointer>;398 using iterator = __bounded_iter<pointer>;
437#else399#else
438 using iterator = __wrap_iter<pointer>;400 using iterator = __wrap_iter<pointer>;
...@@ -442,7 +404,7 @@ public:...@@ -442,7 +404,7 @@ public:
442 static constexpr size_type extent = dynamic_extent;404 static constexpr size_type extent = dynamic_extent;
443405
444// [span.cons], span constructors, copy, assignment, and destructor406// [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
447 constexpr span (const span&) noexcept = default;409 constexpr span (const span&) noexcept = default;
448 constexpr span& operator=(const span&) noexcept = default;410 constexpr span& operator=(const span&) noexcept = default;
...@@ -450,46 +412,35 @@ public:...@@ -450,46 +412,35 @@ public:
450 template <__span_compatible_iterator<element_type> _It>412 template <__span_compatible_iterator<element_type> _It>
451 _LIBCPP_INLINE_VISIBILITY413 _LIBCPP_INLINE_VISIBILITY
452 constexpr span(_It __first, size_type __count)414 constexpr span(_It __first, size_type __count)
453 : __data{_VSTD::to_address(__first)}, __size{__count} {}415 : __data_{_VSTD::to_address(__first)}, __size_{__count} {}
454416
455 template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End>417 template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End>
456 _LIBCPP_INLINE_VISIBILITY constexpr span(_It __first, _End __last)418 _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) {
458 _LIBCPP_ASSERT(__last - __first >= 0, "invalid range in span's constructor (iterator, sentinel)");420 _LIBCPP_ASSERT(__last - __first >= 0, "invalid range in span's constructor (iterator, sentinel)");
459 }421 }
460422
461 template <size_t _Sz>423 template <size_t _Sz>
462 _LIBCPP_INLINE_VISIBILITY424 _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
465 template <__span_array_convertible<element_type> _OtherElementType, size_t _Sz>427 template <__span_array_convertible<element_type> _OtherElementType, size_t _Sz>
466 _LIBCPP_INLINE_VISIBILITY428 _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
469 template <class _OtherElementType, size_t _Sz>431 template <class _OtherElementType, size_t _Sz>
470 requires __span_array_convertible<const _OtherElementType, element_type>432 requires __span_array_convertible<const _OtherElementType, element_type>
471 _LIBCPP_INLINE_VISIBILITY433 _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
484 template <__span_compatible_range<element_type> _Range>436 template <__span_compatible_range<element_type> _Range>
485 _LIBCPP_INLINE_VISIBILITY437 _LIBCPP_INLINE_VISIBILITY
486 constexpr span(_Range&& __r) : __data(ranges::data(__r)), __size{ranges::size(__r)} {}438 constexpr span(_Range&& __r) : __data_(ranges::data(__r)), __size_{ranges::size(__r)} {}
487#endif
488439
489 template <__span_array_convertible<element_type> _OtherElementType, size_t _OtherExtent>440 template <__span_array_convertible<element_type> _OtherElementType, size_t _OtherExtent>
490 _LIBCPP_INLINE_VISIBILITY441 _LIBCPP_INLINE_VISIBILITY
491 constexpr span(const span<_OtherElementType, _OtherExtent>& __other) noexcept442 constexpr span(const span<_OtherElementType, _OtherExtent>& __other) noexcept
492 : __data{__other.data()}, __size{__other.size()} {}443 : __data_{__other.data()}, __size_{__other.size()} {}
493444
494// ~span() noexcept = default;445// ~span() noexcept = default;
495446
...@@ -544,41 +495,41 @@ public:...@@ -544,41 +495,41 @@ public:
544 return {data() + __offset, __count};495 return {data() + __offset, __count};
545 }496 }
546497
547 _LIBCPP_INLINE_VISIBILITY constexpr size_type size() const noexcept { return __size; }498 _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); }499 _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; }500 [[nodiscard]] _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return __size_ == 0; }
550501
551 _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept502 _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept
552 {503 {
553 _LIBCPP_ASSERT(__idx < size(), "span<T>::operator[](index): index out of range");504 _LIBCPP_ASSERT(__idx < size(), "span<T>::operator[](index): index out of range");
554 return __data[__idx];505 return __data_[__idx];
555 }506 }
556507
557 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept508 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
558 {509 {
559 _LIBCPP_ASSERT(!empty(), "span<T>::front() on empty span");510 _LIBCPP_ASSERT(!empty(), "span<T>::front() on empty span");
560 return __data[0];511 return __data_[0];
561 }512 }
562513
563 _LIBCPP_INLINE_VISIBILITY constexpr reference back() const noexcept514 _LIBCPP_INLINE_VISIBILITY constexpr reference back() const noexcept
564 {515 {
565 _LIBCPP_ASSERT(!empty(), "span<T>::back() on empty span");516 _LIBCPP_ASSERT(!empty(), "span<T>::back() on empty span");
566 return __data[size()-1];517 return __data_[size()-1];
567 }518 }
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
572// [span.iter], span iterator support523// [span.iter], span iterator support
573 _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept {524 _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept {
574#ifdef _LIBCPP_ENABLE_DEBUG_MODE525#ifdef _LIBCPP_DEBUG_ITERATOR_BOUNDS_CHECKING
575 return std::__make_bounded_iter(data(), data(), data() + size());526 return std::__make_bounded_iter(data(), data(), data() + size());
576#else527#else
577 return iterator(this, data());528 return iterator(this, data());
578#endif529#endif
579 }530 }
580 _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept {531 _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept {
581#ifdef _LIBCPP_ENABLE_DEBUG_MODE532#ifdef _LIBCPP_DEBUG_ITERATOR_BOUNDS_CHECKING
582 return std::__make_bounded_iter(data() + size(), data(), data() + size());533 return std::__make_bounded_iter(data() + size(), data(), data() + size());
583#else534#else
584 return iterator(this, data() + size());535 return iterator(this, data() + size());
...@@ -594,8 +545,8 @@ public:...@@ -594,8 +545,8 @@ public:
594 { return {reinterpret_cast<byte *>(data()), size_bytes()}; }545 { return {reinterpret_cast<byte *>(data()), size_bytes()}; }
595546
596private:547private:
597 pointer __data;548 pointer __data_;
598 size_type __size;549 size_type __size_;
599};550};
600551
601template <class _Tp, size_t _Extent>552template <class _Tp, size_t _Extent>
...@@ -629,16 +580,8 @@ template<class _Tp, size_t _Sz>...@@ -629,16 +580,8 @@ template<class _Tp, size_t _Sz>
629template<class _Tp, size_t _Sz>580template<class _Tp, size_t _Sz>
630 span(const array<_Tp, _Sz>&) -> span<const _Tp, _Sz>;581 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
639template<ranges::contiguous_range _Range>583template<ranges::contiguous_range _Range>
640 span(_Range&&) -> span<remove_reference_t<ranges::range_reference_t<_Range>>>;584 span(_Range&&) -> span<remove_reference_t<ranges::range_reference_t<_Range>>>;
641#endif
642585
643#endif // _LIBCPP_STD_VER > 17586#endif // _LIBCPP_STD_VER > 17
644587
...@@ -646,4 +589,10 @@ _LIBCPP_END_NAMESPACE_STD...@@ -646,4 +589,10 @@ _LIBCPP_END_NAMESPACE_STD
646589
647_LIBCPP_POP_MACROS590_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
649#endif // _LIBCPP_SPAN598#endif // _LIBCPP_SPAN
lib/libcxx/include/sstream+48-39
...@@ -11,8 +11,9 @@...@@ -11,8 +11,9 @@
11#define _LIBCPP_SSTREAM11#define _LIBCPP_SSTREAM
1212
13/*13/*
14 sstream synopsis14 sstream synopsis [sstream.syn]
1515
16// Class template basic_stringbuf [stringbuf]
16template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >17template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
17class basic_stringbuf18class basic_stringbuf
18 : public basic_streambuf<charT, traits>19 : public basic_streambuf<charT, traits>
...@@ -25,7 +26,7 @@ public:...@@ -25,7 +26,7 @@ public:
25 typedef typename traits_type::off_type off_type;26 typedef typename traits_type::off_type off_type;
26 typedef Allocator allocator_type;27 typedef Allocator allocator_type;
2728
28 // 27.8.1.1 [stringbuf.cons], constructors:29 // [stringbuf.cons] constructors:
29 explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out); // before C++2030 explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out); // before C++20
30 basic_stringbuf() : basic_stringbuf(ios_base::in | ios_base::out) {} // C++2031 basic_stringbuf() : basic_stringbuf(ios_base::in | ios_base::out) {} // C++20
31 explicit basic_stringbuf(ios_base::openmode which); // C++2032 explicit basic_stringbuf(ios_base::openmode which); // C++20
...@@ -33,16 +34,16 @@ public:...@@ -33,16 +34,16 @@ public:
33 ios_base::openmode which = ios_base::in | ios_base::out);34 ios_base::openmode which = ios_base::in | ios_base::out);
34 basic_stringbuf(basic_stringbuf&& rhs);35 basic_stringbuf(basic_stringbuf&& rhs);
3536
36 // 27.8.1.2 Assign and swap:37 // [stringbuf.assign] Assign and swap:
37 basic_stringbuf& operator=(basic_stringbuf&& rhs);38 basic_stringbuf& operator=(basic_stringbuf&& rhs);
38 void swap(basic_stringbuf& rhs);39 void swap(basic_stringbuf& rhs);
3940
40 // 27.8.1.3 Get and set:41 // [stringbuf.members] Member functions:
41 basic_string<char_type, traits_type, allocator_type> str() const;42 basic_string<char_type, traits_type, allocator_type> str() const;
42 void str(const basic_string<char_type, traits_type, allocator_type>& s);43 void str(const basic_string<char_type, traits_type, allocator_type>& s);
4344
44protected:45protected:
45 // 27.8.1.4 Overridden virtual functions:46 // [stringbuf.virtuals] Overridden virtual functions:
46 virtual int_type underflow();47 virtual int_type underflow();
47 virtual int_type pbackfail(int_type c = traits_type::eof());48 virtual int_type pbackfail(int_type c = traits_type::eof());
48 virtual int_type overflow (int_type c = traits_type::eof());49 virtual int_type overflow (int_type c = traits_type::eof());
...@@ -53,6 +54,7 @@ protected:...@@ -53,6 +54,7 @@ protected:
53 ios_base::openmode which = ios_base::in | ios_base::out);54 ios_base::openmode which = ios_base::in | ios_base::out);
54};55};
5556
57// [stringbuf.assign] non member swap
56template <class charT, class traits, class Allocator>58template <class charT, class traits, class Allocator>
57 void swap(basic_stringbuf<charT, traits, Allocator>& x,59 void swap(basic_stringbuf<charT, traits, Allocator>& x,
58 basic_stringbuf<charT, traits, Allocator>& y);60 basic_stringbuf<charT, traits, Allocator>& y);
...@@ -60,6 +62,7 @@ template <class charT, class traits, class Allocator>...@@ -60,6 +62,7 @@ template <class charT, class traits, class Allocator>
60typedef basic_stringbuf<char> stringbuf;62typedef basic_stringbuf<char> stringbuf;
61typedef basic_stringbuf<wchar_t> wstringbuf;63typedef basic_stringbuf<wchar_t> wstringbuf;
6264
65// Class template basic_istringstream [istringstream]
63template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >66template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
64class basic_istringstream67class basic_istringstream
65 : public basic_istream<charT, traits>68 : public basic_istream<charT, traits>
...@@ -72,7 +75,7 @@ public:...@@ -72,7 +75,7 @@ public:
72 typedef typename traits_type::off_type off_type;75 typedef typename traits_type::off_type off_type;
73 typedef Allocator allocator_type;76 typedef Allocator allocator_type;
7477
75 // 27.8.2.1 Constructors:78 // [istringstream.cons] Constructors:
76 explicit basic_istringstream(ios_base::openmode which = ios_base::in); // before C++2079 explicit basic_istringstream(ios_base::openmode which = ios_base::in); // before C++20
77 basic_istringstream() : basic_istringstream(ios_base::in) {} // C++2080 basic_istringstream() : basic_istringstream(ios_base::in) {} // C++20
78 explicit basic_istringstream(ios_base::openmode which); // C++2081 explicit basic_istringstream(ios_base::openmode which); // C++20
...@@ -81,11 +84,11 @@ public:...@@ -81,11 +84,11 @@ public:
81 ios_base::openmode which = ios_base::in);84 ios_base::openmode which = ios_base::in);
82 basic_istringstream(basic_istringstream&& rhs);85 basic_istringstream(basic_istringstream&& rhs);
8386
84 // 27.8.2.2 Assign and swap:87 // [istringstream.assign] Assign and swap:
85 basic_istringstream& operator=(basic_istringstream&& rhs);88 basic_istringstream& operator=(basic_istringstream&& rhs);
86 void swap(basic_istringstream& rhs);89 void swap(basic_istringstream& rhs);
8790
88 // 27.8.2.3 Members:91 // [istringstream.members] Member functions:
89 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;92 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
90 basic_string<char_type, traits_type, allocator_type> str() const;93 basic_string<char_type, traits_type, allocator_type> str() const;
91 void str(const basic_string<char_type, traits_type, allocator_type>& s);94 void str(const basic_string<char_type, traits_type, allocator_type>& s);
...@@ -98,6 +101,7 @@ template <class charT, class traits, class Allocator>...@@ -98,6 +101,7 @@ template <class charT, class traits, class Allocator>
98typedef basic_istringstream<char> istringstream;101typedef basic_istringstream<char> istringstream;
99typedef basic_istringstream<wchar_t> wistringstream;102typedef basic_istringstream<wchar_t> wistringstream;
100103
104// Class template basic_ostringstream [ostringstream]
101template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >105template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
102class basic_ostringstream106class basic_ostringstream
103 : public basic_ostream<charT, traits>107 : public basic_ostream<charT, traits>
...@@ -111,7 +115,7 @@ public:...@@ -111,7 +115,7 @@ public:
111 typedef typename traits_type::off_type off_type;115 typedef typename traits_type::off_type off_type;
112 typedef Allocator allocator_type;116 typedef Allocator allocator_type;
113117
114 // 27.8.3.1 Constructors/destructor:118 // [ostringstream.cons] Constructors:
115 explicit basic_ostringstream(ios_base::openmode which = ios_base::out); // before C++20119 explicit basic_ostringstream(ios_base::openmode which = ios_base::out); // before C++20
116 basic_ostringstream() : basic_ostringstream(ios_base::out) {} // C++20120 basic_ostringstream() : basic_ostringstream(ios_base::out) {} // C++20
117 explicit basic_ostringstream(ios_base::openmode which); // C++20121 explicit basic_ostringstream(ios_base::openmode which); // C++20
...@@ -120,11 +124,11 @@ public:...@@ -120,11 +124,11 @@ public:
120 ios_base::openmode which = ios_base::out);124 ios_base::openmode which = ios_base::out);
121 basic_ostringstream(basic_ostringstream&& rhs);125 basic_ostringstream(basic_ostringstream&& rhs);
122126
123 // 27.8.3.2 Assign/swap:127 // [ostringstream.assign] Assign and swap:
124 basic_ostringstream& operator=(basic_ostringstream&& rhs);128 basic_ostringstream& operator=(basic_ostringstream&& rhs);
125 void swap(basic_ostringstream& rhs);129 void swap(basic_ostringstream& rhs);
126130
127 // 27.8.3.3 Members:131 // [ostringstream.members] Member functions:
128 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;132 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
129 basic_string<char_type, traits_type, allocator_type> str() const;133 basic_string<char_type, traits_type, allocator_type> str() const;
130 void str(const basic_string<char_type, traits_type, allocator_type>& s);134 void str(const basic_string<char_type, traits_type, allocator_type>& s);
...@@ -137,6 +141,7 @@ template <class charT, class traits, class Allocator>...@@ -137,6 +141,7 @@ template <class charT, class traits, class Allocator>
137typedef basic_ostringstream<char> ostringstream;141typedef basic_ostringstream<char> ostringstream;
138typedef basic_ostringstream<wchar_t> wostringstream;142typedef basic_ostringstream<wchar_t> wostringstream;
139143
144// Class template basic_stringstream [stringstream]
140template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >145template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
141class basic_stringstream146class basic_stringstream
142 : public basic_iostream<charT, traits>147 : public basic_iostream<charT, traits>
...@@ -150,7 +155,7 @@ public:...@@ -150,7 +155,7 @@ public:
150 typedef typename traits_type::off_type off_type;155 typedef typename traits_type::off_type off_type;
151 typedef Allocator allocator_type;156 typedef Allocator allocator_type;
152157
153 // constructors/destructor158 // [stringstream.cons] constructors
154 explicit basic_stringstream(ios_base::openmode which = ios_base::out | ios_base::in); // before C++20159 explicit basic_stringstream(ios_base::openmode which = ios_base::out | ios_base::in); // before C++20
155 basic_stringstream() : basic_stringstream(ios_base::out | ios_base::in) {} // C++20160 basic_stringstream() : basic_stringstream(ios_base::out | ios_base::in) {} // C++20
156 explicit basic_stringstream(ios_base::openmode which); // C++20161 explicit basic_stringstream(ios_base::openmode which); // C++20
...@@ -159,11 +164,11 @@ public:...@@ -159,11 +164,11 @@ public:
159 ios_base::openmode which = ios_base::out|ios_base::in);164 ios_base::openmode which = ios_base::out|ios_base::in);
160 basic_stringstream(basic_stringstream&& rhs);165 basic_stringstream(basic_stringstream&& rhs);
161166
162 // 27.8.5.1 Assign/swap:167 // [stringstream.assign] Assign and swap:
163 basic_stringstream& operator=(basic_stringstream&& rhs);168 basic_stringstream& operator=(basic_stringstream&& rhs);
164 void swap(basic_stringstream& rhs);169 void swap(basic_stringstream& rhs);
165170
166 // Members:171 // [stringstream.members] Member functions:
167 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;172 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
168 basic_string<char_type, traits_type, allocator_type> str() const;173 basic_string<char_type, traits_type, allocator_type> str() const;
169 void str(const basic_string<char_type, traits_type, allocator_type>& str);174 void str(const basic_string<char_type, traits_type, allocator_type>& str);
...@@ -198,7 +203,7 @@ _LIBCPP_PUSH_MACROS...@@ -198,7 +203,7 @@ _LIBCPP_PUSH_MACROS
198203
199_LIBCPP_BEGIN_NAMESPACE_STD204_LIBCPP_BEGIN_NAMESPACE_STD
200205
201// basic_stringbuf206// Class template basic_stringbuf [stringbuf]
202207
203template <class _CharT, class _Traits, class _Allocator>208template <class _CharT, class _Traits, class _Allocator>
204class _LIBCPP_TEMPLATE_VIS basic_stringbuf209class _LIBCPP_TEMPLATE_VIS basic_stringbuf
...@@ -221,7 +226,7 @@ private:...@@ -221,7 +226,7 @@ private:
221 ios_base::openmode __mode_;226 ios_base::openmode __mode_;
222227
223public:228public:
224 // 30.8.2.1 [stringbuf.cons], constructors229 // [stringbuf.cons] constructors:
225 _LIBCPP_INLINE_VISIBILITY230 _LIBCPP_INLINE_VISIBILITY
226 basic_stringbuf()231 basic_stringbuf()
227 : __hm_(nullptr), __mode_(ios_base::in | ios_base::out) {}232 : __hm_(nullptr), __mode_(ios_base::in | ios_base::out) {}
...@@ -240,24 +245,24 @@ public:...@@ -240,24 +245,24 @@ public:
240245
241 basic_stringbuf(basic_stringbuf&& __rhs);246 basic_stringbuf(basic_stringbuf&& __rhs);
242247
243 // 27.8.1.2 Assign and swap:248 // [stringbuf.assign] Assign and swap:
244 basic_stringbuf& operator=(basic_stringbuf&& __rhs);249 basic_stringbuf& operator=(basic_stringbuf&& __rhs);
245 void swap(basic_stringbuf& __rhs);250 void swap(basic_stringbuf& __rhs);
246251
247 // 27.8.1.3 Get and set:252 // [stringbuf.members] Member functions:
248 string_type str() const;253 string_type str() const;
249 void str(const string_type& __s);254 void str(const string_type& __s);
250255
251protected:256protected:
252 // 27.8.1.4 Overridden virtual functions:257 // [stringbuf.virtuals] Overridden virtual functions:
253 virtual int_type underflow();258 int_type underflow() override;
254 virtual int_type pbackfail(int_type __c = traits_type::eof());259 int_type pbackfail(int_type __c = traits_type::eof()) override;
255 virtual int_type overflow (int_type __c = traits_type::eof());260 int_type overflow (int_type __c = traits_type::eof()) override;
256 virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,261 pos_type seekoff(off_type __off, ios_base::seekdir __way,
257 ios_base::openmode __wch = ios_base::in | ios_base::out);262 ios_base::openmode __wch = ios_base::in | ios_base::out) override;
258 _LIBCPP_INLINE_VISIBILITY263 _LIBCPP_HIDE_FROM_ABI_VIRTUAL
259 virtual pos_type seekpos(pos_type __sp,264 pos_type seekpos(pos_type __sp,
260 ios_base::openmode __wch = ios_base::in | ios_base::out) {265 ios_base::openmode __wch = ios_base::in | ios_base::out) override {
261 return seekoff(__sp, ios_base::beg, __wch);266 return seekoff(__sp, ios_base::beg, __wch);
262 }267 }
263};268};
...@@ -619,7 +624,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off,...@@ -619,7 +624,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off,
619 return pos_type(__noff);624 return pos_type(__noff);
620}625}
621626
622// basic_istringstream627// Class template basic_istringstream [istringstream]
623628
624template <class _CharT, class _Traits, class _Allocator>629template <class _CharT, class _Traits, class _Allocator>
625class _LIBCPP_TEMPLATE_VIS basic_istringstream630class _LIBCPP_TEMPLATE_VIS basic_istringstream
...@@ -639,7 +644,7 @@ private:...@@ -639,7 +644,7 @@ private:
639 basic_stringbuf<char_type, traits_type, allocator_type> __sb_;644 basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
640645
641public:646public:
642 // 30.8.3.1 [istringstream.cons], constructors647 // [istringstream.cons] Constructors:
643 _LIBCPP_INLINE_VISIBILITY648 _LIBCPP_INLINE_VISIBILITY
644 basic_istringstream()649 basic_istringstream()
645 : basic_istream<_CharT, _Traits>(&__sb_), __sb_(ios_base::in) {}650 : basic_istream<_CharT, _Traits>(&__sb_), __sb_(ios_base::in) {}
...@@ -663,7 +668,7 @@ public:...@@ -663,7 +668,7 @@ public:
663 basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);668 basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
664 }669 }
665670
666 // 27.8.2.2 Assign and swap:671 // [istringstream.assign] Assign and swap:
667 basic_istringstream& operator=(basic_istringstream&& __rhs) {672 basic_istringstream& operator=(basic_istringstream&& __rhs) {
668 basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs));673 basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
669 __sb_ = _VSTD::move(__rhs.__sb_);674 __sb_ = _VSTD::move(__rhs.__sb_);
...@@ -675,7 +680,7 @@ public:...@@ -675,7 +680,7 @@ public:
675 __sb_.swap(__rhs.__sb_);680 __sb_.swap(__rhs.__sb_);
676 }681 }
677682
678 // 27.8.2.3 Members:683 // [istringstream.members] Member functions:
679 _LIBCPP_INLINE_VISIBILITY684 _LIBCPP_INLINE_VISIBILITY
680 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {685 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
681 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);686 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
...@@ -699,7 +704,7 @@ swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x,...@@ -699,7 +704,7 @@ swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x,
699 __x.swap(__y);704 __x.swap(__y);
700}705}
701706
702// basic_ostringstream707// Class template basic_ostringstream [ostringstream]
703708
704template <class _CharT, class _Traits, class _Allocator>709template <class _CharT, class _Traits, class _Allocator>
705class _LIBCPP_TEMPLATE_VIS basic_ostringstream710class _LIBCPP_TEMPLATE_VIS basic_ostringstream
...@@ -719,7 +724,7 @@ private:...@@ -719,7 +724,7 @@ private:
719 basic_stringbuf<char_type, traits_type, allocator_type> __sb_;724 basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
720725
721public:726public:
722 // 30.8.4.1 [ostringstream.cons], constructors727 // [ostringstream.cons] Constructors:
723 _LIBCPP_INLINE_VISIBILITY728 _LIBCPP_INLINE_VISIBILITY
724 basic_ostringstream()729 basic_ostringstream()
725 : basic_ostream<_CharT, _Traits>(&__sb_), __sb_(ios_base::out) {}730 : basic_ostream<_CharT, _Traits>(&__sb_), __sb_(ios_base::out) {}
...@@ -743,7 +748,7 @@ public:...@@ -743,7 +748,7 @@ public:
743 basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_);748 basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_);
744 }749 }
745750
746 // 27.8.2.2 Assign and swap:751 // [ostringstream.assign] Assign and swap:
747 basic_ostringstream& operator=(basic_ostringstream&& __rhs) {752 basic_ostringstream& operator=(basic_ostringstream&& __rhs) {
748 basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));753 basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
749 __sb_ = _VSTD::move(__rhs.__sb_);754 __sb_ = _VSTD::move(__rhs.__sb_);
...@@ -756,7 +761,7 @@ public:...@@ -756,7 +761,7 @@ public:
756 __sb_.swap(__rhs.__sb_);761 __sb_.swap(__rhs.__sb_);
757 }762 }
758763
759 // 27.8.2.3 Members:764 // [ostringstream.members] Member functions:
760 _LIBCPP_INLINE_VISIBILITY765 _LIBCPP_INLINE_VISIBILITY
761 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {766 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
762 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);767 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
...@@ -780,7 +785,7 @@ swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x,...@@ -780,7 +785,7 @@ swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x,
780 __x.swap(__y);785 __x.swap(__y);
781}786}
782787
783// basic_stringstream788// Class template basic_stringstream [stringstream]
784789
785template <class _CharT, class _Traits, class _Allocator>790template <class _CharT, class _Traits, class _Allocator>
786class _LIBCPP_TEMPLATE_VIS basic_stringstream791class _LIBCPP_TEMPLATE_VIS basic_stringstream
...@@ -800,7 +805,7 @@ private:...@@ -800,7 +805,7 @@ private:
800 basic_stringbuf<char_type, traits_type, allocator_type> __sb_;805 basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
801806
802public:807public:
803 // 30.8.5.1 [stringstream.cons], constructors808 // [stringstream.cons] constructors
804 _LIBCPP_INLINE_VISIBILITY809 _LIBCPP_INLINE_VISIBILITY
805 basic_stringstream()810 basic_stringstream()
806 : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(ios_base::in | ios_base::out) {}811 : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(ios_base::in | ios_base::out) {}
...@@ -824,7 +829,7 @@ public:...@@ -824,7 +829,7 @@ public:
824 basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);829 basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
825 }830 }
826831
827 // 27.8.2.2 Assign and swap:832 // [stringstream.assign] Assign and swap:
828 basic_stringstream& operator=(basic_stringstream&& __rhs) {833 basic_stringstream& operator=(basic_stringstream&& __rhs) {
829 basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));834 basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
830 __sb_ = _VSTD::move(__rhs.__sb_);835 __sb_ = _VSTD::move(__rhs.__sb_);
...@@ -836,7 +841,7 @@ public:...@@ -836,7 +841,7 @@ public:
836 __sb_.swap(__rhs.__sb_);841 __sb_.swap(__rhs.__sb_);
837 }842 }
838843
839 // 27.8.2.3 Members:844 // [stringstream.members] Member functions:
840 _LIBCPP_INLINE_VISIBILITY845 _LIBCPP_INLINE_VISIBILITY
841 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {846 basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const {
842 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);847 return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
...@@ -871,4 +876,8 @@ _LIBCPP_END_NAMESPACE_STD...@@ -871,4 +876,8 @@ _LIBCPP_END_NAMESPACE_STD
871876
872_LIBCPP_POP_MACROS877_LIBCPP_POP_MACROS
873878
879#if _LIBCPP_STD_VER <= 20 && !defined(_LIPCPP_REMOVE_TRANSITIVE_INCLUDES)
880# include <type_traits>
881#endif
882
874#endif // _LIBCPP_SSTREAM883#endif // _LIBCPP_SSTREAM
lib/libcxx/include/stack+9-4
...@@ -107,11 +107,9 @@ template <class T, class Container>...@@ -107,11 +107,9 @@ template <class T, class Container>
107#include <type_traits>107#include <type_traits>
108#include <version>108#include <version>
109109
110#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
111# include <functional>
112#endif
113
114// standard-mandated includes110// standard-mandated includes
111
112// [stack.syn]
115#include <compare>113#include <compare>
116#include <initializer_list>114#include <initializer_list>
117115
...@@ -257,6 +255,8 @@ public:...@@ -257,6 +255,8 @@ public:
257 swap(c, __s.c);255 swap(c, __s.c);
258 }256 }
259257
258 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
259
260 template <class T1, class _C1>260 template <class T1, class _C1>
261 friend261 friend
262 bool262 bool
...@@ -363,4 +363,9 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator<stack<_Tp, _Container>, _Alloc>...@@ -363,4 +363,9 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator<stack<_Tp, _Container>, _Alloc>
363363
364_LIBCPP_END_NAMESPACE_STD364_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
366#endif // _LIBCPP_STACK371#endif // _LIBCPP_STACK
lib/libcxx/include/stdbool.h+4-1
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//7//
8//===----------------------------------------------------------------------===//8//===----------------------------------------------------------------------===//
9
9#ifndef _LIBCPP_STDBOOL_H10#ifndef _LIBCPP_STDBOOL_H
10#define _LIBCPP_STDBOOL_H11#define _LIBCPP_STDBOOL_H
1112
...@@ -24,7 +25,9 @@ Macros:...@@ -24,7 +25,9 @@ Macros:
24# pragma GCC system_header25# pragma GCC system_header
25#endif26#endif
2627
27#include_next <stdbool.h>28#if __has_include_next(<stdbool.h>)
29# include_next <stdbool.h>
30#endif
2831
29#ifdef __cplusplus32#ifdef __cplusplus
30#undef bool33#undef bool
lib/libcxx/include/stddef.h+3-1
...@@ -42,7 +42,9 @@ Types:...@@ -42,7 +42,9 @@ Types:
42# pragma GCC system_header42# pragma GCC system_header
43#endif43#endif
4444
45#include_next <stddef.h>45# if __has_include_next(<stddef.h>)
46# include_next <stddef.h>
47# endif
4648
47#ifdef __cplusplus49#ifdef __cplusplus
48 typedef decltype(nullptr) nullptr_t;50 typedef decltype(nullptr) nullptr_t;
lib/libcxx/include/stdexcept+11-11
...@@ -87,9 +87,9 @@ public:...@@ -87,9 +87,9 @@ public:
87 logic_error(const logic_error&) _NOEXCEPT;87 logic_error(const logic_error&) _NOEXCEPT;
88 logic_error& operator=(const logic_error&) _NOEXCEPT;88 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;
93#else93#else
94public:94public:
95 explicit logic_error(const _VSTD::string&); // Symbol uses versioned std::string95 explicit logic_error(const _VSTD::string&); // Symbol uses versioned std::string
...@@ -110,9 +110,9 @@ public:...@@ -110,9 +110,9 @@ public:
110 runtime_error(const runtime_error&) _NOEXCEPT;110 runtime_error(const runtime_error&) _NOEXCEPT;
111 runtime_error& operator=(const runtime_error&) _NOEXCEPT;111 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;
116#else116#else
117public:117public:
118 explicit runtime_error(const _VSTD::string&); // Symbol uses versioned std::string118 explicit runtime_error(const _VSTD::string&); // Symbol uses versioned std::string
...@@ -129,7 +129,7 @@ public:...@@ -129,7 +129,7 @@ public:
129129
130#ifndef _LIBCPP_ABI_VCRUNTIME130#ifndef _LIBCPP_ABI_VCRUNTIME
131 domain_error(const domain_error&) _NOEXCEPT = default;131 domain_error(const domain_error&) _NOEXCEPT = default;
132 virtual ~domain_error() _NOEXCEPT;132 ~domain_error() _NOEXCEPT override;
133#endif133#endif
134};134};
135135
...@@ -142,7 +142,7 @@ public:...@@ -142,7 +142,7 @@ public:
142142
143#ifndef _LIBCPP_ABI_VCRUNTIME143#ifndef _LIBCPP_ABI_VCRUNTIME
144 invalid_argument(const invalid_argument&) _NOEXCEPT = default;144 invalid_argument(const invalid_argument&) _NOEXCEPT = default;
145 virtual ~invalid_argument() _NOEXCEPT;145 ~invalid_argument() _NOEXCEPT override;
146#endif146#endif
147};147};
148148
...@@ -154,7 +154,7 @@ public:...@@ -154,7 +154,7 @@ public:
154 _LIBCPP_INLINE_VISIBILITY explicit length_error(const char* __s) : logic_error(__s) {}154 _LIBCPP_INLINE_VISIBILITY explicit length_error(const char* __s) : logic_error(__s) {}
155#ifndef _LIBCPP_ABI_VCRUNTIME155#ifndef _LIBCPP_ABI_VCRUNTIME
156 length_error(const length_error&) _NOEXCEPT = default;156 length_error(const length_error&) _NOEXCEPT = default;
157 virtual ~length_error() _NOEXCEPT;157 ~length_error() _NOEXCEPT override;
158#endif158#endif
159};159};
160160
...@@ -167,7 +167,7 @@ public:...@@ -167,7 +167,7 @@ public:
167167
168#ifndef _LIBCPP_ABI_VCRUNTIME168#ifndef _LIBCPP_ABI_VCRUNTIME
169 out_of_range(const out_of_range&) _NOEXCEPT = default;169 out_of_range(const out_of_range&) _NOEXCEPT = default;
170 virtual ~out_of_range() _NOEXCEPT;170 ~out_of_range() _NOEXCEPT override;
171#endif171#endif
172};172};
173173
...@@ -180,7 +180,7 @@ public:...@@ -180,7 +180,7 @@ public:
180180
181#ifndef _LIBCPP_ABI_VCRUNTIME181#ifndef _LIBCPP_ABI_VCRUNTIME
182 range_error(const range_error&) _NOEXCEPT = default;182 range_error(const range_error&) _NOEXCEPT = default;
183 virtual ~range_error() _NOEXCEPT;183 ~range_error() _NOEXCEPT override;
184#endif184#endif
185};185};
186186
...@@ -193,7 +193,7 @@ public:...@@ -193,7 +193,7 @@ public:
193193
194#ifndef _LIBCPP_ABI_VCRUNTIME194#ifndef _LIBCPP_ABI_VCRUNTIME
195 overflow_error(const overflow_error&) _NOEXCEPT = default;195 overflow_error(const overflow_error&) _NOEXCEPT = default;
196 virtual ~overflow_error() _NOEXCEPT;196 ~overflow_error() _NOEXCEPT override;
197#endif197#endif
198};198};
199199
...@@ -206,7 +206,7 @@ public:...@@ -206,7 +206,7 @@ public:
206206
207#ifndef _LIBCPP_ABI_VCRUNTIME207#ifndef _LIBCPP_ABI_VCRUNTIME
208 underflow_error(const underflow_error&) _NOEXCEPT = default;208 underflow_error(const underflow_error&) _NOEXCEPT = default;
209 virtual ~underflow_error() _NOEXCEPT;209 ~underflow_error() _NOEXCEPT override;
210#endif210#endif
211};211};
212212
lib/libcxx/include/stdint.h+3-1
...@@ -120,6 +120,8 @@ Macros:...@@ -120,6 +120,8 @@ Macros:
120# define __STDC_CONSTANT_MACROS120# define __STDC_CONSTANT_MACROS
121#endif121#endif
122122
123#include_next <stdint.h>123#if __has_include_next(<stdint.h>)
124# include_next <stdint.h>
125#endif
124126
125#endif // _LIBCPP_STDINT_H127#endif // _LIBCPP_STDINT_H
lib/libcxx/include/stdio.h+3-1
...@@ -104,7 +104,9 @@ void perror(const char* s);...@@ -104,7 +104,9 @@ void perror(const char* s);
104# pragma GCC system_header104# pragma GCC system_header
105#endif105#endif
106106
107#include_next <stdio.h>107# if __has_include_next(<stdio.h>)
108# include_next <stdio.h>
109# endif
108110
109#ifdef __cplusplus111#ifdef __cplusplus
110112
lib/libcxx/include/stdlib.h+8-6
...@@ -90,7 +90,9 @@ void *aligned_alloc(size_t alignment, size_t size); // C11...@@ -90,7 +90,9 @@ void *aligned_alloc(size_t alignment, size_t size); // C11
90# pragma GCC system_header90# pragma GCC system_header
91#endif91#endif
9292
93#include_next <stdlib.h>93# if __has_include_next(<stdlib.h>)
94# include_next <stdlib.h>
95# endif
9496
95#ifdef __cplusplus97#ifdef __cplusplus
96extern "C++" {98extern "C++" {
...@@ -108,24 +110,24 @@ extern "C++" {...@@ -108,24 +110,24 @@ extern "C++" {
108110
109// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined111// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
110#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__)112#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 {
112 return __builtin_labs(__x);114 return __builtin_labs(__x);
113}115}
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 {
115 return __builtin_llabs(__x);117 return __builtin_llabs(__x);
116}118}
117#endif // !defined(_LIBCPP_MSVCRT) && !defined(__sun__)119#endif // !defined(_LIBCPP_MSVCRT) && !defined(__sun__)
118120
119#if !defined(__sun__)121#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 {
121 return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h123 return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h
122}124}
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 {
125 return __builtin_fabs(__lcpp_x);127 return __builtin_fabs(__lcpp_x);
126}128}
127129
128inline _LIBCPP_INLINE_VISIBILITY long double130_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY long double
129abs(long double __lcpp_x) _NOEXCEPT {131abs(long double __lcpp_x) _NOEXCEPT {
130 return __builtin_fabsl(__lcpp_x);132 return __builtin_fabsl(__lcpp_x);
131}133}
lib/libcxx/include/streambuf+4-2
...@@ -489,10 +489,12 @@ basic_streambuf<_CharT, _Traits>::overflow(int_type)...@@ -489,10 +489,12 @@ basic_streambuf<_CharT, _Traits>::overflow(int_type)
489}489}
490490
491extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>;491extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>;
492extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>;
493
494extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>;492extern 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>;
495extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>;496extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>;
497#endif
496498
497_LIBCPP_END_NAMESPACE_STD499_LIBCPP_END_NAMESPACE_STD
498500
lib/libcxx/include/string+777-860
...@@ -13,6 +13,9 @@...@@ -13,6 +13,9 @@
13/*13/*
14 string synopsis14 string synopsis
1515
16#include <compare>
17#include <initializer_list>
18
16namespace std19namespace std
17{20{
1821
...@@ -43,11 +46,13 @@ template <class stateT> bool operator!=(const fpos<stateT>& x, const fpos<stateT...@@ -43,11 +46,13 @@ template <class stateT> bool operator!=(const fpos<stateT>& x, const fpos<stateT
43template <class charT>46template <class charT>
44struct char_traits47struct char_traits
45{48{
46 typedef charT char_type;49 using char_type = charT;
47 typedef ... int_type;50 using int_type = ...;
48 typedef streamoff off_type;51 using off_type = streamoff;
49 typedef streampos pos_type;52 using pos_type = streampos;
50 typedef mbstate_t state_type;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
52 static void assign(char_type& c1, const char_type& c2) noexcept;57 static void assign(char_type& c1, const char_type& c2) noexcept;
53 static constexpr bool eq(char_type c1, char_type c2) noexcept;58 static constexpr bool eq(char_type c1, char_type c2) noexcept;
...@@ -104,6 +109,10 @@ public:...@@ -104,6 +109,10 @@ public:
104 const allocator_type& a = allocator_type()); // constexpr since C++20109 const allocator_type& a = allocator_type()); // constexpr since C++20
105 basic_string(const basic_string& str, size_type pos, size_type n,110 basic_string(const basic_string& str, size_type pos, size_type n,
106 const Allocator& a = Allocator()); // constexpr since C++20111 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
107 template<class T>116 template<class T>
108 basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator()); // C++17, constexpr since C++20117 basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator()); // C++17, constexpr since C++20
109 template <class T>118 template <class T>
...@@ -256,8 +265,9 @@ public:...@@ -256,8 +265,9 @@ public:
256 basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<value_type>); // constexpr since C++20265 basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<value_type>); // constexpr since C++20
257266
258 size_type copy(value_type* s, size_type n, size_type pos = 0) const; // constexpr since C++20267 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++20268 basic_string substr(size_type pos = 0, size_type n = npos) const; // constexpr in C++20, removed in C++23
260269 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
261 void swap(basic_string& str)271 void swap(basic_string& str)
262 noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||272 noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
263 allocator_traits<allocator_type>::is_always_equal::value); // C++17, constexpr since C++20273 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,...@@ -370,60 +380,68 @@ bool operator==(const basic_string<charT, traits, Allocator>& lhs,
370 const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20380 const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
371381
372template<class charT, class traits, class Allocator>382template<class charT, class traits, class Allocator>
373bool operator==(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20383bool operator==(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
374384
375template<class charT, class traits, class Allocator>385template<class charT, class traits, class Allocator>
376bool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20386bool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20
377387
378template<class charT, class traits, class Allocator>388template<class charT, class traits, class Allocator>
379bool operator!=(const basic_string<charT,traits,Allocator>& lhs,389bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
380 const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20390 const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
381391
382template<class charT, class traits, class Allocator>392template<class charT, class traits, class Allocator>
383bool operator!=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20393bool operator!=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
384394
385template<class charT, class traits, class Allocator>395template<class charT, class traits, class Allocator>
386bool operator!=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20396bool operator!=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // removed in C++20
387397
388template<class charT, class traits, class Allocator>398template<class charT, class traits, class Allocator>
389bool operator< (const basic_string<charT, traits, Allocator>& lhs,399bool operator< (const basic_string<charT, traits, Allocator>& lhs,
390 const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20400 const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
391401
392template<class charT, class traits, class Allocator>402template<class charT, class traits, class Allocator>
393bool operator< (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20403bool operator< (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // removed in C++20
394404
395template<class charT, class traits, class Allocator>405template<class charT, class traits, class Allocator>
396bool operator< (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20406bool operator< (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
397407
398template<class charT, class traits, class Allocator>408template<class charT, class traits, class Allocator>
399bool operator> (const basic_string<charT, traits, Allocator>& lhs,409bool operator> (const basic_string<charT, traits, Allocator>& lhs,
400 const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20410 const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
401411
402template<class charT, class traits, class Allocator>412template<class charT, class traits, class Allocator>
403bool operator> (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20413bool operator> (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // removed in C++20
404414
405template<class charT, class traits, class Allocator>415template<class charT, class traits, class Allocator>
406bool operator> (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20416bool operator> (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
407417
408template<class charT, class traits, class Allocator>418template<class charT, class traits, class Allocator>
409bool operator<=(const basic_string<charT, traits, Allocator>& lhs,419bool operator<=(const basic_string<charT, traits, Allocator>& lhs,
410 const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20420 const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
411421
412template<class charT, class traits, class Allocator>422template<class charT, class traits, class Allocator>
413bool operator<=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20423bool operator<=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // removed in C++20
414424
415template<class charT, class traits, class Allocator>425template<class charT, class traits, class Allocator>
416bool operator<=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20426bool operator<=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
417427
418template<class charT, class traits, class Allocator>428template<class charT, class traits, class Allocator>
419bool operator>=(const basic_string<charT, traits, Allocator>& lhs,429bool operator>=(const basic_string<charT, traits, Allocator>& lhs,
420 const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20430 const basic_string<charT, traits, Allocator>& rhs) noexcept; // removed in C++20
421431
422template<class charT, class traits, class Allocator>432template<class charT, class traits, class Allocator>
423bool operator>=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20433bool operator>=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // removed in C++20
424434
425template<class charT, class traits, class Allocator>435template<class charT, class traits, class Allocator>
426bool operator>=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20436bool 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
428template<class charT, class traits, class Allocator>446template<class charT, class traits, class Allocator>
429void swap(basic_string<charT, traits, Allocator>& lhs,447void swap(basic_string<charT, traits, Allocator>& lhs,
...@@ -526,15 +544,24 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len );...@@ -526,15 +544,24 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len );
526#include <__format/enable_insertable.h>544#include <__format/enable_insertable.h>
527#include <__functional/hash.h>545#include <__functional/hash.h>
528#include <__functional/unary_function.h>546#include <__functional/unary_function.h>
547#include <__fwd/string.h>
529#include <__ios/fpos.h>548#include <__ios/fpos.h>
530#include <__iterator/distance.h>549#include <__iterator/distance.h>
531#include <__iterator/iterator_traits.h>550#include <__iterator/iterator_traits.h>
532#include <__iterator/reverse_iterator.h>551#include <__iterator/reverse_iterator.h>
533#include <__iterator/wrap_iter.h>552#include <__iterator/wrap_iter.h>
534#include <__memory/allocate_at_least.h>553#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>
535#include <__memory/swap_allocator.h>559#include <__memory/swap_allocator.h>
560#include <__memory_resource/polymorphic_allocator.h>
536#include <__string/char_traits.h>561#include <__string/char_traits.h>
537#include <__string/extern_template_lists.h>562#include <__string/extern_template_lists.h>
563#include <__type_traits/is_allocator.h>
564#include <__type_traits/noexcept_move_assign_container.h>
538#include <__utility/auto_cast.h>565#include <__utility/auto_cast.h>
539#include <__utility/move.h>566#include <__utility/move.h>
540#include <__utility/swap.h>567#include <__utility/swap.h>
...@@ -544,9 +571,7 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len );...@@ -544,9 +571,7 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len );
544#include <cstdio> // EOF571#include <cstdio> // EOF
545#include <cstdlib>572#include <cstdlib>
546#include <cstring>573#include <cstring>
547#include <iosfwd>
548#include <limits>574#include <limits>
549#include <memory>
550#include <stdexcept>575#include <stdexcept>
551#include <string_view>576#include <string_view>
552#include <type_traits>577#include <type_traits>
...@@ -556,16 +581,6 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len );...@@ -556,16 +581,6 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len );
556# include <cwchar>581# include <cwchar>
557#endif582#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
569// standard-mandated includes584// standard-mandated includes
570585
571// [iterator.range]586// [iterator.range]
...@@ -593,27 +608,27 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -593,27 +608,27 @@ _LIBCPP_BEGIN_NAMESPACE_STD
593608
594template<class _CharT, class _Traits, class _Allocator>609template<class _CharT, class _Traits, class _Allocator>
595basic_string<_CharT, _Traits, _Allocator>610basic_string<_CharT, _Traits, _Allocator>
596_LIBCPP_CONSTEXPR_AFTER_CXX17611_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
597operator+(const basic_string<_CharT, _Traits, _Allocator>& __x,612operator+(const basic_string<_CharT, _Traits, _Allocator>& __x,
598 const basic_string<_CharT, _Traits, _Allocator>& __y);613 const basic_string<_CharT, _Traits, _Allocator>& __y);
599614
600template<class _CharT, class _Traits, class _Allocator>615template<class _CharT, class _Traits, class _Allocator>
601_LIBCPP_CONSTEXPR_AFTER_CXX17616_LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX20
602basic_string<_CharT, _Traits, _Allocator>617basic_string<_CharT, _Traits, _Allocator>
603operator+(const _CharT* __x, const basic_string<_CharT,_Traits,_Allocator>& __y);618operator+(const _CharT* __x, const basic_string<_CharT,_Traits,_Allocator>& __y);
604619
605template<class _CharT, class _Traits, class _Allocator>620template<class _CharT, class _Traits, class _Allocator>
606_LIBCPP_CONSTEXPR_AFTER_CXX17621_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
607basic_string<_CharT, _Traits, _Allocator>622basic_string<_CharT, _Traits, _Allocator>
608operator+(_CharT __x, const basic_string<_CharT,_Traits,_Allocator>& __y);623operator+(_CharT __x, const basic_string<_CharT,_Traits,_Allocator>& __y);
609624
610template<class _CharT, class _Traits, class _Allocator>625template<class _CharT, class _Traits, class _Allocator>
611inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17626inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
612basic_string<_CharT, _Traits, _Allocator>627basic_string<_CharT, _Traits, _Allocator>
613operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const _CharT* __y);628operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const _CharT* __y);
614629
615template<class _CharT, class _Traits, class _Allocator>630template<class _CharT, class _Traits, class _Allocator>
616_LIBCPP_CONSTEXPR_AFTER_CXX17631_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
617basic_string<_CharT, _Traits, _Allocator>632basic_string<_CharT, _Traits, _Allocator>
618operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y);633operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y);
619634
...@@ -636,23 +651,10 @@ struct __can_be_converted_to_string_view : public _BoolConstant<...@@ -636,23 +651,10 @@ struct __can_be_converted_to_string_view : public _BoolConstant<
636 !is_convertible<const _Tp&, const _CharT*>::value651 !is_convertible<const _Tp&, const _CharT*>::value
637 > {};652 > {};
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
645struct __uninitialized_size_tag {};654struct __uninitialized_size_tag {};
646655
647template<class _CharT, class _Traits, class _Allocator>656template<class _CharT, class _Traits, class _Allocator>
648class657class basic_string
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
656{658{
657public:659public:
658 typedef basic_string __self;660 typedef basic_string __self;
...@@ -676,6 +678,11 @@ public:...@@ -676,6 +678,11 @@ public:
676 static_assert(( is_same<typename allocator_type::value_type, value_type>::value),678 static_assert(( is_same<typename allocator_type::value_type, value_type>::value),
677 "Allocator::value_type must be same type as value_type");679 "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.
679 typedef __wrap_iter<pointer> iterator;686 typedef __wrap_iter<pointer> iterator;
680 typedef __wrap_iter<const_pointer> const_iterator;687 typedef __wrap_iter<const_pointer> const_iterator;
681 typedef std::reverse_iterator<iterator> reverse_iterator;688 typedef std::reverse_iterator<iterator> reverse_iterator;
...@@ -787,13 +794,13 @@ private:...@@ -787,13 +794,13 @@ private:
787 // Construct a string with the given allocator and enough storage to hold `__size` characters, but794 // Construct a string with the given allocator and enough storage to hold `__size` characters, but
788 // don't initialize the characters. The contents of the string, including the null terminator, must be795 // don't initialize the characters. The contents of the string, including the null terminator, must be
789 // initialized separately.796 // initialized separately.
790 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17797 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
791 explicit basic_string(__uninitialized_size_tag, size_type __size, const allocator_type& __a)798 explicit basic_string(__uninitialized_size_tag, size_type __size, const allocator_type& __a)
792 : __r_(__default_init_tag(), __a) {799 : __r_(__default_init_tag(), __a) {
793 if (__size > max_size())800 if (__size > max_size())
794 __throw_length_error();801 __throw_length_error();
795 if (__fits_in_sso(__size)) {802 if (__fits_in_sso(__size)) {
796 __zero();803 __r_.first() = __rep();
797 __set_short_size(__size);804 __set_short_size(__size);
798 } else {805 } else {
799 auto __capacity = __recommend(__size) + 1;806 auto __capacity = __recommend(__size) + 1;
...@@ -806,176 +813,289 @@ private:...@@ -806,176 +813,289 @@ private:
806 std::__debug_db_insert_c(this);813 std::__debug_db_insert_c(this);
807 }814 }
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
809public:824public:
810 _LIBCPP_TEMPLATE_DATA_VIS825 _LIBCPP_TEMPLATE_DATA_VIS static const size_type npos = -1;
811 static const size_type npos = -1;
812826
813 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string()827 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string()
814 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);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)
817#if _LIBCPP_STD_VER <= 14835#if _LIBCPP_STD_VER <= 14
818 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);836 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
819#else837#else
820 _NOEXCEPT;838 _NOEXCEPT
821#endif839#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);845 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const basic_string& __str);
824 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(const basic_string& __str, const allocator_type& __a);846 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const basic_string& __str, const allocator_type& __a);
825847
826#ifndef _LIBCPP_CXX03_LANG848#ifndef _LIBCPP_CXX03_LANG
827 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17849 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(basic_string&& __str)
828 basic_string(basic_string&& __str)850# if _LIBCPP_STD_VER <= 14
829#if _LIBCPP_STD_VER <= 14851 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
830 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);852# else
831#else853 _NOEXCEPT
832 _NOEXCEPT;854# endif
833#endif855 : __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_CXX17862 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(basic_string&& __str, const allocator_type& __a)
836 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 }
837#endif // _LIBCPP_CXX03_LANG876#endif // _LIBCPP_CXX03_LANG
838877
839 template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >878 template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >
840 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17879 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s)
841 basic_string(const _CharT* __s) : __r_(__default_init_tag(), __default_init_tag()) {880 : __r_(__default_init_tag(), __default_init_tag()) {
842 _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr");881 _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr");
843 __init(__s, traits_type::length(__s));882 __init(__s, traits_type::length(__s));
844 std::__debug_db_insert_c(this);883 std::__debug_db_insert_c(this);
845 }884 }
846885
847 template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >886 template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >
848 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17887 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, const _Allocator& __a);
849 basic_string(const _CharT* __s, const _Allocator& __a);
850888
851#if _LIBCPP_STD_VER > 20889#if _LIBCPP_STD_VER > 20
852 basic_string(nullptr_t) = delete;890 basic_string(nullptr_t) = delete;
853#endif891#endif
854892
855 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17893 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, size_type __n)
856 basic_string(const _CharT* __s, size_type __n);894 : __r_(__default_init_tag(), __default_init_tag()) {
857 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17895 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr");
858 basic_string(const _CharT* __s, size_type __n, const _Allocator& __a);896 __init(__s, __n);
859 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17897 std::__debug_db_insert_c(this);
860 basic_string(size_type __n, _CharT __c);898 }
861899
862 template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> >900 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
863 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17901 basic_string(const _CharT* __s, size_type __n, const _Allocator& __a)
864 basic_string(size_type __n, _CharT __c, const _Allocator& __a);902 : __r_(__default_init_tag(), __a) {
865903 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr");
866 _LIBCPP_CONSTEXPR_AFTER_CXX17904 __init(__s, __n);
867 basic_string(const basic_string& __str, size_type __pos, size_type __n,905 std::__debug_db_insert_c(this);
868 const _Allocator& __a = _Allocator());906 }
869 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17907
870 basic_string(const basic_string& __str, size_type __pos,908 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c)
871 const _Allocator& __a = _Allocator());909 : __r_(__default_init_tag(), __default_init_tag()) {
872910 __init(__n, __c);
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> >911 std::__debug_db_insert_c(this);
874 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17912 }
875 basic_string(const _Tp& __t, size_type __pos, size_type __n,913
876 const allocator_type& __a = allocator_type());914#if _LIBCPP_STD_VER > 20
877915 _LIBCPP_HIDE_FROM_ABI constexpr
878 template<class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&916 basic_string(basic_string&& __str, size_type __pos, const _Allocator& __alloc = _Allocator())
879 !__is_same_uncvref<_Tp, basic_string>::value> >917 : basic_string(std::move(__str), __pos, npos, __alloc) {}
880 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17918
881 explicit basic_string(const _Tp& __t);919 _LIBCPP_HIDE_FROM_ABI constexpr
882920 basic_string(basic_string&& __str, size_type __pos, size_type __n, const _Allocator& __alloc = _Allocator())
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> >921 : __r_(__default_init_tag(), __alloc) {
884 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17922 if (__pos > __str.size())
885 explicit basic_string(const _Tp& __t, const allocator_type& __a);923 __throw_out_of_range();
886924
887 template<class _InputIterator, class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value> >925 auto __len = std::min<size_type>(__n, __str.size() - __pos);
888 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17926 if (__alloc_traits::is_always_equal::value || __alloc == __str.__alloc()) {
889 basic_string(_InputIterator __first, _InputIterator __last);927 __r_.first() = __str.__r_.first();
890 template<class _InputIterator, class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value> >928 __str.__default_init();
891 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17929
892 basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a);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
893#ifndef _LIBCPP_CXX03_LANG993#ifndef _LIBCPP_CXX03_LANG
894 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17994 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(initializer_list<_CharT> __il)
895 basic_string(initializer_list<_CharT> __il);995 : __r_(__default_init_tag(), __default_init_tag()) {
896 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17996 __init(__il.begin(), __il.end());
897 basic_string(initializer_list<_CharT> __il, const _Allocator& __a);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 }
898#endif // _LIBCPP_CXX03_LANG1005#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_CXX171009 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
903 operator __self_view() const _NOEXCEPT { return __self_view(data(), size()); }1010 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
907 template <class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&1014 template <class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
908 !__is_same_uncvref<_Tp, basic_string>::value> >1015 !__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) {
910 __self_view __sv = __t;1017 __self_view __sv = __t;
911 return assign(__sv);1018 return assign(__sv);
912 }1019 }
9131020
914#ifndef _LIBCPP_CXX03_LANG1021#ifndef _LIBCPP_CXX03_LANG
915 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171022 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(basic_string&& __str)
916 basic_string& operator=(basic_string&& __str)1023 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) {
917 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));1024 __move_assign(__str, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());
918 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171025 return *this;
1026 }
1027
1028 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
919 basic_string& operator=(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());}1029 basic_string& operator=(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());}
920#endif1030#endif
921 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171031 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
922 basic_string& operator=(const value_type* __s) {return assign(__s);}1032 basic_string& operator=(const value_type* __s) {return assign(__s);}
923#if _LIBCPP_STD_VER > 201033#if _LIBCPP_STD_VER > 20
924 basic_string& operator=(nullptr_t) = delete;1034 basic_string& operator=(nullptr_t) = delete;
925#endif1035#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_CXX171038 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
929 iterator begin() _NOEXCEPT1039 iterator begin() _NOEXCEPT
930 {return iterator(this, __get_pointer());}1040 {return __make_iterator(__get_pointer());}
931 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171041 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
932 const_iterator begin() const _NOEXCEPT1042 const_iterator begin() const _NOEXCEPT
933 {return const_iterator(this, __get_pointer());}1043 {return __make_const_iterator(__get_pointer());}
934 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171044 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
935 iterator end() _NOEXCEPT1045 iterator end() _NOEXCEPT
936 {return iterator(this, __get_pointer() + size());}1046 {return __make_iterator(__get_pointer() + size());}
937 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171047 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
938 const_iterator end() const _NOEXCEPT1048 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_CXX171051 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
942 reverse_iterator rbegin() _NOEXCEPT1052 reverse_iterator rbegin() _NOEXCEPT
943 {return reverse_iterator(end());}1053 {return reverse_iterator(end());}
944 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171054 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
945 const_reverse_iterator rbegin() const _NOEXCEPT1055 const_reverse_iterator rbegin() const _NOEXCEPT
946 {return const_reverse_iterator(end());}1056 {return const_reverse_iterator(end());}
947 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171057 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
948 reverse_iterator rend() _NOEXCEPT1058 reverse_iterator rend() _NOEXCEPT
949 {return reverse_iterator(begin());}1059 {return reverse_iterator(begin());}
950 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171060 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
951 const_reverse_iterator rend() const _NOEXCEPT1061 const_reverse_iterator rend() const _NOEXCEPT
952 {return const_reverse_iterator(begin());}1062 {return const_reverse_iterator(begin());}
9531063
954 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171064 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
955 const_iterator cbegin() const _NOEXCEPT1065 const_iterator cbegin() const _NOEXCEPT
956 {return begin();}1066 {return begin();}
957 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171067 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
958 const_iterator cend() const _NOEXCEPT1068 const_iterator cend() const _NOEXCEPT
959 {return end();}1069 {return end();}
960 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171070 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
961 const_reverse_iterator crbegin() const _NOEXCEPT1071 const_reverse_iterator crbegin() const _NOEXCEPT
962 {return rbegin();}1072 {return rbegin();}
963 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171073 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
964 const_reverse_iterator crend() const _NOEXCEPT1074 const_reverse_iterator crend() const _NOEXCEPT
965 {return rend();}1075 {return rend();}
9661076
967 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type size() const _NOEXCEPT1077 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type size() const _NOEXCEPT
968 {return __is_long() ? __get_long_size() : __get_short_size();}1078 {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();}1079 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type length() const _NOEXCEPT {return size();}
970 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT;1080
971 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type capacity() const _NOEXCEPT {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 {
972 return (__is_long() ? __get_long_cap() : static_cast<size_type>(__min_cap)) - 1;1092 return (__is_long() ? __get_long_cap() : static_cast<size_type>(__min_cap)) - 1;
973 }1093 }
9741094
975 _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __n, value_type __c);1095 _LIBCPP_CONSTEXPR_SINCE_CXX20 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()); }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
980#if _LIBCPP_STD_VER > 201100#if _LIBCPP_STD_VER > 20
981 template <class _Op>1101 template <class _Op>
...@@ -986,28 +1106,34 @@ public:...@@ -986,28 +1106,34 @@ public:
986 }1106 }
987#endif1107#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
991 _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve() _NOEXCEPT { shrink_to_fit(); }1111 _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;1112 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT;
993 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void clear() _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_CXX171115 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
996 bool empty() const _NOEXCEPT {return size() == 0;}1116 bool empty() const _NOEXCEPT {return size() == 0;}
9971117
998 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171118 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference operator[](size_type __pos) const _NOEXCEPT {
999 const_reference operator[](size_type __pos) const _NOEXCEPT;1119 _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds");
1000 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator[](size_type __pos) _NOEXCEPT;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;1128 _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference at(size_type __n) const;
1003 _LIBCPP_CONSTEXPR_AFTER_CXX17 reference at(size_type __n);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) {
1006 return append(__str);1132 return append(__str);
1007 }1133 }
10081134
1009 template <class _Tp>1135 template <class _Tp>
1010 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX171136 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1011 __enable_if_t1137 __enable_if_t
1012 <1138 <
1013 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value1139 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
...@@ -1018,35 +1144,36 @@ public:...@@ -1018,35 +1144,36 @@ public:
1018 __self_view __sv = __t; return append(__sv);1144 __self_view __sv = __t; return append(__sv);
1019 }1145 }
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) {
1022 return append(__s);1148 return append(__s);
1023 }1149 }
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) {
1026 push_back(__c);1152 push_back(__c);
1027 return *this;1153 return *this;
1028 }1154 }
10291155
1030#ifndef _LIBCPP_CXX03_LANG1156#ifndef _LIBCPP_CXX03_LANG
1031 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171157 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1032 basic_string& operator+=(initializer_list<value_type> __il) { return append(__il); }1158 basic_string& operator+=(initializer_list<value_type> __il) { return append(__il); }
1033#endif // _LIBCPP_CXX03_LANG1159#endif // _LIBCPP_CXX03_LANG
10341160
1035 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171161 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const basic_string& __str) {
1036 basic_string& append(const basic_string& __str);1162 return append(__str.data(), __str.size());
1163 }
10371164
1038 template <class _Tp>1165 template <class _Tp>
1039 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX171166 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1040 __enable_if_t<1167 __enable_if_t<
1041 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value1168 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
1042 && !__is_same_uncvref<_Tp, basic_string>::value,1169 && !__is_same_uncvref<_Tp, basic_string>::value,
1043 basic_string&1170 basic_string&
1044 >1171 >
1045 append(const _Tp& __t) { __self_view __sv = __t; return append(__sv.data(), __sv.size()); }1172 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
1048 template <class _Tp>1175 template <class _Tp>
1049 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX171176 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1050 __enable_if_t1177 __enable_if_t
1051 <1178 <
1052 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value1179 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
...@@ -1054,11 +1181,11 @@ public:...@@ -1054,11 +1181,11 @@ public:
1054 basic_string&1181 basic_string&
1055 >1182 >
1056 append(const _Tp& __t, size_type __pos, size_type __n=npos);1183 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);1184 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s, size_type __n);
1058 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(const value_type* __s);1185 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s);
1059 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(size_type __n, value_type __c);1186 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(size_type __n, value_type __c);
10601187
1061 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171188 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1062 void __append_default_init(size_type __n);1189 void __append_default_init(size_type __n);
10631190
1064 template<class _InputIterator>1191 template<class _InputIterator>
...@@ -1068,7 +1195,7 @@ public:...@@ -1068,7 +1195,7 @@ public:
1068 __is_exactly_cpp17_input_iterator<_InputIterator>::value,1195 __is_exactly_cpp17_input_iterator<_InputIterator>::value,
1069 basic_string&1196 basic_string&
1070 >1197 >
1071 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171198 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1072 append(_InputIterator __first, _InputIterator __last) {1199 append(_InputIterator __first, _InputIterator __last) {
1073 const basic_string __temp(__first, __last, __alloc());1200 const basic_string __temp(__first, __last, __alloc());
1074 append(__temp.data(), __temp.size());1201 append(__temp.data(), __temp.size());
...@@ -1081,40 +1208,56 @@ public:...@@ -1081,40 +1208,56 @@ public:
1081 __is_cpp17_forward_iterator<_ForwardIterator>::value,1208 __is_cpp17_forward_iterator<_ForwardIterator>::value,
1082 basic_string&1209 basic_string&
1083 >1210 >
1084 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171211 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1085 append(_ForwardIterator __first, _ForwardIterator __last);1212 append(_ForwardIterator __first, _ForwardIterator __last);
10861213
1087#ifndef _LIBCPP_CXX03_LANG1214#ifndef _LIBCPP_CXX03_LANG
1088 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171215 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1089 basic_string& append(initializer_list<value_type> __il) {return append(__il.begin(), __il.size());}1216 basic_string& append(initializer_list<value_type> __il) {return append(__il.begin(), __il.size());}
1090#endif // _LIBCPP_CXX03_LANG1217#endif // _LIBCPP_CXX03_LANG
10911218
1092 _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(value_type __c);1219 _LIBCPP_CONSTEXPR_SINCE_CXX20 void push_back(value_type __c);
1093 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void pop_back();1220 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void pop_back();
1094 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference front() _NOEXCEPT;1221
1095 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference front() const _NOEXCEPT;1222 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference front() _NOEXCEPT {
1096 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference back() _NOEXCEPT;1223 _LIBCPP_ASSERT(!empty(), "string::front(): string is empty");
1097 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference back() const _NOEXCEPT;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
1099 template <class _Tp>1242 template <class _Tp>
1100 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX171243 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1101 __enable_if_t1244 __enable_if_t
1102 <1245 <
1103 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1246 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1104 basic_string&1247 basic_string&
1105 >1248 >
1106 assign(const _Tp & __t) { __self_view __sv = __t; return assign(__sv.data(), __sv.size()); }1249 assign(const _Tp & __t) { __self_view __sv = __t; return assign(__sv.data(), __sv.size()); }
1107 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171250 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1108 basic_string& assign(const basic_string& __str) { return *this = __str; }1251 basic_string& assign(const basic_string& __str) { return *this = __str; }
1109#ifndef _LIBCPP_CXX03_LANG1252#ifndef _LIBCPP_CXX03_LANG
1110 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171253 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1111 basic_string& assign(basic_string&& __str)1254 basic_string& assign(basic_string&& __str)
1112 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))1255 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
1113 {*this = std::move(__str); return *this;}1256 {*this = std::move(__str); return *this;}
1114#endif1257#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);
1116 template <class _Tp>1259 template <class _Tp>
1117 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX171260 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1118 __enable_if_t1261 __enable_if_t
1119 <1262 <
1120 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value1263 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
...@@ -1122,11 +1265,11 @@ public:...@@ -1122,11 +1265,11 @@ public:
1122 basic_string&1265 basic_string&
1123 >1266 >
1124 assign(const _Tp & __t, size_type __pos, size_type __n=npos);1267 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);1268 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* __s, size_type __n);
1126 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(const value_type* __s);1269 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* __s);
1127 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(size_type __n, value_type __c);1270 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(size_type __n, value_type __c);
1128 template<class _InputIterator>1271 template<class _InputIterator>
1129 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX171272 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1130 __enable_if_t1273 __enable_if_t
1131 <1274 <
1132 __is_exactly_cpp17_input_iterator<_InputIterator>::value,1275 __is_exactly_cpp17_input_iterator<_InputIterator>::value,
...@@ -1134,7 +1277,7 @@ public:...@@ -1134,7 +1277,7 @@ public:
1134 >1277 >
1135 assign(_InputIterator __first, _InputIterator __last);1278 assign(_InputIterator __first, _InputIterator __last);
1136 template<class _ForwardIterator>1279 template<class _ForwardIterator>
1137 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX171280 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1138 __enable_if_t1281 __enable_if_t
1139 <1282 <
1140 __is_cpp17_forward_iterator<_ForwardIterator>::value,1283 __is_cpp17_forward_iterator<_ForwardIterator>::value,
...@@ -1142,15 +1285,17 @@ public:...@@ -1142,15 +1285,17 @@ public:
1142 >1285 >
1143 assign(_ForwardIterator __first, _ForwardIterator __last);1286 assign(_ForwardIterator __first, _ForwardIterator __last);
1144#ifndef _LIBCPP_CXX03_LANG1287#ifndef _LIBCPP_CXX03_LANG
1145 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171288 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1146 basic_string& assign(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());}1289 basic_string& assign(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());}
1147#endif // _LIBCPP_CXX03_LANG1290#endif // _LIBCPP_CXX03_LANG
11481291
1149 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171292 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1150 basic_string& insert(size_type __pos1, const basic_string& __str);1293 insert(size_type __pos1, const basic_string& __str) {
1294 return insert(__pos1, __str.data(), __str.size());
1295 }
11511296
1152 template <class _Tp>1297 template <class _Tp>
1153 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX171298 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1154 __enable_if_t1299 __enable_if_t
1155 <1300 <
1156 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1301 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
...@@ -1160,23 +1305,31 @@ public:...@@ -1160,23 +1305,31 @@ public:
1160 { __self_view __sv = __t; return insert(__pos1, __sv.data(), __sv.size()); }1305 { __self_view __sv = __t; return insert(__pos1, __sv.data(), __sv.size()); }
11611306
1162 template <class _Tp>1307 template <class _Tp>
1163 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX171308 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1164 __enable_if_t1309 __enable_if_t
1165 <1310 <
1166 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value,1311 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value,
1167 basic_string&1312 basic_string&
1168 >1313 >
1169 insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n=npos);1314 insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n=npos);
1170 _LIBCPP_CONSTEXPR_AFTER_CXX171315 _LIBCPP_CONSTEXPR_SINCE_CXX20
1171 basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n=npos);1316 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);1317 _LIBCPP_CONSTEXPR_SINCE_CXX20 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);1318 _LIBCPP_CONSTEXPR_SINCE_CXX20 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);1319 _LIBCPP_CONSTEXPR_SINCE_CXX20 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);1320 _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __pos, value_type __c);
1176 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171321
1177 iterator insert(const_iterator __pos, size_type __n, value_type __c);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
1178 template<class _InputIterator>1331 template<class _InputIterator>
1179 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX171332 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1180 __enable_if_t1333 __enable_if_t
1181 <1334 <
1182 __is_exactly_cpp17_input_iterator<_InputIterator>::value,1335 __is_exactly_cpp17_input_iterator<_InputIterator>::value,
...@@ -1184,7 +1337,7 @@ public:...@@ -1184,7 +1337,7 @@ public:
1184 >1337 >
1185 insert(const_iterator __pos, _InputIterator __first, _InputIterator __last);1338 insert(const_iterator __pos, _InputIterator __first, _InputIterator __last);
1186 template<class _ForwardIterator>1339 template<class _ForwardIterator>
1187 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX171340 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1188 __enable_if_t1341 __enable_if_t
1189 <1342 <
1190 __is_cpp17_forward_iterator<_ForwardIterator>::value,1343 __is_cpp17_forward_iterator<_ForwardIterator>::value,
...@@ -1192,47 +1345,53 @@ public:...@@ -1192,47 +1345,53 @@ public:
1192 >1345 >
1193 insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last);1346 insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last);
1194#ifndef _LIBCPP_CXX03_LANG1347#ifndef _LIBCPP_CXX03_LANG
1195 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171348 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1196 iterator insert(const_iterator __pos, initializer_list<value_type> __il)1349 iterator insert(const_iterator __pos, initializer_list<value_type> __il)
1197 {return insert(__pos, __il.begin(), __il.end());}1350 {return insert(__pos, __il.begin(), __il.end());}
1198#endif // _LIBCPP_CXX03_LANG1351#endif // _LIBCPP_CXX03_LANG
11991352
1200 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& erase(size_type __pos = 0, size_type __n = npos);1353 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& erase(size_type __pos = 0, size_type __n = npos);
1201 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171354 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1202 iterator erase(const_iterator __pos);1355 iterator erase(const_iterator __pos);
1203 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171356 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1204 iterator erase(const_iterator __first, const_iterator __last);1357 iterator erase(const_iterator __first, const_iterator __last);
12051358
1206 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171359 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1207 basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str);1360 replace(size_type __pos1, size_type __n1, const basic_string& __str) {
1361 return replace(__pos1, __n1, __str.data(), __str.size());
1362 }
12081363
1209 template <class _Tp>1364 template <class _Tp>
1210 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX171365 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1211 __enable_if_t1366 __enable_if_t
1212 <1367 <
1213 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1368 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1214 basic_string&1369 basic_string&
1215 >1370 >
1216 replace(size_type __pos1, size_type __n1, const _Tp& __t) { __self_view __sv = __t; return replace(__pos1, __n1, __sv.data(), __sv.size()); }1371 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_CXX171372 _LIBCPP_CONSTEXPR_SINCE_CXX20
1218 basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos);1373 basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos);
1219 template <class _Tp>1374 template <class _Tp>
1220 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX171375 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1221 __enable_if_t1376 __enable_if_t
1222 <1377 <
1223 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value,1378 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value,
1224 basic_string&1379 basic_string&
1225 >1380 >
1226 replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos);1381 replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos);
1227 _LIBCPP_CONSTEXPR_AFTER_CXX171382 _LIBCPP_CONSTEXPR_SINCE_CXX20
1228 basic_string& replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2);1383 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);1384 _LIBCPP_CONSTEXPR_SINCE_CXX20 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);1385 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c);
1231 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171386
1232 basic_string& replace(const_iterator __i1, const_iterator __i2, const basic_string& __str);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
1234 template <class _Tp>1393 template <class _Tp>
1235 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX171394 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1236 __enable_if_t1395 __enable_if_t
1237 <1396 <
1238 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1397 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
...@@ -1240,14 +1399,23 @@ public:...@@ -1240,14 +1399,23 @@ public:
1240 >1399 >
1241 replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) { __self_view __sv = __t; return replace(__i1 - begin(), __i2 - __i1, __sv); }1400 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_CXX171402 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1244 basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n);1403 replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n) {
1245 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171404 return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __s, __n);
1246 basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s);1405 }
1247 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171406
1248 basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c);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
1249 template<class _InputIterator>1417 template<class _InputIterator>
1250 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX171418 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1251 __enable_if_t1419 __enable_if_t
1252 <1420 <
1253 __is_cpp17_input_iterator<_InputIterator>::value,1421 __is_cpp17_input_iterator<_InputIterator>::value,
...@@ -1255,16 +1423,31 @@ public:...@@ -1255,16 +1423,31 @@ public:
1255 >1423 >
1256 replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2);1424 replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2);
1257#ifndef _LIBCPP_CXX03_LANG1425#ifndef _LIBCPP_CXX03_LANG
1258 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171426 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1259 basic_string& replace(const_iterator __i1, const_iterator __i2, initializer_list<value_type> __il)1427 basic_string& replace(const_iterator __i1, const_iterator __i2, initializer_list<value_type> __il)
1260 {return replace(__i1, __i2, __il.begin(), __il.end());}1428 {return replace(__i1, __i2, __il.begin(), __il.end());}
1261#endif // _LIBCPP_CXX03_LANG1429#endif // _LIBCPP_CXX03_LANG
12621430
1263 _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const;1431 _LIBCPP_CONSTEXPR_SINCE_CXX20 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;
12661432
1267 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171433#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
1268 void swap(basic_string& __str)1451 void swap(basic_string& __str)
1269#if _LIBCPP_STD_VER >= 141452#if _LIBCPP_STD_VER >= 14
1270 _NOEXCEPT;1453 _NOEXCEPT;
...@@ -1273,129 +1456,129 @@ public:...@@ -1273,129 +1456,129 @@ public:
1273 __is_nothrow_swappable<allocator_type>::value);1456 __is_nothrow_swappable<allocator_type>::value);
1274#endif1457#endif
12751458
1276 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171459 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1277 const value_type* c_str() const _NOEXCEPT {return data();}1460 const value_type* c_str() const _NOEXCEPT {return data();}
1278 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171461 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1279 const value_type* data() const _NOEXCEPT {return std::__to_address(__get_pointer());}1462 const value_type* data() const _NOEXCEPT {return std::__to_address(__get_pointer());}
1280#if _LIBCPP_STD_VER > 14 || defined(_LIBCPP_BUILDING_LIBRARY)1463#if _LIBCPP_STD_VER > 14 || defined(_LIBCPP_BUILDING_LIBRARY)
1281 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171464 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1282 value_type* data() _NOEXCEPT {return std::__to_address(__get_pointer());}1465 value_type* data() _NOEXCEPT {return std::__to_address(__get_pointer());}
1283#endif1466#endif
12841467
1285 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171468 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1286 allocator_type get_allocator() const _NOEXCEPT {return __alloc();}1469 allocator_type get_allocator() const _NOEXCEPT {return __alloc();}
12871470
1288 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171471 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1289 size_type find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;1472 size_type find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
12901473
1291 template <class _Tp>1474 template <class _Tp>
1292 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX171475 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1293 __enable_if_t1476 __enable_if_t
1294 <1477 <
1295 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1478 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1296 size_type1479 size_type
1297 >1480 >
1298 find(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT;1481 find(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT;
1299 _LIBCPP_CONSTEXPR_AFTER_CXX171482 _LIBCPP_CONSTEXPR_SINCE_CXX20
1300 size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;1483 size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
1301 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171484 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1302 size_type find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;1485 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_CXX171488 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1306 size_type rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;1489 size_type rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
13071490
1308 template <class _Tp>1491 template <class _Tp>
1309 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX171492 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1310 __enable_if_t1493 __enable_if_t
1311 <1494 <
1312 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1495 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1313 size_type1496 size_type
1314 >1497 >
1315 rfind(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;1498 rfind(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;
1316 _LIBCPP_CONSTEXPR_AFTER_CXX171499 _LIBCPP_CONSTEXPR_SINCE_CXX20
1317 size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;1500 size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
1318 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171501 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1319 size_type rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;1502 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_CXX171505 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1323 size_type find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;1506 size_type find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
13241507
1325 template <class _Tp>1508 template <class _Tp>
1326 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX171509 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1327 __enable_if_t1510 __enable_if_t
1328 <1511 <
1329 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1512 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1330 size_type1513 size_type
1331 >1514 >
1332 find_first_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT;1515 find_first_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT;
1333 _LIBCPP_CONSTEXPR_AFTER_CXX171516 _LIBCPP_CONSTEXPR_SINCE_CXX20
1334 size_type find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;1517 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_CXX171518 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1336 size_type find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;1519 size_type find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
1337 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171520 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1338 size_type find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;1521 size_type find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;
13391522
1340 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171523 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1341 size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;1524 size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
13421525
1343 template <class _Tp>1526 template <class _Tp>
1344 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX171527 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1345 __enable_if_t1528 __enable_if_t
1346 <1529 <
1347 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1530 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1348 size_type1531 size_type
1349 >1532 >
1350 find_last_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;1533 find_last_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;
1351 _LIBCPP_CONSTEXPR_AFTER_CXX171534 _LIBCPP_CONSTEXPR_SINCE_CXX20
1352 size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;1535 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_CXX171536 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1354 size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;1537 size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
1355 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171538 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1356 size_type find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;1539 size_type find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;
13571540
1358 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171541 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1359 size_type find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;1542 size_type find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
13601543
1361 template <class _Tp>1544 template <class _Tp>
1362 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX171545 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1363 __enable_if_t1546 __enable_if_t
1364 <1547 <
1365 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1548 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1366 size_type1549 size_type
1367 >1550 >
1368 find_first_not_of(const _Tp &__t, size_type __pos = 0) const _NOEXCEPT;1551 find_first_not_of(const _Tp &__t, size_type __pos = 0) const _NOEXCEPT;
1369 _LIBCPP_CONSTEXPR_AFTER_CXX171552 _LIBCPP_CONSTEXPR_SINCE_CXX20
1370 size_type find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;1553 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_CXX171554 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1372 size_type find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;1555 size_type find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
1373 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171556 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1374 size_type find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;1557 size_type find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;
13751558
1376 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171559 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1377 size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;1560 size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
13781561
1379 template <class _Tp>1562 template <class _Tp>
1380 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX171563 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1381 __enable_if_t1564 __enable_if_t
1382 <1565 <
1383 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1566 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
1384 size_type1567 size_type
1385 >1568 >
1386 find_last_not_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;1569 find_last_not_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;
1387 _LIBCPP_CONSTEXPR_AFTER_CXX171570 _LIBCPP_CONSTEXPR_SINCE_CXX20
1388 size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;1571 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_CXX171572 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1390 size_type find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;1573 size_type find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
1391 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171574 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1392 size_type find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;1575 size_type find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;
13931576
1394 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171577 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1395 int compare(const basic_string& __str) const _NOEXCEPT;1578 int compare(const basic_string& __str) const _NOEXCEPT;
13961579
1397 template <class _Tp>1580 template <class _Tp>
1398 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX171581 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1399 __enable_if_t1582 __enable_if_t
1400 <1583 <
1401 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1584 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
...@@ -1404,7 +1587,7 @@ public:...@@ -1404,7 +1587,7 @@ public:
1404 compare(const _Tp &__t) const _NOEXCEPT;1587 compare(const _Tp &__t) const _NOEXCEPT;
14051588
1406 template <class _Tp>1589 template <class _Tp>
1407 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX171590 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
1408 __enable_if_t1591 __enable_if_t
1409 <1592 <
1410 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,1593 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
...@@ -1412,23 +1595,23 @@ public:...@@ -1412,23 +1595,23 @@ public:
1412 >1595 >
1413 compare(size_type __pos1, size_type __n1, const _Tp& __t) const;1596 compare(size_type __pos1, size_type __n1, const _Tp& __t) const;
14141597
1415 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171598 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1416 int compare(size_type __pos1, size_type __n1, const basic_string& __str) const;1599 int compare(size_type __pos1, size_type __n1, const basic_string& __str) const;
1417 _LIBCPP_CONSTEXPR_AFTER_CXX171600 _LIBCPP_CONSTEXPR_SINCE_CXX20
1418 int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2,1601 int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2,
1419 size_type __n2 = npos) const;1602 size_type __n2 = npos) const;
14201603
1421 template <class _Tp>1604 template <class _Tp>
1422 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171605 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1423 __enable_if_t1606 __enable_if_t
1424 <1607 <
1425 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value,1608 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value,
1426 int1609 int
1427 >1610 >
1428 compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos) const;1611 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;1612 _LIBCPP_CONSTEXPR_SINCE_CXX20 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;1613 _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(size_type __pos1, size_type __n1, const value_type* __s) const;
1431 _LIBCPP_CONSTEXPR_AFTER_CXX171614 _LIBCPP_CONSTEXPR_SINCE_CXX20
1432 int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const;1615 int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const;
14331616
1434#if _LIBCPP_STD_VER > 171617#if _LIBCPP_STD_VER > 17
...@@ -1471,9 +1654,9 @@ public:...@@ -1471,9 +1654,9 @@ public:
1471 { return __self_view(data(), size()).contains(__s); }1654 { return __self_view(data(), size()).contains(__s); }
1472#endif1655#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
1478#ifdef _LIBCPP_ENABLE_DEBUG_MODE1661#ifdef _LIBCPP_ENABLE_DEBUG_MODE
14791662
...@@ -1486,20 +1669,20 @@ public:...@@ -1486,20 +1669,20 @@ public:
14861669
1487private:1670private:
1488 template<class _Alloc>1671 template<class _Alloc>
1489 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171672 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1490 bool friend operator==(const basic_string<char, char_traits<char>, _Alloc>& __lhs,1673 bool friend operator==(const basic_string<char, char_traits<char>, _Alloc>& __lhs,
1491 const basic_string<char, char_traits<char>, _Alloc>& __rhs) _NOEXCEPT;1674 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_CXX171678 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1496 bool __is_long() const _NOEXCEPT {1679 bool __is_long() const _NOEXCEPT {
1497 if (__libcpp_is_constant_evaluated())1680 if (__libcpp_is_constant_evaluated())
1498 return true;1681 return true;
1499 return __r_.first().__s.__is_long_;1682 return __r_.first().__s.__is_long_;
1500 }1683 }
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) {
1503#if _LIBCPP_STD_VER > 171686#if _LIBCPP_STD_VER > 17
1504 if (__libcpp_is_constant_evaluated()) {1687 if (__libcpp_is_constant_evaluated()) {
1505 for (size_type __i = 0; __i != __n; ++__i)1688 for (size_type __i = 0; __i != __n; ++__i)
...@@ -1511,8 +1694,8 @@ private:...@@ -1511,8 +1694,8 @@ private:
1511#endif // _LIBCPP_STD_VER > 171694#endif // _LIBCPP_STD_VER > 17
1512 }1695 }
15131696
1514 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __default_init() {1697 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __default_init() {
1515 __zero();1698 __r_.first() = __rep();
1516 if (__libcpp_is_constant_evaluated()) {1699 if (__libcpp_is_constant_evaluated()) {
1517 size_type __sz = __recommend(0) + 1;1700 size_type __sz = __recommend(0) + 1;
1518 pointer __ptr = __alloc_traits::allocate(__alloc(), __sz);1701 pointer __ptr = __alloc_traits::allocate(__alloc(), __sz);
...@@ -1523,7 +1706,7 @@ private:...@@ -1523,7 +1706,7 @@ private:
1523 }1706 }
1524 }1707 }
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() {
1527 if (__libcpp_is_constant_evaluated() && __get_pointer() != nullptr)1710 if (__libcpp_is_constant_evaluated() && __get_pointer() != nullptr)
1528 __alloc_traits::deallocate(__alloc(), __get_pointer(), __get_long_cap());1711 __alloc_traits::deallocate(__alloc(), __get_pointer(), __get_long_cap());
1529 }1712 }
...@@ -1534,7 +1717,7 @@ private:...@@ -1534,7 +1717,7 @@ private:
1534 }1717 }
15351718
1536 template <class _ForwardIterator>1719 template <class _ForwardIterator>
1537 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX111720 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
1538 iterator __insert_from_safe_copy(size_type __n, size_type __ip, _ForwardIterator __first, _ForwardIterator __last) {1721 iterator __insert_from_safe_copy(size_type __n, size_type __ip, _ForwardIterator __first, _ForwardIterator __last) {
1539 size_type __sz = size();1722 size_type __sz = size();
1540 size_type __cap = capacity();1723 size_type __cap = capacity();
...@@ -1560,76 +1743,71 @@ private:...@@ -1560,76 +1743,71 @@ private:
1560 return begin() + __ip;1743 return begin() + __ip;
1561 }1744 }
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(); }
1564 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const allocator_type& __alloc() const _NOEXCEPT { return __r_.second(); }1747 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const allocator_type& __alloc() const _NOEXCEPT { return __r_.second(); }
15651748
1566 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171749 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1567 void __set_short_size(size_type __s) _NOEXCEPT {1750 void __set_short_size(size_type __s) _NOEXCEPT {
1568 _LIBCPP_ASSERT(__s < __min_cap, "__s should never be greater than or equal to the short string capacity");1751 _LIBCPP_ASSERT(__s < __min_cap, "__s should never be greater than or equal to the short string capacity");
1569 __r_.first().__s.__size_ = __s;1752 __r_.first().__s.__size_ = __s;
1570 __r_.first().__s.__is_long_ = false;1753 __r_.first().__s.__is_long_ = false;
1571 }1754 }
15721755
1573 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171756 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1574 size_type __get_short_size() const _NOEXCEPT {1757 size_type __get_short_size() const _NOEXCEPT {
1575 _LIBCPP_ASSERT(!__r_.first().__s.__is_long_, "String has to be short when trying to get the short size");1758 _LIBCPP_ASSERT(!__r_.first().__s.__is_long_, "String has to be short when trying to get the short size");
1576 return __r_.first().__s.__size_;1759 return __r_.first().__s.__size_;
1577 }1760 }
15781761
1579 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171762 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1580 void __set_long_size(size_type __s) _NOEXCEPT1763 void __set_long_size(size_type __s) _NOEXCEPT
1581 {__r_.first().__l.__size_ = __s;}1764 {__r_.first().__l.__size_ = __s;}
1582 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171765 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1583 size_type __get_long_size() const _NOEXCEPT1766 size_type __get_long_size() const _NOEXCEPT
1584 {return __r_.first().__l.__size_;}1767 {return __r_.first().__l.__size_;}
1585 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171768 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1586 void __set_size(size_type __s) _NOEXCEPT1769 void __set_size(size_type __s) _NOEXCEPT
1587 {if (__is_long()) __set_long_size(__s); else __set_short_size(__s);}1770 {if (__is_long()) __set_long_size(__s); else __set_short_size(__s);}
15881771
1589 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171772 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1590 void __set_long_cap(size_type __s) _NOEXCEPT {1773 void __set_long_cap(size_type __s) _NOEXCEPT {
1591 __r_.first().__l.__cap_ = __s / __endian_factor;1774 __r_.first().__l.__cap_ = __s / __endian_factor;
1592 __r_.first().__l.__is_long_ = true;1775 __r_.first().__l.__is_long_ = true;
1593 }1776 }
15941777
1595 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171778 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1596 size_type __get_long_cap() const _NOEXCEPT {1779 size_type __get_long_cap() const _NOEXCEPT {
1597 return __r_.first().__l.__cap_ * __endian_factor;1780 return __r_.first().__l.__cap_ * __endian_factor;
1598 }1781 }
15991782
1600 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171783 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1601 void __set_long_pointer(pointer __p) _NOEXCEPT1784 void __set_long_pointer(pointer __p) _NOEXCEPT
1602 {__r_.first().__l.__data_ = __p;}1785 {__r_.first().__l.__data_ = __p;}
1603 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171786 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1604 pointer __get_long_pointer() _NOEXCEPT1787 pointer __get_long_pointer() _NOEXCEPT
1605 {return __r_.first().__l.__data_;}1788 {return __r_.first().__l.__data_;}
1606 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171789 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1607 const_pointer __get_long_pointer() const _NOEXCEPT1790 const_pointer __get_long_pointer() const _NOEXCEPT
1608 {return __r_.first().__l.__data_;}1791 {return __r_.first().__l.__data_;}
1609 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171792 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1610 pointer __get_short_pointer() _NOEXCEPT1793 pointer __get_short_pointer() _NOEXCEPT
1611 {return pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0]);}1794 {return pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0]);}
1612 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171795 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1613 const_pointer __get_short_pointer() const _NOEXCEPT1796 const_pointer __get_short_pointer() const _NOEXCEPT
1614 {return pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0]);}1797 {return pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0]);}
1615 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171798 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1616 pointer __get_pointer() _NOEXCEPT1799 pointer __get_pointer() _NOEXCEPT
1617 {return __is_long() ? __get_long_pointer() : __get_short_pointer();}1800 {return __is_long() ? __get_long_pointer() : __get_short_pointer();}
1618 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171801 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1619 const_pointer __get_pointer() const _NOEXCEPT1802 const_pointer __get_pointer() const _NOEXCEPT
1620 {return __is_long() ? __get_long_pointer() : __get_short_pointer();}1803 {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
1627 template <size_type __a> static1805 template <size_type __a> static
1628 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171806 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1629 size_type __align_it(size_type __s) _NOEXCEPT1807 size_type __align_it(size_type __s) _NOEXCEPT
1630 {return (__s + (__a-1)) & ~(__a-1);}1808 {return (__s + (__a-1)) & ~(__a-1);}
1631 enum {__alignment = 16};1809 enum {__alignment = 16};
1632 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171810 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1633 size_type __recommend(size_type __s) _NOEXCEPT1811 size_type __recommend(size_type __s) _NOEXCEPT
1634 {1812 {
1635 if (__s < __min_cap) {1813 if (__s < __min_cap) {
...@@ -1644,11 +1822,11 @@ private:...@@ -1644,11 +1822,11 @@ private:
1644 return __guess;1822 return __guess;
1645 }1823 }
16461824
1647 inline _LIBCPP_CONSTEXPR_AFTER_CXX171825 inline _LIBCPP_CONSTEXPR_SINCE_CXX20
1648 void __init(const value_type* __s, size_type __sz, size_type __reserve);1826 void __init(const value_type* __s, size_type __sz, size_type __reserve);
1649 inline _LIBCPP_CONSTEXPR_AFTER_CXX171827 inline _LIBCPP_CONSTEXPR_SINCE_CXX20
1650 void __init(const value_type* __s, size_type __sz);1828 void __init(const value_type* __s, size_type __sz);
1651 inline _LIBCPP_CONSTEXPR_AFTER_CXX171829 inline _LIBCPP_CONSTEXPR_SINCE_CXX20
1652 void __init(size_type __n, value_type __c);1830 void __init(size_type __n, value_type __c);
16531831
1654 // Slow path for the (inlined) copy constructor for 'long' strings.1832 // Slow path for the (inlined) copy constructor for 'long' strings.
...@@ -1659,10 +1837,10 @@ private:...@@ -1659,10 +1837,10 @@ private:
1659 // to call the __init() functions as those are marked as inline which may1837 // to call the __init() functions as those are marked as inline which may
1660 // result in over-aggressive inlining by the compiler, where our aim is1838 // result in over-aggressive inlining by the compiler, where our aim is
1661 // to only inline the fast path code directly in the ctor.1839 // 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
1664 template <class _InputIterator>1842 template <class _InputIterator>
1665 inline _LIBCPP_CONSTEXPR_AFTER_CXX171843 inline _LIBCPP_CONSTEXPR_SINCE_CXX20
1666 __enable_if_t1844 __enable_if_t
1667 <1845 <
1668 __is_exactly_cpp17_input_iterator<_InputIterator>::value1846 __is_exactly_cpp17_input_iterator<_InputIterator>::value
...@@ -1670,17 +1848,17 @@ private:...@@ -1670,17 +1848,17 @@ private:
1670 __init(_InputIterator __first, _InputIterator __last);1848 __init(_InputIterator __first, _InputIterator __last);
16711849
1672 template <class _ForwardIterator>1850 template <class _ForwardIterator>
1673 inline _LIBCPP_CONSTEXPR_AFTER_CXX171851 inline _LIBCPP_CONSTEXPR_SINCE_CXX20
1674 __enable_if_t1852 __enable_if_t
1675 <1853 <
1676 __is_cpp17_forward_iterator<_ForwardIterator>::value1854 __is_cpp17_forward_iterator<_ForwardIterator>::value
1677 >1855 >
1678 __init(_ForwardIterator __first, _ForwardIterator __last);1856 __init(_ForwardIterator __first, _ForwardIterator __last);
16791857
1680 _LIBCPP_CONSTEXPR_AFTER_CXX171858 _LIBCPP_CONSTEXPR_SINCE_CXX20
1681 void __grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz,1859 void __grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz,
1682 size_type __n_copy, size_type __n_del, size_type __n_add = 0);1860 size_type __n_copy, size_type __n_del, size_type __n_add = 0);
1683 _LIBCPP_CONSTEXPR_AFTER_CXX171861 _LIBCPP_CONSTEXPR_SINCE_CXX20
1684 void __grow_by_and_replace(size_type __old_cap, size_type __delta_cap, size_type __old_sz,1862 void __grow_by_and_replace(size_type __old_cap, size_type __delta_cap, size_type __old_sz,
1685 size_type __n_copy, size_type __n_del,1863 size_type __n_copy, size_type __n_del,
1686 size_type __n_add, const value_type* __p_new_stuff);1864 size_type __n_add, const value_type* __p_new_stuff);
...@@ -1689,21 +1867,22 @@ private:...@@ -1689,21 +1867,22 @@ private:
1689 // have proof that the input does not alias the current instance.1867 // have proof that the input does not alias the current instance.
1690 // For example, operator=(basic_string) performs a 'self' check.1868 // For example, operator=(basic_string) performs a 'self' check.
1691 template <bool __is_short>1869 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_CXX171872 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __erase_to_end(size_type __pos) {
1695 void __erase_to_end(size_type __pos);1873 __null_terminate_at(std::__to_address(__get_pointer()), __pos);
1874 }
16961875
1697 // __erase_external_with_move is invoked for erase() invocations where1876 // __erase_external_with_move is invoked for erase() invocations where
1698 // `n ~= npos`, likely requiring memory moves on the string data.1877 // `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_CXX171880 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1702 void __copy_assign_alloc(const basic_string& __str)1881 void __copy_assign_alloc(const basic_string& __str)
1703 {__copy_assign_alloc(__str, integral_constant<bool,1882 {__copy_assign_alloc(__str, integral_constant<bool,
1704 __alloc_traits::propagate_on_container_copy_assignment::value>());}1883 __alloc_traits::propagate_on_container_copy_assignment::value>());}
17051884
1706 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171885 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1707 void __copy_assign_alloc(const basic_string& __str, true_type)1886 void __copy_assign_alloc(const basic_string& __str, true_type)
1708 {1887 {
1709 if (__alloc() == __str.__alloc())1888 if (__alloc() == __str.__alloc())
...@@ -1720,7 +1899,7 @@ private:...@@ -1720,7 +1899,7 @@ private:
1720 allocator_type __a = __str.__alloc();1899 allocator_type __a = __str.__alloc();
1721 auto __allocation = std::__allocate_at_least(__a, __str.__get_long_cap());1900 auto __allocation = std::__allocate_at_least(__a, __str.__get_long_cap());
1722 __begin_lifetime(__allocation.ptr, __allocation.count);1901 __begin_lifetime(__allocation.ptr, __allocation.count);
1723 __clear_and_shrink();1902 __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap());
1724 __alloc() = std::move(__a);1903 __alloc() = std::move(__a);
1725 __set_long_pointer(__allocation.ptr);1904 __set_long_pointer(__allocation.ptr);
1726 __set_long_cap(__allocation.count);1905 __set_long_cap(__allocation.count);
...@@ -1729,15 +1908,15 @@ private:...@@ -1729,15 +1908,15 @@ private:
1729 }1908 }
1730 }1909 }
17311910
1732 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171911 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1733 void __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT1912 void __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT
1734 {}1913 {}
17351914
1736#ifndef _LIBCPP_CXX03_LANG1915#ifndef _LIBCPP_CXX03_LANG
1737 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171916 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1738 void __move_assign(basic_string& __str, false_type)1917 void __move_assign(basic_string& __str, false_type)
1739 _NOEXCEPT_(__alloc_traits::is_always_equal::value);1918 _NOEXCEPT_(__alloc_traits::is_always_equal::value);
1740 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171919 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1741 void __move_assign(basic_string& __str, true_type)1920 void __move_assign(basic_string& __str, true_type)
1742#if _LIBCPP_STD_VER > 141921#if _LIBCPP_STD_VER > 14
1743 _NOEXCEPT;1922 _NOEXCEPT;
...@@ -1746,7 +1925,7 @@ private:...@@ -1746,7 +1925,7 @@ private:
1746#endif1925#endif
1747#endif1926#endif
17481927
1749 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171928 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1750 void1929 void
1751 __move_assign_alloc(basic_string& __str)1930 __move_assign_alloc(basic_string& __str)
1752 _NOEXCEPT_(1931 _NOEXCEPT_(
...@@ -1755,20 +1934,20 @@ private:...@@ -1755,20 +1934,20 @@ private:
1755 {__move_assign_alloc(__str, integral_constant<bool,1934 {__move_assign_alloc(__str, integral_constant<bool,
1756 __alloc_traits::propagate_on_container_move_assignment::value>());}1935 __alloc_traits::propagate_on_container_move_assignment::value>());}
17571936
1758 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171937 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1759 void __move_assign_alloc(basic_string& __c, true_type)1938 void __move_assign_alloc(basic_string& __c, true_type)
1760 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)1939 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
1761 {1940 {
1762 __alloc() = std::move(__c.__alloc());1941 __alloc() = std::move(__c.__alloc());
1763 }1942 }
17641943
1765 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171944 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1766 void __move_assign_alloc(basic_string&, false_type)1945 void __move_assign_alloc(basic_string&, false_type)
1767 _NOEXCEPT1946 _NOEXCEPT
1768 {}1947 {}
17691948
1770 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& __assign_external(const value_type* __s);1949 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& __assign_external(const value_type* __s);
1771 _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& __assign_external(const value_type* __s, size_type __n);1950 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& __assign_external(const value_type* __s, size_type __n);
17721951
1773 // Assigns the value in __s, guaranteed to be __n < __min_cap in length.1952 // Assigns the value in __s, guaranteed to be __n < __min_cap in length.
1774 inline basic_string& __assign_short(const value_type* __s, size_type __n) {1953 inline basic_string& __assign_short(const value_type* __s, size_type __n) {
...@@ -1780,7 +1959,7 @@ private:...@@ -1780,7 +1959,7 @@ private:
1780 return *this;1959 return *this;
1781 }1960 }
17821961
1783 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171962 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1784 basic_string& __null_terminate_at(value_type* __p, size_type __newsz) {1963 basic_string& __null_terminate_at(value_type* __p, size_type __newsz) {
1785 __set_size(__newsz);1964 __set_size(__newsz);
1786 __invalidate_iterators_past(__newsz);1965 __invalidate_iterators_past(__newsz);
...@@ -1788,10 +1967,10 @@ private:...@@ -1788,10 +1967,10 @@ private:
1788 return *this;1967 return *this;
1789 }1968 }
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
1793 template<class _Tp>1972 template<class _Tp>
1794 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX171973 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1795 bool __addr_in_range(_Tp&& __t) const {1974 bool __addr_in_range(_Tp&& __t) const {
1796 // assume that the ranges overlap, because we can't check during constant evaluation1975 // assume that the ranges overlap, because we can't check during constant evaluation
1797 if (__libcpp_is_constant_evaluated())1976 if (__libcpp_is_constant_evaluated())
...@@ -1810,11 +1989,11 @@ private:...@@ -1810,11 +1989,11 @@ private:
1810 std::__throw_out_of_range("basic_string");1989 std::__throw_out_of_range("basic_string");
1811 }1990 }
18121991
1813 friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, const basic_string&);1992 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+<>(const basic_string&, const basic_string&);
1814 friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const value_type*, const basic_string&);1993 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+<>(const value_type*, const basic_string&);
1815 friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(value_type, const basic_string&);1994 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+<>(value_type, const basic_string&);
1816 friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, const value_type*);1995 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+<>(const basic_string&, const value_type*);
1817 friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, value_type);1996 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+<>(const basic_string&, value_type);
1818};1997};
18191998
1820// These declarations must appear before any functions are implicitly used1999// 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& = _...@@ -1863,7 +2042,7 @@ basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _
1863#endif2042#endif
18642043
1865template <class _CharT, class _Traits, class _Allocator>2044template <class _CharT, class _Traits, class _Allocator>
1866inline _LIBCPP_CONSTEXPR_AFTER_CXX172045inline _LIBCPP_CONSTEXPR_SINCE_CXX20
1867void2046void
1868basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type __pos)2047basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type __pos)
1869{2048{
...@@ -1893,37 +2072,13 @@ basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type...@@ -1893,37 +2072,13 @@ basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type
1893}2072}
18942073
1895template <class _CharT, class _Traits, class _Allocator>2074template <class _CharT, class _Traits, class _Allocator>
1896inline _LIBCPP_CONSTEXPR_AFTER_CXX172075_LIBCPP_CONSTEXPR_SINCE_CXX20
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
1921void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s,2076void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s,
1922 size_type __sz,2077 size_type __sz,
1923 size_type __reserve)2078 size_type __reserve)
1924{2079{
1925 if (__libcpp_is_constant_evaluated())2080 if (__libcpp_is_constant_evaluated())
1926 __zero();2081 __r_.first() = __rep();
1927 if (__reserve > max_size())2082 if (__reserve > max_size())
1928 __throw_length_error();2083 __throw_length_error();
1929 pointer __p;2084 pointer __p;
...@@ -1946,12 +2101,12 @@ void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s,...@@ -1946,12 +2101,12 @@ void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s,
1946}2101}
19472102
1948template <class _CharT, class _Traits, class _Allocator>2103template <class _CharT, class _Traits, class _Allocator>
1949_LIBCPP_CONSTEXPR_AFTER_CXX172104_LIBCPP_CONSTEXPR_SINCE_CXX20
1950void2105void
1951basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz)2106basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz)
1952{2107{
1953 if (__libcpp_is_constant_evaluated())2108 if (__libcpp_is_constant_evaluated())
1954 __zero();2109 __r_.first() = __rep();
1955 if (__sz > max_size())2110 if (__sz > max_size())
1956 __throw_length_error();2111 __throw_length_error();
1957 pointer __p;2112 pointer __p;
...@@ -1975,7 +2130,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty...@@ -1975,7 +2130,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty
19752130
1976template <class _CharT, class _Traits, class _Allocator>2131template <class _CharT, class _Traits, class _Allocator>
1977template <class>2132template <class>
1978_LIBCPP_CONSTEXPR_AFTER_CXX172133_LIBCPP_CONSTEXPR_SINCE_CXX20
1979basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a)2134basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a)
1980 : __r_(__default_init_tag(), __a)2135 : __r_(__default_init_tag(), __a)
1981{2136{
...@@ -1985,32 +2140,12 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const...@@ -1985,32 +2140,12 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const
1985}2140}
19862141
1987template <class _CharT, class _Traits, class _Allocator>2142template <class _CharT, class _Traits, class _Allocator>
1988inline _LIBCPP_CONSTEXPR_AFTER_CXX172143_LIBCPP_CONSTEXPR_SINCE_CXX20
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
2009basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str)2144basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str)
2010 : __r_(__default_init_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc()))2145 : __r_(__default_init_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc()))
2011{2146{
2012 if (!__str.__is_long())2147 if (!__str.__is_long())
2013 __r_.first().__r = __str.__r_.first().__r;2148 __r_.first() = __str.__r_.first();
2014 else2149 else
2015 __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()),2150 __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()),
2016 __str.__get_long_size());2151 __str.__get_long_size());
...@@ -2018,13 +2153,13 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st...@@ -2018,13 +2153,13 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
2018}2153}
20192154
2020template <class _CharT, class _Traits, class _Allocator>2155template <class _CharT, class _Traits, class _Allocator>
2021_LIBCPP_CONSTEXPR_AFTER_CXX172156_LIBCPP_CONSTEXPR_SINCE_CXX20
2022basic_string<_CharT, _Traits, _Allocator>::basic_string(2157basic_string<_CharT, _Traits, _Allocator>::basic_string(
2023 const basic_string& __str, const allocator_type& __a)2158 const basic_string& __str, const allocator_type& __a)
2024 : __r_(__default_init_tag(), __a)2159 : __r_(__default_init_tag(), __a)
2025{2160{
2026 if (!__str.__is_long())2161 if (!__str.__is_long())
2027 __r_.first().__r = __str.__r_.first().__r;2162 __r_.first() = __str.__r_.first();
2028 else2163 else
2029 __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()),2164 __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()),
2030 __str.__get_long_size());2165 __str.__get_long_size());
...@@ -2032,11 +2167,12 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(...@@ -2032,11 +2167,12 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
2032}2167}
20332168
2034template <class _CharT, class _Traits, class _Allocator>2169template <class _CharT, class _Traits, class _Allocator>
2035_LIBCPP_CONSTEXPR_AFTER_CXX172170_LIBCPP_CONSTEXPR_SINCE_CXX20
2036void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(2171void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(
2037 const value_type* __s, size_type __sz) {2172 const value_type* __s, size_type __sz) {
2038 if (__libcpp_is_constant_evaluated())2173 if (__libcpp_is_constant_evaluated())
2039 __zero();2174 __r_.first() = __rep();
2175
2040 pointer __p;2176 pointer __p;
2041 if (__fits_in_sso(__sz)) {2177 if (__fits_in_sso(__sz)) {
2042 __p = __get_short_pointer();2178 __p = __get_short_pointer();
...@@ -2054,55 +2190,14 @@ void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(...@@ -2054,55 +2190,14 @@ void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(
2054 traits_type::copy(std::__to_address(__p), __s, __sz + 1);2190 traits_type::copy(std::__to_address(__p), __s, __sz + 1);
2055}2191}
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
2075template <class _CharT, class _Traits, class _Allocator>2193template <class _CharT, class _Traits, class _Allocator>
2076inline _LIBCPP_CONSTEXPR_AFTER_CXX172194_LIBCPP_CONSTEXPR_SINCE_CXX20
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
2101void2195void
2102basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c)2196basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c)
2103{2197{
2104 if (__libcpp_is_constant_evaluated())2198 if (__libcpp_is_constant_evaluated())
2105 __zero();2199 __r_.first() = __rep();
2200
2106 if (__n > max_size())2201 if (__n > max_size())
2107 __throw_length_error();2202 __throw_length_error();
2108 pointer __p;2203 pointer __p;
...@@ -2124,18 +2219,9 @@ basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c)...@@ -2124,18 +2219,9 @@ basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c)
2124 traits_type::assign(__p[__n], value_type());2219 traits_type::assign(__p[__n], value_type());
2125}2220}
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
2136template <class _CharT, class _Traits, class _Allocator>2222template <class _CharT, class _Traits, class _Allocator>
2137template <class>2223template <class>
2138_LIBCPP_CONSTEXPR_AFTER_CXX172224_LIBCPP_CONSTEXPR_SINCE_CXX20
2139basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a)2225basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a)
2140 : __r_(__default_init_tag(), __a)2226 : __r_(__default_init_tag(), __a)
2141{2227{
...@@ -2144,7 +2230,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __...@@ -2144,7 +2230,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __
2144}2230}
21452231
2146template <class _CharT, class _Traits, class _Allocator>2232template <class _CharT, class _Traits, class _Allocator>
2147_LIBCPP_CONSTEXPR_AFTER_CXX172233_LIBCPP_CONSTEXPR_SINCE_CXX20
2148basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str,2234basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str,
2149 size_type __pos, size_type __n,2235 size_type __pos, size_type __n,
2150 const _Allocator& __a)2236 const _Allocator& __a)
...@@ -2157,22 +2243,9 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st...@@ -2157,22 +2243,9 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
2157 std::__debug_db_insert_c(this);2243 std::__debug_db_insert_c(this);
2158}2244}
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
2173template <class _CharT, class _Traits, class _Allocator>2246template <class _CharT, class _Traits, class _Allocator>
2174template <class _Tp, class>2247template <class _Tp, class>
2175_LIBCPP_CONSTEXPR_AFTER_CXX172248_LIBCPP_CONSTEXPR_SINCE_CXX20
2176basic_string<_CharT, _Traits, _Allocator>::basic_string(2249basic_string<_CharT, _Traits, _Allocator>::basic_string(
2177 const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a)2250 const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a)
2178 : __r_(__default_init_tag(), __a)2251 : __r_(__default_init_tag(), __a)
...@@ -2185,7 +2258,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(...@@ -2185,7 +2258,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
21852258
2186template <class _CharT, class _Traits, class _Allocator>2259template <class _CharT, class _Traits, class _Allocator>
2187template <class _Tp, class>2260template <class _Tp, class>
2188_LIBCPP_CONSTEXPR_AFTER_CXX172261_LIBCPP_CONSTEXPR_SINCE_CXX20
2189basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t)2262basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t)
2190 : __r_(__default_init_tag(), __default_init_tag())2263 : __r_(__default_init_tag(), __default_init_tag())
2191{2264{
...@@ -2196,7 +2269,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t)...@@ -2196,7 +2269,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t)
21962269
2197template <class _CharT, class _Traits, class _Allocator>2270template <class _CharT, class _Traits, class _Allocator>
2198template <class _Tp, class>2271template <class _Tp, class>
2199_LIBCPP_CONSTEXPR_AFTER_CXX172272_LIBCPP_CONSTEXPR_SINCE_CXX20
2200basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _Allocator& __a)2273basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _Allocator& __a)
2201 : __r_(__default_init_tag(), __a)2274 : __r_(__default_init_tag(), __a)
2202{2275{
...@@ -2207,7 +2280,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _...@@ -2207,7 +2280,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _
22072280
2208template <class _CharT, class _Traits, class _Allocator>2281template <class _CharT, class _Traits, class _Allocator>
2209template <class _InputIterator>2282template <class _InputIterator>
2210_LIBCPP_CONSTEXPR_AFTER_CXX172283_LIBCPP_CONSTEXPR_SINCE_CXX20
2211__enable_if_t2284__enable_if_t
2212<2285<
2213 __is_exactly_cpp17_input_iterator<_InputIterator>::value2286 __is_exactly_cpp17_input_iterator<_InputIterator>::value
...@@ -2234,7 +2307,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _Input...@@ -2234,7 +2307,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _Input
22342307
2235template <class _CharT, class _Traits, class _Allocator>2308template <class _CharT, class _Traits, class _Allocator>
2236template <class _ForwardIterator>2309template <class _ForwardIterator>
2237_LIBCPP_CONSTEXPR_AFTER_CXX172310_LIBCPP_CONSTEXPR_SINCE_CXX20
2238__enable_if_t2311__enable_if_t
2239<2312<
2240 __is_cpp17_forward_iterator<_ForwardIterator>::value2313 __is_cpp17_forward_iterator<_ForwardIterator>::value
...@@ -2242,7 +2315,7 @@ __enable_if_t...@@ -2242,7 +2315,7 @@ __enable_if_t
2242basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _ForwardIterator __last)2315basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _ForwardIterator __last)
2243{2316{
2244 if (__libcpp_is_constant_evaluated())2317 if (__libcpp_is_constant_evaluated())
2245 __zero();2318 __r_.first() = __rep();
2246 size_type __sz = static_cast<size_type>(std::distance(__first, __last));2319 size_type __sz = static_cast<size_type>(std::distance(__first, __last));
2247 if (__sz > max_size())2320 if (__sz > max_size())
2248 __throw_length_error();2321 __throw_length_error();
...@@ -2281,52 +2354,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _For...@@ -2281,52 +2354,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _For
2281}2354}
22822355
2283template <class _CharT, class _Traits, class _Allocator>2356template <class _CharT, class _Traits, class _Allocator>
2284template<class _InputIterator, class>2357_LIBCPP_CONSTEXPR_SINCE_CXX20
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
2330basic_string<_CharT, _Traits, _Allocator>::~basic_string()2358basic_string<_CharT, _Traits, _Allocator>::~basic_string()
2331{2359{
2332 std::__debug_db_erase_c(this);2360 std::__debug_db_erase_c(this);
...@@ -2335,7 +2363,7 @@ basic_string<_CharT, _Traits, _Allocator>::~basic_string()...@@ -2335,7 +2363,7 @@ basic_string<_CharT, _Traits, _Allocator>::~basic_string()
2335}2363}
23362364
2337template <class _CharT, class _Traits, class _Allocator>2365template <class _CharT, class _Traits, class _Allocator>
2338_LIBCPP_CONSTEXPR_AFTER_CXX172366_LIBCPP_CONSTEXPR_SINCE_CXX20
2339void2367void
2340basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace2368basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace
2341 (size_type __old_cap, size_type __delta_cap, size_type __old_sz,2369 (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...@@ -2372,7 +2400,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace
23722400
2373template <class _CharT, class _Traits, class _Allocator>2401template <class _CharT, class _Traits, class _Allocator>
2374void2402void
2375_LIBCPP_CONSTEXPR_AFTER_CXX172403_LIBCPP_CONSTEXPR_SINCE_CXX20
2376basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz,2404basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz,
2377 size_type __n_copy, size_type __n_del, size_type __n_add)2405 size_type __n_copy, size_type __n_del, size_type __n_add)
2378{2406{
...@@ -2405,7 +2433,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_t...@@ -2405,7 +2433,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_t
24052433
2406template <class _CharT, class _Traits, class _Allocator>2434template <class _CharT, class _Traits, class _Allocator>
2407template <bool __is_short>2435template <bool __is_short>
2408_LIBCPP_CONSTEXPR_AFTER_CXX172436_LIBCPP_CONSTEXPR_SINCE_CXX20
2409basic_string<_CharT, _Traits, _Allocator>&2437basic_string<_CharT, _Traits, _Allocator>&
2410basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(2438basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(
2411 const value_type* __s, size_type __n) {2439 const value_type* __s, size_type __n) {
...@@ -2424,7 +2452,7 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(...@@ -2424,7 +2452,7 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(
2424}2452}
24252453
2426template <class _CharT, class _Traits, class _Allocator>2454template <class _CharT, class _Traits, class _Allocator>
2427_LIBCPP_CONSTEXPR_AFTER_CXX172455_LIBCPP_CONSTEXPR_SINCE_CXX20
2428basic_string<_CharT, _Traits, _Allocator>&2456basic_string<_CharT, _Traits, _Allocator>&
2429basic_string<_CharT, _Traits, _Allocator>::__assign_external(2457basic_string<_CharT, _Traits, _Allocator>::__assign_external(
2430 const value_type* __s, size_type __n) {2458 const value_type* __s, size_type __n) {
...@@ -2441,7 +2469,7 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_external(...@@ -2441,7 +2469,7 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_external(
2441}2469}
24422470
2443template <class _CharT, class _Traits, class _Allocator>2471template <class _CharT, class _Traits, class _Allocator>
2444_LIBCPP_CONSTEXPR_AFTER_CXX172472_LIBCPP_CONSTEXPR_SINCE_CXX20
2445basic_string<_CharT, _Traits, _Allocator>&2473basic_string<_CharT, _Traits, _Allocator>&
2446basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n)2474basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n)
2447{2475{
...@@ -2452,7 +2480,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_ty...@@ -2452,7 +2480,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_ty
2452}2480}
24532481
2454template <class _CharT, class _Traits, class _Allocator>2482template <class _CharT, class _Traits, class _Allocator>
2455_LIBCPP_CONSTEXPR_AFTER_CXX172483_LIBCPP_CONSTEXPR_SINCE_CXX20
2456basic_string<_CharT, _Traits, _Allocator>&2484basic_string<_CharT, _Traits, _Allocator>&
2457basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)2485basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)
2458{2486{
...@@ -2468,7 +2496,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)...@@ -2468,7 +2496,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)
2468}2496}
24692497
2470template <class _CharT, class _Traits, class _Allocator>2498template <class _CharT, class _Traits, class _Allocator>
2471_LIBCPP_CONSTEXPR_AFTER_CXX172499_LIBCPP_CONSTEXPR_SINCE_CXX20
2472basic_string<_CharT, _Traits, _Allocator>&2500basic_string<_CharT, _Traits, _Allocator>&
2473basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c)2501basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c)
2474{2502{
...@@ -2490,7 +2518,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c)...@@ -2490,7 +2518,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c)
2490}2518}
24912519
2492template <class _CharT, class _Traits, class _Allocator>2520template <class _CharT, class _Traits, class _Allocator>
2493_LIBCPP_CONSTEXPR_AFTER_CXX172521_LIBCPP_CONSTEXPR_SINCE_CXX20
2494basic_string<_CharT, _Traits, _Allocator>&2522basic_string<_CharT, _Traits, _Allocator>&
2495basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)2523basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)
2496{2524{
...@@ -2498,7 +2526,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)...@@ -2498,7 +2526,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)
2498 __copy_assign_alloc(__str);2526 __copy_assign_alloc(__str);
2499 if (!__is_long()) {2527 if (!__is_long()) {
2500 if (!__str.__is_long()) {2528 if (!__str.__is_long()) {
2501 __r_.first().__r = __str.__r_.first().__r;2529 __r_.first() = __str.__r_.first();
2502 } else {2530 } else {
2503 return __assign_no_alias<true>(__str.data(), __str.size());2531 return __assign_no_alias<true>(__str.data(), __str.size());
2504 }2532 }
...@@ -2512,7 +2540,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)...@@ -2512,7 +2540,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)
2512#ifndef _LIBCPP_CXX03_LANG2540#ifndef _LIBCPP_CXX03_LANG
25132541
2514template <class _CharT, class _Traits, class _Allocator>2542template <class _CharT, class _Traits, class _Allocator>
2515inline _LIBCPP_CONSTEXPR_AFTER_CXX172543inline _LIBCPP_CONSTEXPR_SINCE_CXX20
2516void2544void
2517basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type)2545basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type)
2518 _NOEXCEPT_(__alloc_traits::is_always_equal::value)2546 _NOEXCEPT_(__alloc_traits::is_always_equal::value)
...@@ -2524,7 +2552,7 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, fa...@@ -2524,7 +2552,7 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, fa
2524}2552}
25252553
2526template <class _CharT, class _Traits, class _Allocator>2554template <class _CharT, class _Traits, class _Allocator>
2527inline _LIBCPP_CONSTEXPR_AFTER_CXX172555inline _LIBCPP_CONSTEXPR_SINCE_CXX20
2528void2556void
2529basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type)2557basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type)
2530#if _LIBCPP_STD_VER > 142558#if _LIBCPP_STD_VER > 14
...@@ -2553,22 +2581,11 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr...@@ -2553,22 +2581,11 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr
2553 }2581 }
2554}2582}
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
2567#endif2584#endif
25682585
2569template <class _CharT, class _Traits, class _Allocator>2586template <class _CharT, class _Traits, class _Allocator>
2570template<class _InputIterator>2587template<class _InputIterator>
2571_LIBCPP_CONSTEXPR_AFTER_CXX172588_LIBCPP_CONSTEXPR_SINCE_CXX20
2572__enable_if_t2589__enable_if_t
2573<2590<
2574 __is_exactly_cpp17_input_iterator<_InputIterator>::value,2591 __is_exactly_cpp17_input_iterator<_InputIterator>::value,
...@@ -2583,7 +2600,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _Input...@@ -2583,7 +2600,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _Input
25832600
2584template <class _CharT, class _Traits, class _Allocator>2601template <class _CharT, class _Traits, class _Allocator>
2585template<class _ForwardIterator>2602template<class _ForwardIterator>
2586_LIBCPP_CONSTEXPR_AFTER_CXX172603_LIBCPP_CONSTEXPR_SINCE_CXX20
2587__enable_if_t2604__enable_if_t
2588<2605<
2589 __is_cpp17_forward_iterator<_ForwardIterator>::value,2606 __is_cpp17_forward_iterator<_ForwardIterator>::value,
...@@ -2619,7 +2636,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _For...@@ -2619,7 +2636,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _For
2619}2636}
26202637
2621template <class _CharT, class _Traits, class _Allocator>2638template <class _CharT, class _Traits, class _Allocator>
2622_LIBCPP_CONSTEXPR_AFTER_CXX172639_LIBCPP_CONSTEXPR_SINCE_CXX20
2623basic_string<_CharT, _Traits, _Allocator>&2640basic_string<_CharT, _Traits, _Allocator>&
2624basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n)2641basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n)
2625{2642{
...@@ -2631,7 +2648,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, siz...@@ -2631,7 +2648,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, siz
26312648
2632template <class _CharT, class _Traits, class _Allocator>2649template <class _CharT, class _Traits, class _Allocator>
2633template <class _Tp>2650template <class _Tp>
2634_LIBCPP_CONSTEXPR_AFTER_CXX172651_LIBCPP_CONSTEXPR_SINCE_CXX20
2635__enable_if_t2652__enable_if_t
2636<2653<
2637 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value2654 __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...@@ -2649,14 +2666,14 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type __p
26492666
26502667
2651template <class _CharT, class _Traits, class _Allocator>2668template <class _CharT, class _Traits, class _Allocator>
2652_LIBCPP_CONSTEXPR_AFTER_CXX172669_LIBCPP_CONSTEXPR_SINCE_CXX20
2653basic_string<_CharT, _Traits, _Allocator>&2670basic_string<_CharT, _Traits, _Allocator>&
2654basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s) {2671basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s) {
2655 return __assign_external(__s, traits_type::length(__s));2672 return __assign_external(__s, traits_type::length(__s));
2656}2673}
26572674
2658template <class _CharT, class _Traits, class _Allocator>2675template <class _CharT, class _Traits, class _Allocator>
2659_LIBCPP_CONSTEXPR_AFTER_CXX172676_LIBCPP_CONSTEXPR_SINCE_CXX20
2660basic_string<_CharT, _Traits, _Allocator>&2677basic_string<_CharT, _Traits, _Allocator>&
2661basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s)2678basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s)
2662{2679{
...@@ -2670,7 +2687,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s)...@@ -2670,7 +2687,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s)
2670// append2687// append
26712688
2672template <class _CharT, class _Traits, class _Allocator>2689template <class _CharT, class _Traits, class _Allocator>
2673_LIBCPP_CONSTEXPR_AFTER_CXX172690_LIBCPP_CONSTEXPR_SINCE_CXX20
2674basic_string<_CharT, _Traits, _Allocator>&2691basic_string<_CharT, _Traits, _Allocator>&
2675basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n)2692basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n)
2676{2693{
...@@ -2694,7 +2711,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_ty...@@ -2694,7 +2711,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_ty
2694}2711}
26952712
2696template <class _CharT, class _Traits, class _Allocator>2713template <class _CharT, class _Traits, class _Allocator>
2697_LIBCPP_CONSTEXPR_AFTER_CXX172714_LIBCPP_CONSTEXPR_SINCE_CXX20
2698basic_string<_CharT, _Traits, _Allocator>&2715basic_string<_CharT, _Traits, _Allocator>&
2699basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c)2716basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c)
2700{2717{
...@@ -2714,7 +2731,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c)...@@ -2714,7 +2731,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c)
2714}2731}
27152732
2716template <class _CharT, class _Traits, class _Allocator>2733template <class _CharT, class _Traits, class _Allocator>
2717_LIBCPP_CONSTEXPR_AFTER_CXX17 inline void2734_LIBCPP_CONSTEXPR_SINCE_CXX20 inline void
2718basic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n)2735basic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n)
2719{2736{
2720 if (__n)2737 if (__n)
...@@ -2731,7 +2748,7 @@ basic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n)...@@ -2731,7 +2748,7 @@ basic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n)
2731}2748}
27322749
2733template <class _CharT, class _Traits, class _Allocator>2750template <class _CharT, class _Traits, class _Allocator>
2734_LIBCPP_CONSTEXPR_AFTER_CXX172751_LIBCPP_CONSTEXPR_SINCE_CXX20
2735void2752void
2736basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c)2753basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c)
2737{2754{
...@@ -2770,7 +2787,7 @@ basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c)...@@ -2770,7 +2787,7 @@ basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c)
27702787
2771template <class _CharT, class _Traits, class _Allocator>2788template <class _CharT, class _Traits, class _Allocator>
2772template<class _ForwardIterator>2789template<class _ForwardIterator>
2773_LIBCPP_CONSTEXPR_AFTER_CXX172790_LIBCPP_CONSTEXPR_SINCE_CXX20
2774__enable_if_t2791__enable_if_t
2775<2792<
2776 __is_cpp17_forward_iterator<_ForwardIterator>::value,2793 __is_cpp17_forward_iterator<_ForwardIterator>::value,
...@@ -2805,15 +2822,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(...@@ -2805,15 +2822,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(
2805}2822}
28062823
2807template <class _CharT, class _Traits, class _Allocator>2824template <class _CharT, class _Traits, class _Allocator>
2808inline _LIBCPP_CONSTEXPR_AFTER_CXX172825_LIBCPP_CONSTEXPR_SINCE_CXX20
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
2817basic_string<_CharT, _Traits, _Allocator>&2826basic_string<_CharT, _Traits, _Allocator>&
2818basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, size_type __pos, size_type __n)2827basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, size_type __pos, size_type __n)
2819{2828{
...@@ -2825,7 +2834,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, siz...@@ -2825,7 +2834,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, siz
28252834
2826template <class _CharT, class _Traits, class _Allocator>2835template <class _CharT, class _Traits, class _Allocator>
2827template <class _Tp>2836template <class _Tp>
2828_LIBCPP_CONSTEXPR_AFTER_CXX172837_LIBCPP_CONSTEXPR_SINCE_CXX20
2829 __enable_if_t2838 __enable_if_t
2830 <2839 <
2831 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,2840 __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...@@ -2841,7 +2850,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const _Tp & __t, size_type __p
2841}2850}
28422851
2843template <class _CharT, class _Traits, class _Allocator>2852template <class _CharT, class _Traits, class _Allocator>
2844_LIBCPP_CONSTEXPR_AFTER_CXX172853_LIBCPP_CONSTEXPR_SINCE_CXX20
2845basic_string<_CharT, _Traits, _Allocator>&2854basic_string<_CharT, _Traits, _Allocator>&
2846basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s)2855basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s)
2847{2856{
...@@ -2852,7 +2861,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s)...@@ -2852,7 +2861,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s)
2852// insert2861// insert
28532862
2854template <class _CharT, class _Traits, class _Allocator>2863template <class _CharT, class _Traits, class _Allocator>
2855_LIBCPP_CONSTEXPR_AFTER_CXX172864_LIBCPP_CONSTEXPR_SINCE_CXX20
2856basic_string<_CharT, _Traits, _Allocator>&2865basic_string<_CharT, _Traits, _Allocator>&
2857basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n)2866basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n)
2858{2867{
...@@ -2892,7 +2901,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t...@@ -2892,7 +2901,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t
2892}2901}
28932902
2894template <class _CharT, class _Traits, class _Allocator>2903template <class _CharT, class _Traits, class _Allocator>
2895_LIBCPP_CONSTEXPR_AFTER_CXX172904_LIBCPP_CONSTEXPR_SINCE_CXX20
2896basic_string<_CharT, _Traits, _Allocator>&2905basic_string<_CharT, _Traits, _Allocator>&
2897basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n, value_type __c)2906basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n, value_type __c)
2898{2907{
...@@ -2925,7 +2934,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n...@@ -2925,7 +2934,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n
29252934
2926template <class _CharT, class _Traits, class _Allocator>2935template <class _CharT, class _Traits, class _Allocator>
2927template<class _InputIterator>2936template<class _InputIterator>
2928_LIBCPP_CONSTEXPR_AFTER_CXX172937_LIBCPP_CONSTEXPR_SINCE_CXX20
2929__enable_if_t2938__enable_if_t
2930<2939<
2931 __is_exactly_cpp17_input_iterator<_InputIterator>::value,2940 __is_exactly_cpp17_input_iterator<_InputIterator>::value,
...@@ -2942,7 +2951,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIt...@@ -2942,7 +2951,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIt
29422951
2943template <class _CharT, class _Traits, class _Allocator>2952template <class _CharT, class _Traits, class _Allocator>
2944template<class _ForwardIterator>2953template<class _ForwardIterator>
2945_LIBCPP_CONSTEXPR_AFTER_CXX172954_LIBCPP_CONSTEXPR_SINCE_CXX20
2946__enable_if_t2955__enable_if_t
2947<2956<
2948 __is_cpp17_forward_iterator<_ForwardIterator>::value,2957 __is_cpp17_forward_iterator<_ForwardIterator>::value,
...@@ -2970,15 +2979,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _Forward...@@ -2970,15 +2979,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _Forward
2970}2979}
29712980
2972template <class _CharT, class _Traits, class _Allocator>2981template <class _CharT, class _Traits, class _Allocator>
2973inline _LIBCPP_CONSTEXPR_AFTER_CXX172982_LIBCPP_CONSTEXPR_SINCE_CXX20
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
2982basic_string<_CharT, _Traits, _Allocator>&2983basic_string<_CharT, _Traits, _Allocator>&
2983basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str,2984basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str,
2984 size_type __pos2, size_type __n)2985 size_type __pos2, size_type __n)
...@@ -2991,7 +2992,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_...@@ -2991,7 +2992,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_
29912992
2992template <class _CharT, class _Traits, class _Allocator>2993template <class _CharT, class _Traits, class _Allocator>
2993template <class _Tp>2994template <class _Tp>
2994_LIBCPP_CONSTEXPR_AFTER_CXX172995_LIBCPP_CONSTEXPR_SINCE_CXX20
2995__enable_if_t2996__enable_if_t
2996<2997<
2997 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,2998 __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& _...@@ -3008,7 +3009,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& _
3008}3009}
30093010
3010template <class _CharT, class _Traits, class _Allocator>3011template <class _CharT, class _Traits, class _Allocator>
3011_LIBCPP_CONSTEXPR_AFTER_CXX173012_LIBCPP_CONSTEXPR_SINCE_CXX20
3012basic_string<_CharT, _Traits, _Allocator>&3013basic_string<_CharT, _Traits, _Allocator>&
3013basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s)3014basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s)
3014{3015{
...@@ -3017,7 +3018,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t...@@ -3017,7 +3018,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t
3017}3018}
30183019
3019template <class _CharT, class _Traits, class _Allocator>3020template <class _CharT, class _Traits, class _Allocator>
3020_LIBCPP_CONSTEXPR_AFTER_CXX173021_LIBCPP_CONSTEXPR_SINCE_CXX20
3021typename basic_string<_CharT, _Traits, _Allocator>::iterator3022typename basic_string<_CharT, _Traits, _Allocator>::iterator
3022basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_type __c)3023basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_type __c)
3023{3024{
...@@ -3047,23 +3048,10 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_ty...@@ -3047,23 +3048,10 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_ty
3047 return begin() + static_cast<difference_type>(__ip);3048 return begin() + static_cast<difference_type>(__ip);
3048}3049}
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
3063// replace3051// replace
30643052
3065template <class _CharT, class _Traits, class _Allocator>3053template <class _CharT, class _Traits, class _Allocator>
3066_LIBCPP_CONSTEXPR_AFTER_CXX173054_LIBCPP_CONSTEXPR_SINCE_CXX20
3067basic_string<_CharT, _Traits, _Allocator>&3055basic_string<_CharT, _Traits, _Allocator>&
3068basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2)3056basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2)
3069 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK3057 _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
...@@ -3117,7 +3105,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __...@@ -3117,7 +3105,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
3117}3105}
31183106
3119template <class _CharT, class _Traits, class _Allocator>3107template <class _CharT, class _Traits, class _Allocator>
3120_LIBCPP_CONSTEXPR_AFTER_CXX173108_LIBCPP_CONSTEXPR_SINCE_CXX20
3121basic_string<_CharT, _Traits, _Allocator>&3109basic_string<_CharT, _Traits, _Allocator>&
3122basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c)3110basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c)
3123{3111{
...@@ -3148,7 +3136,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __...@@ -3148,7 +3136,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
31483136
3149template <class _CharT, class _Traits, class _Allocator>3137template <class _CharT, class _Traits, class _Allocator>
3150template<class _InputIterator>3138template<class _InputIterator>
3151_LIBCPP_CONSTEXPR_AFTER_CXX173139_LIBCPP_CONSTEXPR_SINCE_CXX20
3152__enable_if_t3140__enable_if_t
3153<3141<
3154 __is_cpp17_input_iterator<_InputIterator>::value,3142 __is_cpp17_input_iterator<_InputIterator>::value,
...@@ -3162,15 +3150,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it...@@ -3162,15 +3150,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it
3162}3150}
31633151
3164template <class _CharT, class _Traits, class _Allocator>3152template <class _CharT, class _Traits, class _Allocator>
3165inline _LIBCPP_CONSTEXPR_AFTER_CXX173153_LIBCPP_CONSTEXPR_SINCE_CXX20
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
3174basic_string<_CharT, _Traits, _Allocator>&3154basic_string<_CharT, _Traits, _Allocator>&
3175basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str,3155basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str,
3176 size_type __pos2, size_type __n2)3156 size_type __pos2, size_type __n2)
...@@ -3183,7 +3163,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _...@@ -3183,7 +3163,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _
31833163
3184template <class _CharT, class _Traits, class _Allocator>3164template <class _CharT, class _Traits, class _Allocator>
3185template <class _Tp>3165template <class _Tp>
3186_LIBCPP_CONSTEXPR_AFTER_CXX173166_LIBCPP_CONSTEXPR_SINCE_CXX20
3187__enable_if_t3167__enable_if_t
3188<3168<
3189 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,3169 __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 _...@@ -3200,7 +3180,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _
3200}3180}
32013181
3202template <class _CharT, class _Traits, class _Allocator>3182template <class _CharT, class _Traits, class _Allocator>
3203_LIBCPP_CONSTEXPR_AFTER_CXX173183_LIBCPP_CONSTEXPR_SINCE_CXX20
3204basic_string<_CharT, _Traits, _Allocator>&3184basic_string<_CharT, _Traits, _Allocator>&
3205basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s)3185basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s)
3206{3186{
...@@ -3208,45 +3188,12 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __...@@ -3208,45 +3188,12 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
3208 return replace(__pos, __n1, __s, traits_type::length(__s));3188 return replace(__pos, __n1, __s, traits_type::length(__s));
3209}3189}
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
3244// erase3191// erase
32453192
3246// 'externally instantiated' erase() implementation, called when __n != npos.3193// 'externally instantiated' erase() implementation, called when __n != npos.
3247// Does not check __pos against size()3194// Does not check __pos against size()
3248template <class _CharT, class _Traits, class _Allocator>3195template <class _CharT, class _Traits, class _Allocator>
3249_LIBCPP_CONSTEXPR_AFTER_CXX173196_LIBCPP_CONSTEXPR_SINCE_CXX20
3250void3197void
3251basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(3198basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(
3252 size_type __pos, size_type __n)3199 size_type __pos, size_type __n)
...@@ -3264,7 +3211,7 @@ basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(...@@ -3264,7 +3211,7 @@ basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(
3264}3211}
32653212
3266template <class _CharT, class _Traits, class _Allocator>3213template <class _CharT, class _Traits, class _Allocator>
3267_LIBCPP_CONSTEXPR_AFTER_CXX173214_LIBCPP_CONSTEXPR_SINCE_CXX20
3268basic_string<_CharT, _Traits, _Allocator>&3215basic_string<_CharT, _Traits, _Allocator>&
3269basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos,3216basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos,
3270 size_type __n) {3217 size_type __n) {
...@@ -3279,7 +3226,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos,...@@ -3279,7 +3226,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos,
3279}3226}
32803227
3281template <class _CharT, class _Traits, class _Allocator>3228template <class _CharT, class _Traits, class _Allocator>
3282inline _LIBCPP_CONSTEXPR_AFTER_CXX173229inline _LIBCPP_CONSTEXPR_SINCE_CXX20
3283typename basic_string<_CharT, _Traits, _Allocator>::iterator3230typename basic_string<_CharT, _Traits, _Allocator>::iterator
3284basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos)3231basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos)
3285{3232{
...@@ -3295,7 +3242,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos)...@@ -3295,7 +3242,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos)
3295}3242}
32963243
3297template <class _CharT, class _Traits, class _Allocator>3244template <class _CharT, class _Traits, class _Allocator>
3298inline _LIBCPP_CONSTEXPR_AFTER_CXX173245inline _LIBCPP_CONSTEXPR_SINCE_CXX20
3299typename basic_string<_CharT, _Traits, _Allocator>::iterator3246typename basic_string<_CharT, _Traits, _Allocator>::iterator
3300basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last)3247basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last)
3301{3248{
...@@ -3311,7 +3258,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_i...@@ -3311,7 +3258,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_i
3311}3258}
33123259
3313template <class _CharT, class _Traits, class _Allocator>3260template <class _CharT, class _Traits, class _Allocator>
3314inline _LIBCPP_CONSTEXPR_AFTER_CXX173261inline _LIBCPP_CONSTEXPR_SINCE_CXX20
3315void3262void
3316basic_string<_CharT, _Traits, _Allocator>::pop_back()3263basic_string<_CharT, _Traits, _Allocator>::pop_back()
3317{3264{
...@@ -3320,7 +3267,7 @@ basic_string<_CharT, _Traits, _Allocator>::pop_back()...@@ -3320,7 +3267,7 @@ basic_string<_CharT, _Traits, _Allocator>::pop_back()
3320}3267}
33213268
3322template <class _CharT, class _Traits, class _Allocator>3269template <class _CharT, class _Traits, class _Allocator>
3323inline _LIBCPP_CONSTEXPR_AFTER_CXX173270inline _LIBCPP_CONSTEXPR_SINCE_CXX20
3324void3271void
3325basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT3272basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT
3326{3273{
...@@ -3338,15 +3285,7 @@ basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT...@@ -3338,15 +3285,7 @@ basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT
3338}3285}
33393286
3340template <class _CharT, class _Traits, class _Allocator>3287template <class _CharT, class _Traits, class _Allocator>
3341inline _LIBCPP_CONSTEXPR_AFTER_CXX173288_LIBCPP_CONSTEXPR_SINCE_CXX20
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
3350void3289void
3351basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c)3290basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c)
3352{3291{
...@@ -3358,7 +3297,7 @@ basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c)...@@ -3358,7 +3297,7 @@ basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c)
3358}3297}
33593298
3360template <class _CharT, class _Traits, class _Allocator>3299template <class _CharT, class _Traits, class _Allocator>
3361_LIBCPP_CONSTEXPR_AFTER_CXX17 inline void3300_LIBCPP_CONSTEXPR_SINCE_CXX20 inline void
3362basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n)3301basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n)
3363{3302{
3364 size_type __sz = size();3303 size_type __sz = size();
...@@ -3369,21 +3308,7 @@ basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n)...@@ -3369,21 +3308,7 @@ basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n)
3369}3308}
33703309
3371template <class _CharT, class _Traits, class _Allocator>3310template <class _CharT, class _Traits, class _Allocator>
3372inline _LIBCPP_CONSTEXPR_AFTER_CXX173311_LIBCPP_CONSTEXPR_SINCE_CXX20
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
3387void3312void
3388basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity)3313basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity)
3389{3314{
...@@ -3404,7 +3329,7 @@ basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacit...@@ -3404,7 +3329,7 @@ basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacit
3404}3329}
34053330
3406template <class _CharT, class _Traits, class _Allocator>3331template <class _CharT, class _Traits, class _Allocator>
3407inline _LIBCPP_CONSTEXPR_AFTER_CXX173332inline _LIBCPP_CONSTEXPR_SINCE_CXX20
3408void3333void
3409basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT3334basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT
3410{3335{
...@@ -3415,7 +3340,7 @@ basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT...@@ -3415,7 +3340,7 @@ basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT
3415}3340}
34163341
3417template <class _CharT, class _Traits, class _Allocator>3342template <class _CharT, class _Traits, class _Allocator>
3418inline _LIBCPP_CONSTEXPR_AFTER_CXX173343inline _LIBCPP_CONSTEXPR_SINCE_CXX20
3419void3344void
3420basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target_capacity)3345basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target_capacity)
3421{3346{
...@@ -3479,25 +3404,7 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target...@@ -3479,25 +3404,7 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target
3479}3404}
34803405
3481template <class _CharT, class _Traits, class _Allocator>3406template <class _CharT, class _Traits, class _Allocator>
3482inline _LIBCPP_CONSTEXPR_AFTER_CXX173407_LIBCPP_CONSTEXPR_SINCE_CXX20
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
3501typename basic_string<_CharT, _Traits, _Allocator>::const_reference3408typename basic_string<_CharT, _Traits, _Allocator>::const_reference
3502basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const3409basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const
3503{3410{
...@@ -3507,7 +3414,7 @@ basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const...@@ -3507,7 +3414,7 @@ basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const
3507}3414}
35083415
3509template <class _CharT, class _Traits, class _Allocator>3416template <class _CharT, class _Traits, class _Allocator>
3510_LIBCPP_CONSTEXPR_AFTER_CXX173417_LIBCPP_CONSTEXPR_SINCE_CXX20
3511typename basic_string<_CharT, _Traits, _Allocator>::reference3418typename basic_string<_CharT, _Traits, _Allocator>::reference
3512basic_string<_CharT, _Traits, _Allocator>::at(size_type __n)3419basic_string<_CharT, _Traits, _Allocator>::at(size_type __n)
3513{3420{
...@@ -3517,43 +3424,7 @@ basic_string<_CharT, _Traits, _Allocator>::at(size_type __n)...@@ -3517,43 +3424,7 @@ basic_string<_CharT, _Traits, _Allocator>::at(size_type __n)
3517}3424}
35183425
3519template <class _CharT, class _Traits, class _Allocator>3426template <class _CharT, class _Traits, class _Allocator>
3520inline _LIBCPP_CONSTEXPR_AFTER_CXX173427_LIBCPP_CONSTEXPR_SINCE_CXX20
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
3557typename basic_string<_CharT, _Traits, _Allocator>::size_type3428typename basic_string<_CharT, _Traits, _Allocator>::size_type
3558basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const3429basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const
3559{3430{
...@@ -3566,15 +3437,7 @@ basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n,...@@ -3566,15 +3437,7 @@ basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n,
3566}3437}
35673438
3568template <class _CharT, class _Traits, class _Allocator>3439template <class _CharT, class _Traits, class _Allocator>
3569inline _LIBCPP_CONSTEXPR_AFTER_CXX173440inline _LIBCPP_CONSTEXPR_SINCE_CXX20
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
3578void3441void
3579basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)3442basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)
3580#if _LIBCPP_STD_VER >= 143443#if _LIBCPP_STD_VER >= 14
...@@ -3610,30 +3473,30 @@ struct _LIBCPP_HIDDEN __traits_eq...@@ -3610,30 +3473,30 @@ struct _LIBCPP_HIDDEN __traits_eq
3610};3473};
36113474
3612template<class _CharT, class _Traits, class _Allocator>3475template<class _CharT, class _Traits, class _Allocator>
3613_LIBCPP_CONSTEXPR_AFTER_CXX173476_LIBCPP_CONSTEXPR_SINCE_CXX20
3614typename basic_string<_CharT, _Traits, _Allocator>::size_type3477typename basic_string<_CharT, _Traits, _Allocator>::size_type
3615basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,3478basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,
3616 size_type __pos,3479 size_type __pos,
3617 size_type __n) const _NOEXCEPT3480 size_type __n) const _NOEXCEPT
3618{3481{
3619 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find(): received nullptr");3482 _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>
3621 (data(), size(), __s, __pos, __n);3484 (data(), size(), __s, __pos, __n);
3622}3485}
36233486
3624template<class _CharT, class _Traits, class _Allocator>3487template<class _CharT, class _Traits, class _Allocator>
3625inline _LIBCPP_CONSTEXPR_AFTER_CXX173488inline _LIBCPP_CONSTEXPR_SINCE_CXX20
3626typename basic_string<_CharT, _Traits, _Allocator>::size_type3489typename basic_string<_CharT, _Traits, _Allocator>::size_type
3627basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str,3490basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str,
3628 size_type __pos) const _NOEXCEPT3491 size_type __pos) const _NOEXCEPT
3629{3492{
3630 return __str_find<value_type, size_type, traits_type, npos>3493 return std::__str_find<value_type, size_type, traits_type, npos>
3631 (data(), size(), __str.data(), __pos, __str.size());3494 (data(), size(), __str.data(), __pos, __str.size());
3632}3495}
36333496
3634template<class _CharT, class _Traits, class _Allocator>3497template<class _CharT, class _Traits, class _Allocator>
3635template <class _Tp>3498template <class _Tp>
3636_LIBCPP_CONSTEXPR_AFTER_CXX173499_LIBCPP_CONSTEXPR_SINCE_CXX20
3637__enable_if_t3500__enable_if_t
3638<3501<
3639 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,3502 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
...@@ -3643,58 +3506,58 @@ basic_string<_CharT, _Traits, _Allocator>::find(const _Tp &__t,...@@ -3643,58 +3506,58 @@ basic_string<_CharT, _Traits, _Allocator>::find(const _Tp &__t,
3643 size_type __pos) const _NOEXCEPT3506 size_type __pos) const _NOEXCEPT
3644{3507{
3645 __self_view __sv = __t;3508 __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>
3647 (data(), size(), __sv.data(), __pos, __sv.size());3510 (data(), size(), __sv.data(), __pos, __sv.size());
3648}3511}
36493512
3650template<class _CharT, class _Traits, class _Allocator>3513template<class _CharT, class _Traits, class _Allocator>
3651inline _LIBCPP_CONSTEXPR_AFTER_CXX173514inline _LIBCPP_CONSTEXPR_SINCE_CXX20
3652typename basic_string<_CharT, _Traits, _Allocator>::size_type3515typename basic_string<_CharT, _Traits, _Allocator>::size_type
3653basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,3516basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,
3654 size_type __pos) const _NOEXCEPT3517 size_type __pos) const _NOEXCEPT
3655{3518{
3656 _LIBCPP_ASSERT(__s != nullptr, "string::find(): received nullptr");3519 _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>
3658 (data(), size(), __s, __pos, traits_type::length(__s));3521 (data(), size(), __s, __pos, traits_type::length(__s));
3659}3522}
36603523
3661template<class _CharT, class _Traits, class _Allocator>3524template<class _CharT, class _Traits, class _Allocator>
3662_LIBCPP_CONSTEXPR_AFTER_CXX173525_LIBCPP_CONSTEXPR_SINCE_CXX20
3663typename basic_string<_CharT, _Traits, _Allocator>::size_type3526typename basic_string<_CharT, _Traits, _Allocator>::size_type
3664basic_string<_CharT, _Traits, _Allocator>::find(value_type __c,3527basic_string<_CharT, _Traits, _Allocator>::find(value_type __c,
3665 size_type __pos) const _NOEXCEPT3528 size_type __pos) const _NOEXCEPT
3666{3529{
3667 return __str_find<value_type, size_type, traits_type, npos>3530 return std::__str_find<value_type, size_type, traits_type, npos>
3668 (data(), size(), __c, __pos);3531 (data(), size(), __c, __pos);
3669}3532}
36703533
3671// rfind3534// rfind
36723535
3673template<class _CharT, class _Traits, class _Allocator>3536template<class _CharT, class _Traits, class _Allocator>
3674_LIBCPP_CONSTEXPR_AFTER_CXX173537_LIBCPP_CONSTEXPR_SINCE_CXX20
3675typename basic_string<_CharT, _Traits, _Allocator>::size_type3538typename basic_string<_CharT, _Traits, _Allocator>::size_type
3676basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,3539basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,
3677 size_type __pos,3540 size_type __pos,
3678 size_type __n) const _NOEXCEPT3541 size_type __n) const _NOEXCEPT
3679{3542{
3680 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::rfind(): received nullptr");3543 _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>
3682 (data(), size(), __s, __pos, __n);3545 (data(), size(), __s, __pos, __n);
3683}3546}
36843547
3685template<class _CharT, class _Traits, class _Allocator>3548template<class _CharT, class _Traits, class _Allocator>
3686inline _LIBCPP_CONSTEXPR_AFTER_CXX173549inline _LIBCPP_CONSTEXPR_SINCE_CXX20
3687typename basic_string<_CharT, _Traits, _Allocator>::size_type3550typename basic_string<_CharT, _Traits, _Allocator>::size_type
3688basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str,3551basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str,
3689 size_type __pos) const _NOEXCEPT3552 size_type __pos) const _NOEXCEPT
3690{3553{
3691 return __str_rfind<value_type, size_type, traits_type, npos>3554 return std::__str_rfind<value_type, size_type, traits_type, npos>
3692 (data(), size(), __str.data(), __pos, __str.size());3555 (data(), size(), __str.data(), __pos, __str.size());
3693}3556}
36943557
3695template<class _CharT, class _Traits, class _Allocator>3558template<class _CharT, class _Traits, class _Allocator>
3696template <class _Tp>3559template <class _Tp>
3697_LIBCPP_CONSTEXPR_AFTER_CXX173560_LIBCPP_CONSTEXPR_SINCE_CXX20
3698__enable_if_t3561__enable_if_t
3699<3562<
3700 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,3563 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
...@@ -3704,58 +3567,58 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t,...@@ -3704,58 +3567,58 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t,
3704 size_type __pos) const _NOEXCEPT3567 size_type __pos) const _NOEXCEPT
3705{3568{
3706 __self_view __sv = __t;3569 __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>
3708 (data(), size(), __sv.data(), __pos, __sv.size());3571 (data(), size(), __sv.data(), __pos, __sv.size());
3709}3572}
37103573
3711template<class _CharT, class _Traits, class _Allocator>3574template<class _CharT, class _Traits, class _Allocator>
3712inline _LIBCPP_CONSTEXPR_AFTER_CXX173575inline _LIBCPP_CONSTEXPR_SINCE_CXX20
3713typename basic_string<_CharT, _Traits, _Allocator>::size_type3576typename basic_string<_CharT, _Traits, _Allocator>::size_type
3714basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,3577basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,
3715 size_type __pos) const _NOEXCEPT3578 size_type __pos) const _NOEXCEPT
3716{3579{
3717 _LIBCPP_ASSERT(__s != nullptr, "string::rfind(): received nullptr");3580 _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>
3719 (data(), size(), __s, __pos, traits_type::length(__s));3582 (data(), size(), __s, __pos, traits_type::length(__s));
3720}3583}
37213584
3722template<class _CharT, class _Traits, class _Allocator>3585template<class _CharT, class _Traits, class _Allocator>
3723_LIBCPP_CONSTEXPR_AFTER_CXX173586_LIBCPP_CONSTEXPR_SINCE_CXX20
3724typename basic_string<_CharT, _Traits, _Allocator>::size_type3587typename basic_string<_CharT, _Traits, _Allocator>::size_type
3725basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c,3588basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c,
3726 size_type __pos) const _NOEXCEPT3589 size_type __pos) const _NOEXCEPT
3727{3590{
3728 return __str_rfind<value_type, size_type, traits_type, npos>3591 return std::__str_rfind<value_type, size_type, traits_type, npos>
3729 (data(), size(), __c, __pos);3592 (data(), size(), __c, __pos);
3730}3593}
37313594
3732// find_first_of3595// find_first_of
37333596
3734template<class _CharT, class _Traits, class _Allocator>3597template<class _CharT, class _Traits, class _Allocator>
3735_LIBCPP_CONSTEXPR_AFTER_CXX173598_LIBCPP_CONSTEXPR_SINCE_CXX20
3736typename basic_string<_CharT, _Traits, _Allocator>::size_type3599typename basic_string<_CharT, _Traits, _Allocator>::size_type
3737basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,3600basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,
3738 size_type __pos,3601 size_type __pos,
3739 size_type __n) const _NOEXCEPT3602 size_type __n) const _NOEXCEPT
3740{3603{
3741 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr");3604 _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>
3743 (data(), size(), __s, __pos, __n);3606 (data(), size(), __s, __pos, __n);
3744}3607}
37453608
3746template<class _CharT, class _Traits, class _Allocator>3609template<class _CharT, class _Traits, class _Allocator>
3747inline _LIBCPP_CONSTEXPR_AFTER_CXX173610inline _LIBCPP_CONSTEXPR_SINCE_CXX20
3748typename basic_string<_CharT, _Traits, _Allocator>::size_type3611typename basic_string<_CharT, _Traits, _Allocator>::size_type
3749basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str,3612basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str,
3750 size_type __pos) const _NOEXCEPT3613 size_type __pos) const _NOEXCEPT
3751{3614{
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>
3753 (data(), size(), __str.data(), __pos, __str.size());3616 (data(), size(), __str.data(), __pos, __str.size());
3754}3617}
37553618
3756template<class _CharT, class _Traits, class _Allocator>3619template<class _CharT, class _Traits, class _Allocator>
3757template <class _Tp>3620template <class _Tp>
3758_LIBCPP_CONSTEXPR_AFTER_CXX173621_LIBCPP_CONSTEXPR_SINCE_CXX20
3759__enable_if_t3622__enable_if_t
3760<3623<
3761 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,3624 __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,...@@ -3765,23 +3628,23 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const _Tp& __t,
3765 size_type __pos) const _NOEXCEPT3628 size_type __pos) const _NOEXCEPT
3766{3629{
3767 __self_view __sv = __t;3630 __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>
3769 (data(), size(), __sv.data(), __pos, __sv.size());3632 (data(), size(), __sv.data(), __pos, __sv.size());
3770}3633}
37713634
3772template<class _CharT, class _Traits, class _Allocator>3635template<class _CharT, class _Traits, class _Allocator>
3773inline _LIBCPP_CONSTEXPR_AFTER_CXX173636inline _LIBCPP_CONSTEXPR_SINCE_CXX20
3774typename basic_string<_CharT, _Traits, _Allocator>::size_type3637typename basic_string<_CharT, _Traits, _Allocator>::size_type
3775basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,3638basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,
3776 size_type __pos) const _NOEXCEPT3639 size_type __pos) const _NOEXCEPT
3777{3640{
3778 _LIBCPP_ASSERT(__s != nullptr, "string::find_first_of(): received nullptr");3641 _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>
3780 (data(), size(), __s, __pos, traits_type::length(__s));3643 (data(), size(), __s, __pos, traits_type::length(__s));
3781}3644}
37823645
3783template<class _CharT, class _Traits, class _Allocator>3646template<class _CharT, class _Traits, class _Allocator>
3784inline _LIBCPP_CONSTEXPR_AFTER_CXX173647inline _LIBCPP_CONSTEXPR_SINCE_CXX20
3785typename basic_string<_CharT, _Traits, _Allocator>::size_type3648typename basic_string<_CharT, _Traits, _Allocator>::size_type
3786basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c,3649basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c,
3787 size_type __pos) const _NOEXCEPT3650 size_type __pos) const _NOEXCEPT
...@@ -3792,30 +3655,30 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c,...@@ -3792,30 +3655,30 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c,
3792// find_last_of3655// find_last_of
37933656
3794template<class _CharT, class _Traits, class _Allocator>3657template<class _CharT, class _Traits, class _Allocator>
3795inline _LIBCPP_CONSTEXPR_AFTER_CXX173658inline _LIBCPP_CONSTEXPR_SINCE_CXX20
3796typename basic_string<_CharT, _Traits, _Allocator>::size_type3659typename basic_string<_CharT, _Traits, _Allocator>::size_type
3797basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,3660basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,
3798 size_type __pos,3661 size_type __pos,
3799 size_type __n) const _NOEXCEPT3662 size_type __n) const _NOEXCEPT
3800{3663{
3801 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr");3664 _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>
3803 (data(), size(), __s, __pos, __n);3666 (data(), size(), __s, __pos, __n);
3804}3667}
38053668
3806template<class _CharT, class _Traits, class _Allocator>3669template<class _CharT, class _Traits, class _Allocator>
3807inline _LIBCPP_CONSTEXPR_AFTER_CXX173670inline _LIBCPP_CONSTEXPR_SINCE_CXX20
3808typename basic_string<_CharT, _Traits, _Allocator>::size_type3671typename basic_string<_CharT, _Traits, _Allocator>::size_type
3809basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str,3672basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str,
3810 size_type __pos) const _NOEXCEPT3673 size_type __pos) const _NOEXCEPT
3811{3674{
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>
3813 (data(), size(), __str.data(), __pos, __str.size());3676 (data(), size(), __str.data(), __pos, __str.size());
3814}3677}
38153678
3816template<class _CharT, class _Traits, class _Allocator>3679template<class _CharT, class _Traits, class _Allocator>
3817template <class _Tp>3680template <class _Tp>
3818_LIBCPP_CONSTEXPR_AFTER_CXX173681_LIBCPP_CONSTEXPR_SINCE_CXX20
3819__enable_if_t3682__enable_if_t
3820<3683<
3821 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,3684 __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,...@@ -3825,23 +3688,23 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const _Tp& __t,
3825 size_type __pos) const _NOEXCEPT3688 size_type __pos) const _NOEXCEPT
3826{3689{
3827 __self_view __sv = __t;3690 __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>
3829 (data(), size(), __sv.data(), __pos, __sv.size());3692 (data(), size(), __sv.data(), __pos, __sv.size());
3830}3693}
38313694
3832template<class _CharT, class _Traits, class _Allocator>3695template<class _CharT, class _Traits, class _Allocator>
3833inline _LIBCPP_CONSTEXPR_AFTER_CXX173696inline _LIBCPP_CONSTEXPR_SINCE_CXX20
3834typename basic_string<_CharT, _Traits, _Allocator>::size_type3697typename basic_string<_CharT, _Traits, _Allocator>::size_type
3835basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,3698basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,
3836 size_type __pos) const _NOEXCEPT3699 size_type __pos) const _NOEXCEPT
3837{3700{
3838 _LIBCPP_ASSERT(__s != nullptr, "string::find_last_of(): received nullptr");3701 _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>
3840 (data(), size(), __s, __pos, traits_type::length(__s));3703 (data(), size(), __s, __pos, traits_type::length(__s));
3841}3704}
38423705
3843template<class _CharT, class _Traits, class _Allocator>3706template<class _CharT, class _Traits, class _Allocator>
3844inline _LIBCPP_CONSTEXPR_AFTER_CXX173707inline _LIBCPP_CONSTEXPR_SINCE_CXX20
3845typename basic_string<_CharT, _Traits, _Allocator>::size_type3708typename basic_string<_CharT, _Traits, _Allocator>::size_type
3846basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c,3709basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c,
3847 size_type __pos) const _NOEXCEPT3710 size_type __pos) const _NOEXCEPT
...@@ -3852,30 +3715,30 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c,...@@ -3852,30 +3715,30 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c,
3852// find_first_not_of3715// find_first_not_of
38533716
3854template<class _CharT, class _Traits, class _Allocator>3717template<class _CharT, class _Traits, class _Allocator>
3855_LIBCPP_CONSTEXPR_AFTER_CXX173718_LIBCPP_CONSTEXPR_SINCE_CXX20
3856typename basic_string<_CharT, _Traits, _Allocator>::size_type3719typename basic_string<_CharT, _Traits, _Allocator>::size_type
3857basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s,3720basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s,
3858 size_type __pos,3721 size_type __pos,
3859 size_type __n) const _NOEXCEPT3722 size_type __n) const _NOEXCEPT
3860{3723{
3861 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr");3724 _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>
3863 (data(), size(), __s, __pos, __n);3726 (data(), size(), __s, __pos, __n);
3864}3727}
38653728
3866template<class _CharT, class _Traits, class _Allocator>3729template<class _CharT, class _Traits, class _Allocator>
3867inline _LIBCPP_CONSTEXPR_AFTER_CXX173730inline _LIBCPP_CONSTEXPR_SINCE_CXX20
3868typename basic_string<_CharT, _Traits, _Allocator>::size_type3731typename basic_string<_CharT, _Traits, _Allocator>::size_type
3869basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& __str,3732basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& __str,
3870 size_type __pos) const _NOEXCEPT3733 size_type __pos) const _NOEXCEPT
3871{3734{
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>
3873 (data(), size(), __str.data(), __pos, __str.size());3736 (data(), size(), __str.data(), __pos, __str.size());
3874}3737}
38753738
3876template<class _CharT, class _Traits, class _Allocator>3739template<class _CharT, class _Traits, class _Allocator>
3877template <class _Tp>3740template <class _Tp>
3878_LIBCPP_CONSTEXPR_AFTER_CXX173741_LIBCPP_CONSTEXPR_SINCE_CXX20
3879__enable_if_t3742__enable_if_t
3880<3743<
3881 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,3744 __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,...@@ -3885,58 +3748,58 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const _Tp& __t,
3885 size_type __pos) const _NOEXCEPT3748 size_type __pos) const _NOEXCEPT
3886{3749{
3887 __self_view __sv = __t;3750 __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>
3889 (data(), size(), __sv.data(), __pos, __sv.size());3752 (data(), size(), __sv.data(), __pos, __sv.size());
3890}3753}
38913754
3892template<class _CharT, class _Traits, class _Allocator>3755template<class _CharT, class _Traits, class _Allocator>
3893inline _LIBCPP_CONSTEXPR_AFTER_CXX173756inline _LIBCPP_CONSTEXPR_SINCE_CXX20
3894typename basic_string<_CharT, _Traits, _Allocator>::size_type3757typename basic_string<_CharT, _Traits, _Allocator>::size_type
3895basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s,3758basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s,
3896 size_type __pos) const _NOEXCEPT3759 size_type __pos) const _NOEXCEPT
3897{3760{
3898 _LIBCPP_ASSERT(__s != nullptr, "string::find_first_not_of(): received nullptr");3761 _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>
3900 (data(), size(), __s, __pos, traits_type::length(__s));3763 (data(), size(), __s, __pos, traits_type::length(__s));
3901}3764}
39023765
3903template<class _CharT, class _Traits, class _Allocator>3766template<class _CharT, class _Traits, class _Allocator>
3904inline _LIBCPP_CONSTEXPR_AFTER_CXX173767inline _LIBCPP_CONSTEXPR_SINCE_CXX20
3905typename basic_string<_CharT, _Traits, _Allocator>::size_type3768typename basic_string<_CharT, _Traits, _Allocator>::size_type
3906basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c,3769basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c,
3907 size_type __pos) const _NOEXCEPT3770 size_type __pos) const _NOEXCEPT
3908{3771{
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>
3910 (data(), size(), __c, __pos);3773 (data(), size(), __c, __pos);
3911}3774}
39123775
3913// find_last_not_of3776// find_last_not_of
39143777
3915template<class _CharT, class _Traits, class _Allocator>3778template<class _CharT, class _Traits, class _Allocator>
3916_LIBCPP_CONSTEXPR_AFTER_CXX173779_LIBCPP_CONSTEXPR_SINCE_CXX20
3917typename basic_string<_CharT, _Traits, _Allocator>::size_type3780typename basic_string<_CharT, _Traits, _Allocator>::size_type
3918basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s,3781basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s,
3919 size_type __pos,3782 size_type __pos,
3920 size_type __n) const _NOEXCEPT3783 size_type __n) const _NOEXCEPT
3921{3784{
3922 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr");3785 _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>
3924 (data(), size(), __s, __pos, __n);3787 (data(), size(), __s, __pos, __n);
3925}3788}
39263789
3927template<class _CharT, class _Traits, class _Allocator>3790template<class _CharT, class _Traits, class _Allocator>
3928inline _LIBCPP_CONSTEXPR_AFTER_CXX173791inline _LIBCPP_CONSTEXPR_SINCE_CXX20
3929typename basic_string<_CharT, _Traits, _Allocator>::size_type3792typename basic_string<_CharT, _Traits, _Allocator>::size_type
3930basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& __str,3793basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& __str,
3931 size_type __pos) const _NOEXCEPT3794 size_type __pos) const _NOEXCEPT
3932{3795{
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>
3934 (data(), size(), __str.data(), __pos, __str.size());3797 (data(), size(), __str.data(), __pos, __str.size());
3935}3798}
39363799
3937template<class _CharT, class _Traits, class _Allocator>3800template<class _CharT, class _Traits, class _Allocator>
3938template <class _Tp>3801template <class _Tp>
3939_LIBCPP_CONSTEXPR_AFTER_CXX173802_LIBCPP_CONSTEXPR_SINCE_CXX20
3940__enable_if_t3803__enable_if_t
3941<3804<
3942 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,3805 __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,...@@ -3946,28 +3809,28 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const _Tp& __t,
3946 size_type __pos) const _NOEXCEPT3809 size_type __pos) const _NOEXCEPT
3947{3810{
3948 __self_view __sv = __t;3811 __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>
3950 (data(), size(), __sv.data(), __pos, __sv.size());3813 (data(), size(), __sv.data(), __pos, __sv.size());
3951}3814}
39523815
3953template<class _CharT, class _Traits, class _Allocator>3816template<class _CharT, class _Traits, class _Allocator>
3954inline _LIBCPP_CONSTEXPR_AFTER_CXX173817inline _LIBCPP_CONSTEXPR_SINCE_CXX20
3955typename basic_string<_CharT, _Traits, _Allocator>::size_type3818typename basic_string<_CharT, _Traits, _Allocator>::size_type
3956basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s,3819basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s,
3957 size_type __pos) const _NOEXCEPT3820 size_type __pos) const _NOEXCEPT
3958{3821{
3959 _LIBCPP_ASSERT(__s != nullptr, "string::find_last_not_of(): received nullptr");3822 _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>
3961 (data(), size(), __s, __pos, traits_type::length(__s));3824 (data(), size(), __s, __pos, traits_type::length(__s));
3962}3825}
39633826
3964template<class _CharT, class _Traits, class _Allocator>3827template<class _CharT, class _Traits, class _Allocator>
3965inline _LIBCPP_CONSTEXPR_AFTER_CXX173828inline _LIBCPP_CONSTEXPR_SINCE_CXX20
3966typename basic_string<_CharT, _Traits, _Allocator>::size_type3829typename basic_string<_CharT, _Traits, _Allocator>::size_type
3967basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c,3830basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c,
3968 size_type __pos) const _NOEXCEPT3831 size_type __pos) const _NOEXCEPT
3969{3832{
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>
3971 (data(), size(), __c, __pos);3834 (data(), size(), __c, __pos);
3972}3835}
39733836
...@@ -3975,7 +3838,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c,...@@ -3975,7 +3838,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c,
39753838
3976template <class _CharT, class _Traits, class _Allocator>3839template <class _CharT, class _Traits, class _Allocator>
3977template <class _Tp>3840template <class _Tp>
3978_LIBCPP_CONSTEXPR_AFTER_CXX173841_LIBCPP_CONSTEXPR_SINCE_CXX20
3979__enable_if_t3842__enable_if_t
3980<3843<
3981 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,3844 __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...@@ -3998,7 +3861,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const _NOEXCE
3998}3861}
39993862
4000template <class _CharT, class _Traits, class _Allocator>3863template <class _CharT, class _Traits, class _Allocator>
4001inline _LIBCPP_CONSTEXPR_AFTER_CXX173864inline _LIBCPP_CONSTEXPR_SINCE_CXX20
4002int3865int
4003basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT3866basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT
4004{3867{
...@@ -4006,7 +3869,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) co...@@ -4006,7 +3869,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) co
4006}3869}
40073870
4008template <class _CharT, class _Traits, class _Allocator>3871template <class _CharT, class _Traits, class _Allocator>
4009inline _LIBCPP_CONSTEXPR_AFTER_CXX173872inline _LIBCPP_CONSTEXPR_SINCE_CXX20
4010int3873int
4011basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,3874basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
4012 size_type __n1,3875 size_type __n1,
...@@ -4031,7 +3894,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,...@@ -4031,7 +3894,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
40313894
4032template <class _CharT, class _Traits, class _Allocator>3895template <class _CharT, class _Traits, class _Allocator>
4033template <class _Tp>3896template <class _Tp>
4034_LIBCPP_CONSTEXPR_AFTER_CXX173897_LIBCPP_CONSTEXPR_SINCE_CXX20
4035__enable_if_t3898__enable_if_t
4036<3899<
4037 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,3900 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
...@@ -4046,7 +3909,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,...@@ -4046,7 +3909,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
4046}3909}
40473910
4048template <class _CharT, class _Traits, class _Allocator>3911template <class _CharT, class _Traits, class _Allocator>
4049inline _LIBCPP_CONSTEXPR_AFTER_CXX173912inline _LIBCPP_CONSTEXPR_SINCE_CXX20
4050int3913int
4051basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,3914basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
4052 size_type __n1,3915 size_type __n1,
...@@ -4057,7 +3920,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,...@@ -4057,7 +3920,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
40573920
4058template <class _CharT, class _Traits, class _Allocator>3921template <class _CharT, class _Traits, class _Allocator>
4059template <class _Tp>3922template <class _Tp>
4060_LIBCPP_CONSTEXPR_AFTER_CXX173923_LIBCPP_CONSTEXPR_SINCE_CXX20
4061__enable_if_t3924__enable_if_t
4062<3925<
4063 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value3926 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value
...@@ -4075,7 +3938,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,...@@ -4075,7 +3938,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
4075}3938}
40763939
4077template <class _CharT, class _Traits, class _Allocator>3940template <class _CharT, class _Traits, class _Allocator>
4078_LIBCPP_CONSTEXPR_AFTER_CXX173941_LIBCPP_CONSTEXPR_SINCE_CXX20
4079int3942int
4080basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,3943basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
4081 size_type __n1,3944 size_type __n1,
...@@ -4087,7 +3950,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,...@@ -4087,7 +3950,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
4087}3950}
40883951
4089template <class _CharT, class _Traits, class _Allocator>3952template <class _CharT, class _Traits, class _Allocator>
4090_LIBCPP_CONSTEXPR_AFTER_CXX173953_LIBCPP_CONSTEXPR_SINCE_CXX20
4091int3954int
4092basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT3955basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT
4093{3956{
...@@ -4096,7 +3959,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const...@@ -4096,7 +3959,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const
4096}3959}
40973960
4098template <class _CharT, class _Traits, class _Allocator>3961template <class _CharT, class _Traits, class _Allocator>
4099_LIBCPP_CONSTEXPR_AFTER_CXX173962_LIBCPP_CONSTEXPR_SINCE_CXX20
4100int3963int
4101basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,3964basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
4102 size_type __n1,3965 size_type __n1,
...@@ -4109,7 +3972,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,...@@ -4109,7 +3972,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
4109// __invariants3972// __invariants
41103973
4111template<class _CharT, class _Traits, class _Allocator>3974template<class _CharT, class _Traits, class _Allocator>
4112inline _LIBCPP_CONSTEXPR_AFTER_CXX173975inline _LIBCPP_CONSTEXPR_SINCE_CXX20
4113bool3976bool
4114basic_string<_CharT, _Traits, _Allocator>::__invariants() const3977basic_string<_CharT, _Traits, _Allocator>::__invariants() const
4115{3978{
...@@ -4127,7 +3990,7 @@ basic_string<_CharT, _Traits, _Allocator>::__invariants() const...@@ -4127,7 +3990,7 @@ basic_string<_CharT, _Traits, _Allocator>::__invariants() const
4127// __clear_and_shrink3990// __clear_and_shrink
41283991
4129template<class _CharT, class _Traits, class _Allocator>3992template<class _CharT, class _Traits, class _Allocator>
4130inline _LIBCPP_CONSTEXPR_AFTER_CXX173993inline _LIBCPP_CONSTEXPR_SINCE_CXX20
4131void3994void
4132basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT3995basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT
4133{3996{
...@@ -4135,28 +3998,30 @@ basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT...@@ -4135,28 +3998,30 @@ basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT
4135 if(__is_long())3998 if(__is_long())
4136 {3999 {
4137 __alloc_traits::deallocate(__alloc(), __get_long_pointer(), capacity() + 1);4000 __alloc_traits::deallocate(__alloc(), __get_long_pointer(), capacity() + 1);
4138 __set_long_cap(0);4001 __default_init();
4139 __set_short_size(0);
4140 traits_type::assign(*__get_short_pointer(), value_type());
4141 }4002 }
4142}4003}
41434004
4144// operator==4005// operator==
41454006
4146template<class _CharT, class _Traits, class _Allocator>4007template<class _CharT, class _Traits, class _Allocator>
4147inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI4008inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
4148bool4009bool
4149operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs,4010operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4150 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4011 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
4151{4012{
4013#if _LIBCPP_STD_VER > 17
4014 return basic_string_view<_CharT, _Traits>(__lhs) == basic_string_view<_CharT, _Traits>(__rhs);
4015#else
4152 size_t __lhs_sz = __lhs.size();4016 size_t __lhs_sz = __lhs.size();
4153 return __lhs_sz == __rhs.size() && _Traits::compare(__lhs.data(),4017 return __lhs_sz == __rhs.size() && _Traits::compare(__lhs.data(),
4154 __rhs.data(),4018 __rhs.data(),
4155 __lhs_sz) == 0;4019 __lhs_sz) == 0;
4020#endif
4156}4021}
41574022
4158template<class _Allocator>4023template<class _Allocator>
4159inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI4024inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
4160bool4025bool
4161operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs,4026operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs,
4162 const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT4027 const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT
...@@ -4174,8 +4039,9 @@ operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs,...@@ -4174,8 +4039,9 @@ operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs,
4174 return true;4039 return true;
4175}4040}
41764041
4042#if _LIBCPP_STD_VER <= 17
4177template<class _CharT, class _Traits, class _Allocator>4043template<class _CharT, class _Traits, class _Allocator>
4178inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI4044inline _LIBCPP_HIDE_FROM_ABI
4179bool4045bool
4180operator==(const _CharT* __lhs,4046operator==(const _CharT* __lhs,
4181 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4047 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
...@@ -4186,22 +4052,44 @@ operator==(const _CharT* __lhs,...@@ -4186,22 +4052,44 @@ operator==(const _CharT* __lhs,
4186 if (__lhs_len != __rhs.size()) return false;4052 if (__lhs_len != __rhs.size()) return false;
4187 return __rhs.compare(0, _String::npos, __lhs, __lhs_len) == 0;4053 return __rhs.compare(0, _String::npos, __lhs, __lhs_len) == 0;
4188}4054}
4055#endif // _LIBCPP_STD_VER <= 17
41894056
4190template<class _CharT, class _Traits, class _Allocator>4057template<class _CharT, class _Traits, class _Allocator>
4191inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI4058inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
4192bool4059bool
4193operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,4060operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
4194 const _CharT* __rhs) _NOEXCEPT4061 const _CharT* __rhs) _NOEXCEPT
4195{4062{
4063#if _LIBCPP_STD_VER > 17
4064 return basic_string_view<_CharT, _Traits>(__lhs) == basic_string_view<_CharT, _Traits>(__rhs);
4065#else
4196 typedef basic_string<_CharT, _Traits, _Allocator> _String;4066 typedef basic_string<_CharT, _Traits, _Allocator> _String;
4197 _LIBCPP_ASSERT(__rhs != nullptr, "operator==(basic_string, char*): received nullptr");4067 _LIBCPP_ASSERT(__rhs != nullptr, "operator==(basic_string, char*): received nullptr");
4198 size_t __rhs_len = _Traits::length(__rhs);4068 size_t __rhs_len = _Traits::length(__rhs);
4199 if (__rhs_len != __lhs.size()) return false;4069 if (__rhs_len != __lhs.size()) return false;
4200 return __lhs.compare(0, _String::npos, __rhs, __rhs_len) == 0;4070 return __lhs.compare(0, _String::npos, __rhs, __rhs_len) == 0;
4071#endif
4201}4072}
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
4203template<class _CharT, class _Traits, class _Allocator>4091template<class _CharT, class _Traits, class _Allocator>
4204inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI4092inline _LIBCPP_HIDE_FROM_ABI
4205bool4093bool
4206operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,4094operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
4207 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4095 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
...@@ -4210,7 +4098,7 @@ operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,...@@ -4210,7 +4098,7 @@ operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
4210}4098}
42114099
4212template<class _CharT, class _Traits, class _Allocator>4100template<class _CharT, class _Traits, class _Allocator>
4213inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI4101inline _LIBCPP_HIDE_FROM_ABI
4214bool4102bool
4215operator!=(const _CharT* __lhs,4103operator!=(const _CharT* __lhs,
4216 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4104 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
...@@ -4219,7 +4107,7 @@ operator!=(const _CharT* __lhs,...@@ -4219,7 +4107,7 @@ operator!=(const _CharT* __lhs,
4219}4107}
42204108
4221template<class _CharT, class _Traits, class _Allocator>4109template<class _CharT, class _Traits, class _Allocator>
4222inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI4110inline _LIBCPP_HIDE_FROM_ABI
4223bool4111bool
4224operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,4112operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4225 const _CharT* __rhs) _NOEXCEPT4113 const _CharT* __rhs) _NOEXCEPT
...@@ -4230,7 +4118,7 @@ operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,...@@ -4230,7 +4118,7 @@ operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4230// operator<4118// operator<
42314119
4232template<class _CharT, class _Traits, class _Allocator>4120template<class _CharT, class _Traits, class _Allocator>
4233inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI4121inline _LIBCPP_HIDE_FROM_ABI
4234bool4122bool
4235operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,4123operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4236 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4124 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
...@@ -4239,7 +4127,7 @@ operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,...@@ -4239,7 +4127,7 @@ operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4239}4127}
42404128
4241template<class _CharT, class _Traits, class _Allocator>4129template<class _CharT, class _Traits, class _Allocator>
4242inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI4130inline _LIBCPP_HIDE_FROM_ABI
4243bool4131bool
4244operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,4132operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4245 const _CharT* __rhs) _NOEXCEPT4133 const _CharT* __rhs) _NOEXCEPT
...@@ -4248,7 +4136,7 @@ operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,...@@ -4248,7 +4136,7 @@ operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4248}4136}
42494137
4250template<class _CharT, class _Traits, class _Allocator>4138template<class _CharT, class _Traits, class _Allocator>
4251inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI4139inline _LIBCPP_HIDE_FROM_ABI
4252bool4140bool
4253operator< (const _CharT* __lhs,4141operator< (const _CharT* __lhs,
4254 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4142 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
...@@ -4259,7 +4147,7 @@ operator< (const _CharT* __lhs,...@@ -4259,7 +4147,7 @@ operator< (const _CharT* __lhs,
4259// operator>4147// operator>
42604148
4261template<class _CharT, class _Traits, class _Allocator>4149template<class _CharT, class _Traits, class _Allocator>
4262inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI4150inline _LIBCPP_HIDE_FROM_ABI
4263bool4151bool
4264operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,4152operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4265 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4153 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
...@@ -4268,7 +4156,7 @@ operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,...@@ -4268,7 +4156,7 @@ operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4268}4156}
42694157
4270template<class _CharT, class _Traits, class _Allocator>4158template<class _CharT, class _Traits, class _Allocator>
4271inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI4159inline _LIBCPP_HIDE_FROM_ABI
4272bool4160bool
4273operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,4161operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4274 const _CharT* __rhs) _NOEXCEPT4162 const _CharT* __rhs) _NOEXCEPT
...@@ -4277,7 +4165,7 @@ operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,...@@ -4277,7 +4165,7 @@ operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4277}4165}
42784166
4279template<class _CharT, class _Traits, class _Allocator>4167template<class _CharT, class _Traits, class _Allocator>
4280inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI4168inline _LIBCPP_HIDE_FROM_ABI
4281bool4169bool
4282operator> (const _CharT* __lhs,4170operator> (const _CharT* __lhs,
4283 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4171 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
...@@ -4288,7 +4176,7 @@ operator> (const _CharT* __lhs,...@@ -4288,7 +4176,7 @@ operator> (const _CharT* __lhs,
4288// operator<=4176// operator<=
42894177
4290template<class _CharT, class _Traits, class _Allocator>4178template<class _CharT, class _Traits, class _Allocator>
4291inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI4179inline _LIBCPP_HIDE_FROM_ABI
4292bool4180bool
4293operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,4181operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4294 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4182 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
...@@ -4297,7 +4185,7 @@ operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,...@@ -4297,7 +4185,7 @@ operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4297}4185}
42984186
4299template<class _CharT, class _Traits, class _Allocator>4187template<class _CharT, class _Traits, class _Allocator>
4300inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI4188inline _LIBCPP_HIDE_FROM_ABI
4301bool4189bool
4302operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,4190operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4303 const _CharT* __rhs) _NOEXCEPT4191 const _CharT* __rhs) _NOEXCEPT
...@@ -4306,7 +4194,7 @@ operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,...@@ -4306,7 +4194,7 @@ operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4306}4194}
43074195
4308template<class _CharT, class _Traits, class _Allocator>4196template<class _CharT, class _Traits, class _Allocator>
4309inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI4197inline _LIBCPP_HIDE_FROM_ABI
4310bool4198bool
4311operator<=(const _CharT* __lhs,4199operator<=(const _CharT* __lhs,
4312 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4200 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
...@@ -4317,7 +4205,7 @@ operator<=(const _CharT* __lhs,...@@ -4317,7 +4205,7 @@ operator<=(const _CharT* __lhs,
4317// operator>=4205// operator>=
43184206
4319template<class _CharT, class _Traits, class _Allocator>4207template<class _CharT, class _Traits, class _Allocator>
4320inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI4208inline _LIBCPP_HIDE_FROM_ABI
4321bool4209bool
4322operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,4210operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4323 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4211 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
...@@ -4326,7 +4214,7 @@ operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,...@@ -4326,7 +4214,7 @@ operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4326}4214}
43274215
4328template<class _CharT, class _Traits, class _Allocator>4216template<class _CharT, class _Traits, class _Allocator>
4329inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI4217inline _LIBCPP_HIDE_FROM_ABI
4330bool4218bool
4331operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,4219operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4332 const _CharT* __rhs) _NOEXCEPT4220 const _CharT* __rhs) _NOEXCEPT
...@@ -4335,18 +4223,19 @@ operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,...@@ -4335,18 +4223,19 @@ operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4335}4223}
43364224
4337template<class _CharT, class _Traits, class _Allocator>4225template<class _CharT, class _Traits, class _Allocator>
4338inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI4226inline _LIBCPP_HIDE_FROM_ABI
4339bool4227bool
4340operator>=(const _CharT* __lhs,4228operator>=(const _CharT* __lhs,
4341 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT4229 const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
4342{4230{
4343 return !(__lhs < __rhs);4231 return !(__lhs < __rhs);
4344}4232}
4233#endif // _LIBCPP_STD_VER > 17
43454234
4346// operator +4235// operator +
43474236
4348template<class _CharT, class _Traits, class _Allocator>4237template<class _CharT, class _Traits, class _Allocator>
4349_LIBCPP_CONSTEXPR_AFTER_CXX174238_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
4350basic_string<_CharT, _Traits, _Allocator>4239basic_string<_CharT, _Traits, _Allocator>
4351operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,4240operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4352 const basic_string<_CharT, _Traits, _Allocator>& __rhs)4241 const basic_string<_CharT, _Traits, _Allocator>& __rhs)
...@@ -4365,7 +4254,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,...@@ -4365,7 +4254,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4365}4254}
43664255
4367template<class _CharT, class _Traits, class _Allocator>4256template<class _CharT, class _Traits, class _Allocator>
4368_LIBCPP_CONSTEXPR_AFTER_CXX174257_LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX20
4369basic_string<_CharT, _Traits, _Allocator>4258basic_string<_CharT, _Traits, _Allocator>
4370operator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& __rhs)4259operator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& __rhs)
4371{4260{
...@@ -4383,7 +4272,7 @@ operator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& _...@@ -4383,7 +4272,7 @@ operator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& _
4383}4272}
43844273
4385template<class _CharT, class _Traits, class _Allocator>4274template<class _CharT, class _Traits, class _Allocator>
4386_LIBCPP_CONSTEXPR_AFTER_CXX174275_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
4387basic_string<_CharT, _Traits, _Allocator>4276basic_string<_CharT, _Traits, _Allocator>
4388operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs)4277operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs)
4389{4278{
...@@ -4400,7 +4289,7 @@ operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs)...@@ -4400,7 +4289,7 @@ operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs)
4400}4289}
44014290
4402template<class _CharT, class _Traits, class _Allocator>4291template<class _CharT, class _Traits, class _Allocator>
4403inline _LIBCPP_CONSTEXPR_AFTER_CXX174292inline _LIBCPP_CONSTEXPR_SINCE_CXX20
4404basic_string<_CharT, _Traits, _Allocator>4293basic_string<_CharT, _Traits, _Allocator>
4405operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs)4294operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs)
4406{4295{
...@@ -4418,7 +4307,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT*...@@ -4418,7 +4307,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT*
4418}4307}
44194308
4420template<class _CharT, class _Traits, class _Allocator>4309template<class _CharT, class _Traits, class _Allocator>
4421_LIBCPP_CONSTEXPR_AFTER_CXX174310_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
4422basic_string<_CharT, _Traits, _Allocator>4311basic_string<_CharT, _Traits, _Allocator>
4423operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs)4312operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs)
4424{4313{
...@@ -4437,7 +4326,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs)...@@ -4437,7 +4326,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs)
4437#ifndef _LIBCPP_CXX03_LANG4326#ifndef _LIBCPP_CXX03_LANG
44384327
4439template<class _CharT, class _Traits, class _Allocator>4328template<class _CharT, class _Traits, class _Allocator>
4440inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX174329inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
4441basic_string<_CharT, _Traits, _Allocator>4330basic_string<_CharT, _Traits, _Allocator>
4442operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs)4331operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs)
4443{4332{
...@@ -4445,7 +4334,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<...@@ -4445,7 +4334,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<
4445}4334}
44464335
4447template<class _CharT, class _Traits, class _Allocator>4336template<class _CharT, class _Traits, class _Allocator>
4448inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX174337inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
4449basic_string<_CharT, _Traits, _Allocator>4338basic_string<_CharT, _Traits, _Allocator>
4450operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs)4339operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs)
4451{4340{
...@@ -4453,7 +4342,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_...@@ -4453,7 +4342,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_
4453}4342}
44544343
4455template<class _CharT, class _Traits, class _Allocator>4344template<class _CharT, class _Traits, class _Allocator>
4456inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX174345inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
4457basic_string<_CharT, _Traits, _Allocator>4346basic_string<_CharT, _Traits, _Allocator>
4458operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs)4347operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs)
4459{4348{
...@@ -4461,7 +4350,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT...@@ -4461,7 +4350,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT
4461}4350}
44624351
4463template<class _CharT, class _Traits, class _Allocator>4352template<class _CharT, class _Traits, class _Allocator>
4464inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX174353inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
4465basic_string<_CharT, _Traits, _Allocator>4354basic_string<_CharT, _Traits, _Allocator>
4466operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs)4355operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs)
4467{4356{
...@@ -4469,7 +4358,7 @@ operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs)...@@ -4469,7 +4358,7 @@ operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs)
4469}4358}
44704359
4471template<class _CharT, class _Traits, class _Allocator>4360template<class _CharT, class _Traits, class _Allocator>
4472inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX174361inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
4473basic_string<_CharT, _Traits, _Allocator>4362basic_string<_CharT, _Traits, _Allocator>
4474operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs)4363operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs)
4475{4364{
...@@ -4478,7 +4367,7 @@ operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs)...@@ -4478,7 +4367,7 @@ operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs)
4478}4367}
44794368
4480template<class _CharT, class _Traits, class _Allocator>4369template<class _CharT, class _Traits, class _Allocator>
4481inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX174370inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
4482basic_string<_CharT, _Traits, _Allocator>4371basic_string<_CharT, _Traits, _Allocator>
4483operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs)4372operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs)
4484{4373{
...@@ -4486,7 +4375,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs...@@ -4486,7 +4375,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs
4486}4375}
44874376
4488template<class _CharT, class _Traits, class _Allocator>4377template<class _CharT, class _Traits, class _Allocator>
4489inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX174378inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
4490basic_string<_CharT, _Traits, _Allocator>4379basic_string<_CharT, _Traits, _Allocator>
4491operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs)4380operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs)
4492{4381{
...@@ -4499,7 +4388,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs)...@@ -4499,7 +4388,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs)
4499// swap4388// swap
45004389
4501template<class _CharT, class _Traits, class _Allocator>4390template<class _CharT, class _Traits, class _Allocator>
4502inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX174391inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
4503void4392void
4504swap(basic_string<_CharT, _Traits, _Allocator>& __lhs,4393swap(basic_string<_CharT, _Traits, _Allocator>& __lhs,
4505 basic_string<_CharT, _Traits, _Allocator>& __rhs)4394 basic_string<_CharT, _Traits, _Allocator>& __rhs)
...@@ -4556,27 +4445,44 @@ const typename basic_string<_CharT, _Traits, _Allocator>::size_type...@@ -4556,27 +4445,44 @@ const typename basic_string<_CharT, _Traits, _Allocator>::size_type
4556 basic_string<_CharT, _Traits, _Allocator>::npos;4445 basic_string<_CharT, _Traits, _Allocator>::npos;
45574446
4558template <class _CharT, class _Allocator>4447template <class _CharT, class _Allocator>
4559struct _LIBCPP_TEMPLATE_VIS4448struct __string_hash : public __unary_function<basic_string<_CharT, char_traits<_CharT>, _Allocator>, size_t>
4560 hash<basic_string<_CharT, char_traits<_CharT>, _Allocator> >
4561 : public __unary_function<basic_string<_CharT, char_traits<_CharT>, _Allocator>, size_t>
4562{4449{
4563 size_t4450 size_t
4564 operator()(const basic_string<_CharT, char_traits<_CharT>, _Allocator>& __val) const _NOEXCEPT4451 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()); }
4566};4453};
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
4568template<class _CharT, class _Traits, class _Allocator>4474template<class _CharT, class _Traits, class _Allocator>
4569basic_ostream<_CharT, _Traits>&4475_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
4570operator<<(basic_ostream<_CharT, _Traits>& __os,4476operator<<(basic_ostream<_CharT, _Traits>& __os,
4571 const basic_string<_CharT, _Traits, _Allocator>& __str);4477 const basic_string<_CharT, _Traits, _Allocator>& __str);
45724478
4573template<class _CharT, class _Traits, class _Allocator>4479template<class _CharT, class _Traits, class _Allocator>
4574basic_istream<_CharT, _Traits>&4480_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
4575operator>>(basic_istream<_CharT, _Traits>& __is,4481operator>>(basic_istream<_CharT, _Traits>& __is,
4576 basic_string<_CharT, _Traits, _Allocator>& __str);4482 basic_string<_CharT, _Traits, _Allocator>& __str);
45774483
4578template<class _CharT, class _Traits, class _Allocator>4484template<class _CharT, class _Traits, class _Allocator>
4579basic_istream<_CharT, _Traits>&4485_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
4580getline(basic_istream<_CharT, _Traits>& __is,4486getline(basic_istream<_CharT, _Traits>& __is,
4581 basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm);4487 basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm);
45824488
...@@ -4662,14 +4568,14 @@ inline namespace literals...@@ -4662,14 +4568,14 @@ inline namespace literals
4662{4568{
4663 inline namespace string_literals4569 inline namespace string_literals
4664 {4570 {
4665 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX174571 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
4666 basic_string<char> operator "" s( const char *__str, size_t __len )4572 basic_string<char> operator "" s( const char *__str, size_t __len )
4667 {4573 {
4668 return basic_string<char> (__str, __len);4574 return basic_string<char> (__str, __len);
4669 }4575 }
46704576
4671#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS4577#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
4672 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX174578 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
4673 basic_string<wchar_t> operator "" s( const wchar_t *__str, size_t __len )4579 basic_string<wchar_t> operator "" s( const wchar_t *__str, size_t __len )
4674 {4580 {
4675 return basic_string<wchar_t> (__str, __len);4581 return basic_string<wchar_t> (__str, __len);
...@@ -4678,19 +4584,19 @@ inline namespace literals...@@ -4678,19 +4584,19 @@ inline namespace literals
46784584
4679#ifndef _LIBCPP_HAS_NO_CHAR8_T4585#ifndef _LIBCPP_HAS_NO_CHAR8_T
4680 inline _LIBCPP_HIDE_FROM_ABI constexpr4586 inline _LIBCPP_HIDE_FROM_ABI constexpr
4681 basic_string<char8_t> operator "" s(const char8_t *__str, size_t __len) _NOEXCEPT4587 basic_string<char8_t> operator "" s(const char8_t *__str, size_t __len)
4682 {4588 {
4683 return basic_string<char8_t> (__str, __len);4589 return basic_string<char8_t> (__str, __len);
4684 }4590 }
4685#endif4591#endif
46864592
4687 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX174593 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
4688 basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len )4594 basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len )
4689 {4595 {
4690 return basic_string<char16_t> (__str, __len);4596 return basic_string<char16_t> (__str, __len);
4691 }4597 }
46924598
4693 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX174599 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
4694 basic_string<char32_t> operator "" s( const char32_t *__str, size_t __len )4600 basic_string<char32_t> operator "" s( const char32_t *__str, size_t __len )
4695 {4601 {
4696 return basic_string<char32_t> (__str, __len);4602 return basic_string<char32_t> (__str, __len);
...@@ -4713,4 +4619,15 @@ _LIBCPP_END_NAMESPACE_STD...@@ -4713,4 +4619,15 @@ _LIBCPP_END_NAMESPACE_STD
47134619
4714_LIBCPP_POP_MACROS4620_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
4716#endif // _LIBCPP_STRING4633#endif // _LIBCPP_STRING
lib/libcxx/include/string.h+37-35
...@@ -57,7 +57,9 @@ size_t strlen(const char* s);...@@ -57,7 +57,9 @@ size_t strlen(const char* s);
57# pragma GCC system_header57# pragma GCC system_header
58#endif58#endif
5959
60#include_next <string.h>60#if __has_include_next(<string.h>)
61# include_next <string.h>
62#endif
6163
62// MSVCRT, GNU libc and its derivates may already have the correct prototype in64// MSVCRT, GNU libc and its derivates may already have the correct prototype in
63// <string.h>. This macro can be defined by users if their C library provides65// <string.h>. This macro can be defined by users if their C library provides
...@@ -69,41 +71,41 @@ size_t strlen(const char* s);...@@ -69,41 +71,41 @@ size_t strlen(const char* s);
6971
70#if defined(__cplusplus) && !defined(_LIBCPP_STRING_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)72#if defined(__cplusplus) && !defined(_LIBCPP_STRING_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)
71extern "C++" {73extern "C++" {
72inline _LIBCPP_INLINE_VISIBILITY74inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strchr(const char* __s, int __c) {
73char* __libcpp_strchr(const char* __s, int __c) {return (char*)strchr(__s, __c);}75 return __builtin_strchr(__s, __c);
74inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD76}
75const char* strchr(const char* __s, int __c) {return __libcpp_strchr(__s, __c);}77inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strchr(char* __s, int __c) {
76inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD78 return __builtin_strchr(__s, __c);
77 char* strchr( char* __s, int __c) {return __libcpp_strchr(__s, __c);}79}
7880
79inline _LIBCPP_INLINE_VISIBILITY81inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strpbrk(const char* __s1, const char* __s2) {
80char* __libcpp_strpbrk(const char* __s1, const char* __s2) {return (char*)strpbrk(__s1, __s2);}82 return __builtin_strpbrk(__s1, __s2);
81inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD83}
82const char* strpbrk(const char* __s1, const char* __s2) {return __libcpp_strpbrk(__s1, __s2);}84inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strpbrk(char* __s1, const char* __s2) {
83inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD85 return __builtin_strpbrk(__s1, __s2);
84 char* strpbrk( char* __s1, const char* __s2) {return __libcpp_strpbrk(__s1, __s2);}86}
8587
86inline _LIBCPP_INLINE_VISIBILITY88inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strrchr(const char* __s, int __c) {
87char* __libcpp_strrchr(const char* __s, int __c) {return (char*)strrchr(__s, __c);}89 return __builtin_strrchr(__s, __c);
88inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD90}
89const char* strrchr(const char* __s, int __c) {return __libcpp_strrchr(__s, __c);}91inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strrchr(char* __s, int __c) {
90inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD92 return __builtin_strrchr(__s, __c);
91 char* strrchr( char* __s, int __c) {return __libcpp_strrchr(__s, __c);}93}
9294
93inline _LIBCPP_INLINE_VISIBILITY95inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const void* memchr(const void* __s, int __c, size_t __n) {
94void* __libcpp_memchr(const void* __s, int __c, size_t __n) {return (void*)memchr(__s, __c, __n);}96 return __builtin_memchr(__s, __c, __n);
95inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD97}
96const void* memchr(const void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}98inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD void* memchr(void* __s, int __c, size_t __n) {
97inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD99 return __builtin_memchr(__s, __c, __n);
98 void* memchr( void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}100}
99101
100inline _LIBCPP_INLINE_VISIBILITY102inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strstr(const char* __s1, const char* __s2) {
101char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}103 return __builtin_strstr(__s1, __s2);
102inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD104}
103const char* strstr(const char* __s1, const char* __s2) {return __libcpp_strstr(__s1, __s2);}105inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strstr(char* __s1, const char* __s2) {
104inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD106 return __builtin_strstr(__s1, __s2);
105 char* strstr( char* __s1, const char* __s2) {return __libcpp_strstr(__s1, __s2);}
106}107}
108} // extern "C++"
107#endif109#endif
108110
109#endif // _LIBCPP_STRING_H111#endif // _LIBCPP_STRING_H
lib/libcxx/include/string_view+227-172
...@@ -14,6 +14,8 @@...@@ -14,6 +14,8 @@
1414
15 string_view synopsis15 string_view synopsis
1616
17#include <compare>
18
17namespace std {19namespace std {
1820
19 // 7.2, Class template basic_string_view21 // 7.2, Class template basic_string_view
...@@ -30,21 +32,25 @@ namespace std {...@@ -30,21 +32,25 @@ namespace std {
30 template<class charT, class traits>32 template<class charT, class traits>
31 constexpr bool operator==(basic_string_view<charT, traits> x,33 constexpr bool operator==(basic_string_view<charT, traits> x,
32 basic_string_view<charT, traits> y) noexcept;34 basic_string_view<charT, traits> y) noexcept;
33 template<class charT, class traits>35 template<class charT, class traits> // Removed in C++20
34 constexpr bool operator!=(basic_string_view<charT, traits> x,36 constexpr bool operator!=(basic_string_view<charT, traits> x,
35 basic_string_view<charT, traits> y) noexcept;37 basic_string_view<charT, traits> y) noexcept;
36 template<class charT, class traits>38 template<class charT, class traits> // Removed in C++20
37 constexpr bool operator< (basic_string_view<charT, traits> x,39 constexpr bool operator< (basic_string_view<charT, traits> x,
38 basic_string_view<charT, traits> y) noexcept;40 basic_string_view<charT, traits> y) noexcept;
39 template<class charT, class traits>41 template<class charT, class traits> // Removed in C++20
40 constexpr bool operator> (basic_string_view<charT, traits> x,42 constexpr bool operator> (basic_string_view<charT, traits> x,
41 basic_string_view<charT, traits> y) noexcept;43 basic_string_view<charT, traits> y) noexcept;
42 template<class charT, class traits>44 template<class charT, class traits> // Removed in C++20
43 constexpr bool operator<=(basic_string_view<charT, traits> x,45 constexpr bool operator<=(basic_string_view<charT, traits> x,
44 basic_string_view<charT, traits> y) noexcept;46 basic_string_view<charT, traits> y) noexcept;
45 template<class charT, class traits>47 template<class charT, class traits> // Removed in C++20
46 constexpr bool operator>=(basic_string_view<charT, traits> x,48 constexpr bool operator>=(basic_string_view<charT, traits> x,
47 basic_string_view<charT, traits> y) noexcept;49 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
48 // see below, sufficient additional overloads of comparison functions54 // see below, sufficient additional overloads of comparison functions
4955
50 // 7.10, Inserters and extractors56 // 7.10, Inserters and extractors
...@@ -185,11 +191,11 @@ namespace std {...@@ -185,11 +191,11 @@ namespace std {
185 template <> struct hash<u32string_view>;191 template <> struct hash<u32string_view>;
186 template <> struct hash<wstring_view>;192 template <> struct hash<wstring_view>;
187193
188 constexpr basic_string_view<char> operator "" sv( const char *str, size_t len ) noexcept;194 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;195 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++20196 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;197 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;198 constexpr basic_string_view<char32_t> operator "" sv(const char32_t *str, size_t len) noexcept;
193199
194} // namespace std200} // namespace std
195201
...@@ -218,12 +224,6 @@ namespace std {...@@ -218,12 +224,6 @@ namespace std {
218#include <type_traits>224#include <type_traits>
219#include <version>225#include <version>
220226
221#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
222# include <algorithm>
223# include <functional>
224# include <iterator>
225#endif
226
227// standard-mandated includes227// standard-mandated includes
228228
229// [iterator.range]229// [iterator.range]
...@@ -256,29 +256,21 @@ inline size_t __char_traits_length_checked(const typename _Traits::char_type* __...@@ -256,29 +256,21 @@ inline size_t __char_traits_length_checked(const typename _Traits::char_type* __
256}256}
257257
258template<class _CharT, class _Traits>258template<class _CharT, class _Traits>
259class259class basic_string_view {
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 {
268public:260public:
269 // types261 // types
270 typedef _Traits traits_type;262 using traits_type = _Traits;
271 typedef _CharT value_type;263 using value_type = _CharT;
272 typedef _CharT* pointer;264 using pointer = _CharT*;
273 typedef const _CharT* const_pointer;265 using const_pointer = const _CharT*;
274 typedef _CharT& reference;266 using reference = _CharT&;
275 typedef const _CharT& const_reference;267 using const_reference = const _CharT&;
276 typedef const_pointer const_iterator; // See [string.view.iterators]268 using const_iterator = const_pointer; // See [string.view.iterators]
277 typedef const_iterator iterator;269 using iterator = const_iterator;
278 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;270 using const_reverse_iterator = _VSTD::reverse_iterator<const_iterator>;
279 typedef const_reverse_iterator reverse_iterator;271 using reverse_iterator = const_reverse_iterator;
280 typedef size_t size_type;272 using size_type = size_t;
281 typedef ptrdiff_t difference_type;273 using difference_type = ptrdiff_t;
282 static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1);274 static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1);
283275
284 static_assert((!is_array<value_type>::value), "Character type of basic_string_view must not be an array");276 static_assert((!is_array<value_type>::value), "Character type of basic_string_view must not be an array");
...@@ -289,7 +281,7 @@ public:...@@ -289,7 +281,7 @@ public:
289281
290 // [string.view.cons], construct/copy282 // [string.view.cons], construct/copy
291 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY283 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
292 basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {}284 basic_string_view() _NOEXCEPT : __data_(nullptr), __size_(0) {}
293285
294 _LIBCPP_INLINE_VISIBILITY286 _LIBCPP_INLINE_VISIBILITY
295 basic_string_view(const basic_string_view&) _NOEXCEPT = default;287 basic_string_view(const basic_string_view&) _NOEXCEPT = default;
...@@ -299,7 +291,7 @@ public:...@@ -299,7 +291,7 @@ public:
299291
300 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY292 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
301 basic_string_view(const _CharT* __s, size_type __len) _NOEXCEPT293 basic_string_view(const _CharT* __s, size_type __len) _NOEXCEPT
302 : __data(__s), __size(__len)294 : __data_(__s), __size_(__len)
303 {295 {
304#if _LIBCPP_STD_VER > 11296#if _LIBCPP_STD_VER > 11
305 _LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr");297 _LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr");
...@@ -310,13 +302,13 @@ public:...@@ -310,13 +302,13 @@ public:
310 template <contiguous_iterator _It, sized_sentinel_for<_It> _End>302 template <contiguous_iterator _It, sized_sentinel_for<_It> _End>
311 requires (is_same_v<iter_value_t<_It>, _CharT> && !is_convertible_v<_End, size_type>)303 requires (is_same_v<iter_value_t<_It>, _CharT> && !is_convertible_v<_End, size_type>)
312 constexpr _LIBCPP_HIDE_FROM_ABI basic_string_view(_It __begin, _End __end)304 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)
314 {306 {
315 _LIBCPP_ASSERT((__end - __begin) >= 0, "std::string_view::string_view(iterator, sentinel) received invalid range");307 _LIBCPP_ASSERT((__end - __begin) >= 0, "std::string_view::string_view(iterator, sentinel) received invalid range");
316 }308 }
317#endif // _LIBCPP_STD_VER > 17309#endif // _LIBCPP_STD_VER > 17
318310
319#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)311#if _LIBCPP_STD_VER > 20
320 template <class _Range>312 template <class _Range>
321 requires (313 requires (
322 !is_same_v<remove_cvref_t<_Range>, basic_string_view> &&314 !is_same_v<remove_cvref_t<_Range>, basic_string_view> &&
...@@ -331,13 +323,13 @@ public:...@@ -331,13 +323,13 @@ public:
331 typename remove_reference_t<_Range>::traits_type;323 typename remove_reference_t<_Range>::traits_type;
332 } || is_same_v<typename remove_reference_t<_Range>::traits_type, _Traits>)324 } || is_same_v<typename remove_reference_t<_Range>::traits_type, _Traits>)
333 )325 )
334 constexpr _LIBCPP_HIDE_FROM_ABI326 constexpr explicit _LIBCPP_HIDE_FROM_ABI
335 basic_string_view(_Range&& __r) : __data(ranges::data(__r)), __size(ranges::size(__r)) {}327 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)328#endif // _LIBCPP_STD_VER > 20
337329
338 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY330 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
339 basic_string_view(const _CharT* __s)331 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
342#if _LIBCPP_STD_VER > 20334#if _LIBCPP_STD_VER > 20
343 basic_string_view(nullptr_t) = delete;335 basic_string_view(nullptr_t) = delete;
...@@ -351,94 +343,94 @@ public:...@@ -351,94 +343,94 @@ public:
351 const_iterator end() const _NOEXCEPT { return cend(); }343 const_iterator end() const _NOEXCEPT { return cend(); }
352344
353 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY345 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
354 const_iterator cbegin() const _NOEXCEPT { return __data; }346 const_iterator cbegin() const _NOEXCEPT { return __data_; }
355347
356 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY348 _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_VISIBILITY351 _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_INLINE_VISIBILITY
360 const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }352 const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
361353
362 _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY354 _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_INLINE_VISIBILITY
363 const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }355 const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
364356
365 _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY357 _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_INLINE_VISIBILITY
366 const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }358 const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
367359
368 _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY360 _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_INLINE_VISIBILITY
369 const_reverse_iterator crend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }361 const_reverse_iterator crend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
370362
371 // [string.view.capacity], capacity363 // [string.view.capacity], capacity
372 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY364 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
373 size_type size() const _NOEXCEPT { return __size; }365 size_type size() const _NOEXCEPT { return __size_; }
374366
375 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY367 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
376 size_type length() const _NOEXCEPT { return __size; }368 size_type length() const _NOEXCEPT { return __size_; }
377369
378 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY370 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
379 size_type max_size() const _NOEXCEPT { return numeric_limits<size_type>::max() / sizeof(value_type); }371 size_type max_size() const _NOEXCEPT { return numeric_limits<size_type>::max() / sizeof(value_type); }
380372
381 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR373 _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
384 // [string.view.access], element access376 // [string.view.access], element access
385 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY377 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
386 const_reference operator[](size_type __pos) const _NOEXCEPT {378 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];
388 }380 }
389381
390 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY382 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
391 const_reference at(size_type __pos) const383 const_reference at(size_type __pos) const
392 {384 {
393 return __pos >= size()385 return __pos >= size()
394 ? (__throw_out_of_range("string_view::at"), __data[0])386 ? (__throw_out_of_range("string_view::at"), __data_[0])
395 : __data[__pos];387 : __data_[__pos];
396 }388 }
397389
398 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY390 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
399 const_reference front() const _NOEXCEPT391 const_reference front() const _NOEXCEPT
400 {392 {
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];
402 }394 }
403395
404 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY396 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
405 const_reference back() const _NOEXCEPT397 const_reference back() const _NOEXCEPT
406 {398 {
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];
408 }400 }
409401
410 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY402 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
411 const_pointer data() const _NOEXCEPT { return __data; }403 const_pointer data() const _NOEXCEPT { return __data_; }
412404
413 // [string.view.modifiers], modifiers:405 // [string.view.modifiers], modifiers:
414 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY406 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
415 void remove_prefix(size_type __n) _NOEXCEPT407 void remove_prefix(size_type __n) _NOEXCEPT
416 {408 {
417 _LIBCPP_ASSERT(__n <= size(), "remove_prefix() can't remove more than size()");409 _LIBCPP_ASSERT(__n <= size(), "remove_prefix() can't remove more than size()");
418 __data += __n;410 __data_ += __n;
419 __size -= __n;411 __size_ -= __n;
420 }412 }
421413
422 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY414 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
423 void remove_suffix(size_type __n) _NOEXCEPT415 void remove_suffix(size_type __n) _NOEXCEPT
424 {416 {
425 _LIBCPP_ASSERT(__n <= size(), "remove_suffix() can't remove more than size()");417 _LIBCPP_ASSERT(__n <= size(), "remove_suffix() can't remove more than size()");
426 __size -= __n;418 __size_ -= __n;
427 }419 }
428420
429 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY421 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
430 void swap(basic_string_view& __other) _NOEXCEPT422 void swap(basic_string_view& __other) _NOEXCEPT
431 {423 {
432 const value_type *__p = __data;424 const value_type *__p = __data_;
433 __data = __other.__data;425 __data_ = __other.__data_;
434 __other.__data = __p;426 __other.__data_ = __p;
435427
436 size_type __sz = __size;428 size_type __sz = __size_;
437 __size = __other.__size;429 __size_ = __other.__size_;
438 __other.__size = __sz;430 __other.__size_ = __sz;
439 }431 }
440432
441 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17433 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
442 size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const434 size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
443 {435 {
444 if (__pos > size())436 if (__pos > size())
...@@ -456,229 +448,229 @@ public:...@@ -456,229 +448,229 @@ public:
456 : basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos));448 : basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos));
457 }449 }
458450
459 _LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT451 _LIBCPP_CONSTEXPR_SINCE_CXX14 int compare(basic_string_view __sv) const _NOEXCEPT
460 {452 {
461 size_type __rlen = _VSTD::min( size(), __sv.size());453 size_type __rlen = _VSTD::min(size(), __sv.size());
462 int __retval = _Traits::compare(data(), __sv.data(), __rlen);454 int __retval = _Traits::compare(data(), __sv.data(), __rlen);
463 if ( __retval == 0 ) // first __rlen chars matched455 if (__retval == 0) // first __rlen chars matched
464 __retval = size() == __sv.size() ? 0 : ( size() < __sv.size() ? -1 : 1 );456 __retval = size() == __sv.size() ? 0 : (size() < __sv.size() ? -1 : 1);
465 return __retval;457 return __retval;
466 }458 }
467459
468 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY460 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
469 int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const461 int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const
470 {462 {
471 return substr(__pos1, __n1).compare(__sv);463 return substr(__pos1, __n1).compare(__sv);
472 }464 }
473465
474 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY466 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
475 int compare( size_type __pos1, size_type __n1,467 int compare( size_type __pos1, size_type __n1,
476 basic_string_view __sv, size_type __pos2, size_type __n2) const468 basic_string_view __sv, size_type __pos2, size_type __n2) const
477 {469 {
478 return substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));470 return substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
479 }471 }
480472
481 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY473 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
482 int compare(const _CharT* __s) const _NOEXCEPT474 int compare(const _CharT* __s) const _NOEXCEPT
483 {475 {
484 return compare(basic_string_view(__s));476 return compare(basic_string_view(__s));
485 }477 }
486478
487 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY479 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
488 int compare(size_type __pos1, size_type __n1, const _CharT* __s) const480 int compare(size_type __pos1, size_type __n1, const _CharT* __s) const
489 {481 {
490 return substr(__pos1, __n1).compare(basic_string_view(__s));482 return substr(__pos1, __n1).compare(basic_string_view(__s));
491 }483 }
492484
493 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY485 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
494 int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const486 int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const
495 {487 {
496 return substr(__pos1, __n1).compare(basic_string_view(__s, __n2));488 return substr(__pos1, __n1).compare(basic_string_view(__s, __n2));
497 }489 }
498490
499 // find491 // find
500 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY492 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
501 size_type find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT493 size_type find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
502 {494 {
503 _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");495 _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>
505 (data(), size(), __s.data(), __pos, __s.size());497 (data(), size(), __s.data(), __pos, __s.size());
506 }498 }
507499
508 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY500 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
509 size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT501 size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT
510 {502 {
511 return __str_find<value_type, size_type, traits_type, npos>503 return std::__str_find<value_type, size_type, traits_type, npos>
512 (data(), size(), __c, __pos);504 (data(), size(), __c, __pos);
513 }505 }
514506
515 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY507 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
516 size_type find(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT508 size_type find(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
517 {509 {
518 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): received nullptr");510 _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>
520 (data(), size(), __s, __pos, __n);512 (data(), size(), __s, __pos, __n);
521 }513 }
522514
523 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY515 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
524 size_type find(const _CharT* __s, size_type __pos = 0) const _NOEXCEPT516 size_type find(const _CharT* __s, size_type __pos = 0) const _NOEXCEPT
525 {517 {
526 _LIBCPP_ASSERT(__s != nullptr, "string_view::find(): received nullptr");518 _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>
528 (data(), size(), __s, __pos, traits_type::length(__s));520 (data(), size(), __s, __pos, traits_type::length(__s));
529 }521 }
530522
531 // rfind523 // rfind
532 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY524 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
533 size_type rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT525 size_type rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT
534 {526 {
535 _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");527 _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>
537 (data(), size(), __s.data(), __pos, __s.size());529 (data(), size(), __s.data(), __pos, __s.size());
538 }530 }
539531
540 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY532 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
541 size_type rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT533 size_type rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT
542 {534 {
543 return __str_rfind<value_type, size_type, traits_type, npos>535 return std::__str_rfind<value_type, size_type, traits_type, npos>
544 (data(), size(), __c, __pos);536 (data(), size(), __c, __pos);
545 }537 }
546538
547 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY539 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
548 size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT540 size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
549 {541 {
550 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): received nullptr");542 _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>
552 (data(), size(), __s, __pos, __n);544 (data(), size(), __s, __pos, __n);
553 }545 }
554546
555 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY547 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
556 size_type rfind(const _CharT* __s, size_type __pos=npos) const _NOEXCEPT548 size_type rfind(const _CharT* __s, size_type __pos=npos) const _NOEXCEPT
557 {549 {
558 _LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): received nullptr");550 _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>
560 (data(), size(), __s, __pos, traits_type::length(__s));552 (data(), size(), __s, __pos, traits_type::length(__s));
561 }553 }
562554
563 // find_first_of555 // find_first_of
564 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY556 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
565 size_type find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT557 size_type find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
566 {558 {
567 _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): received nullptr");559 _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>
569 (data(), size(), __s.data(), __pos, __s.size());561 (data(), size(), __s.data(), __pos, __s.size());
570 }562 }
571563
572 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY564 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
573 size_type find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT565 size_type find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT
574 { return find(__c, __pos); }566 { return find(__c, __pos); }
575567
576 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY568 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
577 size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT569 size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
578 {570 {
579 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_of(): received nullptr");571 _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>
581 (data(), size(), __s, __pos, __n);573 (data(), size(), __s, __pos, __n);
582 }574 }
583575
584 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY576 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
585 size_type find_first_of(const _CharT* __s, size_type __pos=0) const _NOEXCEPT577 size_type find_first_of(const _CharT* __s, size_type __pos=0) const _NOEXCEPT
586 {578 {
587 _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_of(): received nullptr");579 _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>
589 (data(), size(), __s, __pos, traits_type::length(__s));581 (data(), size(), __s, __pos, traits_type::length(__s));
590 }582 }
591583
592 // find_last_of584 // find_last_of
593 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY585 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
594 size_type find_last_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT586 size_type find_last_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
595 {587 {
596 _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): received nullptr");588 _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>
598 (data(), size(), __s.data(), __pos, __s.size());590 (data(), size(), __s.data(), __pos, __s.size());
599 }591 }
600592
601 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY593 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
602 size_type find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT594 size_type find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT
603 { return rfind(__c, __pos); }595 { return rfind(__c, __pos); }
604596
605 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY597 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
606 size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT598 size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
607 {599 {
608 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_of(): received nullptr");600 _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>
610 (data(), size(), __s, __pos, __n);602 (data(), size(), __s, __pos, __n);
611 }603 }
612604
613 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY605 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
614 size_type find_last_of(const _CharT* __s, size_type __pos=npos) const _NOEXCEPT606 size_type find_last_of(const _CharT* __s, size_type __pos=npos) const _NOEXCEPT
615 {607 {
616 _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_of(): received nullptr");608 _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>
618 (data(), size(), __s, __pos, traits_type::length(__s));610 (data(), size(), __s, __pos, traits_type::length(__s));
619 }611 }
620612
621 // find_first_not_of613 // find_first_not_of
622 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY614 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
623 size_type find_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT615 size_type find_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT
624 {616 {
625 _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): received nullptr");617 _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>
627 (data(), size(), __s.data(), __pos, __s.size());619 (data(), size(), __s.data(), __pos, __s.size());
628 }620 }
629621
630 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY622 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
631 size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT623 size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT
632 {624 {
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>
634 (data(), size(), __c, __pos);626 (data(), size(), __c, __pos);
635 }627 }
636628
637 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY629 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
638 size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT630 size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
639 {631 {
640 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): received nullptr");632 _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>
642 (data(), size(), __s, __pos, __n);634 (data(), size(), __s, __pos, __n);
643 }635 }
644636
645 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY637 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
646 size_type find_first_not_of(const _CharT* __s, size_type __pos=0) const _NOEXCEPT638 size_type find_first_not_of(const _CharT* __s, size_type __pos=0) const _NOEXCEPT
647 {639 {
648 _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_not_of(): received nullptr");640 _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>
650 (data(), size(), __s, __pos, traits_type::length(__s));642 (data(), size(), __s, __pos, traits_type::length(__s));
651 }643 }
652644
653 // find_last_not_of645 // find_last_not_of
654 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY646 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
655 size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT647 size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
656 {648 {
657 _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): received nullptr");649 _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>
659 (data(), size(), __s.data(), __pos, __s.size());651 (data(), size(), __s.data(), __pos, __s.size());
660 }652 }
661653
662 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY654 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
663 size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT655 size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT
664 {656 {
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>
666 (data(), size(), __c, __pos);658 (data(), size(), __c, __pos);
667 }659 }
668660
669 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY661 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
670 size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT662 size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
671 {663 {
672 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): received nullptr");664 _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>
674 (data(), size(), __s, __pos, __n);666 (data(), size(), __s, __pos, __n);
675 }667 }
676668
677 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY669 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
678 size_type find_last_not_of(const _CharT* __s, size_type __pos=npos) const _NOEXCEPT670 size_type find_last_not_of(const _CharT* __s, size_type __pos=npos) const _NOEXCEPT
679 {671 {
680 _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_not_of(): received nullptr");672 _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>
682 (data(), size(), __s, __pos, traits_type::length(__s));674 (data(), size(), __s, __pos, traits_type::length(__s));
683 }675 }
684676
...@@ -723,9 +715,10 @@ public:...@@ -723,9 +715,10 @@ public:
723#endif715#endif
724716
725private:717private:
726 const value_type* __data;718 const value_type* __data_;
727 size_type __size;719 size_type __size_;
728};720};
721_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_string_view);
729722
730#if _LIBCPP_STD_VER > 17723#if _LIBCPP_STD_VER > 17
731template <class _CharT, class _Traits>724template <class _CharT, class _Traits>
...@@ -743,69 +736,105 @@ template <contiguous_iterator _It, sized_sentinel_for<_It> _End>...@@ -743,69 +736,105 @@ template <contiguous_iterator _It, sized_sentinel_for<_It> _End>
743#endif // _LIBCPP_STD_VER > 17736#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
747template <ranges::contiguous_range _Range>740template <ranges::contiguous_range _Range>
748 basic_string_view(_Range) -> basic_string_view<ranges::range_value_t<_Range>>;741 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
751// [string.view.comparison]744// [string.view.comparison]
752// operator ==745// operator ==
753template<class _CharT, class _Traits>746template<class _CharT, class _Traits>
754_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY747_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
755bool operator==(basic_string_view<_CharT, _Traits> __lhs,748bool operator==(basic_string_view<_CharT, _Traits> __lhs,
756 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT749 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
757{750{
758 if ( __lhs.size() != __rhs.size()) return false;751 if (__lhs.size() != __rhs.size()) return false;
759 return __lhs.compare(__rhs) == 0;752 return __lhs.compare(__rhs) == 0;
760}753}
761754
762// The dummy default template parameters are used to work around a MSVC issue with mangling, see VSO-409326 for details.755// The dummy default template parameters are used to work around a MSVC issue with mangling, see VSO-409326 for details.
763// This applies to the other sufficient overloads below for the other comparison operators.756// This applies to the other sufficient overloads below for the other comparison operators.
764template<class _CharT, class _Traits, int = 1>757template<class _CharT, class _Traits, int = 1>
765_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY758_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
766bool operator==(basic_string_view<_CharT, _Traits> __lhs,759bool operator==(basic_string_view<_CharT, _Traits> __lhs,
767 typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT760 __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT
768{761{
769 if ( __lhs.size() != __rhs.size()) return false;762 if (__lhs.size() != __rhs.size()) return false;
770 return __lhs.compare(__rhs) == 0;763 return __lhs.compare(__rhs) == 0;
771}764}
772765
766#if _LIBCPP_STD_VER < 20
767// This overload is automatically generated in C++20.
773template<class _CharT, class _Traits, int = 2>768template<class _CharT, class _Traits, int = 2>
774_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY769_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
775bool operator==(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,770bool operator==(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
776 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT771 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
777{772{
778 if ( __lhs.size() != __rhs.size()) return false;773 if (__lhs.size() != __rhs.size()) return false;
779 return __lhs.compare(__rhs) == 0;774 return __lhs.compare(__rhs) == 0;
780}775}
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
783// operator !=812// operator !=
784template<class _CharT, class _Traits>813template<class _CharT, class _Traits>
785_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY814_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
786bool operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT815bool operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
787{816{
788 if ( __lhs.size() != __rhs.size())817 if (__lhs.size() != __rhs.size())
789 return true;818 return true;
790 return __lhs.compare(__rhs) != 0;819 return __lhs.compare(__rhs) != 0;
791}820}
792821
793template<class _CharT, class _Traits, int = 1>822template<class _CharT, class _Traits, int = 1>
794_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY823_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
795bool operator!=(basic_string_view<_CharT, _Traits> __lhs,824bool operator!=(basic_string_view<_CharT, _Traits> __lhs,
796 typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT825 __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT
797{826{
798 if ( __lhs.size() != __rhs.size())827 if (__lhs.size() != __rhs.size())
799 return true;828 return true;
800 return __lhs.compare(__rhs) != 0;829 return __lhs.compare(__rhs) != 0;
801}830}
802831
803template<class _CharT, class _Traits, int = 2>832template<class _CharT, class _Traits, int = 2>
804_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY833_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
805bool operator!=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,834bool operator!=(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
806 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT835 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
807{836{
808 if ( __lhs.size() != __rhs.size())837 if (__lhs.size() != __rhs.size())
809 return true;838 return true;
810 return __lhs.compare(__rhs) != 0;839 return __lhs.compare(__rhs) != 0;
811}840}
...@@ -813,23 +842,23 @@ bool operator!=(typename common_type<basic_string_view<_CharT, _Traits> >::type...@@ -813,23 +842,23 @@ bool operator!=(typename common_type<basic_string_view<_CharT, _Traits> >::type
813842
814// operator <843// operator <
815template<class _CharT, class _Traits>844template<class _CharT, class _Traits>
816_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY845_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
817bool operator<(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT846bool operator<(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
818{847{
819 return __lhs.compare(__rhs) < 0;848 return __lhs.compare(__rhs) < 0;
820}849}
821850
822template<class _CharT, class _Traits, int = 1>851template<class _CharT, class _Traits, int = 1>
823_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY852_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
824bool operator<(basic_string_view<_CharT, _Traits> __lhs,853bool operator<(basic_string_view<_CharT, _Traits> __lhs,
825 typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT854 __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT
826{855{
827 return __lhs.compare(__rhs) < 0;856 return __lhs.compare(__rhs) < 0;
828}857}
829858
830template<class _CharT, class _Traits, int = 2>859template<class _CharT, class _Traits, int = 2>
831_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY860_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
832bool operator<(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,861bool operator<(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
833 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT862 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
834{863{
835 return __lhs.compare(__rhs) < 0;864 return __lhs.compare(__rhs) < 0;
...@@ -838,23 +867,23 @@ bool operator<(typename common_type<basic_string_view<_CharT, _Traits> >::type _...@@ -838,23 +867,23 @@ bool operator<(typename common_type<basic_string_view<_CharT, _Traits> >::type _
838867
839// operator >868// operator >
840template<class _CharT, class _Traits>869template<class _CharT, class _Traits>
841_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY870_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
842bool operator> (basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT871bool operator> (basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
843{872{
844 return __lhs.compare(__rhs) > 0;873 return __lhs.compare(__rhs) > 0;
845}874}
846875
847template<class _CharT, class _Traits, int = 1>876template<class _CharT, class _Traits, int = 1>
848_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY877_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
849bool operator>(basic_string_view<_CharT, _Traits> __lhs,878bool operator>(basic_string_view<_CharT, _Traits> __lhs,
850 typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT879 __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT
851{880{
852 return __lhs.compare(__rhs) > 0;881 return __lhs.compare(__rhs) > 0;
853}882}
854883
855template<class _CharT, class _Traits, int = 2>884template<class _CharT, class _Traits, int = 2>
856_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY885_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
857bool operator>(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,886bool operator>(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
858 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT887 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
859{888{
860 return __lhs.compare(__rhs) > 0;889 return __lhs.compare(__rhs) > 0;
...@@ -863,23 +892,23 @@ bool operator>(typename common_type<basic_string_view<_CharT, _Traits> >::type _...@@ -863,23 +892,23 @@ bool operator>(typename common_type<basic_string_view<_CharT, _Traits> >::type _
863892
864// operator <=893// operator <=
865template<class _CharT, class _Traits>894template<class _CharT, class _Traits>
866_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY895_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
867bool operator<=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT896bool operator<=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
868{897{
869 return __lhs.compare(__rhs) <= 0;898 return __lhs.compare(__rhs) <= 0;
870}899}
871900
872template<class _CharT, class _Traits, int = 1>901template<class _CharT, class _Traits, int = 1>
873_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY902_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
874bool operator<=(basic_string_view<_CharT, _Traits> __lhs,903bool operator<=(basic_string_view<_CharT, _Traits> __lhs,
875 typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT904 __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT
876{905{
877 return __lhs.compare(__rhs) <= 0;906 return __lhs.compare(__rhs) <= 0;
878}907}
879908
880template<class _CharT, class _Traits, int = 2>909template<class _CharT, class _Traits, int = 2>
881_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY910_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
882bool operator<=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,911bool operator<=(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
883 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT912 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
884{913{
885 return __lhs.compare(__rhs) <= 0;914 return __lhs.compare(__rhs) <= 0;
...@@ -888,7 +917,7 @@ bool operator<=(typename common_type<basic_string_view<_CharT, _Traits> >::type...@@ -888,7 +917,7 @@ bool operator<=(typename common_type<basic_string_view<_CharT, _Traits> >::type
888917
889// operator >=918// operator >=
890template<class _CharT, class _Traits>919template<class _CharT, class _Traits>
891_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY920_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
892bool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT921bool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
893{922{
894 return __lhs.compare(__rhs) >= 0;923 return __lhs.compare(__rhs) >= 0;
...@@ -896,38 +925,57 @@ bool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_Cha...@@ -896,38 +925,57 @@ bool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_Cha
896925
897926
898template<class _CharT, class _Traits, int = 1>927template<class _CharT, class _Traits, int = 1>
899_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY928_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
900bool operator>=(basic_string_view<_CharT, _Traits> __lhs,929bool operator>=(basic_string_view<_CharT, _Traits> __lhs,
901 typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT930 __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT
902{931{
903 return __lhs.compare(__rhs) >= 0;932 return __lhs.compare(__rhs) >= 0;
904}933}
905934
906template<class _CharT, class _Traits, int = 2>935template<class _CharT, class _Traits, int = 2>
907_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY936_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
908bool operator>=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,937bool operator>=(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs,
909 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT938 basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
910{939{
911 return __lhs.compare(__rhs) >= 0;940 return __lhs.compare(__rhs) >= 0;
912}941}
913942
943#endif // _LIBCPP_STD_VER > 17
914944
915template<class _CharT, class _Traits>945template<class _CharT, class _Traits>
916basic_ostream<_CharT, _Traits>&946_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
917operator<<(basic_ostream<_CharT, _Traits>& __os,947operator<<(basic_ostream<_CharT, _Traits>& __os,
918 basic_string_view<_CharT, _Traits> __str);948 basic_string_view<_CharT, _Traits> __str);
919949
920// [string.view.hash]950// [string.view.hash]
921template<class _CharT>951template<class _CharT>
922struct _LIBCPP_TEMPLATE_VIS hash<basic_string_view<_CharT, char_traits<_CharT> > >952struct __string_view_hash : public __unary_function<basic_string_view<_CharT, char_traits<_CharT> >, size_t>
923 : public __unary_function<basic_string_view<_CharT, char_traits<_CharT> >, size_t>
924{953{
925 _LIBCPP_INLINE_VISIBILITY954 _LIBCPP_INLINE_VISIBILITY
926 size_t operator()(const basic_string_view<_CharT, char_traits<_CharT> > __val) const _NOEXCEPT {955 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());
928 }957 }
929};958};
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
931#if _LIBCPP_STD_VER > 11979#if _LIBCPP_STD_VER > 11
932inline namespace literals980inline namespace literals
933{981{
...@@ -973,4 +1021,11 @@ _LIBCPP_END_NAMESPACE_STD...@@ -973,4 +1021,11 @@ _LIBCPP_END_NAMESPACE_STD
9731021
974_LIBCPP_POP_MACROS1022_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
976#endif // _LIBCPP_STRING_VIEW1031#endif // _LIBCPP_STRING_VIEW
lib/libcxx/include/strstream+11-11
...@@ -167,7 +167,7 @@ public:...@@ -167,7 +167,7 @@ public:
167 strstreambuf& operator=(strstreambuf&& __rhs);167 strstreambuf& operator=(strstreambuf&& __rhs);
168#endif // _LIBCPP_CXX03_LANG168#endif // _LIBCPP_CXX03_LANG
169169
170 virtual ~strstreambuf();170 ~strstreambuf() override;
171171
172 void swap(strstreambuf& __rhs);172 void swap(strstreambuf& __rhs);
173173
...@@ -176,13 +176,13 @@ public:...@@ -176,13 +176,13 @@ public:
176 int pcount() const;176 int pcount() const;
177177
178protected:178protected:
179 virtual int_type overflow (int_type __c = EOF);179 int_type overflow (int_type __c = EOF) override;
180 virtual int_type pbackfail(int_type __c = EOF);180 int_type pbackfail(int_type __c = EOF) override;
181 virtual int_type underflow();181 int_type underflow() override;
182 virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,182 pos_type seekoff(off_type __off, ios_base::seekdir __way,
183 ios_base::openmode __which = ios_base::in | ios_base::out);183 ios_base::openmode __which = ios_base::in | ios_base::out) override;
184 virtual pos_type seekpos(pos_type __sp,184 pos_type seekpos(pos_type __sp,
185 ios_base::openmode __which = ios_base::in | ios_base::out);185 ios_base::openmode __which = ios_base::in | ios_base::out) override;
186186
187private:187private:
188 typedef unsigned __mode_type;188 typedef unsigned __mode_type;
...@@ -272,7 +272,7 @@ public:...@@ -272,7 +272,7 @@ public:
272 }272 }
273#endif // _LIBCPP_CXX03_LANG273#endif // _LIBCPP_CXX03_LANG
274274
275 virtual ~istrstream();275 ~istrstream() override;
276276
277 _LIBCPP_INLINE_VISIBILITY277 _LIBCPP_INLINE_VISIBILITY
278 void swap(istrstream& __rhs)278 void swap(istrstream& __rhs)
...@@ -321,7 +321,7 @@ public:...@@ -321,7 +321,7 @@ public:
321 }321 }
322#endif // _LIBCPP_CXX03_LANG322#endif // _LIBCPP_CXX03_LANG
323323
324 virtual ~ostrstream();324 ~ostrstream() override;
325325
326 _LIBCPP_INLINE_VISIBILITY326 _LIBCPP_INLINE_VISIBILITY
327 void swap(ostrstream& __rhs)327 void swap(ostrstream& __rhs)
...@@ -381,7 +381,7 @@ public:...@@ -381,7 +381,7 @@ public:
381 }381 }
382#endif // _LIBCPP_CXX03_LANG382#endif // _LIBCPP_CXX03_LANG
383383
384 virtual ~strstream();384 ~strstream() override;
385385
386 _LIBCPP_INLINE_VISIBILITY386 _LIBCPP_INLINE_VISIBILITY
387 void swap(strstream& __rhs)387 void swap(strstream& __rhs)
lib/libcxx/include/system_error+92-33
...@@ -32,8 +32,9 @@ public:...@@ -32,8 +32,9 @@ public:
32 virtual string message(int ev) const = 0;32 virtual string message(int ev) const = 0;
3333
34 bool operator==(const error_category& rhs) const noexcept;34 bool operator==(const error_category& rhs) const noexcept;
35 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;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
37};38};
3839
39const error_category& generic_category() noexcept;40const error_category& generic_category() noexcept;
...@@ -75,7 +76,6 @@ public:...@@ -75,7 +76,6 @@ public:
75};76};
7677
77// non-member functions:78// non-member functions:
78bool operator<(const error_code& lhs, const error_code& rhs) noexcept;
79template <class charT, class traits>79template <class charT, class traits>
80 basic_ostream<charT,traits>&80 basic_ostream<charT,traits>&
81 operator<<(basic_ostream<charT,traits>& os, const error_code& ec);81 operator<<(basic_ostream<charT,traits>& os, const error_code& ec);
...@@ -102,8 +102,6 @@ public:...@@ -102,8 +102,6 @@ public:
102 explicit operator bool() const noexcept;102 explicit operator bool() const noexcept;
103};103};
104104
105bool operator<(const error_condition& lhs, const error_condition& rhs) noexcept;
106
107class system_error105class system_error
108 : public runtime_error106 : public runtime_error
109{107{
...@@ -128,12 +126,16 @@ error_condition make_error_condition(errc e) noexcept;...@@ -128,12 +126,16 @@ error_condition make_error_condition(errc e) noexcept;
128// Comparison operators:126// Comparison operators:
129bool operator==(const error_code& lhs, const error_code& rhs) noexcept;127bool operator==(const error_code& lhs, const error_code& rhs) noexcept;
130bool operator==(const error_code& lhs, const error_condition& rhs) noexcept;128bool 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
132bool operator==(const error_condition& lhs, const error_condition& rhs) noexcept;130bool operator==(const error_condition& lhs, const error_condition& rhs) noexcept;
133bool operator!=(const error_code& lhs, const error_code& rhs) noexcept;131bool operator!=(const error_code& lhs, const error_code& rhs) noexcept; // removed in C++20
134bool operator!=(const error_code& lhs, const error_condition& rhs) noexcept;132bool operator!=(const error_code& lhs, const error_condition& rhs) noexcept; // removed in C++20
135bool operator!=(const error_condition& lhs, const error_code& rhs) noexcept;133bool operator!=(const error_condition& lhs, const error_code& rhs) noexcept; // removed in C++20
136bool operator!=(const error_condition& lhs, const error_condition& rhs) noexcept;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
138template <> struct hash<std::error_code>;140template <> struct hash<std::error_code>;
139template <> struct hash<std::error_condition>;141template <> struct hash<std::error_condition>;
...@@ -147,12 +149,15 @@ template <> struct hash<std::error_condition>;...@@ -147,12 +149,15 @@ template <> struct hash<std::error_condition>;
147#include <__errc>149#include <__errc>
148#include <__functional/hash.h>150#include <__functional/hash.h>
149#include <__functional/unary_function.h>151#include <__functional/unary_function.h>
152#include <__memory/addressof.h>
150#include <stdexcept>153#include <stdexcept>
151#include <string>154#include <string>
152#include <type_traits>155#include <type_traits>
153#include <version>156#include <version>
154157
155// standard-mandated includes158// standard-mandated includes
159
160// [system.error.syn]
156#include <compare>161#include <compare>
157162
158#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)163#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -209,7 +214,7 @@ public:...@@ -209,7 +214,7 @@ public:
209 error_category() noexcept;214 error_category() noexcept;
210#else215#else
211 _LIBCPP_INLINE_VISIBILITY216 _LIBCPP_INLINE_VISIBILITY
212 _LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT = default;217 _LIBCPP_CONSTEXPR_SINCE_CXX14 error_category() _NOEXCEPT = default;
213#endif218#endif
214 error_category(const error_category&) = delete;219 error_category(const error_category&) = delete;
215 error_category& operator=(const error_category&) = delete;220 error_category& operator=(const error_category&) = delete;
...@@ -223,12 +228,21 @@ public:...@@ -223,12 +228,21 @@ public:
223 _LIBCPP_INLINE_VISIBILITY228 _LIBCPP_INLINE_VISIBILITY
224 bool operator==(const error_category& __rhs) const _NOEXCEPT {return this == &__rhs;}229 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
226 _LIBCPP_INLINE_VISIBILITY238 _LIBCPP_INLINE_VISIBILITY
227 bool operator!=(const error_category& __rhs) const _NOEXCEPT {return !(*this == __rhs);}239 bool operator!=(const error_category& __rhs) const _NOEXCEPT {return !(*this == __rhs);}
228240
229 _LIBCPP_INLINE_VISIBILITY241 _LIBCPP_INLINE_VISIBILITY
230 bool operator< (const error_category& __rhs) const _NOEXCEPT {return this < &__rhs;}242 bool operator< (const error_category& __rhs) const _NOEXCEPT {return this < &__rhs;}
231243
244#endif // _LIBCPP_STD_VER > 17
245
232 friend class _LIBCPP_HIDDEN __do_message;246 friend class _LIBCPP_HIDDEN __do_message;
233};247};
234248
...@@ -236,12 +250,19 @@ class _LIBCPP_HIDDEN __do_message...@@ -236,12 +250,19 @@ class _LIBCPP_HIDDEN __do_message
236 : public error_category250 : public error_category
237{251{
238public:252public:
239 virtual string message(int __ev) const;253 string message(int __ev) const override;
240};254};
241255
242_LIBCPP_FUNC_VIS const error_category& generic_category() _NOEXCEPT;256_LIBCPP_FUNC_VIS const error_category& generic_category() _NOEXCEPT;
243_LIBCPP_FUNC_VIS const error_category& system_category() _NOEXCEPT;257_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
245class _LIBCPP_TYPE_VIS error_condition266class _LIBCPP_TYPE_VIS error_condition
246{267{
247 int __val_;268 int __val_;
...@@ -259,7 +280,10 @@ public:...@@ -259,7 +280,10 @@ public:
259 error_condition(_Ep __e,280 error_condition(_Ep __e,
260 typename enable_if<is_error_condition_enum<_Ep>::value>::type* = nullptr281 typename enable_if<is_error_condition_enum<_Ep>::value>::type* = nullptr
261 ) _NOEXCEPT282 ) _NOEXCEPT
262 {*this = make_error_condition(__e);}283 {
284 using __adl_only::make_error_condition;
285 *this = make_error_condition(__e);
286 }
263287
264 _LIBCPP_INLINE_VISIBILITY288 _LIBCPP_INLINE_VISIBILITY
265 void assign(int __val, const error_category& __cat) _NOEXCEPT289 void assign(int __val, const error_category& __cat) _NOEXCEPT
...@@ -276,7 +300,11 @@ public:...@@ -276,7 +300,11 @@ public:
276 error_condition&300 error_condition&
277 >::type301 >::type
278 operator=(_Ep __e) _NOEXCEPT302 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
281 _LIBCPP_INLINE_VISIBILITY309 _LIBCPP_INLINE_VISIBILITY
282 void clear() _NOEXCEPT310 void clear() _NOEXCEPT
...@@ -303,14 +331,6 @@ make_error_condition(errc __e) _NOEXCEPT...@@ -303,14 +331,6 @@ make_error_condition(errc __e) _NOEXCEPT
303 return error_condition(static_cast<int>(__e), generic_category());331 return error_condition(static_cast<int>(__e), generic_category());
304}332}
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
314// error_code334// error_code
315335
316class _LIBCPP_TYPE_VIS error_code336class _LIBCPP_TYPE_VIS error_code
...@@ -330,7 +350,10 @@ public:...@@ -330,7 +350,10 @@ public:
330 error_code(_Ep __e,350 error_code(_Ep __e,
331 typename enable_if<is_error_code_enum<_Ep>::value>::type* = nullptr351 typename enable_if<is_error_code_enum<_Ep>::value>::type* = nullptr
332 ) _NOEXCEPT352 ) _NOEXCEPT
333 {*this = make_error_code(__e);}353 {
354 using __adl_only::make_error_code;
355 *this = make_error_code(__e);
356 }
334357
335 _LIBCPP_INLINE_VISIBILITY358 _LIBCPP_INLINE_VISIBILITY
336 void assign(int __val, const error_category& __cat) _NOEXCEPT359 void assign(int __val, const error_category& __cat) _NOEXCEPT
...@@ -347,7 +370,11 @@ public:...@@ -347,7 +370,11 @@ public:
347 error_code&370 error_code&
348 >::type371 >::type
349 operator=(_Ep __e) _NOEXCEPT372 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
352 _LIBCPP_INLINE_VISIBILITY379 _LIBCPP_INLINE_VISIBILITY
353 void clear() _NOEXCEPT380 void clear() _NOEXCEPT
...@@ -379,14 +406,6 @@ make_error_code(errc __e) _NOEXCEPT...@@ -379,14 +406,6 @@ make_error_code(errc __e) _NOEXCEPT
379 return error_code(static_cast<int>(__e), generic_category());406 return error_code(static_cast<int>(__e), generic_category());
380}407}
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
390inline _LIBCPP_INLINE_VISIBILITY409inline _LIBCPP_INLINE_VISIBILITY
391bool410bool
392operator==(const error_code& __x, const error_code& __y) _NOEXCEPT411operator==(const error_code& __x, const error_code& __y) _NOEXCEPT
...@@ -402,12 +421,14 @@ operator==(const error_code& __x, const error_condition& __y) _NOEXCEPT...@@ -402,12 +421,14 @@ operator==(const error_code& __x, const error_condition& __y) _NOEXCEPT
402 || __y.category().equivalent(__x, __y.value());421 || __y.category().equivalent(__x, __y.value());
403}422}
404423
424#if _LIBCPP_STD_VER <= 17
405inline _LIBCPP_INLINE_VISIBILITY425inline _LIBCPP_INLINE_VISIBILITY
406bool426bool
407operator==(const error_condition& __x, const error_code& __y) _NOEXCEPT427operator==(const error_condition& __x, const error_code& __y) _NOEXCEPT
408{428{
409 return __y == __x;429 return __y == __x;
410}430}
431#endif
411432
412inline _LIBCPP_INLINE_VISIBILITY433inline _LIBCPP_INLINE_VISIBILITY
413bool434bool
...@@ -416,6 +437,8 @@ operator==(const error_condition& __x, const error_condition& __y) _NOEXCEPT...@@ -416,6 +437,8 @@ operator==(const error_condition& __x, const error_condition& __y) _NOEXCEPT
416 return __x.category() == __y.category() && __x.value() == __y.value();437 return __x.category() == __y.category() && __x.value() == __y.value();
417}438}
418439
440#if _LIBCPP_STD_VER <= 17
441
419inline _LIBCPP_INLINE_VISIBILITY442inline _LIBCPP_INLINE_VISIBILITY
420bool443bool
421operator!=(const error_code& __x, const error_code& __y) _NOEXCEPT444operator!=(const error_code& __x, const error_code& __y) _NOEXCEPT
...@@ -436,6 +459,42 @@ bool...@@ -436,6 +459,42 @@ bool
436operator!=(const error_condition& __x, const error_condition& __y) _NOEXCEPT459operator!=(const error_condition& __x, const error_condition& __y) _NOEXCEPT
437{return !(__x == __y);}460{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
439template <>498template <>
440struct _LIBCPP_TEMPLATE_VIS hash<error_code>499struct _LIBCPP_TEMPLATE_VIS hash<error_code>
441 : public __unary_function<error_code, size_t>500 : public __unary_function<error_code, size_t>
...@@ -472,7 +531,7 @@ public:...@@ -472,7 +531,7 @@ public:
472 system_error(int __ev, const error_category& __ecat, const char* __what_arg);531 system_error(int __ev, const error_category& __ecat, const char* __what_arg);
473 system_error(int __ev, const error_category& __ecat);532 system_error(int __ev, const error_category& __ecat);
474 system_error(const system_error&) _NOEXCEPT = default;533 system_error(const system_error&) _NOEXCEPT = default;
475 ~system_error() _NOEXCEPT;534 ~system_error() _NOEXCEPT override;
476535
477 _LIBCPP_INLINE_VISIBILITY536 _LIBCPP_INLINE_VISIBILITY
478 const error_code& code() const _NOEXCEPT {return __ec_;}537 const error_code& code() const _NOEXCEPT {return __ec_;}
lib/libcxx/include/tgmath.h+6-8
...@@ -24,13 +24,11 @@...@@ -24,13 +24,11 @@
24#endif24#endif
2525
26#ifdef __cplusplus26#ifdef __cplusplus
2727# include <ctgmath>
28#include <ctgmath>28#else
2929# if __has_include_next(<tgmath.h>)
30#else // __cplusplus30# include_next <tgmath.h>
3131# endif
32#include_next <tgmath.h>32#endif
33
34#endif // __cplusplus
3533
36#endif // _LIBCPP_TGMATH_H34#endif // _LIBCPP_TGMATH_H
lib/libcxx/include/thread+22-16
...@@ -53,11 +53,12 @@ public:...@@ -53,11 +53,12 @@ public:
53};53};
5454
55bool operator==(thread::id x, thread::id y) noexcept;55bool operator==(thread::id x, thread::id y) noexcept;
56bool 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;57bool operator< (thread::id x, thread::id y) noexcept; // removed in C++20
58bool operator<=(thread::id x, thread::id y) noexcept;58bool operator<=(thread::id x, thread::id y) noexcept; // removed in C++20
59bool operator> (thread::id x, thread::id y) noexcept;59bool operator> (thread::id x, thread::id y) noexcept; // removed in C++20
60bool operator>=(thread::id x, thread::id y) noexcept;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
62template<class charT, class traits>63template<class charT, class traits>
63basic_ostream<charT, traits>&64basic_ostream<charT, traits>&
...@@ -85,6 +86,7 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);...@@ -85,6 +86,7 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
85#include <__assert> // all public C++ headers provide the assertion handler86#include <__assert> // all public C++ headers provide the assertion handler
86#include <__config>87#include <__config>
87#include <__functional/hash.h>88#include <__functional/hash.h>
89#include <__memory/unique_ptr.h>
88#include <__mutex_base>90#include <__mutex_base>
89#include <__thread/poll_with_backoff.h>91#include <__thread/poll_with_backoff.h>
90#include <__thread/timed_backoff_policy.h>92#include <__thread/timed_backoff_policy.h>
...@@ -92,18 +94,14 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);...@@ -92,18 +94,14 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
92#include <__utility/forward.h>94#include <__utility/forward.h>
93#include <cstddef>95#include <cstddef>
94#include <iosfwd>96#include <iosfwd>
95#include <memory>
96#include <system_error>97#include <system_error>
97#include <tuple>98#include <tuple>
98#include <type_traits>99#include <type_traits>
99#include <version>100#include <version>
100101
101#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
102# include <chrono>
103# include <functional>
104#endif
105
106// standard-mandated includes102// standard-mandated includes
103
104// [thread.syn]
107#include <compare>105#include <compare>
108106
109#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)107#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -201,7 +199,7 @@ __thread_specific_ptr<_Tp>::set_pointer(pointer __p)...@@ -201,7 +199,7 @@ __thread_specific_ptr<_Tp>::set_pointer(pointer __p)
201{199{
202 _LIBCPP_ASSERT(get() == nullptr,200 _LIBCPP_ASSERT(get() == nullptr,
203 "Attempting to overwrite thread local data");201 "Attempting to overwrite thread local data");
204 __libcpp_tls_set(__key_, __p);202 std::__libcpp_tls_set(__key_, __p);
205}203}
206204
207template<>205template<>
...@@ -235,7 +233,7 @@ public:...@@ -235,7 +233,7 @@ public:
235 thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {}233 thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {}
236#ifndef _LIBCPP_CXX03_LANG234#ifndef _LIBCPP_CXX03_LANG
237 template <class _Fp, class ..._Args,235 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> >
239 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS237 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
240 explicit thread(_Fp&& __f, _Args&&... __args);238 explicit thread(_Fp&& __f, _Args&&... __args);
241#else // _LIBCPP_CXX03_LANG239#else // _LIBCPP_CXX03_LANG
...@@ -328,7 +326,7 @@ struct __thread_invoke_pair {...@@ -328,7 +326,7 @@ struct __thread_invoke_pair {
328};326};
329327
330template <class _Fp>328template <class _Fp>
331void* __thread_proxy_cxx03(void* __vp)329_LIBCPP_HIDE_FROM_ABI void* __thread_proxy_cxx03(void* __vp)
332{330{
333 unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));331 unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
334 __thread_local_data().set_pointer(__p->__tsp_.release());332 __thread_local_data().set_pointer(__p->__tsp_.release());
...@@ -361,7 +359,7 @@ namespace this_thread...@@ -361,7 +359,7 @@ namespace this_thread
361_LIBCPP_FUNC_VIS void sleep_for(const chrono::nanoseconds& __ns);359_LIBCPP_FUNC_VIS void sleep_for(const chrono::nanoseconds& __ns);
362360
363template <class _Rep, class _Period>361template <class _Rep, class _Period>
364void362_LIBCPP_HIDE_FROM_ABI void
365sleep_for(const chrono::duration<_Rep, _Period>& __d)363sleep_for(const chrono::duration<_Rep, _Period>& __d)
366{364{
367 if (__d > chrono::duration<_Rep, _Period>::zero())365 if (__d > chrono::duration<_Rep, _Period>::zero())
...@@ -385,7 +383,7 @@ sleep_for(const chrono::duration<_Rep, _Period>& __d)...@@ -385,7 +383,7 @@ sleep_for(const chrono::duration<_Rep, _Period>& __d)
385}383}
386384
387template <class _Clock, class _Duration>385template <class _Clock, class _Duration>
388void386_LIBCPP_HIDE_FROM_ABI void
389sleep_until(const chrono::time_point<_Clock, _Duration>& __t)387sleep_until(const chrono::time_point<_Clock, _Duration>& __t)
390{388{
391 mutex __mut;389 mutex __mut;
...@@ -412,4 +410,12 @@ _LIBCPP_END_NAMESPACE_STD...@@ -412,4 +410,12 @@ _LIBCPP_END_NAMESPACE_STD
412410
413_LIBCPP_POP_MACROS411_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
415#endif // _LIBCPP_THREAD421#endif // _LIBCPP_THREAD
lib/libcxx/include/tuple+162-126
...@@ -205,10 +205,45 @@ template <class... Types>...@@ -205,10 +205,45 @@ template <class... Types>
205#include <__compare/common_comparison_category.h>205#include <__compare/common_comparison_category.h>
206#include <__compare/synth_three_way.h>206#include <__compare/synth_three_way.h>
207#include <__config>207#include <__config>
208#include <__functional/invoke.h>
208#include <__functional/unwrap_ref.h>209#include <__functional/unwrap_ref.h>
210#include <__fwd/array.h>
209#include <__memory/allocator_arg_t.h>211#include <__memory/allocator_arg_t.h>
210#include <__memory/uses_allocator.h>212#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>
212#include <__utility/forward.h>247#include <__utility/forward.h>
213#include <__utility/integer_sequence.h>248#include <__utility/integer_sequence.h>
214#include <__utility/move.h>249#include <__utility/move.h>
...@@ -216,18 +251,11 @@ template <class... Types>...@@ -216,18 +251,11 @@ template <class... Types>
216#include <__utility/piecewise_construct.h>251#include <__utility/piecewise_construct.h>
217#include <__utility/swap.h>252#include <__utility/swap.h>
218#include <cstddef>253#include <cstddef>
219#include <type_traits>
220#include <version>254#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
230// standard-mandated includes256// standard-mandated includes
257
258// [tuple.syn]
231#include <compare>259#include <compare>
232260
233#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)261#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -247,7 +275,7 @@ template <size_t _Ip, class _Hp,...@@ -247,7 +275,7 @@ template <size_t _Ip, class _Hp,
247class __tuple_leaf;275class __tuple_leaf;
248276
249template <size_t _Ip, class _Hp, bool _Ep>277template <size_t _Ip, class _Hp, bool _Ep>
250inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11278inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
251void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)279void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
252 _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)280 _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)
253{281{
...@@ -255,7 +283,7 @@ void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)...@@ -255,7 +283,7 @@ void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
255}283}
256284
257template <size_t _Ip, class _Hp, bool _Ep>285template <size_t _Ip, class _Hp, bool _Ep>
258_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11286_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
259void swap(const __tuple_leaf<_Ip, _Hp, _Ep>& __x, const __tuple_leaf<_Ip, _Hp, _Ep>& __y)287void swap(const __tuple_leaf<_Ip, _Hp, _Ep>& __x, const __tuple_leaf<_Ip, _Hp, _Ep>& __y)
260 _NOEXCEPT_(__is_nothrow_swappable<const _Hp>::value) {288 _NOEXCEPT_(__is_nothrow_swappable<const _Hp>::value) {
261 swap(__x.get(), __y.get());289 swap(__x.get(), __y.get());
...@@ -275,7 +303,7 @@ class __tuple_leaf...@@ -275,7 +303,7 @@ class __tuple_leaf
275#endif303#endif
276 }304 }
277305
278 _LIBCPP_CONSTEXPR_AFTER_CXX11306 _LIBCPP_CONSTEXPR_SINCE_CXX14
279 __tuple_leaf& operator=(const __tuple_leaf&);307 __tuple_leaf& operator=(const __tuple_leaf&);
280public:308public:
281 _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf()309 _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf()
...@@ -307,33 +335,33 @@ public:...@@ -307,33 +335,33 @@ public:
307 template <class _Tp,335 template <class _Tp,
308 class = __enable_if_t<336 class = __enable_if_t<
309 _And<337 _And<
310 _IsNotSame<__uncvref_t<_Tp>, __tuple_leaf>,338 _IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>,
311 is_constructible<_Hp, _Tp>339 is_constructible<_Hp, _Tp>
312 >::value340 >::value
313 >341 >
314 >342 >
315 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11343 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
316 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))344 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
317 : __value_(_VSTD::forward<_Tp>(__t))345 : __value_(_VSTD::forward<_Tp>(__t))
318 {static_assert(__can_bind_reference<_Tp&&>(),346 {static_assert(__can_bind_reference<_Tp&&>(),
319 "Attempted construction of reference element binds to a temporary whose lifetime has ended");}347 "Attempted construction of reference element binds to a temporary whose lifetime has ended");}
320348
321 template <class _Tp, class _Alloc>349 template <class _Tp, class _Alloc>
322 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11350 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
323 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)351 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
324 : __value_(_VSTD::forward<_Tp>(__t))352 : __value_(_VSTD::forward<_Tp>(__t))
325 {static_assert(__can_bind_reference<_Tp&&>(),353 {static_assert(__can_bind_reference<_Tp&&>(),
326 "Attempted construction of reference element binds to a temporary whose lifetime has ended");}354 "Attempted construction of reference element binds to a temporary whose lifetime has ended");}
327355
328 template <class _Tp, class _Alloc>356 template <class _Tp, class _Alloc>
329 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11357 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
330 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)358 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
331 : __value_(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))359 : __value_(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))
332 {static_assert(!is_reference<_Hp>::value,360 {static_assert(!is_reference<_Hp>::value,
333 "Attempted to uses-allocator construct a reference element in a tuple");}361 "Attempted to uses-allocator construct a reference element in a tuple");}
334362
335 template <class _Tp, class _Alloc>363 template <class _Tp, class _Alloc>
336 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11364 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
337 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)365 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
338 : __value_(_VSTD::forward<_Tp>(__t), __a)366 : __value_(_VSTD::forward<_Tp>(__t), __a)
339 {static_assert(!is_reference<_Hp>::value,367 {static_assert(!is_reference<_Hp>::value,
...@@ -342,28 +370,28 @@ public:...@@ -342,28 +370,28 @@ public:
342 __tuple_leaf(const __tuple_leaf& __t) = default;370 __tuple_leaf(const __tuple_leaf& __t) = default;
343 __tuple_leaf(__tuple_leaf&& __t) = default;371 __tuple_leaf(__tuple_leaf&& __t) = default;
344372
345 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11373 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
346 int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)374 int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
347 {375 {
348 _VSTD::swap(*this, __t);376 _VSTD::swap(*this, __t);
349 return 0;377 return 0;
350 }378 }
351379
352 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11380 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
353 int swap(const __tuple_leaf& __t) const _NOEXCEPT_(__is_nothrow_swappable<const __tuple_leaf>::value) {381 int swap(const __tuple_leaf& __t) const _NOEXCEPT_(__is_nothrow_swappable<const __tuple_leaf>::value) {
354 _VSTD::swap(*this, __t);382 _VSTD::swap(*this, __t);
355 return 0;383 return 0;
356 }384 }
357385
358 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return __value_;}386 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 _Hp& get() _NOEXCEPT {return __value_;}
359 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return __value_;}387 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Hp& get() const _NOEXCEPT {return __value_;}
360};388};
361389
362template <size_t _Ip, class _Hp>390template <size_t _Ip, class _Hp>
363class __tuple_leaf<_Ip, _Hp, true>391class __tuple_leaf<_Ip, _Hp, true>
364 : private _Hp392 : private _Hp
365{393{
366 _LIBCPP_CONSTEXPR_AFTER_CXX11394 _LIBCPP_CONSTEXPR_SINCE_CXX14
367 __tuple_leaf& operator=(const __tuple_leaf&);395 __tuple_leaf& operator=(const __tuple_leaf&);
368public:396public:
369 _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf()397 _LIBCPP_INLINE_VISIBILITY constexpr __tuple_leaf()
...@@ -386,12 +414,12 @@ public:...@@ -386,12 +414,12 @@ public:
386 template <class _Tp,414 template <class _Tp,
387 class = __enable_if_t<415 class = __enable_if_t<
388 _And<416 _And<
389 _IsNotSame<__uncvref_t<_Tp>, __tuple_leaf>,417 _IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>,
390 is_constructible<_Hp, _Tp>418 is_constructible<_Hp, _Tp>
391 >::value419 >::value
392 >420 >
393 >421 >
394 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11422 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
395 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))423 explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
396 : _Hp(_VSTD::forward<_Tp>(__t)) {}424 : _Hp(_VSTD::forward<_Tp>(__t)) {}
397425
...@@ -413,7 +441,7 @@ public:...@@ -413,7 +441,7 @@ public:
413 __tuple_leaf(__tuple_leaf const &) = default;441 __tuple_leaf(__tuple_leaf const &) = default;
414 __tuple_leaf(__tuple_leaf &&) = default;442 __tuple_leaf(__tuple_leaf &&) = default;
415443
416 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11444 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
417 int445 int
418 swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)446 swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
419 {447 {
...@@ -421,18 +449,18 @@ public:...@@ -421,18 +449,18 @@ public:
421 return 0;449 return 0;
422 }450 }
423451
424 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11452 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
425 int swap(const __tuple_leaf& __rhs) const _NOEXCEPT_(__is_nothrow_swappable<const __tuple_leaf>::value) {453 int swap(const __tuple_leaf& __rhs) const _NOEXCEPT_(__is_nothrow_swappable<const __tuple_leaf>::value) {
426 _VSTD::swap(*this, __rhs);454 _VSTD::swap(*this, __rhs);
427 return 0;455 return 0;
428 }456 }
429457
430 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);}458 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 _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);}459 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}
432};460};
433461
434template <class ..._Tp>462template <class ..._Tp>
435_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11463_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
436void __swallow(_Tp&&...) _NOEXCEPT {}464void __swallow(_Tp&&...) _NOEXCEPT {}
437465
438template <class _Tp>466template <class _Tp>
...@@ -457,7 +485,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp....@@ -457,7 +485,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
457485
458 template <size_t ..._Uf, class ..._Tf,486 template <size_t ..._Uf, class ..._Tf,
459 size_t ..._Ul, class ..._Tl, class ..._Up>487 size_t ..._Ul, class ..._Tl, class ..._Up>
460 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11488 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
461 explicit489 explicit
462 __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,490 __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
463 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,491 __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
...@@ -470,7 +498,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp....@@ -470,7 +498,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
470498
471 template <class _Alloc, size_t ..._Uf, class ..._Tf,499 template <class _Alloc, size_t ..._Uf, class ..._Tf,
472 size_t ..._Ul, class ..._Tl, class ..._Up>500 size_t ..._Ul, class ..._Tl, class ..._Up>
473 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11501 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
474 explicit502 explicit
475 __tuple_impl(allocator_arg_t, const _Alloc& __a,503 __tuple_impl(allocator_arg_t, const _Alloc& __a,
476 __tuple_indices<_Uf...>, __tuple_types<_Tf...>,504 __tuple_indices<_Uf...>, __tuple_types<_Tf...>,
...@@ -484,7 +512,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp....@@ -484,7 +512,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
484 template <class _Tuple,512 template <class _Tuple,
485 class = __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value>513 class = __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value>
486 >514 >
487 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11515 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
488 __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,516 __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
489 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))517 typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
490 : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx,518 : __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....@@ -494,7 +522,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
494 template <class _Alloc, class _Tuple,522 template <class _Alloc, class _Tuple,
495 class = __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value>523 class = __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value>
496 >524 >
497 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11525 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
498 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)526 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
499 : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,527 : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
500 typename __make_tuple_types<_Tuple>::type>::type>(), __a,528 typename __make_tuple_types<_Tuple>::type>::type>(), __a,
...@@ -505,14 +533,14 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp....@@ -505,14 +533,14 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
505 __tuple_impl(const __tuple_impl&) = default;533 __tuple_impl(const __tuple_impl&) = default;
506 __tuple_impl(__tuple_impl&&) = default;534 __tuple_impl(__tuple_impl&&) = default;
507535
508 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11536 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
509 void swap(__tuple_impl& __t)537 void swap(__tuple_impl& __t)
510 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)538 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
511 {539 {
512 _VSTD::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);540 _VSTD::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
513 }541 }
514542
515 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11543 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
516 void swap(const __tuple_impl& __t) const544 void swap(const __tuple_impl& __t) const
517 _NOEXCEPT_(__all<__is_nothrow_swappable<const _Tp>::value...>::value)545 _NOEXCEPT_(__all<__is_nothrow_swappable<const _Tp>::value...>::value)
518 {546 {
...@@ -521,13 +549,13 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp....@@ -521,13 +549,13 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
521};549};
522550
523template<class _Dest, class _Source, size_t ..._Np>551template<class _Dest, class _Source, size_t ..._Np>
524_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11552_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
525void __memberwise_copy_assign(_Dest& __dest, _Source const& __source, __tuple_indices<_Np...>) {553void __memberwise_copy_assign(_Dest& __dest, _Source const& __source, __tuple_indices<_Np...>) {
526 _VSTD::__swallow(((_VSTD::get<_Np>(__dest) = _VSTD::get<_Np>(__source)), void(), 0)...);554 _VSTD::__swallow(((_VSTD::get<_Np>(__dest) = _VSTD::get<_Np>(__source)), void(), 0)...);
527}555}
528556
529template<class _Dest, class _Source, class ..._Up, size_t ..._Np>557template<class _Dest, class _Source, class ..._Up, size_t ..._Np>
530_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11558_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
531void __memberwise_forward_assign(_Dest& __dest, _Source&& __source, __tuple_types<_Up...>, __tuple_indices<_Np...>) {559void __memberwise_forward_assign(_Dest& __dest, _Source&& __source, __tuple_types<_Up...>, __tuple_indices<_Np...>) {
532 _VSTD::__swallow(((560 _VSTD::__swallow(((
533 _VSTD::get<_Np>(__dest) = _VSTD::forward<_Up>(_VSTD::get<_Np>(__source))561 _VSTD::get<_Np>(__dest) = _VSTD::forward<_Up>(_VSTD::get<_Np>(__source))
...@@ -541,13 +569,13 @@ class _LIBCPP_TEMPLATE_VIS tuple...@@ -541,13 +569,13 @@ class _LIBCPP_TEMPLATE_VIS tuple
541569
542 _BaseT __base_;570 _BaseT __base_;
543571
544 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11572 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_SINCE_CXX14
545 typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;573 typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
546 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11574 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_SINCE_CXX14
547 const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;575 const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
548 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11576 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_SINCE_CXX14
549 typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;577 typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
550 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11578 template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_SINCE_CXX14
551 const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT;579 const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT;
552public:580public:
553 // [tuple.cnstr]581 // [tuple.cnstr]
...@@ -580,7 +608,7 @@ public:...@@ -580,7 +608,7 @@ public:
580 _IsImpDefault<_Tp>... // explicit check608 _IsImpDefault<_Tp>... // explicit check
581 >::value609 >::value
582 , int> = 0>610 , int> = 0>
583 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17611 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
584 tuple(allocator_arg_t, _Alloc const& __a)612 tuple(allocator_arg_t, _Alloc const& __a)
585 : __base_(allocator_arg_t(), __a,613 : __base_(allocator_arg_t(), __a,
586 __tuple_indices<>(), __tuple_types<>(),614 __tuple_indices<>(), __tuple_types<>(),
...@@ -595,7 +623,7 @@ public:...@@ -595,7 +623,7 @@ public:
595 _Not<_Lazy<_And, _IsImpDefault<_Tp>...> > // explicit check623 _Not<_Lazy<_And, _IsImpDefault<_Tp>...> > // explicit check
596 >::value624 >::value
597 , int> = 0>625 , int> = 0>
598 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17626 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
599 explicit tuple(allocator_arg_t, _Alloc const& __a)627 explicit tuple(allocator_arg_t, _Alloc const& __a)
600 : __base_(allocator_arg_t(), __a,628 : __base_(allocator_arg_t(), __a,
601 __tuple_indices<>(), __tuple_types<>(),629 __tuple_indices<>(), __tuple_types<>(),
...@@ -610,7 +638,7 @@ public:...@@ -610,7 +638,7 @@ public:
610 is_convertible<const _Tp&, _Tp>... // explicit check638 is_convertible<const _Tp&, _Tp>... // explicit check
611 >::value639 >::value
612 , int> = 0>640 , int> = 0>
613 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11641 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
614 tuple(const _Tp& ... __t)642 tuple(const _Tp& ... __t)
615 _NOEXCEPT_(_And<is_nothrow_copy_constructible<_Tp>...>::value)643 _NOEXCEPT_(_And<is_nothrow_copy_constructible<_Tp>...>::value)
616 : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),644 : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
...@@ -627,7 +655,7 @@ public:...@@ -627,7 +655,7 @@ public:
627 _Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> > // explicit check655 _Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> > // explicit check
628 >::value656 >::value
629 , int> = 0>657 , int> = 0>
630 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11658 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
631 explicit tuple(const _Tp& ... __t)659 explicit tuple(const _Tp& ... __t)
632 _NOEXCEPT_(_And<is_nothrow_copy_constructible<_Tp>...>::value)660 _NOEXCEPT_(_And<is_nothrow_copy_constructible<_Tp>...>::value)
633 : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),661 : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
...@@ -644,7 +672,7 @@ public:...@@ -644,7 +672,7 @@ public:
644 is_convertible<const _Tp&, _Tp>... // explicit check672 is_convertible<const _Tp&, _Tp>... // explicit check
645 >::value673 >::value
646 , int> = 0>674 , int> = 0>
647 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17675 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
648 tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)676 tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
649 : __base_(allocator_arg_t(), __a,677 : __base_(allocator_arg_t(), __a,
650 typename __make_tuple_indices<sizeof...(_Tp)>::type(),678 typename __make_tuple_indices<sizeof...(_Tp)>::type(),
...@@ -661,7 +689,7 @@ public:...@@ -661,7 +689,7 @@ public:
661 _Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> > // explicit check689 _Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> > // explicit check
662 >::value690 >::value
663 , int> = 0>691 , int> = 0>
664 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17692 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
665 explicit tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)693 explicit tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
666 : __base_(allocator_arg_t(), __a,694 : __base_(allocator_arg_t(), __a,
667 typename __make_tuple_indices<sizeof...(_Tp)>::type(),695 typename __make_tuple_indices<sizeof...(_Tp)>::type(),
...@@ -673,7 +701,7 @@ public:...@@ -673,7 +701,7 @@ public:
673701
674 // tuple(U&& ...) constructors (including allocator_arg_t variants)702 // tuple(U&& ...) constructors (including allocator_arg_t variants)
675 template <class ..._Up> struct _IsThisTuple : false_type { };703 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
678 template <class ..._Up>706 template <class ..._Up>
679 struct _EnableUTypesCtor : _And<707 struct _EnableUTypesCtor : _And<
...@@ -689,7 +717,7 @@ public:...@@ -689,7 +717,7 @@ public:
689 is_convertible<_Up, _Tp>... // explicit check717 is_convertible<_Up, _Tp>... // explicit check
690 >::value718 >::value
691 , int> = 0>719 , int> = 0>
692 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11720 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
693 tuple(_Up&&... __u)721 tuple(_Up&&... __u)
694 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))722 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
695 : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),723 : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
...@@ -705,7 +733,7 @@ public:...@@ -705,7 +733,7 @@ public:
705 _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check733 _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
706 >::value734 >::value
707 , int> = 0>735 , int> = 0>
708 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11736 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
709 explicit tuple(_Up&&... __u)737 explicit tuple(_Up&&... __u)
710 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))738 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
711 : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),739 : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
...@@ -721,7 +749,7 @@ public:...@@ -721,7 +749,7 @@ public:
721 is_convertible<_Up, _Tp>... // explicit check749 is_convertible<_Up, _Tp>... // explicit check
722 >::value750 >::value
723 , int> = 0>751 , int> = 0>
724 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17752 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
725 tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)753 tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
726 : __base_(allocator_arg_t(), __a,754 : __base_(allocator_arg_t(), __a,
727 typename __make_tuple_indices<sizeof...(_Up)>::type(),755 typename __make_tuple_indices<sizeof...(_Up)>::type(),
...@@ -737,7 +765,7 @@ public:...@@ -737,7 +765,7 @@ public:
737 _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check765 _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
738 >::value766 >::value
739 , int> = 0>767 , int> = 0>
740 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17768 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
741 explicit tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)769 explicit tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
742 : __base_(allocator_arg_t(), __a,770 : __base_(allocator_arg_t(), __a,
743 typename __make_tuple_indices<sizeof...(_Up)>::type(),771 typename __make_tuple_indices<sizeof...(_Up)>::type(),
...@@ -753,7 +781,7 @@ public:...@@ -753,7 +781,7 @@ public:
753 template <class _Alloc, template<class...> class _And = _And, __enable_if_t<781 template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
754 _And<is_copy_constructible<_Tp>...>::value782 _And<is_copy_constructible<_Tp>...>::value
755 , int> = 0>783 , int> = 0>
756 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17784 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
757 tuple(allocator_arg_t, const _Alloc& __alloc, const tuple& __t)785 tuple(allocator_arg_t, const _Alloc& __alloc, const tuple& __t)
758 : __base_(allocator_arg_t(), __alloc, __t)786 : __base_(allocator_arg_t(), __alloc, __t)
759 { }787 { }
...@@ -761,14 +789,14 @@ public:...@@ -761,14 +789,14 @@ public:
761 template <class _Alloc, template<class...> class _And = _And, __enable_if_t<789 template <class _Alloc, template<class...> class _And = _And, __enable_if_t<
762 _And<is_move_constructible<_Tp>...>::value790 _And<is_move_constructible<_Tp>...>::value
763 , int> = 0>791 , int> = 0>
764 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17792 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
765 tuple(allocator_arg_t, const _Alloc& __alloc, tuple&& __t)793 tuple(allocator_arg_t, const _Alloc& __alloc, tuple&& __t)
766 : __base_(allocator_arg_t(), __alloc, _VSTD::move(__t))794 : __base_(allocator_arg_t(), __alloc, _VSTD::move(__t))
767 { }795 { }
768796
769 // tuple(const tuple<U...>&) constructors (including allocator_arg_t variants)797 // 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>
772 struct _EnableCtorFromUTypesTuple : false_type {};800 struct _EnableCtorFromUTypesTuple : false_type {};
773801
774 template <class _OtherTuple, class... _Up>802 template <class _OtherTuple, class... _Up>
...@@ -797,7 +825,7 @@ public:...@@ -797,7 +825,7 @@ public:
797 is_convertible<const _Up&, _Tp>... // explicit check825 is_convertible<const _Up&, _Tp>... // explicit check
798 >::value826 >::value
799 , int> = 0>827 , int> = 0>
800 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11828 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
801 tuple(const tuple<_Up...>& __t)829 tuple(const tuple<_Up...>& __t)
802 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, const _Up&>...>::value))830 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, const _Up&>...>::value))
803 : __base_(__t)831 : __base_(__t)
...@@ -809,7 +837,7 @@ public:...@@ -809,7 +837,7 @@ public:
809 _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check837 _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check
810 >::value838 >::value
811 , int> = 0>839 , int> = 0>
812 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11840 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
813 explicit tuple(const tuple<_Up...>& __t)841 explicit tuple(const tuple<_Up...>& __t)
814 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, const _Up&>...>::value))842 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, const _Up&>...>::value))
815 : __base_(__t)843 : __base_(__t)
...@@ -821,7 +849,7 @@ public:...@@ -821,7 +849,7 @@ public:
821 is_convertible<const _Up&, _Tp>... // explicit check849 is_convertible<const _Up&, _Tp>... // explicit check
822 >::value850 >::value
823 , int> = 0>851 , int> = 0>
824 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17852 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
825 tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t)853 tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t)
826 : __base_(allocator_arg_t(), __a, __t)854 : __base_(allocator_arg_t(), __a, __t)
827 { }855 { }
...@@ -832,7 +860,7 @@ public:...@@ -832,7 +860,7 @@ public:
832 _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check860 _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check
833 >::value861 >::value
834 , int> = 0>862 , int> = 0>
835 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17863 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
836 explicit tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t)864 explicit tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t)
837 : __base_(allocator_arg_t(), __a, __t)865 : __base_(allocator_arg_t(), __a, __t)
838 { }866 { }
...@@ -861,7 +889,7 @@ public:...@@ -861,7 +889,7 @@ public:
861 is_convertible<_Up, _Tp>... // explicit check889 is_convertible<_Up, _Tp>... // explicit check
862 >::value890 >::value
863 , int> = 0>891 , int> = 0>
864 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11892 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
865 tuple(tuple<_Up...>&& __t)893 tuple(tuple<_Up...>&& __t)
866 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))894 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
867 : __base_(_VSTD::move(__t))895 : __base_(_VSTD::move(__t))
...@@ -873,7 +901,7 @@ public:...@@ -873,7 +901,7 @@ public:
873 _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check901 _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
874 >::value902 >::value
875 , int> = 0>903 , int> = 0>
876 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11904 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
877 explicit tuple(tuple<_Up...>&& __t)905 explicit tuple(tuple<_Up...>&& __t)
878 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))906 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
879 : __base_(_VSTD::move(__t))907 : __base_(_VSTD::move(__t))
...@@ -885,7 +913,7 @@ public:...@@ -885,7 +913,7 @@ public:
885 is_convertible<_Up, _Tp>... // explicit check913 is_convertible<_Up, _Tp>... // explicit check
886 >::value914 >::value
887 , int> = 0>915 , int> = 0>
888 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17916 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
889 tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t)917 tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t)
890 : __base_(allocator_arg_t(), __a, _VSTD::move(__t))918 : __base_(allocator_arg_t(), __a, _VSTD::move(__t))
891 { }919 { }
...@@ -896,7 +924,7 @@ public:...@@ -896,7 +924,7 @@ public:
896 _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check924 _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check
897 >::value925 >::value
898 , int> = 0>926 , int> = 0>
899 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17927 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
900 explicit tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t)928 explicit tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t)
901 : __base_(allocator_arg_t(), __a, _VSTD::move(__t))929 : __base_(allocator_arg_t(), __a, _VSTD::move(__t))
902 { }930 { }
...@@ -920,7 +948,7 @@ public:...@@ -920,7 +948,7 @@ public:
920948
921 // tuple(const pair<U1, U2>&) constructors (including allocator_arg_t variants)949 // 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>
924 struct _CtorPredicateFromPair : false_type{};952 struct _CtorPredicateFromPair : false_type{};
925953
926 template <template <class...> class Pred, class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>954 template <template <class...> class Pred, class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
...@@ -935,7 +963,7 @@ public:...@@ -935,7 +963,7 @@ public:
935 template <class _Pair>963 template <class _Pair>
936 struct _NothrowConstructibleFromPair : _CtorPredicateFromPair<is_nothrow_constructible, _Pair>{};964 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>
939 struct _BothImplicitlyConvertible : false_type{};967 struct _BothImplicitlyConvertible : false_type{};
940968
941 template <class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>969 template <class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2>
...@@ -950,7 +978,7 @@ public:...@@ -950,7 +978,7 @@ public:
950 _BothImplicitlyConvertible<const pair<_Up1, _Up2>&> // explicit check978 _BothImplicitlyConvertible<const pair<_Up1, _Up2>&> // explicit check
951 >::value979 >::value
952 , int> = 0>980 , int> = 0>
953 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11981 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
954 tuple(const pair<_Up1, _Up2>& __p)982 tuple(const pair<_Up1, _Up2>& __p)
955 _NOEXCEPT_((_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value))983 _NOEXCEPT_((_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value))
956 : __base_(__p)984 : __base_(__p)
...@@ -962,7 +990,7 @@ public:...@@ -962,7 +990,7 @@ public:
962 _Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> > // explicit check990 _Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> > // explicit check
963 >::value991 >::value
964 , int> = 0>992 , int> = 0>
965 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11993 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
966 explicit tuple(const pair<_Up1, _Up2>& __p)994 explicit tuple(const pair<_Up1, _Up2>& __p)
967 _NOEXCEPT_((_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value))995 _NOEXCEPT_((_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value))
968 : __base_(__p)996 : __base_(__p)
...@@ -974,7 +1002,7 @@ public:...@@ -974,7 +1002,7 @@ public:
974 _BothImplicitlyConvertible<const pair<_Up1, _Up2>&> // explicit check1002 _BothImplicitlyConvertible<const pair<_Up1, _Up2>&> // explicit check
975 >::value1003 >::value
976 , int> = 0>1004 , int> = 0>
977 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171005 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
978 tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p)1006 tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p)
979 : __base_(allocator_arg_t(), __a, __p)1007 : __base_(allocator_arg_t(), __a, __p)
980 { }1008 { }
...@@ -985,7 +1013,7 @@ public:...@@ -985,7 +1013,7 @@ public:
985 _Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> > // explicit check1013 _Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> > // explicit check
986 >::value1014 >::value
987 , int> = 0>1015 , int> = 0>
988 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171016 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
989 explicit tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p)1017 explicit tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p)
990 : __base_(allocator_arg_t(), __a, __p)1018 : __base_(allocator_arg_t(), __a, __p)
991 { }1019 { }
...@@ -1014,7 +1042,7 @@ public:...@@ -1014,7 +1042,7 @@ public:
1014 _BothImplicitlyConvertible<pair<_Up1, _Up2>&&> // explicit check1042 _BothImplicitlyConvertible<pair<_Up1, _Up2>&&> // explicit check
1015 >::value1043 >::value
1016 , int> = 0>1044 , int> = 0>
1017 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111045 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1018 tuple(pair<_Up1, _Up2>&& __p)1046 tuple(pair<_Up1, _Up2>&& __p)
1019 _NOEXCEPT_((_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value))1047 _NOEXCEPT_((_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value))
1020 : __base_(_VSTD::move(__p))1048 : __base_(_VSTD::move(__p))
...@@ -1026,7 +1054,7 @@ public:...@@ -1026,7 +1054,7 @@ public:
1026 _Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> > // explicit check1054 _Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> > // explicit check
1027 >::value1055 >::value
1028 , int> = 0>1056 , int> = 0>
1029 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111057 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1030 explicit tuple(pair<_Up1, _Up2>&& __p)1058 explicit tuple(pair<_Up1, _Up2>&& __p)
1031 _NOEXCEPT_((_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value))1059 _NOEXCEPT_((_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value))
1032 : __base_(_VSTD::move(__p))1060 : __base_(_VSTD::move(__p))
...@@ -1038,7 +1066,7 @@ public:...@@ -1038,7 +1066,7 @@ public:
1038 _BothImplicitlyConvertible<pair<_Up1, _Up2>&&> // explicit check1066 _BothImplicitlyConvertible<pair<_Up1, _Up2>&&> // explicit check
1039 >::value1067 >::value
1040 , int> = 0>1068 , int> = 0>
1041 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171069 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1042 tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p)1070 tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p)
1043 : __base_(allocator_arg_t(), __a, _VSTD::move(__p))1071 : __base_(allocator_arg_t(), __a, _VSTD::move(__p))
1044 { }1072 { }
...@@ -1049,7 +1077,7 @@ public:...@@ -1049,7 +1077,7 @@ public:
1049 _Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> > // explicit check1077 _Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> > // explicit check
1050 >::value1078 >::value
1051 , int> = 0>1079 , int> = 0>
1052 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171080 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1053 explicit tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p)1081 explicit tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p)
1054 : __base_(allocator_arg_t(), __a, _VSTD::move(__p))1082 : __base_(allocator_arg_t(), __a, _VSTD::move(__p))
1055 { }1083 { }
...@@ -1072,7 +1100,7 @@ public:...@@ -1072,7 +1100,7 @@ public:
1072#endif // _LIBCPP_STD_VER > 201100#endif // _LIBCPP_STD_VER > 20
10731101
1074 // [tuple.assign]1102 // [tuple.assign]
1075 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171103 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1076 tuple& operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple)1104 tuple& operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple)
1077 _NOEXCEPT_((_And<is_nothrow_copy_assignable<_Tp>...>::value))1105 _NOEXCEPT_((_And<is_nothrow_copy_assignable<_Tp>...>::value))
1078 {1106 {
...@@ -1100,7 +1128,7 @@ public:...@@ -1100,7 +1128,7 @@ public:
1100 }1128 }
1101#endif // _LIBCPP_STD_VER > 201129#endif // _LIBCPP_STD_VER > 20
11021130
1103 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171131 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1104 tuple& operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple)1132 tuple& operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple)
1105 _NOEXCEPT_((_And<is_nothrow_move_assignable<_Tp>...>::value))1133 _NOEXCEPT_((_And<is_nothrow_move_assignable<_Tp>...>::value))
1106 {1134 {
...@@ -1116,7 +1144,7 @@ public:...@@ -1116,7 +1144,7 @@ public:
1116 is_assignable<_Tp&, _Up const&>...1144 is_assignable<_Tp&, _Up const&>...
1117 >::value1145 >::value
1118 ,int> = 0>1146 ,int> = 0>
1119 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171147 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1120 tuple& operator=(tuple<_Up...> const& __tuple)1148 tuple& operator=(tuple<_Up...> const& __tuple)
1121 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value))1149 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value))
1122 {1150 {
...@@ -1131,7 +1159,7 @@ public:...@@ -1131,7 +1159,7 @@ public:
1131 is_assignable<_Tp&, _Up>...1159 is_assignable<_Tp&, _Up>...
1132 >::value1160 >::value
1133 ,int> = 0>1161 ,int> = 0>
1134 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171162 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1135 tuple& operator=(tuple<_Up...>&& __tuple)1163 tuple& operator=(tuple<_Up...>&& __tuple)
1136 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up>...>::value))1164 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up>...>::value))
1137 {1165 {
...@@ -1168,7 +1196,7 @@ public:...@@ -1168,7 +1196,7 @@ public:
1168#endif // _LIBCPP_STD_VER > 201196#endif // _LIBCPP_STD_VER > 20
11691197
1170 template <template<class...> class Pred, bool _Const,1198 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>
1172 struct _AssignPredicateFromPair : false_type {};1200 struct _AssignPredicateFromPair : false_type {};
11731201
1174 template <template<class...> class Pred, bool _Const,1202 template <template<class...> class Pred, bool _Const,
...@@ -1209,7 +1237,7 @@ public:...@@ -1209,7 +1237,7 @@ public:
1209 template<class _Up1, class _Up2, __enable_if_t<1237 template<class _Up1, class _Up2, __enable_if_t<
1210 _EnableAssignFromPair<false, pair<_Up1, _Up2> const&>::value1238 _EnableAssignFromPair<false, pair<_Up1, _Up2> const&>::value
1211 ,int> = 0>1239 ,int> = 0>
1212 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171240 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1213 tuple& operator=(pair<_Up1, _Up2> const& __pair)1241 tuple& operator=(pair<_Up1, _Up2> const& __pair)
1214 _NOEXCEPT_((_NothrowAssignFromPair<false, pair<_Up1, _Up2> const&>::value))1242 _NOEXCEPT_((_NothrowAssignFromPair<false, pair<_Up1, _Up2> const&>::value))
1215 {1243 {
...@@ -1221,7 +1249,7 @@ public:...@@ -1221,7 +1249,7 @@ public:
1221 template<class _Up1, class _Up2, __enable_if_t<1249 template<class _Up1, class _Up2, __enable_if_t<
1222 _EnableAssignFromPair<false, pair<_Up1, _Up2>&&>::value1250 _EnableAssignFromPair<false, pair<_Up1, _Up2>&&>::value
1223 ,int> = 0>1251 ,int> = 0>
1224 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171252 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1225 tuple& operator=(pair<_Up1, _Up2>&& __pair)1253 tuple& operator=(pair<_Up1, _Up2>&& __pair)
1226 _NOEXCEPT_((_NothrowAssignFromPair<false, pair<_Up1, _Up2>&&>::value))1254 _NOEXCEPT_((_NothrowAssignFromPair<false, pair<_Up1, _Up2>&&>::value))
1227 {1255 {
...@@ -1237,7 +1265,7 @@ public:...@@ -1237,7 +1265,7 @@ public:
1237 is_assignable<_Tp&, _Up const&>...1265 is_assignable<_Tp&, _Up const&>...
1238 >::value1266 >::value
1239 > >1267 > >
1240 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171268 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1241 tuple& operator=(array<_Up, _Np> const& __array)1269 tuple& operator=(array<_Up, _Np> const& __array)
1242 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value))1270 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value))
1243 {1271 {
...@@ -1253,7 +1281,7 @@ public:...@@ -1253,7 +1281,7 @@ public:
1253 is_assignable<_Tp&, _Up>...1281 is_assignable<_Tp&, _Up>...
1254 >::value1282 >::value
1255 > >1283 > >
1256 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171284 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1257 tuple& operator=(array<_Up, _Np>&& __array)1285 tuple& operator=(array<_Up, _Np>&& __array)
1258 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up>...>::value))1286 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up>...>::value))
1259 {1287 {
...@@ -1264,7 +1292,7 @@ public:...@@ -1264,7 +1292,7 @@ public:
1264 }1292 }
12651293
1266 // [tuple.swap]1294 // [tuple.swap]
1267 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171295 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1268 void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)1296 void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
1269 {__base_.swap(__t.__base_);}1297 {__base_.swap(__t.__base_);}
12701298
...@@ -1283,18 +1311,18 @@ public:...@@ -1283,18 +1311,18 @@ public:
1283 _LIBCPP_INLINE_VISIBILITY constexpr1311 _LIBCPP_INLINE_VISIBILITY constexpr
1284 tuple() _NOEXCEPT = default;1312 tuple() _NOEXCEPT = default;
1285 template <class _Alloc>1313 template <class _Alloc>
1286 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171314 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1287 tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}1315 tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
1288 template <class _Alloc>1316 template <class _Alloc>
1289 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171317 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1290 tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}1318 tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
1291 template <class _Up>1319 template <class _Up>
1292 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171320 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1293 tuple(array<_Up, 0>) _NOEXCEPT {}1321 tuple(array<_Up, 0>) _NOEXCEPT {}
1294 template <class _Alloc, class _Up>1322 template <class _Alloc, class _Up>
1295 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171323 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1296 tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}1324 tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
1297 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171325 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1298 void swap(tuple&) _NOEXCEPT {}1326 void swap(tuple&) _NOEXCEPT {}
1299#if _LIBCPP_STD_VER > 201327#if _LIBCPP_STD_VER > 20
1300 _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple&) const noexcept {}1328 _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple&) const noexcept {}
...@@ -1329,7 +1357,7 @@ tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>;...@@ -1329,7 +1357,7 @@ tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>;
1329#endif1357#endif
13301358
1331template <class ..._Tp>1359template <class ..._Tp>
1332inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171360inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1333__enable_if_t<__all<__is_swappable<_Tp>::value...>::value, void>1361__enable_if_t<__all<__is_swappable<_Tp>::value...>::value, void>
1334swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)1362swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
1335 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)1363 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
...@@ -1348,7 +1376,7 @@ swap(const tuple<_Tp...>& __lhs, const tuple<_Tp...>& __rhs)...@@ -1348,7 +1376,7 @@ swap(const tuple<_Tp...>& __lhs, const tuple<_Tp...>& __rhs)
1348// get1376// get
13491377
1350template <size_t _Ip, class ..._Tp>1378template <size_t _Ip, class ..._Tp>
1351inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111379inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1352typename tuple_element<_Ip, tuple<_Tp...> >::type&1380typename tuple_element<_Ip, tuple<_Tp...> >::type&
1353get(tuple<_Tp...>& __t) _NOEXCEPT1381get(tuple<_Tp...>& __t) _NOEXCEPT
1354{1382{
...@@ -1357,7 +1385,7 @@ get(tuple<_Tp...>& __t) _NOEXCEPT...@@ -1357,7 +1385,7 @@ get(tuple<_Tp...>& __t) _NOEXCEPT
1357}1385}
13581386
1359template <size_t _Ip, class ..._Tp>1387template <size_t _Ip, class ..._Tp>
1360inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111388inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1361const typename tuple_element<_Ip, tuple<_Tp...> >::type&1389const typename tuple_element<_Ip, tuple<_Tp...> >::type&
1362get(const tuple<_Tp...>& __t) _NOEXCEPT1390get(const tuple<_Tp...>& __t) _NOEXCEPT
1363{1391{
...@@ -1366,7 +1394,7 @@ get(const tuple<_Tp...>& __t) _NOEXCEPT...@@ -1366,7 +1394,7 @@ get(const tuple<_Tp...>& __t) _NOEXCEPT
1366}1394}
13671395
1368template <size_t _Ip, class ..._Tp>1396template <size_t _Ip, class ..._Tp>
1369inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111397inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1370typename tuple_element<_Ip, tuple<_Tp...> >::type&&1398typename tuple_element<_Ip, tuple<_Tp...> >::type&&
1371get(tuple<_Tp...>&& __t) _NOEXCEPT1399get(tuple<_Tp...>&& __t) _NOEXCEPT
1372{1400{
...@@ -1376,7 +1404,7 @@ get(tuple<_Tp...>&& __t) _NOEXCEPT...@@ -1376,7 +1404,7 @@ get(tuple<_Tp...>&& __t) _NOEXCEPT
1376}1404}
13771405
1378template <size_t _Ip, class ..._Tp>1406template <size_t _Ip, class ..._Tp>
1379inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111407inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1380const typename tuple_element<_Ip, tuple<_Tp...> >::type&&1408const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
1381get(const tuple<_Tp...>&& __t) _NOEXCEPT1409get(const tuple<_Tp...>&& __t) _NOEXCEPT
1382{1410{
...@@ -1402,7 +1430,7 @@ template <size_t _Nx>...@@ -1402,7 +1430,7 @@ template <size_t _Nx>
1402inline _LIBCPP_INLINE_VISIBILITY1430inline _LIBCPP_INLINE_VISIBILITY
1403constexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) {1431constexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) {
1404 return __i == _Nx ? __not_found :1432 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]);
1406}1434}
14071435
1408template <class _T1, class ..._Args>1436template <class _T1, class ..._Args>
...@@ -1458,7 +1486,7 @@ constexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept...@@ -1458,7 +1486,7 @@ constexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept
1458// tie1486// tie
14591487
1460template <class ..._Tp>1488template <class ..._Tp>
1461inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111489inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1462tuple<_Tp&...>1490tuple<_Tp&...>
1463tie(_Tp&... __t) _NOEXCEPT1491tie(_Tp&... __t) _NOEXCEPT
1464{1492{
...@@ -1469,7 +1497,7 @@ template <class _Up>...@@ -1469,7 +1497,7 @@ template <class _Up>
1469struct __ignore_t1497struct __ignore_t
1470{1498{
1471 template <class _Tp>1499 template <class _Tp>
1472 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111500 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1473 const __ignore_t& operator=(_Tp&&) const {return *this;}1501 const __ignore_t& operator=(_Tp&&) const {return *this;}
1474};1502};
14751503
...@@ -1478,7 +1506,7 @@ namespace {...@@ -1478,7 +1506,7 @@ namespace {
1478} // namespace1506} // namespace
14791507
1480template <class... _Tp>1508template <class... _Tp>
1481inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111509inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1482tuple<typename __unwrap_ref_decay<_Tp>::type...>1510tuple<typename __unwrap_ref_decay<_Tp>::type...>
1483make_tuple(_Tp&&... __t)1511make_tuple(_Tp&&... __t)
1484{1512{
...@@ -1486,7 +1514,7 @@ make_tuple(_Tp&&... __t)...@@ -1486,7 +1514,7 @@ make_tuple(_Tp&&... __t)
1486}1514}
14871515
1488template <class... _Tp>1516template <class... _Tp>
1489inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111517inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1490tuple<_Tp&&...>1518tuple<_Tp&&...>
1491forward_as_tuple(_Tp&&... __t) _NOEXCEPT1519forward_as_tuple(_Tp&&... __t) _NOEXCEPT
1492{1520{
...@@ -1497,7 +1525,7 @@ template <size_t _Ip>...@@ -1497,7 +1525,7 @@ template <size_t _Ip>
1497struct __tuple_equal1525struct __tuple_equal
1498{1526{
1499 template <class _Tp, class _Up>1527 template <class _Tp, class _Up>
1500 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111528 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1501 bool operator()(const _Tp& __x, const _Up& __y)1529 bool operator()(const _Tp& __x, const _Up& __y)
1502 {1530 {
1503 return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y);1531 return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y);
...@@ -1508,7 +1536,7 @@ template <>...@@ -1508,7 +1536,7 @@ template <>
1508struct __tuple_equal<0>1536struct __tuple_equal<0>
1509{1537{
1510 template <class _Tp, class _Up>1538 template <class _Tp, class _Up>
1511 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111539 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1512 bool operator()(const _Tp&, const _Up&)1540 bool operator()(const _Tp&, const _Up&)
1513 {1541 {
1514 return true;1542 return true;
...@@ -1516,7 +1544,7 @@ struct __tuple_equal<0>...@@ -1516,7 +1544,7 @@ struct __tuple_equal<0>
1516};1544};
15171545
1518template <class ..._Tp, class ..._Up>1546template <class ..._Tp, class ..._Up>
1519inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111547inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1520bool1548bool
1521operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)1549operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1522{1550{
...@@ -1549,7 +1577,7 @@ operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)...@@ -1549,7 +1577,7 @@ operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1549#else // _LIBCPP_STD_VER > 171577#else // _LIBCPP_STD_VER > 17
15501578
1551template <class ..._Tp, class ..._Up>1579template <class ..._Tp, class ..._Up>
1552inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111580inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1553bool1581bool
1554operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)1582operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1555{1583{
...@@ -1560,7 +1588,7 @@ template <size_t _Ip>...@@ -1560,7 +1588,7 @@ template <size_t _Ip>
1560struct __tuple_less1588struct __tuple_less
1561{1589{
1562 template <class _Tp, class _Up>1590 template <class _Tp, class _Up>
1563 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111591 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1564 bool operator()(const _Tp& __x, const _Up& __y)1592 bool operator()(const _Tp& __x, const _Up& __y)
1565 {1593 {
1566 const size_t __idx = tuple_size<_Tp>::value - _Ip;1594 const size_t __idx = tuple_size<_Tp>::value - _Ip;
...@@ -1576,7 +1604,7 @@ template <>...@@ -1576,7 +1604,7 @@ template <>
1576struct __tuple_less<0>1604struct __tuple_less<0>
1577{1605{
1578 template <class _Tp, class _Up>1606 template <class _Tp, class _Up>
1579 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111607 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1580 bool operator()(const _Tp&, const _Up&)1608 bool operator()(const _Tp&, const _Up&)
1581 {1609 {
1582 return false;1610 return false;
...@@ -1584,7 +1612,7 @@ struct __tuple_less<0>...@@ -1584,7 +1612,7 @@ struct __tuple_less<0>
1584};1612};
15851613
1586template <class ..._Tp, class ..._Up>1614template <class ..._Tp, class ..._Up>
1587inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111615inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1588bool1616bool
1589operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)1617operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1590{1618{
...@@ -1593,7 +1621,7 @@ operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)...@@ -1593,7 +1621,7 @@ operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1593}1621}
15941622
1595template <class ..._Tp, class ..._Up>1623template <class ..._Tp, class ..._Up>
1596inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111624inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1597bool1625bool
1598operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)1626operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1599{1627{
...@@ -1601,7 +1629,7 @@ operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)...@@ -1601,7 +1629,7 @@ operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1601}1629}
16021630
1603template <class ..._Tp, class ..._Up>1631template <class ..._Tp, class ..._Up>
1604inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111632inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1605bool1633bool
1606operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)1634operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1607{1635{
...@@ -1609,7 +1637,7 @@ operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)...@@ -1609,7 +1637,7 @@ operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1609}1637}
16101638
1611template <class ..._Tp, class ..._Up>1639template <class ..._Tp, class ..._Up>
1612inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111640inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1613bool1641bool
1614operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)1642operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
1615{1643{
...@@ -1638,7 +1666,7 @@ struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>...@@ -1638,7 +1666,7 @@ struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
1638{1666{
1639 using type _LIBCPP_NODEBUG = typename __tuple_cat_type<1667 using type _LIBCPP_NODEBUG = typename __tuple_cat_type<
1640 tuple<_Types...>,1668 tuple<_Types...>,
1641 typename __make_tuple_types<__uncvref_t<_Tuple0> >::type1669 typename __make_tuple_types<__remove_cvref_t<_Tuple0> >::type
1642 >::type;1670 >::type;
1643};1671};
16441672
...@@ -1647,9 +1675,9 @@ struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples......@@ -1647,9 +1675,9 @@ struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...
1647 : public __tuple_cat_return_1<1675 : public __tuple_cat_return_1<
1648 typename __tuple_cat_type<1676 typename __tuple_cat_type<
1649 tuple<_Types...>,1677 tuple<_Types...>,
1650 typename __make_tuple_types<__uncvref_t<_Tuple0> >::type1678 typename __make_tuple_types<__remove_cvref_t<_Tuple0> >::type
1651 >::type,1679 >::type,
1652 __tuple_like<typename remove_reference<_Tuple1>::type>::value,1680 __tuple_like_ext<__libcpp_remove_reference_t<_Tuple1> >::value,
1653 _Tuple1, _Tuples...>1681 _Tuple1, _Tuples...>
1654{1682{
1655};1683};
...@@ -1659,7 +1687,7 @@ template <class ..._Tuples> struct __tuple_cat_return;...@@ -1659,7 +1687,7 @@ template <class ..._Tuples> struct __tuple_cat_return;
1659template <class _Tuple0, class ..._Tuples>1687template <class _Tuple0, class ..._Tuples>
1660struct __tuple_cat_return<_Tuple0, _Tuples...>1688struct __tuple_cat_return<_Tuple0, _Tuples...>
1661 : public __tuple_cat_return_1<tuple<>,1689 : 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,
1663 _Tuples...>1691 _Tuples...>
1664{1692{
1665};1693};
...@@ -1670,7 +1698,7 @@ struct __tuple_cat_return<>...@@ -1670,7 +1698,7 @@ struct __tuple_cat_return<>
1670 typedef _LIBCPP_NODEBUG tuple<> type;1698 typedef _LIBCPP_NODEBUG tuple<> type;
1671};1699};
16721700
1673inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111701inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1674tuple<>1702tuple<>
1675tuple_cat()1703tuple_cat()
1676{1704{
...@@ -1683,7 +1711,7 @@ struct __tuple_cat_return_ref_imp;...@@ -1683,7 +1711,7 @@ struct __tuple_cat_return_ref_imp;
1683template <class ..._Types, size_t ..._I0, class _Tuple0>1711template <class ..._Types, size_t ..._I0, class _Tuple0>
1684struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>1712struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
1685{1713{
1686 typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0;1714 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0;
1687 typedef tuple<_Types..., typename __apply_cv<_Tuple0,1715 typedef tuple<_Types..., typename __apply_cv<_Tuple0,
1688 typename tuple_element<_I0, _T0>::type>::type&&...> type;1716 typename tuple_element<_I0, _T0>::type>::type&&...> type;
1689};1717};
...@@ -1694,9 +1722,8 @@ struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,...@@ -1694,9 +1722,8 @@ struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
1694 : public __tuple_cat_return_ref_imp<1722 : public __tuple_cat_return_ref_imp<
1695 tuple<_Types..., typename __apply_cv<_Tuple0,1723 tuple<_Types..., typename __apply_cv<_Tuple0,
1696 typename tuple_element<_I0,1724 typename tuple_element<_I0,
1697 typename remove_reference<_Tuple0>::type>::type>::type&&...>,1725 __libcpp_remove_reference_t<_Tuple0> >::type>::type&&...>,
1698 typename __make_tuple_indices<tuple_size<typename1726 typename __make_tuple_indices<tuple_size<__libcpp_remove_reference_t<_Tuple1> >::value>::type,
1699 remove_reference<_Tuple1>::type>::value>::type,
1700 _Tuple1, _Tuples...>1727 _Tuple1, _Tuples...>
1701{1728{
1702};1729};
...@@ -1705,7 +1732,7 @@ template <class _Tuple0, class ..._Tuples>...@@ -1705,7 +1732,7 @@ template <class _Tuple0, class ..._Tuples>
1705struct __tuple_cat_return_ref1732struct __tuple_cat_return_ref
1706 : public __tuple_cat_return_ref_imp<tuple<>,1733 : public __tuple_cat_return_ref_imp<tuple<>,
1707 typename __make_tuple_indices<1734 typename __make_tuple_indices<
1708 tuple_size<typename remove_reference<_Tuple0>::type>::value1735 tuple_size<__libcpp_remove_reference_t<_Tuple0> >::value
1709 >::type, _Tuple0, _Tuples...>1736 >::type, _Tuple0, _Tuples...>
1710{1737{
1711};1738};
...@@ -1717,7 +1744,7 @@ template <class ..._Types, size_t ..._I0, size_t ..._J0>...@@ -1717,7 +1744,7 @@ template <class ..._Types, size_t ..._I0, size_t ..._J0>
1717struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >1744struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
1718{1745{
1719 template <class _Tuple0>1746 template <class _Tuple0>
1720 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111747 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1721 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type1748 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
1722 operator()(tuple<_Types...> __t, _Tuple0&& __t0)1749 operator()(tuple<_Types...> __t, _Tuple0&& __t0)
1723 {1750 {
...@@ -1728,13 +1755,13 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J...@@ -1728,13 +1755,13 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
1728 }1755 }
17291756
1730 template <class _Tuple0, class _Tuple1, class ..._Tuples>1757 template <class _Tuple0, class _Tuple1, class ..._Tuples>
1731 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111758 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1732 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type1759 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
1733 operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)1760 operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
1734 {1761 {
1735 (void)__t; // avoid unused parameter warning on GCC when _I0 is empty1762 (void)__t; // avoid unused parameter warning on GCC when _I0 is empty
1736 typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0;1763 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0;
1737 typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple1>::type _T1;1764 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple1> _T1;
1738 return __tuple_cat<1765 return __tuple_cat<
1739 tuple<_Types...,1766 tuple<_Types...,
1740 typename __apply_cv<_Tuple0, typename tuple_element<1767 typename __apply_cv<_Tuple0, typename tuple_element<
...@@ -1750,11 +1777,11 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J...@@ -1750,11 +1777,11 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
1750};1777};
17511778
1752template <class _Tuple0, class... _Tuples>1779template <class _Tuple0, class... _Tuples>
1753inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX111780inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
1754typename __tuple_cat_return<_Tuple0, _Tuples...>::type1781typename __tuple_cat_return<_Tuple0, _Tuples...>::type
1755tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)1782tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
1756{1783{
1757 typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0;1784 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0;
1758 return __tuple_cat<tuple<>, __tuple_indices<>,1785 return __tuple_cat<tuple<>, __tuple_indices<>,
1759 typename __make_tuple_indices<tuple_size<_T0>::value>::type>()1786 typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
1760 (tuple<>(), _VSTD::forward<_Tuple0>(__t0),1787 (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
...@@ -1767,7 +1794,7 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc>...@@ -1767,7 +1794,7 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc>
17671794
1768template <class _T1, class _T2>1795template <class _T1, class _T2>
1769template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>1796template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
1770inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX171797inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
1771pair<_T1, _T2>::pair(piecewise_construct_t,1798pair<_T1, _T2>::pair(piecewise_construct_t,
1772 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,1799 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
1773 __tuple_indices<_I1...>, __tuple_indices<_I2...>)1800 __tuple_indices<_I1...>, __tuple_indices<_I2...>)
...@@ -1824,4 +1851,13 @@ _LIBCPP_NOEXCEPT_RETURN(...@@ -1824,4 +1851,13 @@ _LIBCPP_NOEXCEPT_RETURN(
18241851
1825_LIBCPP_END_NAMESPACE_STD1852_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
1827#endif // _LIBCPP_TUPLE1863#endif // _LIBCPP_TUPLE
lib/libcxx/include/type_traits+13-278
...@@ -158,8 +158,8 @@ namespace std...@@ -158,8 +158,8 @@ namespace std
158 // Alignment properties and transformations:158 // Alignment properties and transformations:
159 template <class T> struct alignment_of;159 template <class T> struct alignment_of;
160 template <size_t Len, size_t Align = most_stringent_alignment_requirement>160 template <size_t Len, size_t Align = most_stringent_alignment_requirement>
161 struct aligned_storage;161 struct aligned_storage; // deprecated in C++23
162 template <size_t Len, class... Types> struct aligned_union;162 template <size_t Len, class... Types> struct aligned_union; // deprecated in C++23
163 template <class T> struct remove_cvref; // C++20163 template <class T> struct remove_cvref; // C++20
164164
165 template <class T> struct decay;165 template <class T> struct decay;
...@@ -419,6 +419,7 @@ namespace std...@@ -419,6 +419,7 @@ namespace std
419#include <__assert> // all public C++ headers provide the assertion handler419#include <__assert> // all public C++ headers provide the assertion handler
420#include <__config>420#include <__config>
421#include <__functional/invoke.h>421#include <__functional/invoke.h>
422#include <__fwd/hash.h> // This is https://llvm.org/PR56938
422#include <__type_traits/add_const.h>423#include <__type_traits/add_const.h>
423#include <__type_traits/add_cv.h>424#include <__type_traits/add_cv.h>
424#include <__type_traits/add_lvalue_reference.h>425#include <__type_traits/add_lvalue_reference.h>
...@@ -429,11 +430,13 @@ namespace std...@@ -429,11 +430,13 @@ namespace std
429#include <__type_traits/aligned_union.h>430#include <__type_traits/aligned_union.h>
430#include <__type_traits/alignment_of.h>431#include <__type_traits/alignment_of.h>
431#include <__type_traits/apply_cv.h>432#include <__type_traits/apply_cv.h>
433#include <__type_traits/can_extract_key.h>
432#include <__type_traits/common_reference.h>434#include <__type_traits/common_reference.h>
433#include <__type_traits/common_type.h>435#include <__type_traits/common_type.h>
434#include <__type_traits/conditional.h>436#include <__type_traits/conditional.h>
435#include <__type_traits/conjunction.h>437#include <__type_traits/conjunction.h>
436#include <__type_traits/decay.h>438#include <__type_traits/decay.h>
439#include <__type_traits/dependent_type.h>
437#include <__type_traits/disjunction.h>440#include <__type_traits/disjunction.h>
438#include <__type_traits/enable_if.h>441#include <__type_traits/enable_if.h>
439#include <__type_traits/extent.h>442#include <__type_traits/extent.h>
...@@ -448,6 +451,7 @@ namespace std...@@ -448,6 +451,7 @@ namespace std
448#include <__type_traits/is_base_of.h>451#include <__type_traits/is_base_of.h>
449#include <__type_traits/is_bounded_array.h>452#include <__type_traits/is_bounded_array.h>
450#include <__type_traits/is_callable.h>453#include <__type_traits/is_callable.h>
454#include <__type_traits/is_char_like_type.h>
451#include <__type_traits/is_class.h>455#include <__type_traits/is_class.h>
452#include <__type_traits/is_compound.h>456#include <__type_traits/is_compound.h>
453#include <__type_traits/is_const.h>457#include <__type_traits/is_const.h>
...@@ -464,6 +468,7 @@ namespace std...@@ -464,6 +468,7 @@ namespace std
464#include <__type_traits/is_floating_point.h>468#include <__type_traits/is_floating_point.h>
465#include <__type_traits/is_function.h>469#include <__type_traits/is_function.h>
466#include <__type_traits/is_fundamental.h>470#include <__type_traits/is_fundamental.h>
471#include <__type_traits/is_implicitly_default_constructible.h>
467#include <__type_traits/is_integral.h>472#include <__type_traits/is_integral.h>
468#include <__type_traits/is_literal_type.h>473#include <__type_traits/is_literal_type.h>
469#include <__type_traits/is_member_function_pointer.h>474#include <__type_traits/is_member_function_pointer.h>
...@@ -492,7 +497,9 @@ namespace std...@@ -492,7 +497,9 @@ namespace std
492#include <__type_traits/is_scalar.h>497#include <__type_traits/is_scalar.h>
493#include <__type_traits/is_scoped_enum.h>498#include <__type_traits/is_scoped_enum.h>
494#include <__type_traits/is_signed.h>499#include <__type_traits/is_signed.h>
500#include <__type_traits/is_specialization.h>
495#include <__type_traits/is_standard_layout.h>501#include <__type_traits/is_standard_layout.h>
502#include <__type_traits/is_swappable.h>
496#include <__type_traits/is_trivial.h>503#include <__type_traits/is_trivial.h>
497#include <__type_traits/is_trivially_assignable.h>504#include <__type_traits/is_trivially_assignable.h>
498#include <__type_traits/is_trivially_constructible.h>505#include <__type_traits/is_trivially_constructible.h>
...@@ -508,17 +515,21 @@ namespace std...@@ -508,17 +515,21 @@ namespace std
508#include <__type_traits/is_unsigned.h>515#include <__type_traits/is_unsigned.h>
509#include <__type_traits/is_void.h>516#include <__type_traits/is_void.h>
510#include <__type_traits/is_volatile.h>517#include <__type_traits/is_volatile.h>
518#include <__type_traits/make_const_lvalue_ref.h>
511#include <__type_traits/make_signed.h>519#include <__type_traits/make_signed.h>
512#include <__type_traits/make_unsigned.h>520#include <__type_traits/make_unsigned.h>
521#include <__type_traits/maybe_const.h>
513#include <__type_traits/negation.h>522#include <__type_traits/negation.h>
514#include <__type_traits/rank.h>523#include <__type_traits/rank.h>
515#include <__type_traits/remove_all_extents.h>524#include <__type_traits/remove_all_extents.h>
516#include <__type_traits/remove_const.h>525#include <__type_traits/remove_const.h>
526#include <__type_traits/remove_const_ref.h>
517#include <__type_traits/remove_cv.h>527#include <__type_traits/remove_cv.h>
518#include <__type_traits/remove_extent.h>528#include <__type_traits/remove_extent.h>
519#include <__type_traits/remove_pointer.h>529#include <__type_traits/remove_pointer.h>
520#include <__type_traits/remove_reference.h>530#include <__type_traits/remove_reference.h>
521#include <__type_traits/remove_volatile.h>531#include <__type_traits/remove_volatile.h>
532#include <__type_traits/result_of.h>
522#include <__type_traits/type_identity.h>533#include <__type_traits/type_identity.h>
523#include <__type_traits/underlying_type.h>534#include <__type_traits/underlying_type.h>
524#include <__type_traits/void_t.h>535#include <__type_traits/void_t.h>
...@@ -531,280 +542,4 @@ namespace std...@@ -531,280 +542,4 @@ namespace std
531# pragma GCC system_header542# pragma GCC system_header
532#endif543#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
810#endif // _LIBCPP_TYPE_TRAITS545#endif // _LIBCPP_TYPE_TRAITS
lib/libcxx/include/typeindex+20-7
...@@ -23,11 +23,12 @@ public:...@@ -23,11 +23,12 @@ public:
23 type_index(const type_info& rhs) noexcept;23 type_index(const type_info& rhs) noexcept;
2424
25 bool operator==(const type_index& rhs) const noexcept;25 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
27 bool operator< (const type_index& rhs) const noexcept;27 bool operator< (const type_index& rhs) const noexcept;
28 bool operator<=(const type_index& rhs) const noexcept;28 bool operator<=(const type_index& rhs) const noexcept;
29 bool operator> (const type_index& rhs) const noexcept;29 bool operator> (const type_index& rhs) const noexcept;
30 bool operator>=(const type_index& rhs) const noexcept;30 bool operator>=(const type_index& rhs) const noexcept;
31 strong_ordering operator<=>(const type_index& rhs) const noexcept; // C++20
3132
32 size_t hash_code() const noexcept;33 size_t hash_code() const noexcept;
33 const char* name() const noexcept;34 const char* name() const noexcept;
...@@ -50,12 +51,6 @@ struct hash<type_index>...@@ -50,12 +51,6 @@ struct hash<type_index>
50#include <typeinfo>51#include <typeinfo>
51#include <version>52#include <version>
5253
53#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
54# include <iosfwd>
55# include <new>
56# include <utility>
57#endif
58
59// standard-mandated includes54// standard-mandated includes
60#include <compare>55#include <compare>
6156
...@@ -76,8 +71,10 @@ public:...@@ -76,8 +71,10 @@ public:
76 bool operator==(const type_index& __y) const _NOEXCEPT71 bool operator==(const type_index& __y) const _NOEXCEPT
77 {return *__t_ == *__y.__t_;}72 {return *__t_ == *__y.__t_;}
78 _LIBCPP_INLINE_VISIBILITY73 _LIBCPP_INLINE_VISIBILITY
74#if _LIBCPP_STD_VER <= 17
79 bool operator!=(const type_index& __y) const _NOEXCEPT75 bool operator!=(const type_index& __y) const _NOEXCEPT
80 {return *__t_ != *__y.__t_;}76 {return *__t_ != *__y.__t_;}
77#endif
81 _LIBCPP_INLINE_VISIBILITY78 _LIBCPP_INLINE_VISIBILITY
82 bool operator< (const type_index& __y) const _NOEXCEPT79 bool operator< (const type_index& __y) const _NOEXCEPT
83 {return __t_->before(*__y.__t_);}80 {return __t_->before(*__y.__t_);}
...@@ -90,6 +87,16 @@ public:...@@ -90,6 +87,16 @@ public:
90 _LIBCPP_INLINE_VISIBILITY87 _LIBCPP_INLINE_VISIBILITY
91 bool operator>=(const type_index& __y) const _NOEXCEPT88 bool operator>=(const type_index& __y) const _NOEXCEPT
92 {return !__t_->before(*__y.__t_);}89 {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
94 _LIBCPP_INLINE_VISIBILITY101 _LIBCPP_INLINE_VISIBILITY
95 size_t hash_code() const _NOEXCEPT {return __t_->hash_code();}102 size_t hash_code() const _NOEXCEPT {return __t_->hash_code();}
...@@ -110,4 +117,10 @@ struct _LIBCPP_TEMPLATE_VIS hash<type_index>...@@ -110,4 +117,10 @@ struct _LIBCPP_TEMPLATE_VIS hash<type_index>
110117
111_LIBCPP_END_NAMESPACE_STD118_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
113#endif // _LIBCPP_TYPEINDEX126#endif // _LIBCPP_TYPEINDEX
lib/libcxx/include/typeinfo+36-11
...@@ -22,7 +22,7 @@ public:...@@ -22,7 +22,7 @@ public:
22 virtual ~type_info();22 virtual ~type_info();
2323
24 bool operator==(const type_info& rhs) const noexcept;24 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
27 bool before(const type_info& rhs) const noexcept;27 bool before(const type_info& rhs) const noexcept;
28 size_t hash_code() const noexcept;28 size_t hash_code() const noexcept;
...@@ -61,13 +61,10 @@ public:...@@ -61,13 +61,10 @@ public:
61#include <__config>61#include <__config>
62#include <cstddef>62#include <cstddef>
63#include <cstdint>63#include <cstdint>
64#include <cstdlib>
64#include <exception>65#include <exception>
65#include <type_traits>66#include <type_traits>
6667
67#ifdef _LIBCPP_NO_EXCEPTIONS
68#include <cstdlib>
69#endif
70
71#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)68#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
72# pragma GCC system_header69# pragma GCC system_header
73#endif70#endif
...@@ -112,9 +109,11 @@ public:...@@ -112,9 +109,11 @@ public:
112 return __compare(__arg) == 0;109 return __compare(__arg) == 0;
113 }110 }
114111
112#if _LIBCPP_STD_VER <= 17
115 _LIBCPP_INLINE_VISIBILITY113 _LIBCPP_INLINE_VISIBILITY
116 bool operator!=(const type_info& __arg) const _NOEXCEPT114 bool operator!=(const type_info& __arg) const _NOEXCEPT
117 { return !operator==(__arg); }115 { return !operator==(__arg); }
116#endif
118};117};
119118
120#else // !defined(_LIBCPP_ABI_MICROSOFT)119#else // !defined(_LIBCPP_ABI_MICROSOFT)
...@@ -174,8 +173,8 @@ public:...@@ -174,8 +173,8 @@ public:
174// we pick a default implementation based on the platform here.173// we pick a default implementation based on the platform here.
175#ifndef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION174#ifndef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION
176175
177 // Windows binaries can't merge typeinfos, so use the NonUnique implementation.176 // Windows and AIX binaries can't merge typeinfos, so use the NonUnique implementation.
178# ifdef _LIBCPP_OBJECT_FORMAT_COFF177# if defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)
179# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 2178# define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 2
180179
181 // On arm64 on Apple platforms, use the special NonUniqueARMRTTIBit implementation.180 // On arm64 on Apple platforms, use the special NonUniqueARMRTTIBit implementation.
...@@ -337,9 +336,11 @@ public:...@@ -337,9 +336,11 @@ public:
337 return __impl::__eq(__type_name, __arg.__type_name);336 return __impl::__eq(__type_name, __arg.__type_name);
338 }337 }
339338
339#if _LIBCPP_STD_VER <= 17
340 _LIBCPP_INLINE_VISIBILITY340 _LIBCPP_INLINE_VISIBILITY
341 bool operator!=(const type_info& __arg) const _NOEXCEPT341 bool operator!=(const type_info& __arg) const _NOEXCEPT
342 { return !operator==(__arg); }342 { return !operator==(__arg); }
343#endif
343};344};
344#endif // defined(_LIBCPP_ABI_MICROSOFT)345#endif // defined(_LIBCPP_ABI_MICROSOFT)
345346
...@@ -349,8 +350,8 @@ class _LIBCPP_EXCEPTION_ABI bad_cast...@@ -349,8 +350,8 @@ class _LIBCPP_EXCEPTION_ABI bad_cast
349 public:350 public:
350 bad_cast() _NOEXCEPT;351 bad_cast() _NOEXCEPT;
351 bad_cast(const bad_cast&) _NOEXCEPT = default;352 bad_cast(const bad_cast&) _NOEXCEPT = default;
352 virtual ~bad_cast() _NOEXCEPT;353 ~bad_cast() _NOEXCEPT override;
353 virtual const char* what() const _NOEXCEPT;354 const char* what() const _NOEXCEPT override;
354};355};
355356
356class _LIBCPP_EXCEPTION_ABI bad_typeid357class _LIBCPP_EXCEPTION_ABI bad_typeid
...@@ -358,14 +359,38 @@ class _LIBCPP_EXCEPTION_ABI bad_typeid...@@ -358,14 +359,38 @@ class _LIBCPP_EXCEPTION_ABI bad_typeid
358{359{
359 public:360 public:
360 bad_typeid() _NOEXCEPT;361 bad_typeid() _NOEXCEPT;
361 virtual ~bad_typeid() _NOEXCEPT;362 ~bad_typeid() _NOEXCEPT override;
362 virtual const char* what() const _NOEXCEPT;363 const char* what() const _NOEXCEPT override;
363};364};
364365
365} // namespace std366} // namespace std
366367
367#endif // defined(_LIBCPP_ABI_VCRUNTIME)368#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
369_LIBCPP_BEGIN_NAMESPACE_STD394_LIBCPP_BEGIN_NAMESPACE_STD
370_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY395_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
371void __throw_bad_cast()396void __throw_bad_cast()
lib/libcxx/include/uchar.h+2
...@@ -23,6 +23,8 @@ Types:...@@ -23,6 +23,8 @@ Types:
23 mbstate_t23 mbstate_t
24 size_t24 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
26size_t mbrtoc16(char16_t* pc16, const char* s, size_t n, mbstate_t* ps);28size_t mbrtoc16(char16_t* pc16, const char* s, size_t n, mbstate_t* ps);
27size_t c16rtomb(char* s, char16_t c16, mbstate_t* ps);29size_t c16rtomb(char* s, char16_t c16, mbstate_t* ps);
28size_t mbrtoc32(char32_t* pc32, const char* s, size_t n, mbstate_t* ps);30size_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>...@@ -525,18 +525,15 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
525#include <__iterator/erase_if_container.h>525#include <__iterator/erase_if_container.h>
526#include <__iterator/iterator_traits.h>526#include <__iterator/iterator_traits.h>
527#include <__memory/addressof.h>527#include <__memory/addressof.h>
528#include <__memory/allocator.h>
529#include <__memory_resource/polymorphic_allocator.h>
528#include <__node_handle>530#include <__node_handle>
531#include <__type_traits/is_allocator.h>
529#include <__utility/forward.h>532#include <__utility/forward.h>
530#include <stdexcept>533#include <stdexcept>
531#include <tuple>534#include <tuple>
532#include <version>535#include <version>
533536
534#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
535# include <algorithm>
536# include <bit>
537# include <iterator>
538#endif
539
540// standard-mandated includes537// standard-mandated includes
541538
542// [iterator.range]539// [iterator.range]
...@@ -822,16 +819,16 @@ struct _LIBCPP_STANDALONE_DEBUG __hash_value_type...@@ -822,16 +819,16 @@ struct _LIBCPP_STANDALONE_DEBUG __hash_value_type
822 typedef pair<key_type&&, mapped_type&&> __nc_rref_pair_type;819 typedef pair<key_type&&, mapped_type&&> __nc_rref_pair_type;
823820
824private:821private:
825 value_type __cc;822 value_type __cc_;
826823
827public:824public:
828 _LIBCPP_INLINE_VISIBILITY825 _LIBCPP_INLINE_VISIBILITY
829 value_type& __get_value()826 value_type& __get_value()
830 {827 {
831#if _LIBCPP_STD_VER > 14828#if _LIBCPP_STD_VER > 14
832 return *_VSTD::launder(_VSTD::addressof(__cc));829 return *_VSTD::launder(_VSTD::addressof(__cc_));
833#else830#else
834 return __cc;831 return __cc_;
835#endif832#endif
836 }833 }
837834
...@@ -839,9 +836,9 @@ public:...@@ -839,9 +836,9 @@ public:
839 const value_type& __get_value() const836 const value_type& __get_value() const
840 {837 {
841#if _LIBCPP_STD_VER > 14838#if _LIBCPP_STD_VER > 14
842 return *_VSTD::launder(_VSTD::addressof(__cc));839 return *_VSTD::launder(_VSTD::addressof(__cc_));
843#else840#else
844 return __cc;841 return __cc_;
845#endif842#endif
846 }843 }
847844
...@@ -904,13 +901,13 @@ struct __hash_value_type...@@ -904,13 +901,13 @@ struct __hash_value_type
904 typedef pair<const key_type, mapped_type> value_type;901 typedef pair<const key_type, mapped_type> value_type;
905902
906private:903private:
907 value_type __cc;904 value_type __cc_;
908905
909public:906public:
910 _LIBCPP_INLINE_VISIBILITY907 _LIBCPP_INLINE_VISIBILITY
911 value_type& __get_value() { return __cc; }908 value_type& __get_value() { return __cc_; }
912 _LIBCPP_INLINE_VISIBILITY909 _LIBCPP_INLINE_VISIBILITY
913 const value_type& __get_value() const { return __cc; }910 const value_type& __get_value() const { return __cc_; }
914911
915private:912private:
916 ~__hash_value_type();913 ~__hash_value_type();
...@@ -1044,8 +1041,7 @@ private:...@@ -1044,8 +1041,7 @@ private:
1044 typedef __hash_value_type<key_type, mapped_type> __value_type;1041 typedef __hash_value_type<key_type, mapped_type> __value_type;
1045 typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;1042 typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;
1046 typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal;1043 typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal;
1047 typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,1044 typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type;
1048 __value_type>::type __allocator_type;
10491045
1050 typedef __hash_table<__value_type, __hasher,1046 typedef __hash_table<__value_type, __hasher,
1051 __key_equal, __allocator_type> __table;1047 __key_equal, __allocator_type> __table;
...@@ -1062,6 +1058,10 @@ private:...@@ -1062,6 +1058,10 @@ private:
1062 typedef unique_ptr<__node, _Dp> __node_holder;1058 typedef unique_ptr<__node, _Dp> __node_holder;
1063 typedef allocator_traits<allocator_type> __alloc_traits;1059 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
1065 static_assert((is_same<typename __table::__container_value_type, value_type>::value), "");1065 static_assert((is_same<typename __table::__container_value_type, value_type>::value), "");
1066 static_assert((is_same<typename __table::__node_value_type, __value_type>::value), "");1066 static_assert((is_same<typename __table::__node_value_type, __value_type>::value), "");
1067public:1067public:
...@@ -1149,7 +1149,7 @@ public:...@@ -1149,7 +1149,7 @@ public:
1149#endif1149#endif
1150 _LIBCPP_INLINE_VISIBILITY1150 _LIBCPP_INLINE_VISIBILITY
1151 ~unordered_map() {1151 ~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)), "");
1153 }1153 }
11541154
1155 _LIBCPP_INLINE_VISIBILITY1155 _LIBCPP_INLINE_VISIBILITY
...@@ -1886,7 +1886,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -1886,7 +1886,7 @@ inline _LIBCPP_INLINE_VISIBILITY
1886#endif1886#endif
18871887
1888template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>1888template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1889bool1889_LIBCPP_HIDE_FROM_ABI bool
1890operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,1890operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
1891 const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)1891 const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
1892{1892{
...@@ -1934,8 +1934,7 @@ private:...@@ -1934,8 +1934,7 @@ private:
1934 typedef __hash_value_type<key_type, mapped_type> __value_type;1934 typedef __hash_value_type<key_type, mapped_type> __value_type;
1935 typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;1935 typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;
1936 typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal;1936 typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal;
1937 typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,1937 typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type;
1938 __value_type>::type __allocator_type;
19391938
1940 typedef __hash_table<__value_type, __hasher,1939 typedef __hash_table<__value_type, __hasher,
1941 __key_equal, __allocator_type> __table;1940 __key_equal, __allocator_type> __table;
...@@ -1952,7 +1951,12 @@ private:...@@ -1952,7 +1951,12 @@ private:
1952 static_assert((is_same<typename __node_traits::size_type,1951 static_assert((is_same<typename __node_traits::size_type,
1953 typename __alloc_traits::size_type>::value),1952 typename __alloc_traits::size_type>::value),
1954 "Allocator uses different size_type for different types");1953 "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:
1956 typedef typename __alloc_traits::pointer pointer;1960 typedef typename __alloc_traits::pointer pointer;
1957 typedef typename __alloc_traits::const_pointer const_pointer;1961 typedef typename __alloc_traits::const_pointer const_pointer;
1958 typedef typename __table::size_type size_type;1962 typedef typename __table::size_type size_type;
...@@ -2037,7 +2041,7 @@ public:...@@ -2037,7 +2041,7 @@ public:
2037#endif2041#endif
2038 _LIBCPP_INLINE_VISIBILITY2042 _LIBCPP_INLINE_VISIBILITY
2039 ~unordered_multimap() {2043 ~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)), "");
2041 }2045 }
20422046
2043 _LIBCPP_INLINE_VISIBILITY2047 _LIBCPP_INLINE_VISIBILITY
...@@ -2592,7 +2596,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -2592,7 +2596,7 @@ inline _LIBCPP_INLINE_VISIBILITY
2592#endif2596#endif
25932597
2594template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>2598template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2595bool2599_LIBCPP_HIDE_FROM_ABI bool
2596operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,2600operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
2597 const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)2601 const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
2598{2602{
...@@ -2625,4 +2629,25 @@ operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,...@@ -2625,4 +2629,25 @@ operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
26252629
2626_LIBCPP_END_NAMESPACE_STD2630_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
2628#endif // _LIBCPP_UNORDERED_MAP2653#endif // _LIBCPP_UNORDERED_MAP
lib/libcxx/include/unordered_set+30-10
...@@ -470,15 +470,13 @@ template <class Value, class Hash, class Pred, class Alloc>...@@ -470,15 +470,13 @@ template <class Value, class Hash, class Pred, class Alloc>
470#include <__iterator/erase_if_container.h>470#include <__iterator/erase_if_container.h>
471#include <__iterator/iterator_traits.h>471#include <__iterator/iterator_traits.h>
472#include <__memory/addressof.h>472#include <__memory/addressof.h>
473#include <__memory/allocator.h>
474#include <__memory_resource/polymorphic_allocator.h>
473#include <__node_handle>475#include <__node_handle>
476#include <__type_traits/is_allocator.h>
474#include <__utility/forward.h>477#include <__utility/forward.h>
475#include <version>478#include <version>
476479
477#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
478# include <functional>
479# include <iterator>
480#endif
481
482// standard-mandated includes480// standard-mandated includes
483481
484// [iterator.range]482// [iterator.range]
...@@ -517,7 +515,11 @@ public:...@@ -517,7 +515,11 @@ public:
517 static_assert((is_same<value_type, typename allocator_type::value_type>::value),515 static_assert((is_same<value_type, typename allocator_type::value_type>::value),
518 "Invalid allocator::value_type");516 "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:
521 typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;523 typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
522524
523 __table __table_;525 __table __table_;
...@@ -611,7 +613,7 @@ public:...@@ -611,7 +613,7 @@ public:
611#endif // _LIBCPP_CXX03_LANG613#endif // _LIBCPP_CXX03_LANG
612 _LIBCPP_INLINE_VISIBILITY614 _LIBCPP_INLINE_VISIBILITY
613 ~unordered_set() {615 ~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)), "");
615 }617 }
616618
617 _LIBCPP_INLINE_VISIBILITY619 _LIBCPP_INLINE_VISIBILITY
...@@ -1130,7 +1132,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -1130,7 +1132,7 @@ inline _LIBCPP_INLINE_VISIBILITY
1130#endif1132#endif
11311133
1132template <class _Value, class _Hash, class _Pred, class _Alloc>1134template <class _Value, class _Hash, class _Pred, class _Alloc>
1133bool1135_LIBCPP_HIDE_FROM_ABI bool
1134operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,1136operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
1135 const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)1137 const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
1136{1138{
...@@ -1265,7 +1267,7 @@ public:...@@ -1265,7 +1267,7 @@ public:
1265#endif // _LIBCPP_CXX03_LANG1267#endif // _LIBCPP_CXX03_LANG
1266 _LIBCPP_INLINE_VISIBILITY1268 _LIBCPP_INLINE_VISIBILITY
1267 ~unordered_multiset() {1269 ~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)), "");
1269 }1271 }
12701272
1271 _LIBCPP_INLINE_VISIBILITY1273 _LIBCPP_INLINE_VISIBILITY
...@@ -1768,7 +1770,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -1768,7 +1770,7 @@ inline _LIBCPP_INLINE_VISIBILITY
1768#endif1770#endif
17691771
1770template <class _Value, class _Hash, class _Pred, class _Alloc>1772template <class _Value, class _Hash, class _Pred, class _Alloc>
1771bool1773_LIBCPP_HIDE_FROM_ABI bool
1772operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,1774operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1773 const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)1775 const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1774{1776{
...@@ -1801,4 +1803,22 @@ operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,...@@ -1801,4 +1803,22 @@ operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
18011803
1802_LIBCPP_END_NAMESPACE_STD1804_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
1804#endif // _LIBCPP_UNORDERED_SET1824#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)));...@@ -42,6 +42,10 @@ swap(T (&a)[N], T (&b)[N]) noexcept(noexcept(swap(*a, *b)));
42template <class T> T&& forward(typename remove_reference<T>::type& t) noexcept; // constexpr in C++1442template <class T> T&& forward(typename remove_reference<T>::type& t) noexcept; // constexpr in C++14
43template <class T> T&& forward(typename remove_reference<T>::type&& t) noexcept; // constexpr in C++1443template <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
45template <class T> typename remove_reference<T>::type&& move(T&&) noexcept; // constexpr in C++1449template <class T> typename remove_reference<T>::type&& move(T&&) noexcept; // constexpr in C++14
4650
47template <class T>51template <class T>
...@@ -80,19 +84,29 @@ struct pair...@@ -80,19 +84,29 @@ struct pair
80 explicit(see-below) constexpr pair();84 explicit(see-below) constexpr pair();
81 explicit(see-below) pair(const T1& x, const T2& y); // constexpr in C++1485 explicit(see-below) pair(const T1& x, const T2& y); // constexpr in C++14
82 template <class U = T1, class V = T2> explicit(see-below) pair(U&&, V&&); // constexpr in C++1486 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
83 template <class U, class V> explicit(see-below) pair(const pair<U, V>& p); // constexpr in C++1488 template <class U, class V> explicit(see-below) pair(const pair<U, V>& p); // constexpr in C++14
84 template <class U, class V> explicit(see-below) pair(pair<U, V>&& p); // constexpr in C++1489 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
85 template <class... Args1, class... Args2>92 template <class... Args1, class... Args2>
86 pair(piecewise_construct_t, tuple<Args1...> first_args,93 pair(piecewise_construct_t, tuple<Args1...> first_args,
87 tuple<Args2...> second_args); // constexpr in C++2094 tuple<Args2...> second_args); // constexpr in C++20
8895
96 constexpr const pair& operator=(const pair& p) const; // since C++23
89 template <class U, class V> pair& operator=(const pair<U, V>& p); // constexpr in C++2097 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
90 pair& operator=(pair&& p) noexcept(is_nothrow_move_assignable<T1>::value &&100 pair& operator=(pair&& p) noexcept(is_nothrow_move_assignable<T1>::value &&
91 is_nothrow_move_assignable<T2>::value); // constexpr in C++20101 is_nothrow_move_assignable<T2>::value); // constexpr in C++20
102 constexpr const pair& operator=(pair&& p) const; // since C++23
92 template <class U, class V> pair& operator=(pair<U, V>&& p); // constexpr in C++20103 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
94 void swap(pair& p) noexcept(is_nothrow_swappable_v<T1> &&107 void swap(pair& p) noexcept(is_nothrow_swappable_v<T1> &&
95 is_nothrow_swappable_v<T2>); // constexpr in C++20108 is_nothrow_swappable_v<T2>); // constexpr in C++20
109 constexpr void swap(const pair& p) const noexcept(see below); // since C++23
96};110};
97111
98template<class T1, class T2, class U1, class U2, template<class> class TQual, template<class> class UQual>112template<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>...@@ -119,6 +133,9 @@ template <class T1, class T2>
119void133void
120swap(pair<T1, T2>& x, pair<T1, T2>& y) noexcept(noexcept(x.swap(y))); // constexpr in C++20134swap(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
122struct piecewise_construct_t { explicit piecewise_construct_t() = default; };139struct piecewise_construct_t { explicit piecewise_construct_t() = default; };
123inline constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();140inline constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
124141
...@@ -222,13 +239,14 @@ template <class T>...@@ -222,13 +239,14 @@ template <class T>
222239
223#include <__assert> // all public C++ headers provide the assertion handler240#include <__assert> // all public C++ headers provide the assertion handler
224#include <__config>241#include <__config>
225#include <__tuple>
226#include <__utility/as_const.h>242#include <__utility/as_const.h>
227#include <__utility/auto_cast.h>243#include <__utility/auto_cast.h>
228#include <__utility/cmp.h>244#include <__utility/cmp.h>
229#include <__utility/declval.h>245#include <__utility/declval.h>
246#include <__utility/exception_guard.h>
230#include <__utility/exchange.h>247#include <__utility/exchange.h>
231#include <__utility/forward.h>248#include <__utility/forward.h>
249#include <__utility/forward_like.h>
232#include <__utility/in_place.h>250#include <__utility/in_place.h>
233#include <__utility/integer_sequence.h>251#include <__utility/integer_sequence.h>
234#include <__utility/move.h>252#include <__utility/move.h>
...@@ -238,21 +256,27 @@ template <class T>...@@ -238,21 +256,27 @@ template <class T>
238#include <__utility/rel_ops.h>256#include <__utility/rel_ops.h>
239#include <__utility/swap.h>257#include <__utility/swap.h>
240#include <__utility/to_underlying.h>258#include <__utility/to_underlying.h>
241#include <__utility/transaction.h>
242#include <__utility/unreachable.h>259#include <__utility/unreachable.h>
243#include <type_traits>
244#include <version>260#include <version>
245261
246#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
247# include <iosfwd>
248#endif
249
250// standard-mandated includes262// standard-mandated includes
263
264// [utility.syn]
251#include <compare>265#include <compare>
252#include <initializer_list>266#include <initializer_list>
253267
268// [tuple.helper]
269#include <__tuple_dir/tuple_element.h>
270#include <__tuple_dir/tuple_size.h>
271
254#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)272#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
255# pragma GCC system_header273# pragma GCC system_header
256#endif274#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
258#endif // _LIBCPP_UTILITY282#endif // _LIBCPP_UTILITY
lib/libcxx/include/valarray+32-27
...@@ -353,6 +353,7 @@ template <class T> unspecified2 end(const valarray<T>& v);...@@ -353,6 +353,7 @@ template <class T> unspecified2 end(const valarray<T>& v);
353#include <__functional/operations.h>353#include <__functional/operations.h>
354#include <__memory/allocator.h>354#include <__memory/allocator.h>
355#include <__memory/uninitialized_algorithms.h>355#include <__memory/uninitialized_algorithms.h>
356#include <__type_traits/remove_reference.h>
356#include <__utility/move.h>357#include <__utility/move.h>
357#include <__utility/swap.h>358#include <__utility/swap.h>
358#include <cmath>359#include <cmath>
...@@ -360,12 +361,9 @@ template <class T> unspecified2 end(const valarray<T>& v);...@@ -360,12 +361,9 @@ template <class T> unspecified2 end(const valarray<T>& v);
360#include <new>361#include <new>
361#include <version>362#include <version>
362363
363#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
364# include <algorithm>
365# include <functional>
366#endif
367
368// standard-mandated includes364// standard-mandated includes
365
366// [valarray.syn]
369#include <initializer_list>367#include <initializer_list>
370368
371#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)369#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -548,7 +546,7 @@ struct __abs_expr...@@ -548,7 +546,7 @@ struct __abs_expr
548 typedef _Tp __result_type;546 typedef _Tp __result_type;
549 _LIBCPP_INLINE_VISIBILITY547 _LIBCPP_INLINE_VISIBILITY
550 _Tp operator()(const _Tp& __x) const548 _Tp operator()(const _Tp& __x) const
551 {return abs(__x);}549 {return std::abs(__x);}
552};550};
553551
554template <class _Tp>552template <class _Tp>
...@@ -557,7 +555,7 @@ struct __acos_expr...@@ -557,7 +555,7 @@ struct __acos_expr
557 typedef _Tp __result_type;555 typedef _Tp __result_type;
558 _LIBCPP_INLINE_VISIBILITY556 _LIBCPP_INLINE_VISIBILITY
559 _Tp operator()(const _Tp& __x) const557 _Tp operator()(const _Tp& __x) const
560 {return acos(__x);}558 {return std::acos(__x);}
561};559};
562560
563template <class _Tp>561template <class _Tp>
...@@ -566,7 +564,7 @@ struct __asin_expr...@@ -566,7 +564,7 @@ struct __asin_expr
566 typedef _Tp __result_type;564 typedef _Tp __result_type;
567 _LIBCPP_INLINE_VISIBILITY565 _LIBCPP_INLINE_VISIBILITY
568 _Tp operator()(const _Tp& __x) const566 _Tp operator()(const _Tp& __x) const
569 {return asin(__x);}567 {return std::asin(__x);}
570};568};
571569
572template <class _Tp>570template <class _Tp>
...@@ -575,7 +573,7 @@ struct __atan_expr...@@ -575,7 +573,7 @@ struct __atan_expr
575 typedef _Tp __result_type;573 typedef _Tp __result_type;
576 _LIBCPP_INLINE_VISIBILITY574 _LIBCPP_INLINE_VISIBILITY
577 _Tp operator()(const _Tp& __x) const575 _Tp operator()(const _Tp& __x) const
578 {return atan(__x);}576 {return std::atan(__x);}
579};577};
580578
581template <class _Tp>579template <class _Tp>
...@@ -584,7 +582,7 @@ struct __atan2_expr...@@ -584,7 +582,7 @@ struct __atan2_expr
584 typedef _Tp __result_type;582 typedef _Tp __result_type;
585 _LIBCPP_INLINE_VISIBILITY583 _LIBCPP_INLINE_VISIBILITY
586 _Tp operator()(const _Tp& __x, const _Tp& __y) const584 _Tp operator()(const _Tp& __x, const _Tp& __y) const
587 {return atan2(__x, __y);}585 {return std::atan2(__x, __y);}
588};586};
589587
590template <class _Tp>588template <class _Tp>
...@@ -593,7 +591,7 @@ struct __cos_expr...@@ -593,7 +591,7 @@ struct __cos_expr
593 typedef _Tp __result_type;591 typedef _Tp __result_type;
594 _LIBCPP_INLINE_VISIBILITY592 _LIBCPP_INLINE_VISIBILITY
595 _Tp operator()(const _Tp& __x) const593 _Tp operator()(const _Tp& __x) const
596 {return cos(__x);}594 {return std::cos(__x);}
597};595};
598596
599template <class _Tp>597template <class _Tp>
...@@ -602,7 +600,7 @@ struct __cosh_expr...@@ -602,7 +600,7 @@ struct __cosh_expr
602 typedef _Tp __result_type;600 typedef _Tp __result_type;
603 _LIBCPP_INLINE_VISIBILITY601 _LIBCPP_INLINE_VISIBILITY
604 _Tp operator()(const _Tp& __x) const602 _Tp operator()(const _Tp& __x) const
605 {return cosh(__x);}603 {return std::cosh(__x);}
606};604};
607605
608template <class _Tp>606template <class _Tp>
...@@ -611,7 +609,7 @@ struct __exp_expr...@@ -611,7 +609,7 @@ struct __exp_expr
611 typedef _Tp __result_type;609 typedef _Tp __result_type;
612 _LIBCPP_INLINE_VISIBILITY610 _LIBCPP_INLINE_VISIBILITY
613 _Tp operator()(const _Tp& __x) const611 _Tp operator()(const _Tp& __x) const
614 {return exp(__x);}612 {return std::exp(__x);}
615};613};
616614
617template <class _Tp>615template <class _Tp>
...@@ -620,7 +618,7 @@ struct __log_expr...@@ -620,7 +618,7 @@ struct __log_expr
620 typedef _Tp __result_type;618 typedef _Tp __result_type;
621 _LIBCPP_INLINE_VISIBILITY619 _LIBCPP_INLINE_VISIBILITY
622 _Tp operator()(const _Tp& __x) const620 _Tp operator()(const _Tp& __x) const
623 {return log(__x);}621 {return std::log(__x);}
624};622};
625623
626template <class _Tp>624template <class _Tp>
...@@ -629,7 +627,7 @@ struct __log10_expr...@@ -629,7 +627,7 @@ struct __log10_expr
629 typedef _Tp __result_type;627 typedef _Tp __result_type;
630 _LIBCPP_INLINE_VISIBILITY628 _LIBCPP_INLINE_VISIBILITY
631 _Tp operator()(const _Tp& __x) const629 _Tp operator()(const _Tp& __x) const
632 {return log10(__x);}630 {return std::log10(__x);}
633};631};
634632
635template <class _Tp>633template <class _Tp>
...@@ -638,7 +636,7 @@ struct __pow_expr...@@ -638,7 +636,7 @@ struct __pow_expr
638 typedef _Tp __result_type;636 typedef _Tp __result_type;
639 _LIBCPP_INLINE_VISIBILITY637 _LIBCPP_INLINE_VISIBILITY
640 _Tp operator()(const _Tp& __x, const _Tp& __y) const638 _Tp operator()(const _Tp& __x, const _Tp& __y) const
641 {return pow(__x, __y);}639 {return std::pow(__x, __y);}
642};640};
643641
644template <class _Tp>642template <class _Tp>
...@@ -647,7 +645,7 @@ struct __sin_expr...@@ -647,7 +645,7 @@ struct __sin_expr
647 typedef _Tp __result_type;645 typedef _Tp __result_type;
648 _LIBCPP_INLINE_VISIBILITY646 _LIBCPP_INLINE_VISIBILITY
649 _Tp operator()(const _Tp& __x) const647 _Tp operator()(const _Tp& __x) const
650 {return sin(__x);}648 {return std::sin(__x);}
651};649};
652650
653template <class _Tp>651template <class _Tp>
...@@ -656,7 +654,7 @@ struct __sinh_expr...@@ -656,7 +654,7 @@ struct __sinh_expr
656 typedef _Tp __result_type;654 typedef _Tp __result_type;
657 _LIBCPP_INLINE_VISIBILITY655 _LIBCPP_INLINE_VISIBILITY
658 _Tp operator()(const _Tp& __x) const656 _Tp operator()(const _Tp& __x) const
659 {return sinh(__x);}657 {return std::sinh(__x);}
660};658};
661659
662template <class _Tp>660template <class _Tp>
...@@ -665,7 +663,7 @@ struct __sqrt_expr...@@ -665,7 +663,7 @@ struct __sqrt_expr
665 typedef _Tp __result_type;663 typedef _Tp __result_type;
666 _LIBCPP_INLINE_VISIBILITY664 _LIBCPP_INLINE_VISIBILITY
667 _Tp operator()(const _Tp& __x) const665 _Tp operator()(const _Tp& __x) const
668 {return sqrt(__x);}666 {return std::sqrt(__x);}
669};667};
670668
671template <class _Tp>669template <class _Tp>
...@@ -674,7 +672,7 @@ struct __tan_expr...@@ -674,7 +672,7 @@ struct __tan_expr
674 typedef _Tp __result_type;672 typedef _Tp __result_type;
675 _LIBCPP_INLINE_VISIBILITY673 _LIBCPP_INLINE_VISIBILITY
676 _Tp operator()(const _Tp& __x) const674 _Tp operator()(const _Tp& __x) const
677 {return tan(__x);}675 {return std::tan(__x);}
678};676};
679677
680template <class _Tp>678template <class _Tp>
...@@ -683,13 +681,13 @@ struct __tanh_expr...@@ -683,13 +681,13 @@ struct __tanh_expr
683 typedef _Tp __result_type;681 typedef _Tp __result_type;
684 _LIBCPP_INLINE_VISIBILITY682 _LIBCPP_INLINE_VISIBILITY
685 _Tp operator()(const _Tp& __x) const683 _Tp operator()(const _Tp& __x) const
686 {return tanh(__x);}684 {return std::tanh(__x);}
687};685};
688686
689template <class _ValExpr>687template <class _ValExpr>
690class __slice_expr688class __slice_expr
691{689{
692 typedef typename remove_reference<_ValExpr>::type _RmExpr;690 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
693public:691public:
694 typedef typename _RmExpr::value_type value_type;692 typedef typename _RmExpr::value_type value_type;
695 typedef value_type __result_type;693 typedef value_type __result_type;
...@@ -729,7 +727,7 @@ class __indirect_expr;...@@ -729,7 +727,7 @@ class __indirect_expr;
729template <class _ValExpr>727template <class _ValExpr>
730class __shift_expr728class __shift_expr
731{729{
732 typedef typename remove_reference<_ValExpr>::type _RmExpr;730 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
733public:731public:
734 typedef typename _RmExpr::value_type value_type;732 typedef typename _RmExpr::value_type value_type;
735 typedef value_type __result_type;733 typedef value_type __result_type;
...@@ -772,7 +770,7 @@ public:...@@ -772,7 +770,7 @@ public:
772template <class _ValExpr>770template <class _ValExpr>
773class __cshift_expr771class __cshift_expr
774{772{
775 typedef typename remove_reference<_ValExpr>::type _RmExpr;773 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
776public:774public:
777 typedef typename _RmExpr::value_type value_type;775 typedef typename _RmExpr::value_type value_type;
778 typedef value_type __result_type;776 typedef value_type __result_type;
...@@ -2247,7 +2245,7 @@ mask_array<_Tp>::operator=(const value_type& __x) const...@@ -2247,7 +2245,7 @@ mask_array<_Tp>::operator=(const value_type& __x) const
2247template <class _ValExpr>2245template <class _ValExpr>
2248class __mask_expr2246class __mask_expr
2249{2247{
2250 typedef typename remove_reference<_ValExpr>::type _RmExpr;2248 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
2251public:2249public:
2252 typedef typename _RmExpr::value_type value_type;2250 typedef typename _RmExpr::value_type value_type;
2253 typedef value_type __result_type;2251 typedef value_type __result_type;
...@@ -2610,7 +2608,7 @@ indirect_array<_Tp>::operator=(const value_type& __x) const...@@ -2610,7 +2608,7 @@ indirect_array<_Tp>::operator=(const value_type& __x) const
2610template <class _ValExpr>2608template <class _ValExpr>
2611class __indirect_expr2609class __indirect_expr
2612{2610{
2613 typedef typename remove_reference<_ValExpr>::type _RmExpr;2611 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
2614public:2612public:
2615 typedef typename _RmExpr::value_type value_type;2613 typedef typename _RmExpr::value_type value_type;
2616 typedef value_type __result_type;2614 typedef value_type __result_type;
...@@ -2650,7 +2648,7 @@ public:...@@ -2650,7 +2648,7 @@ public:
2650template<class _ValExpr>2648template<class _ValExpr>
2651class __val_expr2649class __val_expr
2652{2650{
2653 typedef typename remove_reference<_ValExpr>::type _RmExpr;2651 typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr;
26542652
2655 _ValExpr __expr_;2653 _ValExpr __expr_;
2656public:2654public:
...@@ -4932,4 +4930,11 @@ _LIBCPP_END_NAMESPACE_STD...@@ -4932,4 +4930,11 @@ _LIBCPP_END_NAMESPACE_STD
49324930
4933_LIBCPP_POP_MACROS4931_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
4935#endif // _LIBCPP_VALARRAY4940#endif // _LIBCPP_VALARRAY
lib/libcxx/include/variant+227-178
...@@ -22,8 +22,8 @@ namespace std {...@@ -22,8 +22,8 @@ namespace std {
2222
23 // 20.7.2.1, constructors23 // 20.7.2.1, constructors
24 constexpr variant() noexcept(see below);24 constexpr variant() noexcept(see below);
25 variant(const variant&); // constexpr in C++2025 constexpr variant(const variant&);
26 variant(variant&&) noexcept(see below); // constexpr in C++2026 constexpr variant(variant&&) noexcept(see below);
2727
28 template <class T> constexpr variant(T&&) noexcept(see below);28 template <class T> constexpr variant(T&&) noexcept(see below);
2929
...@@ -45,8 +45,8 @@ namespace std {...@@ -45,8 +45,8 @@ namespace std {
45 ~variant();45 ~variant();
4646
47 // 20.7.2.3, assignment47 // 20.7.2.3, assignment
48 variant& operator=(const variant&); // constexpr in C++2048 constexpr variant& operator=(const variant&);
49 variant& operator=(variant&&) noexcept(see below); // constexpr in C++2049 constexpr variant& operator=(variant&&) noexcept(see below);
5050
51 template <class T> variant& operator=(T&&) noexcept(see below);51 template <class T> variant& operator=(T&&) noexcept(see below);
5252
...@@ -165,6 +165,10 @@ namespace std {...@@ -165,6 +165,10 @@ namespace std {
165 template <class... Types>165 template <class... Types>
166 constexpr bool operator>=(const variant<Types...>&, const variant<Types...>&);166 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
168 // 20.7.6, visitation172 // 20.7.6, visitation
169 template <class Visitor, class... Variants>173 template <class Visitor, class... Variants>
170 constexpr see below visit(Visitor&&, Variants&&...);174 constexpr see below visit(Visitor&&, Variants&&...);
...@@ -176,12 +180,13 @@ namespace std {...@@ -176,12 +180,13 @@ namespace std {
176 struct monostate;180 struct monostate;
177181
178 // 20.7.8, monostate relational operators182 // 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;
183 constexpr bool operator==(monostate, monostate) noexcept;183 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
186 // 20.7.9, specialized algorithms191 // 20.7.9, specialized algorithms
187 template <class... Types>192 template <class... Types>
...@@ -201,11 +206,31 @@ namespace std {...@@ -201,11 +206,31 @@ namespace std {
201206
202#include <__assert> // all public C++ headers provide the assertion handler207#include <__assert> // all public C++ headers provide the assertion handler
203#include <__availability>208#include <__availability>
209#include <__compare/common_comparison_category.h>
210#include <__compare/compare_three_way_result.h>
211#include <__compare/three_way_comparable.h>
204#include <__config>212#include <__config>
205#include <__functional/hash.h>213#include <__functional/hash.h>
214#include <__functional/invoke.h>
206#include <__functional/operations.h>215#include <__functional/operations.h>
207#include <__functional/unary_function.h>216#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>
209#include <__utility/forward.h>234#include <__utility/forward.h>
210#include <__utility/in_place.h>235#include <__utility/in_place.h>
211#include <__utility/move.h>236#include <__utility/move.h>
...@@ -216,15 +241,11 @@ namespace std {...@@ -216,15 +241,11 @@ namespace std {
216#include <limits>241#include <limits>
217#include <new>242#include <new>
218#include <tuple>243#include <tuple>
219#include <type_traits>
220#include <version>244#include <version>
221245
222#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
223# include <typeinfo>
224# include <utility>
225#endif
226
227// standard-mandated includes246// standard-mandated includes
247
248// [variant.syn]
228#include <compare>249#include <compare>
229250
230#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)251#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -238,7 +259,7 @@ namespace std { // explicitly not using versioning namespace...@@ -238,7 +259,7 @@ namespace std { // explicitly not using versioning namespace
238259
239class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS bad_variant_access : public exception {260class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS bad_variant_access : public exception {
240public:261public:
241 virtual const char* what() const _NOEXCEPT;262 const char* what() const _NOEXCEPT override;
242};263};
243264
244} // namespace std265} // namespace std
...@@ -261,7 +282,7 @@ struct __farray {...@@ -261,7 +282,7 @@ struct __farray {
261};282};
262283
263_LIBCPP_NORETURN284_LIBCPP_NORETURN
264inline _LIBCPP_INLINE_VISIBILITY285inline _LIBCPP_HIDE_FROM_ABI
265_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS286_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
266void __throw_bad_variant_access() {287void __throw_bad_variant_access() {
267#ifndef _LIBCPP_NO_EXCEPTIONS288#ifndef _LIBCPP_NO_EXCEPTIONS
...@@ -320,7 +341,7 @@ struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, variant<_Types...>> {...@@ -320,7 +341,7 @@ struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, variant<_Types...>> {
320341
321inline constexpr size_t variant_npos = static_cast<size_t>(-1);342inline 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) {
324 if (__num_elem < numeric_limits<unsigned char>::max())345 if (__num_elem < numeric_limits<unsigned char>::max())
325 return 0;346 return 0;
326 if (__num_elem < numeric_limits<unsigned short>::max())347 if (__num_elem < numeric_limits<unsigned short>::max())
...@@ -372,7 +393,7 @@ __as_variant(const variant<_Types...>&& __vs) noexcept {...@@ -372,7 +393,7 @@ __as_variant(const variant<_Types...>&& __vs) noexcept {
372namespace __find_detail {393namespace __find_detail {
373394
374template <class _Tp, class... _Types>395template <class _Tp, class... _Types>
375inline _LIBCPP_INLINE_VISIBILITY396_LIBCPP_HIDE_FROM_ABI
376constexpr size_t __find_index() {397constexpr size_t __find_index() {
377 constexpr bool __matches[] = {is_same_v<_Tp, _Types>...};398 constexpr bool __matches[] = {is_same_v<_Tp, _Types>...};
378 size_t __result = __not_found;399 size_t __result = __not_found;
...@@ -417,7 +438,7 @@ constexpr _Trait __trait =...@@ -417,7 +438,7 @@ constexpr _Trait __trait =
417 ? _Trait::_TriviallyAvailable438 ? _Trait::_TriviallyAvailable
418 : _IsAvailable<_Tp>::value ? _Trait::_Available : _Trait::_Unavailable;439 : _IsAvailable<_Tp>::value ? _Trait::_Available : _Trait::_Unavailable;
419440
420inline _LIBCPP_INLINE_VISIBILITY441_LIBCPP_HIDE_FROM_ABI
421constexpr _Trait __common_trait(initializer_list<_Trait> __traits) {442constexpr _Trait __common_trait(initializer_list<_Trait> __traits) {
422 _Trait __result = _Trait::_TriviallyAvailable;443 _Trait __result = _Trait::_TriviallyAvailable;
423 for (_Trait __t : __traits) {444 for (_Trait __t : __traits) {
...@@ -431,24 +452,24 @@ constexpr _Trait __common_trait(initializer_list<_Trait> __traits) {...@@ -431,24 +452,24 @@ constexpr _Trait __common_trait(initializer_list<_Trait> __traits) {
431template <typename... _Types>452template <typename... _Types>
432struct __traits {453struct __traits {
433 static constexpr _Trait __copy_constructible_trait =454 static constexpr _Trait __copy_constructible_trait =
434 __common_trait({__trait<_Types,455 __variant_detail::__common_trait({__trait<_Types,
435 is_trivially_copy_constructible,456 is_trivially_copy_constructible,
436 is_copy_constructible>...});457 is_copy_constructible>...});
437458
438 static constexpr _Trait __move_constructible_trait =459 static constexpr _Trait __move_constructible_trait =
439 __common_trait({__trait<_Types,460 __variant_detail::__common_trait({__trait<_Types,
440 is_trivially_move_constructible,461 is_trivially_move_constructible,
441 is_move_constructible>...});462 is_move_constructible>...});
442463
443 static constexpr _Trait __copy_assignable_trait = __common_trait(464 static constexpr _Trait __copy_assignable_trait = __variant_detail::__common_trait(
444 {__copy_constructible_trait,465 {__copy_constructible_trait,
445 __trait<_Types, is_trivially_copy_assignable, is_copy_assignable>...});466 __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(
448 {__move_constructible_trait,469 {__move_constructible_trait,
449 __trait<_Types, is_trivially_move_assignable, is_move_assignable>...});470 __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(
452 {__trait<_Types, is_trivially_destructible, is_destructible>...});473 {__trait<_Types, is_trivially_destructible, is_destructible>...});
453};474};
454475
...@@ -456,13 +477,13 @@ namespace __access {...@@ -456,13 +477,13 @@ namespace __access {
456477
457struct __union {478struct __union {
458 template <class _Vp>479 template <class _Vp>
459 inline _LIBCPP_INLINE_VISIBILITY480 _LIBCPP_HIDE_FROM_ABI
460 static constexpr auto&& __get_alt(_Vp&& __v, in_place_index_t<0>) {481 static constexpr auto&& __get_alt(_Vp&& __v, in_place_index_t<0>) {
461 return _VSTD::forward<_Vp>(__v).__head;482 return _VSTD::forward<_Vp>(__v).__head;
462 }483 }
463484
464 template <class _Vp, size_t _Ip>485 template <class _Vp, size_t _Ip>
465 inline _LIBCPP_INLINE_VISIBILITY486 _LIBCPP_HIDE_FROM_ABI
466 static constexpr auto&& __get_alt(_Vp&& __v, in_place_index_t<_Ip>) {487 static constexpr auto&& __get_alt(_Vp&& __v, in_place_index_t<_Ip>) {
467 return __get_alt(_VSTD::forward<_Vp>(__v).__tail, in_place_index<_Ip - 1>);488 return __get_alt(_VSTD::forward<_Vp>(__v).__tail, in_place_index<_Ip - 1>);
468 }489 }
...@@ -470,7 +491,7 @@ struct __union {...@@ -470,7 +491,7 @@ struct __union {
470491
471struct __base {492struct __base {
472 template <size_t _Ip, class _Vp>493 template <size_t _Ip, class _Vp>
473 inline _LIBCPP_INLINE_VISIBILITY494 _LIBCPP_HIDE_FROM_ABI
474 static constexpr auto&& __get_alt(_Vp&& __v) {495 static constexpr auto&& __get_alt(_Vp&& __v) {
475 return __union::__get_alt(_VSTD::forward<_Vp>(__v).__data,496 return __union::__get_alt(_VSTD::forward<_Vp>(__v).__data,
476 in_place_index<_Ip>);497 in_place_index<_Ip>);
...@@ -479,9 +500,9 @@ struct __base {...@@ -479,9 +500,9 @@ struct __base {
479500
480struct __variant {501struct __variant {
481 template <size_t _Ip, class _Vp>502 template <size_t _Ip, class _Vp>
482 inline _LIBCPP_INLINE_VISIBILITY503 _LIBCPP_HIDE_FROM_ABI
483 static constexpr auto&& __get_alt(_Vp&& __v) {504 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_);
485 }506 }
486};507};
487508
...@@ -491,7 +512,7 @@ namespace __visitation {...@@ -491,7 +512,7 @@ namespace __visitation {
491512
492struct __base {513struct __base {
493 template <class _Visitor, class... _Vs>514 template <class _Visitor, class... _Vs>
494 inline _LIBCPP_INLINE_VISIBILITY515 _LIBCPP_HIDE_FROM_ABI
495 static constexpr decltype(auto)516 static constexpr decltype(auto)
496 __visit_alt_at(size_t __index, _Visitor&& __visitor, _Vs&&... __vs) {517 __visit_alt_at(size_t __index, _Visitor&& __visitor, _Vs&&... __vs) {
497 constexpr auto __fdiagonal =518 constexpr auto __fdiagonal =
...@@ -502,7 +523,7 @@ struct __base {...@@ -502,7 +523,7 @@ struct __base {
502 }523 }
503524
504 template <class _Visitor, class... _Vs>525 template <class _Visitor, class... _Vs>
505 inline _LIBCPP_INLINE_VISIBILITY526 _LIBCPP_HIDE_FROM_ABI
506 static constexpr decltype(auto) __visit_alt(_Visitor&& __visitor,527 static constexpr decltype(auto) __visit_alt(_Visitor&& __visitor,
507 _Vs&&... __vs) {528 _Vs&&... __vs) {
508 constexpr auto __fmatrix =529 constexpr auto __fmatrix =
...@@ -515,11 +536,11 @@ struct __base {...@@ -515,11 +536,11 @@ struct __base {
515536
516private:537private:
517 template <class _Tp>538 template <class _Tp>
518 inline _LIBCPP_INLINE_VISIBILITY539 _LIBCPP_HIDE_FROM_ABI
519 static constexpr const _Tp& __at(const _Tp& __elem) { return __elem; }540 static constexpr const _Tp& __at(const _Tp& __elem) { return __elem; }
520541
521 template <class _Tp, size_t _Np, typename... _Indices>542 template <class _Tp, size_t _Np, typename... _Indices>
522 inline _LIBCPP_INLINE_VISIBILITY543 _LIBCPP_HIDE_FROM_ABI
523 static constexpr auto&& __at(const __farray<_Tp, _Np>& __elems,544 static constexpr auto&& __at(const __farray<_Tp, _Np>& __elems,
524 size_t __index, _Indices... __indices) {545 size_t __index, _Indices... __indices) {
525 return __at(__elems[__index], __indices...);546 return __at(__elems[__index], __indices...);
...@@ -533,17 +554,17 @@ private:...@@ -533,17 +554,17 @@ private:
533 }554 }
534555
535 template <class... _Fs>556 template <class... _Fs>
536 inline _LIBCPP_INLINE_VISIBILITY557 _LIBCPP_HIDE_FROM_ABI
537 static constexpr auto __make_farray(_Fs&&... __fs) {558 static constexpr auto __make_farray(_Fs&&... __fs) {
538 __std_visit_visitor_return_type_check<__uncvref_t<_Fs>...>();559 __std_visit_visitor_return_type_check<__remove_cvref_t<_Fs>...>();
539 using __result = __farray<common_type_t<__uncvref_t<_Fs>...>, sizeof...(_Fs)>;560 using __result = __farray<common_type_t<__remove_cvref_t<_Fs>...>, sizeof...(_Fs)>;
540 return __result{{_VSTD::forward<_Fs>(__fs)...}};561 return __result{{_VSTD::forward<_Fs>(__fs)...}};
541 }562 }
542563
543 template <size_t... _Is>564 template <size_t... _Is>
544 struct __dispatcher {565 struct __dispatcher {
545 template <class _Fp, class... _Vs>566 template <class _Fp, class... _Vs>
546 inline _LIBCPP_INLINE_VISIBILITY567 _LIBCPP_HIDE_FROM_ABI
547 static constexpr decltype(auto) __dispatch(_Fp __f, _Vs... __vs) {568 static constexpr decltype(auto) __dispatch(_Fp __f, _Vs... __vs) {
548 return _VSTD::__invoke(569 return _VSTD::__invoke(
549 static_cast<_Fp>(__f),570 static_cast<_Fp>(__f),
...@@ -552,40 +573,40 @@ private:...@@ -552,40 +573,40 @@ private:
552 };573 };
553574
554 template <class _Fp, class... _Vs, size_t... _Is>575 template <class _Fp, class... _Vs, size_t... _Is>
555 inline _LIBCPP_INLINE_VISIBILITY576 _LIBCPP_HIDE_FROM_ABI
556 static constexpr auto __make_dispatch(index_sequence<_Is...>) {577 static constexpr auto __make_dispatch(index_sequence<_Is...>) {
557 return __dispatcher<_Is...>::template __dispatch<_Fp, _Vs...>;578 return __dispatcher<_Is...>::template __dispatch<_Fp, _Vs...>;
558 }579 }
559580
560 template <size_t _Ip, class _Fp, class... _Vs>581 template <size_t _Ip, class _Fp, class... _Vs>
561 inline _LIBCPP_INLINE_VISIBILITY582 _LIBCPP_HIDE_FROM_ABI
562 static constexpr auto __make_fdiagonal_impl() {583 static constexpr auto __make_fdiagonal_impl() {
563 return __make_dispatch<_Fp, _Vs...>(584 return __make_dispatch<_Fp, _Vs...>(
564 index_sequence<((void)__type_identity<_Vs>{}, _Ip)...>{});585 index_sequence<((void)__type_identity<_Vs>{}, _Ip)...>{});
565 }586 }
566587
567 template <class _Fp, class... _Vs, size_t... _Is>588 template <class _Fp, class... _Vs, size_t... _Is>
568 inline _LIBCPP_INLINE_VISIBILITY589 _LIBCPP_HIDE_FROM_ABI
569 static constexpr auto __make_fdiagonal_impl(index_sequence<_Is...>) {590 static constexpr auto __make_fdiagonal_impl(index_sequence<_Is...>) {
570 return __base::__make_farray(__make_fdiagonal_impl<_Is, _Fp, _Vs...>()...);591 return __base::__make_farray(__make_fdiagonal_impl<_Is, _Fp, _Vs...>()...);
571 }592 }
572593
573 template <class _Fp, class _Vp, class... _Vs>594 template <class _Fp, class _Vp, class... _Vs>
574 inline _LIBCPP_INLINE_VISIBILITY595 _LIBCPP_HIDE_FROM_ABI
575 static constexpr auto __make_fdiagonal() {596 static constexpr auto __make_fdiagonal() {
576 constexpr size_t _Np = __uncvref_t<_Vp>::__size();597 constexpr size_t _Np = __remove_cvref_t<_Vp>::__size();
577 static_assert(__all<(_Np == __uncvref_t<_Vs>::__size())...>::value);598 static_assert(__all<(_Np == __remove_cvref_t<_Vs>::__size())...>::value);
578 return __make_fdiagonal_impl<_Fp, _Vp, _Vs...>(make_index_sequence<_Np>{});599 return __make_fdiagonal_impl<_Fp, _Vp, _Vs...>(make_index_sequence<_Np>{});
579 }600 }
580601
581 template <class _Fp, class... _Vs, size_t... _Is>602 template <class _Fp, class... _Vs, size_t... _Is>
582 inline _LIBCPP_INLINE_VISIBILITY603 _LIBCPP_HIDE_FROM_ABI
583 static constexpr auto __make_fmatrix_impl(index_sequence<_Is...> __is) {604 static constexpr auto __make_fmatrix_impl(index_sequence<_Is...> __is) {
584 return __make_dispatch<_Fp, _Vs...>(__is);605 return __make_dispatch<_Fp, _Vs...>(__is);
585 }606 }
586607
587 template <class _Fp, class... _Vs, size_t... _Is, size_t... _Js, class... _Ls>608 template <class _Fp, class... _Vs, size_t... _Is, size_t... _Js, class... _Ls>
588 inline _LIBCPP_INLINE_VISIBILITY609 _LIBCPP_HIDE_FROM_ABI
589 static constexpr auto __make_fmatrix_impl(index_sequence<_Is...>,610 static constexpr auto __make_fmatrix_impl(index_sequence<_Is...>,
590 index_sequence<_Js...>,611 index_sequence<_Js...>,
591 _Ls... __ls) {612 _Ls... __ls) {
...@@ -594,34 +615,34 @@ private:...@@ -594,34 +615,34 @@ private:
594 }615 }
595616
596 template <class _Fp, class... _Vs>617 template <class _Fp, class... _Vs>
597 inline _LIBCPP_INLINE_VISIBILITY618 _LIBCPP_HIDE_FROM_ABI
598 static constexpr auto __make_fmatrix() {619 static constexpr auto __make_fmatrix() {
599 return __make_fmatrix_impl<_Fp, _Vs...>(620 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()>{}...);
601 }622 }
602};623};
603624
604struct __variant {625struct __variant {
605 template <class _Visitor, class... _Vs>626 template <class _Visitor, class... _Vs>
606 inline _LIBCPP_INLINE_VISIBILITY627 _LIBCPP_HIDE_FROM_ABI
607 static constexpr decltype(auto)628 static constexpr decltype(auto)
608 __visit_alt_at(size_t __index, _Visitor&& __visitor, _Vs&&... __vs) {629 __visit_alt_at(size_t __index, _Visitor&& __visitor, _Vs&&... __vs) {
609 return __base::__visit_alt_at(__index,630 return __base::__visit_alt_at(__index,
610 _VSTD::forward<_Visitor>(__visitor),631 _VSTD::forward<_Visitor>(__visitor),
611 _VSTD::forward<_Vs>(__vs).__impl...);632 _VSTD::forward<_Vs>(__vs).__impl_...);
612 }633 }
613634
614 template <class _Visitor, class... _Vs>635 template <class _Visitor, class... _Vs>
615 inline _LIBCPP_INLINE_VISIBILITY636 _LIBCPP_HIDE_FROM_ABI
616 static constexpr decltype(auto) __visit_alt(_Visitor&& __visitor,637 static constexpr decltype(auto) __visit_alt(_Visitor&& __visitor,
617 _Vs&&... __vs) {638 _Vs&&... __vs) {
618 return __base::__visit_alt(639 return __base::__visit_alt(
619 _VSTD::forward<_Visitor>(__visitor),640 _VSTD::forward<_Visitor>(__visitor),
620 _VSTD::__as_variant(_VSTD::forward<_Vs>(__vs)).__impl...);641 _VSTD::__as_variant(_VSTD::forward<_Vs>(__vs)).__impl_...);
621 }642 }
622643
623 template <class _Visitor, class... _Vs>644 template <class _Visitor, class... _Vs>
624 inline _LIBCPP_INLINE_VISIBILITY645 _LIBCPP_HIDE_FROM_ABI
625 static constexpr decltype(auto)646 static constexpr decltype(auto)
626 __visit_value_at(size_t __index, _Visitor&& __visitor, _Vs&&... __vs) {647 __visit_value_at(size_t __index, _Visitor&& __visitor, _Vs&&... __vs) {
627 return __visit_alt_at(648 return __visit_alt_at(
...@@ -631,7 +652,7 @@ struct __variant {...@@ -631,7 +652,7 @@ struct __variant {
631 }652 }
632653
633 template <class _Visitor, class... _Vs>654 template <class _Visitor, class... _Vs>
634 inline _LIBCPP_INLINE_VISIBILITY655 _LIBCPP_HIDE_FROM_ABI
635 static constexpr decltype(auto) __visit_value(_Visitor&& __visitor,656 static constexpr decltype(auto) __visit_value(_Visitor&& __visitor,
636 _Vs&&... __vs) {657 _Vs&&... __vs) {
637 return __visit_alt(658 return __visit_alt(
...@@ -641,7 +662,7 @@ struct __variant {...@@ -641,7 +662,7 @@ struct __variant {
641662
642#if _LIBCPP_STD_VER > 17663#if _LIBCPP_STD_VER > 17
643 template <class _Rp, class _Visitor, class... _Vs>664 template <class _Rp, class _Visitor, class... _Vs>
644 inline _LIBCPP_INLINE_VISIBILITY665 _LIBCPP_HIDE_FROM_ABI
645 static constexpr _Rp __visit_value(_Visitor&& __visitor,666 static constexpr _Rp __visit_value(_Visitor&& __visitor,
646 _Vs&&... __vs) {667 _Vs&&... __vs) {
647 return __visit_alt(668 return __visit_alt(
...@@ -660,7 +681,7 @@ private:...@@ -660,7 +681,7 @@ private:
660 template <class _Visitor>681 template <class _Visitor>
661 struct __value_visitor {682 struct __value_visitor {
662 template <class... _Alts>683 template <class... _Alts>
663 inline _LIBCPP_INLINE_VISIBILITY684 _LIBCPP_HIDE_FROM_ABI
664 constexpr decltype(auto) operator()(_Alts&&... __alts) const {685 constexpr decltype(auto) operator()(_Alts&&... __alts) const {
665 __std_visit_exhaustive_visitor_check<686 __std_visit_exhaustive_visitor_check<
666 _Visitor,687 _Visitor,
...@@ -675,7 +696,7 @@ private:...@@ -675,7 +696,7 @@ private:
675 template <class _Rp, class _Visitor>696 template <class _Rp, class _Visitor>
676 struct __value_visitor_return_type {697 struct __value_visitor_return_type {
677 template <class... _Alts>698 template <class... _Alts>
678 inline _LIBCPP_INLINE_VISIBILITY699 _LIBCPP_HIDE_FROM_ABI
679 constexpr _Rp operator()(_Alts&&... __alts) const {700 constexpr _Rp operator()(_Alts&&... __alts) const {
680 __std_visit_exhaustive_visitor_check<701 __std_visit_exhaustive_visitor_check<
681 _Visitor,702 _Visitor,
...@@ -695,14 +716,14 @@ private:...@@ -695,14 +716,14 @@ private:
695#endif716#endif
696717
697 template <class _Visitor>718 template <class _Visitor>
698 inline _LIBCPP_INLINE_VISIBILITY719 _LIBCPP_HIDE_FROM_ABI
699 static constexpr auto __make_value_visitor(_Visitor&& __visitor) {720 static constexpr auto __make_value_visitor(_Visitor&& __visitor) {
700 return __value_visitor<_Visitor>{_VSTD::forward<_Visitor>(__visitor)};721 return __value_visitor<_Visitor>{_VSTD::forward<_Visitor>(__visitor)};
701 }722 }
702723
703#if _LIBCPP_STD_VER > 17724#if _LIBCPP_STD_VER > 17
704 template <class _Rp, class _Visitor>725 template <class _Rp, class _Visitor>
705 inline _LIBCPP_INLINE_VISIBILITY726 _LIBCPP_HIDE_FROM_ABI
706 static constexpr auto __make_value_visitor(_Visitor&& __visitor) {727 static constexpr auto __make_value_visitor(_Visitor&& __visitor) {
707 return __value_visitor_return_type<_Rp, _Visitor>{_VSTD::forward<_Visitor>(__visitor)};728 return __value_visitor_return_type<_Rp, _Visitor>{_VSTD::forward<_Visitor>(__visitor)};
708 }729 }
...@@ -716,7 +737,7 @@ struct _LIBCPP_TEMPLATE_VIS __alt {...@@ -716,7 +737,7 @@ struct _LIBCPP_TEMPLATE_VIS __alt {
716 using __value_type = _Tp;737 using __value_type = _Tp;
717738
718 template <class... _Args>739 template <class... _Args>
719 inline _LIBCPP_INLINE_VISIBILITY740 _LIBCPP_HIDE_FROM_ABI
720 explicit constexpr __alt(in_place_t, _Args&&... __args)741 explicit constexpr __alt(in_place_t, _Args&&... __args)
721 : __value(_VSTD::forward<_Args>(__args)...) {}742 : __value(_VSTD::forward<_Args>(__args)...) {}
722743
...@@ -731,21 +752,21 @@ union _LIBCPP_TEMPLATE_VIS __union<_DestructibleTrait, _Index> {};...@@ -731,21 +752,21 @@ union _LIBCPP_TEMPLATE_VIS __union<_DestructibleTrait, _Index> {};
731752
732#define _LIBCPP_VARIANT_UNION(destructible_trait, destructor) \753#define _LIBCPP_VARIANT_UNION(destructible_trait, destructor) \
733 template <size_t _Index, class _Tp, class... _Types> \754 template <size_t _Index, class _Tp, class... _Types> \
734 union _LIBCPP_TEMPLATE_VIS __union<destructible_trait, \755 union _LIBCPP_TEMPLATE_VIS __union<destructible_trait, \
735 _Index, \756 _Index, \
736 _Tp, \757 _Tp, \
737 _Types...> { \758 _Types...> { \
738 public: \759 public: \
739 inline _LIBCPP_INLINE_VISIBILITY \760 _LIBCPP_HIDE_FROM_ABI \
740 explicit constexpr __union(__valueless_t) noexcept : __dummy{} {} \761 explicit constexpr __union(__valueless_t) noexcept : __dummy{} {} \
741 \762 \
742 template <class... _Args> \763 template <class... _Args> \
743 inline _LIBCPP_INLINE_VISIBILITY \764 _LIBCPP_HIDE_FROM_ABI \
744 explicit constexpr __union(in_place_index_t<0>, _Args&&... __args) \765 explicit constexpr __union(in_place_index_t<0>, _Args&&... __args) \
745 : __head(in_place, _VSTD::forward<_Args>(__args)...) {} \766 : __head(in_place, _VSTD::forward<_Args>(__args)...) {} \
746 \767 \
747 template <size_t _Ip, class... _Args> \768 template <size_t _Ip, class... _Args> \
748 inline _LIBCPP_INLINE_VISIBILITY \769 _LIBCPP_HIDE_FROM_ABI \
749 explicit constexpr __union(in_place_index_t<_Ip>, _Args&&... __args) \770 explicit constexpr __union(in_place_index_t<_Ip>, _Args&&... __args) \
750 : __tail(in_place_index<_Ip - 1>, _VSTD::forward<_Args>(__args)...) {} \771 : __tail(in_place_index<_Ip - 1>, _VSTD::forward<_Args>(__args)...) {} \
751 \772 \
...@@ -776,41 +797,41 @@ class _LIBCPP_TEMPLATE_VIS __base {...@@ -776,41 +797,41 @@ class _LIBCPP_TEMPLATE_VIS __base {
776public:797public:
777 using __index_t = __variant_index_t<sizeof...(_Types)>;798 using __index_t = __variant_index_t<sizeof...(_Types)>;
778799
779 inline _LIBCPP_INLINE_VISIBILITY800 _LIBCPP_HIDE_FROM_ABI
780 explicit constexpr __base(__valueless_t __tag) noexcept801 explicit constexpr __base(__valueless_t __tag) noexcept
781 : __data(__tag), __index(__variant_npos<__index_t>) {}802 : __data(__tag), __index(__variant_npos<__index_t>) {}
782803
783 template <size_t _Ip, class... _Args>804 template <size_t _Ip, class... _Args>
784 inline _LIBCPP_INLINE_VISIBILITY805 _LIBCPP_HIDE_FROM_ABI
785 explicit constexpr __base(in_place_index_t<_Ip>, _Args&&... __args)806 explicit constexpr __base(in_place_index_t<_Ip>, _Args&&... __args)
786 :807 :
787 __data(in_place_index<_Ip>, _VSTD::forward<_Args>(__args)...),808 __data(in_place_index<_Ip>, _VSTD::forward<_Args>(__args)...),
788 __index(_Ip) {}809 __index(_Ip) {}
789810
790 inline _LIBCPP_INLINE_VISIBILITY811 _LIBCPP_HIDE_FROM_ABI
791 constexpr bool valueless_by_exception() const noexcept {812 constexpr bool valueless_by_exception() const noexcept {
792 return index() == variant_npos;813 return index() == variant_npos;
793 }814 }
794815
795 inline _LIBCPP_INLINE_VISIBILITY816 _LIBCPP_HIDE_FROM_ABI
796 constexpr size_t index() const noexcept {817 constexpr size_t index() const noexcept {
797 return __index == __variant_npos<__index_t> ? variant_npos : __index;818 return __index == __variant_npos<__index_t> ? variant_npos : __index;
798 }819 }
799820
800protected:821protected:
801 inline _LIBCPP_INLINE_VISIBILITY822 _LIBCPP_HIDE_FROM_ABI
802 constexpr auto&& __as_base() & { return *this; }823 constexpr auto&& __as_base() & { return *this; }
803824
804 inline _LIBCPP_INLINE_VISIBILITY825 _LIBCPP_HIDE_FROM_ABI
805 constexpr auto&& __as_base() && { return _VSTD::move(*this); }826 constexpr auto&& __as_base() && { return _VSTD::move(*this); }
806827
807 inline _LIBCPP_INLINE_VISIBILITY828 _LIBCPP_HIDE_FROM_ABI
808 constexpr auto&& __as_base() const & { return *this; }829 constexpr auto&& __as_base() const & { return *this; }
809830
810 inline _LIBCPP_INLINE_VISIBILITY831 _LIBCPP_HIDE_FROM_ABI
811 constexpr auto&& __as_base() const && { return _VSTD::move(*this); }832 constexpr auto&& __as_base() const && { return _VSTD::move(*this); }
812833
813 inline _LIBCPP_INLINE_VISIBILITY834 _LIBCPP_HIDE_FROM_ABI
814 static constexpr size_t __size() { return sizeof...(_Types); }835 static constexpr size_t __size() { return sizeof...(_Types); }
815836
816 __union<_DestructibleTrait, 0, _Types...> __data;837 __union<_DestructibleTrait, 0, _Types...> __data;
...@@ -842,7 +863,7 @@ class _LIBCPP_TEMPLATE_VIS __dtor;...@@ -842,7 +863,7 @@ class _LIBCPP_TEMPLATE_VIS __dtor;
842 __dtor& operator=(__dtor&&) = default; \863 __dtor& operator=(__dtor&&) = default; \
843 \864 \
844 protected: \865 protected: \
845 inline _LIBCPP_INLINE_VISIBILITY \866 inline _LIBCPP_HIDE_FROM_ABI \
846 destroy \867 destroy \
847 }868 }
848869
...@@ -858,7 +879,7 @@ _LIBCPP_VARIANT_DESTRUCTOR(...@@ -858,7 +879,7 @@ _LIBCPP_VARIANT_DESTRUCTOR(
858 if (!this->valueless_by_exception()) {879 if (!this->valueless_by_exception()) {
859 __visitation::__base::__visit_alt(880 __visitation::__base::__visit_alt(
860 [](auto& __alt) noexcept {881 [](auto& __alt) noexcept {
861 using __alt_type = __uncvref_t<decltype(__alt)>;882 using __alt_type = __remove_cvref_t<decltype(__alt)>;
862 __alt.~__alt_type();883 __alt.~__alt_type();
863 },884 },
864 *this);885 *this);
...@@ -883,7 +904,7 @@ public:...@@ -883,7 +904,7 @@ public:
883904
884protected:905protected:
885 template <size_t _Ip, class _Tp, class... _Args>906 template <size_t _Ip, class _Tp, class... _Args>
886 inline _LIBCPP_INLINE_VISIBILITY907 _LIBCPP_HIDE_FROM_ABI
887 static _Tp& __construct_alt(__alt<_Ip, _Tp>& __a, _Args&&... __args) {908 static _Tp& __construct_alt(__alt<_Ip, _Tp>& __a, _Args&&... __args) {
888 ::new ((void*)_VSTD::addressof(__a))909 ::new ((void*)_VSTD::addressof(__a))
889 __alt<_Ip, _Tp>(in_place, _VSTD::forward<_Args>(__args)...);910 __alt<_Ip, _Tp>(in_place, _VSTD::forward<_Args>(__args)...);
...@@ -891,7 +912,7 @@ protected:...@@ -891,7 +912,7 @@ protected:
891 }912 }
892913
893 template <class _Rhs>914 template <class _Rhs>
894 inline _LIBCPP_INLINE_VISIBILITY915 _LIBCPP_HIDE_FROM_ABI
895 static void __generic_construct(__ctor& __lhs, _Rhs&& __rhs) {916 static void __generic_construct(__ctor& __lhs, _Rhs&& __rhs) {
896 __lhs.__destroy();917 __lhs.__destroy();
897 if (!__rhs.valueless_by_exception()) {918 if (!__rhs.valueless_by_exception()) {
...@@ -954,7 +975,7 @@ class _LIBCPP_TEMPLATE_VIS __copy_constructor;...@@ -954,7 +975,7 @@ class _LIBCPP_TEMPLATE_VIS __copy_constructor;
954#define _LIBCPP_VARIANT_COPY_CONSTRUCTOR(copy_constructible_trait, \975#define _LIBCPP_VARIANT_COPY_CONSTRUCTOR(copy_constructible_trait, \
955 copy_constructor) \976 copy_constructor) \
956 template <class... _Types> \977 template <class... _Types> \
957 class _LIBCPP_TEMPLATE_VIS __copy_constructor<__traits<_Types...>, \978 class _LIBCPP_TEMPLATE_VIS __copy_constructor<__traits<_Types...>, \
958 copy_constructible_trait> \979 copy_constructible_trait> \
959 : public __move_constructor<__traits<_Types...>> { \980 : public __move_constructor<__traits<_Types...>> { \
960 using __base_type = __move_constructor<__traits<_Types...>>; \981 using __base_type = __move_constructor<__traits<_Types...>>; \
...@@ -996,7 +1017,7 @@ public:...@@ -996,7 +1017,7 @@ public:
996 using __base_type::operator=;1017 using __base_type::operator=;
9971018
998 template <size_t _Ip, class... _Args>1019 template <size_t _Ip, class... _Args>
999 inline _LIBCPP_INLINE_VISIBILITY1020 _LIBCPP_HIDE_FROM_ABI
1000 auto& __emplace(_Args&&... __args) {1021 auto& __emplace(_Args&&... __args) {
1001 this->__destroy();1022 this->__destroy();
1002 auto& __res = this->__construct_alt(__access::__base::__get_alt<_Ip>(*this),1023 auto& __res = this->__construct_alt(__access::__base::__get_alt<_Ip>(*this),
...@@ -1007,7 +1028,7 @@ public:...@@ -1007,7 +1028,7 @@ public:
10071028
1008protected:1029protected:
1009 template <size_t _Ip, class _Tp, class _Arg>1030 template <size_t _Ip, class _Tp, class _Arg>
1010 inline _LIBCPP_INLINE_VISIBILITY1031 _LIBCPP_HIDE_FROM_ABI
1011 void __assign_alt(__alt<_Ip, _Tp>& __a, _Arg&& __arg) {1032 void __assign_alt(__alt<_Ip, _Tp>& __a, _Arg&& __arg) {
1012 if (this->index() == _Ip) {1033 if (this->index() == _Ip) {
1013 __a.__value = _VSTD::forward<_Arg>(__arg);1034 __a.__value = _VSTD::forward<_Arg>(__arg);
...@@ -1028,7 +1049,7 @@ protected:...@@ -1028,7 +1049,7 @@ protected:
1028 }1049 }
10291050
1030 template <class _That>1051 template <class _That>
1031 inline _LIBCPP_INLINE_VISIBILITY1052 _LIBCPP_HIDE_FROM_ABI
1032 void __generic_assign(_That&& __that) {1053 void __generic_assign(_That&& __that) {
1033 if (this->valueless_by_exception() && __that.valueless_by_exception()) {1054 if (this->valueless_by_exception() && __that.valueless_by_exception()) {
1034 // do nothing.1055 // do nothing.
...@@ -1053,7 +1074,7 @@ class _LIBCPP_TEMPLATE_VIS __move_assignment;...@@ -1053,7 +1074,7 @@ class _LIBCPP_TEMPLATE_VIS __move_assignment;
1053#define _LIBCPP_VARIANT_MOVE_ASSIGNMENT(move_assignable_trait, \1074#define _LIBCPP_VARIANT_MOVE_ASSIGNMENT(move_assignable_trait, \
1054 move_assignment) \1075 move_assignment) \
1055 template <class... _Types> \1076 template <class... _Types> \
1056 class _LIBCPP_TEMPLATE_VIS __move_assignment<__traits<_Types...>, \1077 class _LIBCPP_TEMPLATE_VIS __move_assignment<__traits<_Types...>, \
1057 move_assignable_trait> \1078 move_assignable_trait> \
1058 : public __assignment<__traits<_Types...>> { \1079 : public __assignment<__traits<_Types...>> { \
1059 using __base_type = __assignment<__traits<_Types...>>; \1080 using __base_type = __assignment<__traits<_Types...>>; \
...@@ -1094,7 +1115,7 @@ class _LIBCPP_TEMPLATE_VIS __copy_assignment;...@@ -1094,7 +1115,7 @@ class _LIBCPP_TEMPLATE_VIS __copy_assignment;
1094#define _LIBCPP_VARIANT_COPY_ASSIGNMENT(copy_assignable_trait, \1115#define _LIBCPP_VARIANT_COPY_ASSIGNMENT(copy_assignable_trait, \
1095 copy_assignment) \1116 copy_assignment) \
1096 template <class... _Types> \1117 template <class... _Types> \
1097 class _LIBCPP_TEMPLATE_VIS __copy_assignment<__traits<_Types...>, \1118 class _LIBCPP_TEMPLATE_VIS __copy_assignment<__traits<_Types...>, \
1098 copy_assignable_trait> \1119 copy_assignable_trait> \
1099 : public __move_assignment<__traits<_Types...>> { \1120 : public __move_assignment<__traits<_Types...>> { \
1100 using __base_type = __move_assignment<__traits<_Types...>>; \1121 using __base_type = __move_assignment<__traits<_Types...>>; \
...@@ -1140,13 +1161,13 @@ public:...@@ -1140,13 +1161,13 @@ public:
1140 __impl& operator=(__impl&&) = default;1161 __impl& operator=(__impl&&) = default;
11411162
1142 template <size_t _Ip, class _Arg>1163 template <size_t _Ip, class _Arg>
1143 inline _LIBCPP_INLINE_VISIBILITY1164 _LIBCPP_HIDE_FROM_ABI
1144 void __assign(_Arg&& __arg) {1165 void __assign(_Arg&& __arg) {
1145 this->__assign_alt(__access::__base::__get_alt<_Ip>(*this),1166 this->__assign_alt(__access::__base::__get_alt<_Ip>(*this),
1146 _VSTD::forward<_Arg>(__arg));1167 _VSTD::forward<_Arg>(__arg));
1147 }1168 }
11481169
1149 inline _LIBCPP_INLINE_VISIBILITY1170 inline _LIBCPP_HIDE_FROM_ABI
1150 void __swap(__impl& __that) {1171 void __swap(__impl& __that) {
1151 if (this->valueless_by_exception() && __that.valueless_by_exception()) {1172 if (this->valueless_by_exception() && __that.valueless_by_exception()) {
1152 // do nothing.1173 // do nothing.
...@@ -1192,7 +1213,7 @@ public:...@@ -1192,7 +1213,7 @@ public:
1192 }1213 }
11931214
1194private:1215private:
1195 inline _LIBCPP_INLINE_VISIBILITY1216 inline _LIBCPP_HIDE_FROM_ABI
1196 bool __move_nothrow() const {1217 bool __move_nothrow() const {
1197 constexpr bool __results[] = {is_nothrow_move_constructible_v<_Types>...};1218 constexpr bool __results[] = {is_nothrow_move_constructible_v<_Types>...};
1198 return this->valueless_by_exception() || __results[this->index()];1219 return this->valueless_by_exception() || __results[this->index()];
...@@ -1208,7 +1229,7 @@ struct __narrowing_check {...@@ -1208,7 +1229,7 @@ struct __narrowing_check {
1208 template <class _Dest>1229 template <class _Dest>
1209 static auto __test_impl(_Dest (&&)[1]) -> __type_identity<_Dest>;1230 static auto __test_impl(_Dest (&&)[1]) -> __type_identity<_Dest>;
1210 template <class _Dest, class _Source>1231 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>()}));
1212};1233};
12131234
1214template <class _Dest, class _Source>1235template <class _Dest, class _Source>
...@@ -1230,7 +1251,7 @@ struct __overload {...@@ -1230,7 +1251,7 @@ struct __overload {
12301251
1231template <class _Tp, size_t>1252template <class _Tp, size_t>
1232struct __overload_bool {1253struct __overload_bool {
1233 template <class _Up, class _Ap = __uncvref_t<_Up>>1254 template <class _Up, class _Ap = __remove_cvref_t<_Up>>
1234 auto operator()(bool, _Up&&) const1255 auto operator()(bool, _Up&&) const
1235 -> enable_if_t<is_same_v<_Ap, bool>, __type_identity<_Tp>>;1256 -> enable_if_t<is_same_v<_Ap, bool>, __type_identity<_Tp>>;
1236};1257};
...@@ -1298,36 +1319,36 @@ public:...@@ -1298,36 +1319,36 @@ public:
1298 enable_if_t<__dependent_type<is_default_constructible<__first_type>,1319 enable_if_t<__dependent_type<is_default_constructible<__first_type>,
1299 _Dummy>::value,1320 _Dummy>::value,
1300 int> = 0>1321 int> = 0>
1301 inline _LIBCPP_INLINE_VISIBILITY1322 _LIBCPP_HIDE_FROM_ABI
1302 constexpr variant() noexcept(is_nothrow_default_constructible_v<__first_type>)1323 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;1326 constexpr variant(const variant&) = default;
1306 variant(variant&&) = default;1327 constexpr variant(variant&&) = default;
13071328
1308 template <1329 template <
1309 class _Arg,1330 class _Arg,
1310 enable_if_t<!is_same_v<__uncvref_t<_Arg>, variant>, int> = 0,1331 enable_if_t<!is_same_v<__remove_cvref_t<_Arg>, variant>, int> = 0,
1311 enable_if_t<!__is_inplace_type<__uncvref_t<_Arg>>::value, int> = 0,1332 enable_if_t<!__is_inplace_type<__remove_cvref_t<_Arg>>::value, int> = 0,
1312 enable_if_t<!__is_inplace_index<__uncvref_t<_Arg>>::value, int> = 0,1333 enable_if_t<!__is_inplace_index<__remove_cvref_t<_Arg>>::value, int> = 0,
1313 class _Tp = __variant_detail::__best_match_t<_Arg, _Types...>,1334 class _Tp = __variant_detail::__best_match_t<_Arg, _Types...>,
1314 size_t _Ip =1335 size_t _Ip =
1315 __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,1336 __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,
1316 enable_if_t<is_constructible_v<_Tp, _Arg>, int> = 0>1337 enable_if_t<is_constructible_v<_Tp, _Arg>, int> = 0>
1317 inline _LIBCPP_INLINE_VISIBILITY1338 _LIBCPP_HIDE_FROM_ABI
1318 constexpr variant(_Arg&& __arg) noexcept(1339 constexpr variant(_Arg&& __arg) noexcept(
1319 is_nothrow_constructible_v<_Tp, _Arg>)1340 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
1322 template <size_t _Ip, class... _Args,1343 template <size_t _Ip, class... _Args,
1323 class = enable_if_t<(_Ip < sizeof...(_Types)), int>,1344 class = enable_if_t<(_Ip < sizeof...(_Types)), int>,
1324 class _Tp = variant_alternative_t<_Ip, variant<_Types...>>,1345 class _Tp = variant_alternative_t<_Ip, variant<_Types...>>,
1325 enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0>1346 enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0>
1326 inline _LIBCPP_INLINE_VISIBILITY1347 _LIBCPP_HIDE_FROM_ABI
1327 explicit constexpr variant(1348 explicit constexpr variant(
1328 in_place_index_t<_Ip>,1349 in_place_index_t<_Ip>,
1329 _Args&&... __args) noexcept(is_nothrow_constructible_v<_Tp, _Args...>)1350 _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
1332 template <1353 template <
1333 size_t _Ip,1354 size_t _Ip,
...@@ -1337,13 +1358,13 @@ public:...@@ -1337,13 +1358,13 @@ public:
1337 class _Tp = variant_alternative_t<_Ip, variant<_Types...>>,1358 class _Tp = variant_alternative_t<_Ip, variant<_Types...>>,
1338 enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>,1359 enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>,
1339 int> = 0>1360 int> = 0>
1340 inline _LIBCPP_INLINE_VISIBILITY1361 _LIBCPP_HIDE_FROM_ABI
1341 explicit constexpr variant(1362 explicit constexpr variant(
1342 in_place_index_t<_Ip>,1363 in_place_index_t<_Ip>,
1343 initializer_list<_Up> __il,1364 initializer_list<_Up> __il,
1344 _Args&&... __args) noexcept(1365 _Args&&... __args) noexcept(
1345 is_nothrow_constructible_v<_Tp, initializer_list<_Up>&, _Args...>)1366 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
1348 template <1369 template <
1349 class _Tp,1370 class _Tp,
...@@ -1351,10 +1372,10 @@ public:...@@ -1351,10 +1372,10 @@ public:
1351 size_t _Ip =1372 size_t _Ip =
1352 __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,1373 __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,
1353 enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0>1374 enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0>
1354 inline _LIBCPP_INLINE_VISIBILITY1375 _LIBCPP_HIDE_FROM_ABI
1355 explicit constexpr variant(in_place_type_t<_Tp>, _Args&&... __args) noexcept(1376 explicit constexpr variant(in_place_type_t<_Tp>, _Args&&... __args) noexcept(
1356 is_nothrow_constructible_v<_Tp, _Args...>)1377 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
1359 template <1380 template <
1360 class _Tp,1381 class _Tp,
...@@ -1364,32 +1385,32 @@ public:...@@ -1364,32 +1385,32 @@ public:
1364 __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,1385 __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,
1365 enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>,1386 enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>,
1366 int> = 0>1387 int> = 0>
1367 inline _LIBCPP_INLINE_VISIBILITY1388 _LIBCPP_HIDE_FROM_ABI
1368 explicit constexpr variant(1389 explicit constexpr variant(
1369 in_place_type_t<_Tp>,1390 in_place_type_t<_Tp>,
1370 initializer_list<_Up> __il,1391 initializer_list<_Up> __il,
1371 _Args&&... __args) noexcept(1392 _Args&&... __args) noexcept(
1372 is_nothrow_constructible_v<_Tp, initializer_list< _Up>&, _Args...>)1393 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
1375 ~variant() = default;1396 ~variant() = default;
13761397
1377 variant& operator=(const variant&) = default;1398 constexpr variant& operator=(const variant&) = default;
1378 variant& operator=(variant&&) = default;1399 constexpr variant& operator=(variant&&) = default;
13791400
1380 template <1401 template <
1381 class _Arg,1402 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,
1383 class _Tp = __variant_detail::__best_match_t<_Arg, _Types...>,1404 class _Tp = __variant_detail::__best_match_t<_Arg, _Types...>,
1384 size_t _Ip =1405 size_t _Ip =
1385 __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,1406 __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,
1386 enable_if_t<is_assignable_v<_Tp&, _Arg> && is_constructible_v<_Tp, _Arg>,1407 enable_if_t<is_assignable_v<_Tp&, _Arg> && is_constructible_v<_Tp, _Arg>,
1387 int> = 0>1408 int> = 0>
1388 inline _LIBCPP_INLINE_VISIBILITY1409 _LIBCPP_HIDE_FROM_ABI
1389 variant& operator=(_Arg&& __arg) noexcept(1410 variant& operator=(_Arg&& __arg) noexcept(
1390 is_nothrow_assignable_v<_Tp&, _Arg> &&1411 is_nothrow_assignable_v<_Tp&, _Arg> &&
1391 is_nothrow_constructible_v<_Tp, _Arg>) {1412 is_nothrow_constructible_v<_Tp, _Arg>) {
1392 __impl.template __assign<_Ip>(_VSTD::forward<_Arg>(__arg));1413 __impl_.template __assign<_Ip>(_VSTD::forward<_Arg>(__arg));
1393 return *this;1414 return *this;
1394 }1415 }
13951416
...@@ -1399,9 +1420,9 @@ public:...@@ -1399,9 +1420,9 @@ public:
1399 enable_if_t<(_Ip < sizeof...(_Types)), int> = 0,1420 enable_if_t<(_Ip < sizeof...(_Types)), int> = 0,
1400 class _Tp = variant_alternative_t<_Ip, variant<_Types...>>,1421 class _Tp = variant_alternative_t<_Ip, variant<_Types...>>,
1401 enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0>1422 enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0>
1402 inline _LIBCPP_INLINE_VISIBILITY1423 _LIBCPP_HIDE_FROM_ABI
1403 _Tp& emplace(_Args&&... __args) {1424 _Tp& emplace(_Args&&... __args) {
1404 return __impl.template __emplace<_Ip>(_VSTD::forward<_Args>(__args)...);1425 return __impl_.template __emplace<_Ip>(_VSTD::forward<_Args>(__args)...);
1405 }1426 }
14061427
1407 template <1428 template <
...@@ -1412,9 +1433,9 @@ public:...@@ -1412,9 +1433,9 @@ public:
1412 class _Tp = variant_alternative_t<_Ip, variant<_Types...>>,1433 class _Tp = variant_alternative_t<_Ip, variant<_Types...>>,
1413 enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>,1434 enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>,
1414 int> = 0>1435 int> = 0>
1415 inline _LIBCPP_INLINE_VISIBILITY1436 _LIBCPP_HIDE_FROM_ABI
1416 _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) {1437 _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)...);
1418 }1439 }
14191440
1420 template <1441 template <
...@@ -1423,9 +1444,9 @@ public:...@@ -1423,9 +1444,9 @@ public:
1423 size_t _Ip =1444 size_t _Ip =
1424 __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,1445 __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,
1425 enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0>1446 enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0>
1426 inline _LIBCPP_INLINE_VISIBILITY1447 _LIBCPP_HIDE_FROM_ABI
1427 _Tp& emplace(_Args&&... __args) {1448 _Tp& emplace(_Args&&... __args) {
1428 return __impl.template __emplace<_Ip>(_VSTD::forward<_Args>(__args)...);1449 return __impl_.template __emplace<_Ip>(_VSTD::forward<_Args>(__args)...);
1429 }1450 }
14301451
1431 template <1452 template <
...@@ -1436,18 +1457,18 @@ public:...@@ -1436,18 +1457,18 @@ public:
1436 __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,1457 __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,
1437 enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>,1458 enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>,
1438 int> = 0>1459 int> = 0>
1439 inline _LIBCPP_INLINE_VISIBILITY1460 _LIBCPP_HIDE_FROM_ABI
1440 _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) {1461 _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)...);
1442 }1463 }
14431464
1444 inline _LIBCPP_INLINE_VISIBILITY1465 _LIBCPP_HIDE_FROM_ABI
1445 constexpr bool valueless_by_exception() const noexcept {1466 constexpr bool valueless_by_exception() const noexcept {
1446 return __impl.valueless_by_exception();1467 return __impl_.valueless_by_exception();
1447 }1468 }
14481469
1449 inline _LIBCPP_INLINE_VISIBILITY1470 _LIBCPP_HIDE_FROM_ABI
1450 constexpr size_t index() const noexcept { return __impl.index(); }1471 constexpr size_t index() const noexcept { return __impl_.index(); }
14511472
1452 template <1473 template <
1453 bool _Dummy = true,1474 bool _Dummy = true,
...@@ -1456,85 +1477,85 @@ public:...@@ -1456,85 +1477,85 @@ public:
1456 __dependent_type<is_move_constructible<_Types>, _Dummy>::value &&1477 __dependent_type<is_move_constructible<_Types>, _Dummy>::value &&
1457 __dependent_type<is_swappable<_Types>, _Dummy>::value)...>::value,1478 __dependent_type<is_swappable<_Types>, _Dummy>::value)...>::value,
1458 int> = 0>1479 int> = 0>
1459 inline _LIBCPP_INLINE_VISIBILITY1480 _LIBCPP_HIDE_FROM_ABI
1460 void swap(variant& __that) noexcept(1481 void swap(variant& __that) noexcept(
1461 __all<(is_nothrow_move_constructible_v<_Types> &&1482 __all<(is_nothrow_move_constructible_v<_Types> &&
1462 is_nothrow_swappable_v<_Types>)...>::value) {1483 is_nothrow_swappable_v<_Types>)...>::value) {
1463 __impl.__swap(__that.__impl);1484 __impl_.__swap(__that.__impl_);
1464 }1485 }
14651486
1466private:1487private:
1467 __variant_detail::__impl<_Types...> __impl;1488 __variant_detail::__impl<_Types...> __impl_;
14681489
1469 friend struct __variant_detail::__access::__variant;1490 friend struct __variant_detail::__access::__variant;
1470 friend struct __variant_detail::__visitation::__variant;1491 friend struct __variant_detail::__visitation::__variant;
1471};1492};
14721493
1473template <size_t _Ip, class... _Types>1494template <size_t _Ip, class... _Types>
1474inline _LIBCPP_INLINE_VISIBILITY1495_LIBCPP_HIDE_FROM_ABI
1475constexpr bool __holds_alternative(const variant<_Types...>& __v) noexcept {1496constexpr bool __holds_alternative(const variant<_Types...>& __v) noexcept {
1476 return __v.index() == _Ip;1497 return __v.index() == _Ip;
1477}1498}
14781499
1479template <class _Tp, class... _Types>1500template <class _Tp, class... _Types>
1480inline _LIBCPP_INLINE_VISIBILITY1501_LIBCPP_HIDE_FROM_ABI
1481constexpr bool holds_alternative(const variant<_Types...>& __v) noexcept {1502constexpr 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);
1483}1504}
14841505
1485template <size_t _Ip, class _Vp>1506template <size_t _Ip, class _Vp>
1486inline _LIBCPP_INLINE_VISIBILITY1507_LIBCPP_HIDE_FROM_ABI
1487_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS1508_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
1488constexpr auto&& __generic_get(_Vp&& __v) {1509constexpr auto&& __generic_get(_Vp&& __v) {
1489 using __variant_detail::__access::__variant;1510 using __variant_detail::__access::__variant;
1490 if (!__holds_alternative<_Ip>(__v)) {1511 if (!std::__holds_alternative<_Ip>(__v)) {
1491 __throw_bad_variant_access();1512 __throw_bad_variant_access();
1492 }1513 }
1493 return __variant::__get_alt<_Ip>(_VSTD::forward<_Vp>(__v)).__value;1514 return __variant::__get_alt<_Ip>(_VSTD::forward<_Vp>(__v)).__value;
1494}1515}
14951516
1496template <size_t _Ip, class... _Types>1517template <size_t _Ip, class... _Types>
1497inline _LIBCPP_INLINE_VISIBILITY1518_LIBCPP_HIDE_FROM_ABI
1498_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS1519_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
1499constexpr variant_alternative_t<_Ip, variant<_Types...>>& get(1520constexpr variant_alternative_t<_Ip, variant<_Types...>>& get(
1500 variant<_Types...>& __v) {1521 variant<_Types...>& __v) {
1501 static_assert(_Ip < sizeof...(_Types));1522 static_assert(_Ip < sizeof...(_Types));
1502 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);1523 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
1503 return __generic_get<_Ip>(__v);1524 return std::__generic_get<_Ip>(__v);
1504}1525}
15051526
1506template <size_t _Ip, class... _Types>1527template <size_t _Ip, class... _Types>
1507inline _LIBCPP_INLINE_VISIBILITY1528_LIBCPP_HIDE_FROM_ABI
1508_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS1529_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
1509constexpr variant_alternative_t<_Ip, variant<_Types...>>&& get(1530constexpr variant_alternative_t<_Ip, variant<_Types...>>&& get(
1510 variant<_Types...>&& __v) {1531 variant<_Types...>&& __v) {
1511 static_assert(_Ip < sizeof...(_Types));1532 static_assert(_Ip < sizeof...(_Types));
1512 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);1533 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));
1514}1535}
15151536
1516template <size_t _Ip, class... _Types>1537template <size_t _Ip, class... _Types>
1517inline _LIBCPP_INLINE_VISIBILITY1538_LIBCPP_HIDE_FROM_ABI
1518_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS1539_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
1519constexpr const variant_alternative_t<_Ip, variant<_Types...>>& get(1540constexpr const variant_alternative_t<_Ip, variant<_Types...>>& get(
1520 const variant<_Types...>& __v) {1541 const variant<_Types...>& __v) {
1521 static_assert(_Ip < sizeof...(_Types));1542 static_assert(_Ip < sizeof...(_Types));
1522 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);1543 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
1523 return __generic_get<_Ip>(__v);1544 return std::__generic_get<_Ip>(__v);
1524}1545}
15251546
1526template <size_t _Ip, class... _Types>1547template <size_t _Ip, class... _Types>
1527inline _LIBCPP_INLINE_VISIBILITY1548_LIBCPP_HIDE_FROM_ABI
1528_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS1549_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
1529constexpr const variant_alternative_t<_Ip, variant<_Types...>>&& get(1550constexpr const variant_alternative_t<_Ip, variant<_Types...>>&& get(
1530 const variant<_Types...>&& __v) {1551 const variant<_Types...>&& __v) {
1531 static_assert(_Ip < sizeof...(_Types));1552 static_assert(_Ip < sizeof...(_Types));
1532 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);1553 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));
1534}1555}
15351556
1536template <class _Tp, class... _Types>1557template <class _Tp, class... _Types>
1537inline _LIBCPP_INLINE_VISIBILITY1558_LIBCPP_HIDE_FROM_ABI
1538_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS1559_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
1539constexpr _Tp& get(variant<_Types...>& __v) {1560constexpr _Tp& get(variant<_Types...>& __v) {
1540 static_assert(!is_void_v<_Tp>);1561 static_assert(!is_void_v<_Tp>);
...@@ -1542,7 +1563,7 @@ constexpr _Tp& get(variant<_Types...>& __v) {...@@ -1542,7 +1563,7 @@ constexpr _Tp& get(variant<_Types...>& __v) {
1542}1563}
15431564
1544template <class _Tp, class... _Types>1565template <class _Tp, class... _Types>
1545inline _LIBCPP_INLINE_VISIBILITY1566_LIBCPP_HIDE_FROM_ABI
1546_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS1567_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
1547constexpr _Tp&& get(variant<_Types...>&& __v) {1568constexpr _Tp&& get(variant<_Types...>&& __v) {
1548 static_assert(!is_void_v<_Tp>);1569 static_assert(!is_void_v<_Tp>);
...@@ -1551,7 +1572,7 @@ constexpr _Tp&& get(variant<_Types...>&& __v) {...@@ -1551,7 +1572,7 @@ constexpr _Tp&& get(variant<_Types...>&& __v) {
1551}1572}
15521573
1553template <class _Tp, class... _Types>1574template <class _Tp, class... _Types>
1554inline _LIBCPP_INLINE_VISIBILITY1575_LIBCPP_HIDE_FROM_ABI
1555_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS1576_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
1556constexpr const _Tp& get(const variant<_Types...>& __v) {1577constexpr const _Tp& get(const variant<_Types...>& __v) {
1557 static_assert(!is_void_v<_Tp>);1578 static_assert(!is_void_v<_Tp>);
...@@ -1559,7 +1580,7 @@ constexpr const _Tp& get(const variant<_Types...>& __v) {...@@ -1559,7 +1580,7 @@ constexpr const _Tp& get(const variant<_Types...>& __v) {
1559}1580}
15601581
1561template <class _Tp, class... _Types>1582template <class _Tp, class... _Types>
1562inline _LIBCPP_INLINE_VISIBILITY1583_LIBCPP_HIDE_FROM_ABI
1563_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS1584_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
1564constexpr const _Tp&& get(const variant<_Types...>&& __v) {1585constexpr const _Tp&& get(const variant<_Types...>&& __v) {
1565 static_assert(!is_void_v<_Tp>);1586 static_assert(!is_void_v<_Tp>);
...@@ -1568,34 +1589,34 @@ constexpr const _Tp&& get(const variant<_Types...>&& __v) {...@@ -1568,34 +1589,34 @@ constexpr const _Tp&& get(const variant<_Types...>&& __v) {
1568}1589}
15691590
1570template <size_t _Ip, class _Vp>1591template <size_t _Ip, class _Vp>
1571inline _LIBCPP_INLINE_VISIBILITY1592_LIBCPP_HIDE_FROM_ABI
1572constexpr auto* __generic_get_if(_Vp* __v) noexcept {1593constexpr auto* __generic_get_if(_Vp* __v) noexcept {
1573 using __variant_detail::__access::__variant;1594 using __variant_detail::__access::__variant;
1574 return __v && __holds_alternative<_Ip>(*__v)1595 return __v && std::__holds_alternative<_Ip>(*__v)
1575 ? _VSTD::addressof(__variant::__get_alt<_Ip>(*__v).__value)1596 ? _VSTD::addressof(__variant::__get_alt<_Ip>(*__v).__value)
1576 : nullptr;1597 : nullptr;
1577}1598}
15781599
1579template <size_t _Ip, class... _Types>1600template <size_t _Ip, class... _Types>
1580inline _LIBCPP_INLINE_VISIBILITY1601_LIBCPP_HIDE_FROM_ABI
1581constexpr add_pointer_t<variant_alternative_t<_Ip, variant<_Types...>>>1602constexpr add_pointer_t<variant_alternative_t<_Ip, variant<_Types...>>>
1582get_if(variant<_Types...>* __v) noexcept {1603get_if(variant<_Types...>* __v) noexcept {
1583 static_assert(_Ip < sizeof...(_Types));1604 static_assert(_Ip < sizeof...(_Types));
1584 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);1605 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);
1586}1607}
15871608
1588template <size_t _Ip, class... _Types>1609template <size_t _Ip, class... _Types>
1589inline _LIBCPP_INLINE_VISIBILITY1610_LIBCPP_HIDE_FROM_ABI
1590constexpr add_pointer_t<const variant_alternative_t<_Ip, variant<_Types...>>>1611constexpr add_pointer_t<const variant_alternative_t<_Ip, variant<_Types...>>>
1591get_if(const variant<_Types...>* __v) noexcept {1612get_if(const variant<_Types...>* __v) noexcept {
1592 static_assert(_Ip < sizeof...(_Types));1613 static_assert(_Ip < sizeof...(_Types));
1593 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);1614 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);
1595}1616}
15961617
1597template <class _Tp, class... _Types>1618template <class _Tp, class... _Types>
1598inline _LIBCPP_INLINE_VISIBILITY1619_LIBCPP_HIDE_FROM_ABI
1599constexpr add_pointer_t<_Tp>1620constexpr add_pointer_t<_Tp>
1600get_if(variant<_Types...>* __v) noexcept {1621get_if(variant<_Types...>* __v) noexcept {
1601 static_assert(!is_void_v<_Tp>);1622 static_assert(!is_void_v<_Tp>);
...@@ -1603,7 +1624,7 @@ get_if(variant<_Types...>* __v) noexcept {...@@ -1603,7 +1624,7 @@ get_if(variant<_Types...>* __v) noexcept {
1603}1624}
16041625
1605template <class _Tp, class... _Types>1626template <class _Tp, class... _Types>
1606inline _LIBCPP_INLINE_VISIBILITY1627_LIBCPP_HIDE_FROM_ABI
1607constexpr add_pointer_t<const _Tp>1628constexpr add_pointer_t<const _Tp>
1608get_if(const variant<_Types...>* __v) noexcept {1629get_if(const variant<_Types...>* __v) noexcept {
1609 static_assert(!is_void_v<_Tp>);1630 static_assert(!is_void_v<_Tp>);
...@@ -1613,7 +1634,8 @@ get_if(const variant<_Types...>* __v) noexcept {...@@ -1613,7 +1634,8 @@ get_if(const variant<_Types...>* __v) noexcept {
1613template <class _Operator>1634template <class _Operator>
1614struct __convert_to_bool {1635struct __convert_to_bool {
1615 template <class _T1, class _T2>1636 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 {
1617 static_assert(is_convertible<decltype(_Operator{}(_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2))), bool>::value,1639 static_assert(is_convertible<decltype(_Operator{}(_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2))), bool>::value,
1618 "the relational operator does not return a type which is implicitly convertible to bool");1640 "the relational operator does not return a type which is implicitly convertible to bool");
1619 return _Operator{}(_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2));1641 return _Operator{}(_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2));
...@@ -1621,7 +1643,7 @@ struct __convert_to_bool {...@@ -1621,7 +1643,7 @@ struct __convert_to_bool {
1621};1643};
16221644
1623template <class... _Types>1645template <class... _Types>
1624inline _LIBCPP_INLINE_VISIBILITY1646_LIBCPP_HIDE_FROM_ABI
1625constexpr bool operator==(const variant<_Types...>& __lhs,1647constexpr bool operator==(const variant<_Types...>& __lhs,
1626 const variant<_Types...>& __rhs) {1648 const variant<_Types...>& __rhs) {
1627 using __variant_detail::__visitation::__variant;1649 using __variant_detail::__visitation::__variant;
...@@ -1630,8 +1652,29 @@ constexpr bool operator==(const variant<_Types...>& __lhs,...@@ -1630,8 +1652,29 @@ constexpr bool operator==(const variant<_Types...>& __lhs,
1630 return __variant::__visit_value_at(__lhs.index(), __convert_to_bool<equal_to<>>{}, __lhs, __rhs);1652 return __variant::__visit_value_at(__lhs.index(), __convert_to_bool<equal_to<>>{}, __lhs, __rhs);
1631}1653}
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
1633template <class... _Types>1676template <class... _Types>
1634inline _LIBCPP_INLINE_VISIBILITY1677_LIBCPP_HIDE_FROM_ABI
1635constexpr bool operator!=(const variant<_Types...>& __lhs,1678constexpr bool operator!=(const variant<_Types...>& __lhs,
1636 const variant<_Types...>& __rhs) {1679 const variant<_Types...>& __rhs) {
1637 using __variant_detail::__visitation::__variant;1680 using __variant_detail::__visitation::__variant;
...@@ -1642,7 +1685,7 @@ constexpr bool operator!=(const variant<_Types...>& __lhs,...@@ -1642,7 +1685,7 @@ constexpr bool operator!=(const variant<_Types...>& __lhs,
1642}1685}
16431686
1644template <class... _Types>1687template <class... _Types>
1645inline _LIBCPP_INLINE_VISIBILITY1688_LIBCPP_HIDE_FROM_ABI
1646constexpr bool operator<(const variant<_Types...>& __lhs,1689constexpr bool operator<(const variant<_Types...>& __lhs,
1647 const variant<_Types...>& __rhs) {1690 const variant<_Types...>& __rhs) {
1648 using __variant_detail::__visitation::__variant;1691 using __variant_detail::__visitation::__variant;
...@@ -1654,7 +1697,7 @@ constexpr bool operator<(const variant<_Types...>& __lhs,...@@ -1654,7 +1697,7 @@ constexpr bool operator<(const variant<_Types...>& __lhs,
1654}1697}
16551698
1656template <class... _Types>1699template <class... _Types>
1657inline _LIBCPP_INLINE_VISIBILITY1700_LIBCPP_HIDE_FROM_ABI
1658constexpr bool operator>(const variant<_Types...>& __lhs,1701constexpr bool operator>(const variant<_Types...>& __lhs,
1659 const variant<_Types...>& __rhs) {1702 const variant<_Types...>& __rhs) {
1660 using __variant_detail::__visitation::__variant;1703 using __variant_detail::__visitation::__variant;
...@@ -1666,7 +1709,7 @@ constexpr bool operator>(const variant<_Types...>& __lhs,...@@ -1666,7 +1709,7 @@ constexpr bool operator>(const variant<_Types...>& __lhs,
1666}1709}
16671710
1668template <class... _Types>1711template <class... _Types>
1669inline _LIBCPP_INLINE_VISIBILITY1712_LIBCPP_HIDE_FROM_ABI
1670constexpr bool operator<=(const variant<_Types...>& __lhs,1713constexpr bool operator<=(const variant<_Types...>& __lhs,
1671 const variant<_Types...>& __rhs) {1714 const variant<_Types...>& __rhs) {
1672 using __variant_detail::__visitation::__variant;1715 using __variant_detail::__visitation::__variant;
...@@ -1679,7 +1722,7 @@ constexpr bool operator<=(const variant<_Types...>& __lhs,...@@ -1679,7 +1722,7 @@ constexpr bool operator<=(const variant<_Types...>& __lhs,
1679}1722}
16801723
1681template <class... _Types>1724template <class... _Types>
1682inline _LIBCPP_INLINE_VISIBILITY1725_LIBCPP_HIDE_FROM_ABI
1683constexpr bool operator>=(const variant<_Types...>& __lhs,1726constexpr bool operator>=(const variant<_Types...>& __lhs,
1684 const variant<_Types...>& __rhs) {1727 const variant<_Types...>& __rhs) {
1685 using __variant_detail::__visitation::__variant;1728 using __variant_detail::__visitation::__variant;
...@@ -1692,9 +1735,9 @@ constexpr bool operator>=(const variant<_Types...>& __lhs,...@@ -1692,9 +1735,9 @@ constexpr bool operator>=(const variant<_Types...>& __lhs,
1692}1735}
16931736
1694template <class... _Vs>1737template <class... _Vs>
1695inline _LIBCPP_INLINE_VISIBILITY1738_LIBCPP_HIDE_FROM_ABI
1696 _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr void1739_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
1697 __throw_if_valueless(_Vs&&... __vs) {1740constexpr void __throw_if_valueless(_Vs&&... __vs) {
1698 const bool __valueless =1741 const bool __valueless =
1699 (... || _VSTD::__as_variant(__vs).valueless_by_exception());1742 (... || _VSTD::__as_variant(__vs).valueless_by_exception());
1700 if (__valueless) {1743 if (__valueless) {
...@@ -1704,10 +1747,10 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -1704,10 +1747,10 @@ inline _LIBCPP_INLINE_VISIBILITY
17041747
1705template <1748template <
1706 class _Visitor, class... _Vs,1749 class _Visitor, class... _Vs,
1707 typename = void_t<decltype(_VSTD::__as_variant(declval<_Vs>()))...> >1750 typename = void_t<decltype(_VSTD::__as_variant(std::declval<_Vs>()))...> >
1708inline _LIBCPP_INLINE_VISIBILITY1751_LIBCPP_HIDE_FROM_ABI
1709 _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr1752_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
1710 decltype(auto) visit(_Visitor&& __visitor, _Vs&&... __vs) {1753constexpr decltype(auto) visit(_Visitor&& __visitor, _Vs&&... __vs) {
1711 using __variant_detail::__visitation::__variant;1754 using __variant_detail::__visitation::__variant;
1712 _VSTD::__throw_if_valueless(_VSTD::forward<_Vs>(__vs)...);1755 _VSTD::__throw_if_valueless(_VSTD::forward<_Vs>(__vs)...);
1713 return __variant::__visit_value(_VSTD::forward<_Visitor>(__visitor),1756 return __variant::__visit_value(_VSTD::forward<_Visitor>(__visitor),
...@@ -1717,10 +1760,10 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -1717,10 +1760,10 @@ inline _LIBCPP_INLINE_VISIBILITY
1717#if _LIBCPP_STD_VER > 171760#if _LIBCPP_STD_VER > 17
1718template <1761template <
1719 class _Rp, class _Visitor, class... _Vs,1762 class _Rp, class _Visitor, class... _Vs,
1720 typename = void_t<decltype(_VSTD::__as_variant(declval<_Vs>()))...> >1763 typename = void_t<decltype(_VSTD::__as_variant(std::declval<_Vs>()))...> >
1721inline _LIBCPP_INLINE_VISIBILITY1764_LIBCPP_HIDE_FROM_ABI
1722 _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Rp1765_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
1723 visit(_Visitor&& __visitor, _Vs&&... __vs) {1766constexpr _Rp visit(_Visitor&& __visitor, _Vs&&... __vs) {
1724 using __variant_detail::__visitation::__variant;1767 using __variant_detail::__visitation::__variant;
1725 _VSTD::__throw_if_valueless(_VSTD::forward<_Vs>(__vs)...);1768 _VSTD::__throw_if_valueless(_VSTD::forward<_Vs>(__vs)...);
1726 return __variant::__visit_value<_Rp>(_VSTD::forward<_Visitor>(__visitor),1769 return __variant::__visit_value<_Rp>(_VSTD::forward<_Visitor>(__visitor),
...@@ -1729,7 +1772,7 @@ inline _LIBCPP_INLINE_VISIBILITY...@@ -1729,7 +1772,7 @@ inline _LIBCPP_INLINE_VISIBILITY
1729#endif1772#endif
17301773
1731template <class... _Types>1774template <class... _Types>
1732inline _LIBCPP_INLINE_VISIBILITY1775_LIBCPP_HIDE_FROM_ABI
1733auto swap(variant<_Types...>& __lhs, variant<_Types...>& __rhs)1776auto swap(variant<_Types...>& __lhs, variant<_Types...>& __rhs)
1734 noexcept(noexcept(__lhs.swap(__rhs)))1777 noexcept(noexcept(__lhs.swap(__rhs)))
1735 -> decltype( __lhs.swap(__rhs))1778 -> decltype( __lhs.swap(__rhs))
...@@ -1741,7 +1784,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<...@@ -1741,7 +1784,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<
1741 using argument_type = variant<_Types...>;1784 using argument_type = variant<_Types...>;
1742 using result_type = size_t;1785 using result_type = size_t;
17431786
1744 inline _LIBCPP_INLINE_VISIBILITY1787 _LIBCPP_HIDE_FROM_ABI
1745 result_type operator()(const argument_type& __v) const {1788 result_type operator()(const argument_type& __v) const {
1746 using __variant_detail::__visitation::__variant;1789 using __variant_detail::__visitation::__variant;
1747 size_t __res =1790 size_t __res =
...@@ -1749,13 +1792,13 @@ struct _LIBCPP_TEMPLATE_VIS hash<...@@ -1749,13 +1792,13 @@ struct _LIBCPP_TEMPLATE_VIS hash<
1749 ? 299792458 // Random value chosen by the universe upon creation1792 ? 299792458 // Random value chosen by the universe upon creation
1750 : __variant::__visit_alt(1793 : __variant::__visit_alt(
1751 [](const auto& __alt) {1794 [](const auto& __alt) {
1752 using __alt_type = __uncvref_t<decltype(__alt)>;1795 using __alt_type = __remove_cvref_t<decltype(__alt)>;
1753 using __value_type = remove_const_t<1796 using __value_type = remove_const_t<
1754 typename __alt_type::__value_type>;1797 typename __alt_type::__value_type>;
1755 return hash<__value_type>{}(__alt.__value);1798 return hash<__value_type>{}(__alt.__value);
1756 },1799 },
1757 __v);1800 __v);
1758 return __hash_combine(__res, hash<size_t>{}(__v.index()));1801 return std::__hash_combine(__res, hash<size_t>{}(__v.index()));
1759 }1802 }
1760};1803};
17611804
...@@ -1763,22 +1806,22 @@ struct _LIBCPP_TEMPLATE_VIS hash<...@@ -1763,22 +1806,22 @@ struct _LIBCPP_TEMPLATE_VIS hash<
1763// type whereas std::get will throw or returning nullptr. This makes it faster than1806// type whereas std::get will throw or returning nullptr. This makes it faster than
1764// std::get.1807// std::get.
1765template <size_t _Ip, class _Vp>1808template <size_t _Ip, class _Vp>
1766inline _LIBCPP_INLINE_VISIBILITY1809_LIBCPP_HIDE_FROM_ABI
1767constexpr auto&& __unchecked_get(_Vp&& __v) noexcept {1810constexpr auto&& __unchecked_get(_Vp&& __v) noexcept {
1768 using __variant_detail::__access::__variant;1811 using __variant_detail::__access::__variant;
1769 return __variant::__get_alt<_Ip>(_VSTD::forward<_Vp>(__v)).__value;1812 return __variant::__get_alt<_Ip>(_VSTD::forward<_Vp>(__v)).__value;
1770}1813}
17711814
1772template <class _Tp, class... _Types>1815template <class _Tp, class... _Types>
1773inline _LIBCPP_INLINE_VISIBILITY1816_LIBCPP_HIDE_FROM_ABI
1774constexpr auto&& __unchecked_get(const variant<_Types...>& __v) noexcept {1817constexpr 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);
1776}1819}
17771820
1778template <class _Tp, class... _Types>1821template <class _Tp, class... _Types>
1779inline _LIBCPP_INLINE_VISIBILITY1822_LIBCPP_HIDE_FROM_ABI
1780constexpr auto&& __unchecked_get(variant<_Types...>& __v) noexcept {1823constexpr 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);
1782}1825}
17831826
1784#endif // _LIBCPP_STD_VER > 141827#endif // _LIBCPP_STD_VER > 14
...@@ -1787,4 +1830,10 @@ _LIBCPP_END_NAMESPACE_STD...@@ -1787,4 +1830,10 @@ _LIBCPP_END_NAMESPACE_STD
17871830
1788_LIBCPP_POP_MACROS1831_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
1790#endif // _LIBCPP_VARIANT1839#endif // _LIBCPP_VARIANT
lib/libcxx/include/vector+691-648
...@@ -267,6 +267,13 @@ template <class T, class Allocator, class Predicate>...@@ -267,6 +267,13 @@ template <class T, class Allocator, class Predicate>
267typename vector<T, Allocator>::size_type267typename vector<T, Allocator>::size_type
268erase_if(vector<T, Allocator>& c, Predicate pred); // C++20268erase_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
270} // std277} // std
271278
272*/279*/
...@@ -281,9 +288,11 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20...@@ -281,9 +288,11 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
281#include <__algorithm/unwrap_iter.h>288#include <__algorithm/unwrap_iter.h>
282#include <__assert> // all public C++ headers provide the assertion handler289#include <__assert> // all public C++ headers provide the assertion handler
283#include <__bit_reference>290#include <__bit_reference>
291#include <__concepts/same_as.h>
284#include <__config>292#include <__config>
285#include <__debug>293#include <__debug>
286#include <__format/enable_insertable.h>294#include <__format/enable_insertable.h>
295#include <__format/formatter.h>
287#include <__functional/hash.h>296#include <__functional/hash.h>
288#include <__functional/unary_function.h>297#include <__functional/unary_function.h>
289#include <__iterator/advance.h>298#include <__iterator/advance.h>
...@@ -293,7 +302,13 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20...@@ -293,7 +302,13 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
293#include <__memory/allocate_at_least.h>302#include <__memory/allocate_at_least.h>
294#include <__memory/pointer_traits.h>303#include <__memory/pointer_traits.h>
295#include <__memory/swap_allocator.h>304#include <__memory/swap_allocator.h>
305#include <__memory/temp_value.h>
306#include <__memory/uninitialized_algorithms.h>
307#include <__memory_resource/polymorphic_allocator.h>
296#include <__split_buffer>308#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>
297#include <__utility/forward.h>312#include <__utility/forward.h>
298#include <__utility/move.h>313#include <__utility/move.h>
299#include <__utility/swap.h>314#include <__utility/swap.h>
...@@ -302,17 +317,10 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20...@@ -302,17 +317,10 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
302#include <cstring>317#include <cstring>
303#include <iosfwd> // for forward declaration of vector318#include <iosfwd> // for forward declaration of vector
304#include <limits>319#include <limits>
305#include <memory>
306#include <stdexcept>320#include <stdexcept>
307#include <type_traits>321#include <type_traits>
308#include <version>322#include <version>
309323
310#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
311# include <algorithm>
312# include <typeinfo>
313# include <utility>
314#endif
315
316// standard-mandated includes324// standard-mandated includes
317325
318// [iterator.range]326// [iterator.range]
...@@ -352,20 +360,25 @@ public:...@@ -352,20 +360,25 @@ public:
352 typedef typename __alloc_traits::difference_type difference_type;360 typedef typename __alloc_traits::difference_type difference_type;
353 typedef typename __alloc_traits::pointer pointer;361 typedef typename __alloc_traits::pointer pointer;
354 typedef typename __alloc_traits::const_pointer const_pointer;362 typedef typename __alloc_traits::const_pointer const_pointer;
363 // TODO: Implement iterator bounds checking without requiring the global database.
355 typedef __wrap_iter<pointer> iterator;364 typedef __wrap_iter<pointer> iterator;
356 typedef __wrap_iter<const_pointer> const_iterator;365 typedef __wrap_iter<const_pointer> const_iterator;
357 typedef _VSTD::reverse_iterator<iterator> reverse_iterator;366 typedef std::reverse_iterator<iterator> reverse_iterator;
358 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;367 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
359368
360 static_assert((is_same<typename allocator_type::value_type, value_type>::value),369 static_assert((is_same<typename allocator_type::value_type, value_type>::value),
361 "Allocator::value_type must be same type as value_type");370 "Allocator::value_type must be same type as value_type");
362371
363 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY372 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
364 vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)377 vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
365 {378 {
366 _VSTD::__debug_db_insert_c(this);379 std::__debug_db_insert_c(this);
367 }380 }
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)
369#if _LIBCPP_STD_VER <= 14382#if _LIBCPP_STD_VER <= 14
370 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)383 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
371#else384#else
...@@ -373,20 +386,20 @@ public:...@@ -373,20 +386,20 @@ public:
373#endif386#endif
374 : __end_cap_(nullptr, __a)387 : __end_cap_(nullptr, __a)
375 {388 {
376 _VSTD::__debug_db_insert_c(this);389 std::__debug_db_insert_c(this);
377 }390 }
378 _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n);391 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n);
379#if _LIBCPP_STD_VER > 11392#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);
381#endif394#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
384 template <class = __enable_if_t<__is_allocator<_Allocator>::value> >397 template <class = __enable_if_t<__is_allocator<_Allocator>::value> >
385 _LIBCPP_CONSTEXPR_AFTER_CXX17398 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
386 vector(size_type __n, const value_type& __x, const allocator_type& __a)399 vector(size_type __n, const value_type& __x, const allocator_type& __a)
387 : __end_cap_(nullptr, __a)400 : __end_cap_(nullptr, __a)
388 {401 {
389 _VSTD::__debug_db_insert_c(this);402 std::__debug_db_insert_c(this);
390 if (__n > 0)403 if (__n > 0)
391 {404 {
392 __vallocate(__n);405 __vallocate(__n);
...@@ -394,68 +407,72 @@ public:...@@ -394,68 +407,72 @@ public:
394 }407 }
395 }408 }
396409
397 template <class _InputIterator>410 template <class _InputIterator,
398 _LIBCPP_CONSTEXPR_AFTER_CXX17411 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
399 vector(_InputIterator __first,412 is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value,
400 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&413 int> = 0>
401 is_constructible<414 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_InputIterator __first, _InputIterator __last);
402 value_type,415 template <class _InputIterator,
403 typename iterator_traits<_InputIterator>::reference>::value,416 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
404 _InputIterator>::type __last);417 is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value,
405 template <class _InputIterator>418 int> = 0>
406 _LIBCPP_CONSTEXPR_AFTER_CXX17419 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
407 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,420 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a);
408 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&421
409 is_constructible<422 template <
410 value_type,423 class _ForwardIterator,
411 typename iterator_traits<_InputIterator>::reference>::value>::type* = 0);424 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
412 template <class _ForwardIterator>425 is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value,
413 _LIBCPP_CONSTEXPR_AFTER_CXX17426 int> = 0>
414 vector(_ForwardIterator __first,427 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_ForwardIterator __first, _ForwardIterator __last);
415 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&428
416 is_constructible<429 template <class _ForwardIterator,
417 value_type,430 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
418 typename iterator_traits<_ForwardIterator>::reference>::value,431 is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value,
419 _ForwardIterator>::type __last);432 int> = 0>
420 template <class _ForwardIterator>433 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
421 _LIBCPP_CONSTEXPR_AFTER_CXX17434 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a);
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);
427435
428 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY436private:
429 ~vector()437 class __destroy_vector {
430 {438 public:
431 __annotate_delete();439 _LIBCPP_CONSTEXPR __destroy_vector(vector& __vec) : __vec_(__vec) {}
432 std::__debug_db_erase_c(this);
433440
434 if (this->__begin_ != nullptr)441 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void operator()() {
435 {442 __vec_.__annotate_delete();
436 __clear();443 std::__debug_db_erase_c(std::addressof(__vec_));
437 __alloc_traits::deallocate(__alloc(), this->__begin_, capacity());444
445 if (__vec_.__begin_ != nullptr) {
446 __vec_.__clear();
447 __alloc_traits::deallocate(__vec_.__alloc(), __vec_.__begin_, __vec_.capacity());
448 }
438 }449 }
439 }
440450
441 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __x);451 private:
442 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __x, const __type_identity_t<allocator_type>& __a);452 vector& __vec_;
443 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY453 };
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
444 vector& operator=(const vector& __x);461 vector& operator=(const vector& __x);
445462
446#ifndef _LIBCPP_CXX03_LANG463#ifndef _LIBCPP_CXX03_LANG
447 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY464 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
448 vector(initializer_list<value_type> __il);465 vector(initializer_list<value_type> __il);
449466
450 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY467 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
451 vector(initializer_list<value_type> __il, const allocator_type& __a);468 vector(initializer_list<value_type> __il, const allocator_type& __a);
452469
453 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY470 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
454 vector& operator=(initializer_list<value_type> __il)471 vector& operator=(initializer_list<value_type> __il)
455 {assign(__il.begin(), __il.end()); return *this;}472 {assign(__il.begin(), __il.end()); return *this;}
456#endif // !_LIBCPP_CXX03_LANG473#endif // !_LIBCPP_CXX03_LANG
457474
458 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY475 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
459 vector(vector&& __x)476 vector(vector&& __x)
460#if _LIBCPP_STD_VER > 14477#if _LIBCPP_STD_VER > 14
461 noexcept;478 noexcept;
...@@ -463,174 +480,163 @@ public:...@@ -463,174 +480,163 @@ public:
463 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);480 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
464#endif481#endif
465482
466 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY483 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
467 vector(vector&& __x, const __type_identity_t<allocator_type>& __a);484 vector(vector&& __x, const __type_identity_t<allocator_type>& __a);
468 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY485 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
469 vector& operator=(vector&& __x)486 vector& operator=(vector&& __x)
470 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));487 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
471488
472 template <class _InputIterator>489 template <class _InputIterator,
473 _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&490 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
474 is_constructible<491 is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value,
475 value_type,492 int> = 0>
476 typename iterator_traits<_InputIterator>::reference>::value,493 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(_InputIterator __first, _InputIterator __last);
477 void494 template <
478 >::type495 class _ForwardIterator,
479 assign(_InputIterator __first, _InputIterator __last);496 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
480 template <class _ForwardIterator>497 is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value,
481 _LIBCPP_CONSTEXPR_AFTER_CXX17498 int> = 0>
482 typename enable_if499 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(_ForwardIterator __first, _ForwardIterator __last);
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);
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
494#ifndef _LIBCPP_CXX03_LANG503#ifndef _LIBCPP_CXX03_LANG
495 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY504 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
496 void assign(initializer_list<value_type> __il)505 void assign(initializer_list<value_type> __il)
497 {assign(__il.begin(), __il.end());}506 {assign(__il.begin(), __il.end());}
498#endif507#endif
499508
500 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY509 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
501 allocator_type get_allocator() const _NOEXCEPT510 allocator_type get_allocator() const _NOEXCEPT
502 {return this->__alloc();}511 {return this->__alloc();}
503512
504 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT;513 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT;
505 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT;514 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT;
506 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT;515 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT;
507 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT;516 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT;
508517
509 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY518 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
510 reverse_iterator rbegin() _NOEXCEPT519 reverse_iterator rbegin() _NOEXCEPT
511 {return reverse_iterator(end());}520 {return reverse_iterator(end());}
512 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY521 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
513 const_reverse_iterator rbegin() const _NOEXCEPT522 const_reverse_iterator rbegin() const _NOEXCEPT
514 {return const_reverse_iterator(end());}523 {return const_reverse_iterator(end());}
515 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY524 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
516 reverse_iterator rend() _NOEXCEPT525 reverse_iterator rend() _NOEXCEPT
517 {return reverse_iterator(begin());}526 {return reverse_iterator(begin());}
518 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY527 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
519 const_reverse_iterator rend() const _NOEXCEPT528 const_reverse_iterator rend() const _NOEXCEPT
520 {return const_reverse_iterator(begin());}529 {return const_reverse_iterator(begin());}
521530
522 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY531 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
523 const_iterator cbegin() const _NOEXCEPT532 const_iterator cbegin() const _NOEXCEPT
524 {return begin();}533 {return begin();}
525 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY534 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
526 const_iterator cend() const _NOEXCEPT535 const_iterator cend() const _NOEXCEPT
527 {return end();}536 {return end();}
528 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY537 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
529 const_reverse_iterator crbegin() const _NOEXCEPT538 const_reverse_iterator crbegin() const _NOEXCEPT
530 {return rbegin();}539 {return rbegin();}
531 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY540 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
532 const_reverse_iterator crend() const _NOEXCEPT541 const_reverse_iterator crend() const _NOEXCEPT
533 {return rend();}542 {return rend();}
534543
535 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY544 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
536 size_type size() const _NOEXCEPT545 size_type size() const _NOEXCEPT
537 {return static_cast<size_type>(this->__end_ - this->__begin_);}546 {return static_cast<size_type>(this->__end_ - this->__begin_);}
538 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY547 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
539 size_type capacity() const _NOEXCEPT548 size_type capacity() const _NOEXCEPT
540 {return static_cast<size_type>(__end_cap() - this->__begin_);}549 {return static_cast<size_type>(__end_cap() - this->__begin_);}
541 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY550 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
542 bool empty() const _NOEXCEPT551 bool empty() const _NOEXCEPT
543 {return this->__begin_ == this->__end_;}552 {return this->__begin_ == this->__end_;}
544 _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT;553 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT;
545 _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n);554 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n);
546 _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT;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;557 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __n) _NOEXCEPT;
549 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const _NOEXCEPT;558 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __n) const _NOEXCEPT;
550 _LIBCPP_CONSTEXPR_AFTER_CXX17 reference at(size_type __n);559 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference at(size_type __n);
551 _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference at(size_type __n) const;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() _NOEXCEPT562 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() _NOEXCEPT
554 {563 {
555 _LIBCPP_ASSERT(!empty(), "front() called on an empty vector");564 _LIBCPP_ASSERT(!empty(), "front() called on an empty vector");
556 return *this->__begin_;565 return *this->__begin_;
557 }566 }
558 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT567 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const _NOEXCEPT
559 {568 {
560 _LIBCPP_ASSERT(!empty(), "front() called on an empty vector");569 _LIBCPP_ASSERT(!empty(), "front() called on an empty vector");
561 return *this->__begin_;570 return *this->__begin_;
562 }571 }
563 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference back() _NOEXCEPT572 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() _NOEXCEPT
564 {573 {
565 _LIBCPP_ASSERT(!empty(), "back() called on an empty vector");574 _LIBCPP_ASSERT(!empty(), "back() called on an empty vector");
566 return *(this->__end_ - 1);575 return *(this->__end_ - 1);
567 }576 }
568 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference back() const _NOEXCEPT577 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT
569 {578 {
570 _LIBCPP_ASSERT(!empty(), "back() called on an empty vector");579 _LIBCPP_ASSERT(!empty(), "back() called on an empty vector");
571 return *(this->__end_ - 1);580 return *(this->__end_ - 1);
572 }581 }
573582
574 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY583 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
575 value_type* data() _NOEXCEPT584 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_VISIBILITY587 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
579 const value_type* data() const _NOEXCEPT588 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
586 template <class... _Args>595 template <class... _Args>
587 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY596 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
588#if _LIBCPP_STD_VER > 14597#if _LIBCPP_STD_VER > 14
589 reference emplace_back(_Args&&... __args);598 reference emplace_back(_Args&&... __args);
590#else599#else
591 void emplace_back(_Args&&... __args);600 void emplace_back(_Args&&... __args);
592#endif601#endif
593602
594 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY603 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
595 void pop_back();604 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);
600 template <class... _Args>609 template <class... _Args>
601 _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator emplace(const_iterator __position, _Args&&... __args);610 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __position, _Args&&... __args);
602611
603 _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, size_type __n, const_reference __x);612 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
604 template <class _InputIterator>613 iterator insert(const_iterator __position, size_type __n, const_reference __x);
605 _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&614
606 is_constructible<615 template <class _InputIterator,
607 value_type,616 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
608 typename iterator_traits<_InputIterator>::reference>::value,617 is_constructible< value_type, typename iterator_traits<_InputIterator>::reference>::value,
609 iterator618 int> = 0>
610 >::type619 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
611 insert(const_iterator __position, _InputIterator __first, _InputIterator __last);620 insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
612 template <class _ForwardIterator>621
613 _LIBCPP_CONSTEXPR_AFTER_CXX17622 template <
614 typename enable_if623 class _ForwardIterator,
615 <624 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
616 __is_cpp17_forward_iterator<_ForwardIterator>::value &&625 is_constructible< value_type, typename iterator_traits<_ForwardIterator>::reference>::value,
617 is_constructible<626 int> = 0>
618 value_type,627 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
619 typename iterator_traits<_ForwardIterator>::reference>::value,628 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
620 iterator
621 >::type
622 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
623629
624#ifndef _LIBCPP_CXX03_LANG630#ifndef _LIBCPP_CXX03_LANG
625 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY631 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
626 iterator insert(const_iterator __position, initializer_list<value_type> __il)632 iterator insert(const_iterator __position, initializer_list<value_type> __il)
627 {return insert(__position, __il.begin(), __il.end());}633 {return insert(__position, __il.begin(), __il.end());}
628#endif634#endif
629635
630 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);636 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __position);
631 _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __first, const_iterator __last);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_VISIBILITY639 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
634 void clear() _NOEXCEPT640 void clear() _NOEXCEPT
635 {641 {
636 size_type __old_size = size();642 size_type __old_size = size();
...@@ -639,10 +645,10 @@ public:...@@ -639,10 +645,10 @@ public:
639 std::__debug_db_invalidate_all(this);645 std::__debug_db_invalidate_all(this);
640 }646 }
641647
642 _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __sz);648 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void resize(size_type __sz);
643 _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __sz, const_reference __x);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&)
646#if _LIBCPP_STD_VER >= 14652#if _LIBCPP_STD_VER >= 14
647 _NOEXCEPT;653 _NOEXCEPT;
648#else654#else
...@@ -650,7 +656,7 @@ public:...@@ -650,7 +656,7 @@ public:
650 __is_nothrow_swappable<allocator_type>::value);656 __is_nothrow_swappable<allocator_type>::value);
651#endif657#endif
652658
653 _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const;659 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const;
654660
655#ifdef _LIBCPP_ENABLE_DEBUG_MODE661#ifdef _LIBCPP_ENABLE_DEBUG_MODE
656662
...@@ -667,7 +673,7 @@ private:...@@ -667,7 +673,7 @@ private:
667 __compressed_pair<pointer, allocator_type> __end_cap_ =673 __compressed_pair<pointer, allocator_type> __end_cap_ =
668 __compressed_pair<pointer, allocator_type>(nullptr, __default_init_tag());674 __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
672 // Allocate space for __n objects678 // Allocate space for __n objects
673 // throws length_error if __n > max_size()679 // throws length_error if __n > max_size()
...@@ -676,7 +682,7 @@ private:...@@ -676,7 +682,7 @@ private:
676 // Precondition: __n > 0682 // Precondition: __n > 0
677 // Postcondition: capacity() >= __n683 // Postcondition: capacity() >= __n
678 // Postcondition: size() == 0684 // 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) {
680 if (__n > max_size())686 if (__n > max_size())
681 __throw_length_error();687 __throw_length_error();
682 auto __allocation = std::__allocate_at_least(__alloc(), __n);688 auto __allocation = std::__allocate_at_least(__alloc(), __n);
...@@ -686,33 +692,30 @@ private:...@@ -686,33 +692,30 @@ private:
686 __annotate_new(0);692 __annotate_new(0);
687 }693 }
688694
689 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vdeallocate() _NOEXCEPT;695 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vdeallocate() _NOEXCEPT;
690 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;696 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __recommend(size_type __new_size) const;
691 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n);697 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n);
692 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY698 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
693 void __construct_at_end(size_type __n, const_reference __x);699 void __construct_at_end(size_type __n, const_reference __x);
694 template <class _ForwardIterator>700
695 _LIBCPP_CONSTEXPR_AFTER_CXX17701 template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value, int> = 0>
696 typename enable_if702 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
697 <703 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n);
698 __is_cpp17_forward_iterator<_ForwardIterator>::value,704
699 void705 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n);
700 >::type706 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n, const_reference __x);
701 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n);707 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
702 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n);708 iterator __make_iter(pointer __p) _NOEXCEPT { return iterator(this, __p); }
703 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n, const_reference __x);709 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
704 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY710 const_iterator __make_iter(const_pointer __p) const _NOEXCEPT { return const_iterator(this, __p); }
705 iterator __make_iter(pointer __p) _NOEXCEPT;711 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v);
706 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY712 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p);
707 const_iterator __make_iter(const_pointer __p) const _NOEXCEPT;713 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_range(pointer __from_s, pointer __from_e, pointer __to);
708 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v);714 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, true_type)
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)
712 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);715 _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)
714 _NOEXCEPT_(__alloc_traits::is_always_equal::value);717 _NOEXCEPT_(__alloc_traits::is_always_equal::value);
715 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY718 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
716 void __destruct_at_end(pointer __new_last) _NOEXCEPT719 void __destruct_at_end(pointer __new_last) _NOEXCEPT
717 {720 {
718 if (!__libcpp_is_constant_evaluated())721 if (!__libcpp_is_constant_evaluated())
...@@ -723,11 +726,11 @@ private:...@@ -723,11 +726,11 @@ private:
723 }726 }
724727
725 template <class _Up>728 template <class _Up>
726 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY729 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
727 inline void __push_back_slow_path(_Up&& __x);730 inline void __push_back_slow_path(_Up&& __x);
728731
729 template <class... _Args>732 template <class... _Args>
730 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY733 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
731 inline void __emplace_back_slow_path(_Args&&... __args);734 inline void __emplace_back_slow_path(_Args&&... __args);
732735
733 // The following functions are no-ops outside of AddressSanitizer mode.736 // The following functions are no-ops outside of AddressSanitizer mode.
...@@ -735,7 +738,7 @@ private:...@@ -735,7 +738,7 @@ private:
735 // may not meet the AddressSanitizer alignment constraints.738 // may not meet the AddressSanitizer alignment constraints.
736 // See the documentation for __sanitizer_annotate_contiguous_container for more details.739 // See the documentation for __sanitizer_annotate_contiguous_container for more details.
737#ifndef _LIBCPP_HAS_NO_ASAN740#ifndef _LIBCPP_HAS_NO_ASAN
738 _LIBCPP_CONSTEXPR_AFTER_CXX17741 _LIBCPP_CONSTEXPR_SINCE_CXX20
739 void __annotate_contiguous_container(const void *__beg, const void *__end,742 void __annotate_contiguous_container(const void *__beg, const void *__end,
740 const void *__old_mid,743 const void *__old_mid,
741 const void *__new_mid) const744 const void *__new_mid) const
...@@ -745,30 +748,30 @@ private:...@@ -745,30 +748,30 @@ private:
745 __sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid);748 __sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid);
746 }749 }
747#else750#else
748 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY751 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
749 void __annotate_contiguous_container(const void*, const void*, const void*,752 void __annotate_contiguous_container(const void*, const void*, const void*,
750 const void*) const _NOEXCEPT {}753 const void*) const _NOEXCEPT {}
751#endif754#endif
752 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY755 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
753 void __annotate_new(size_type __current_size) const _NOEXCEPT {756 void __annotate_new(size_type __current_size) const _NOEXCEPT {
754 __annotate_contiguous_container(data(), data() + capacity(),757 __annotate_contiguous_container(data(), data() + capacity(),
755 data() + capacity(), data() + __current_size);758 data() + capacity(), data() + __current_size);
756 }759 }
757760
758 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY761 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
759 void __annotate_delete() const _NOEXCEPT {762 void __annotate_delete() const _NOEXCEPT {
760 __annotate_contiguous_container(data(), data() + capacity(),763 __annotate_contiguous_container(data(), data() + capacity(),
761 data() + size(), data() + capacity());764 data() + size(), data() + capacity());
762 }765 }
763766
764 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY767 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
765 void __annotate_increase(size_type __n) const _NOEXCEPT768 void __annotate_increase(size_type __n) const _NOEXCEPT
766 {769 {
767 __annotate_contiguous_container(data(), data() + capacity(),770 __annotate_contiguous_container(data(), data() + capacity(),
768 data() + size(), data() + size() + __n);771 data() + size(), data() + size() + __n);
769 }772 }
770773
771 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY774 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
772 void __annotate_shrink(size_type __old_size) const _NOEXCEPT775 void __annotate_shrink(size_type __old_size) const _NOEXCEPT
773 {776 {
774 __annotate_contiguous_container(data(), data() + capacity(),777 __annotate_contiguous_container(data(), data() + capacity(),
...@@ -776,14 +779,14 @@ private:...@@ -776,14 +779,14 @@ private:
776 }779 }
777780
778 struct _ConstructTransaction {781 struct _ConstructTransaction {
779 _LIBCPP_CONSTEXPR_AFTER_CXX17782 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
780 explicit _ConstructTransaction(vector &__v, size_type __n)783 explicit _ConstructTransaction(vector &__v, size_type __n)
781 : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) {784 : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) {
782#ifndef _LIBCPP_HAS_NO_ASAN785#ifndef _LIBCPP_HAS_NO_ASAN
783 __v_.__annotate_increase(__n);786 __v_.__annotate_increase(__n);
784#endif787#endif
785 }788 }
786 _LIBCPP_CONSTEXPR_AFTER_CXX17 ~_ConstructTransaction() {789 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() {
787 __v_.__end_ = __pos_;790 __v_.__end_ = __pos_;
788#ifndef _LIBCPP_HAS_NO_ASAN791#ifndef _LIBCPP_HAS_NO_ASAN
789 if (__pos_ != __new_end_) {792 if (__pos_ != __new_end_) {
...@@ -802,44 +805,44 @@ private:...@@ -802,44 +805,44 @@ private:
802 };805 };
803806
804 template <class ..._Args>807 template <class ..._Args>
805 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY808 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
806 void __construct_one_at_end(_Args&& ...__args) {809 void __construct_one_at_end(_Args&& ...__args) {
807 _ConstructTransaction __tx(*this, 1);810 _ConstructTransaction __tx(*this, 1);
808 __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_),811 __alloc_traits::construct(this->__alloc(), std::__to_address(__tx.__pos_),
809 _VSTD::forward<_Args>(__args)...);812 std::forward<_Args>(__args)...);
810 ++__tx.__pos_;813 ++__tx.__pos_;
811 }814 }
812815
813 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY816 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
814 allocator_type& __alloc() _NOEXCEPT817 allocator_type& __alloc() _NOEXCEPT
815 {return this->__end_cap_.second();}818 {return this->__end_cap_.second();}
816 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY819 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
817 const allocator_type& __alloc() const _NOEXCEPT820 const allocator_type& __alloc() const _NOEXCEPT
818 {return this->__end_cap_.second();}821 {return this->__end_cap_.second();}
819 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY822 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
820 pointer& __end_cap() _NOEXCEPT823 pointer& __end_cap() _NOEXCEPT
821 {return this->__end_cap_.first();}824 {return this->__end_cap_.first();}
822 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY825 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
823 const pointer& __end_cap() const _NOEXCEPT826 const pointer& __end_cap() const _NOEXCEPT
824 {return this->__end_cap_.first();}827 {return this->__end_cap_.first();}
825828
826 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY829 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
827 void __clear() _NOEXCEPT {__base_destruct_at_end(this->__begin_);}830 void __clear() _NOEXCEPT {__base_destruct_at_end(this->__begin_);}
828831
829 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY832 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
830 void __base_destruct_at_end(pointer __new_last) _NOEXCEPT {833 void __base_destruct_at_end(pointer __new_last) _NOEXCEPT {
831 pointer __soon_to_be_end = this->__end_;834 pointer __soon_to_be_end = this->__end_;
832 while (__new_last != __soon_to_be_end)835 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));
834 this->__end_ = __new_last;837 this->__end_ = __new_last;
835 }838 }
836839
837 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY840 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
838 void __copy_assign_alloc(const vector& __c)841 void __copy_assign_alloc(const vector& __c)
839 {__copy_assign_alloc(__c, integral_constant<bool,842 {__copy_assign_alloc(__c, integral_constant<bool,
840 __alloc_traits::propagate_on_container_copy_assignment::value>());}843 __alloc_traits::propagate_on_container_copy_assignment::value>());}
841844
842 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY845 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
843 void __move_assign_alloc(vector& __c)846 void __move_assign_alloc(vector& __c)
844 _NOEXCEPT_(847 _NOEXCEPT_(
845 !__alloc_traits::propagate_on_container_move_assignment::value ||848 !__alloc_traits::propagate_on_container_move_assignment::value ||
...@@ -849,15 +852,15 @@ private:...@@ -849,15 +852,15 @@ private:
849852
850 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI853 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
851 void __throw_length_error() const {854 void __throw_length_error() const {
852 _VSTD::__throw_length_error("vector");855 std::__throw_length_error("vector");
853 }856 }
854857
855 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI858 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
856 void __throw_out_of_range() const {859 void __throw_out_of_range() const {
857 _VSTD::__throw_out_of_range("vector");860 std::__throw_out_of_range("vector");
858 }861 }
859862
860 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY863 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
861 void __copy_assign_alloc(const vector& __c, true_type)864 void __copy_assign_alloc(const vector& __c, true_type)
862 {865 {
863 if (__alloc() != __c.__alloc())866 if (__alloc() != __c.__alloc())
...@@ -869,18 +872,18 @@ private:...@@ -869,18 +872,18 @@ private:
869 __alloc() = __c.__alloc();872 __alloc() = __c.__alloc();
870 }873 }
871874
872 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY875 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
873 void __copy_assign_alloc(const vector&, false_type)876 void __copy_assign_alloc(const vector&, false_type)
874 {}877 {}
875878
876 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY879 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
877 void __move_assign_alloc(vector& __c, true_type)880 void __move_assign_alloc(vector& __c, true_type)
878 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)881 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
879 {882 {
880 __alloc() = _VSTD::move(__c.__alloc());883 __alloc() = std::move(__c.__alloc());
881 }884 }
882885
883 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY886 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
884 void __move_assign_alloc(vector&, false_type)887 void __move_assign_alloc(vector&, false_type)
885 _NOEXCEPT888 _NOEXCEPT
886 {}889 {}
...@@ -905,7 +908,7 @@ vector(_InputIterator, _InputIterator, _Alloc)...@@ -905,7 +908,7 @@ vector(_InputIterator, _InputIterator, _Alloc)
905#endif908#endif
906909
907template <class _Tp, class _Allocator>910template <class _Tp, class _Allocator>
908_LIBCPP_CONSTEXPR_AFTER_CXX17911_LIBCPP_CONSTEXPR_SINCE_CXX20
909void912void
910vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v)913vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v)
911{914{
...@@ -914,16 +917,16 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a...@@ -914,16 +917,16 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
914 __v.__begin_ = std::__uninitialized_allocator_move_if_noexcept(917 __v.__begin_ = std::__uninitialized_allocator_move_if_noexcept(
915 __alloc(), _RevIter(__end_), _RevIter(__begin_), _RevIter(__v.__begin_))918 __alloc(), _RevIter(__end_), _RevIter(__begin_), _RevIter(__v.__begin_))
916 .base();919 .base();
917 _VSTD::swap(this->__begin_, __v.__begin_);920 std::swap(this->__begin_, __v.__begin_);
918 _VSTD::swap(this->__end_, __v.__end_);921 std::swap(this->__end_, __v.__end_);
919 _VSTD::swap(this->__end_cap(), __v.__end_cap());922 std::swap(this->__end_cap(), __v.__end_cap());
920 __v.__first_ = __v.__begin_;923 __v.__first_ = __v.__begin_;
921 __annotate_new(size());924 __annotate_new(size());
922 std::__debug_db_invalidate_all(this);925 std::__debug_db_invalidate_all(this);
923}926}
924927
925template <class _Tp, class _Allocator>928template <class _Tp, class _Allocator>
926_LIBCPP_CONSTEXPR_AFTER_CXX17929_LIBCPP_CONSTEXPR_SINCE_CXX20
927typename vector<_Tp, _Allocator>::pointer930typename vector<_Tp, _Allocator>::pointer
928vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p)931vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p)
929{932{
...@@ -934,9 +937,9 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a...@@ -934,9 +937,9 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
934 __alloc(), _RevIter(__p), _RevIter(__begin_), _RevIter(__v.__begin_))937 __alloc(), _RevIter(__p), _RevIter(__begin_), _RevIter(__v.__begin_))
935 .base();938 .base();
936 __v.__end_ = std::__uninitialized_allocator_move_if_noexcept(__alloc(), __p, __end_, __v.__end_);939 __v.__end_ = std::__uninitialized_allocator_move_if_noexcept(__alloc(), __p, __end_, __v.__end_);
937 _VSTD::swap(this->__begin_, __v.__begin_);940 std::swap(this->__begin_, __v.__begin_);
938 _VSTD::swap(this->__end_, __v.__end_);941 std::swap(this->__end_, __v.__end_);
939 _VSTD::swap(this->__end_cap(), __v.__end_cap());942 std::swap(this->__end_cap(), __v.__end_cap());
940 __v.__first_ = __v.__begin_;943 __v.__first_ = __v.__begin_;
941 __annotate_new(size());944 __annotate_new(size());
942 std::__debug_db_invalidate_all(this);945 std::__debug_db_invalidate_all(this);
...@@ -944,7 +947,7 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a...@@ -944,7 +947,7 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
944}947}
945948
946template <class _Tp, class _Allocator>949template <class _Tp, class _Allocator>
947_LIBCPP_CONSTEXPR_AFTER_CXX17950_LIBCPP_CONSTEXPR_SINCE_CXX20
948void951void
949vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT952vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT
950{953{
...@@ -957,18 +960,18 @@ vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT...@@ -957,18 +960,18 @@ vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT
957}960}
958961
959template <class _Tp, class _Allocator>962template <class _Tp, class _Allocator>
960_LIBCPP_CONSTEXPR_AFTER_CXX17963_LIBCPP_CONSTEXPR_SINCE_CXX20
961typename vector<_Tp, _Allocator>::size_type964typename vector<_Tp, _Allocator>::size_type
962vector<_Tp, _Allocator>::max_size() const _NOEXCEPT965vector<_Tp, _Allocator>::max_size() const _NOEXCEPT
963{966{
964 return _VSTD::min<size_type>(__alloc_traits::max_size(this->__alloc()),967 return std::min<size_type>(__alloc_traits::max_size(this->__alloc()),
965 numeric_limits<difference_type>::max());968 numeric_limits<difference_type>::max());
966}969}
967970
968// Precondition: __new_size > capacity()971// Precondition: __new_size > capacity()
969template <class _Tp, class _Allocator>972template <class _Tp, class _Allocator>
970_LIBCPP_CONSTEXPR_AFTER_CXX17973_LIBCPP_CONSTEXPR_SINCE_CXX20
971inline _LIBCPP_INLINE_VISIBILITY974inline _LIBCPP_HIDE_FROM_ABI
972typename vector<_Tp, _Allocator>::size_type975typename vector<_Tp, _Allocator>::size_type
973vector<_Tp, _Allocator>::__recommend(size_type __new_size) const976vector<_Tp, _Allocator>::__recommend(size_type __new_size) const
974{977{
...@@ -978,7 +981,7 @@ vector<_Tp, _Allocator>::__recommend(size_type __new_size) const...@@ -978,7 +981,7 @@ vector<_Tp, _Allocator>::__recommend(size_type __new_size) const
978 const size_type __cap = capacity();981 const size_type __cap = capacity();
979 if (__cap >= __ms / 2)982 if (__cap >= __ms / 2)
980 return __ms;983 return __ms;
981 return _VSTD::max<size_type>(2 * __cap, __new_size);984 return std::max<size_type>(2 * __cap, __new_size);
982}985}
983986
984// Default constructs __n objects starting at __end_987// Default constructs __n objects starting at __end_
...@@ -987,14 +990,14 @@ vector<_Tp, _Allocator>::__recommend(size_type __new_size) const...@@ -987,14 +990,14 @@ vector<_Tp, _Allocator>::__recommend(size_type __new_size) const
987// Precondition: size() + __n <= capacity()990// Precondition: size() + __n <= capacity()
988// Postcondition: size() == size() + __n991// Postcondition: size() == size() + __n
989template <class _Tp, class _Allocator>992template <class _Tp, class _Allocator>
990_LIBCPP_CONSTEXPR_AFTER_CXX17993_LIBCPP_CONSTEXPR_SINCE_CXX20
991void994void
992vector<_Tp, _Allocator>::__construct_at_end(size_type __n)995vector<_Tp, _Allocator>::__construct_at_end(size_type __n)
993{996{
994 _ConstructTransaction __tx(*this, __n);997 _ConstructTransaction __tx(*this, __n);
995 const_pointer __new_end = __tx.__new_end_;998 const_pointer __new_end = __tx.__new_end_;
996 for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) {999 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));
998 }1001 }
999}1002}
10001003
...@@ -1005,7 +1008,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n)...@@ -1005,7 +1008,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n)
1005// Postcondition: size() == old size() + __n1008// Postcondition: size() == old size() + __n
1006// Postcondition: [i] == __x for all i in [size() - __n, __n)1009// Postcondition: [i] == __x for all i in [size() - __n, __n)
1007template <class _Tp, class _Allocator>1010template <class _Tp, class _Allocator>
1008_LIBCPP_CONSTEXPR_AFTER_CXX171011_LIBCPP_CONSTEXPR_SINCE_CXX20
1009inline1012inline
1010void1013void
1011vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)1014vector<_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)...@@ -1013,18 +1016,13 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
1013 _ConstructTransaction __tx(*this, __n);1016 _ConstructTransaction __tx(*this, __n);
1014 const_pointer __new_end = __tx.__new_end_;1017 const_pointer __new_end = __tx.__new_end_;
1015 for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) {1018 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);
1017 }1020 }
1018}1021}
10191022
1020template <class _Tp, class _Allocator>1023template <class _Tp, class _Allocator>
1021template <class _ForwardIterator>1024template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value, int> >
1022_LIBCPP_CONSTEXPR_AFTER_CXX171025_LIBCPP_CONSTEXPR_SINCE_CXX20 void
1023typename enable_if
1024<
1025 __is_cpp17_forward_iterator<_ForwardIterator>::value,
1026 void
1027>::type
1028vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n)1026vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n)
1029{1027{
1030 _ConstructTransaction __tx(*this, __n);1028 _ConstructTransaction __tx(*this, __n);
...@@ -1036,7 +1034,7 @@ vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIt...@@ -1036,7 +1034,7 @@ vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIt
1036// Postcondition: size() == size() + __n1034// Postcondition: size() == size() + __n
1037// Exception safety: strong.1035// Exception safety: strong.
1038template <class _Tp, class _Allocator>1036template <class _Tp, class _Allocator>
1039_LIBCPP_CONSTEXPR_AFTER_CXX171037_LIBCPP_CONSTEXPR_SINCE_CXX20
1040void1038void
1041vector<_Tp, _Allocator>::__append(size_type __n)1039vector<_Tp, _Allocator>::__append(size_type __n)
1042{1040{
...@@ -1056,7 +1054,7 @@ vector<_Tp, _Allocator>::__append(size_type __n)...@@ -1056,7 +1054,7 @@ vector<_Tp, _Allocator>::__append(size_type __n)
1056// Postcondition: size() == size() + __n1054// Postcondition: size() == size() + __n
1057// Exception safety: strong.1055// Exception safety: strong.
1058template <class _Tp, class _Allocator>1056template <class _Tp, class _Allocator>
1059_LIBCPP_CONSTEXPR_AFTER_CXX171057_LIBCPP_CONSTEXPR_SINCE_CXX20
1060void1058void
1061vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)1059vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)
1062{1060{
...@@ -1072,152 +1070,160 @@ vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)...@@ -1072,152 +1070,160 @@ vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)
1072}1070}
10731071
1074template <class _Tp, class _Allocator>1072template <class _Tp, class _Allocator>
1075_LIBCPP_CONSTEXPR_AFTER_CXX171073_LIBCPP_CONSTEXPR_SINCE_CXX20
1076vector<_Tp, _Allocator>::vector(size_type __n)1074vector<_Tp, _Allocator>::vector(size_type __n)
1077{1075{
1078 _VSTD::__debug_db_insert_c(this);1076 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1077 std::__debug_db_insert_c(this);
1079 if (__n > 0)1078 if (__n > 0)
1080 {1079 {
1081 __vallocate(__n);1080 __vallocate(__n);
1082 __construct_at_end(__n);1081 __construct_at_end(__n);
1083 }1082 }
1083 __guard.__complete();
1084}1084}
10851085
1086#if _LIBCPP_STD_VER > 111086#if _LIBCPP_STD_VER > 11
1087template <class _Tp, class _Allocator>1087template <class _Tp, class _Allocator>
1088_LIBCPP_CONSTEXPR_AFTER_CXX171088_LIBCPP_CONSTEXPR_SINCE_CXX20
1089vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)1089vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)
1090 : __end_cap_(nullptr, __a)1090 : __end_cap_(nullptr, __a)
1091{1091{
1092 _VSTD::__debug_db_insert_c(this);1092 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1093 std::__debug_db_insert_c(this);
1093 if (__n > 0)1094 if (__n > 0)
1094 {1095 {
1095 __vallocate(__n);1096 __vallocate(__n);
1096 __construct_at_end(__n);1097 __construct_at_end(__n);
1097 }1098 }
1099 __guard.__complete();
1098}1100}
1099#endif1101#endif
11001102
1101template <class _Tp, class _Allocator>1103template <class _Tp, class _Allocator>
1102_LIBCPP_CONSTEXPR_AFTER_CXX171104_LIBCPP_CONSTEXPR_SINCE_CXX20
1103vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x)1105vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x)
1104{1106{
1105 _VSTD::__debug_db_insert_c(this);1107 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1108 std::__debug_db_insert_c(this);
1106 if (__n > 0)1109 if (__n > 0)
1107 {1110 {
1108 __vallocate(__n);1111 __vallocate(__n);
1109 __construct_at_end(__n, __x);1112 __construct_at_end(__n, __x);
1110 }1113 }
1114 __guard.__complete();
1111}1115}
11121116
1113template <class _Tp, class _Allocator>1117template <class _Tp, class _Allocator>
1114template <class _InputIterator>1118template <class _InputIterator, __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
1115_LIBCPP_CONSTEXPR_AFTER_CXX171119 is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value,
1116vector<_Tp, _Allocator>::vector(_InputIterator __first,1120 int> >
1117 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&1121_LIBCPP_CONSTEXPR_SINCE_CXX20
1118 is_constructible<1122vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last)
1119 value_type,1123{
1120 typename iterator_traits<_InputIterator>::reference>::value,1124 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1121 _InputIterator>::type __last)1125 std::__debug_db_insert_c(this);
1122{
1123 _VSTD::__debug_db_insert_c(this);
1124 for (; __first != __last; ++__first)1126 for (; __first != __last; ++__first)
1125 emplace_back(*__first);1127 emplace_back(*__first);
1128 __guard.__complete();
1126}1129}
11271130
1128template <class _Tp, class _Allocator>1131template <class _Tp, class _Allocator>
1129template <class _InputIterator>1132template <class _InputIterator, __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
1130_LIBCPP_CONSTEXPR_AFTER_CXX171133 is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value,
1131vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,1134 int> >
1132 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&1135_LIBCPP_CONSTEXPR_SINCE_CXX20
1133 is_constructible<1136vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a)
1134 value_type,
1135 typename iterator_traits<_InputIterator>::reference>::value>::type*)
1136 : __end_cap_(nullptr, __a)1137 : __end_cap_(nullptr, __a)
1137{1138{
1138 _VSTD::__debug_db_insert_c(this);1139 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1140 std::__debug_db_insert_c(this);
1139 for (; __first != __last; ++__first)1141 for (; __first != __last; ++__first)
1140 emplace_back(*__first);1142 emplace_back(*__first);
1143 __guard.__complete();
1141}1144}
11421145
1143template <class _Tp, class _Allocator>1146template <class _Tp, class _Allocator>
1144template <class _ForwardIterator>1147template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
1145_LIBCPP_CONSTEXPR_AFTER_CXX171148 is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value,
1146vector<_Tp, _Allocator>::vector(_ForwardIterator __first,1149 int> >
1147 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&1150_LIBCPP_CONSTEXPR_SINCE_CXX20
1148 is_constructible<1151vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last)
1149 value_type,1152{
1150 typename iterator_traits<_ForwardIterator>::reference>::value,1153 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1151 _ForwardIterator>::type __last)1154 std::__debug_db_insert_c(this);
1152{1155 size_type __n = static_cast<size_type>(std::distance(__first, __last));
1153 _VSTD::__debug_db_insert_c(this);
1154 size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
1155 if (__n > 0)1156 if (__n > 0)
1156 {1157 {
1157 __vallocate(__n);1158 __vallocate(__n);
1158 __construct_at_end(__first, __last, __n);1159 __construct_at_end(__first, __last, __n);
1159 }1160 }
1161 __guard.__complete();
1160}1162}
11611163
1162template <class _Tp, class _Allocator>1164template <class _Tp, class _Allocator>
1163template <class _ForwardIterator>1165template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
1164_LIBCPP_CONSTEXPR_AFTER_CXX171166 is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value,
1165vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,1167 int> >
1166 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&1168_LIBCPP_CONSTEXPR_SINCE_CXX20
1167 is_constructible<1169vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a)
1168 value_type,
1169 typename iterator_traits<_ForwardIterator>::reference>::value>::type*)
1170 : __end_cap_(nullptr, __a)1170 : __end_cap_(nullptr, __a)
1171{1171{
1172 _VSTD::__debug_db_insert_c(this);1172 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1173 size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));1173 std::__debug_db_insert_c(this);
1174 size_type __n = static_cast<size_type>(std::distance(__first, __last));
1174 if (__n > 0)1175 if (__n > 0)
1175 {1176 {
1176 __vallocate(__n);1177 __vallocate(__n);
1177 __construct_at_end(__first, __last, __n);1178 __construct_at_end(__first, __last, __n);
1178 }1179 }
1180 __guard.__complete();
1179}1181}
11801182
1181template <class _Tp, class _Allocator>1183template <class _Tp, class _Allocator>
1182_LIBCPP_CONSTEXPR_AFTER_CXX171184_LIBCPP_CONSTEXPR_SINCE_CXX20
1183vector<_Tp, _Allocator>::vector(const vector& __x)1185vector<_Tp, _Allocator>::vector(const vector& __x)
1184 : __end_cap_(nullptr, __alloc_traits::select_on_container_copy_construction(__x.__alloc()))1186 : __end_cap_(nullptr, __alloc_traits::select_on_container_copy_construction(__x.__alloc()))
1185{1187{
1186 _VSTD::__debug_db_insert_c(this);1188 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1189 std::__debug_db_insert_c(this);
1187 size_type __n = __x.size();1190 size_type __n = __x.size();
1188 if (__n > 0)1191 if (__n > 0)
1189 {1192 {
1190 __vallocate(__n);1193 __vallocate(__n);
1191 __construct_at_end(__x.__begin_, __x.__end_, __n);1194 __construct_at_end(__x.__begin_, __x.__end_, __n);
1192 }1195 }
1196 __guard.__complete();
1193}1197}
11941198
1195template <class _Tp, class _Allocator>1199template <class _Tp, class _Allocator>
1196_LIBCPP_CONSTEXPR_AFTER_CXX171200_LIBCPP_CONSTEXPR_SINCE_CXX20
1197vector<_Tp, _Allocator>::vector(const vector& __x, const __type_identity_t<allocator_type>& __a)1201vector<_Tp, _Allocator>::vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
1198 : __end_cap_(nullptr, __a)1202 : __end_cap_(nullptr, __a)
1199{1203{
1200 _VSTD::__debug_db_insert_c(this);1204 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1205 std::__debug_db_insert_c(this);
1201 size_type __n = __x.size();1206 size_type __n = __x.size();
1202 if (__n > 0)1207 if (__n > 0)
1203 {1208 {
1204 __vallocate(__n);1209 __vallocate(__n);
1205 __construct_at_end(__x.__begin_, __x.__end_, __n);1210 __construct_at_end(__x.__begin_, __x.__end_, __n);
1206 }1211 }
1212 __guard.__complete();
1207}1213}
12081214
1209template <class _Tp, class _Allocator>1215template <class _Tp, class _Allocator>
1210_LIBCPP_CONSTEXPR_AFTER_CXX171216_LIBCPP_CONSTEXPR_SINCE_CXX20
1211inline _LIBCPP_INLINE_VISIBILITY1217inline _LIBCPP_HIDE_FROM_ABI
1212vector<_Tp, _Allocator>::vector(vector&& __x)1218vector<_Tp, _Allocator>::vector(vector&& __x)
1213#if _LIBCPP_STD_VER > 141219#if _LIBCPP_STD_VER > 14
1214 noexcept1220 noexcept
1215#else1221#else
1216 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)1222 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
1217#endif1223#endif
1218 : __end_cap_(nullptr, _VSTD::move(__x.__alloc()))1224 : __end_cap_(nullptr, std::move(__x.__alloc()))
1219{1225{
1220 _VSTD::__debug_db_insert_c(this);1226 std::__debug_db_insert_c(this);
1221 std::__debug_db_swap(this, std::addressof(__x));1227 std::__debug_db_swap(this, std::addressof(__x));
1222 this->__begin_ = __x.__begin_;1228 this->__begin_ = __x.__begin_;
1223 this->__end_ = __x.__end_;1229 this->__end_ = __x.__end_;
...@@ -1226,12 +1232,12 @@ vector<_Tp, _Allocator>::vector(vector&& __x)...@@ -1226,12 +1232,12 @@ vector<_Tp, _Allocator>::vector(vector&& __x)
1226}1232}
12271233
1228template <class _Tp, class _Allocator>1234template <class _Tp, class _Allocator>
1229_LIBCPP_CONSTEXPR_AFTER_CXX171235_LIBCPP_CONSTEXPR_SINCE_CXX20
1230inline _LIBCPP_INLINE_VISIBILITY1236inline _LIBCPP_HIDE_FROM_ABI
1231vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_type>& __a)1237vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_type>& __a)
1232 : __end_cap_(nullptr, __a)1238 : __end_cap_(nullptr, __a)
1233{1239{
1234 _VSTD::__debug_db_insert_c(this);1240 std::__debug_db_insert_c(this);
1235 if (__a == __x.__alloc())1241 if (__a == __x.__alloc())
1236 {1242 {
1237 this->__begin_ = __x.__begin_;1243 this->__begin_ = __x.__begin_;
...@@ -1243,44 +1249,50 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_...@@ -1243,44 +1249,50 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_
1243 else1249 else
1244 {1250 {
1245 typedef move_iterator<iterator> _Ip;1251 typedef move_iterator<iterator> _Ip;
1252 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1246 assign(_Ip(__x.begin()), _Ip(__x.end()));1253 assign(_Ip(__x.begin()), _Ip(__x.end()));
1254 __guard.__complete();
1247 }1255 }
1248}1256}
12491257
1250#ifndef _LIBCPP_CXX03_LANG1258#ifndef _LIBCPP_CXX03_LANG
12511259
1252template <class _Tp, class _Allocator>1260template <class _Tp, class _Allocator>
1253_LIBCPP_CONSTEXPR_AFTER_CXX171261_LIBCPP_CONSTEXPR_SINCE_CXX20
1254inline _LIBCPP_INLINE_VISIBILITY1262inline _LIBCPP_HIDE_FROM_ABI
1255vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)1263vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
1256{1264{
1257 _VSTD::__debug_db_insert_c(this);1265 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1266 std::__debug_db_insert_c(this);
1258 if (__il.size() > 0)1267 if (__il.size() > 0)
1259 {1268 {
1260 __vallocate(__il.size());1269 __vallocate(__il.size());
1261 __construct_at_end(__il.begin(), __il.end(), __il.size());1270 __construct_at_end(__il.begin(), __il.end(), __il.size());
1262 }1271 }
1272 __guard.__complete();
1263}1273}
12641274
1265template <class _Tp, class _Allocator>1275template <class _Tp, class _Allocator>
1266_LIBCPP_CONSTEXPR_AFTER_CXX171276_LIBCPP_CONSTEXPR_SINCE_CXX20
1267inline _LIBCPP_INLINE_VISIBILITY1277inline _LIBCPP_HIDE_FROM_ABI
1268vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)1278vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
1269 : __end_cap_(nullptr, __a)1279 : __end_cap_(nullptr, __a)
1270{1280{
1271 _VSTD::__debug_db_insert_c(this);1281 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1282 std::__debug_db_insert_c(this);
1272 if (__il.size() > 0)1283 if (__il.size() > 0)
1273 {1284 {
1274 __vallocate(__il.size());1285 __vallocate(__il.size());
1275 __construct_at_end(__il.begin(), __il.end(), __il.size());1286 __construct_at_end(__il.begin(), __il.end(), __il.size());
1276 }1287 }
1288 __guard.__complete();
1277}1289}
12781290
1279#endif // _LIBCPP_CXX03_LANG1291#endif // _LIBCPP_CXX03_LANG
12801292
1281template <class _Tp, class _Allocator>1293template <class _Tp, class _Allocator>
1282_LIBCPP_CONSTEXPR_AFTER_CXX171294_LIBCPP_CONSTEXPR_SINCE_CXX20
1283inline _LIBCPP_INLINE_VISIBILITY1295inline _LIBCPP_HIDE_FROM_ABI
1284vector<_Tp, _Allocator>&1296vector<_Tp, _Allocator>&
1285vector<_Tp, _Allocator>::operator=(vector&& __x)1297vector<_Tp, _Allocator>::operator=(vector&& __x)
1286 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))1298 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
...@@ -1291,7 +1303,7 @@ vector<_Tp, _Allocator>::operator=(vector&& __x)...@@ -1291,7 +1303,7 @@ vector<_Tp, _Allocator>::operator=(vector&& __x)
1291}1303}
12921304
1293template <class _Tp, class _Allocator>1305template <class _Tp, class _Allocator>
1294_LIBCPP_CONSTEXPR_AFTER_CXX171306_LIBCPP_CONSTEXPR_SINCE_CXX20
1295void1307void
1296vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)1308vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)
1297 _NOEXCEPT_(__alloc_traits::is_always_equal::value)1309 _NOEXCEPT_(__alloc_traits::is_always_equal::value)
...@@ -1306,7 +1318,7 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)...@@ -1306,7 +1318,7 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)
1306}1318}
13071319
1308template <class _Tp, class _Allocator>1320template <class _Tp, class _Allocator>
1309_LIBCPP_CONSTEXPR_AFTER_CXX171321_LIBCPP_CONSTEXPR_SINCE_CXX20
1310void1322void
1311vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)1323vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
1312 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)1324 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
...@@ -1321,12 +1333,12 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)...@@ -1321,12 +1333,12 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
1321}1333}
13221334
1323template <class _Tp, class _Allocator>1335template <class _Tp, class _Allocator>
1324_LIBCPP_CONSTEXPR_AFTER_CXX171336_LIBCPP_CONSTEXPR_SINCE_CXX20
1325inline _LIBCPP_INLINE_VISIBILITY1337inline _LIBCPP_HIDE_FROM_ABI
1326vector<_Tp, _Allocator>&1338vector<_Tp, _Allocator>&
1327vector<_Tp, _Allocator>::operator=(const vector& __x)1339vector<_Tp, _Allocator>::operator=(const vector& __x)
1328{1340{
1329 if (this != _VSTD::addressof(__x))1341 if (this != std::addressof(__x))
1330 {1342 {
1331 __copy_assign_alloc(__x);1343 __copy_assign_alloc(__x);
1332 assign(__x.__begin_, __x.__end_);1344 assign(__x.__begin_, __x.__end_);
...@@ -1335,13 +1347,10 @@ vector<_Tp, _Allocator>::operator=(const vector& __x)...@@ -1335,13 +1347,10 @@ vector<_Tp, _Allocator>::operator=(const vector& __x)
1335}1347}
13361348
1337template <class _Tp, class _Allocator>1349template <class _Tp, class _Allocator>
1338template <class _InputIterator>1350template <class _InputIterator, __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
1339_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&1351 is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value,
1340 is_constructible<1352 int> >
1341 _Tp,1353_LIBCPP_CONSTEXPR_SINCE_CXX20 void
1342 typename iterator_traits<_InputIterator>::reference>::value,
1343 void
1344>::type
1345vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last)1354vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
1346{1355{
1347 clear();1356 clear();
...@@ -1350,19 +1359,13 @@ vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last)...@@ -1350,19 +1359,13 @@ vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
1350}1359}
13511360
1352template <class _Tp, class _Allocator>1361template <class _Tp, class _Allocator>
1353template <class _ForwardIterator>1362template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
1354_LIBCPP_CONSTEXPR_AFTER_CXX171363 is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value,
1355typename enable_if1364 int> >
1356<1365_LIBCPP_CONSTEXPR_SINCE_CXX20 void
1357 __is_cpp17_forward_iterator<_ForwardIterator>::value &&
1358 is_constructible<
1359 _Tp,
1360 typename iterator_traits<_ForwardIterator>::reference>::value,
1361 void
1362>::type
1363vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)1366vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)
1364{1367{
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));
1366 if (__new_size <= capacity())1369 if (__new_size <= capacity())
1367 {1370 {
1368 _ForwardIterator __mid = __last;1371 _ForwardIterator __mid = __last;
...@@ -1371,9 +1374,9 @@ vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __las...@@ -1371,9 +1374,9 @@ vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __las
1371 {1374 {
1372 __growing = true;1375 __growing = true;
1373 __mid = __first;1376 __mid = __first;
1374 _VSTD::advance(__mid, size());1377 std::advance(__mid, size());
1375 }1378 }
1376 pointer __m = _VSTD::copy(__first, __mid, this->__begin_);1379 pointer __m = std::copy(__first, __mid, this->__begin_);
1377 if (__growing)1380 if (__growing)
1378 __construct_at_end(__mid, __last, __new_size - size());1381 __construct_at_end(__mid, __last, __new_size - size());
1379 else1382 else
...@@ -1389,14 +1392,14 @@ vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __las...@@ -1389,14 +1392,14 @@ vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __las
1389}1392}
13901393
1391template <class _Tp, class _Allocator>1394template <class _Tp, class _Allocator>
1392_LIBCPP_CONSTEXPR_AFTER_CXX171395_LIBCPP_CONSTEXPR_SINCE_CXX20
1393void1396void
1394vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)1397vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)
1395{1398{
1396 if (__n <= capacity())1399 if (__n <= capacity())
1397 {1400 {
1398 size_type __s = size();1401 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);
1400 if (__n > __s)1403 if (__n > __s)
1401 __construct_at_end(__n - __s, __u);1404 __construct_at_end(__n - __s, __u);
1402 else1405 else
...@@ -1412,44 +1415,44 @@ vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)...@@ -1412,44 +1415,44 @@ vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)
1412}1415}
14131416
1414template <class _Tp, class _Allocator>1417template <class _Tp, class _Allocator>
1415_LIBCPP_CONSTEXPR_AFTER_CXX171418_LIBCPP_CONSTEXPR_SINCE_CXX20
1416inline _LIBCPP_INLINE_VISIBILITY1419inline _LIBCPP_HIDE_FROM_ABI
1417typename vector<_Tp, _Allocator>::iterator1420typename vector<_Tp, _Allocator>::iterator
1418vector<_Tp, _Allocator>::begin() _NOEXCEPT1421vector<_Tp, _Allocator>::begin() _NOEXCEPT
1419{1422{
1420 return iterator(this, this->__begin_);1423 return __make_iter(this->__begin_);
1421}1424}
14221425
1423template <class _Tp, class _Allocator>1426template <class _Tp, class _Allocator>
1424_LIBCPP_CONSTEXPR_AFTER_CXX171427_LIBCPP_CONSTEXPR_SINCE_CXX20
1425inline _LIBCPP_INLINE_VISIBILITY1428inline _LIBCPP_HIDE_FROM_ABI
1426typename vector<_Tp, _Allocator>::const_iterator1429typename vector<_Tp, _Allocator>::const_iterator
1427vector<_Tp, _Allocator>::begin() const _NOEXCEPT1430vector<_Tp, _Allocator>::begin() const _NOEXCEPT
1428{1431{
1429 return const_iterator(this, this->__begin_);1432 return __make_iter(this->__begin_);
1430}1433}
14311434
1432template <class _Tp, class _Allocator>1435template <class _Tp, class _Allocator>
1433_LIBCPP_CONSTEXPR_AFTER_CXX171436_LIBCPP_CONSTEXPR_SINCE_CXX20
1434inline _LIBCPP_INLINE_VISIBILITY1437inline _LIBCPP_HIDE_FROM_ABI
1435typename vector<_Tp, _Allocator>::iterator1438typename vector<_Tp, _Allocator>::iterator
1436vector<_Tp, _Allocator>::end() _NOEXCEPT1439vector<_Tp, _Allocator>::end() _NOEXCEPT
1437{1440{
1438 return iterator(this, this->__end_);1441 return __make_iter(this->__end_);
1439}1442}
14401443
1441template <class _Tp, class _Allocator>1444template <class _Tp, class _Allocator>
1442_LIBCPP_CONSTEXPR_AFTER_CXX171445_LIBCPP_CONSTEXPR_SINCE_CXX20
1443inline _LIBCPP_INLINE_VISIBILITY1446inline _LIBCPP_HIDE_FROM_ABI
1444typename vector<_Tp, _Allocator>::const_iterator1447typename vector<_Tp, _Allocator>::const_iterator
1445vector<_Tp, _Allocator>::end() const _NOEXCEPT1448vector<_Tp, _Allocator>::end() const _NOEXCEPT
1446{1449{
1447 return const_iterator(this, this->__end_);1450 return __make_iter(this->__end_);
1448}1451}
14491452
1450template <class _Tp, class _Allocator>1453template <class _Tp, class _Allocator>
1451_LIBCPP_CONSTEXPR_AFTER_CXX171454_LIBCPP_CONSTEXPR_SINCE_CXX20
1452inline _LIBCPP_INLINE_VISIBILITY1455inline _LIBCPP_HIDE_FROM_ABI
1453typename vector<_Tp, _Allocator>::reference1456typename vector<_Tp, _Allocator>::reference
1454vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT1457vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT
1455{1458{
...@@ -1458,8 +1461,8 @@ vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT...@@ -1458,8 +1461,8 @@ vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT
1458}1461}
14591462
1460template <class _Tp, class _Allocator>1463template <class _Tp, class _Allocator>
1461_LIBCPP_CONSTEXPR_AFTER_CXX171464_LIBCPP_CONSTEXPR_SINCE_CXX20
1462inline _LIBCPP_INLINE_VISIBILITY1465inline _LIBCPP_HIDE_FROM_ABI
1463typename vector<_Tp, _Allocator>::const_reference1466typename vector<_Tp, _Allocator>::const_reference
1464vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT1467vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT
1465{1468{
...@@ -1468,7 +1471,7 @@ vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT...@@ -1468,7 +1471,7 @@ vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT
1468}1471}
14691472
1470template <class _Tp, class _Allocator>1473template <class _Tp, class _Allocator>
1471_LIBCPP_CONSTEXPR_AFTER_CXX171474_LIBCPP_CONSTEXPR_SINCE_CXX20
1472typename vector<_Tp, _Allocator>::reference1475typename vector<_Tp, _Allocator>::reference
1473vector<_Tp, _Allocator>::at(size_type __n)1476vector<_Tp, _Allocator>::at(size_type __n)
1474{1477{
...@@ -1478,7 +1481,7 @@ vector<_Tp, _Allocator>::at(size_type __n)...@@ -1478,7 +1481,7 @@ vector<_Tp, _Allocator>::at(size_type __n)
1478}1481}
14791482
1480template <class _Tp, class _Allocator>1483template <class _Tp, class _Allocator>
1481_LIBCPP_CONSTEXPR_AFTER_CXX171484_LIBCPP_CONSTEXPR_SINCE_CXX20
1482typename vector<_Tp, _Allocator>::const_reference1485typename vector<_Tp, _Allocator>::const_reference
1483vector<_Tp, _Allocator>::at(size_type __n) const1486vector<_Tp, _Allocator>::at(size_type __n) const
1484{1487{
...@@ -1488,7 +1491,7 @@ vector<_Tp, _Allocator>::at(size_type __n) const...@@ -1488,7 +1491,7 @@ vector<_Tp, _Allocator>::at(size_type __n) const
1488}1491}
14891492
1490template <class _Tp, class _Allocator>1493template <class _Tp, class _Allocator>
1491_LIBCPP_CONSTEXPR_AFTER_CXX171494_LIBCPP_CONSTEXPR_SINCE_CXX20
1492void1495void
1493vector<_Tp, _Allocator>::reserve(size_type __n)1496vector<_Tp, _Allocator>::reserve(size_type __n)
1494{1497{
...@@ -1503,7 +1506,7 @@ vector<_Tp, _Allocator>::reserve(size_type __n)...@@ -1503,7 +1506,7 @@ vector<_Tp, _Allocator>::reserve(size_type __n)
1503}1506}
15041507
1505template <class _Tp, class _Allocator>1508template <class _Tp, class _Allocator>
1506_LIBCPP_CONSTEXPR_AFTER_CXX171509_LIBCPP_CONSTEXPR_SINCE_CXX20
1507void1510void
1508vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT1511vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
1509{1512{
...@@ -1527,21 +1530,21 @@ vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT...@@ -1527,21 +1530,21 @@ vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
15271530
1528template <class _Tp, class _Allocator>1531template <class _Tp, class _Allocator>
1529template <class _Up>1532template <class _Up>
1530_LIBCPP_CONSTEXPR_AFTER_CXX171533_LIBCPP_CONSTEXPR_SINCE_CXX20
1531void1534void
1532vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x)1535vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x)
1533{1536{
1534 allocator_type& __a = this->__alloc();1537 allocator_type& __a = this->__alloc();
1535 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);1538 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);
1536 // __v.push_back(_VSTD::forward<_Up>(__x));1539 // __v.push_back(std::forward<_Up>(__x));
1537 __alloc_traits::construct(__a, _VSTD::__to_address(__v.__end_), _VSTD::forward<_Up>(__x));1540 __alloc_traits::construct(__a, std::__to_address(__v.__end_), std::forward<_Up>(__x));
1538 __v.__end_++;1541 __v.__end_++;
1539 __swap_out_circular_buffer(__v);1542 __swap_out_circular_buffer(__v);
1540}1543}
15411544
1542template <class _Tp, class _Allocator>1545template <class _Tp, class _Allocator>
1543_LIBCPP_CONSTEXPR_AFTER_CXX171546_LIBCPP_CONSTEXPR_SINCE_CXX20
1544inline _LIBCPP_INLINE_VISIBILITY1547inline _LIBCPP_HIDE_FROM_ABI
1545void1548void
1546vector<_Tp, _Allocator>::push_back(const_reference __x)1549vector<_Tp, _Allocator>::push_back(const_reference __x)
1547{1550{
...@@ -1554,36 +1557,36 @@ vector<_Tp, _Allocator>::push_back(const_reference __x)...@@ -1554,36 +1557,36 @@ vector<_Tp, _Allocator>::push_back(const_reference __x)
1554}1557}
15551558
1556template <class _Tp, class _Allocator>1559template <class _Tp, class _Allocator>
1557_LIBCPP_CONSTEXPR_AFTER_CXX171560_LIBCPP_CONSTEXPR_SINCE_CXX20
1558inline _LIBCPP_INLINE_VISIBILITY1561inline _LIBCPP_HIDE_FROM_ABI
1559void1562void
1560vector<_Tp, _Allocator>::push_back(value_type&& __x)1563vector<_Tp, _Allocator>::push_back(value_type&& __x)
1561{1564{
1562 if (this->__end_ < this->__end_cap())1565 if (this->__end_ < this->__end_cap())
1563 {1566 {
1564 __construct_one_at_end(_VSTD::move(__x));1567 __construct_one_at_end(std::move(__x));
1565 }1568 }
1566 else1569 else
1567 __push_back_slow_path(_VSTD::move(__x));1570 __push_back_slow_path(std::move(__x));
1568}1571}
15691572
1570template <class _Tp, class _Allocator>1573template <class _Tp, class _Allocator>
1571template <class... _Args>1574template <class... _Args>
1572_LIBCPP_CONSTEXPR_AFTER_CXX171575_LIBCPP_CONSTEXPR_SINCE_CXX20
1573void1576void
1574vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args)1577vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args)
1575{1578{
1576 allocator_type& __a = this->__alloc();1579 allocator_type& __a = this->__alloc();
1577 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);1580 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);
1578// __v.emplace_back(_VSTD::forward<_Args>(__args)...);1581// __v.emplace_back(std::forward<_Args>(__args)...);
1579 __alloc_traits::construct(__a, _VSTD::__to_address(__v.__end_), _VSTD::forward<_Args>(__args)...);1582 __alloc_traits::construct(__a, std::__to_address(__v.__end_), std::forward<_Args>(__args)...);
1580 __v.__end_++;1583 __v.__end_++;
1581 __swap_out_circular_buffer(__v);1584 __swap_out_circular_buffer(__v);
1582}1585}
15831586
1584template <class _Tp, class _Allocator>1587template <class _Tp, class _Allocator>
1585template <class... _Args>1588template <class... _Args>
1586_LIBCPP_CONSTEXPR_AFTER_CXX171589_LIBCPP_CONSTEXPR_SINCE_CXX20
1587inline1590inline
1588#if _LIBCPP_STD_VER > 141591#if _LIBCPP_STD_VER > 14
1589typename vector<_Tp, _Allocator>::reference1592typename vector<_Tp, _Allocator>::reference
...@@ -1594,17 +1597,17 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)...@@ -1594,17 +1597,17 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)
1594{1597{
1595 if (this->__end_ < this->__end_cap())1598 if (this->__end_ < this->__end_cap())
1596 {1599 {
1597 __construct_one_at_end(_VSTD::forward<_Args>(__args)...);1600 __construct_one_at_end(std::forward<_Args>(__args)...);
1598 }1601 }
1599 else1602 else
1600 __emplace_back_slow_path(_VSTD::forward<_Args>(__args)...);1603 __emplace_back_slow_path(std::forward<_Args>(__args)...);
1601#if _LIBCPP_STD_VER > 141604#if _LIBCPP_STD_VER > 14
1602 return this->back();1605 return this->back();
1603#endif1606#endif
1604}1607}
16051608
1606template <class _Tp, class _Allocator>1609template <class _Tp, class _Allocator>
1607_LIBCPP_CONSTEXPR_AFTER_CXX171610_LIBCPP_CONSTEXPR_SINCE_CXX20
1608inline1611inline
1609void1612void
1610vector<_Tp, _Allocator>::pop_back()1613vector<_Tp, _Allocator>::pop_back()
...@@ -1614,47 +1617,45 @@ vector<_Tp, _Allocator>::pop_back()...@@ -1614,47 +1617,45 @@ vector<_Tp, _Allocator>::pop_back()
1614}1617}
16151618
1616template <class _Tp, class _Allocator>1619template <class _Tp, class _Allocator>
1617_LIBCPP_CONSTEXPR_AFTER_CXX171620_LIBCPP_CONSTEXPR_SINCE_CXX20
1618inline _LIBCPP_INLINE_VISIBILITY1621inline _LIBCPP_HIDE_FROM_ABI
1619typename vector<_Tp, _Allocator>::iterator1622typename vector<_Tp, _Allocator>::iterator
1620vector<_Tp, _Allocator>::erase(const_iterator __position)1623vector<_Tp, _Allocator>::erase(const_iterator __position)
1621{1624{
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,
1623 "vector::erase(iterator) called with an iterator not referring to this vector");1626 "vector::erase(iterator) called with an iterator not referring to this vector");
1624 _LIBCPP_ASSERT(__position != end(),1627 _LIBCPP_ASSERT(__position != end(),
1625 "vector::erase(iterator) called with a non-dereferenceable iterator");1628 "vector::erase(iterator) called with a non-dereferenceable iterator");
1626 difference_type __ps = __position - cbegin();1629 difference_type __ps = __position - cbegin();
1627 pointer __p = this->__begin_ + __ps;1630 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));
1629 if (!__libcpp_is_constant_evaluated())1632 if (!__libcpp_is_constant_evaluated())
1630 this->__invalidate_iterators_past(__p - 1);1633 this->__invalidate_iterators_past(__p - 1);
1631 iterator __r = iterator(this, __p);1634 return __make_iter(__p);
1632 return __r;
1633}1635}
16341636
1635template <class _Tp, class _Allocator>1637template <class _Tp, class _Allocator>
1636_LIBCPP_CONSTEXPR_AFTER_CXX171638_LIBCPP_CONSTEXPR_SINCE_CXX20
1637typename vector<_Tp, _Allocator>::iterator1639typename vector<_Tp, _Allocator>::iterator
1638vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last)1640vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last)
1639{1641{
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,
1641 "vector::erase(iterator, iterator) called with an iterator not referring to this vector");1643 "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,
1643 "vector::erase(iterator, iterator) called with an iterator not referring to this vector");1645 "vector::erase(iterator, iterator) called with an iterator not referring to this vector");
16441646
1645 _LIBCPP_ASSERT(__first <= __last, "vector::erase(first, last) called with invalid range");1647 _LIBCPP_ASSERT(__first <= __last, "vector::erase(first, last) called with invalid range");
1646 pointer __p = this->__begin_ + (__first - begin());1648 pointer __p = this->__begin_ + (__first - begin());
1647 if (__first != __last) {1649 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));
1649 if (!__libcpp_is_constant_evaluated())1651 if (!__libcpp_is_constant_evaluated())
1650 this->__invalidate_iterators_past(__p - 1);1652 this->__invalidate_iterators_past(__p - 1);
1651 }1653 }
1652 iterator __r = iterator(this, __p);1654 return __make_iter(__p);
1653 return __r;
1654}1655}
16551656
1656template <class _Tp, class _Allocator>1657template <class _Tp, class _Allocator>
1657_LIBCPP_CONSTEXPR_AFTER_CXX171658_LIBCPP_CONSTEXPR_SINCE_CXX20
1658void1659void
1659vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to)1660vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to)
1660{1661{
...@@ -1666,19 +1667,19 @@ vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointe...@@ -1666,19 +1667,19 @@ vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointe
1666 for (pointer __pos = __tx.__pos_; __i < __from_e;1667 for (pointer __pos = __tx.__pos_; __i < __from_e;
1667 ++__i, (void) ++__pos, __tx.__pos_ = __pos) {1668 ++__i, (void) ++__pos, __tx.__pos_ = __pos) {
1668 __alloc_traits::construct(this->__alloc(),1669 __alloc_traits::construct(this->__alloc(),
1669 _VSTD::__to_address(__pos),1670 std::__to_address(__pos),
1670 _VSTD::move(*__i));1671 std::move(*__i));
1671 }1672 }
1672 }1673 }
1673 _VSTD::move_backward(__from_s, __from_s + __n, __old_last);1674 std::move_backward(__from_s, __from_s + __n, __old_last);
1674}1675}
16751676
1676template <class _Tp, class _Allocator>1677template <class _Tp, class _Allocator>
1677_LIBCPP_CONSTEXPR_AFTER_CXX171678_LIBCPP_CONSTEXPR_SINCE_CXX20
1678typename vector<_Tp, _Allocator>::iterator1679typename vector<_Tp, _Allocator>::iterator
1679vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)1680vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
1680{1681{
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,
1682 "vector::insert(iterator, x) called with an iterator not referring to this vector");1683 "vector::insert(iterator, x) called with an iterator not referring to this vector");
1683 pointer __p = this->__begin_ + (__position - begin());1684 pointer __p = this->__begin_ + (__position - begin());
1684 // We can't compare unrelated pointers inside constant expressions1685 // We can't compare unrelated pointers inside constant expressions
...@@ -1704,77 +1705,77 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)...@@ -1704,77 +1705,77 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
1704 __v.push_back(__x);1705 __v.push_back(__x);
1705 __p = __swap_out_circular_buffer(__v, __p);1706 __p = __swap_out_circular_buffer(__v, __p);
1706 }1707 }
1707 return iterator(this, __p);1708 return __make_iter(__p);
1708}1709}
17091710
1710template <class _Tp, class _Allocator>1711template <class _Tp, class _Allocator>
1711_LIBCPP_CONSTEXPR_AFTER_CXX171712_LIBCPP_CONSTEXPR_SINCE_CXX20
1712typename vector<_Tp, _Allocator>::iterator1713typename vector<_Tp, _Allocator>::iterator
1713vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)1714vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)
1714{1715{
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,
1716 "vector::insert(iterator, x) called with an iterator not referring to this vector");1717 "vector::insert(iterator, x) called with an iterator not referring to this vector");
1717 pointer __p = this->__begin_ + (__position - begin());1718 pointer __p = this->__begin_ + (__position - begin());
1718 if (this->__end_ < this->__end_cap())1719 if (this->__end_ < this->__end_cap())
1719 {1720 {
1720 if (__p == this->__end_)1721 if (__p == this->__end_)
1721 {1722 {
1722 __construct_one_at_end(_VSTD::move(__x));1723 __construct_one_at_end(std::move(__x));
1723 }1724 }
1724 else1725 else
1725 {1726 {
1726 __move_range(__p, this->__end_, __p + 1);1727 __move_range(__p, this->__end_, __p + 1);
1727 *__p = _VSTD::move(__x);1728 *__p = std::move(__x);
1728 }1729 }
1729 }1730 }
1730 else1731 else
1731 {1732 {
1732 allocator_type& __a = this->__alloc();1733 allocator_type& __a = this->__alloc();
1733 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a);1734 __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));
1735 __p = __swap_out_circular_buffer(__v, __p);1736 __p = __swap_out_circular_buffer(__v, __p);
1736 }1737 }
1737 return iterator(this, __p);1738 return __make_iter(__p);
1738}1739}
17391740
1740template <class _Tp, class _Allocator>1741template <class _Tp, class _Allocator>
1741template <class... _Args>1742template <class... _Args>
1742_LIBCPP_CONSTEXPR_AFTER_CXX171743_LIBCPP_CONSTEXPR_SINCE_CXX20
1743typename vector<_Tp, _Allocator>::iterator1744typename vector<_Tp, _Allocator>::iterator
1744vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)1745vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
1745{1746{
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,
1747 "vector::emplace(iterator, x) called with an iterator not referring to this vector");1748 "vector::emplace(iterator, x) called with an iterator not referring to this vector");
1748 pointer __p = this->__begin_ + (__position - begin());1749 pointer __p = this->__begin_ + (__position - begin());
1749 if (this->__end_ < this->__end_cap())1750 if (this->__end_ < this->__end_cap())
1750 {1751 {
1751 if (__p == this->__end_)1752 if (__p == this->__end_)
1752 {1753 {
1753 __construct_one_at_end(_VSTD::forward<_Args>(__args)...);1754 __construct_one_at_end(std::forward<_Args>(__args)...);
1754 }1755 }
1755 else1756 else
1756 {1757 {
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)...);
1758 __move_range(__p, this->__end_, __p + 1);1759 __move_range(__p, this->__end_, __p + 1);
1759 *__p = _VSTD::move(__tmp.get());1760 *__p = std::move(__tmp.get());
1760 }1761 }
1761 }1762 }
1762 else1763 else
1763 {1764 {
1764 allocator_type& __a = this->__alloc();1765 allocator_type& __a = this->__alloc();
1765 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a);1766 __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)...);
1767 __p = __swap_out_circular_buffer(__v, __p);1768 __p = __swap_out_circular_buffer(__v, __p);
1768 }1769 }
1769 return iterator(this, __p);1770 return __make_iter(__p);
1770}1771}
17711772
1772template <class _Tp, class _Allocator>1773template <class _Tp, class _Allocator>
1773_LIBCPP_CONSTEXPR_AFTER_CXX171774_LIBCPP_CONSTEXPR_SINCE_CXX20
1774typename vector<_Tp, _Allocator>::iterator1775typename vector<_Tp, _Allocator>::iterator
1775vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x)1776vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x)
1776{1777{
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,
1778 "vector::insert(iterator, n, x) called with an iterator not referring to this vector");1779 "vector::insert(iterator, n, x) called with an iterator not referring to this vector");
1779 pointer __p = this->__begin_ + (__position - begin());1780 pointer __p = this->__begin_ + (__position - begin());
1780 if (__n > 0)1781 if (__n > 0)
...@@ -1796,7 +1797,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_...@@ -1796,7 +1797,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_
1796 const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);1797 const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
1797 if (__p <= __xr && __xr < this->__end_)1798 if (__p <= __xr && __xr < this->__end_)
1798 __xr += __old_n;1799 __xr += __old_n;
1799 _VSTD::fill_n(__p, __n, *__xr);1800 std::fill_n(__p, __n, *__xr);
1800 }1801 }
1801 }1802 }
1802 else1803 else
...@@ -1807,20 +1808,17 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_...@@ -1807,20 +1808,17 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_
1807 __p = __swap_out_circular_buffer(__v, __p);1808 __p = __swap_out_circular_buffer(__v, __p);
1808 }1809 }
1809 }1810 }
1810 return iterator(this, __p);1811 return __make_iter(__p);
1811}1812}
18121813
1813template <class _Tp, class _Allocator>1814template <class _Tp, class _Allocator>
1814template <class _InputIterator>1815template <class _InputIterator, __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
1815_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&1816 is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value,
1816 is_constructible<1817 int> >
1817 _Tp,1818_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
1818 typename iterator_traits<_InputIterator>::reference>::value,
1819 typename vector<_Tp, _Allocator>::iterator
1820>::type
1821vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)1819vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
1822{1820{
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,
1824 "vector::insert(iterator, range) called with an iterator not referring to this vector");1822 "vector::insert(iterator, range) called with an iterator not referring to this vector");
1825 difference_type __off = __position - begin();1823 difference_type __off = __position - begin();
1826 pointer __p = this->__begin_ + __off;1824 pointer __p = this->__begin_ + __off;
...@@ -1847,34 +1845,28 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __firs...@@ -1847,34 +1845,28 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __firs
1847 }1845 }
1848 catch (...)1846 catch (...)
1849 {1847 {
1850 erase(iterator(this, __old_last), end());1848 erase(__make_iter(__old_last), end());
1851 throw;1849 throw;
1852 }1850 }
1853#endif // _LIBCPP_NO_EXCEPTIONS1851#endif // _LIBCPP_NO_EXCEPTIONS
1854 }1852 }
1855 __p = _VSTD::rotate(__p, __old_last, this->__end_);1853 __p = std::rotate(__p, __old_last, this->__end_);
1856 insert(iterator(this, __p), _VSTD::make_move_iterator(__v.begin()),1854 insert(__make_iter(__p), std::make_move_iterator(__v.begin()),
1857 _VSTD::make_move_iterator(__v.end()));1855 std::make_move_iterator(__v.end()));
1858 return begin() + __off;1856 return begin() + __off;
1859}1857}
18601858
1861template <class _Tp, class _Allocator>1859template <class _Tp, class _Allocator>
1862template <class _ForwardIterator>1860template <class _ForwardIterator, __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
1863_LIBCPP_CONSTEXPR_AFTER_CXX171861 is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value,
1864typename enable_if1862 int> >
1865<1863_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
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
1872vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last)1864vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last)
1873{1865{
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,
1875 "vector::insert(iterator, range) called with an iterator not referring to this vector");1867 "vector::insert(iterator, range) called with an iterator not referring to this vector");
1876 pointer __p = this->__begin_ + (__position - begin());1868 pointer __p = this->__begin_ + (__position - begin());
1877 difference_type __n = _VSTD::distance(__first, __last);1869 difference_type __n = std::distance(__first, __last);
1878 if (__n > 0)1870 if (__n > 0)
1879 {1871 {
1880 if (__n <= this->__end_cap() - this->__end_)1872 if (__n <= this->__end_cap() - this->__end_)
...@@ -1887,14 +1879,14 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __fi...@@ -1887,14 +1879,14 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __fi
1887 {1879 {
1888 __m = __first;1880 __m = __first;
1889 difference_type __diff = this->__end_ - __p;1881 difference_type __diff = this->__end_ - __p;
1890 _VSTD::advance(__m, __diff);1882 std::advance(__m, __diff);
1891 __construct_at_end(__m, __last, __n - __diff);1883 __construct_at_end(__m, __last, __n - __diff);
1892 __n = __dx;1884 __n = __dx;
1893 }1885 }
1894 if (__n > 0)1886 if (__n > 0)
1895 {1887 {
1896 __move_range(__p, __old_last, __p + __old_n);1888 __move_range(__p, __old_last, __p + __old_n);
1897 _VSTD::copy(__first, __m, __p);1889 std::copy(__first, __m, __p);
1898 }1890 }
1899 }1891 }
1900 else1892 else
...@@ -1905,11 +1897,11 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __fi...@@ -1905,11 +1897,11 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __fi
1905 __p = __swap_out_circular_buffer(__v, __p);1897 __p = __swap_out_circular_buffer(__v, __p);
1906 }1898 }
1907 }1899 }
1908 return iterator(this, __p);1900 return __make_iter(__p);
1909}1901}
19101902
1911template <class _Tp, class _Allocator>1903template <class _Tp, class _Allocator>
1912_LIBCPP_CONSTEXPR_AFTER_CXX171904_LIBCPP_CONSTEXPR_SINCE_CXX20
1913void1905void
1914vector<_Tp, _Allocator>::resize(size_type __sz)1906vector<_Tp, _Allocator>::resize(size_type __sz)
1915{1907{
...@@ -1921,7 +1913,7 @@ vector<_Tp, _Allocator>::resize(size_type __sz)...@@ -1921,7 +1913,7 @@ vector<_Tp, _Allocator>::resize(size_type __sz)
1921}1913}
19221914
1923template <class _Tp, class _Allocator>1915template <class _Tp, class _Allocator>
1924_LIBCPP_CONSTEXPR_AFTER_CXX171916_LIBCPP_CONSTEXPR_SINCE_CXX20
1925void1917void
1926vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)1918vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)
1927{1919{
...@@ -1933,7 +1925,7 @@ vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)...@@ -1933,7 +1925,7 @@ vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)
1933}1925}
19341926
1935template <class _Tp, class _Allocator>1927template <class _Tp, class _Allocator>
1936_LIBCPP_CONSTEXPR_AFTER_CXX171928_LIBCPP_CONSTEXPR_SINCE_CXX20
1937void1929void
1938vector<_Tp, _Allocator>::swap(vector& __x)1930vector<_Tp, _Allocator>::swap(vector& __x)
1939#if _LIBCPP_STD_VER >= 141931#if _LIBCPP_STD_VER >= 14
...@@ -1947,16 +1939,16 @@ vector<_Tp, _Allocator>::swap(vector& __x)...@@ -1947,16 +1939,16 @@ vector<_Tp, _Allocator>::swap(vector& __x)
1947 this->__alloc() == __x.__alloc(),1939 this->__alloc() == __x.__alloc(),
1948 "vector::swap: Either propagate_on_container_swap must be true"1940 "vector::swap: Either propagate_on_container_swap must be true"
1949 " or the allocators must compare equal");1941 " or the allocators must compare equal");
1950 _VSTD::swap(this->__begin_, __x.__begin_);1942 std::swap(this->__begin_, __x.__begin_);
1951 _VSTD::swap(this->__end_, __x.__end_);1943 std::swap(this->__end_, __x.__end_);
1952 _VSTD::swap(this->__end_cap(), __x.__end_cap());1944 std::swap(this->__end_cap(), __x.__end_cap());
1953 _VSTD::__swap_allocator(this->__alloc(), __x.__alloc(),1945 std::__swap_allocator(this->__alloc(), __x.__alloc(),
1954 integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>());1946 integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>());
1955 std::__debug_db_swap(this, std::addressof(__x));1947 std::__debug_db_swap(this, std::addressof(__x));
1956}1948}
19571949
1958template <class _Tp, class _Allocator>1950template <class _Tp, class _Allocator>
1959_LIBCPP_CONSTEXPR_AFTER_CXX171951_LIBCPP_CONSTEXPR_SINCE_CXX20
1960bool1952bool
1961vector<_Tp, _Allocator>::__invariants() const1953vector<_Tp, _Allocator>::__invariants() const
1962{1954{
...@@ -2012,7 +2004,7 @@ vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __...@@ -2012,7 +2004,7 @@ vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __
2012#endif // _LIBCPP_ENABLE_DEBUG_MODE2004#endif // _LIBCPP_ENABLE_DEBUG_MODE
20132005
2014template <class _Tp, class _Allocator>2006template <class _Tp, class _Allocator>
2015inline _LIBCPP_INLINE_VISIBILITY2007inline _LIBCPP_HIDE_FROM_ABI
2016void2008void
2017vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) {2009vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) {
2018#ifdef _LIBCPP_ENABLE_DEBUG_MODE2010#ifdef _LIBCPP_ENABLE_DEBUG_MODE
...@@ -2023,7 +2015,7 @@ vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) {...@@ -2023,7 +2015,7 @@ vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) {
2023 if (__i->base() > __new_last) {2015 if (__i->base() > __new_last) {
2024 (*__p)->__c_ = nullptr;2016 (*__p)->__c_ = nullptr;
2025 if (--__c->end_ != __p)2017 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*));
2027 }2019 }
2028 }2020 }
2029 __get_db()->unlock();2021 __get_db()->unlock();
...@@ -2059,11 +2051,11 @@ public:...@@ -2059,11 +2051,11 @@ public:
2059 typedef __bit_iterator<vector, true> const_pointer;2051 typedef __bit_iterator<vector, true> const_pointer;
2060 typedef pointer iterator;2052 typedef pointer iterator;
2061 typedef const_pointer const_iterator;2053 typedef const_pointer const_iterator;
2062 typedef _VSTD::reverse_iterator<iterator> reverse_iterator;2054 typedef std::reverse_iterator<iterator> reverse_iterator;
2063 typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;2055 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
20642056
2065private:2057private:
2066 typedef typename __rebind_alloc_helper<__alloc_traits, __storage_type>::type __storage_allocator;2058 typedef __rebind_alloc<__alloc_traits, __storage_type> __storage_allocator;
2067 typedef allocator_traits<__storage_allocator> __storage_traits;2059 typedef allocator_traits<__storage_allocator> __storage_traits;
2068 typedef typename __storage_traits::pointer __storage_pointer;2060 typedef typename __storage_traits::pointer __storage_pointer;
2069 typedef typename __storage_traits::const_pointer __const_storage_pointer;2061 typedef typename __storage_traits::const_pointer __const_storage_pointer;
...@@ -2079,81 +2071,99 @@ public:...@@ -2079,81 +2071,99 @@ public:
2079 typedef __bit_const_reference<vector> const_reference;2071 typedef __bit_const_reference<vector> const_reference;
2080#endif2072#endif
2081private:2073private:
2082 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172074 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2083 size_type& __cap() _NOEXCEPT2075 size_type& __cap() _NOEXCEPT
2084 {return __cap_alloc_.first();}2076 {return __cap_alloc_.first();}
2085 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172077 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2086 const size_type& __cap() const _NOEXCEPT2078 const size_type& __cap() const _NOEXCEPT
2087 {return __cap_alloc_.first();}2079 {return __cap_alloc_.first();}
2088 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172080 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2089 __storage_allocator& __alloc() _NOEXCEPT2081 __storage_allocator& __alloc() _NOEXCEPT
2090 {return __cap_alloc_.second();}2082 {return __cap_alloc_.second();}
2091 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172083 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2092 const __storage_allocator& __alloc() const _NOEXCEPT2084 const __storage_allocator& __alloc() const _NOEXCEPT
2093 {return __cap_alloc_.second();}2085 {return __cap_alloc_.second();}
20942086
2095 static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);2087 static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
20962088
2097 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172089 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2098 static size_type __internal_cap_to_external(size_type __n) _NOEXCEPT2090 static size_type __internal_cap_to_external(size_type __n) _NOEXCEPT
2099 {return __n * __bits_per_word;}2091 {return __n * __bits_per_word;}
2100 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172092 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2101 static size_type __external_cap_to_internal(size_type __n) _NOEXCEPT2093 static size_type __external_cap_to_internal(size_type __n) _NOEXCEPT
2102 {return (__n - 1) / __bits_per_word + 1;}2094 {return (__n - 1) / __bits_per_word + 1;}
21032095
2104public:2096public:
2105 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172097 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2106 vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);2098 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)
2109#if _LIBCPP_STD_VER <= 142101#if _LIBCPP_STD_VER <= 14
2110 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);2102 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);
2111#else2103#else
2112 _NOEXCEPT;2104 _NOEXCEPT;
2113#endif2105#endif
2114 _LIBCPP_CONSTEXPR_AFTER_CXX17 ~vector();2106
2115 _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n);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);
2116#if _LIBCPP_STD_VER > 112126#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);
2118#endif2128#endif
2119 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __v);2129 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 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);2130 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(size_type __n, const value_type& __v, const allocator_type& __a);
2121 template <class _InputIterator>2131 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,
2123 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type* = 0);2133 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type* = 0);
2124 template <class _InputIterator>2134 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,
2126 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type* = 0);2136 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type* = 0);
2127 template <class _ForwardIterator>2137 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,
2129 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);2139 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);
2130 template <class _ForwardIterator>2140 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,
2132 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);2142 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);
21332143
2134 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __v);2144 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(const vector& __v);
2135 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __v, const allocator_type& __a);2145 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(const vector& __v, const allocator_type& __a);
2136 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector& operator=(const vector& __v);2146 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector& operator=(const vector& __v);
21372147
2138#ifndef _LIBCPP_CXX03_LANG2148#ifndef _LIBCPP_CXX03_LANG
2139 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(initializer_list<value_type> __il);2149 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(initializer_list<value_type> __il);
2140 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(initializer_list<value_type> __il, const allocator_type& __a);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_CXX172152 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2143 vector& operator=(initializer_list<value_type> __il)2153 vector& operator=(initializer_list<value_type> __il)
2144 {assign(__il.begin(), __il.end()); return *this;}2154 {assign(__il.begin(), __il.end()); return *this;}
21452155
2146#endif // !_LIBCPP_CXX03_LANG2156#endif // !_LIBCPP_CXX03_LANG
21472157
2148 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172158 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2149 vector(vector&& __v)2159 vector(vector&& __v)
2150#if _LIBCPP_STD_VER > 142160#if _LIBCPP_STD_VER > 14
2151 noexcept;2161 noexcept;
2152#else2162#else
2153 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);2163 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
2154#endif2164#endif
2155 _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(vector&& __v, const __type_identity_t<allocator_type>& __a);2165 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(vector&& __v, const __type_identity_t<allocator_type>& __a);
2156 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172166 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2157 vector& operator=(vector&& __v)2167 vector& operator=(vector&& __v)
2158 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));2168 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
21592169
...@@ -2161,162 +2171,162 @@ public:...@@ -2161,162 +2171,162 @@ public:
2161 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,2171 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
2162 void2172 void
2163 >::type2173 >::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);
2165 template <class _ForwardIterator>2175 template <class _ForwardIterator>
2166 typename enable_if2176 typename enable_if
2167 <2177 <
2168 __is_cpp17_forward_iterator<_ForwardIterator>::value,2178 __is_cpp17_forward_iterator<_ForwardIterator>::value,
2169 void2179 void
2170 >::type2180 >::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
2175#ifndef _LIBCPP_CXX03_LANG2185#ifndef _LIBCPP_CXX03_LANG
2176 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172186 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2177 void assign(initializer_list<value_type> __il)2187 void assign(initializer_list<value_type> __il)
2178 {assign(__il.begin(), __il.end());}2188 {assign(__il.begin(), __il.end());}
2179#endif2189#endif
21802190
2181 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 allocator_type get_allocator() const _NOEXCEPT2191 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator_type get_allocator() const _NOEXCEPT
2182 {return allocator_type(this->__alloc());}2192 {return allocator_type(this->__alloc());}
21832193
2184 _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT;2194 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT;
2185 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172195 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2186 size_type capacity() const _NOEXCEPT2196 size_type capacity() const _NOEXCEPT
2187 {return __internal_cap_to_external(__cap());}2197 {return __internal_cap_to_external(__cap());}
2188 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172198 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2189 size_type size() const _NOEXCEPT2199 size_type size() const _NOEXCEPT
2190 {return __size_;}2200 {return __size_;}
2191 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172201 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2192 bool empty() const _NOEXCEPT2202 bool empty() const _NOEXCEPT
2193 {return __size_ == 0;}2203 {return __size_ == 0;}
2194 _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n);2204 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reserve(size_type __n);
2195 _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT;2205 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT;
21962206
2197 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172207 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2198 iterator begin() _NOEXCEPT2208 iterator begin() _NOEXCEPT
2199 {return __make_iter(0);}2209 {return __make_iter(0);}
2200 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172210 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2201 const_iterator begin() const _NOEXCEPT2211 const_iterator begin() const _NOEXCEPT
2202 {return __make_iter(0);}2212 {return __make_iter(0);}
2203 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172213 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2204 iterator end() _NOEXCEPT2214 iterator end() _NOEXCEPT
2205 {return __make_iter(__size_);}2215 {return __make_iter(__size_);}
2206 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172216 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2207 const_iterator end() const _NOEXCEPT2217 const_iterator end() const _NOEXCEPT
2208 {return __make_iter(__size_);}2218 {return __make_iter(__size_);}
22092219
2210 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172220 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2211 reverse_iterator rbegin() _NOEXCEPT2221 reverse_iterator rbegin() _NOEXCEPT
2212 {return reverse_iterator(end());}2222 {return reverse_iterator(end());}
2213 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172223 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2214 const_reverse_iterator rbegin() const _NOEXCEPT2224 const_reverse_iterator rbegin() const _NOEXCEPT
2215 {return const_reverse_iterator(end());}2225 {return const_reverse_iterator(end());}
2216 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172226 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2217 reverse_iterator rend() _NOEXCEPT2227 reverse_iterator rend() _NOEXCEPT
2218 {return reverse_iterator(begin());}2228 {return reverse_iterator(begin());}
2219 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172229 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2220 const_reverse_iterator rend() const _NOEXCEPT2230 const_reverse_iterator rend() const _NOEXCEPT
2221 {return const_reverse_iterator(begin());}2231 {return const_reverse_iterator(begin());}
22222232
2223 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172233 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2224 const_iterator cbegin() const _NOEXCEPT2234 const_iterator cbegin() const _NOEXCEPT
2225 {return __make_iter(0);}2235 {return __make_iter(0);}
2226 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172236 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2227 const_iterator cend() const _NOEXCEPT2237 const_iterator cend() const _NOEXCEPT
2228 {return __make_iter(__size_);}2238 {return __make_iter(__size_);}
2229 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172239 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2230 const_reverse_iterator crbegin() const _NOEXCEPT2240 const_reverse_iterator crbegin() const _NOEXCEPT
2231 {return rbegin();}2241 {return rbegin();}
2232 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172242 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2233 const_reverse_iterator crend() const _NOEXCEPT2243 const_reverse_iterator crend() const _NOEXCEPT
2234 {return rend();}2244 {return rend();}
22352245
2236 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator[](size_type __n) {return __make_ref(__n);}2246 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 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);}2247 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference operator[](size_type __n) const {return __make_ref(__n);}
2238 reference at(size_type __n);2248 _LIBCPP_HIDE_FROM_ABI reference at(size_type __n);
2239 const_reference at(size_type __n) const;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);}2251 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference front() {return __make_ref(0);}
2242 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference front() const {return __make_ref(0);}2252 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference front() const {return __make_ref(0);}
2243 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference back() {return __make_ref(__size_ - 1);}2253 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference back() {return __make_ref(__size_ - 1);}
2244 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference back() const {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);
2247#if _LIBCPP_STD_VER > 112257#if _LIBCPP_STD_VER > 11
2248 template <class... _Args>2258 template <class... _Args>
2249#if _LIBCPP_STD_VER > 142259#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)
2251#else2261#else
2252 _LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args)2262 _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args)
2253#endif2263#endif
2254 {2264 {
2255 push_back ( value_type ( _VSTD::forward<_Args>(__args)... ));2265 push_back ( value_type ( std::forward<_Args>(__args)... ));
2256#if _LIBCPP_STD_VER > 142266#if _LIBCPP_STD_VER > 14
2257 return this->back();2267 return this->back();
2258#endif2268#endif
2259 }2269 }
2260#endif2270#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
2264#if _LIBCPP_STD_VER > 112274#if _LIBCPP_STD_VER > 11
2265 template <class... _Args>2275 template <class... _Args>
2266 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator emplace(const_iterator __position, _Args&&... __args)2276 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator emplace(const_iterator __position, _Args&&... __args)
2267 { return insert ( __position, value_type ( _VSTD::forward<_Args>(__args)... )); }2277 { return insert ( __position, value_type ( std::forward<_Args>(__args)... )); }
2268#endif2278#endif
22692279
2270 _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, const value_type& __x);2280 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 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);2281 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __position, size_type __n, const value_type& __x);
2272 template <class _InputIterator>2282 template <class _InputIterator>
2273 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,2283 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
2274 iterator2284 iterator
2275 >::type2285 >::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);
2277 template <class _ForwardIterator>2287 template <class _ForwardIterator>
2278 typename enable_if2288 typename enable_if
2279 <2289 <
2280 __is_cpp17_forward_iterator<_ForwardIterator>::value,2290 __is_cpp17_forward_iterator<_ForwardIterator>::value,
2281 iterator2291 iterator
2282 >::type2292 >::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
2285#ifndef _LIBCPP_CXX03_LANG2295#ifndef _LIBCPP_CXX03_LANG
2286 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172296 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2287 iterator insert(const_iterator __position, initializer_list<value_type> __il)2297 iterator insert(const_iterator __position, initializer_list<value_type> __il)
2288 {return insert(__position, __il.begin(), __il.end());}2298 {return insert(__position, __il.begin(), __il.end());}
2289#endif2299#endif
22902300
2291 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __position);2301 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __position);
2292 _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __first, const_iterator __last);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_CXX172304 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2295 void clear() _NOEXCEPT {__size_ = 0;}2305 void clear() _NOEXCEPT {__size_ = 0;}
22962306
2297 _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(vector&)2307 _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(vector&)
2298#if _LIBCPP_STD_VER >= 142308#if _LIBCPP_STD_VER >= 14
2299 _NOEXCEPT;2309 _NOEXCEPT;
2300#else2310#else
2301 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||2311 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
2302 __is_nothrow_swappable<allocator_type>::value);2312 __is_nothrow_swappable<allocator_type>::value);
2303#endif2313#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);2316 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __sz, value_type __x = false);
2307 _LIBCPP_CONSTEXPR_AFTER_CXX17 void flip() _NOEXCEPT;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
2311private:2321private:
2312 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI2322 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
2313 void __throw_length_error() const {2323 void __throw_length_error() const {
2314 _VSTD::__throw_length_error("vector");2324 std::__throw_length_error("vector");
2315 }2325 }
23162326
2317 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI2327 _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
2318 void __throw_out_of_range() const {2328 void __throw_out_of_range() const {
2319 _VSTD::__throw_out_of_range("vector");2329 std::__throw_out_of_range("vector");
2320 }2330 }
23212331
2322 // Allocate space for __n objects2332 // Allocate space for __n objects
...@@ -2326,7 +2336,7 @@ private:...@@ -2326,7 +2336,7 @@ private:
2326 // Precondition: __n > 02336 // Precondition: __n > 0
2327 // Postcondition: capacity() >= __n2337 // Postcondition: capacity() >= __n
2328 // Postcondition: size() == 02338 // 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) {
2330 if (__n > max_size())2340 if (__n > max_size())
2331 __throw_length_error();2341 __throw_length_error();
2332 auto __allocation = std::__allocate_at_least(__alloc(), __external_cap_to_internal(__n));2342 auto __allocation = std::__allocate_at_least(__alloc(), __external_cap_to_internal(__n));
...@@ -2339,43 +2349,43 @@ private:...@@ -2339,43 +2349,43 @@ private:
2339 }2349 }
2340 }2350 }
23412351
2342 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vdeallocate() _NOEXCEPT;2352 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __vdeallocate() _NOEXCEPT;
2343 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172353 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2344 static size_type __align_it(size_type __new_size) _NOEXCEPT2354 static size_type __align_it(size_type __new_size) _NOEXCEPT
2345 {return (__new_size + (__bits_per_word-1)) & ~((size_type)__bits_per_word-1);}2355 {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;2356 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 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);2357 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct_at_end(size_type __n, bool __x);
2348 template <class _ForwardIterator>2358 template <class _ForwardIterator>
2349 typename enable_if2359 typename enable_if
2350 <2360 <
2351 __is_cpp17_forward_iterator<_ForwardIterator>::value,2361 __is_cpp17_forward_iterator<_ForwardIterator>::value,
2352 void2362 void
2353 >::type2363 >::type
2354 _LIBCPP_CONSTEXPR_AFTER_CXX17 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);2364 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
2355 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n, const_reference __x);2365 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __append(size_type __n, const_reference __x);
2356 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172366 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2357 reference __make_ref(size_type __pos) _NOEXCEPT2367 reference __make_ref(size_type __pos) _NOEXCEPT
2358 {return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}2368 {return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}
2359 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172369 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2360 const_reference __make_ref(size_type __pos) const _NOEXCEPT {2370 const_reference __make_ref(size_type __pos) const _NOEXCEPT {
2361 return __bit_const_reference<vector>(__begin_ + __pos / __bits_per_word,2371 return __bit_const_reference<vector>(__begin_ + __pos / __bits_per_word,
2362 __storage_type(1) << __pos % __bits_per_word);2372 __storage_type(1) << __pos % __bits_per_word);
2363 }2373 }
2364 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172374 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2365 iterator __make_iter(size_type __pos) _NOEXCEPT2375 iterator __make_iter(size_type __pos) _NOEXCEPT
2366 {return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}2376 {return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}
2367 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172377 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2368 const_iterator __make_iter(size_type __pos) const _NOEXCEPT2378 const_iterator __make_iter(size_type __pos) const _NOEXCEPT
2369 {return const_iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}2379 {return const_iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}
2370 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172380 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2371 iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT2381 iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT
2372 {return begin() + (__p - cbegin());}2382 {return begin() + (__p - cbegin());}
23732383
2374 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172384 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2375 void __copy_assign_alloc(const vector& __v)2385 void __copy_assign_alloc(const vector& __v)
2376 {__copy_assign_alloc(__v, integral_constant<bool,2386 {__copy_assign_alloc(__v, integral_constant<bool,
2377 __storage_traits::propagate_on_container_copy_assignment::value>());}2387 __storage_traits::propagate_on_container_copy_assignment::value>());}
2378 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172388 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2379 void __copy_assign_alloc(const vector& __c, true_type)2389 void __copy_assign_alloc(const vector& __c, true_type)
2380 {2390 {
2381 if (__alloc() != __c.__alloc())2391 if (__alloc() != __c.__alloc())
...@@ -2383,33 +2393,33 @@ private:...@@ -2383,33 +2393,33 @@ private:
2383 __alloc() = __c.__alloc();2393 __alloc() = __c.__alloc();
2384 }2394 }
23852395
2386 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172396 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2387 void __copy_assign_alloc(const vector&, false_type)2397 void __copy_assign_alloc(const vector&, false_type)
2388 {}2398 {}
23892399
2390 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, false_type);2400 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign(vector& __c, false_type);
2391 _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, true_type)2401 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign(vector& __c, true_type)
2392 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);2402 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
2393 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172403 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2394 void __move_assign_alloc(vector& __c)2404 void __move_assign_alloc(vector& __c)
2395 _NOEXCEPT_(2405 _NOEXCEPT_(
2396 !__storage_traits::propagate_on_container_move_assignment::value ||2406 !__storage_traits::propagate_on_container_move_assignment::value ||
2397 is_nothrow_move_assignable<allocator_type>::value)2407 is_nothrow_move_assignable<allocator_type>::value)
2398 {__move_assign_alloc(__c, integral_constant<bool,2408 {__move_assign_alloc(__c, integral_constant<bool,
2399 __storage_traits::propagate_on_container_move_assignment::value>());}2409 __storage_traits::propagate_on_container_move_assignment::value>());}
2400 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172410 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2401 void __move_assign_alloc(vector& __c, true_type)2411 void __move_assign_alloc(vector& __c, true_type)
2402 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)2412 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
2403 {2413 {
2404 __alloc() = _VSTD::move(__c.__alloc());2414 __alloc() = std::move(__c.__alloc());
2405 }2415 }
24062416
2407 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172417 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2408 void __move_assign_alloc(vector&, false_type)2418 void __move_assign_alloc(vector&, false_type)
2409 _NOEXCEPT2419 _NOEXCEPT
2410 {}2420 {}
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
2414 friend class __bit_reference<vector>;2424 friend class __bit_reference<vector>;
2415 friend class __bit_const_reference<vector>;2425 friend class __bit_const_reference<vector>;
...@@ -2420,7 +2430,7 @@ private:...@@ -2420,7 +2430,7 @@ private:
2420};2430};
24212431
2422template <class _Allocator>2432template <class _Allocator>
2423_LIBCPP_CONSTEXPR_AFTER_CXX17 void2433_LIBCPP_CONSTEXPR_SINCE_CXX20 void
2424vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT2434vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT
2425{2435{
2426 if (this->__begin_ != nullptr)2436 if (this->__begin_ != nullptr)
...@@ -2433,7 +2443,7 @@ vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT...@@ -2433,7 +2443,7 @@ vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT
2433}2443}
24342444
2435template <class _Allocator>2445template <class _Allocator>
2436_LIBCPP_CONSTEXPR_AFTER_CXX172446_LIBCPP_CONSTEXPR_SINCE_CXX20
2437typename vector<bool, _Allocator>::size_type2447typename vector<bool, _Allocator>::size_type
2438vector<bool, _Allocator>::max_size() const _NOEXCEPT2448vector<bool, _Allocator>::max_size() const _NOEXCEPT
2439{2449{
...@@ -2446,7 +2456,7 @@ vector<bool, _Allocator>::max_size() const _NOEXCEPT...@@ -2446,7 +2456,7 @@ vector<bool, _Allocator>::max_size() const _NOEXCEPT
24462456
2447// Precondition: __new_size > capacity()2457// Precondition: __new_size > capacity()
2448template <class _Allocator>2458template <class _Allocator>
2449inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172459inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2450typename vector<bool, _Allocator>::size_type2460typename vector<bool, _Allocator>::size_type
2451vector<bool, _Allocator>::__recommend(size_type __new_size) const2461vector<bool, _Allocator>::__recommend(size_type __new_size) const
2452{2462{
...@@ -2456,7 +2466,7 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const...@@ -2456,7 +2466,7 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const
2456 const size_type __cap = capacity();2466 const size_type __cap = capacity();
2457 if (__cap >= __ms / 2)2467 if (__cap >= __ms / 2)
2458 return __ms;2468 return __ms;
2459 return _VSTD::max(2 * __cap, __align_it(__new_size));2469 return std::max(2 * __cap, __align_it(__new_size));
2460}2470}
24612471
2462// Default constructs __n objects starting at __end_2472// Default constructs __n objects starting at __end_
...@@ -2464,7 +2474,7 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const...@@ -2464,7 +2474,7 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const
2464// Precondition: size() + __n <= capacity()2474// Precondition: size() + __n <= capacity()
2465// Postcondition: size() == size() + __n2475// Postcondition: size() == size() + __n
2466template <class _Allocator>2476template <class _Allocator>
2467inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172477inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2468void2478void
2469vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x)2479vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x)
2470{2480{
...@@ -2477,12 +2487,12 @@ vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x)...@@ -2477,12 +2487,12 @@ vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x)
2477 else2487 else
2478 this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0);2488 this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0);
2479 }2489 }
2480 _VSTD::fill_n(__make_iter(__old_size), __n, __x);2490 std::fill_n(__make_iter(__old_size), __n, __x);
2481}2491}
24822492
2483template <class _Allocator>2493template <class _Allocator>
2484template <class _ForwardIterator>2494template <class _ForwardIterator>
2485_LIBCPP_CONSTEXPR_AFTER_CXX172495_LIBCPP_CONSTEXPR_SINCE_CXX20
2486typename enable_if2496typename enable_if
2487<2497<
2488 __is_cpp17_forward_iterator<_ForwardIterator>::value,2498 __is_cpp17_forward_iterator<_ForwardIterator>::value,
...@@ -2491,7 +2501,7 @@ typename enable_if...@@ -2491,7 +2501,7 @@ typename enable_if
2491vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)2501vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
2492{2502{
2493 size_type __old_size = this->__size_;2503 size_type __old_size = this->__size_;
2494 this->__size_ += _VSTD::distance(__first, __last);2504 this->__size_ += std::distance(__first, __last);
2495 if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word))2505 if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word))
2496 {2506 {
2497 if (this->__size_ <= __bits_per_word)2507 if (this->__size_ <= __bits_per_word)
...@@ -2499,11 +2509,11 @@ vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardI...@@ -2499,11 +2509,11 @@ vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardI
2499 else2509 else
2500 this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0);2510 this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0);
2501 }2511 }
2502 _VSTD::copy(__first, __last, __make_iter(__old_size));2512 std::copy(__first, __last, __make_iter(__old_size));
2503}2513}
25042514
2505template <class _Allocator>2515template <class _Allocator>
2506inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172516inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2507vector<bool, _Allocator>::vector()2517vector<bool, _Allocator>::vector()
2508 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)2518 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
2509 : __begin_(nullptr),2519 : __begin_(nullptr),
...@@ -2513,7 +2523,7 @@ vector<bool, _Allocator>::vector()...@@ -2513,7 +2523,7 @@ vector<bool, _Allocator>::vector()
2513}2523}
25142524
2515template <class _Allocator>2525template <class _Allocator>
2516inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172526inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2517vector<bool, _Allocator>::vector(const allocator_type& __a)2527vector<bool, _Allocator>::vector(const allocator_type& __a)
2518#if _LIBCPP_STD_VER <= 142528#if _LIBCPP_STD_VER <= 14
2519 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)2529 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
...@@ -2527,7 +2537,7 @@ vector<bool, _Allocator>::vector(const allocator_type& __a)...@@ -2527,7 +2537,7 @@ vector<bool, _Allocator>::vector(const allocator_type& __a)
2527}2537}
25282538
2529template <class _Allocator>2539template <class _Allocator>
2530_LIBCPP_CONSTEXPR_AFTER_CXX172540_LIBCPP_CONSTEXPR_SINCE_CXX20
2531vector<bool, _Allocator>::vector(size_type __n)2541vector<bool, _Allocator>::vector(size_type __n)
2532 : __begin_(nullptr),2542 : __begin_(nullptr),
2533 __size_(0),2543 __size_(0),
...@@ -2542,7 +2552,7 @@ vector<bool, _Allocator>::vector(size_type __n)...@@ -2542,7 +2552,7 @@ vector<bool, _Allocator>::vector(size_type __n)
25422552
2543#if _LIBCPP_STD_VER > 112553#if _LIBCPP_STD_VER > 11
2544template <class _Allocator>2554template <class _Allocator>
2545_LIBCPP_CONSTEXPR_AFTER_CXX172555_LIBCPP_CONSTEXPR_SINCE_CXX20
2546vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)2556vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)
2547 : __begin_(nullptr),2557 : __begin_(nullptr),
2548 __size_(0),2558 __size_(0),
...@@ -2557,7 +2567,7 @@ vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)...@@ -2557,7 +2567,7 @@ vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)
2557#endif2567#endif
25582568
2559template <class _Allocator>2569template <class _Allocator>
2560_LIBCPP_CONSTEXPR_AFTER_CXX172570_LIBCPP_CONSTEXPR_SINCE_CXX20
2561vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)2571vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
2562 : __begin_(nullptr),2572 : __begin_(nullptr),
2563 __size_(0),2573 __size_(0),
...@@ -2571,7 +2581,7 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)...@@ -2571,7 +2581,7 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
2571}2581}
25722582
2573template <class _Allocator>2583template <class _Allocator>
2574_LIBCPP_CONSTEXPR_AFTER_CXX172584_LIBCPP_CONSTEXPR_SINCE_CXX20
2575vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a)2585vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a)
2576 : __begin_(nullptr),2586 : __begin_(nullptr),
2577 __size_(0),2587 __size_(0),
...@@ -2586,7 +2596,7 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const all...@@ -2586,7 +2596,7 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const all
25862596
2587template <class _Allocator>2597template <class _Allocator>
2588template <class _InputIterator>2598template <class _InputIterator>
2589_LIBCPP_CONSTEXPR_AFTER_CXX172599_LIBCPP_CONSTEXPR_SINCE_CXX20
2590vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,2600vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
2591 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type*)2601 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type*)
2592 : __begin_(nullptr),2602 : __begin_(nullptr),
...@@ -2613,7 +2623,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,...@@ -2613,7 +2623,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
26132623
2614template <class _Allocator>2624template <class _Allocator>
2615template <class _InputIterator>2625template <class _InputIterator>
2616_LIBCPP_CONSTEXPR_AFTER_CXX172626_LIBCPP_CONSTEXPR_SINCE_CXX20
2617vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,2627vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
2618 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type*)2628 typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type*)
2619 : __begin_(nullptr),2629 : __begin_(nullptr),
...@@ -2640,42 +2650,46 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,...@@ -2640,42 +2650,46 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
26402650
2641template <class _Allocator>2651template <class _Allocator>
2642template <class _ForwardIterator>2652template <class _ForwardIterator>
2643_LIBCPP_CONSTEXPR_AFTER_CXX172653_LIBCPP_CONSTEXPR_SINCE_CXX20
2644vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last,2654vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last,
2645 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*)2655 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*)
2646 : __begin_(nullptr),2656 : __begin_(nullptr),
2647 __size_(0),2657 __size_(0),
2648 __cap_alloc_(0, __default_init_tag())2658 __cap_alloc_(0, __default_init_tag())
2649{2659{
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));
2651 if (__n > 0)2662 if (__n > 0)
2652 {2663 {
2653 __vallocate(__n);2664 __vallocate(__n);
2654 __construct_at_end(__first, __last);2665 __construct_at_end(__first, __last);
2655 }2666 }
2667 __guard.__complete();
2656}2668}
26572669
2658template <class _Allocator>2670template <class _Allocator>
2659template <class _ForwardIterator>2671template <class _ForwardIterator>
2660_LIBCPP_CONSTEXPR_AFTER_CXX172672_LIBCPP_CONSTEXPR_SINCE_CXX20
2661vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,2673vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
2662 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*)2674 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*)
2663 : __begin_(nullptr),2675 : __begin_(nullptr),
2664 __size_(0),2676 __size_(0),
2665 __cap_alloc_(0, static_cast<__storage_allocator>(__a))2677 __cap_alloc_(0, static_cast<__storage_allocator>(__a))
2666{2678{
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));
2668 if (__n > 0)2681 if (__n > 0)
2669 {2682 {
2670 __vallocate(__n);2683 __vallocate(__n);
2671 __construct_at_end(__first, __last);2684 __construct_at_end(__first, __last);
2672 }2685 }
2686 __guard.__complete();
2673}2687}
26742688
2675#ifndef _LIBCPP_CXX03_LANG2689#ifndef _LIBCPP_CXX03_LANG
26762690
2677template <class _Allocator>2691template <class _Allocator>
2678_LIBCPP_CONSTEXPR_AFTER_CXX172692_LIBCPP_CONSTEXPR_SINCE_CXX20
2679vector<bool, _Allocator>::vector(initializer_list<value_type> __il)2693vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
2680 : __begin_(nullptr),2694 : __begin_(nullptr),
2681 __size_(0),2695 __size_(0),
...@@ -2690,7 +2704,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il)...@@ -2690,7 +2704,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
2690}2704}
26912705
2692template <class _Allocator>2706template <class _Allocator>
2693_LIBCPP_CONSTEXPR_AFTER_CXX172707_LIBCPP_CONSTEXPR_SINCE_CXX20
2694vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)2708vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
2695 : __begin_(nullptr),2709 : __begin_(nullptr),
2696 __size_(0),2710 __size_(0),
...@@ -2707,16 +2721,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const alloca...@@ -2707,16 +2721,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const alloca
2707#endif // _LIBCPP_CXX03_LANG2721#endif // _LIBCPP_CXX03_LANG
27082722
2709template <class _Allocator>2723template <class _Allocator>
2710_LIBCPP_CONSTEXPR_AFTER_CXX172724_LIBCPP_CONSTEXPR_SINCE_CXX20
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
2720vector<bool, _Allocator>::vector(const vector& __v)2725vector<bool, _Allocator>::vector(const vector& __v)
2721 : __begin_(nullptr),2726 : __begin_(nullptr),
2722 __size_(0),2727 __size_(0),
...@@ -2730,7 +2735,7 @@ vector<bool, _Allocator>::vector(const vector& __v)...@@ -2730,7 +2735,7 @@ vector<bool, _Allocator>::vector(const vector& __v)
2730}2735}
27312736
2732template <class _Allocator>2737template <class _Allocator>
2733_LIBCPP_CONSTEXPR_AFTER_CXX172738_LIBCPP_CONSTEXPR_SINCE_CXX20
2734vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)2739vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)
2735 : __begin_(nullptr),2740 : __begin_(nullptr),
2736 __size_(0),2741 __size_(0),
...@@ -2744,11 +2749,11 @@ vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)...@@ -2744,11 +2749,11 @@ vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)
2744}2749}
27452750
2746template <class _Allocator>2751template <class _Allocator>
2747_LIBCPP_CONSTEXPR_AFTER_CXX172752_LIBCPP_CONSTEXPR_SINCE_CXX20
2748vector<bool, _Allocator>&2753vector<bool, _Allocator>&
2749vector<bool, _Allocator>::operator=(const vector& __v)2754vector<bool, _Allocator>::operator=(const vector& __v)
2750{2755{
2751 if (this != _VSTD::addressof(__v))2756 if (this != std::addressof(__v))
2752 {2757 {
2753 __copy_assign_alloc(__v);2758 __copy_assign_alloc(__v);
2754 if (__v.__size_)2759 if (__v.__size_)
...@@ -2758,7 +2763,7 @@ vector<bool, _Allocator>::operator=(const vector& __v)...@@ -2758,7 +2763,7 @@ vector<bool, _Allocator>::operator=(const vector& __v)
2758 __vdeallocate();2763 __vdeallocate();
2759 __vallocate(__v.__size_);2764 __vallocate(__v.__size_);
2760 }2765 }
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_);
2762 }2767 }
2763 __size_ = __v.__size_;2768 __size_ = __v.__size_;
2764 }2769 }
...@@ -2766,7 +2771,7 @@ vector<bool, _Allocator>::operator=(const vector& __v)...@@ -2766,7 +2771,7 @@ vector<bool, _Allocator>::operator=(const vector& __v)
2766}2771}
27672772
2768template <class _Allocator>2773template <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)
2770#if _LIBCPP_STD_VER > 142775#if _LIBCPP_STD_VER > 14
2771 _NOEXCEPT2776 _NOEXCEPT
2772#else2777#else
...@@ -2774,14 +2779,14 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 vector<bool, _All...@@ -2774,14 +2779,14 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 vector<bool, _All
2774#endif2779#endif
2775 : __begin_(__v.__begin_),2780 : __begin_(__v.__begin_),
2776 __size_(__v.__size_),2781 __size_(__v.__size_),
2777 __cap_alloc_(_VSTD::move(__v.__cap_alloc_)) {2782 __cap_alloc_(std::move(__v.__cap_alloc_)) {
2778 __v.__begin_ = nullptr;2783 __v.__begin_ = nullptr;
2779 __v.__size_ = 0;2784 __v.__size_ = 0;
2780 __v.__cap() = 0;2785 __v.__cap() = 0;
2781}2786}
27822787
2783template <class _Allocator>2788template <class _Allocator>
2784_LIBCPP_CONSTEXPR_AFTER_CXX172789_LIBCPP_CONSTEXPR_SINCE_CXX20
2785vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator_type>& __a)2790vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator_type>& __a)
2786 : __begin_(nullptr),2791 : __begin_(nullptr),
2787 __size_(0),2792 __size_(0),
...@@ -2803,7 +2808,7 @@ vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator...@@ -2803,7 +2808,7 @@ vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator
2803}2808}
28042809
2805template <class _Allocator>2810template <class _Allocator>
2806inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX172811inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
2807vector<bool, _Allocator>&2812vector<bool, _Allocator>&
2808vector<bool, _Allocator>::operator=(vector&& __v)2813vector<bool, _Allocator>::operator=(vector&& __v)
2809 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))2814 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
...@@ -2814,7 +2819,7 @@ vector<bool, _Allocator>::operator=(vector&& __v)...@@ -2814,7 +2819,7 @@ vector<bool, _Allocator>::operator=(vector&& __v)
2814}2819}
28152820
2816template <class _Allocator>2821template <class _Allocator>
2817_LIBCPP_CONSTEXPR_AFTER_CXX17 void2822_LIBCPP_CONSTEXPR_SINCE_CXX20 void
2818vector<bool, _Allocator>::__move_assign(vector& __c, false_type)2823vector<bool, _Allocator>::__move_assign(vector& __c, false_type)
2819{2824{
2820 if (__alloc() != __c.__alloc())2825 if (__alloc() != __c.__alloc())
...@@ -2824,7 +2829,7 @@ vector<bool, _Allocator>::__move_assign(vector& __c, false_type)...@@ -2824,7 +2829,7 @@ vector<bool, _Allocator>::__move_assign(vector& __c, false_type)
2824}2829}
28252830
2826template <class _Allocator>2831template <class _Allocator>
2827_LIBCPP_CONSTEXPR_AFTER_CXX17 void2832_LIBCPP_CONSTEXPR_SINCE_CXX20 void
2828vector<bool, _Allocator>::__move_assign(vector& __c, true_type)2833vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
2829 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)2834 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
2830{2835{
...@@ -2838,7 +2843,7 @@ vector<bool, _Allocator>::__move_assign(vector& __c, true_type)...@@ -2838,7 +2843,7 @@ vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
2838}2843}
28392844
2840template <class _Allocator>2845template <class _Allocator>
2841_LIBCPP_CONSTEXPR_AFTER_CXX17 void2846_LIBCPP_CONSTEXPR_SINCE_CXX20 void
2842vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)2847vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)
2843{2848{
2844 __size_ = 0;2849 __size_ = 0;
...@@ -2854,14 +2859,14 @@ vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)...@@ -2854,14 +2859,14 @@ vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)
2854 __v.__size_ = __n;2859 __v.__size_ = __n;
2855 swap(__v);2860 swap(__v);
2856 }2861 }
2857 _VSTD::fill_n(begin(), __n, __x);2862 std::fill_n(begin(), __n, __x);
2858 }2863 }
2859 std::__debug_db_invalidate_all(this);2864 std::__debug_db_invalidate_all(this);
2860}2865}
28612866
2862template <class _Allocator>2867template <class _Allocator>
2863template <class _InputIterator>2868template <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,
2865 void2870 void
2866>::type2871>::type
2867vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last)2872vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
...@@ -2873,7 +2878,7 @@ vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last)...@@ -2873,7 +2878,7 @@ vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
28732878
2874template <class _Allocator>2879template <class _Allocator>
2875template <class _ForwardIterator>2880template <class _ForwardIterator>
2876_LIBCPP_CONSTEXPR_AFTER_CXX172881_LIBCPP_CONSTEXPR_SINCE_CXX20
2877typename enable_if2882typename enable_if
2878<2883<
2879 __is_cpp17_forward_iterator<_ForwardIterator>::value,2884 __is_cpp17_forward_iterator<_ForwardIterator>::value,
...@@ -2882,7 +2887,7 @@ typename enable_if...@@ -2882,7 +2887,7 @@ typename enable_if
2882vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)2887vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)
2883{2888{
2884 clear();2889 clear();
2885 difference_type __ns = _VSTD::distance(__first, __last);2890 difference_type __ns = std::distance(__first, __last);
2886 _LIBCPP_ASSERT(__ns >= 0, "invalid range specified");2891 _LIBCPP_ASSERT(__ns >= 0, "invalid range specified");
2887 const size_t __n = static_cast<size_type>(__ns);2892 const size_t __n = static_cast<size_type>(__ns);
2888 if (__n)2893 if (__n)
...@@ -2897,7 +2902,7 @@ vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __la...@@ -2897,7 +2902,7 @@ vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __la
2897}2902}
28982903
2899template <class _Allocator>2904template <class _Allocator>
2900_LIBCPP_CONSTEXPR_AFTER_CXX17 void2905_LIBCPP_CONSTEXPR_SINCE_CXX20 void
2901vector<bool, _Allocator>::reserve(size_type __n)2906vector<bool, _Allocator>::reserve(size_type __n)
2902{2907{
2903 if (__n > capacity())2908 if (__n > capacity())
...@@ -2913,7 +2918,7 @@ vector<bool, _Allocator>::reserve(size_type __n)...@@ -2913,7 +2918,7 @@ vector<bool, _Allocator>::reserve(size_type __n)
2913}2918}
29142919
2915template <class _Allocator>2920template <class _Allocator>
2916_LIBCPP_CONSTEXPR_AFTER_CXX17 void2921_LIBCPP_CONSTEXPR_SINCE_CXX20 void
2917vector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT2922vector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT
2918{2923{
2919 if (__external_cap_to_internal(size()) > __cap())2924 if (__external_cap_to_internal(size()) > __cap())
...@@ -2951,7 +2956,7 @@ vector<bool, _Allocator>::at(size_type __n) const...@@ -2951,7 +2956,7 @@ vector<bool, _Allocator>::at(size_type __n) const
2951}2956}
29522957
2953template <class _Allocator>2958template <class _Allocator>
2954_LIBCPP_CONSTEXPR_AFTER_CXX17 void2959_LIBCPP_CONSTEXPR_SINCE_CXX20 void
2955vector<bool, _Allocator>::push_back(const value_type& __x)2960vector<bool, _Allocator>::push_back(const value_type& __x)
2956{2961{
2957 if (this->__size_ == this->capacity())2962 if (this->__size_ == this->capacity())
...@@ -2961,7 +2966,7 @@ vector<bool, _Allocator>::push_back(const value_type& __x)...@@ -2961,7 +2966,7 @@ vector<bool, _Allocator>::push_back(const value_type& __x)
2961}2966}
29622967
2963template <class _Allocator>2968template <class _Allocator>
2964_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<bool, _Allocator>::iterator2969_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator
2965vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __x)2970vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __x)
2966{2971{
2967 iterator __r;2972 iterator __r;
...@@ -2969,7 +2974,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __...@@ -2969,7 +2974,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __
2969 {2974 {
2970 const_iterator __old_end = end();2975 const_iterator __old_end = end();
2971 ++__size_;2976 ++__size_;
2972 _VSTD::copy_backward(__position, __old_end, end());2977 std::copy_backward(__position, __old_end, end());
2973 __r = __const_iterator_cast(__position);2978 __r = __const_iterator_cast(__position);
2974 }2979 }
2975 else2980 else
...@@ -2977,8 +2982,8 @@ vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __...@@ -2977,8 +2982,8 @@ vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __
2977 vector __v(get_allocator());2982 vector __v(get_allocator());
2978 __v.reserve(__recommend(__size_ + 1));2983 __v.reserve(__recommend(__size_ + 1));
2979 __v.__size_ = __size_ + 1;2984 __v.__size_ = __size_ + 1;
2980 __r = _VSTD::copy(cbegin(), __position, __v.begin());2985 __r = std::copy(cbegin(), __position, __v.begin());
2981 _VSTD::copy_backward(__position, cend(), __v.end());2986 std::copy_backward(__position, cend(), __v.end());
2982 swap(__v);2987 swap(__v);
2983 }2988 }
2984 *__r = __x;2989 *__r = __x;
...@@ -2986,7 +2991,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __...@@ -2986,7 +2991,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __
2986}2991}
29872992
2988template <class _Allocator>2993template <class _Allocator>
2989_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<bool, _Allocator>::iterator2994_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator
2990vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const value_type& __x)2995vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const value_type& __x)
2991{2996{
2992 iterator __r;2997 iterator __r;
...@@ -2995,7 +3000,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const...@@ -2995,7 +3000,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const
2995 {3000 {
2996 const_iterator __old_end = end();3001 const_iterator __old_end = end();
2997 __size_ += __n;3002 __size_ += __n;
2998 _VSTD::copy_backward(__position, __old_end, end());3003 std::copy_backward(__position, __old_end, end());
2999 __r = __const_iterator_cast(__position);3004 __r = __const_iterator_cast(__position);
3000 }3005 }
3001 else3006 else
...@@ -3003,17 +3008,17 @@ vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const...@@ -3003,17 +3008,17 @@ vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const
3003 vector __v(get_allocator());3008 vector __v(get_allocator());
3004 __v.reserve(__recommend(__size_ + __n));3009 __v.reserve(__recommend(__size_ + __n));
3005 __v.__size_ = __size_ + __n;3010 __v.__size_ = __size_ + __n;
3006 __r = _VSTD::copy(cbegin(), __position, __v.begin());3011 __r = std::copy(cbegin(), __position, __v.begin());
3007 _VSTD::copy_backward(__position, cend(), __v.end());3012 std::copy_backward(__position, cend(), __v.end());
3008 swap(__v);3013 swap(__v);
3009 }3014 }
3010 _VSTD::fill_n(__r, __n, __x);3015 std::fill_n(__r, __n, __x);
3011 return __r;3016 return __r;
3012}3017}
30133018
3014template <class _Allocator>3019template <class _Allocator>
3015template <class _InputIterator>3020template <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,
3017 typename vector<bool, _Allocator>::iterator3022 typename vector<bool, _Allocator>::iterator
3018>::type3023>::type
3019vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)3024vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
...@@ -3048,14 +3053,14 @@ vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __fir...@@ -3048,14 +3053,14 @@ vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __fir
3048 }3053 }
3049#endif // _LIBCPP_NO_EXCEPTIONS3054#endif // _LIBCPP_NO_EXCEPTIONS
3050 }3055 }
3051 __p = _VSTD::rotate(__p, __old_end, end());3056 __p = std::rotate(__p, __old_end, end());
3052 insert(__p, __v.begin(), __v.end());3057 insert(__p, __v.begin(), __v.end());
3053 return begin() + __off;3058 return begin() + __off;
3054}3059}
30553060
3056template <class _Allocator>3061template <class _Allocator>
3057template <class _ForwardIterator>3062template <class _ForwardIterator>
3058_LIBCPP_CONSTEXPR_AFTER_CXX173063_LIBCPP_CONSTEXPR_SINCE_CXX20
3059typename enable_if3064typename enable_if
3060<3065<
3061 __is_cpp17_forward_iterator<_ForwardIterator>::value,3066 __is_cpp17_forward_iterator<_ForwardIterator>::value,
...@@ -3063,7 +3068,7 @@ typename enable_if...@@ -3063,7 +3068,7 @@ typename enable_if
3063>::type3068>::type
3064vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last)3069vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last)
3065{3070{
3066 const difference_type __n_signed = _VSTD::distance(__first, __last);3071 const difference_type __n_signed = std::distance(__first, __last);
3067 _LIBCPP_ASSERT(__n_signed >= 0, "invalid range specified");3072 _LIBCPP_ASSERT(__n_signed >= 0, "invalid range specified");
3068 const size_type __n = static_cast<size_type>(__n_signed);3073 const size_type __n = static_cast<size_type>(__n_signed);
3069 iterator __r;3074 iterator __r;
...@@ -3072,7 +3077,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __f...@@ -3072,7 +3077,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __f
3072 {3077 {
3073 const_iterator __old_end = end();3078 const_iterator __old_end = end();
3074 __size_ += __n;3079 __size_ += __n;
3075 _VSTD::copy_backward(__position, __old_end, end());3080 std::copy_backward(__position, __old_end, end());
3076 __r = __const_iterator_cast(__position);3081 __r = __const_iterator_cast(__position);
3077 }3082 }
3078 else3083 else
...@@ -3080,39 +3085,39 @@ vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __f...@@ -3080,39 +3085,39 @@ vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __f
3080 vector __v(get_allocator());3085 vector __v(get_allocator());
3081 __v.reserve(__recommend(__size_ + __n));3086 __v.reserve(__recommend(__size_ + __n));
3082 __v.__size_ = __size_ + __n;3087 __v.__size_ = __size_ + __n;
3083 __r = _VSTD::copy(cbegin(), __position, __v.begin());3088 __r = std::copy(cbegin(), __position, __v.begin());
3084 _VSTD::copy_backward(__position, cend(), __v.end());3089 std::copy_backward(__position, cend(), __v.end());
3085 swap(__v);3090 swap(__v);
3086 }3091 }
3087 _VSTD::copy(__first, __last, __r);3092 std::copy(__first, __last, __r);
3088 return __r;3093 return __r;
3089}3094}
30903095
3091template <class _Allocator>3096template <class _Allocator>
3092inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX173097inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
3093typename vector<bool, _Allocator>::iterator3098typename vector<bool, _Allocator>::iterator
3094vector<bool, _Allocator>::erase(const_iterator __position)3099vector<bool, _Allocator>::erase(const_iterator __position)
3095{3100{
3096 iterator __r = __const_iterator_cast(__position);3101 iterator __r = __const_iterator_cast(__position);
3097 _VSTD::copy(__position + 1, this->cend(), __r);3102 std::copy(__position + 1, this->cend(), __r);
3098 --__size_;3103 --__size_;
3099 return __r;3104 return __r;
3100}3105}
31013106
3102template <class _Allocator>3107template <class _Allocator>
3103_LIBCPP_CONSTEXPR_AFTER_CXX173108_LIBCPP_CONSTEXPR_SINCE_CXX20
3104typename vector<bool, _Allocator>::iterator3109typename vector<bool, _Allocator>::iterator
3105vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last)3110vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last)
3106{3111{
3107 iterator __r = __const_iterator_cast(__first);3112 iterator __r = __const_iterator_cast(__first);
3108 difference_type __d = __last - __first;3113 difference_type __d = __last - __first;
3109 _VSTD::copy(__last, this->cend(), __r);3114 std::copy(__last, this->cend(), __r);
3110 __size_ -= __d;3115 __size_ -= __d;
3111 return __r;3116 return __r;
3112}3117}
31133118
3114template <class _Allocator>3119template <class _Allocator>
3115_LIBCPP_CONSTEXPR_AFTER_CXX17 void3120_LIBCPP_CONSTEXPR_SINCE_CXX20 void
3116vector<bool, _Allocator>::swap(vector& __x)3121vector<bool, _Allocator>::swap(vector& __x)
3117#if _LIBCPP_STD_VER >= 143122#if _LIBCPP_STD_VER >= 14
3118 _NOEXCEPT3123 _NOEXCEPT
...@@ -3121,15 +3126,15 @@ vector<bool, _Allocator>::swap(vector& __x)...@@ -3121,15 +3126,15 @@ vector<bool, _Allocator>::swap(vector& __x)
3121 __is_nothrow_swappable<allocator_type>::value)3126 __is_nothrow_swappable<allocator_type>::value)
3122#endif3127#endif
3123{3128{
3124 _VSTD::swap(this->__begin_, __x.__begin_);3129 std::swap(this->__begin_, __x.__begin_);
3125 _VSTD::swap(this->__size_, __x.__size_);3130 std::swap(this->__size_, __x.__size_);
3126 _VSTD::swap(this->__cap(), __x.__cap());3131 std::swap(this->__cap(), __x.__cap());
3127 _VSTD::__swap_allocator(this->__alloc(), __x.__alloc(),3132 std::__swap_allocator(this->__alloc(), __x.__alloc(),
3128 integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>());3133 integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>());
3129}3134}
31303135
3131template <class _Allocator>3136template <class _Allocator>
3132_LIBCPP_CONSTEXPR_AFTER_CXX17 void3137_LIBCPP_CONSTEXPR_SINCE_CXX20 void
3133vector<bool, _Allocator>::resize(size_type __sz, value_type __x)3138vector<bool, _Allocator>::resize(size_type __sz, value_type __x)
3134{3139{
3135 size_type __cs = size();3140 size_type __cs = size();
...@@ -3148,17 +3153,17 @@ vector<bool, _Allocator>::resize(size_type __sz, value_type __x)...@@ -3148,17 +3153,17 @@ vector<bool, _Allocator>::resize(size_type __sz, value_type __x)
3148 vector __v(get_allocator());3153 vector __v(get_allocator());
3149 __v.reserve(__recommend(__size_ + __n));3154 __v.reserve(__recommend(__size_ + __n));
3150 __v.__size_ = __size_ + __n;3155 __v.__size_ = __size_ + __n;
3151 __r = _VSTD::copy(cbegin(), cend(), __v.begin());3156 __r = std::copy(cbegin(), cend(), __v.begin());
3152 swap(__v);3157 swap(__v);
3153 }3158 }
3154 _VSTD::fill_n(__r, __n, __x);3159 std::fill_n(__r, __n, __x);
3155 }3160 }
3156 else3161 else
3157 __size_ = __sz;3162 __size_ = __sz;
3158}3163}
31593164
3160template <class _Allocator>3165template <class _Allocator>
3161_LIBCPP_CONSTEXPR_AFTER_CXX17 void3166_LIBCPP_CONSTEXPR_SINCE_CXX20 void
3162vector<bool, _Allocator>::flip() _NOEXCEPT3167vector<bool, _Allocator>::flip() _NOEXCEPT
3163{3168{
3164 // do middle whole words3169 // do middle whole words
...@@ -3177,7 +3182,7 @@ vector<bool, _Allocator>::flip() _NOEXCEPT...@@ -3177,7 +3182,7 @@ vector<bool, _Allocator>::flip() _NOEXCEPT
3177}3182}
31783183
3179template <class _Allocator>3184template <class _Allocator>
3180_LIBCPP_CONSTEXPR_AFTER_CXX17 bool3185_LIBCPP_CONSTEXPR_SINCE_CXX20 bool
3181vector<bool, _Allocator>::__invariants() const3186vector<bool, _Allocator>::__invariants() const
3182{3187{
3183 if (this->__begin_ == nullptr)3188 if (this->__begin_ == nullptr)
...@@ -3196,7 +3201,7 @@ vector<bool, _Allocator>::__invariants() const...@@ -3196,7 +3201,7 @@ vector<bool, _Allocator>::__invariants() const
3196}3201}
31973202
3198template <class _Allocator>3203template <class _Allocator>
3199_LIBCPP_CONSTEXPR_AFTER_CXX17 size_t3204_LIBCPP_CONSTEXPR_SINCE_CXX20 size_t
3200vector<bool, _Allocator>::__hash_code() const _NOEXCEPT3205vector<bool, _Allocator>::__hash_code() const _NOEXCEPT
3201{3206{
3202 size_t __h = 0;3207 size_t __h = 0;
...@@ -3218,24 +3223,24 @@ template <class _Allocator>...@@ -3218,24 +3223,24 @@ template <class _Allocator>
3218struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> >3223struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> >
3219 : public __unary_function<vector<bool, _Allocator>, size_t>3224 : public __unary_function<vector<bool, _Allocator>, size_t>
3220{3225{
3221 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX173226 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
3222 size_t operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT3227 size_t operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT
3223 {return __vec.__hash_code();}3228 {return __vec.__hash_code();}
3224};3229};
32253230
3226template <class _Tp, class _Allocator>3231template <class _Tp, class _Allocator>
3227_LIBCPP_CONSTEXPR_AFTER_CXX173232_LIBCPP_CONSTEXPR_SINCE_CXX20
3228inline _LIBCPP_INLINE_VISIBILITY3233inline _LIBCPP_HIDE_FROM_ABI
3229bool3234bool
3230operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)3235operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
3231{3236{
3232 const typename vector<_Tp, _Allocator>::size_type __sz = __x.size();3237 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());
3234}3239}
32353240
3236template <class _Tp, class _Allocator>3241template <class _Tp, class _Allocator>
3237_LIBCPP_CONSTEXPR_AFTER_CXX173242_LIBCPP_CONSTEXPR_SINCE_CXX20
3238inline _LIBCPP_INLINE_VISIBILITY3243inline _LIBCPP_HIDE_FROM_ABI
3239bool3244bool
3240operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)3245operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
3241{3246{
...@@ -3243,17 +3248,17 @@ operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __...@@ -3243,17 +3248,17 @@ operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
3243}3248}
32443249
3245template <class _Tp, class _Allocator>3250template <class _Tp, class _Allocator>
3246_LIBCPP_CONSTEXPR_AFTER_CXX173251_LIBCPP_CONSTEXPR_SINCE_CXX20
3247inline _LIBCPP_INLINE_VISIBILITY3252inline _LIBCPP_HIDE_FROM_ABI
3248bool3253bool
3249operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)3254operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
3250{3255{
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());
3252}3257}
32533258
3254template <class _Tp, class _Allocator>3259template <class _Tp, class _Allocator>
3255_LIBCPP_CONSTEXPR_AFTER_CXX173260_LIBCPP_CONSTEXPR_SINCE_CXX20
3256inline _LIBCPP_INLINE_VISIBILITY3261inline _LIBCPP_HIDE_FROM_ABI
3257bool3262bool
3258operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)3263operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
3259{3264{
...@@ -3261,8 +3266,8 @@ operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __...@@ -3261,8 +3266,8 @@ operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
3261}3266}
32623267
3263template <class _Tp, class _Allocator>3268template <class _Tp, class _Allocator>
3264_LIBCPP_CONSTEXPR_AFTER_CXX173269_LIBCPP_CONSTEXPR_SINCE_CXX20
3265inline _LIBCPP_INLINE_VISIBILITY3270inline _LIBCPP_HIDE_FROM_ABI
3266bool3271bool
3267operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)3272operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
3268{3273{
...@@ -3270,8 +3275,8 @@ operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __...@@ -3270,8 +3275,8 @@ operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
3270}3275}
32713276
3272template <class _Tp, class _Allocator>3277template <class _Tp, class _Allocator>
3273_LIBCPP_CONSTEXPR_AFTER_CXX173278_LIBCPP_CONSTEXPR_SINCE_CXX20
3274inline _LIBCPP_INLINE_VISIBILITY3279inline _LIBCPP_HIDE_FROM_ABI
3275bool3280bool
3276operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)3281operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
3277{3282{
...@@ -3279,8 +3284,8 @@ operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __...@@ -3279,8 +3284,8 @@ operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
3279}3284}
32803285
3281template <class _Tp, class _Allocator>3286template <class _Tp, class _Allocator>
3282_LIBCPP_CONSTEXPR_AFTER_CXX173287_LIBCPP_CONSTEXPR_SINCE_CXX20
3283inline _LIBCPP_INLINE_VISIBILITY3288inline _LIBCPP_HIDE_FROM_ABI
3284void3289void
3285swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y)3290swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y)
3286 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))3291 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
...@@ -3290,34 +3295,72 @@ swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y)...@@ -3290,34 +3295,72 @@ swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y)
32903295
3291#if _LIBCPP_STD_VER > 173296#if _LIBCPP_STD_VER > 17
3292template <class _Tp, class _Allocator, class _Up>3297template <class _Tp, class _Allocator, class _Up>
3293_LIBCPP_CONSTEXPR_AFTER_CXX173298_LIBCPP_CONSTEXPR_SINCE_CXX20
3294inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type3299inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type
3295erase(vector<_Tp, _Allocator>& __c, const _Up& __v) {3300erase(vector<_Tp, _Allocator>& __c, const _Up& __v) {
3296 auto __old_size = __c.size();3301 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());
3298 return __old_size - __c.size();3303 return __old_size - __c.size();
3299}3304}
33003305
3301template <class _Tp, class _Allocator, class _Predicate>3306template <class _Tp, class _Allocator, class _Predicate>
3302_LIBCPP_CONSTEXPR_AFTER_CXX173307_LIBCPP_CONSTEXPR_SINCE_CXX20
3303inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type3308inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type
3304erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) {3309erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) {
3305 auto __old_size = __c.size();3310 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());
3307 return __old_size - __c.size();3312 return __old_size - __c.size();
3308}3313}
33093314
3310template <>3315template <>
3311inline constexpr bool __format::__enable_insertable<std::vector<char>> = true;3316inline constexpr bool __format::__enable_insertable<vector<char>> = true;
3312#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS3317#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
3313template <>3318template <>
3314inline constexpr bool __format::__enable_insertable<std::vector<wchar_t>> = true;3319inline constexpr bool __format::__enable_insertable<vector<wchar_t>> = true;
3315#endif3320#endif
33163321
3317#endif // _LIBCPP_STD_VER > 173322#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
3319_LIBCPP_END_NAMESPACE_STD3345_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
3321_LIBCPP_POP_MACROS3356_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
3323#endif // _LIBCPP_VECTOR3366#endif // _LIBCPP_VECTOR
lib/libcxx/include/version+22-11
...@@ -55,13 +55,16 @@ __cpp_lib_chrono_udls 201304L <chrono>...@@ -55,13 +55,16 @@ __cpp_lib_chrono_udls 201304L <chrono>
55__cpp_lib_clamp 201603L <algorithm>55__cpp_lib_clamp 201603L <algorithm>
56__cpp_lib_complex_udls 201309L <complex>56__cpp_lib_complex_udls 201309L <complex>
57__cpp_lib_concepts 202002L <concepts>57__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>
59__cpp_lib_constexpr_cmath 202202L <cmath> <cstdlib>61__cpp_lib_constexpr_cmath 202202L <cmath> <cstdlib>
60__cpp_lib_constexpr_complex 201711L <complex>62__cpp_lib_constexpr_complex 201711L <complex>
61__cpp_lib_constexpr_dynamic_alloc 201907L <memory>63__cpp_lib_constexpr_dynamic_alloc 201907L <memory>
62__cpp_lib_constexpr_functional 201907L <functional>64__cpp_lib_constexpr_functional 201907L <functional>
63__cpp_lib_constexpr_iterator 201811L <iterator>65__cpp_lib_constexpr_iterator 201811L <iterator>
64__cpp_lib_constexpr_memory 201811L <memory>66__cpp_lib_constexpr_memory 202202L <memory>
67 201811L // C++20
65__cpp_lib_constexpr_numeric 201911L <numeric>68__cpp_lib_constexpr_numeric 201911L <numeric>
66__cpp_lib_constexpr_string 201907L <string>69__cpp_lib_constexpr_string 201907L <string>
67__cpp_lib_constexpr_string_view 201811L <string_view>70__cpp_lib_constexpr_string_view 201811L <string_view>
...@@ -79,8 +82,10 @@ __cpp_lib_erase_if 202002L <deque> <forward...@@ -79,8 +82,10 @@ __cpp_lib_erase_if 202002L <deque> <forward
79__cpp_lib_exchange_function 201304L <utility>82__cpp_lib_exchange_function 201304L <utility>
80__cpp_lib_execution 201902L <execution>83__cpp_lib_execution 201902L <execution>
81 201603L // C++1784 201603L // C++17
85__cpp_lib_expected 202202L <expected>
82__cpp_lib_filesystem 201703L <filesystem>86__cpp_lib_filesystem 201703L <filesystem>
83__cpp_lib_format 202106L <format>87__cpp_lib_format 202106L <format>
88__cpp_lib_forward_like 202207L <utility>
84__cpp_lib_gcd_lcm 201606L <numeric>89__cpp_lib_gcd_lcm 201606L <numeric>
85__cpp_lib_generic_associative_lookup 201304L <map> <set>90__cpp_lib_generic_associative_lookup 201304L <map> <set>
86__cpp_lib_generic_unordered_lookup 201811L <unordered_map> <unordered_set>91__cpp_lib_generic_unordered_lookup 201811L <unordered_map> <unordered_set>
...@@ -132,7 +137,7 @@ __cpp_lib_out_ptr 202106L <memory>...@@ -132,7 +137,7 @@ __cpp_lib_out_ptr 202106L <memory>
132__cpp_lib_parallel_algorithm 201603L <algorithm> <numeric>137__cpp_lib_parallel_algorithm 201603L <algorithm> <numeric>
133__cpp_lib_polymorphic_allocator 201902L <memory_resource>138__cpp_lib_polymorphic_allocator 201902L <memory_resource>
134__cpp_lib_quoted_string_io 201304L <iomanip>139__cpp_lib_quoted_string_io 201304L <iomanip>
135__cpp_lib_ranges 201811L <algorithm> <functional> <iterator>140__cpp_lib_ranges 202106L <algorithm> <functional> <iterator>
136 <memory> <ranges>141 <memory> <ranges>
137__cpp_lib_ranges_chunk 202202L <ranges>142__cpp_lib_ranges_chunk 202202L <ranges>
138__cpp_lib_ranges_chunk_by 202202L <ranges>143__cpp_lib_ranges_chunk_by 202202L <ranges>
...@@ -262,7 +267,7 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -262,7 +267,7 @@ __cpp_lib_void_t 201411L <type_traits>
262# define __cpp_lib_make_from_tuple 201606L267# define __cpp_lib_make_from_tuple 201606L
263# define __cpp_lib_map_try_emplace 201411L268# define __cpp_lib_map_try_emplace 201411L
264// # define __cpp_lib_math_special_functions 201603L269// # define __cpp_lib_math_special_functions 201603L
265// # define __cpp_lib_memory_resource 201603L270# define __cpp_lib_memory_resource 201603L
266# define __cpp_lib_node_extract 201606L271# define __cpp_lib_node_extract 201606L
267# define __cpp_lib_nonmember_container_access 201411L272# define __cpp_lib_nonmember_container_access 201411L
268# define __cpp_lib_not_fn 201603L273# define __cpp_lib_not_fn 201603L
...@@ -312,7 +317,7 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -312,7 +317,7 @@ __cpp_lib_void_t 201411L <type_traits>
312# endif317# endif
313# define __cpp_lib_concepts 202002L318# define __cpp_lib_concepts 202002L
314# define __cpp_lib_constexpr_algorithms 201806L319# define __cpp_lib_constexpr_algorithms 201806L
315// # define __cpp_lib_constexpr_complex 201711L320# define __cpp_lib_constexpr_complex 201711L
316# define __cpp_lib_constexpr_dynamic_alloc 201907L321# define __cpp_lib_constexpr_dynamic_alloc 201907L
317# define __cpp_lib_constexpr_functional 201907L322# define __cpp_lib_constexpr_functional 201907L
318# define __cpp_lib_constexpr_iterator 201811L323# define __cpp_lib_constexpr_iterator 201811L
...@@ -322,7 +327,7 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -322,7 +327,7 @@ __cpp_lib_void_t 201411L <type_traits>
322# define __cpp_lib_constexpr_string_view 201811L327# define __cpp_lib_constexpr_string_view 201811L
323# define __cpp_lib_constexpr_tuple 201811L328# define __cpp_lib_constexpr_tuple 201811L
324# define __cpp_lib_constexpr_utility 201811L329# define __cpp_lib_constexpr_utility 201811L
325// # define __cpp_lib_constexpr_vector 201907L330# define __cpp_lib_constexpr_vector 201907L
326# define __cpp_lib_coroutine 201902L331# define __cpp_lib_coroutine 201902L
327# if _LIBCPP_STD_VER > 17 && defined(__cpp_impl_destroying_delete) && __cpp_impl_destroying_delete >= 201806L332# if _LIBCPP_STD_VER > 17 && defined(__cpp_impl_destroying_delete) && __cpp_impl_destroying_delete >= 201806L
328# define __cpp_lib_destroying_delete 201806L333# define __cpp_lib_destroying_delete 201806L
...@@ -350,10 +355,8 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -350,10 +355,8 @@ __cpp_lib_void_t 201411L <type_traits>
350# endif355# endif
351# define __cpp_lib_list_remove_return_type 201806L356# define __cpp_lib_list_remove_return_type 201806L
352# define __cpp_lib_math_constants 201907L357# define __cpp_lib_math_constants 201907L
353// # define __cpp_lib_polymorphic_allocator 201902L358# define __cpp_lib_polymorphic_allocator 201902L
354# if !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)359# define __cpp_lib_ranges 202106L
355# define __cpp_lib_ranges 201811L
356# endif
357# define __cpp_lib_remove_cvref 201711L360# define __cpp_lib_remove_cvref 201711L
358# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore)361# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore)
359# define __cpp_lib_semaphore 201907L362# define __cpp_lib_semaphore 201907L
...@@ -362,7 +365,9 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -362,7 +365,9 @@ __cpp_lib_void_t 201411L <type_traits>
362# define __cpp_lib_shared_ptr_arrays 201707L365# define __cpp_lib_shared_ptr_arrays 201707L
363# define __cpp_lib_shift 201806L366# define __cpp_lib_shift 201806L
364// # define __cpp_lib_smart_ptr_for_overwrite 202002L367// # define __cpp_lib_smart_ptr_for_overwrite 202002L
365// # define __cpp_lib_source_location 201907L368# if __has_builtin(__builtin_source_location)
369# define __cpp_lib_source_location 201907L
370# endif
366# define __cpp_lib_span 202002L371# define __cpp_lib_span 202002L
367# define __cpp_lib_ssize 201902L372# define __cpp_lib_ssize 201902L
368# define __cpp_lib_starts_ends_with 201711L373# define __cpp_lib_starts_ends_with 201711L
...@@ -382,8 +387,14 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -382,8 +387,14 @@ __cpp_lib_void_t 201411L <type_traits>
382// # define __cpp_lib_associative_heterogeneous_erasure 202110L387// # define __cpp_lib_associative_heterogeneous_erasure 202110L
383// # define __cpp_lib_bind_back 202202L388// # define __cpp_lib_bind_back 202202L
384# define __cpp_lib_byteswap 202110L389# define __cpp_lib_byteswap 202110L
390# define __cpp_lib_constexpr_bitset 202207L
391# define __cpp_lib_constexpr_charconv 202207L
385// # define __cpp_lib_constexpr_cmath 202202L392// # define __cpp_lib_constexpr_cmath 202202L
393# undef __cpp_lib_constexpr_memory
394# define __cpp_lib_constexpr_memory 202202L
386// # define __cpp_lib_constexpr_typeinfo 202106L395// # define __cpp_lib_constexpr_typeinfo 202106L
396# define __cpp_lib_expected 202202L
397# define __cpp_lib_forward_like 202207L
387// # define __cpp_lib_invoke_r 202106L398// # define __cpp_lib_invoke_r 202106L
388# define __cpp_lib_is_scoped_enum 202011L399# define __cpp_lib_is_scoped_enum 202011L
389// # define __cpp_lib_move_only_function 202110L400// # 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,...@@ -120,7 +120,9 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
120#define __CORRECT_ISO_CPP_WCHAR_H_PROTO120#define __CORRECT_ISO_CPP_WCHAR_H_PROTO
121#endif121#endif
122122
123#include_next <wchar.h>123# if __has_include_next(<wchar.h>)
124# include_next <wchar.h>
125# endif
124126
125// Determine whether we have const-correct overloads for wcschr and friends.127// Determine whether we have const-correct overloads for wcschr and friends.
126#if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_)128#if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_)
lib/libcxx/src/atomic.cpp+24-3
...@@ -26,6 +26,11 @@...@@ -26,6 +26,11 @@
26# define SYS_futex SYS_futex_time6426# define SYS_futex SYS_futex_time64
27#endif27#endif
2828
29#elif defined(__FreeBSD__)
30
31#include <sys/types.h>
32#include <sys/umtx.h>
33
29#else // <- Add other operating systems here34#else // <- Add other operating systems here
3035
31// Baseline needs no new headers36// Baseline needs no new headers
...@@ -52,11 +57,11 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo...@@ -52,11 +57,11 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo
52#elif defined(__APPLE__) && defined(_LIBCPP_USE_ULOCK)57#elif defined(__APPLE__) && defined(_LIBCPP_USE_ULOCK)
5358
54extern "C" int __ulock_wait(uint32_t operation, void *addr, uint64_t value,59extern "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 */
56extern "C" int __ulock_wake(uint32_t operation, void *addr, uint64_t wake_value);61extern "C" int __ulock_wake(uint32_t operation, void *addr, uint64_t wake_value);
5762
58#define UL_COMPARE_AND_WAIT 163#define UL_COMPARE_AND_WAIT 1
59#define ULF_WAKE_ALL 0x0000010064#define ULF_WAKE_ALL 0x00000100
6065
61static void __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr,66static void __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr,
62 __cxx_contention_t __val)67 __cxx_contention_t __val)
...@@ -72,6 +77,22 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo...@@ -72,6 +77,22 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo
72 const_cast<__cxx_atomic_contention_t*>(__ptr), 0);77 const_cast<__cxx_atomic_contention_t*>(__ptr), 0);
73}78}
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
75#else // <- Add other operating systems here96#else // <- Add other operating systems here
7697
77// Baseline is just a timed backoff98// Baseline is just a timed backoff
lib/libcxx/src/charconv.cpp+2-2
...@@ -21,13 +21,13 @@ namespace __itoa...@@ -21,13 +21,13 @@ namespace __itoa
21_LIBCPP_FUNC_VIS char*21_LIBCPP_FUNC_VIS char*
22__u32toa(uint32_t value, char* buffer) noexcept22__u32toa(uint32_t value, char* buffer) noexcept
23{23{
24 return __base_10_u32(buffer, value);24 return __base_10_u32(buffer, value);
25}25}
2626
27_LIBCPP_FUNC_VIS char*27_LIBCPP_FUNC_VIS char*
28__u64toa(uint64_t value, char* buffer) noexcept28__u64toa(uint64_t value, char* buffer) noexcept
29{29{
30 return __base_10_u64(buffer, value);30 return __base_10_u64(buffer, value);
31}31}
3232
33} // namespace __itoa33} // namespace __itoa
lib/libcxx/src/experimental/memory_resource.cpp+3-1
...@@ -8,6 +8,8 @@...@@ -8,6 +8,8 @@
88
9#include <experimental/memory_resource>9#include <experimental/memory_resource>
1010
11_LIBCPP_SUPPRESS_DEPRECATED_PUSH
12
11#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER13#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER
12# include <atomic>14# include <atomic>
13#elif !defined(_LIBCPP_HAS_NO_THREADS)15#elif !defined(_LIBCPP_HAS_NO_THREADS)
...@@ -72,7 +74,7 @@ union ResourceInitHelper {...@@ -72,7 +74,7 @@ union ResourceInitHelper {
72 __null_memory_resource_imp null_res;74 __null_memory_resource_imp null_res;
73 } resources;75 } resources;
74 char dummy;76 char dummy;
75 _LIBCPP_CONSTEXPR_AFTER_CXX11 ResourceInitHelper() : resources() {}77 _LIBCPP_CONSTEXPR_SINCE_CXX14 ResourceInitHelper() : resources() {}
76 ~ResourceInitHelper() {}78 ~ResourceInitHelper() {}
77};79};
7880
lib/libcxx/src/filesystem/filesystem_common.h+10-10
...@@ -124,7 +124,7 @@ error_code make_windows_error(int err) {...@@ -124,7 +124,7 @@ error_code make_windows_error(int err) {
124template <class T>124template <class T>
125T error_value();125T error_value();
126template <>126template <>
127_LIBCPP_CONSTEXPR_AFTER_CXX11 void error_value<void>() {}127_LIBCPP_CONSTEXPR_SINCE_CXX14 void error_value<void>() {}
128template <>128template <>
129bool error_value<bool>() {129bool error_value<bool>() {
130 return false;130 return false;
...@@ -140,7 +140,7 @@ uintmax_t error_value<uintmax_t>() {...@@ -140,7 +140,7 @@ uintmax_t error_value<uintmax_t>() {
140 return uintmax_t(-1);140 return uintmax_t(-1);
141}141}
142template <>142template <>
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>() {
144 return file_time_type::min();144 return file_time_type::min();
145}145}
146template <>146template <>
...@@ -309,7 +309,7 @@ struct time_util_base {...@@ -309,7 +309,7 @@ struct time_util_base {
309 .count();309 .count();
310310
311private:311private:
312 static _LIBCPP_CONSTEXPR_AFTER_CXX11 fs_duration get_min_nsecs() {312 static _LIBCPP_CONSTEXPR_SINCE_CXX14 fs_duration get_min_nsecs() {
313 return duration_cast<fs_duration>(313 return duration_cast<fs_duration>(
314 fs_nanoseconds(min_nsec_timespec) -314 fs_nanoseconds(min_nsec_timespec) -
315 duration_cast<fs_nanoseconds>(fs_seconds(1)));315 duration_cast<fs_nanoseconds>(fs_seconds(1)));
...@@ -319,7 +319,7 @@ private:...@@ -319,7 +319,7 @@ private:
319 FileTimeT::duration::min(),319 FileTimeT::duration::min(),
320 "value doesn't roundtrip");320 "value doesn't roundtrip");
321321
322 static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool check_range() {322 static _LIBCPP_CONSTEXPR_SINCE_CXX14 bool check_range() {
323 // This kinda sucks, but it's what happens when we don't have __int128_t.323 // This kinda sucks, but it's what happens when we don't have __int128_t.
324 if (sizeof(TimeT) == sizeof(rep)) {324 if (sizeof(TimeT) == sizeof(rep)) {
325 typedef duration<long long, ratio<3600 * 24 * 365> > Years;325 typedef duration<long long, ratio<3600 * 24 * 365> > Years;
...@@ -385,7 +385,7 @@ struct time_util : time_util_base<FileTimeT, TimeT> {...@@ -385,7 +385,7 @@ struct time_util : time_util_base<FileTimeT, TimeT> {
385385
386public:386public:
387 template <class CType, class ChronoType>387 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,
389 ChronoType time) {389 ChronoType time) {
390 using Lim = numeric_limits<CType>;390 using Lim = numeric_limits<CType>;
391 if (time > Lim::max() || time < Lim::min())391 if (time > Lim::max() || time < Lim::min())
...@@ -394,7 +394,7 @@ public:...@@ -394,7 +394,7 @@ public:
394 return true;394 return true;
395 }395 }
396396
397 static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool is_representable(TimeSpecT tm) {397 static _LIBCPP_CONSTEXPR_SINCE_CXX14 bool is_representable(TimeSpecT tm) {
398 if (tm.tv_sec >= 0) {398 if (tm.tv_sec >= 0) {
399 return tm.tv_sec < max_seconds ||399 return tm.tv_sec < max_seconds ||
400 (tm.tv_sec == max_seconds && tm.tv_nsec <= max_nsec);400 (tm.tv_sec == max_seconds && tm.tv_nsec <= max_nsec);
...@@ -405,7 +405,7 @@ public:...@@ -405,7 +405,7 @@ public:
405 }405 }
406 }406 }
407407
408 static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool is_representable(FileTimeT tm) {408 static _LIBCPP_CONSTEXPR_SINCE_CXX14 bool is_representable(FileTimeT tm) {
409 auto secs = duration_cast<fs_seconds>(tm.time_since_epoch());409 auto secs = duration_cast<fs_seconds>(tm.time_since_epoch());
410 auto nsecs = duration_cast<fs_nanoseconds>(tm.time_since_epoch() - secs);410 auto nsecs = duration_cast<fs_nanoseconds>(tm.time_since_epoch() - secs);
411 if (nsecs.count() < 0) {411 if (nsecs.count() < 0) {
...@@ -418,7 +418,7 @@ public:...@@ -418,7 +418,7 @@ public:
418 return secs.count() >= TLim::min();418 return secs.count() >= TLim::min();
419 }419 }
420420
421 static _LIBCPP_CONSTEXPR_AFTER_CXX11 FileTimeT421 static _LIBCPP_CONSTEXPR_SINCE_CXX14 FileTimeT
422 convert_from_timespec(TimeSpecT tm) {422 convert_from_timespec(TimeSpecT tm) {
423 if (tm.tv_sec >= 0 || tm.tv_nsec == 0) {423 if (tm.tv_sec >= 0 || tm.tv_nsec == 0) {
424 return FileTimeT(fs_seconds(tm.tv_sec) +424 return FileTimeT(fs_seconds(tm.tv_sec) +
...@@ -432,7 +432,7 @@ public:...@@ -432,7 +432,7 @@ public:
432 }432 }
433433
434 template <class SubSecT>434 template <class SubSecT>
435 static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool435 static _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
436 set_times_checked(TimeT* sec_out, SubSecT* subsec_out, FileTimeT tp) {436 set_times_checked(TimeT* sec_out, SubSecT* subsec_out, FileTimeT tp) {
437 auto dur = tp.time_since_epoch();437 auto dur = tp.time_since_epoch();
438 auto sec_dur = duration_cast<fs_seconds>(dur);438 auto sec_dur = duration_cast<fs_seconds>(dur);
...@@ -449,7 +449,7 @@ public:...@@ -449,7 +449,7 @@ public:
449 return checked_set(sec_out, sec_dur.count()) &&449 return checked_set(sec_out, sec_dur.count()) &&
450 checked_set(subsec_out, subsec_dur.count());450 checked_set(subsec_out, subsec_dur.count());
451 }451 }
452 static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool convert_to_timespec(TimeSpecT& dest,452 static _LIBCPP_CONSTEXPR_SINCE_CXX14 bool convert_to_timespec(TimeSpecT& dest,
453 FileTimeT tp) {453 FileTimeT tp) {
454 if (!is_representable(tp))454 if (!is_representable(tp))
455 return false;455 return false;
lib/libcxx/src/filesystem/operations.cpp+2-1
...@@ -1348,7 +1348,7 @@ bool __remove(const path& p, error_code* ec) {...@@ -1348,7 +1348,7 @@ bool __remove(const path& p, error_code* ec) {
1348//1348//
1349// The second implementation is used on platforms where `openat()` & friends are available,1349// The second implementation is used on platforms where `openat()` & friends are available,
1350// and it threads file descriptors through recursive calls to avoid such race conditions.1350// 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__)
1352# define REMOVE_ALL_USE_DIRECTORY_ITERATOR1352# define REMOVE_ALL_USE_DIRECTORY_ITERATOR
1353#endif1353#endif
13541354
...@@ -1408,6 +1408,7 @@ struct scope_exit {...@@ -1408,6 +1408,7 @@ struct scope_exit {
1408private:1408private:
1409 Cleanup cleanup_;1409 Cleanup cleanup_;
1410};1410};
1411_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(scope_exit);
14111412
1412uintmax_t remove_all_impl(int parent_directory, const path& p, error_code& ec) {1413uintmax_t remove_all_impl(int parent_directory, const path& p, error_code& ec) {
1413 // First, try to open the path as a directory.1414 // First, try to open the path as a directory.
lib/libcxx/src/format.cpp+2
...@@ -10,6 +10,8 @@...@@ -10,6 +10,8 @@
1010
11_LIBCPP_BEGIN_NAMESPACE_STD11_LIBCPP_BEGIN_NAMESPACE_STD
1212
13#ifndef _LIBCPP_INLINE_FORMAT_ERROR_DTOR
13format_error::~format_error() noexcept = default;14format_error::~format_error() noexcept = default;
15#endif
1416
15_LIBCPP_END_NAMESPACE_STD17_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/include/apple_availability.h+1
...@@ -5,6 +5,7 @@...@@ -5,6 +5,7 @@
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
8
8#ifndef _LIBCPP_SRC_INCLUDE_APPLE_AVAILABILITY_H9#ifndef _LIBCPP_SRC_INCLUDE_APPLE_AVAILABILITY_H
9#define _LIBCPP_SRC_INCLUDE_APPLE_AVAILABILITY_H10#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...@@ -50,7 +50,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
50// In order to minimize the diff in the Ryu code between MSVC STL and libc++50// In order to minimize the diff in the Ryu code between MSVC STL and libc++
51// the code uses the name __DIGIT_TABLE. In order to avoid code duplication it51// the code uses the name __DIGIT_TABLE. In order to avoid code duplication it
52// reuses the table already available in libc++.52// 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
55_LIBCPP_END_NAMESPACE_STD55_LIBCPP_END_NAMESPACE_STD
5656
lib/libcxx/src/ios.cpp+5-5
...@@ -145,11 +145,11 @@ int ios_base::__xindex_ = 0;...@@ -145,11 +145,11 @@ int ios_base::__xindex_ = 0;
145template <typename _Tp>145template <typename _Tp>
146static size_t __ios_new_cap(size_t __req_size, size_t __current_cap)146static size_t __ios_new_cap(size_t __req_size, size_t __current_cap)
147{ // Precondition: __req_size > __current_cap147{ // Precondition: __req_size > __current_cap
148 const size_t mx = std::numeric_limits<size_t>::max() / sizeof(_Tp);148 const size_t mx = std::numeric_limits<size_t>::max() / sizeof(_Tp);
149 if (__req_size < mx/2)149 if (__req_size < mx/2)
150 return _VSTD::max(2 * __current_cap, __req_size);150 return _VSTD::max(2 * __current_cap, __req_size);
151 else151 else
152 return mx;152 return mx;
153}153}
154154
155int155int
lib/libcxx/src/ios.instantiations.cpp+3
...@@ -36,9 +36,12 @@ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_stringbuf<char>;...@@ -36,9 +36,12 @@ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_stringbuf<char>;
36template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_stringstream<char>;36template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_stringstream<char>;
37template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostringstream<char>;37template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostringstream<char>;
38template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istringstream<char>;38template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istringstream<char>;
39
40#ifndef _LIBCPP_HAS_NO_FSTREAM
39template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ifstream<char>;41template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ifstream<char>;
40template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ofstream<char>;42template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ofstream<char>;
41template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_filebuf<char>;43template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_filebuf<char>;
44#endif
4245
43// Add more here if needed...46// Add more here if needed...
4447
lib/libcxx/src/iostream.cpp+2-2
...@@ -109,8 +109,8 @@ static void force_locale_initialization() {...@@ -109,8 +109,8 @@ static void force_locale_initialization() {
109109
110class DoIOSInit {110class DoIOSInit {
111public:111public:
112 DoIOSInit();112 DoIOSInit();
113 ~DoIOSInit();113 ~DoIOSInit();
114};114};
115115
116DoIOSInit::DoIOSInit()116DoIOSInit::DoIOSInit()
lib/libcxx/src/locale.cpp+160-167
...@@ -141,14 +141,7 @@ class _LIBCPP_HIDDEN locale::__imp...@@ -141,14 +141,7 @@ class _LIBCPP_HIDDEN locale::__imp
141 : public facet141 : public facet
142{142{
143 enum {N = 30};143 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
150 vector<facet*, __sso_allocator<facet*, N> > facets_;144 vector<facet*, __sso_allocator<facet*, N> > facets_;
151#endif
152 string name_;145 string name_;
153public:146public:
154 explicit __imp(size_t refs = 0);147 explicit __imp(size_t refs = 0);
...@@ -739,25 +732,25 @@ locale::id::__init()...@@ -739,25 +732,25 @@ locale::id::__init()
739732
740collate_byname<char>::collate_byname(const char* n, size_t refs)733collate_byname<char>::collate_byname(const char* n, size_t refs)
741 : collate<char>(refs),734 : collate<char>(refs),
742 __l(newlocale(LC_ALL_MASK, n, 0))735 __l_(newlocale(LC_ALL_MASK, n, 0))
743{736{
744 if (__l == 0)737 if (__l_ == 0)
745 __throw_runtime_error("collate_byname<char>::collate_byname"738 __throw_runtime_error("collate_byname<char>::collate_byname"
746 " failed to construct for " + string(n));739 " failed to construct for " + string(n));
747}740}
748741
749collate_byname<char>::collate_byname(const string& name, size_t refs)742collate_byname<char>::collate_byname(const string& name, size_t refs)
750 : collate<char>(refs),743 : collate<char>(refs),
751 __l(newlocale(LC_ALL_MASK, name.c_str(), 0))744 __l_(newlocale(LC_ALL_MASK, name.c_str(), 0))
752{745{
753 if (__l == 0)746 if (__l_ == 0)
754 __throw_runtime_error("collate_byname<char>::collate_byname"747 __throw_runtime_error("collate_byname<char>::collate_byname"
755 " failed to construct for " + name);748 " failed to construct for " + name);
756}749}
757750
758collate_byname<char>::~collate_byname()751collate_byname<char>::~collate_byname()
759{752{
760 freelocale(__l);753 freelocale(__l_);
761}754}
762755
763int756int
...@@ -766,7 +759,7 @@ collate_byname<char>::do_compare(const char_type* __lo1, const char_type* __hi1,...@@ -766,7 +759,7 @@ collate_byname<char>::do_compare(const char_type* __lo1, const char_type* __hi1,
766{759{
767 string_type lhs(__lo1, __hi1);760 string_type lhs(__lo1, __hi1);
768 string_type rhs(__lo2, __hi2);761 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_);
770 if (r < 0)763 if (r < 0)
771 return -1;764 return -1;
772 if (r > 0)765 if (r > 0)
...@@ -778,8 +771,8 @@ collate_byname<char>::string_type...@@ -778,8 +771,8 @@ collate_byname<char>::string_type
778collate_byname<char>::do_transform(const char_type* lo, const char_type* hi) const771collate_byname<char>::do_transform(const char_type* lo, const char_type* hi) const
779{772{
780 const string_type in(lo, hi);773 const string_type in(lo, hi);
781 string_type out(strxfrm_l(0, in.c_str(), 0, __l), char());774 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);775 strxfrm_l(const_cast<char*>(out.c_str()), in.c_str(), out.size()+1, __l_);
783 return out;776 return out;
784}777}
785778
...@@ -788,25 +781,25 @@ collate_byname<char>::do_transform(const char_type* lo, const char_type* hi) con...@@ -788,25 +781,25 @@ collate_byname<char>::do_transform(const char_type* lo, const char_type* hi) con
788#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS781#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
789collate_byname<wchar_t>::collate_byname(const char* n, size_t refs)782collate_byname<wchar_t>::collate_byname(const char* n, size_t refs)
790 : collate<wchar_t>(refs),783 : collate<wchar_t>(refs),
791 __l(newlocale(LC_ALL_MASK, n, 0))784 __l_(newlocale(LC_ALL_MASK, n, 0))
792{785{
793 if (__l == 0)786 if (__l_ == 0)
794 __throw_runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)"787 __throw_runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)"
795 " failed to construct for " + string(n));788 " failed to construct for " + string(n));
796}789}
797790
798collate_byname<wchar_t>::collate_byname(const string& name, size_t refs)791collate_byname<wchar_t>::collate_byname(const string& name, size_t refs)
799 : collate<wchar_t>(refs),792 : collate<wchar_t>(refs),
800 __l(newlocale(LC_ALL_MASK, name.c_str(), 0))793 __l_(newlocale(LC_ALL_MASK, name.c_str(), 0))
801{794{
802 if (__l == 0)795 if (__l_ == 0)
803 __throw_runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)"796 __throw_runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)"
804 " failed to construct for " + name);797 " failed to construct for " + name);
805}798}
806799
807collate_byname<wchar_t>::~collate_byname()800collate_byname<wchar_t>::~collate_byname()
808{801{
809 freelocale(__l);802 freelocale(__l_);
810}803}
811804
812int805int
...@@ -815,7 +808,7 @@ collate_byname<wchar_t>::do_compare(const char_type* __lo1, const char_type* __h...@@ -815,7 +808,7 @@ collate_byname<wchar_t>::do_compare(const char_type* __lo1, const char_type* __h
815{808{
816 string_type lhs(__lo1, __hi1);809 string_type lhs(__lo1, __hi1);
817 string_type rhs(__lo2, __hi2);810 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_);
819 if (r < 0)812 if (r < 0)
820 return -1;813 return -1;
821 if (r > 0)814 if (r > 0)
...@@ -827,8 +820,8 @@ collate_byname<wchar_t>::string_type...@@ -827,8 +820,8 @@ collate_byname<wchar_t>::string_type
827collate_byname<wchar_t>::do_transform(const char_type* lo, const char_type* hi) const820collate_byname<wchar_t>::do_transform(const char_type* lo, const char_type* hi) const
828{821{
829 const string_type in(lo, hi);822 const string_type in(lo, hi);
830 string_type out(wcsxfrm_l(0, in.c_str(), 0, __l), wchar_t());823 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);824 wcsxfrm_l(const_cast<wchar_t*>(out.c_str()), in.c_str(), out.size()+1, __l_);
832 return out;825 return out;
833}826}
834#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS827#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
...@@ -1190,7 +1183,7 @@ ctype<char>::classic_table() noexcept...@@ -1190,7 +1183,7 @@ ctype<char>::classic_table() noexcept
1190const ctype<char>::mask*1183const ctype<char>::mask*
1191ctype<char>::classic_table() noexcept1184ctype<char>::classic_table() noexcept
1192{1185{
1193#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__)1186#if defined(__APPLE__) || defined(__FreeBSD__)
1194 return _DefaultRuneLocale.__runetype;1187 return _DefaultRuneLocale.__runetype;
1195#elif defined(__NetBSD__)1188#elif defined(__NetBSD__)
1196 return _C_ctype_tab_ + 1;1189 return _C_ctype_tab_ + 1;
...@@ -1286,52 +1279,52 @@ ctype<char>::__classic_upper_table() _NOEXCEPT...@@ -1286,52 +1279,52 @@ ctype<char>::__classic_upper_table() _NOEXCEPT
12861279
1287ctype_byname<char>::ctype_byname(const char* name, size_t refs)1280ctype_byname<char>::ctype_byname(const char* name, size_t refs)
1288 : ctype<char>(0, false, refs),1281 : ctype<char>(0, false, refs),
1289 __l(newlocale(LC_ALL_MASK, name, 0))1282 __l_(newlocale(LC_ALL_MASK, name, 0))
1290{1283{
1291 if (__l == 0)1284 if (__l_ == 0)
1292 __throw_runtime_error("ctype_byname<char>::ctype_byname"1285 __throw_runtime_error("ctype_byname<char>::ctype_byname"
1293 " failed to construct for " + string(name));1286 " failed to construct for " + string(name));
1294}1287}
12951288
1296ctype_byname<char>::ctype_byname(const string& name, size_t refs)1289ctype_byname<char>::ctype_byname(const string& name, size_t refs)
1297 : ctype<char>(0, false, refs),1290 : 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))
1299{1292{
1300 if (__l == 0)1293 if (__l_ == 0)
1301 __throw_runtime_error("ctype_byname<char>::ctype_byname"1294 __throw_runtime_error("ctype_byname<char>::ctype_byname"
1302 " failed to construct for " + name);1295 " failed to construct for " + name);
1303}1296}
13041297
1305ctype_byname<char>::~ctype_byname()1298ctype_byname<char>::~ctype_byname()
1306{1299{
1307 freelocale(__l);1300 freelocale(__l_);
1308}1301}
13091302
1310char1303char
1311ctype_byname<char>::do_toupper(char_type c) const1304ctype_byname<char>::do_toupper(char_type c) const
1312{1305{
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_));
1314}1307}
13151308
1316const char*1309const char*
1317ctype_byname<char>::do_toupper(char_type* low, const char_type* high) const1310ctype_byname<char>::do_toupper(char_type* low, const char_type* high) const
1318{1311{
1319 for (; low != high; ++low)1312 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_));
1321 return low;1314 return low;
1322}1315}
13231316
1324char1317char
1325ctype_byname<char>::do_tolower(char_type c) const1318ctype_byname<char>::do_tolower(char_type c) const
1326{1319{
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_));
1328}1321}
13291322
1330const char*1323const char*
1331ctype_byname<char>::do_tolower(char_type* low, const char_type* high) const1324ctype_byname<char>::do_tolower(char_type* low, const char_type* high) const
1332{1325{
1333 for (; low != high; ++low)1326 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_));
1335 return low;1328 return low;
1336}1329}
13371330
...@@ -1340,45 +1333,45 @@ ctype_byname<char>::do_tolower(char_type* low, const char_type* high) const...@@ -1340,45 +1333,45 @@ ctype_byname<char>::do_tolower(char_type* low, const char_type* high) const
1340#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS1333#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
1341ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs)1334ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs)
1342 : ctype<wchar_t>(refs),1335 : ctype<wchar_t>(refs),
1343 __l(newlocale(LC_ALL_MASK, name, 0))1336 __l_(newlocale(LC_ALL_MASK, name, 0))
1344{1337{
1345 if (__l == 0)1338 if (__l_ == 0)
1346 __throw_runtime_error("ctype_byname<wchar_t>::ctype_byname"1339 __throw_runtime_error("ctype_byname<wchar_t>::ctype_byname"
1347 " failed to construct for " + string(name));1340 " failed to construct for " + string(name));
1348}1341}
13491342
1350ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs)1343ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs)
1351 : ctype<wchar_t>(refs),1344 : ctype<wchar_t>(refs),
1352 __l(newlocale(LC_ALL_MASK, name.c_str(), 0))1345 __l_(newlocale(LC_ALL_MASK, name.c_str(), 0))
1353{1346{
1354 if (__l == 0)1347 if (__l_ == 0)
1355 __throw_runtime_error("ctype_byname<wchar_t>::ctype_byname"1348 __throw_runtime_error("ctype_byname<wchar_t>::ctype_byname"
1356 " failed to construct for " + name);1349 " failed to construct for " + name);
1357}1350}
13581351
1359ctype_byname<wchar_t>::~ctype_byname()1352ctype_byname<wchar_t>::~ctype_byname()
1360{1353{
1361 freelocale(__l);1354 freelocale(__l_);
1362}1355}
13631356
1364bool1357bool
1365ctype_byname<wchar_t>::do_is(mask m, char_type c) const1358ctype_byname<wchar_t>::do_is(mask m, char_type c) const
1366{1359{
1367#ifdef _LIBCPP_WCTYPE_IS_MASK1360#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_));
1369#else1362#else
1370 bool result = false;1363 bool result = false;
1371 wint_t ch = static_cast<wint_t>(c);1364 wint_t ch = static_cast<wint_t>(c);
1372 if ((m & space) == space) result |= (iswspace_l(ch, __l) != 0);1365 if ((m & space) == space) result |= (iswspace_l(ch, __l_) != 0);
1373 if ((m & print) == print) result |= (iswprint_l(ch, __l) != 0);1366 if ((m & print) == print) result |= (iswprint_l(ch, __l_) != 0);
1374 if ((m & cntrl) == cntrl) result |= (iswcntrl_l(ch, __l) != 0);1367 if ((m & cntrl) == cntrl) result |= (iswcntrl_l(ch, __l_) != 0);
1375 if ((m & upper) == upper) result |= (iswupper_l(ch, __l) != 0);1368 if ((m & upper) == upper) result |= (iswupper_l(ch, __l_) != 0);
1376 if ((m & lower) == lower) result |= (iswlower_l(ch, __l) != 0);1369 if ((m & lower) == lower) result |= (iswlower_l(ch, __l_) != 0);
1377 if ((m & alpha) == alpha) result |= (iswalpha_l(ch, __l) != 0);1370 if ((m & alpha) == alpha) result |= (iswalpha_l(ch, __l_) != 0);
1378 if ((m & digit) == digit) result |= (iswdigit_l(ch, __l) != 0);1371 if ((m & digit) == digit) result |= (iswdigit_l(ch, __l_) != 0);
1379 if ((m & punct) == punct) result |= (iswpunct_l(ch, __l) != 0);1372 if ((m & punct) == punct) result |= (iswpunct_l(ch, __l_) != 0);
1380 if ((m & xdigit) == xdigit) result |= (iswxdigit_l(ch, __l) != 0);1373 if ((m & xdigit) == xdigit) result |= (iswxdigit_l(ch, __l_) != 0);
1381 if ((m & blank) == blank) result |= (iswblank_l(ch, __l) != 0);1374 if ((m & blank) == blank) result |= (iswblank_l(ch, __l_) != 0);
1382 return result;1375 return result;
1383#endif1376#endif
1384}1377}
...@@ -1394,32 +1387,32 @@ ctype_byname<wchar_t>::do_is(const char_type* low, const char_type* high, mask*...@@ -1394,32 +1387,32 @@ ctype_byname<wchar_t>::do_is(const char_type* low, const char_type* high, mask*
1394 {1387 {
1395 *vec = 0;1388 *vec = 0;
1396 wint_t ch = static_cast<wint_t>(*low);1389 wint_t ch = static_cast<wint_t>(*low);
1397 if (iswspace_l(ch, __l))1390 if (iswspace_l(ch, __l_))
1398 *vec |= space;1391 *vec |= space;
1399#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT1392#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
1400 if (iswprint_l(ch, __l))1393 if (iswprint_l(ch, __l_))
1401 *vec |= print;1394 *vec |= print;
1402#endif1395#endif
1403 if (iswcntrl_l(ch, __l))1396 if (iswcntrl_l(ch, __l_))
1404 *vec |= cntrl;1397 *vec |= cntrl;
1405 if (iswupper_l(ch, __l))1398 if (iswupper_l(ch, __l_))
1406 *vec |= upper;1399 *vec |= upper;
1407 if (iswlower_l(ch, __l))1400 if (iswlower_l(ch, __l_))
1408 *vec |= lower;1401 *vec |= lower;
1409#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA1402#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
1410 if (iswalpha_l(ch, __l))1403 if (iswalpha_l(ch, __l_))
1411 *vec |= alpha;1404 *vec |= alpha;
1412#endif1405#endif
1413 if (iswdigit_l(ch, __l))1406 if (iswdigit_l(ch, __l_))
1414 *vec |= digit;1407 *vec |= digit;
1415 if (iswpunct_l(ch, __l))1408 if (iswpunct_l(ch, __l_))
1416 *vec |= punct;1409 *vec |= punct;
1417#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT1410#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT
1418 if (iswxdigit_l(ch, __l))1411 if (iswxdigit_l(ch, __l_))
1419 *vec |= xdigit;1412 *vec |= xdigit;
1420#endif1413#endif
1421#if !defined(__sun__)1414#if !defined(__sun__)
1422 if (iswblank_l(ch, __l))1415 if (iswblank_l(ch, __l_))
1423 *vec |= blank;1416 *vec |= blank;
1424#endif1417#endif
1425 }1418 }
...@@ -1433,20 +1426,20 @@ ctype_byname<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type*...@@ -1433,20 +1426,20 @@ ctype_byname<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type*
1433 for (; low != high; ++low)1426 for (; low != high; ++low)
1434 {1427 {
1435#ifdef _LIBCPP_WCTYPE_IS_MASK1428#ifdef _LIBCPP_WCTYPE_IS_MASK
1436 if (iswctype_l(*low, m, __l))1429 if (iswctype_l(*low, m, __l_))
1437 break;1430 break;
1438#else1431#else
1439 wint_t ch = static_cast<wint_t>(*low);1432 wint_t ch = static_cast<wint_t>(*low);
1440 if ((m & space) == space && iswspace_l(ch, __l)) break;1433 if ((m & space) == space && iswspace_l(ch, __l_)) break;
1441 if ((m & print) == print && iswprint_l(ch, __l)) break;1434 if ((m & print) == print && iswprint_l(ch, __l_)) break;
1442 if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l)) break;1435 if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l_)) break;
1443 if ((m & upper) == upper && iswupper_l(ch, __l)) break;1436 if ((m & upper) == upper && iswupper_l(ch, __l_)) break;
1444 if ((m & lower) == lower && iswlower_l(ch, __l)) break;1437 if ((m & lower) == lower && iswlower_l(ch, __l_)) break;
1445 if ((m & alpha) == alpha && iswalpha_l(ch, __l)) break;1438 if ((m & alpha) == alpha && iswalpha_l(ch, __l_)) break;
1446 if ((m & digit) == digit && iswdigit_l(ch, __l)) break;1439 if ((m & digit) == digit && iswdigit_l(ch, __l_)) break;
1447 if ((m & punct) == punct && iswpunct_l(ch, __l)) break;1440 if ((m & punct) == punct && iswpunct_l(ch, __l_)) break;
1448 if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l)) break;1441 if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l_)) break;
1449 if ((m & blank) == blank && iswblank_l(ch, __l)) break;1442 if ((m & blank) == blank && iswblank_l(ch, __l_)) break;
1450#endif1443#endif
1451 }1444 }
1452 return low;1445 return low;
...@@ -1458,20 +1451,20 @@ ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type...@@ -1458,20 +1451,20 @@ ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type
1458 for (; low != high; ++low)1451 for (; low != high; ++low)
1459 {1452 {
1460#ifdef _LIBCPP_WCTYPE_IS_MASK1453#ifdef _LIBCPP_WCTYPE_IS_MASK
1461 if (!iswctype_l(*low, m, __l))1454 if (!iswctype_l(*low, m, __l_))
1462 break;1455 break;
1463#else1456#else
1464 wint_t ch = static_cast<wint_t>(*low);1457 wint_t ch = static_cast<wint_t>(*low);
1465 if ((m & space) == space && iswspace_l(ch, __l)) continue;1458 if ((m & space) == space && iswspace_l(ch, __l_)) continue;
1466 if ((m & print) == print && iswprint_l(ch, __l)) continue;1459 if ((m & print) == print && iswprint_l(ch, __l_)) continue;
1467 if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l)) continue;1460 if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l_)) continue;
1468 if ((m & upper) == upper && iswupper_l(ch, __l)) continue;1461 if ((m & upper) == upper && iswupper_l(ch, __l_)) continue;
1469 if ((m & lower) == lower && iswlower_l(ch, __l)) continue;1462 if ((m & lower) == lower && iswlower_l(ch, __l_)) continue;
1470 if ((m & alpha) == alpha && iswalpha_l(ch, __l)) continue;1463 if ((m & alpha) == alpha && iswalpha_l(ch, __l_)) continue;
1471 if ((m & digit) == digit && iswdigit_l(ch, __l)) continue;1464 if ((m & digit) == digit && iswdigit_l(ch, __l_)) continue;
1472 if ((m & punct) == punct && iswpunct_l(ch, __l)) continue;1465 if ((m & punct) == punct && iswpunct_l(ch, __l_)) continue;
1473 if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l)) continue;1466 if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l_)) continue;
1474 if ((m & blank) == blank && iswblank_l(ch, __l)) continue;1467 if ((m & blank) == blank && iswblank_l(ch, __l_)) continue;
1475 break;1468 break;
1476#endif1469#endif
1477 }1470 }
...@@ -1481,49 +1474,49 @@ ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type...@@ -1481,49 +1474,49 @@ ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type
1481wchar_t1474wchar_t
1482ctype_byname<wchar_t>::do_toupper(char_type c) const1475ctype_byname<wchar_t>::do_toupper(char_type c) const
1483{1476{
1484 return towupper_l(c, __l);1477 return towupper_l(c, __l_);
1485}1478}
14861479
1487const wchar_t*1480const wchar_t*
1488ctype_byname<wchar_t>::do_toupper(char_type* low, const char_type* high) const1481ctype_byname<wchar_t>::do_toupper(char_type* low, const char_type* high) const
1489{1482{
1490 for (; low != high; ++low)1483 for (; low != high; ++low)
1491 *low = towupper_l(*low, __l);1484 *low = towupper_l(*low, __l_);
1492 return low;1485 return low;
1493}1486}
14941487
1495wchar_t1488wchar_t
1496ctype_byname<wchar_t>::do_tolower(char_type c) const1489ctype_byname<wchar_t>::do_tolower(char_type c) const
1497{1490{
1498 return towlower_l(c, __l);1491 return towlower_l(c, __l_);
1499}1492}
15001493
1501const wchar_t*1494const wchar_t*
1502ctype_byname<wchar_t>::do_tolower(char_type* low, const char_type* high) const1495ctype_byname<wchar_t>::do_tolower(char_type* low, const char_type* high) const
1503{1496{
1504 for (; low != high; ++low)1497 for (; low != high; ++low)
1505 *low = towlower_l(*low, __l);1498 *low = towlower_l(*low, __l_);
1506 return low;1499 return low;
1507}1500}
15081501
1509wchar_t1502wchar_t
1510ctype_byname<wchar_t>::do_widen(char c) const1503ctype_byname<wchar_t>::do_widen(char c) const
1511{1504{
1512 return __libcpp_btowc_l(c, __l);1505 return __libcpp_btowc_l(c, __l_);
1513}1506}
15141507
1515const char*1508const char*
1516ctype_byname<wchar_t>::do_widen(const char* low, const char* high, char_type* dest) const1509ctype_byname<wchar_t>::do_widen(const char* low, const char* high, char_type* dest) const
1517{1510{
1518 for (; low != high; ++low, ++dest)1511 for (; low != high; ++low, ++dest)
1519 *dest = __libcpp_btowc_l(*low, __l);1512 *dest = __libcpp_btowc_l(*low, __l_);
1520 return low;1513 return low;
1521}1514}
15221515
1523char1516char
1524ctype_byname<wchar_t>::do_narrow(char_type c, char dfault) const1517ctype_byname<wchar_t>::do_narrow(char_type c, char dfault) const
1525{1518{
1526 int r = __libcpp_wctob_l(c, __l);1519 int r = __libcpp_wctob_l(c, __l_);
1527 return (r != EOF) ? static_cast<char>(r) : dfault;1520 return (r != EOF) ? static_cast<char>(r) : dfault;
1528}1521}
15291522
...@@ -1532,7 +1525,7 @@ ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, ch...@@ -1532,7 +1525,7 @@ ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, ch
1532{1525{
1533 for (; low != high; ++low, ++dest)1526 for (; low != high; ++low, ++dest)
1534 {1527 {
1535 int r = __libcpp_wctob_l(*low, __l);1528 int r = __libcpp_wctob_l(*low, __l_);
1536 *dest = (r != EOF) ? static_cast<char>(r) : dfault;1529 *dest = (r != EOF) ? static_cast<char>(r) : dfault;
1537 }1530 }
1538 return low;1531 return low;
...@@ -1607,23 +1600,23 @@ locale::id codecvt<wchar_t, char, mbstate_t>::id;...@@ -1607,23 +1600,23 @@ locale::id codecvt<wchar_t, char, mbstate_t>::id;
16071600
1608codecvt<wchar_t, char, mbstate_t>::codecvt(size_t refs)1601codecvt<wchar_t, char, mbstate_t>::codecvt(size_t refs)
1609 : locale::facet(refs),1602 : locale::facet(refs),
1610 __l(_LIBCPP_GET_C_LOCALE)1603 __l_(_LIBCPP_GET_C_LOCALE)
1611{1604{
1612}1605}
16131606
1614codecvt<wchar_t, char, mbstate_t>::codecvt(const char* nm, size_t refs)1607codecvt<wchar_t, char, mbstate_t>::codecvt(const char* nm, size_t refs)
1615 : locale::facet(refs),1608 : locale::facet(refs),
1616 __l(newlocale(LC_ALL_MASK, nm, 0))1609 __l_(newlocale(LC_ALL_MASK, nm, 0))
1617{1610{
1618 if (__l == 0)1611 if (__l_ == 0)
1619 __throw_runtime_error("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname"1612 __throw_runtime_error("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname"
1620 " failed to construct for " + string(nm));1613 " failed to construct for " + string(nm));
1621}1614}
16221615
1623codecvt<wchar_t, char, mbstate_t>::~codecvt()1616codecvt<wchar_t, char, mbstate_t>::~codecvt()
1624{1617{
1625 if (__l != _LIBCPP_GET_C_LOCALE)1618 if (__l_ != _LIBCPP_GET_C_LOCALE)
1626 freelocale(__l);1619 freelocale(__l_);
1627}1620}
16281621
1629codecvt<wchar_t, char, mbstate_t>::result1622codecvt<wchar_t, char, mbstate_t>::result
...@@ -1643,13 +1636,13 @@ codecvt<wchar_t, char, mbstate_t>::do_out(state_type& st,...@@ -1643,13 +1636,13 @@ codecvt<wchar_t, char, mbstate_t>::do_out(state_type& st,
1643 // save state in case it is needed to recover to_nxt on error1636 // save state in case it is needed to recover to_nxt on error
1644 mbstate_t save_state = st;1637 mbstate_t save_state = st;
1645 size_t n = __libcpp_wcsnrtombs_l(to, &frm_nxt, static_cast<size_t>(fend-frm),1638 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_);
1647 if (n == size_t(-1))1640 if (n == size_t(-1))
1648 {1641 {
1649 // need to recover to_nxt1642 // need to recover to_nxt
1650 for (to_nxt = to; frm != frm_nxt; ++frm)1643 for (to_nxt = to; frm != frm_nxt; ++frm)
1651 {1644 {
1652 n = __libcpp_wcrtomb_l(to_nxt, *frm, &save_state, __l);1645 n = __libcpp_wcrtomb_l(to_nxt, *frm, &save_state, __l_);
1653 if (n == size_t(-1))1646 if (n == size_t(-1))
1654 break;1647 break;
1655 to_nxt += n;1648 to_nxt += n;
...@@ -1666,7 +1659,7 @@ codecvt<wchar_t, char, mbstate_t>::do_out(state_type& st,...@@ -1666,7 +1659,7 @@ codecvt<wchar_t, char, mbstate_t>::do_out(state_type& st,
1666 {1659 {
1667 // Try to write the terminating null1660 // Try to write the terminating null
1668 extern_type tmp[MB_LEN_MAX];1661 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_);
1670 if (n == size_t(-1)) // on error1663 if (n == size_t(-1)) // on error
1671 return error;1664 return error;
1672 if (n > static_cast<size_t>(to_end-to_nxt)) // is there room?1665 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,...@@ -1700,14 +1693,14 @@ codecvt<wchar_t, char, mbstate_t>::do_in(state_type& st,
1700 // save state in case it is needed to recover to_nxt on error1693 // save state in case it is needed to recover to_nxt on error
1701 mbstate_t save_state = st;1694 mbstate_t save_state = st;
1702 size_t n = __libcpp_mbsnrtowcs_l(to, &frm_nxt, static_cast<size_t>(fend-frm),1695 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_);
1704 if (n == size_t(-1))1697 if (n == size_t(-1))
1705 {1698 {
1706 // need to recover to_nxt1699 // need to recover to_nxt
1707 for (to_nxt = to; frm != frm_nxt; ++to_nxt)1700 for (to_nxt = to; frm != frm_nxt; ++to_nxt)
1708 {1701 {
1709 n = __libcpp_mbrtowc_l(to_nxt, frm, static_cast<size_t>(fend-frm),1702 n = __libcpp_mbrtowc_l(to_nxt, frm, static_cast<size_t>(fend-frm),
1710 &save_state, __l);1703 &save_state, __l_);
1711 switch (n)1704 switch (n)
1712 {1705 {
1713 case 0:1706 case 0:
...@@ -1735,7 +1728,7 @@ codecvt<wchar_t, char, mbstate_t>::do_in(state_type& st,...@@ -1735,7 +1728,7 @@ codecvt<wchar_t, char, mbstate_t>::do_in(state_type& st,
1735 if (fend != frm_end) // set up next null terminated sequence1728 if (fend != frm_end) // set up next null terminated sequence
1736 {1729 {
1737 // Try to write the terminating null1730 // 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_);
1739 if (n != 0) // on error1732 if (n != 0) // on error
1740 return error;1733 return error;
1741 ++to_nxt;1734 ++to_nxt;
...@@ -1755,7 +1748,7 @@ codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& st,...@@ -1755,7 +1748,7 @@ codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& st,
1755{1748{
1756 to_nxt = to;1749 to_nxt = to;
1757 extern_type tmp[MB_LEN_MAX];1750 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_);
1759 if (n == size_t(-1) || n == 0) // on error1752 if (n == size_t(-1) || n == 0) // on error
1760 return error;1753 return error;
1761 --n;1754 --n;
...@@ -1769,11 +1762,11 @@ codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& st,...@@ -1769,11 +1762,11 @@ codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& st,
1769int1762int
1770codecvt<wchar_t, char, mbstate_t>::do_encoding() const noexcept1763codecvt<wchar_t, char, mbstate_t>::do_encoding() const noexcept
1771{1764{
1772 if (__libcpp_mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) != 0)1765 if (__libcpp_mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l_) != 0)
1773 return -1;1766 return -1;
17741767
1775 // stateless encoding1768 // stateless encoding
1776 if (__l == 0 || __libcpp_mb_cur_max_l(__l) == 1) // there are no known constant length encodings1769 if (__l_ == 0 || __libcpp_mb_cur_max_l(__l_) == 1) // there are no known constant length encodings
1777 return 1; // which take more than 1 char to form a wchar_t1770 return 1; // which take more than 1 char to form a wchar_t
1778 return 0;1771 return 0;
1779}1772}
...@@ -1791,7 +1784,7 @@ codecvt<wchar_t, char, mbstate_t>::do_length(state_type& st,...@@ -1791,7 +1784,7 @@ codecvt<wchar_t, char, mbstate_t>::do_length(state_type& st,
1791 int nbytes = 0;1784 int nbytes = 0;
1792 for (size_t nwchar_t = 0; nwchar_t < mx && frm != frm_end; ++nwchar_t)1785 for (size_t nwchar_t = 0; nwchar_t < mx && frm != frm_end; ++nwchar_t)
1793 {1786 {
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_);
1795 switch (n)1788 switch (n)
1796 {1789 {
1797 case 0:1790 case 0:
...@@ -1813,7 +1806,7 @@ codecvt<wchar_t, char, mbstate_t>::do_length(state_type& st,...@@ -1813,7 +1806,7 @@ codecvt<wchar_t, char, mbstate_t>::do_length(state_type& st,
1813int1806int
1814codecvt<wchar_t, char, mbstate_t>::do_max_length() const noexcept1807codecvt<wchar_t, char, mbstate_t>::do_max_length() const noexcept
1815{1808{
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_));
1817}1810}
1818#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS1811#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
18191812
...@@ -3545,10 +3538,10 @@ __codecvt_utf8<wchar_t>::do_out(state_type&,...@@ -3545,10 +3538,10 @@ __codecvt_utf8<wchar_t>::do_out(state_type&,
3545 uint8_t* _to_nxt = _to;3538 uint8_t* _to_nxt = _to;
3546#if defined(_LIBCPP_SHORT_WCHAR)3539#if defined(_LIBCPP_SHORT_WCHAR)
3547 result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,3540 result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3548 _Maxcode_, _Mode_);3541 __maxcode_, __mode_);
3549#else3542#else
3550 result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,3543 result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3551 _Maxcode_, _Mode_);3544 __maxcode_, __mode_);
3552#endif3545#endif
3553 frm_nxt = frm + (_frm_nxt - _frm);3546 frm_nxt = frm + (_frm_nxt - _frm);
3554 to_nxt = to + (_to_nxt - _to);3547 to_nxt = to + (_to_nxt - _to);
...@@ -3568,13 +3561,13 @@ __codecvt_utf8<wchar_t>::do_in(state_type&,...@@ -3568,13 +3561,13 @@ __codecvt_utf8<wchar_t>::do_in(state_type&,
3568 uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);3561 uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
3569 uint16_t* _to_nxt = _to;3562 uint16_t* _to_nxt = _to;
3570 result r = utf8_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,3563 result r = utf8_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3571 _Maxcode_, _Mode_);3564 __maxcode_, __mode_);
3572#else3565#else
3573 uint32_t* _to = reinterpret_cast<uint32_t*>(to);3566 uint32_t* _to = reinterpret_cast<uint32_t*>(to);
3574 uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);3567 uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
3575 uint32_t* _to_nxt = _to;3568 uint32_t* _to_nxt = _to;
3576 result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,3569 result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3577 _Maxcode_, _Mode_);3570 __maxcode_, __mode_);
3578#endif3571#endif
3579 frm_nxt = frm + (_frm_nxt - _frm);3572 frm_nxt = frm + (_frm_nxt - _frm);
3580 to_nxt = to + (_to_nxt - _to);3573 to_nxt = to + (_to_nxt - _to);
...@@ -3608,9 +3601,9 @@ __codecvt_utf8<wchar_t>::do_length(state_type&,...@@ -3608,9 +3601,9 @@ __codecvt_utf8<wchar_t>::do_length(state_type&,
3608 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);3601 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
3609 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);3602 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
3610#if defined(_LIBCPP_SHORT_WCHAR)3603#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_);
3612#else3605#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_);
3614#endif3607#endif
3615}3608}
36163609
...@@ -3619,11 +3612,11 @@ int...@@ -3619,11 +3612,11 @@ int
3619__codecvt_utf8<wchar_t>::do_max_length() const noexcept3612__codecvt_utf8<wchar_t>::do_max_length() const noexcept
3620{3613{
3621#if defined(_LIBCPP_SHORT_WCHAR)3614#if defined(_LIBCPP_SHORT_WCHAR)
3622 if (_Mode_ & consume_header)3615 if (__mode_ & consume_header)
3623 return 6;3616 return 6;
3624 return 3;3617 return 3;
3625#else3618#else
3626 if (_Mode_ & consume_header)3619 if (__mode_ & consume_header)
3627 return 7;3620 return 7;
3628 return 4;3621 return 4;
3629#endif3622#endif
...@@ -3644,7 +3637,7 @@ __codecvt_utf8<char16_t>::do_out(state_type&,...@@ -3644,7 +3637,7 @@ __codecvt_utf8<char16_t>::do_out(state_type&,
3644 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);3637 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
3645 uint8_t* _to_nxt = _to;3638 uint8_t* _to_nxt = _to;
3646 result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,3639 result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3647 _Maxcode_, _Mode_);3640 __maxcode_, __mode_);
3648 frm_nxt = frm + (_frm_nxt - _frm);3641 frm_nxt = frm + (_frm_nxt - _frm);
3649 to_nxt = to + (_to_nxt - _to);3642 to_nxt = to + (_to_nxt - _to);
3650 return r;3643 return r;
...@@ -3662,7 +3655,7 @@ __codecvt_utf8<char16_t>::do_in(state_type&,...@@ -3662,7 +3655,7 @@ __codecvt_utf8<char16_t>::do_in(state_type&,
3662 uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);3655 uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
3663 uint16_t* _to_nxt = _to;3656 uint16_t* _to_nxt = _to;
3664 result r = utf8_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,3657 result r = utf8_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3665 _Maxcode_, _Mode_);3658 __maxcode_, __mode_);
3666 frm_nxt = frm + (_frm_nxt - _frm);3659 frm_nxt = frm + (_frm_nxt - _frm);
3667 to_nxt = to + (_to_nxt - _to);3660 to_nxt = to + (_to_nxt - _to);
3668 return r;3661 return r;
...@@ -3694,14 +3687,14 @@ __codecvt_utf8<char16_t>::do_length(state_type&,...@@ -3694,14 +3687,14 @@ __codecvt_utf8<char16_t>::do_length(state_type&,
3694{3687{
3695 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);3688 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
3696 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);3689 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_);
3698}3691}
36993692
3700_LIBCPP_SUPPRESS_DEPRECATED_PUSH3693_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3701int3694int
3702__codecvt_utf8<char16_t>::do_max_length() const noexcept3695__codecvt_utf8<char16_t>::do_max_length() const noexcept
3703{3696{
3704 if (_Mode_ & consume_header)3697 if (__mode_ & consume_header)
3705 return 6;3698 return 6;
3706 return 3;3699 return 3;
3707}3700}
...@@ -3721,7 +3714,7 @@ __codecvt_utf8<char32_t>::do_out(state_type&,...@@ -3721,7 +3714,7 @@ __codecvt_utf8<char32_t>::do_out(state_type&,
3721 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);3714 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
3722 uint8_t* _to_nxt = _to;3715 uint8_t* _to_nxt = _to;
3723 result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,3716 result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3724 _Maxcode_, _Mode_);3717 __maxcode_, __mode_);
3725 frm_nxt = frm + (_frm_nxt - _frm);3718 frm_nxt = frm + (_frm_nxt - _frm);
3726 to_nxt = to + (_to_nxt - _to);3719 to_nxt = to + (_to_nxt - _to);
3727 return r;3720 return r;
...@@ -3739,7 +3732,7 @@ __codecvt_utf8<char32_t>::do_in(state_type&,...@@ -3739,7 +3732,7 @@ __codecvt_utf8<char32_t>::do_in(state_type&,
3739 uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);3732 uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
3740 uint32_t* _to_nxt = _to;3733 uint32_t* _to_nxt = _to;
3741 result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,3734 result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3742 _Maxcode_, _Mode_);3735 __maxcode_, __mode_);
3743 frm_nxt = frm + (_frm_nxt - _frm);3736 frm_nxt = frm + (_frm_nxt - _frm);
3744 to_nxt = to + (_to_nxt - _to);3737 to_nxt = to + (_to_nxt - _to);
3745 return r;3738 return r;
...@@ -3771,14 +3764,14 @@ __codecvt_utf8<char32_t>::do_length(state_type&,...@@ -3771,14 +3764,14 @@ __codecvt_utf8<char32_t>::do_length(state_type&,
3771{3764{
3772 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);3765 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
3773 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);3766 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_);
3775}3768}
37763769
3777_LIBCPP_SUPPRESS_DEPRECATED_PUSH3770_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3778int3771int
3779__codecvt_utf8<char32_t>::do_max_length() const noexcept3772__codecvt_utf8<char32_t>::do_max_length() const noexcept
3780{3773{
3781 if (_Mode_ & consume_header)3774 if (__mode_ & consume_header)
3782 return 7;3775 return 7;
3783 return 4;3776 return 4;
3784}3777}
...@@ -3806,10 +3799,10 @@ __codecvt_utf16<wchar_t, false>::do_out(state_type&,...@@ -3806,10 +3799,10 @@ __codecvt_utf16<wchar_t, false>::do_out(state_type&,
3806 uint8_t* _to_nxt = _to;3799 uint8_t* _to_nxt = _to;
3807#if defined(_LIBCPP_SHORT_WCHAR)3800#if defined(_LIBCPP_SHORT_WCHAR)
3808 result r = ucs2_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,3801 result r = ucs2_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3809 _Maxcode_, _Mode_);3802 __maxcode_, __mode_);
3810#else3803#else
3811 result r = ucs4_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,3804 result r = ucs4_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3812 _Maxcode_, _Mode_);3805 __maxcode_, __mode_);
3813#endif3806#endif
3814 frm_nxt = frm + (_frm_nxt - _frm);3807 frm_nxt = frm + (_frm_nxt - _frm);
3815 to_nxt = to + (_to_nxt - _to);3808 to_nxt = to + (_to_nxt - _to);
...@@ -3829,13 +3822,13 @@ __codecvt_utf16<wchar_t, false>::do_in(state_type&,...@@ -3829,13 +3822,13 @@ __codecvt_utf16<wchar_t, false>::do_in(state_type&,
3829 uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);3822 uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
3830 uint16_t* _to_nxt = _to;3823 uint16_t* _to_nxt = _to;
3831 result r = utf16be_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,3824 result r = utf16be_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3832 _Maxcode_, _Mode_);3825 __maxcode_, __mode_);
3833#else3826#else
3834 uint32_t* _to = reinterpret_cast<uint32_t*>(to);3827 uint32_t* _to = reinterpret_cast<uint32_t*>(to);
3835 uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);3828 uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
3836 uint32_t* _to_nxt = _to;3829 uint32_t* _to_nxt = _to;
3837 result r = utf16be_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,3830 result r = utf16be_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3838 _Maxcode_, _Mode_);3831 __maxcode_, __mode_);
3839#endif3832#endif
3840 frm_nxt = frm + (_frm_nxt - _frm);3833 frm_nxt = frm + (_frm_nxt - _frm);
3841 to_nxt = to + (_to_nxt - _to);3834 to_nxt = to + (_to_nxt - _to);
...@@ -3869,9 +3862,9 @@ __codecvt_utf16<wchar_t, false>::do_length(state_type&,...@@ -3869,9 +3862,9 @@ __codecvt_utf16<wchar_t, false>::do_length(state_type&,
3869 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);3862 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
3870 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);3863 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
3871#if defined(_LIBCPP_SHORT_WCHAR)3864#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_);
3873#else3866#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_);
3875#endif3868#endif
3876}3869}
38773870
...@@ -3879,11 +3872,11 @@ int...@@ -3879,11 +3872,11 @@ int
3879__codecvt_utf16<wchar_t, false>::do_max_length() const noexcept3872__codecvt_utf16<wchar_t, false>::do_max_length() const noexcept
3880{3873{
3881#if defined(_LIBCPP_SHORT_WCHAR)3874#if defined(_LIBCPP_SHORT_WCHAR)
3882 if (_Mode_ & consume_header)3875 if (__mode_ & consume_header)
3883 return 4;3876 return 4;
3884 return 2;3877 return 2;
3885#else3878#else
3886 if (_Mode_ & consume_header)3879 if (__mode_ & consume_header)
3887 return 6;3880 return 6;
3888 return 4;3881 return 4;
3889#endif3882#endif
...@@ -3910,10 +3903,10 @@ __codecvt_utf16<wchar_t, true>::do_out(state_type&,...@@ -3910,10 +3903,10 @@ __codecvt_utf16<wchar_t, true>::do_out(state_type&,
3910 uint8_t* _to_nxt = _to;3903 uint8_t* _to_nxt = _to;
3911#if defined(_LIBCPP_SHORT_WCHAR)3904#if defined(_LIBCPP_SHORT_WCHAR)
3912 result r = ucs2_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,3905 result r = ucs2_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3913 _Maxcode_, _Mode_);3906 __maxcode_, __mode_);
3914#else3907#else
3915 result r = ucs4_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,3908 result r = ucs4_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3916 _Maxcode_, _Mode_);3909 __maxcode_, __mode_);
3917#endif3910#endif
3918 frm_nxt = frm + (_frm_nxt - _frm);3911 frm_nxt = frm + (_frm_nxt - _frm);
3919 to_nxt = to + (_to_nxt - _to);3912 to_nxt = to + (_to_nxt - _to);
...@@ -3933,13 +3926,13 @@ __codecvt_utf16<wchar_t, true>::do_in(state_type&,...@@ -3933,13 +3926,13 @@ __codecvt_utf16<wchar_t, true>::do_in(state_type&,
3933 uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);3926 uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
3934 uint16_t* _to_nxt = _to;3927 uint16_t* _to_nxt = _to;
3935 result r = utf16le_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,3928 result r = utf16le_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3936 _Maxcode_, _Mode_);3929 __maxcode_, __mode_);
3937#else3930#else
3938 uint32_t* _to = reinterpret_cast<uint32_t*>(to);3931 uint32_t* _to = reinterpret_cast<uint32_t*>(to);
3939 uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);3932 uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
3940 uint32_t* _to_nxt = _to;3933 uint32_t* _to_nxt = _to;
3941 result r = utf16le_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,3934 result r = utf16le_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
3942 _Maxcode_, _Mode_);3935 __maxcode_, __mode_);
3943#endif3936#endif
3944 frm_nxt = frm + (_frm_nxt - _frm);3937 frm_nxt = frm + (_frm_nxt - _frm);
3945 to_nxt = to + (_to_nxt - _to);3938 to_nxt = to + (_to_nxt - _to);
...@@ -3973,9 +3966,9 @@ __codecvt_utf16<wchar_t, true>::do_length(state_type&,...@@ -3973,9 +3966,9 @@ __codecvt_utf16<wchar_t, true>::do_length(state_type&,
3973 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);3966 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
3974 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);3967 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
3975#if defined(_LIBCPP_SHORT_WCHAR)3968#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_);
3977#else3970#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_);
3979#endif3972#endif
3980}3973}
39813974
...@@ -3983,11 +3976,11 @@ int...@@ -3983,11 +3976,11 @@ int
3983__codecvt_utf16<wchar_t, true>::do_max_length() const noexcept3976__codecvt_utf16<wchar_t, true>::do_max_length() const noexcept
3984{3977{
3985#if defined(_LIBCPP_SHORT_WCHAR)3978#if defined(_LIBCPP_SHORT_WCHAR)
3986 if (_Mode_ & consume_header)3979 if (__mode_ & consume_header)
3987 return 4;3980 return 4;
3988 return 2;3981 return 2;
3989#else3982#else
3990 if (_Mode_ & consume_header)3983 if (__mode_ & consume_header)
3991 return 6;3984 return 6;
3992 return 4;3985 return 4;
3993#endif3986#endif
...@@ -4008,7 +4001,7 @@ __codecvt_utf16<char16_t, false>::do_out(state_type&,...@@ -4008,7 +4001,7 @@ __codecvt_utf16<char16_t, false>::do_out(state_type&,
4008 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);4001 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
4009 uint8_t* _to_nxt = _to;4002 uint8_t* _to_nxt = _to;
4010 result r = ucs2_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,4003 result r = ucs2_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4011 _Maxcode_, _Mode_);4004 __maxcode_, __mode_);
4012 frm_nxt = frm + (_frm_nxt - _frm);4005 frm_nxt = frm + (_frm_nxt - _frm);
4013 to_nxt = to + (_to_nxt - _to);4006 to_nxt = to + (_to_nxt - _to);
4014 return r;4007 return r;
...@@ -4026,7 +4019,7 @@ __codecvt_utf16<char16_t, false>::do_in(state_type&,...@@ -4026,7 +4019,7 @@ __codecvt_utf16<char16_t, false>::do_in(state_type&,
4026 uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);4019 uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
4027 uint16_t* _to_nxt = _to;4020 uint16_t* _to_nxt = _to;
4028 result r = utf16be_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,4021 result r = utf16be_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4029 _Maxcode_, _Mode_);4022 __maxcode_, __mode_);
4030 frm_nxt = frm + (_frm_nxt - _frm);4023 frm_nxt = frm + (_frm_nxt - _frm);
4031 to_nxt = to + (_to_nxt - _to);4024 to_nxt = to + (_to_nxt - _to);
4032 return r;4025 return r;
...@@ -4058,14 +4051,14 @@ __codecvt_utf16<char16_t, false>::do_length(state_type&,...@@ -4058,14 +4051,14 @@ __codecvt_utf16<char16_t, false>::do_length(state_type&,
4058{4051{
4059 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);4052 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
4060 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);4053 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_);
4062}4055}
40634056
4064_LIBCPP_SUPPRESS_DEPRECATED_PUSH4057_LIBCPP_SUPPRESS_DEPRECATED_PUSH
4065int4058int
4066__codecvt_utf16<char16_t, false>::do_max_length() const noexcept4059__codecvt_utf16<char16_t, false>::do_max_length() const noexcept
4067{4060{
4068 if (_Mode_ & consume_header)4061 if (__mode_ & consume_header)
4069 return 4;4062 return 4;
4070 return 2;4063 return 2;
4071}4064}
...@@ -4085,7 +4078,7 @@ __codecvt_utf16<char16_t, true>::do_out(state_type&,...@@ -4085,7 +4078,7 @@ __codecvt_utf16<char16_t, true>::do_out(state_type&,
4085 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);4078 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
4086 uint8_t* _to_nxt = _to;4079 uint8_t* _to_nxt = _to;
4087 result r = ucs2_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,4080 result r = ucs2_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4088 _Maxcode_, _Mode_);4081 __maxcode_, __mode_);
4089 frm_nxt = frm + (_frm_nxt - _frm);4082 frm_nxt = frm + (_frm_nxt - _frm);
4090 to_nxt = to + (_to_nxt - _to);4083 to_nxt = to + (_to_nxt - _to);
4091 return r;4084 return r;
...@@ -4103,7 +4096,7 @@ __codecvt_utf16<char16_t, true>::do_in(state_type&,...@@ -4103,7 +4096,7 @@ __codecvt_utf16<char16_t, true>::do_in(state_type&,
4103 uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);4096 uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
4104 uint16_t* _to_nxt = _to;4097 uint16_t* _to_nxt = _to;
4105 result r = utf16le_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,4098 result r = utf16le_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4106 _Maxcode_, _Mode_);4099 __maxcode_, __mode_);
4107 frm_nxt = frm + (_frm_nxt - _frm);4100 frm_nxt = frm + (_frm_nxt - _frm);
4108 to_nxt = to + (_to_nxt - _to);4101 to_nxt = to + (_to_nxt - _to);
4109 return r;4102 return r;
...@@ -4135,14 +4128,14 @@ __codecvt_utf16<char16_t, true>::do_length(state_type&,...@@ -4135,14 +4128,14 @@ __codecvt_utf16<char16_t, true>::do_length(state_type&,
4135{4128{
4136 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);4129 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
4137 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);4130 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_);
4139}4132}
41404133
4141_LIBCPP_SUPPRESS_DEPRECATED_PUSH4134_LIBCPP_SUPPRESS_DEPRECATED_PUSH
4142int4135int
4143__codecvt_utf16<char16_t, true>::do_max_length() const noexcept4136__codecvt_utf16<char16_t, true>::do_max_length() const noexcept
4144{4137{
4145 if (_Mode_ & consume_header)4138 if (__mode_ & consume_header)
4146 return 4;4139 return 4;
4147 return 2;4140 return 2;
4148}4141}
...@@ -4162,7 +4155,7 @@ __codecvt_utf16<char32_t, false>::do_out(state_type&,...@@ -4162,7 +4155,7 @@ __codecvt_utf16<char32_t, false>::do_out(state_type&,
4162 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);4155 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
4163 uint8_t* _to_nxt = _to;4156 uint8_t* _to_nxt = _to;
4164 result r = ucs4_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,4157 result r = ucs4_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4165 _Maxcode_, _Mode_);4158 __maxcode_, __mode_);
4166 frm_nxt = frm + (_frm_nxt - _frm);4159 frm_nxt = frm + (_frm_nxt - _frm);
4167 to_nxt = to + (_to_nxt - _to);4160 to_nxt = to + (_to_nxt - _to);
4168 return r;4161 return r;
...@@ -4180,7 +4173,7 @@ __codecvt_utf16<char32_t, false>::do_in(state_type&,...@@ -4180,7 +4173,7 @@ __codecvt_utf16<char32_t, false>::do_in(state_type&,
4180 uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);4173 uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
4181 uint32_t* _to_nxt = _to;4174 uint32_t* _to_nxt = _to;
4182 result r = utf16be_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,4175 result r = utf16be_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4183 _Maxcode_, _Mode_);4176 __maxcode_, __mode_);
4184 frm_nxt = frm + (_frm_nxt - _frm);4177 frm_nxt = frm + (_frm_nxt - _frm);
4185 to_nxt = to + (_to_nxt - _to);4178 to_nxt = to + (_to_nxt - _to);
4186 return r;4179 return r;
...@@ -4212,14 +4205,14 @@ __codecvt_utf16<char32_t, false>::do_length(state_type&,...@@ -4212,14 +4205,14 @@ __codecvt_utf16<char32_t, false>::do_length(state_type&,
4212{4205{
4213 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);4206 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
4214 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);4207 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_);
4216}4209}
42174210
4218_LIBCPP_SUPPRESS_DEPRECATED_PUSH4211_LIBCPP_SUPPRESS_DEPRECATED_PUSH
4219int4212int
4220__codecvt_utf16<char32_t, false>::do_max_length() const noexcept4213__codecvt_utf16<char32_t, false>::do_max_length() const noexcept
4221{4214{
4222 if (_Mode_ & consume_header)4215 if (__mode_ & consume_header)
4223 return 6;4216 return 6;
4224 return 4;4217 return 4;
4225}4218}
...@@ -4239,7 +4232,7 @@ __codecvt_utf16<char32_t, true>::do_out(state_type&,...@@ -4239,7 +4232,7 @@ __codecvt_utf16<char32_t, true>::do_out(state_type&,
4239 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);4232 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
4240 uint8_t* _to_nxt = _to;4233 uint8_t* _to_nxt = _to;
4241 result r = ucs4_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,4234 result r = ucs4_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4242 _Maxcode_, _Mode_);4235 __maxcode_, __mode_);
4243 frm_nxt = frm + (_frm_nxt - _frm);4236 frm_nxt = frm + (_frm_nxt - _frm);
4244 to_nxt = to + (_to_nxt - _to);4237 to_nxt = to + (_to_nxt - _to);
4245 return r;4238 return r;
...@@ -4257,7 +4250,7 @@ __codecvt_utf16<char32_t, true>::do_in(state_type&,...@@ -4257,7 +4250,7 @@ __codecvt_utf16<char32_t, true>::do_in(state_type&,
4257 uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);4250 uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
4258 uint32_t* _to_nxt = _to;4251 uint32_t* _to_nxt = _to;
4259 result r = utf16le_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,4252 result r = utf16le_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4260 _Maxcode_, _Mode_);4253 __maxcode_, __mode_);
4261 frm_nxt = frm + (_frm_nxt - _frm);4254 frm_nxt = frm + (_frm_nxt - _frm);
4262 to_nxt = to + (_to_nxt - _to);4255 to_nxt = to + (_to_nxt - _to);
4263 return r;4256 return r;
...@@ -4289,14 +4282,14 @@ __codecvt_utf16<char32_t, true>::do_length(state_type&,...@@ -4289,14 +4282,14 @@ __codecvt_utf16<char32_t, true>::do_length(state_type&,
4289{4282{
4290 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);4283 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
4291 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);4284 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_);
4293}4286}
42944287
4295_LIBCPP_SUPPRESS_DEPRECATED_PUSH4288_LIBCPP_SUPPRESS_DEPRECATED_PUSH
4296int4289int
4297__codecvt_utf16<char32_t, true>::do_max_length() const noexcept4290__codecvt_utf16<char32_t, true>::do_max_length() const noexcept
4298{4291{
4299 if (_Mode_ & consume_header)4292 if (__mode_ & consume_header)
4300 return 6;4293 return 6;
4301 return 4;4294 return 4;
4302}4295}
...@@ -4323,7 +4316,7 @@ __codecvt_utf8_utf16<wchar_t>::do_out(state_type&,...@@ -4323,7 +4316,7 @@ __codecvt_utf8_utf16<wchar_t>::do_out(state_type&,
4323 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);4316 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
4324 uint8_t* _to_nxt = _to;4317 uint8_t* _to_nxt = _to;
4325 result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,4318 result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4326 _Maxcode_, _Mode_);4319 __maxcode_, __mode_);
4327 frm_nxt = frm + (_frm_nxt - _frm);4320 frm_nxt = frm + (_frm_nxt - _frm);
4328 to_nxt = to + (_to_nxt - _to);4321 to_nxt = to + (_to_nxt - _to);
4329 return r;4322 return r;
...@@ -4347,7 +4340,7 @@ __codecvt_utf8_utf16<wchar_t>::do_in(state_type&,...@@ -4347,7 +4340,7 @@ __codecvt_utf8_utf16<wchar_t>::do_in(state_type&,
4347 uint32_t* _to_nxt = _to;4340 uint32_t* _to_nxt = _to;
4348#endif4341#endif
4349 result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,4342 result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4350 _Maxcode_, _Mode_);4343 __maxcode_, __mode_);
4351 frm_nxt = frm + (_frm_nxt - _frm);4344 frm_nxt = frm + (_frm_nxt - _frm);
4352 to_nxt = to + (_to_nxt - _to);4345 to_nxt = to + (_to_nxt - _to);
4353 return r;4346 return r;
...@@ -4379,13 +4372,13 @@ __codecvt_utf8_utf16<wchar_t>::do_length(state_type&,...@@ -4379,13 +4372,13 @@ __codecvt_utf8_utf16<wchar_t>::do_length(state_type&,
4379{4372{
4380 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);4373 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
4381 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);4374 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_);
4383}4376}
43844377
4385int4378int
4386__codecvt_utf8_utf16<wchar_t>::do_max_length() const noexcept4379__codecvt_utf8_utf16<wchar_t>::do_max_length() const noexcept
4387{4380{
4388 if (_Mode_ & consume_header)4381 if (__mode_ & consume_header)
4389 return 7;4382 return 7;
4390 return 4;4383 return 4;
4391}4384}
...@@ -4405,7 +4398,7 @@ __codecvt_utf8_utf16<char16_t>::do_out(state_type&,...@@ -4405,7 +4398,7 @@ __codecvt_utf8_utf16<char16_t>::do_out(state_type&,
4405 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);4398 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
4406 uint8_t* _to_nxt = _to;4399 uint8_t* _to_nxt = _to;
4407 result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,4400 result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4408 _Maxcode_, _Mode_);4401 __maxcode_, __mode_);
4409 frm_nxt = frm + (_frm_nxt - _frm);4402 frm_nxt = frm + (_frm_nxt - _frm);
4410 to_nxt = to + (_to_nxt - _to);4403 to_nxt = to + (_to_nxt - _to);
4411 return r;4404 return r;
...@@ -4423,7 +4416,7 @@ __codecvt_utf8_utf16<char16_t>::do_in(state_type&,...@@ -4423,7 +4416,7 @@ __codecvt_utf8_utf16<char16_t>::do_in(state_type&,
4423 uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);4416 uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
4424 uint16_t* _to_nxt = _to;4417 uint16_t* _to_nxt = _to;
4425 result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,4418 result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4426 _Maxcode_, _Mode_);4419 __maxcode_, __mode_);
4427 frm_nxt = frm + (_frm_nxt - _frm);4420 frm_nxt = frm + (_frm_nxt - _frm);
4428 to_nxt = to + (_to_nxt - _to);4421 to_nxt = to + (_to_nxt - _to);
4429 return r;4422 return r;
...@@ -4455,14 +4448,14 @@ __codecvt_utf8_utf16<char16_t>::do_length(state_type&,...@@ -4455,14 +4448,14 @@ __codecvt_utf8_utf16<char16_t>::do_length(state_type&,
4455{4448{
4456 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);4449 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
4457 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);4450 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_);
4459}4452}
44604453
4461_LIBCPP_SUPPRESS_DEPRECATED_PUSH4454_LIBCPP_SUPPRESS_DEPRECATED_PUSH
4462int4455int
4463__codecvt_utf8_utf16<char16_t>::do_max_length() const noexcept4456__codecvt_utf8_utf16<char16_t>::do_max_length() const noexcept
4464{4457{
4465 if (_Mode_ & consume_header)4458 if (__mode_ & consume_header)
4466 return 7;4459 return 7;
4467 return 4;4460 return 4;
4468}4461}
...@@ -4482,7 +4475,7 @@ __codecvt_utf8_utf16<char32_t>::do_out(state_type&,...@@ -4482,7 +4475,7 @@ __codecvt_utf8_utf16<char32_t>::do_out(state_type&,
4482 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);4475 uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
4483 uint8_t* _to_nxt = _to;4476 uint8_t* _to_nxt = _to;
4484 result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,4477 result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4485 _Maxcode_, _Mode_);4478 __maxcode_, __mode_);
4486 frm_nxt = frm + (_frm_nxt - _frm);4479 frm_nxt = frm + (_frm_nxt - _frm);
4487 to_nxt = to + (_to_nxt - _to);4480 to_nxt = to + (_to_nxt - _to);
4488 return r;4481 return r;
...@@ -4500,7 +4493,7 @@ __codecvt_utf8_utf16<char32_t>::do_in(state_type&,...@@ -4500,7 +4493,7 @@ __codecvt_utf8_utf16<char32_t>::do_in(state_type&,
4500 uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);4493 uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
4501 uint32_t* _to_nxt = _to;4494 uint32_t* _to_nxt = _to;
4502 result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,4495 result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
4503 _Maxcode_, _Mode_);4496 __maxcode_, __mode_);
4504 frm_nxt = frm + (_frm_nxt - _frm);4497 frm_nxt = frm + (_frm_nxt - _frm);
4505 to_nxt = to + (_to_nxt - _to);4498 to_nxt = to + (_to_nxt - _to);
4506 return r;4499 return r;
...@@ -4532,14 +4525,14 @@ __codecvt_utf8_utf16<char32_t>::do_length(state_type&,...@@ -4532,14 +4525,14 @@ __codecvt_utf8_utf16<char32_t>::do_length(state_type&,
4532{4525{
4533 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);4526 const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
4534 const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);4527 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_);
4536}4529}
45374530
4538_LIBCPP_SUPPRESS_DEPRECATED_PUSH4531_LIBCPP_SUPPRESS_DEPRECATED_PUSH
4539int4532int
4540__codecvt_utf8_utf16<char32_t>::do_max_length() const noexcept4533__codecvt_utf8_utf16<char32_t>::do_max_length() const noexcept
4541{4534{
4542 if (_Mode_ & consume_header)4535 if (__mode_ & consume_header)
4543 return 7;4536 return 7;
4544 return 4;4537 return 4;
4545}4538}
...@@ -4805,7 +4798,7 @@ __check_grouping(const string& __grouping, unsigned* __g, unsigned* __g_end,...@@ -4805,7 +4798,7 @@ __check_grouping(const string& __grouping, unsigned* __g, unsigned* __g_end,
4805{4798{
4806// if the grouping pattern is empty _or_ there are no grouping bits, then do nothing4799// if the grouping pattern is empty _or_ there are no grouping bits, then do nothing
4807// we always have at least a single entry in [__g, __g_end); the end of the input sequence4800// 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)
4809 {4802 {
4810 reverse(__g, __g_end);4803 reverse(__g, __g_end);
4811 const char* __ig = __grouping.data();4804 const char* __ig = __grouping.data();
...@@ -4838,7 +4831,7 @@ __num_put_base::__format_int(char* __fmtp, const char* __len, bool __signd,...@@ -4838,7 +4831,7 @@ __num_put_base::__format_int(char* __fmtp, const char* __len, bool __signd,
4838 if ((__flags & ios_base::showpos) &&4831 if ((__flags & ios_base::showpos) &&
4839 (__flags & ios_base::basefield) != ios_base::oct &&4832 (__flags & ios_base::basefield) != ios_base::oct &&
4840 (__flags & ios_base::basefield) != ios_base::hex &&4833 (__flags & ios_base::basefield) != ios_base::hex &&
4841 __signd)4834 __signd)
4842 *__fmtp++ = '+';4835 *__fmtp++ = '+';
4843 if (__flags & ios_base::showbase)4836 if (__flags & ios_base::showbase)
4844 *__fmtp++ = '#';4837 *__fmtp++ = '#';
lib/libcxx/src/memory.cpp+4-4
...@@ -152,21 +152,21 @@ static constinit __libcpp_mutex_t mut_back[__sp_mut_count] =...@@ -152,21 +152,21 @@ static constinit __libcpp_mutex_t mut_back[__sp_mut_count] =
152};152};
153153
154_LIBCPP_CONSTEXPR __sp_mut::__sp_mut(void* p) noexcept154_LIBCPP_CONSTEXPR __sp_mut::__sp_mut(void* p) noexcept
155 : __lx(p)155 : __lx_(p)
156{156{
157}157}
158158
159void159void
160__sp_mut::lock() noexcept160__sp_mut::lock() noexcept
161{161{
162 auto m = static_cast<__libcpp_mutex_t*>(__lx);162 auto m = static_cast<__libcpp_mutex_t*>(__lx_);
163 __libcpp_mutex_lock(m);163 __libcpp_mutex_lock(m);
164}164}
165165
166void166void
167__sp_mut::unlock() noexcept167__sp_mut::unlock() noexcept
168{168{
169 __libcpp_mutex_unlock(static_cast<__libcpp_mutex_t*>(__lx));169 __libcpp_mutex_unlock(static_cast<__libcpp_mutex_t*>(__lx_));
170}170}
171171
172__sp_mut&172__sp_mut&
...@@ -194,7 +194,7 @@ align(size_t alignment, size_t size, void*& ptr, size_t& space)...@@ -194,7 +194,7 @@ align(size_t alignment, size_t size, void*& ptr, size_t& space)
194 if (size <= space)194 if (size <= space)
195 {195 {
196 char* p1 = static_cast<char*>(ptr);196 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);
198 size_t d = static_cast<size_t>(p2 - p1);198 size_t d = static_cast<size_t>(p2 - p1);
199 if (d <= space - size)199 if (d <= space - size)
200 {200 {
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;...@@ -16,7 +16,7 @@ bad_optional_access::~bad_optional_access() noexcept = default;
1616
17const char* bad_optional_access::what() const noexcept {17const char* bad_optional_access::what() const noexcept {
18 return "bad_optional_access";18 return "bad_optional_access";
19 }19}
2020
21} // std21} // std
2222
...@@ -28,13 +28,13 @@ const char* bad_optional_access::what() const noexcept {...@@ -28,13 +28,13 @@ const char* bad_optional_access::what() const noexcept {
28_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL28_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
2929
30class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access30class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access
31 : public std::logic_error31 : public std::logic_error
32{32{
33public:33public:
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 dylib36 // Get the key function ~bad_optional_access() into the dylib
37 virtual ~bad_optional_access() noexcept;37 virtual ~bad_optional_access() noexcept;
38};38};
3939
40bad_optional_access::~bad_optional_access() noexcept = default;40bad_optional_access::~bad_optional_access() noexcept = default;
lib/libcxx/src/shared_mutex.cpp+7-7
...@@ -106,13 +106,13 @@ __shared_mutex_base::unlock_shared()...@@ -106,13 +106,13 @@ __shared_mutex_base::unlock_shared()
106106
107// Shared Timed Mutex107// Shared Timed Mutex
108// These routines are here for ABI stability108// These routines are here for ABI stability
109shared_timed_mutex::shared_timed_mutex() : __base() {}109shared_timed_mutex::shared_timed_mutex() : __base_() {}
110void shared_timed_mutex::lock() { return __base.lock(); }110void shared_timed_mutex::lock() { return __base_.lock(); }
111bool shared_timed_mutex::try_lock() { return __base.try_lock(); }111bool shared_timed_mutex::try_lock() { return __base_.try_lock(); }
112void shared_timed_mutex::unlock() { return __base.unlock(); }112void shared_timed_mutex::unlock() { return __base_.unlock(); }
113void shared_timed_mutex::lock_shared() { return __base.lock_shared(); }113void shared_timed_mutex::lock_shared() { return __base_.lock_shared(); }
114bool shared_timed_mutex::try_lock_shared() { return __base.try_lock_shared(); }114bool shared_timed_mutex::try_lock_shared() { return __base_.try_lock_shared(); }
115void shared_timed_mutex::unlock_shared() { return __base.unlock_shared(); }115void shared_timed_mutex::unlock_shared() { return __base_.unlock_shared(); }
116116
117_LIBCPP_END_NAMESPACE_STD117_LIBCPP_END_NAMESPACE_STD
118118
lib/libcxx/src/string.cpp+2-2
...@@ -85,7 +85,7 @@ template<typename V, typename S, typename F>...@@ -85,7 +85,7 @@ template<typename V, typename S, typename F>
85inline V as_integer_helper(const string& func, const S& str, size_t* idx, int base, F f) {85inline V as_integer_helper(const string& func, const S& str, size_t* idx, int base, F f) {
86 typename S::value_type* ptr = nullptr;86 typename S::value_type* ptr = nullptr;
87 const typename S::value_type* const p = str.c_str();87 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;
89 errno = 0;89 errno = 0;
90 V r = f(p, &ptr, base);90 V r = f(p, &ptr, base);
91 swap(errno, errno_save);91 swap(errno, errno_save);
...@@ -172,7 +172,7 @@ template<typename V, typename S, typename F>...@@ -172,7 +172,7 @@ template<typename V, typename S, typename F>
172inline V as_float_helper(const string& func, const S& str, size_t* idx, F f) {172inline V as_float_helper(const string& func, const S& str, size_t* idx, F f) {
173 typename S::value_type* ptr = nullptr;173 typename S::value_type* ptr = nullptr;
174 const typename S::value_type* const p = str.c_str();174 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;
176 errno = 0;176 errno = 0;
177 V r = f(p, &ptr);177 V r = f(p, &ptr);
178 swap(errno, errno_save);178 swap(errno, errno_save);
lib/libcxx/src/support/ibm/wcsnrtombs.cpp+1-1
...@@ -14,7 +14,7 @@...@@ -14,7 +14,7 @@
14// Converts `max_source_chars` from the wide character buffer pointer to by *`src`,14// Converts `max_source_chars` from the wide character buffer pointer to by *`src`,
15// into the multi byte character sequence buffer stored at `dst`, which must be15// into the multi byte character sequence buffer stored at `dst`, which must be
16// `dst_size_bytes` bytes in size. Returns the number of bytes in the sequence16// `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.
18// Returns (size_t) -1 if an error occurs and sets errno.18// Returns (size_t) -1 if an error occurs and sets errno.
19// If `dst` is NULL, `dst_size_bytes` is ignored and no bytes are copied to `dst`.19// If `dst` is NULL, `dst_size_bytes` is ignored and no bytes are copied to `dst`.
20_LIBCPP_FUNC_VIS20_LIBCPP_FUNC_VIS
lib/libcxx/src/support/runtime/stdexcept_vcruntime.ipp+1-1
...@@ -7,7 +7,7 @@...@@ -7,7 +7,7 @@
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#ifndef _LIBCPP_ABI_VCRUNTIME9#ifndef _LIBCPP_ABI_VCRUNTIME
10#error This file may only be used when defering to vcruntime10#error This file may only be used when deferring to vcruntime
11#endif11#endif
1212
13namespace std {13namespace std {
lib/libcxx/src/thread.cpp+1-1
...@@ -164,8 +164,8 @@ __thread_struct_imp::~__thread_struct_imp()...@@ -164,8 +164,8 @@ __thread_struct_imp::~__thread_struct_imp()
164 for (_Notify::iterator i = notify_.begin(), e = notify_.end();164 for (_Notify::iterator i = notify_.begin(), e = notify_.end();
165 i != e; ++i)165 i != e; ++i)
166 {166 {
167 i->second->unlock();
168 i->first->notify_all();167 i->first->notify_all();
168 i->second->unlock();
169 }169 }
170 for (_AsyncStates::iterator i = async_states_.begin(), e = async_states_.end();170 for (_AsyncStates::iterator i = async_states_.begin(), e = async_states_.end();
171 i != e; ++i)171 i != e; ++i)